text stringlengths 93 16.4k | id stringlengths 20 40 | metadata dict | input_ids listlengths 45 2.05k | attention_mask listlengths 45 2.05k | complexity int64 1 9 |
|---|---|---|---|---|---|
#[test]
fn test_append_invalid_blocks() {
let mut rng: StdRng = SeedableRng::from_seed([1u8; 32]);
let mut ledger_db = create_db();
let account_key = AccountKey::random(&mut rng);
let (origin_block, origin_block_contents) = get_origin_block_and_contents(&account_key);
// append_block rejects a block with invalid id.
{
let mut block = origin_block.clone();
block.id.0[0] += 1;
assert_eq!(
ledger_db.append_block(&block, &origin_block_contents, None),
Err(Error::InvalidBlockID(block.id.clone()))
);
}
// append_block rejects a block with invalid contents hash.
{
let mut block = origin_block.clone();
block.contents_hash.0[0] += 1;
assert_eq!(
ledger_db.append_block(&block, &origin_block_contents, None),
Err(Error::InvalidBlockContents)
);
}
assert_eq!(
ledger_db.append_block(&origin_block, &origin_block_contents, None),
Ok(())
);
// append_block rejects a block with non-existent parent.
{
let tx_out = create_test_tx_out(&mut rng);
let key_images = vec![KeyImage::from(rng.next_u64())];
let outputs = vec![tx_out];
let block_contents = BlockContents {
key_images,
outputs,
..Default::default()
};
let bytes = [14u8; 32];
let bad_parent_id = BlockID::try_from(&bytes[..]).unwrap();
// This block has a bad parent id.
let block_one_bad = Block::new(
BLOCK_VERSION,
&bad_parent_id,
1,
origin_block.cumulative_txo_count,
&Default::default(),
&block_contents,
);
assert_eq!(
ledger_db.append_block(&block_one_bad, &block_contents, None),
Err(Error::InvalidParentBlockID(block_one_bad.parent_id.clone()))
);
// This block correctly has block zero as its parent.
let block_one_good = Block::new(
BLOCK_VERSION,
&origin_block.id,
1,
origin_block.cumulative_txo_count,
&Default::default(),
&block_contents,
);
assert_eq!(
ledger_db.append_block(&block_one_good, &block_contents, None),
Ok(())
);
}
} | rust_cleaned_test_functions.jsonl/118281 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1410
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26041,
31433,
25201,
368,
341,
286,
1077,
5206,
28422,
25,
42517,
49,
968,
284,
35822,
480,
49,
968,
486,
1499,
33809,
2561,
16,
84,
23,
26,
220,
18,
17,
2558,
286,
1077,
5206,
46933,
8685,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_persisted_dht() {
let log = NullLoggerBuilder.build().unwrap();
let store: HotColdDB<
MinimalEthSpec,
MemoryStore<MinimalEthSpec>,
MemoryStore<MinimalEthSpec>,
> = HotColdDB::open_ephemeral(StoreConfig::default(), ChainSpec::minimal(), log).unwrap();
let enrs = vec![Enr::from_str("enr:-IS4QHCYrYZbAKWCBRlAy5zzaDZXJBGkcnh4MHcBFZntXNFrdvJjX04jRzjzCBOonrkTfj499SZuOh8R33Ls8RRcy5wBgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQPKY0yuDUmstAHYpMa2_oxVtw0RW_QAdpzBQA8yWM0xOIN1ZHCCdl8").unwrap()];
let key = Hash256::from_slice(&DHT_DB_KEY.as_bytes());
store
.put_item(&key, &PersistedDht { enrs: enrs.clone() })
.unwrap();
let dht: PersistedDht = store.get_item(&key).unwrap().unwrap();
assert_eq!(dht.enrs, enrs);
} | rust_cleaned_test_functions.jsonl/76980 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 456
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
4975,
291,
814,
426,
368,
341,
286,
1077,
1487,
284,
18084,
7395,
3297,
13239,
1005,
15454,
543,
286,
1077,
3553,
25,
8007,
76418,
3506,
30558,
310,
75112,
65390,
8327,
345,
310,
13850,
6093,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_bad_workers_values() {
// Take the lock so changing the environment doesn't cause races.
let _env_lock = ENV_LOCK.lock().unwrap();
env::remove_var(CONFIG_ENV);
assert!(FullConfig::parse(r#"
[development]
workers = true
"#.to_string(), TEST_CONFIG_FILENAME).is_err());
assert!(FullConfig::parse(r#"
[production]
workers = "hello"
"#.to_string(), TEST_CONFIG_FILENAME).is_err());
assert!(FullConfig::parse(r#"
[staging]
workers = -1
"#.to_string(), TEST_CONFIG_FILENAME).is_err());
assert!(FullConfig::parse(r#"
[staging]
workers = 65536
"#.to_string(), TEST_CONFIG_FILENAME).is_err());
assert!(FullConfig::parse(r#"
[staging]
workers = 105836
"#.to_string(), TEST_CONFIG_FILENAME).is_err());
} | rust_cleaned_test_functions.jsonl/54709 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 480
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34199,
43557,
9146,
368,
341,
286,
442,
11778,
279,
5296,
773,
10018,
279,
4573,
3171,
944,
5240,
20588,
624,
286,
1077,
716,
3160,
9818,
284,
32791,
27661,
21003,
1005,
15454,
543,
286,
6105,
486... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_get_schema_none() {
let mut transaction_context = MockTransactionContext::default();
let state = TrackAndTraceState::new(&mut transaction_context);
let result = state.get_schema("not_an_schema").unwrap();
assert!(result.is_none())
} | rust_cleaned_test_functions.jsonl/116992 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 116
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
25371,
31488,
368,
341,
286,
1077,
5206,
7745,
8467,
284,
14563,
8070,
1972,
486,
2258,
543,
286,
1077,
1584,
284,
19785,
3036,
6550,
1397,
486,
931,
2099,
6984,
7745,
8467,
626,
286,
1077,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_accepting_nan(){
assert_eq!(
WeightedIndex::new(&[core::f32::NAN, 0.5]).unwrap_err(),
WeightedError::InvalidWeight,
);
assert_eq!(
WeightedIndex::new(&[core::f32::NAN]).unwrap_err(),
WeightedError::InvalidWeight,
);
assert_eq!(
WeightedIndex::new(&[0.5, core::f32::NAN]).unwrap_err(),
WeightedError::InvalidWeight,
);
assert_eq!(
WeightedIndex::new(&[0.5, 7.0])
.unwrap()
.update_weights(&[(0, &core::f32::NAN)])
.unwrap_err(),
WeightedError::InvalidWeight,
)
} | rust_cleaned_test_functions.jsonl/86248 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 396
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
35728,
287,
73936,
3032,
286,
2060,
10714,
33673,
310,
16516,
291,
1552,
486,
931,
2099,
58,
2153,
486,
69,
18,
17,
486,
45,
1093,
11,
220,
15,
13,
20,
10697,
15454,
9266,
3148,
310,
16516,
29... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_find_floki_yaml_sibling() -> Result<(), Error> {
let tmp_dir = tempdir::TempDir::new("")?;
let floki_yaml_path = tmp_dir.path().join("src/floki.yaml");
touch_file(&floki_yaml_path)?;
assert!(find_floki_yaml(&tmp_dir.path().join("include")).is_err());
Ok(())
} | rust_cleaned_test_functions.jsonl/69267 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 160
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21814,
761,
385,
6642,
64380,
96328,
368,
1464,
5714,
68843,
4600,
29,
341,
286,
1077,
4174,
4334,
284,
2730,
3741,
486,
12151,
6184,
486,
931,
39047,
37445,
286,
1077,
9744,
6642,
64380,
2638,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_clone_path() {
let home = Path::new("/src");
[
(
"https://github.com/influxdata/influxdb2-sample-data.git",
"/src/github.com/influxdata/influxdb2-sample-data",
),
(
"https://github.com/influxdata/influxdb2-sample-data",
"/src/github.com/influxdata/influxdb2-sample-data",
),
("github.com/zesterer/tao", "/src/github.com/zesterer/tao"),
(
"github.com/denoland/deno/",
"/src/github.com/denoland/deno/",
),
(
"git@github.com:wezm/git-grab.git",
"/src/github.com/wezm/git-grab",
),
("git.sr.ht/~wezm/lobsters", "/src/git.sr.ht/~wezm/lobsters"),
(
"git@git.sr.ht:~wezm/lobsters",
"/src/git.sr.ht/~wezm/lobsters",
),
(
"bitbucket.org/egrange/dwscript",
"/src/bitbucket.org/egrange/dwscript",
),
("git://c9x.me/qbe.git", "/src/c9x.me/qbe"),
]
.iter()
.for_each(|(url, expected)| {
assert_eq!(
clone_path(home, &parse_url(url).unwrap()).unwrap(),
PathBuf::from(expected)
)
});
} | rust_cleaned_test_functions.jsonl/117918 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 866
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
54742,
2638,
368,
341,
286,
1077,
2114,
284,
7933,
486,
931,
4283,
3548,
797,
286,
2278,
310,
2399,
394,
330,
2428,
1110,
5204,
905,
17996,
36706,
691,
17996,
36706,
1999,
17,
83879,
13945,
32799,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_get_all_tables() -> common_exception::Result<()> {
// prepare test data
let mut fake_apis = FakeStoreApis::new();
fake_apis.insert_db(0, "test");
fake_apis.insert_tbl("test", TableInfo {
id: 0,
ver: 0,
name: "t1".to_string(),
schema: Arc::new(DataSchema::empty()),
});
fake_apis.inject_inconsistent_meta_state = true;
let provider = Arc::new(FakeStoreApisProvider::new(fake_apis));
let store_client = RemoteMetaStoreClient::with_timeout_setting(provider, None);
// illegal meta state
let res = store_client.get_all_tables();
assert!(res.is_err());
if let Err(err) = res {
assert_eq!(err.code(), ErrorCode::IllegalMetaState("").code());
}
// prepare test data
let mut fake_apis = FakeStoreApis::new();
fake_apis.insert_db(0, "test");
fake_apis.insert_tbl("test", TableInfo {
id: 0,
ver: 0,
name: "t1".to_string(),
schema: Arc::new(DataSchema::empty()),
});
let provider = Arc::new(FakeStoreApisProvider::new(fake_apis));
let store_client = RemoteMetaStoreClient::create(provider);
// normal case
let res = store_client.get_all_tables()?;
assert_eq!(res.len(), 1);
Ok(())
} | rust_cleaned_test_functions.jsonl/59318 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 544
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
5705,
35632,
368,
1464,
4185,
17499,
486,
2077,
71698,
341,
262,
442,
10549,
1273,
821,
198,
262,
1077,
5206,
12418,
62,
13725,
284,
36965,
6093,
91121,
486,
931,
543,
262,
12418,
62,
13725,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_shabal384_hash_bytes() {
let bytes = b"password";
let hash = Shabal384Hasher.hash((), bytes).unwrap();
assert_eq!("673f98958f04371edad63fe095e6903fdf894324b9944f36a6828e2b8b6dd2f4986cd4a61e29bf2866f021bbbaa02e8a", hash.as_hex());
} | rust_cleaned_test_functions.jsonl/65768 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 146
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3712,
62794,
18,
23,
19,
8950,
12524,
368,
341,
286,
1077,
5820,
284,
293,
1,
3833,
3302,
286,
1077,
5175,
284,
1417,
62794,
18,
23,
19,
6370,
261,
15101,
7,
1507,
5820,
568,
15454,
1428,
286,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_bittestandset() {
unsafe {
let mut a = 0b0101_0000i32;
assert_eq!(_bittestandset(&mut a as _, 4), 1);
assert_eq!(_bittestandset(&mut a as _, 4), 1);
assert_eq!(_bittestandset(&mut a as _, 5), 0);
assert_eq!(_bittestandset(&mut a as _, 5), 1);
}
} | rust_cleaned_test_functions.jsonl/46671 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 198
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
880,
14267,
437,
746,
368,
341,
286,
19860,
341,
310,
1077,
5206,
264,
284,
220,
15,
65,
15,
16,
15,
16,
62,
15,
15,
15,
15,
72,
18,
17,
280,
310,
2060,
10714,
0,
2490,
65,
14267,
437,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_named_struct() {
let test_data: Vec<u8> = [
0xFF,
0b1001_0110,
0xAA,
0xBB,
0xCC,
0xDD,
0b1001_0110,
0xCC,
0xDD,
0x02,
0xBE,
0xEF,
]
.to_vec();
// Read
let ret_read = samples::NamedDeku::try_from(test_data.as_ref()).unwrap();
assert_eq!(
samples::NamedDeku {
field_a: 0xFF,
field_b: 0b0000_0010,
field_c: 0b0001_0110,
field_d: 0xBBAA,
field_e: 0xCCDD,
field_f: samples::NestedDeku {
nest_a: 0b00_100101,
nest_b: 0b10,
inner: samples::DoubleNestedDeku { data: 0xDDCC }
},
vec_len: 0x02,
vec_data: vec![0xBE, 0xEF]
},
ret_read
);
// Write
let ret_write: Vec<u8> = ret_read.try_into().unwrap();
assert_eq!(test_data, ret_write);
} | rust_cleaned_test_functions.jsonl/123224 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 615
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
71834,
15126,
368,
341,
262,
1077,
1273,
1769,
25,
11312,
34837,
23,
29,
284,
2278,
286,
220,
15,
9264,
345,
286,
220,
15,
65,
16,
15,
15,
16,
62,
15,
16,
16,
15,
345,
286,
220,
15,
60051,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_lerp() {
let c1 = XyY::new(0.3, 0.1, 0.6);
let c2 = XyY::new(0.8, 0.2, 0.6);
assert_relative_eq!(c1.lerp(&c2, 0.00), c1);
assert_relative_eq!(c1.lerp(&c2, 1.00), c2);
assert_relative_eq!(c1.lerp(&c2, 0.50), XyY::new(0.55, 0.15, 0.6));
} | rust_cleaned_test_functions.jsonl/67707 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 191
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
907,
22632,
368,
341,
286,
1077,
272,
16,
284,
1599,
88,
56,
486,
931,
7,
15,
13,
18,
11,
220,
15,
13,
16,
11,
220,
15,
13,
21,
317,
286,
1077,
272,
17,
284,
1599,
88,
56,
486,
931,
7,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_assert_token() {
assert!(assert_token(Some("a"), "a").is_ok());
assert!(assert_token(Some("a"), "b").is_err());
assert!(assert_token(None, "b").is_err());
} | rust_cleaned_test_functions.jsonl/37568 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 100
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16553,
6458,
368,
341,
286,
2060,
10297,
2207,
6458,
65405,
445,
64,
3975,
330,
64,
1827,
285,
19817,
1423,
286,
2060,
10297,
2207,
6458,
65405,
445,
64,
3975,
330,
65,
1827,
285,
9266,
1423,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_serde_hashmap_reader() {
let mut map = HashMap::new();
map.insert(SmolStr::new("a"), SmolStr::new("ohno"));
let s = serde_json::to_string(&map).unwrap();
let _s: HashMap<SmolStr, SmolStr> =
serde_json::from_reader(std::io::Cursor::new(s)).unwrap();
} | rust_cleaned_test_functions.jsonl/106854 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 159
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
75861,
450,
8950,
2186,
22306,
368,
341,
286,
1077,
5206,
2415,
284,
10528,
486,
931,
543,
286,
2415,
7030,
3759,
44344,
2580,
486,
931,
445,
64,
3975,
4388,
337,
2580,
486,
931,
445,
2267,
2152... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_peekable() {
let path = TempDir::new("test-raftstore").unwrap();
let engine = new_temp_engine(&path);
let mut r = Region::new();
r.set_id(10);
r.set_start_key(b"key0".to_vec());
r.set_end_key(b"key4".to_vec());
let store = new_peer_storage(engine.clone(), &r);
let (key1, value1) = (b"key1", 2u64);
engine.put_u64(&data_key(key1), value1).expect("");
let (key2, value2) = (b"key2", 2i64);
engine.put_i64(&data_key(key2), value2).expect("");
let key3 = b"key3";
engine.put_msg(&data_key(key3), &r).expect("");
let snap = RegionSnapshot::new(&store);
let v1 = snap.get_u64(key1).expect("");
assert_eq!(v1, Some(value1));
let v2 = snap.get_i64(key2).expect("");
assert_eq!(v2, Some(value2));
let v3 = snap.get_msg(key3).expect("");
assert_eq!(v3, Some(r));
let v0 = snap.get_value(b"key0").expect("");
assert!(v0.is_none());
let v4 = snap.get_value(b"key5");
assert!(v4.is_err());
} | rust_cleaned_test_functions.jsonl/37247 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 574
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
29107,
480,
368,
341,
286,
1077,
1815,
284,
19944,
6184,
486,
931,
445,
1944,
12,
2944,
4314,
1827,
15454,
543,
286,
1077,
4712,
284,
501,
11771,
24823,
2099,
2343,
317,
286,
1077,
5206,
435... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_load_words() {
let w = load_pgpwords();
assert_eq!(w.len(), 2);
assert_eq!(w[0][0], "adroitness");
assert_eq!(w[1][0], "aardvark");
assert_eq!(w[0][255], "yucatan");
assert_eq!(w[1][255], "zulu");
} | rust_cleaned_test_functions.jsonl/132782 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 156
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12411,
18981,
368,
341,
286,
1077,
289,
284,
2795,
620,
21888,
5761,
543,
286,
2060,
10714,
10297,
86,
19406,
1507,
220,
17,
317,
286,
2060,
10714,
10297,
86,
58,
15,
1457,
15,
1125,
330,
89676,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parse_pos() {
// The empty string is an error
assert!(parse_pos("").is_err());
// Zero is an error
let res = parse_pos("0");
assert!(res.is_err());
assert_eq!(res.unwrap_err().to_string(), "illegal list value: \"0\"",);
let res = parse_pos("0-1");
assert!(res.is_err());
assert_eq!(res.unwrap_err().to_string(), "illegal list value: \"0\"",);
// A leading "+" is an error
let res = parse_pos("+1");
assert!(res.is_err());
assert_eq!(
res.unwrap_err().to_string(),
"illegal list value: \"+1\"",
);
let res = parse_pos("+1-2");
assert!(res.is_err());
assert_eq!(
res.unwrap_err().to_string(),
"illegal list value: \"+1-2\"",
);
let res = parse_pos("1-+2");
assert!(res.is_err());
assert_eq!(
res.unwrap_err().to_string(),
"illegal list value: \"1-+2\"",
);
// Any non-number is an error
let res = parse_pos("a");
assert!(res.is_err());
assert_eq!(res.unwrap_err().to_string(), "illegal list value: \"a\"",);
let res = parse_pos("1,a");
assert!(res.is_err());
assert_eq!(res.unwrap_err().to_string(), "illegal list value: \"a\"",);
let res = parse_pos("1-a");
assert!(res.is_err());
assert_eq!(
res.unwrap_err().to_string(),
"illegal list value: \"1-a\"",
);
let res = parse_pos("a-1");
assert!(res.is_err());
assert_eq!(
res.unwrap_err().to_string(),
"illegal list value: \"a-1\"",
);
// Wonky ranges
let res = parse_pos("-");
assert!(res.is_err());
let res = parse_pos(",");
assert!(res.is_err());
let res = parse_pos("1,");
assert!(res.is_err());
let res = parse_pos("1-");
assert!(res.is_err());
let res = parse_pos("1-1-1");
assert!(res.is_err());
let res = parse_pos("1-1-a");
assert!(res.is_err());
// First number must be less than second
let res = parse_pos("1-1");
assert!(res.is_err());
assert_eq!(
res.unwrap_err().to_string(),
"First number in range (1) must be lower than second number (1)"
);
let res = parse_pos("2-1");
assert!(res.is_err());
assert_eq!(
res.unwrap_err().to_string(),
"First number in range (2) must be lower than second number (1)"
);
// All the following are acceptable
let res = parse_pos("1");
assert!(res.is_ok());
assert_eq!(res.unwrap(), vec![0..1]);
let res = parse_pos("01");
assert!(res.is_ok());
assert_eq!(res.unwrap(), vec![0..1]);
let res = parse_pos("1,3");
assert!(res.is_ok());
assert_eq!(res.unwrap(), vec![0..1, 2..3]);
let res = parse_pos("001,0003");
assert!(res.is_ok());
assert_eq!(res.unwrap(), vec![0..1, 2..3]);
let res = parse_pos("1-3");
assert!(res.is_ok());
assert_eq!(res.unwrap(), vec![0..3]);
let res = parse_pos("0001-03");
assert!(res.is_ok());
assert_eq!(res.unwrap(), vec![0..3]);
let res = parse_pos("1,7,3-5");
assert!(res.is_ok());
assert_eq!(res.unwrap(), vec![0..1, 6..7, 2..5]);
let res = parse_pos("15,19-20");
assert!(res.is_ok());
assert_eq!(res.unwrap(), vec![14..15, 18..20]);
} | rust_cleaned_test_functions.jsonl/34698 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1887
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
6479,
368,
341,
286,
442,
576,
4287,
914,
374,
458,
1465,
198,
286,
2060,
10297,
6400,
6479,
80821,
285,
9266,
5231,
286,
442,
18306,
374,
458,
1465,
198,
286,
1077,
592,
284,
4715,
6479,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ver_forces_meta_enabled() {
assert!(!ver_forces_meta_enabled(Version::V1));
assert!(!ver_forces_meta_enabled(Version::V2));
assert!(!ver_forces_meta_enabled(Version::V3));
assert!(ver_forces_meta_enabled(Version::V17));
assert!(ver_forces_meta_enabled(Version::V18));
assert!(ver_forces_meta_enabled(Version::V19));
} | rust_cleaned_test_functions.jsonl/107026 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 148
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26042,
5478,
1603,
13381,
18220,
368,
341,
262,
2060,
0,
3471,
423,
5478,
1603,
13381,
18220,
7,
5637,
486,
53,
16,
1106,
262,
2060,
0,
3471,
423,
5478,
1603,
13381,
18220,
7,
5637,
486,
53,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_wasted_bit_decode() {
let mut output = [0; 4];
let constant = Subframe {
data: subframe::Data::Constant(1),
wasted_bits: 10,
};
decode(&constant, 4, &mut output);
assert_eq!(&output, &[1024, 1024, 1024, 1024]);
} | rust_cleaned_test_functions.jsonl/61779 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 120
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1670,
15036,
13996,
15227,
368,
341,
262,
1077,
5206,
2550,
284,
508,
15,
26,
220,
19,
4821,
262,
1077,
6783,
284,
3719,
6763,
341,
414,
821,
25,
1186,
6763,
486,
1043,
486,
15472,
7,
16,
1326... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_deserialize() {
let p = Packet::deserialize(&vec![
SOP,
0b00010010,
0x00,
Device::SomeDevice1 as u8,
Command::SomeCommand1 as u8,
22,
1,
123,
EOP
]);
println!("{:?}", p);
assert!(p.is_ok());
} | rust_cleaned_test_functions.jsonl/43361 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 236
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15768,
9050,
368,
341,
286,
1077,
281,
284,
28889,
486,
66777,
2099,
4083,
90515,
310,
86507,
345,
310,
220,
15,
65,
15,
15,
15,
16,
15,
15,
16,
15,
345,
310,
220,
15,
87,
15,
15,
345,
310... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_search_artist() {
let mut oauth = SpotifyOAuth::default().scope("user-read-private").build();
match get_token(&mut oauth) {
Some(token_info) => {
let client_credential = SpotifyClientCredentials::default()
.token_info(token_info)
.build();
let spotify = Spotify::default()
.client_credentials_manager(client_credential)
.build();
let query = "tania bowra";
let result = spotify.search_artist(query, 10, 0, Some(Country::UnitedStates));
assert!(result.is_ok());
}
None => assert!(false),
};
} | rust_cleaned_test_functions.jsonl/79276 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 323
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10716,
66840,
368,
341,
262,
1077,
5206,
46415,
284,
40537,
57850,
486,
2258,
1005,
4186,
445,
872,
28806,
65277,
1827,
5834,
543,
262,
2432,
633,
6458,
2099,
6984,
46415,
8,
341,
286,
4329,
13274... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_nodeid() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin(BIN_NAME)?;
cmd.arg("nodeid")
.arg("--pubkey")
.arg("cde8fbf86c44e4ed2095f83b6f3c97b7aec55a77e06e843f8b9ffeab66ad4b32");
cmd.assert()
.success()
.stdout(predicate::str::contains("cdae19f3d5a96d016e74d656ef15e35839b554ae2590bec0dce5e6608cb7f837"));
let mut cmd = Command::cargo_bin(BIN_NAME)?;
cmd.arg("nodeid")
.arg("--keypair")
.arg("tests/samples/exp.json");
cmd.assert()
.success()
.stdout(predicate::str::contains("e8c5df53b6205e8db639629d2cd2552b354501021a9f223bb72e81e75f37f64a"));
let mut cmd = Command::cargo_bin(BIN_NAME)?;
cmd.arg("nodeid")
.arg("--keypair")
.arg("ghost frost pool buzz rival mad naive rare shell tooth smart praise");
cmd.assert()
.success()
.stdout(predicate::str::contains("e8c5df53b6205e8db639629d2cd2552b354501021a9f223bb72e81e75f37f64a"));
Ok(())
} | rust_cleaned_test_functions.jsonl/118322 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 523
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5084,
307,
368,
1464,
5714,
68843,
8261,
92846,
1460,
486,
841,
486,
1454,
2452,
341,
262,
1077,
5206,
5439,
284,
7348,
486,
66715,
21816,
5349,
687,
4708,
40007,
262,
5439,
21186,
445,
3509,
307,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
#[test]
fn test_json_basic_with_nulls() {
let builder = ReaderBuilder::new().infer_schema(None).with_batch_size(64);
let mut reader: Reader<File> = builder
.build::<File>(File::open("test/data/basic_nulls.json").unwrap())
.unwrap();
let batch = reader.next().unwrap().unwrap();
assert_eq!(4, batch.num_columns());
assert_eq!(12, batch.num_rows());
let schema = reader.schema();
let batch_schema = batch.schema();
assert_eq!(schema, batch_schema);
let a = schema.column_with_name("a").unwrap();
assert_eq!(&DataType::Int64, a.1.data_type());
let b = schema.column_with_name("b").unwrap();
assert_eq!(&DataType::Float64, b.1.data_type());
let c = schema.column_with_name("c").unwrap();
assert_eq!(&DataType::Boolean, c.1.data_type());
let d = schema.column_with_name("d").unwrap();
assert_eq!(&DataType::Utf8, d.1.data_type());
let aa = batch
.column(a.0)
.as_any()
.downcast_ref::<Int64Array>()
.unwrap();
assert!(aa.is_valid(0));
assert!(!aa.is_valid(1));
assert!(!aa.is_valid(11));
let bb = batch
.column(b.0)
.as_any()
.downcast_ref::<Float64Array>()
.unwrap();
assert!(bb.is_valid(0));
assert!(!bb.is_valid(2));
assert!(!bb.is_valid(11));
let cc = batch
.column(c.0)
.as_any()
.downcast_ref::<BooleanArray>()
.unwrap();
assert!(cc.is_valid(0));
assert!(!cc.is_valid(4));
assert!(!cc.is_valid(11));
let dd = batch
.column(d.0)
.as_any()
.downcast_ref::<StringArray>()
.unwrap();
assert!(!dd.is_valid(0));
assert!(dd.is_valid(1));
assert!(!dd.is_valid(4));
assert!(!dd.is_valid(11));
} | rust_cleaned_test_functions.jsonl/22587 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1065
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9455,
34729,
6615,
15162,
82,
368,
341,
286,
1077,
7363,
284,
25166,
3297,
486,
931,
1005,
89559,
25371,
26717,
568,
4197,
14534,
2368,
7,
21,
19,
317,
286,
1077,
5206,
6604,
25,
25166,
52014,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_buffered_stream() {
struct S;
impl io::Writer for S {
fn write(&mut self, _: &[u8]) -> io::IoResult<()> { Ok(()) }
}
impl io::Reader for S {
fn read(&mut self, _: &mut [u8]) -> io::IoResult<uint> {
Err(io::standard_error(io::EndOfFile))
}
}
let mut stream = BufferedStream::new(S);
let mut buf = [];
assert!(stream.read(&mut buf).is_err());
stream.write(&buf).unwrap();
stream.flush().unwrap();
} | rust_cleaned_test_functions.jsonl/52988 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 289
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7776,
291,
12673,
368,
341,
286,
2036,
328,
401,
286,
11605,
6399,
486,
6492,
369,
328,
341,
310,
5168,
3270,
2099,
6984,
656,
11,
58536,
44590,
84,
23,
2467,
1464,
6399,
486,
42799,
2077,
71698... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_construct_subtree_three_siblings() {
// x
// [4; 32] c y
// z b [3; 32]
// node a [2; 32]
let key = b"hello".test_only_hash();
let blob = AccountStateBlob::from(b"world".to_vec());
let leaf_hash = hash_leaf(key, blob.hash());
let node = SparseMerkleNode::new_leaf(key, LeafValue::BlobHash(blob.hash()));
let bits = vec![false, false, true];
let a_hash = HashValue::new([2; HashValue::LENGTH]);
let b_hash = HashValue::new([3; HashValue::LENGTH]);
let c_hash = HashValue::new([4; HashValue::LENGTH]);
let siblings = vec![a_hash, b_hash, c_hash]
.into_iter()
.map(|hash| Arc::new(SparseMerkleNode::new_subtree(hash)));
let subtree_node =
SparseMerkleTree::construct_subtree(bits.into_iter(), siblings, Arc::new(node));
let smt = SparseMerkleTree { root: subtree_node };
let z_hash = hash_internal(leaf_hash, a_hash);
let y_hash = hash_internal(z_hash, b_hash);
let root_hash = hash_internal(c_hash, y_hash);
assert_eq!(smt.root_hash(), root_hash);
} | rust_cleaned_test_functions.jsonl/15411 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 525
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
64803,
5228,
9344,
50016,
643,
24229,
368,
341,
262,
442,
394,
856,
7213,
262,
442,
414,
508,
19,
26,
220,
18,
17,
60,
272,
256,
379,
7213,
262,
442,
394,
1147,
256,
293,
508,
18,
26,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_find_labels() {
check(
r#"
fn foo<'a>() -> &'a () {
'a: loop {
'b: loop {
continue 'a<|>;
}
break 'a;
}
}
"#,
expect![[r#"
'a Label FileId(0) 29..32 29..31 Lifetime
FileId(0) 80..82 Lifetime
FileId(0) 108..110 Lifetime
"#]],
);
} | rust_cleaned_test_functions.jsonl/79347 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 260
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21814,
14547,
368,
341,
286,
1779,
1006,
310,
435,
2,
698,
8822,
15229,
18291,
64,
13555,
1464,
30136,
64,
1719,
341,
262,
364,
64,
25,
6337,
341,
286,
364,
65,
25,
6337,
341,
310,
3060,
364,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_skip_constraint_check() {
let engine = TestEngineBuilder::new().build().unwrap();
let (key, value) = (b"key", b"value");
must_prewrite_put(&engine, key, value, key, 5);
must_commit(&engine, key, 5, 10);
let ctx = Context::default();
let snapshot = engine.snapshot(&ctx).unwrap();
let cm = ConcurrencyManager::new(10.into());
let mut txn = MvccTxn::new(snapshot, 5.into(), true, cm.clone());
assert!(prewrite(
&mut txn,
Mutation::Put((Key::from_raw(key), value.to_vec())),
key,
&None,
false,
0,
0,
TimeStamp::default(),
TimeStamp::default(),
)
.is_err());
let ctx = Context::default();
let snapshot = engine.snapshot(&ctx).unwrap();
let mut txn = MvccTxn::new(snapshot, 5.into(), true, cm);
assert!(prewrite(
&mut txn,
Mutation::Put((Key::from_raw(key), value.to_vec())),
key,
&None,
true,
0,
0,
TimeStamp::default(),
TimeStamp::default(),
)
.is_ok());
} | rust_cleaned_test_functions.jsonl/35962 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 667
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
44830,
46973,
7200,
368,
341,
286,
1077,
4712,
284,
3393,
4571,
3297,
486,
931,
1005,
5834,
1005,
15454,
543,
286,
1077,
320,
792,
11,
897,
8,
284,
320,
65,
1,
792,
497,
293,
63307,
3071,
286,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_encode_decode_utf8_string_invalid() {
let bytes = b"\x80\xae".to_vec();
let src = unsafe { String::from_utf8_unchecked(bytes) };
let doc = doc!{ "key": src };
let mut buf = Vec::new();
encode_document(&mut buf, &doc).unwrap();
let expected = doc!{ "key": "��" };
let decoded = decode_document_utf8_lossy(&mut Cursor::new(buf)).unwrap();
assert_eq!(decoded, expected);
} | rust_cleaned_test_functions.jsonl/69699 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 177
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11224,
15227,
39453,
23,
3904,
31433,
368,
341,
262,
1077,
5820,
284,
293,
11934,
87,
23,
15,
3462,
5918,
3263,
983,
13251,
543,
262,
1077,
2286,
284,
19860,
314,
923,
486,
1499,
39453,
23,
4907... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ec_mul() {
let input = &hex_decode("089142debb13c461f61523586a60732d8b69c5b38a3380a74da7b2961d867dbf2d5fc7bbc013c16d7945f190b232eacc25da675c0eb093fe6b9f1b4b4e107b36ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap();
let output = hex_decode("0bf982b98a2757878c051bfe7eee228b12bc69274b918f08d9fcb21e9184ddc10b17c77cbf3c19d5d27e18cbd4a8c336afb488d0e92c18d56e64dd4ea5c437e6").unwrap();
test_precompile!(EcMul, input, output, 6000);
let input = &hex_decode("25f8c89ea3437f44f8fc8b6bfbb6312074dc6f983809a5e809ff4e1d076dd5850b38c7ced6e4daef9c4347f370d6d8b58f4b1d8dc61a3c59d651a0644a2a27cfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap();
let output = hex_decode("18a902ac147b2951531770c7c18a25e3dd87765e23f7e0c4e9d62b624a6e37450288473776e7e99b2aaa27e8f4656ea9ce5e634fd1ca1aab45315199ecaced2e").unwrap();
test_precompile!(EcMul, input, output, 6000);
let input = &hex_decode("23f16f1bcc31bd002746da6fa3825209af9a356ccd99cf79604a430dd592bcd90a03caeda9c5aa40cdc9e4166e083492885dad36c72714e3697e34a4bc72ccaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap();
let output = hex_decode("0c6a880ffdd0737c53bfec9b65c9098a3298747bd4e5fd07026661b4cb804331116aeec88e11f49753df224c60c4bd8b8bc0a98b8d50f24ce64475268d227f4c").unwrap();
test_precompile!(EcMul, input, output, 6000);
let input = &hex_decode("0341b65d1b32805aedf29c4704ae125b98bb9b736d6e05bd934320632bf46bb60d22bc985718acbcf51e3740c1565f66ff890dfd2302fc51abc999c83d8774baffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap();
let output = hex_decode("15bd6ea71fd264e1bfb04eb6d97b4f3686c5bf36f91356fc13ddde3494e172d90b3f8392fd4cdd5d542887ea4ee0274835bf37b58edf927ef242b8704af52e92").unwrap();
test_precompile!(EcMul, input, output, 6000);
let input = &hex_decode("1f752f85cf5cc01b2dfe279541032da61c2fcc8ae0dfc6d4253ba9b5d3c858231d03a84afe2a9f595ab03007400ccd36a2c0bc31203d881011dfc450c39b5abeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap();
let output = hex_decode("0aa7b6fda656f23eab50e36db0519cdf79f4624d417253085907ebfd9aef38a414cdd2edce2b313fc6dd390628ac9fac910841706d55f9af2a064548694dc05c").unwrap();
test_precompile!(EcMul, input, output, 6000);
} | rust_cleaned_test_functions.jsonl/51968 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1145
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36844,
24944,
368,
341,
262,
1077,
1946,
284,
609,
17308,
15227,
445,
15,
23,
24,
16,
19,
17,
450,
6066,
16,
18,
66,
19,
21,
16,
69,
21,
16,
20,
17,
18,
20,
23,
21,
64,
21,
15,
22,
18,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_add_full_ipv4() {
let event = DhcpEvent::LeaseAdded {
event_timestamp: DateTime::<FixedOffset>::from(Local::now()),
lease_info: full_lease_info_v4(),
};
assert_script_result_equal(event);
} | rust_cleaned_test_functions.jsonl/48439 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 131
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
16372,
49378,
19,
368,
341,
286,
1077,
1538,
284,
43227,
4672,
1556,
486,
2304,
519,
19337,
341,
310,
1538,
23073,
25,
6520,
27638,
13520,
6446,
6831,
1499,
42718,
486,
3328,
14702,
310,
250... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_temperature_converter_from_kelvin_to_celsius() {
let conv = TemperatureConverter::new(300.0, TemperatureUnit::Kelvin);
let res = conv.convert(TemperatureUnit::Celsius);
assert!(res.is_ok());
let res = res.unwrap();
assert!(is_close(26.85, res.scalar()), "res was {:?}", res.scalar());
assert_eq!(&TemperatureUnit::Celsius, res.unit());
} | rust_cleaned_test_functions.jsonl/76288 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 185
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
53525,
74073,
5673,
59222,
9603,
2346,
666,
40247,
368,
341,
286,
1077,
5686,
284,
37022,
14920,
486,
931,
7,
18,
15,
15,
13,
15,
11,
37022,
4562,
486,
84599,
9603,
317,
286,
1077,
592,
284,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_packet_new() {
let p = Packet::new(Action::SERVER_TIME, &[]);
assert_eq!(1i16, p.event_size);
assert_eq!(&Action::SERVER_TIME, &p.action);
assert_eq!(&[] as &[u8], &p.data[..]);
assert_eq!(&[0x01, 0x00, 0xC6], &p.as_bytes()[..]);
let p = Packet::new(Action::SERVER_TIME, &[0xEE, 0xEE]);
assert_eq!(3i16, p.event_size);
assert_eq!(&Action::SERVER_TIME, &p.action);
assert_eq!(&[0xEE, 0xEE][..], &p.data[..]);
assert_eq!(&[0x03, 0x00, 0xC6, 0xEE, 0xEE], &p.as_bytes()[..]);
} | rust_cleaned_test_functions.jsonl/54648 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 320
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21078,
5921,
368,
341,
286,
1077,
281,
284,
28889,
486,
931,
21905,
486,
12915,
10051,
11,
609,
56703,
286,
2060,
10714,
10297,
16,
72,
16,
21,
11,
281,
5773,
2368,
317,
286,
2060,
10714,
0,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_rollback_while_other_transaction_running() {
let engine = TestEngineBuilder::new().build().unwrap();
let (k, v) = (b"k1", b"v1");
must_prewrite_put_async_commit(&engine, k, v, k, &Some(vec![]), 10, 0);
must_cleanup(&engine, k, 15, 0);
must_commit(&engine, k, 10, 15);
let w = must_written(&engine, k, 10, 15, WriteType::Put);
assert!(w.has_overlapped_rollback);
// GC fence shouldn't be set in this case.
assert!(w.gc_fence.is_none());
must_prewrite_put_async_commit(&engine, k, v, k, &Some(vec![]), 20, 0);
check_txn_status::tests::must_success(&engine, k, 25, 0, 0, true, false, false, |s| {
s == TxnStatus::LockNotExist
});
must_commit(&engine, k, 20, 25);
let w = must_written(&engine, k, 20, 25, WriteType::Put);
assert!(w.has_overlapped_rollback);
assert!(w.gc_fence.is_none());
must_prewrite_put_async_commit(&engine, k, v, k, &Some(vec![]), 30, 0);
check_secondary_locks::tests::must_success(
&engine,
k,
35,
SecondaryLocksStatus::RolledBack,
);
must_commit(&engine, k, 30, 35);
let w = must_written(&engine, k, 30, 35, WriteType::Put);
assert!(w.has_overlapped_rollback);
assert!(w.gc_fence.is_none());
// Do not commit with overlapped_rollback if the rollback ts doesn't equal to commit_ts.
must_prewrite_put_async_commit(&engine, k, v, k, &Some(vec![]), 40, 0);
must_cleanup(&engine, k, 44, 0);
must_commit(&engine, k, 40, 45);
let w = must_written(&engine, k, 40, 45, WriteType::Put);
assert!(!w.has_overlapped_rollback);
// Do not put rollback mark to the lock if the lock is not async commit or if lock.ts is
// before start_ts or min_commit_ts.
must_prewrite_put(&engine, k, v, k, 50);
must_cleanup(&engine, k, 55, 0);
let l = must_locked(&engine, k, 50);
assert!(l.rollback_ts.is_empty());
must_commit(&engine, k, 50, 56);
must_prewrite_put_async_commit(&engine, k, v, k, &Some(vec![]), 60, 0);
must_cleanup(&engine, k, 59, 0);
let l = must_locked(&engine, k, 60);
assert!(l.rollback_ts.is_empty());
must_commit(&engine, k, 60, 65);
must_prewrite_put_async_commit(&engine, k, v, k, &Some(vec![]), 70, 75);
must_cleanup(&engine, k, 74, 0);
must_cleanup(&engine, k, 75, 0);
let l = must_locked(&engine, k, 70);
assert_eq!(l.min_commit_ts, 75.into());
assert_eq!(l.rollback_ts, vec![75.into()]);
} | rust_cleaned_test_functions.jsonl/16095 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1286
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
33559,
86069,
30456,
28884,
37333,
368,
341,
286,
1077,
4712,
284,
3393,
4571,
3297,
486,
931,
1005,
5834,
1005,
15454,
543,
286,
1077,
320,
74,
11,
348,
8,
284,
320,
65,
62911,
16,
497,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_mutex_arc_condvar() {
let arc = Arc::new((Mutex::new(false), Condvar::new()));
let arc2 = arc.clone();
let (tx, rx) = channel();
spawn(move|| {
// wait until parent gets in
rx.recv();
let &(ref lock, ref cvar) = &*arc2;
let mut lock = lock.lock();
*lock = true;
cvar.notify_one();
});
let &(ref lock, ref cvar) = &*arc;
let lock = lock.lock();
tx.send(());
assert!(!*lock);
while !*lock {
cvar.wait(&lock);
}
} | rust_cleaned_test_functions.jsonl/49615 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 340
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14204,
62914,
24433,
947,
368,
341,
286,
1077,
15580,
284,
19689,
486,
931,
1188,
38099,
486,
931,
3576,
701,
44826,
947,
486,
931,
7392,
286,
1077,
15580,
17,
284,
15580,
15997,
543,
286,
1077,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_zeroize_client_login_start() -> Result<(), ProtocolError> {
let mut client_rng = OsRng;
let client_login_start_result = ClientLogin::<RistrettoSha5123dhNoSlowHash>::start(
&mut client_rng,
STR_PASSWORD.as_bytes(),
ClientLoginStartParameters::default(),
)?;
let mut state = client_login_start_result.state;
let ptrs = state.as_byte_ptrs();
state.zeroize();
for (ptr, len) in ptrs {
let bytes = unsafe { from_raw_parts(ptr, len) };
assert!(bytes.iter().all(|&x| x == 0));
}
Ok(())
} | rust_cleaned_test_functions.jsonl/27847 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 255
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19359,
551,
8179,
13681,
4906,
368,
1464,
5714,
68843,
24572,
1454,
29,
341,
262,
1077,
5206,
2943,
66849,
284,
15433,
49,
968,
280,
262,
1077,
2943,
13681,
4906,
5287,
284,
8423,
6231,
27638,
49,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_uses_index_on_second_iteration() {
let mut encoder: Encoder = Encoder::new();
let headers = vec![(b"custom-key".to_vec(), b"custom-value".to_vec())];
let _ = encoder.encode_for_test(headers.iter().map(|h| (&h.0[..], &h.1[..])));
// Encode the same headers again!
let result = encoder.encode_for_test(headers.iter().map(|h| (&h.0[..], &h.1[..])));
// The header is in the encoder's dynamic table.
assert_eq!(encoder.header_table.dynamic_table.to_vec_of_vec(), headers);
// The output is a single index byte?
assert_eq!(result.len(), 1);
// The index is correctly encoded:
// - The most significant bit is set
assert_eq!(0x80 & result[0], 0x80);
// - The other 7 bits decode to an integer giving the index in the full
// header address space.
assert_eq!(result[0] ^ 0x80, 62);
// The header table actually contains the header at that index?
assert_eq!(
encoder.header_table.get_from_table_vec(62).unwrap(),
headers[0]
);
} | rust_cleaned_test_functions.jsonl/121975 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 505
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
4776,
3560,
4470,
29644,
62772,
368,
341,
286,
1077,
5206,
23668,
25,
55115,
284,
55115,
486,
931,
543,
286,
1077,
7102,
284,
7486,
0,
9697,
65,
1,
9163,
16173,
3263,
983,
13251,
1507,
293,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_waiter_notify() {
let (waiter, lock_info, f) = new_test_waiter(10.into(), 20.into(), 20);
waiter.notify();
expect_key_is_locked(f.wait().unwrap().unwrap(), lock_info);
// A waiter can conflict with other transactions more than once.
for conflict_times in 1..=3 {
let waiter_ts = TimeStamp::new(10);
let mut lock_ts = TimeStamp::new(20);
let (mut waiter, mut lock_info, f) = new_test_waiter(waiter_ts, lock_ts, 20);
let mut conflict_commit_ts = TimeStamp::new(30);
for _ in 0..conflict_times {
waiter.conflict_with(*lock_ts.incr(), *conflict_commit_ts.incr());
lock_info.set_lock_version(lock_ts.into_inner());
}
waiter.notify();
expect_write_conflict(f.wait().unwrap(), waiter_ts, lock_info, conflict_commit_ts);
}
// Deadlock
let waiter_ts = TimeStamp::new(10);
let (mut waiter, lock_info, f) = new_test_waiter(waiter_ts, 20.into(), 20);
waiter.deadlock_with(111);
waiter.notify();
expect_deadlock(f.wait().unwrap(), waiter_ts, lock_info, 111);
// Conflict then deadlock.
let waiter_ts = TimeStamp::new(10);
let (mut waiter, lock_info, f) = new_test_waiter(waiter_ts, 20.into(), 20);
waiter.conflict_with(20.into(), 30.into());
waiter.deadlock_with(111);
waiter.notify();
expect_deadlock(f.wait().unwrap(), waiter_ts, lock_info, 111);
} | rust_cleaned_test_functions.jsonl/32484 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 728
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18760,
261,
36654,
368,
341,
286,
1077,
320,
11489,
261,
11,
5296,
3109,
11,
282,
8,
284,
501,
4452,
18760,
261,
7,
16,
15,
39860,
1507,
220,
17,
15,
39860,
1507,
220,
17,
15,
317,
286,
6716... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_established_send_fin() {
let mut s = socket_established();
s.send_slice(b"abcdef").unwrap();
send!(s, TcpRepr {
control: TcpControl::Fin,
seq_number: REMOTE_SEQ + 1,
ack_number: Some(LOCAL_SEQ + 1),
..SEND_TEMPL
});
assert_eq!(s.state, State::CloseWait);
recv!(s, [TcpRepr {
seq_number: LOCAL_SEQ + 1,
ack_number: Some(REMOTE_SEQ + 1 + 1),
payload: &b"abcdef"[..],
..RECV_TEMPL
}]);
} | rust_cleaned_test_functions.jsonl/1730 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 327
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18583,
5102,
291,
13565,
39737,
368,
341,
286,
1077,
5206,
274,
284,
7575,
18583,
5102,
291,
543,
286,
274,
5219,
26488,
1883,
1,
41202,
1827,
15454,
543,
286,
3624,
10297,
82,
11,
64876,
693,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_dim_after_const_duplicate_definition() {
let program = r#"
CONST A = "hello"
DIM A AS STRING
"#;
assert_linter_err!(program, QError::DuplicateDefinition, 3, 17);
} | rust_cleaned_test_functions.jsonl/122455 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 116
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10791,
19844,
13610,
70434,
31698,
368,
341,
262,
1077,
2025,
284,
435,
2,
698,
310,
29602,
362,
284,
330,
14990,
698,
310,
50859,
362,
5752,
35255,
198,
310,
5869,
280,
262,
2060,
907,
2245,
92... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_from_size() {
let b = Box3D::from_size(size3(30.0, 40.0, 50.0));
assert!(b.min == Point3D::zero());
assert!(b.size().width == 30.0);
assert!(b.size().height == 40.0);
assert!(b.size().depth == 50.0);
} | rust_cleaned_test_functions.jsonl/7484 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 142
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5673,
2368,
368,
341,
286,
1077,
293,
284,
8261,
18,
35,
486,
1499,
2368,
6856,
18,
7,
18,
15,
13,
15,
11,
220,
19,
15,
13,
15,
11,
220,
20,
15,
13,
15,
1106,
286,
2060,
10297,
65,
4358,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_flow_control() {
// Disable CDC sink memory quota.
let (_server, client, mut task_rx) = new_rpc_suite();
// Create a event feed stream.
let (mut tx, mut rx) = client.event_feed().unwrap();
let mut req = ChangeDataRequest {
region_id: 1,
..Default::default()
};
req.mut_header().set_ticdc_version("4.0.7".into());
block_on(tx.send((req, WriteFlags::default()))).unwrap();
let task = task_rx.recv_timeout(Duration::from_millis(100)).unwrap();
let conn = if let Some(Task::OpenConn { conn }) = task {
conn
} else {
panic!("expect to be Task::OpenConn");
};
let sink = conn.get_sink().clone();
// Approximate 1 KB.
let mut rts = ResolvedTs::default();
rts.set_regions(vec![u64::MAX; 128]);
let send = || {
let rts_ = rts.clone();
let mut sink_ = sink.clone();
Box::pin(async move { sink_.send_all(vec![CdcEvent::ResolvedTs(rts_)]).await })
};
let must_fill_window = || {
let mut window_size = 0;
loop {
if poll_timeout(&mut send(), Duration::from_millis(100)).is_err() {
// Window is filled and flow control in sink is triggered.
break;
}
window_size += 1;
// gRPC window size should not be larger than 1GB.
assert!(window_size <= 1024 * 1024, "window_size: {}", window_size);
}
window_size
};
// Fill gRPC window.
let window_size = must_fill_window();
assert_ne!(window_size, 0);
recv_timeout(&mut rx, Duration::from_millis(100))
.unwrap()
.unwrap()
.unwrap();
poll_timeout(&mut send(), Duration::from_millis(100))
.unwrap()
.unwrap();
// though server should not be able to send messages infinitely.
let window_size = must_fill_window();
assert_ne!(window_size, 0);
} | rust_cleaned_test_functions.jsonl/32183 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1076
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
27441,
13436,
368,
341,
286,
442,
28027,
39309,
19309,
4938,
42042,
624,
286,
1077,
5453,
4030,
11,
2943,
11,
5206,
3383,
24330,
8,
284,
501,
60799,
57239,
543,
286,
442,
4230,
264,
1538,
5395,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
#[test]
fn test_floor() {
let cases = vec![
("12345", "12345"),
("0.99999", "0"),
("-0.99999", "-1"),
("18446744073709551615", "18446744073709551615"),
("18446744073709551616", "18446744073709551616"),
("-18446744073709551615", "-18446744073709551615"),
("-18446744073709551616", "-18446744073709551616"),
("-1", "-1"),
("1.23", "1"),
("-1.23", "-2"),
("00001.00000", "1"),
("-00001.00000", "-1"),
("9999999999999999999999999.001", "9999999999999999999999999"),
];
for (input, exp) in cases {
let dec: Decimal = input.parse().unwrap();
let exp: Decimal = exp.parse().unwrap();
let got = dec.floor().unwrap();
assert_eq!(got, exp);
}
} | rust_cleaned_test_functions.jsonl/13672 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 500
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
60044,
368,
341,
286,
1077,
5048,
284,
7486,
90515,
310,
3489,
16,
17,
18,
19,
20,
497,
330,
16,
17,
18,
19,
20,
4461,
310,
3489,
15,
13,
24,
24,
24,
24,
24,
497,
330,
15,
4461,
310,
986... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_ident() {
assert_eq!(ident(b"abcde").unwrap().1, "abcde");
assert_eq!(ident(b"hello1").unwrap().1, "hello1");
assert_eq!(ident(b"hell_o").unwrap().1, "hell_o");
assert!(ident(b"12a").is_err());
} | rust_cleaned_test_functions.jsonl/68319 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 133
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
38399,
368,
341,
286,
2060,
10714,
10297,
1713,
1883,
1,
13683,
450,
1827,
15454,
1005,
16,
11,
330,
13683,
450,
797,
286,
2060,
10714,
10297,
1713,
1883,
1,
14990,
16,
1827,
15454,
1005,
16,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_approximate_float() {
assert_eq!(Ratio::from_f32(0.5f32), Some(Ratio::new(1i64, 2)));
assert_eq!(Ratio::from_f64(0.5f64), Some(Ratio::new(1i32, 2)));
assert_eq!(Ratio::from_f32(5f32), Some(Ratio::new(5i64, 1)));
assert_eq!(Ratio::from_f64(5f64), Some(Ratio::new(5i32, 1)));
assert_eq!(Ratio::from_f32(29.97f32), Some(Ratio::new(2997i64, 100)));
assert_eq!(Ratio::from_f32(-29.97f32), Some(Ratio::new(-2997i64, 100)));
assert_eq!(Ratio::<i8>::from_f32(63.5f32), Some(Ratio::new(127i8, 2)));
assert_eq!(Ratio::<i8>::from_f32(126.5f32), Some(Ratio::new(126i8, 1)));
assert_eq!(Ratio::<i8>::from_f32(127.0f32), Some(Ratio::new(127i8, 1)));
assert_eq!(Ratio::<i8>::from_f32(127.5f32), None);
assert_eq!(Ratio::<i8>::from_f32(-63.5f32), Some(Ratio::new(-127i8, 2)));
assert_eq!(
Ratio::<i8>::from_f32(-126.5f32),
Some(Ratio::new(-126i8, 1))
);
assert_eq!(
Ratio::<i8>::from_f32(-127.0f32),
Some(Ratio::new(-127i8, 1))
);
assert_eq!(Ratio::<i8>::from_f32(-127.5f32), None);
assert_eq!(Ratio::<u8>::from_f32(-127f32), None);
assert_eq!(Ratio::<u8>::from_f32(127f32), Some(Ratio::new(127u8, 1)));
assert_eq!(Ratio::<u8>::from_f32(127.5f32), Some(Ratio::new(255u8, 2)));
assert_eq!(Ratio::<u8>::from_f32(256f32), None);
assert_eq!(Ratio::<i64>::from_f64(-10e200), None);
assert_eq!(Ratio::<i64>::from_f64(10e200), None);
assert_eq!(Ratio::<i64>::from_f64(f64::INFINITY), None);
assert_eq!(Ratio::<i64>::from_f64(f64::NEG_INFINITY), None);
assert_eq!(Ratio::<i64>::from_f64(f64::NAN), None);
assert_eq!(
Ratio::<i64>::from_f64(f64::EPSILON),
Some(Ratio::new(1, 4503599627370496))
);
assert_eq!(Ratio::<i64>::from_f64(0.0), Some(Ratio::new(0, 1)));
assert_eq!(Ratio::<i64>::from_f64(-0.0), Some(Ratio::new(0, 1)));
} | rust_cleaned_test_functions.jsonl/824 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1167
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
90425,
3426,
17586,
368,
341,
286,
2060,
10714,
10297,
22777,
486,
1499,
761,
18,
17,
7,
15,
13,
20,
69,
18,
17,
701,
4329,
2785,
6266,
486,
931,
7,
16,
72,
21,
19,
11,
220,
17,
4945,
286,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_hidden_prob_calc_active_connect() {
let mut network_config = NetworkConfig::new(
NetworkIdentifier::new(b"some_ssid".to_vec(), SecurityType::None),
Credential::None,
false,
)
.expect("Failed to create network config");
network_config.update_hidden_prob(HiddenProbEvent::ConnectActive);
assert_eq!(network_config.hidden_probability, PROB_HIDDEN_IF_CONNECT_ACTIVE);
// we won't care that we previously needed an active scan.
network_config.update_hidden_prob(HiddenProbEvent::SeenPassive);
assert_eq!(network_config.hidden_probability, PROB_HIDDEN_IF_SEEN_PASSIVE);
// network has become hidden.
network_config.update_hidden_prob(HiddenProbEvent::ConnectActive);
assert_eq!(network_config.hidden_probability, PROB_HIDDEN_IF_CONNECT_ACTIVE);
} | rust_cleaned_test_functions.jsonl/114361 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 395
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26739,
20794,
38241,
12930,
15720,
368,
341,
286,
1077,
5206,
3922,
5332,
284,
8141,
2648,
486,
931,
1006,
310,
8141,
8714,
486,
931,
1883,
1,
14689,
643,
21027,
3263,
983,
13251,
1507,
8234,
929,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_compare_and_swap() {
let mut io_loop = Runtime::new().unwrap();
let (bg, mut client, origin) = create_sig0_ready_client(&mut io_loop);
// create a record
let mut record = Record::with(
Name::from_str("new.example.com").unwrap(),
RecordType::A,
Duration::minutes(5).num_seconds() as u32,
);
record.set_rdata(RData::A(Ipv4Addr::new(100, 10, 100, 10)));
let record = record;
io_loop.spawn(bg);
let result = io_loop
.block_on(client.create(record.clone(), origin.clone()))
.expect("create failed");
assert_eq!(result.response_code(), ResponseCode::NoError);
let current = record;
let mut new = current.clone();
new.set_rdata(RData::A(Ipv4Addr::new(101, 11, 101, 11)));
let new = new;
let result = io_loop
.block_on(client.compare_and_swap(current.clone(), new.clone(), origin.clone()))
.expect("compare_and_swap failed");
assert_eq!(result.response_code(), ResponseCode::NoError);
let result = io_loop
.block_on(client.query(new.name().clone(), new.dns_class(), new.rr_type()))
.expect("query failed");
assert_eq!(result.response_code(), ResponseCode::NoError);
assert_eq!(result.answers().len(), 1);
assert!(result.answers().iter().any(|rr| *rr == new));
assert!(!result.answers().iter().any(|rr| *rr == current));
// check the it fails if tried again.
let mut not = new.clone();
not.set_rdata(RData::A(Ipv4Addr::new(102, 12, 102, 12)));
let not = not;
let result = io_loop
.block_on(client.compare_and_swap(current, not.clone(), origin.clone()))
.expect("compare_and_swap failed");
assert_eq!(result.response_code(), ResponseCode::NXRRSet);
let result = io_loop
.block_on(client.query(new.name().clone(), new.dns_class(), new.rr_type()))
.expect("query failed");
assert_eq!(result.response_code(), ResponseCode::NoError);
assert_eq!(result.answers().len(), 1);
assert!(result.answers().iter().any(|rr| *rr == new));
assert!(!result.answers().iter().any(|rr| *rr == not));
} | rust_cleaned_test_functions.jsonl/33940 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 897
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
32235,
8378,
40991,
368,
341,
262,
1077,
5206,
6399,
17198,
284,
10954,
486,
931,
1005,
15454,
543,
262,
1077,
320,
12220,
11,
5206,
2943,
11,
6238,
8,
284,
1855,
29252,
15,
35456,
8179,
2099,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_contract_upgrade() {
let (master_account, _contract_account) = init();
master_account
.call(
accounts(0).to_string(),
"stage_upgrade",
&EVM_WASM_BYTES,
DEFAULT_GAS,
0,
)
.assert_success();
master_account
.call(
accounts(0).to_string(),
"deploy_upgrade",
&[],
DEFAULT_GAS,
0,
)
.assert_success();
} | rust_cleaned_test_functions.jsonl/95435 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 300
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
51499,
67794,
368,
341,
262,
1077,
320,
13629,
13500,
11,
716,
20257,
13500,
8,
284,
2930,
543,
262,
7341,
13500,
198,
286,
659,
6659,
1006,
310,
9618,
7,
15,
568,
983,
3904,
3148,
310,
330,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_validate_rules() {
let mut kb = KnowledgeBase::new();
kb.register_constant(
sym!("Fruit"),
term!(Value::ExternalInstance(ExternalInstance {
instance_id: 1,
constructor: None,
repr: None
})),
)
.unwrap();
kb.register_constant(
sym!("Citrus"),
term!(Value::ExternalInstance(ExternalInstance {
instance_id: 2,
constructor: None,
repr: None
})),
)
.unwrap();
kb.register_constant(
sym!("Orange"),
term!(Value::ExternalInstance(ExternalInstance {
instance_id: 3,
constructor: None,
repr: None
})),
)
.unwrap();
kb.add_mro(sym!("Fruit"), vec![1]).unwrap();
// Citrus is a subclass of Fruit
kb.add_mro(sym!("Citrus"), vec![2, 1]).unwrap();
// Orange is a subclass of Citrus
kb.add_mro(sym!("Orange"), vec![3, 2, 1]).unwrap();
// Rule type applies if it has the same name as a rule
kb.add_rule_type(rule!("f", ["x"; instance!(sym!("Orange"))]));
kb.add_rule(rule!("f", ["x"; instance!(sym!("Orange"))]));
kb.add_rule(rule!("f", ["x"; instance!(sym!("Fruit"))]));
let diagnostics = kb.validate_rules();
assert_eq!(diagnostics.len(), 1);
assert!(matches!(
diagnostics.first().unwrap(),
Diagnostic::Error(PolarError {
kind: Validation(ValidationError::InvalidRule { .. }),
..
})
));
// Rule type does not apply if it doesn't have the same name as a rule
kb.clear_rules();
kb.add_rule_type(rule!("f", ["x"; instance!(sym!("Orange"))]));
kb.add_rule(rule!("f", ["x"; instance!(sym!("Orange"))]));
kb.add_rule(rule!("g", ["x"; instance!(sym!("Fruit"))]));
assert!(kb.validate_rules().is_empty());
// Rule type does apply if it has the same name as a rule even if different arity
kb.clear_rules();
kb.add_rule_type(rule!("f", ["x"; instance!(sym!("Orange")), value!(1)]));
kb.add_rule(rule!("f", ["x"; instance!(sym!("Orange"))]));
assert!(matches!(
kb.validate_rules().first().unwrap(),
Diagnostic::Error(PolarError {
kind: Validation(ValidationError::InvalidRule { .. }),
..
})
));
// Multiple templates can exist for the same name but only one needs to match
kb.clear_rules();
kb.add_rule_type(rule!("f", ["x"; instance!(sym!("Orange"))]));
kb.add_rule_type(rule!("f", ["x"; instance!(sym!("Orange")), value!(1)]));
kb.add_rule_type(rule!("f", ["x"; instance!(sym!("Fruit"))]));
kb.add_rule(rule!("f", ["x"; instance!(sym!("Fruit"))]));
assert!(kb.validate_rules().is_empty());
} | rust_cleaned_test_functions.jsonl/39055 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1512
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
42681,
21407,
368,
341,
286,
1077,
5206,
38653,
284,
31925,
3978,
486,
931,
543,
286,
38653,
9929,
34967,
1006,
310,
7886,
17223,
37,
21026,
4461,
310,
4647,
10297,
1130,
486,
25913,
2523,
7,
2591... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_query_account_request() {
let msg =
QueryAccountRequest::new("cosmos1fknpjldck6n3v2wu86arpz8xjnfc60f99ylcjd".to_string());
let proto = msg.to_proto();
let decoded = QueryAccountRequest::from_proto(&proto).unwrap();
assert_eq!(msg, decoded);
} | rust_cleaned_test_functions.jsonl/105264 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 153
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5738,
13500,
7893,
368,
341,
286,
1077,
3750,
4035,
310,
11361,
7365,
1900,
486,
931,
445,
9407,
8631,
16,
41718,
62245,
507,
377,
21,
77,
18,
85,
17,
65465,
23,
21,
7876,
89,
23,
87,
93808,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_activity_secrets() {
let value = ActivitySecrets {
join: Some("a".to_owned()),
match_: Some("b".to_owned()),
spectate: Some("c".to_owned()),
};
serde_test::assert_tokens(
&value,
&[
Token::Struct {
name: "ActivitySecrets",
len: 3,
},
Token::Str("join"),
Token::Some,
Token::Str("a"),
Token::Str("match"),
Token::Some,
Token::Str("b"),
Token::Str("spectate"),
Token::Some,
Token::Str("c"),
Token::StructEnd,
],
);
} | rust_cleaned_test_functions.jsonl/67838 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 492
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
30026,
3453,
52710,
368,
341,
286,
1077,
897,
284,
14981,
19773,
82,
341,
310,
5138,
25,
4329,
445,
64,
3263,
983,
51973,
14702,
310,
2432,
23211,
4329,
445,
65,
3263,
983,
51973,
14702,
310,
94... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_value_recording_for_structs() {
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)]
struct R(u32);
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)]
struct S {
a: u32,
}
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)]
struct T(u32, u64);
let mut tracer = Tracer::new(
TracerConfig::default()
.record_samples_for_newtype_structs(false) // default is tested above
.record_samples_for_tuple_structs(true)
.record_samples_for_structs(true),
);
let mut samples = Samples::new();
tracer.trace_value(&mut samples, &R(1)).unwrap();
tracer.trace_value(&mut samples, &S { a: 2 }).unwrap();
tracer.trace_value(&mut samples, &T(3, 4)).unwrap();
assert!(samples.value("R").is_none());
assert!(samples.value("S").is_some());
assert!(samples.value("T").is_some());
assert_eq!(tracer.trace_type_once::<R>(&samples).unwrap().1, R(0));
assert_eq!(tracer.trace_type_once::<S>(&samples).unwrap().1, S { a: 2 });
assert_eq!(tracer.trace_type_once::<T>(&samples).unwrap().1, T(3, 4));
} | rust_cleaned_test_functions.jsonl/23934 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 519
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3142,
7080,
2678,
5478,
15126,
82,
368,
341,
262,
11506,
27098,
3759,
9050,
11,
48440,
11,
55039,
11,
33122,
11,
11091,
11,
27913,
5563,
262,
2036,
431,
8154,
18,
17,
317,
262,
11506,
27098,
375... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_to_vote_instruction() {
let vote = Vote::default();
let mut decision = SwitchForkDecision::FailedSwitchThreshold;
assert!(decision
.to_vote_instruction(vote.clone(), &Pubkey::default(), &Pubkey::default())
.is_none());
decision = SwitchForkDecision::NoSwitch;
assert_eq!(
decision.to_vote_instruction(vote.clone(), &Pubkey::default(), &Pubkey::default()),
Some(vote_instruction::vote(
&Pubkey::default(),
&Pubkey::default(),
vote.clone(),
))
);
decision = SwitchForkDecision::SwitchProof(Hash::default());
assert_eq!(
decision.to_vote_instruction(vote.clone(), &Pubkey::default(), &Pubkey::default()),
Some(vote_instruction::vote_switch(
&Pubkey::default(),
&Pubkey::default(),
vote,
Hash::default()
))
);
} | rust_cleaned_test_functions.jsonl/77014 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 510
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2346,
54360,
54923,
368,
341,
286,
1077,
6910,
284,
34034,
486,
2258,
543,
286,
1077,
5206,
5480,
284,
15586,
37,
669,
74846,
486,
9408,
16837,
37841,
280,
286,
2060,
10297,
63938,
198,
310,
659,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_geo_invalid_p() {
assert!(Geometric::new(core::f64::NAN).is_err());
assert!(Geometric::new(core::f64::INFINITY).is_err());
assert!(Geometric::new(core::f64::NEG_INFINITY).is_err());
assert!(Geometric::new(-0.5).is_err());
assert!(Geometric::new(0.0).is_ok());
assert!(Geometric::new(1.0).is_ok());
assert!(Geometric::new(2.0).is_err());
} | rust_cleaned_test_functions.jsonl/9273 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 213
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
60308,
31433,
620,
368,
341,
286,
2060,
10297,
9499,
23375,
486,
931,
47867,
486,
69,
21,
19,
486,
45,
1093,
568,
285,
9266,
1423,
286,
2060,
10297,
9499,
23375,
486,
931,
47867,
486,
69,
21,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_user_playlist_remove_specific_occurrenes_of_tracks() {
let mut oauth = SpotifyOAuth::default()
.scope("playlist-modify-private playlist-modify-public")
.build();
match get_token(&mut oauth) {
Some(token_info) => {
let client_credential = SpotifyClientCredentials::default()
.token_info(token_info)
.build();
let spotify = Spotify::default()
.client_credentials_manager(client_credential)
.build();
let user_id = "2257tjys2e2u2ygfke42niy2q";
let playlist_id = String::from("5jAOgWXCBKuinsGiZxjDQ5");
let mut tracks = vec![];
let mut map1 = Map::new();
let mut position1 = vec![];
position1.push(0);
position1.push(3);
map1.insert("uri".to_string(),
"spotify:track:4iV5W9uYEdYUVa79Axb7Rh".into());
map1.insert("position".to_string(), position1.into());
tracks.push(map1);
let mut map2 = Map::new();
let mut position2 = vec![];
position2.push(7);
map2.insert("uri".to_string(),
"spotify:track:1301WleyT98MSxVHPZCA6M".into());
map2.insert("position".to_string(), position2.into());
tracks.push(map2);
let result =
spotify.user_playlist_remove_specific_occurrenes_of_tracks(user_id,
&playlist_id,
tracks,
None);
assert!(result.is_ok());
}
None => assert!(false),
};
} | rust_cleaned_test_functions.jsonl/79292 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1073
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3317,
69267,
18193,
56592,
57291,
843,
4873,
3575,
66953,
368,
341,
262,
1077,
5206,
46415,
284,
40537,
57850,
486,
2258,
741,
286,
659,
4186,
445,
34233,
17078,
1437,
65277,
26791,
17078,
1437,
564... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_from_bytes_incomplete() {
let data: Vec<u8> = vec![];
let err = HeaderIdentAbiVersion::from_bytes((&data, 0));
assert!(matches!(err, Err(_)));
} | rust_cleaned_test_functions.jsonl/112406 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 95
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5673,
12524,
1243,
14737,
368,
341,
286,
1077,
821,
25,
11312,
34837,
23,
29,
284,
7486,
0,
40901,
286,
1077,
1848,
284,
12104,
28301,
5830,
72,
5637,
486,
1499,
12524,
42902,
691,
11,
220,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_default_style() {
const FORMAT_STR: &str = "text";
let style = Some(Color::Red.bold());
let formatter = StringFormatter::new(FORMAT_STR).unwrap().map(empty_mapper);
let result = formatter.parse(style).unwrap();
let mut result_iter = result.iter();
match_next!(result_iter, "text", style);
} | rust_cleaned_test_functions.jsonl/71876 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 157
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9993,
15117,
368,
341,
286,
733,
52225,
7159,
25,
609,
495,
284,
330,
1318,
876,
286,
1077,
1707,
284,
4329,
15028,
486,
6033,
31675,
5231,
286,
1077,
24814,
284,
923,
14183,
486,
931,
7832,
980... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_mediastream() {
let mut exec = fasync::Executor::new().expect("failed to create an executor");
let mut s = StreamEndpoint::new(
REMOTE_ID_VAL,
MediaType::Audio,
EndpointType::Sink,
vec![ServiceCapability::MediaTransport],
)
.unwrap();
assert_matches!(s.configure(&REMOTE_ID, vec![ServiceCapability::MediaTransport]), Ok(()));
assert!(s.take_transport().is_none());
let remote_transport = establish_stream(&mut s);
// Should be able to get the transport from the stream now.
let temp_stream = s.take_transport();
assert!(temp_stream.is_some());
// But only once
assert!(s.take_transport().is_none());
// Until you drop the stream
drop(temp_stream);
let media_stream = s.take_transport();
assert!(media_stream.is_some());
let mut media_stream = media_stream.unwrap();
// Writing to the media stream should send it through the transport channel.
let hearts = &[0xF0, 0x9F, 0x92, 0x96, 0xF0, 0x9F, 0x92, 0x96];
let mut write_fut = media_stream.write(hearts);
assert_matches!(exec.run_until_stalled(&mut write_fut), Poll::Ready(Ok(8)));
expect_remote_recv(hearts, &remote_transport);
// Closing the media stream should close the channel.
let mut close_fut = media_stream.close();
assert_matches!(exec.run_until_stalled(&mut close_fut), Poll::Ready(Ok(())));
// until the channel is dropped.
drop(s);
// Reading from the remote end should fail.
let mut result = vec![0];
assert_matches!(
remote_transport.as_ref().read(&mut result[..]),
Err(zx::Status::PEER_CLOSED)
);
let mut write_fut = media_stream.write(&[0xDE, 0xAD]);
assert_matches!(exec.run_until_stalled(&mut write_fut), Poll::Ready(Err(_)));
let mut next_fut = media_stream.next();
assert_matches!(exec.run_until_stalled(&mut next_fut), Poll::Ready(None));
} | rust_cleaned_test_functions.jsonl/32977 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 966
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
717,
19048,
559,
1237,
368,
341,
286,
1077,
5206,
3883,
284,
282,
7692,
486,
25255,
486,
931,
1005,
17119,
445,
16091,
311,
1855,
458,
31558,
797,
286,
1077,
5206,
274,
284,
9203,
27380,
486,
93... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_array_chunks_nth_back() {
let v: &[i32] = &[0, 1, 2, 3, 4, 5];
let mut c = v.array_chunks::<2>();
assert_eq!(c.nth_back(1).unwrap(), &[2, 3]);
assert_eq!(c.next().unwrap(), &[0, 1]);
assert_eq!(c.next(), None);
let v2: &[i32] = &[0, 1, 2, 3, 4];
let mut c2 = v2.array_chunks::<3>();
assert_eq!(c2.nth_back(0).unwrap(), &[0, 1, 2]);
assert_eq!(c2.next(), None);
assert_eq!(c2.next_back(), None);
let v3: &[i32] = &[0, 1, 2, 3, 4];
let mut c3 = v3.array_chunks::<10>();
assert_eq!(c3.nth_back(0), None);
} | rust_cleaned_test_functions.jsonl/9645 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 316
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3858,
65470,
78342,
3895,
368,
341,
262,
1077,
348,
25,
44590,
72,
18,
17,
60,
284,
44590,
15,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
935,
262,
1077,
5206,
272,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_keyword() {
assert_eq!(js_parser_rs::parse("var".chars()), Ok(vec![TokenType::Var]));
assert_eq!(js_parser_rs::parse("if".chars()), Ok(vec![TokenType::If]));
assert_eq!(js_parser_rs::parse("else".chars()), Ok(vec![TokenType::Else]));
assert_eq!(js_parser_rs::parse("do".chars()), Ok(vec![TokenType::Do]));
assert_eq!(js_parser_rs::parse("typeof".chars()), Ok(vec![TokenType::Typeof]));
assert_eq!(js_parser_rs::parse("switch".chars()), Ok(vec![TokenType::Switch]));
assert_eq!(js_parser_rs::parse("catch".chars()), Ok(vec![TokenType::Catch]));
assert_eq!(js_parser_rs::parse("try".chars()), Ok(vec![TokenType::Try]));
assert_eq!(js_parser_rs::parse("instanceof".chars()), Ok(vec![TokenType::Instanceof]));
assert_eq!(js_parser_rs::parse("export".chars()), Ok(vec![TokenType::Export]));
assert_eq!(js_parser_rs::parse("return".chars()), Ok(vec![TokenType::Return]));
assert_eq!(js_parser_rs::parse("void".chars()), Ok(vec![TokenType::Void]));
assert_eq!(js_parser_rs::parse("extends".chars()), Ok(vec![TokenType::Extends]));
assert_eq!(js_parser_rs::parse("const".chars()), Ok(vec![TokenType::Const]));
assert_eq!(js_parser_rs::parse("finally".chars()), Ok(vec![TokenType::Finally]));
assert_eq!(js_parser_rs::parse("super".chars()), Ok(vec![TokenType::Super]));
assert_eq!(js_parser_rs::parse("with".chars()), Ok(vec![TokenType::With]));
assert_eq!(js_parser_rs::parse("yield".chars()), Ok(vec![TokenType::Yield]));
assert_eq!(js_parser_rs::parse("default".chars()), Ok(vec![TokenType::Default]));
assert_eq!(js_parser_rs::parse("function".chars()), Ok(vec![TokenType::Function]));
assert_eq!(js_parser_rs::parse("of".chars()), Ok(vec![TokenType::Of]));
assert_eq!(js_parser_rs::parse("in".chars()), Ok(vec![TokenType::In]));
assert_eq!(js_parser_rs::parse("for".chars()), Ok(vec![TokenType::For]));
assert_eq!(js_parser_rs::parse("while".chars()), Ok(vec![TokenType::While]));
assert_eq!(js_parser_rs::parse("class".chars()), Ok(vec![TokenType::Class]));
assert_eq!(js_parser_rs::parse("break".chars()), Ok(vec![TokenType::Break]));
assert_eq!(js_parser_rs::parse("continue".chars()), Ok(vec![TokenType::Continue]));
assert_eq!(js_parser_rs::parse("new".chars()), Ok(vec![TokenType::New]));
} | rust_cleaned_test_functions.jsonl/61524 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 988
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
45824,
368,
341,
14808,
262,
2060,
10714,
10297,
2519,
18517,
47115,
486,
6400,
445,
947,
3263,
19255,
11858,
7622,
25592,
20703,
75611,
486,
3962,
14382,
262,
2060,
10714,
10297,
2519,
18517,
47115,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_http() {
let target = "http://example.domain/";
let p = Proxy::http(target).unwrap();
let http = "http://hyper.rs";
let other = "https://hyper.rs";
assert_eq!(intercepted_uri(&p, http), target);
assert!(p.intercept(&url(other)).is_none());
} | rust_cleaned_test_functions.jsonl/6804 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 146
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25888,
368,
341,
286,
1077,
2169,
284,
330,
1254,
1110,
8687,
11003,
37254,
286,
1077,
281,
284,
32778,
486,
1254,
8637,
568,
15454,
1428,
286,
1077,
1758,
284,
330,
1254,
1110,
68192,
25638,
876,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_initialize_at_ok() {
ExtBuilder::default().build().execute_with(|| {
assert_ok!(CrowdloanRewards::initialize_at(Origin::root(), 10));
assert_eq!(CrowdloanRewards::total_rewards(), 0);
assert_eq!(CrowdloanRewards::claimed_rewards(), 0);
});
} | rust_cleaned_test_functions.jsonl/41084 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 112
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
40889,
3752,
19817,
368,
341,
76605,
3297,
486,
2258,
1005,
5834,
1005,
10257,
6615,
79453,
341,
197,
6948,
19817,
10297,
93926,
67,
38329,
58465,
2347,
486,
21641,
3752,
7,
13298,
486,
2888,
1507,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_mlen_increase_values() {
let mut context = Sha384::default();
context._state.increment_mlen(&WordU64::from(1u64));
assert_eq!(context._state.message_len[0], WordU64::from(0u64));
assert_eq!(context._state.message_len[1], WordU64::from(8u64));
context._state.increment_mlen(&WordU64::from(17u64));
assert_eq!(context._state.message_len[0], WordU64::from(0u64));
assert_eq!(context._state.message_len[1], WordU64::from(144u64));
context._state.increment_mlen(&WordU64::from(12u64));
assert_eq!(context._state.message_len[0], WordU64::from(0u64));
assert_eq!(context._state.message_len[1], WordU64::from(240u64));
// Overflow
context._state.increment_mlen(&WordU64::from(u64::MAX / 8));
assert_eq!(context._state.message_len[0], WordU64::from(1u64));
assert_eq!(context._state.message_len[1], WordU64::from(232u64));
} | rust_cleaned_test_functions.jsonl/46935 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 495
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
717,
2892,
73807,
9146,
368,
341,
310,
1077,
5206,
2266,
284,
27970,
18,
23,
19,
486,
2258,
1428,
310,
2266,
1436,
2454,
56936,
717,
2892,
2099,
10879,
52,
21,
19,
486,
1499,
7,
16,
84,
21,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_interval_value_truncate_high_fields() {
use DateTimeField::*;
let mut test_cases = [
(Year, (321, 654_321), (321, 654_321)),
(Month, (321, 654_321), (9, 654_321)),
(Day, (321, 654_321), (0, 654_321)),
(Hour, (321, 654_321), (0, 654_321 % (60 * 60 * 24))),
(Minute, (321, 654_321), (0, 654_321 % (60 * 60))),
(Second, (321, 654_321), (0, 654_321 % 60)),
];
for test in test_cases.iter_mut() {
let mut i = Interval::new((test.1).0, (test.1).1, 123).unwrap();
let j = Interval::new((test.2).0, (test.2).1, 123).unwrap();
i.truncate_high_fields(test.0);
if i != j {
panic!(
"test_interval_value_truncate_high_fields failed on {} \n actual: {:?} \n expected: {:?}",
test.0, i, j
);
}
}
} | rust_cleaned_test_functions.jsonl/94293 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 553
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20541,
3142,
3547,
26900,
22680,
12132,
368,
341,
286,
990,
6520,
1877,
79304,
286,
1077,
5206,
1273,
41427,
284,
2278,
310,
320,
9490,
11,
320,
18,
17,
16,
11,
220,
21,
20,
19,
62,
18,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_plan_build_minimum_workspace_dependency() {
let planned_build_res = BuildPlannerImpl::new(
template_raze_metadata(templates::DUMMY_MODIFIED_METADATA),
dummy_raze_settings(),
)
.plan_build(Some(PlatformDetails::new(
"some_target_triple".to_owned(),
Vec::new(), /* attrs */
)));
let planned_build = planned_build_res.unwrap();
assert_eq!(planned_build.crate_contexts.len(), 1);
let dep = planned_build.crate_contexts.get(0).unwrap();
assert_eq!(dep.pkg_name, "test_dep");
assert!(!dep.workspace_member_dependents.is_empty());
assert!(
!dep.workspace_path_to_crate.contains('.'),
"{} should be sanitized",
dep.workspace_path_to_crate
);
assert!(
!dep.workspace_path_to_crate.contains('-'),
"{} should be sanitized",
dep.workspace_path_to_crate
);
} | rust_cleaned_test_functions.jsonl/31788 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 386
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26564,
20801,
84855,
75560,
62387,
368,
341,
262,
1077,
12909,
20801,
4918,
284,
7854,
2120,
4887,
9673,
486,
931,
1006,
414,
3811,
59969,
2986,
22220,
7,
15463,
486,
35,
58673,
85958,
58084,
1326,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_punctuation_3() {
assert_eq!(lex("*%="), (Token::StarPercentEqual, 3));
assert_eq!(lex("+%="), (Token::PlusPercentEqual, 3));
assert_eq!(lex("-%="), (Token::MinusPercentEqual, 3));
assert_eq!(lex("..."), (Token::Dot3, 3));
assert_eq!(lex("<<="), (Token::LAngle2Equal, 3));
assert_eq!(lex(">>="), (Token::RAngle2Equal, 3));
} | rust_cleaned_test_functions.jsonl/80525 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 200
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
72299,
62,
18,
368,
341,
286,
2060,
10714,
10297,
2571,
29592,
4,
428,
701,
320,
3323,
486,
12699,
32010,
2993,
11,
220,
18,
1106,
286,
2060,
10714,
10297,
2571,
34973,
4,
428,
701,
320,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_vendor_devices() {
let vendor = Vendor::from_id(0x17cb).unwrap();
for device in vendor.devices() {
assert_eq!(device.vendor(), vendor);
assert!(!device.name().is_empty());
}
} | rust_cleaned_test_functions.jsonl/27529 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 123
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
58320,
41334,
368,
341,
286,
1077,
20728,
284,
45136,
486,
1499,
842,
7,
15,
87,
16,
22,
7221,
568,
15454,
1428,
286,
369,
3671,
304,
20728,
78914,
368,
341,
310,
2060,
10714,
10297,
6111,
72395... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
#[test]
fn test_part2() {
assert!(supports_ssl(&parse_addr("aba[bab]xyz")));
assert!(!supports_ssl(&parse_addr("xyx[xyx]xyx")));
assert!(supports_ssl(&parse_addr("aaa[kek]eke")));
assert!(supports_ssl(&parse_addr("zazbz[bzb]cdb")));
} | rust_cleaned_test_functions.jsonl/60101 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 144
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10495,
17,
368,
341,
286,
2060,
10297,
77709,
48210,
2099,
6400,
7387,
445,
12004,
18483,
370,
60,
28854,
17621,
286,
2060,
0,
3471,
77709,
48210,
2099,
6400,
7387,
445,
4130,
87,
58,
4130,
87,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_sequence() {
let mut bits = 0xCC;
for i in 0..8 {
test_seq_value(bits);
assert_eq!(i + 1, sequence_bytes_required(bits));
bits <<= 8;
}
} | rust_cleaned_test_functions.jsonl/18952 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 101
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
23735,
368,
341,
262,
1077,
5206,
9472,
284,
220,
15,
72255,
401,
262,
369,
600,
304,
220,
15,
496,
23,
341,
286,
1273,
14486,
3142,
68901,
317,
286,
2060,
10714,
10297,
72,
488,
220,
16,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
#[test]
fn test_data_retransmit() {
let mut s = socket_established();
s.send_slice(b"abcdef").unwrap();
recv!(s, time 1000, Ok(TcpRepr {
seq_number: LOCAL_SEQ + 1,
ack_number: Some(REMOTE_SEQ + 1),
payload: &b"abcdef"[..],
..RECV_TEMPL
}));
recv!(s, time 1050, Err(Error::Exhausted));
recv!(s, time 1100, Ok(TcpRepr {
seq_number: LOCAL_SEQ + 1,
ack_number: Some(REMOTE_SEQ + 1),
payload: &b"abcdef"[..],
..RECV_TEMPL
}));
} | rust_cleaned_test_functions.jsonl/1762 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 347
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1769,
1288,
1458,
1763,
368,
341,
286,
1077,
5206,
274,
284,
7575,
18583,
5102,
291,
543,
286,
274,
5219,
26488,
1883,
1,
41202,
1827,
15454,
543,
286,
27006,
10297,
82,
11,
882,
220,
16,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_alr() {
let code = vec![0x4B, 0xD1];
let mut nes = Cpu::new();
let mut memory = new_memory(code);
nes.A = 0xc4;
// AND is 0b11000000
// Shift right -> 0b01100000 and C = 0
nes.next(&mut memory).unwrap();
assert_eq!(0, nes.C);
assert_eq!(0, nes.N);
assert_eq!(0, nes.Z);
assert_eq!(0x60, nes.A);
} | rust_cleaned_test_functions.jsonl/38743 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 237
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8418,
81,
368,
341,
286,
1077,
2038,
284,
7486,
20703,
15,
87,
19,
33,
11,
220,
15,
15764,
16,
935,
286,
1077,
5206,
308,
288,
284,
356,
5584,
486,
931,
543,
286,
1077,
5206,
4938,
284,
501,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_apply_remove_encryption() {
let db_name = format!("{}.sqlite3", string(8).as_str());
let temp_dir = tempdir().unwrap();
let db_folder = temp_dir.path().to_str().unwrap().to_string();
let db_path = format!("{}{}", db_folder, db_name);
embed_migrations!("./migrations");
let conn = SqliteConnection::establish(&db_path).unwrap_or_else(|_| panic!("Error connecting to {}", db_path));
embedded_migrations::run_with_output(&conn, &mut std::io::stdout()).expect("Migration failed");
let inbound_tx = InboundTransaction {
tx_id: 1,
source_public_key: PublicKey::from_secret_key(&PrivateKey::random(&mut OsRng)),
amount: MicroTari::from(100),
receiver_protocol: ReceiverTransactionProtocol::new_placeholder(),
status: TransactionStatus::Pending,
message: "Yo!".to_string(),
timestamp: Utc::now().naive_utc(),
cancelled: false,
direct_send_success: false,
send_count: 0,
last_send_timestamp: None,
};
let inbound_tx_sql = InboundTransactionSql::try_from(inbound_tx).unwrap();
inbound_tx_sql.commit(&conn).unwrap();
let outbound_tx = OutboundTransaction {
tx_id: 2u64,
destination_public_key: PublicKey::from_secret_key(&PrivateKey::random(&mut OsRng)),
amount: MicroTari::from(100),
fee: MicroTari::from(10),
sender_protocol: SenderTransactionProtocol::new_placeholder(),
status: TransactionStatus::Pending,
message: "Yo!".to_string(),
timestamp: Utc::now().naive_utc(),
cancelled: false,
direct_send_success: false,
send_count: 0,
last_send_timestamp: None,
};
let outbound_tx_sql = OutboundTransactionSql::try_from(outbound_tx).unwrap();
outbound_tx_sql.commit(&conn).unwrap();
let completed_tx = CompletedTransaction {
tx_id: 3,
source_public_key: PublicKey::from_secret_key(&PrivateKey::random(&mut OsRng)),
destination_public_key: PublicKey::from_secret_key(&PrivateKey::random(&mut OsRng)),
amount: MicroTari::from(100),
fee: MicroTari::from(100),
transaction: Transaction::new(
vec![],
vec![],
vec![],
PrivateKey::random(&mut OsRng),
PrivateKey::random(&mut OsRng),
),
status: TransactionStatus::MinedUnconfirmed,
message: "Yo!".to_string(),
timestamp: Utc::now().naive_utc(),
cancelled: false,
direction: TransactionDirection::Unknown,
coinbase_block_height: None,
send_count: 0,
last_send_timestamp: None,
valid: true,
confirmations: None,
mined_height: None,
};
let completed_tx_sql = CompletedTransactionSql::try_from(completed_tx).unwrap();
completed_tx_sql.commit(&conn).unwrap();
let key = GenericArray::from_slice(b"an example very very secret key.");
let cipher = Aes256Gcm::new(key);
let connection = WalletDbConnection::new(conn, None);
let db1 = TransactionServiceSqliteDatabase::new(connection.clone(), Some(cipher.clone()));
assert!(db1.apply_encryption(cipher.clone()).is_err());
let db2 = TransactionServiceSqliteDatabase::new(connection.clone(), None);
assert!(db2.remove_encryption().is_ok());
db2.apply_encryption(cipher).unwrap();
assert!(db2.fetch(&DbKey::PendingInboundTransactions).is_ok());
assert!(db2.fetch(&DbKey::PendingOutboundTransactions).is_ok());
assert!(db2.fetch(&DbKey::CompletedTransactions).is_ok());
let db3 = TransactionServiceSqliteDatabase::new(connection, None);
assert!(db3.fetch(&DbKey::PendingInboundTransactions).is_err());
assert!(db3.fetch(&DbKey::PendingOutboundTransactions).is_err());
assert!(db3.fetch(&DbKey::CompletedTransactions).is_err());
db2.remove_encryption().unwrap();
assert!(db3.fetch(&DbKey::PendingInboundTransactions).is_ok());
assert!(db3.fetch(&DbKey::PendingOutboundTransactions).is_ok());
assert!(db3.fetch(&DbKey::CompletedTransactions).is_ok());
} | rust_cleaned_test_functions.jsonl/1823 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2009
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36551,
18193,
13781,
15597,
368,
341,
286,
1077,
2927,
1269,
284,
3561,
17223,
46391,
37042,
18,
497,
914,
7,
23,
568,
300,
2895,
1423,
286,
1077,
2730,
4334,
284,
2730,
3741,
1005,
15454,
543,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_create() {
try_create(10.0, 0.1);
try_create(-5.0, 1.0);
try_create(0.0, 10.0);
try_create(10.0, 100.0);
try_create(-5.0, f64::INFINITY);
} | rust_cleaned_test_functions.jsonl/88257 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 125
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8657,
368,
341,
286,
1430,
8657,
7,
16,
15,
13,
15,
11,
220,
15,
13,
16,
317,
286,
1430,
8657,
4080,
20,
13,
15,
11,
220,
16,
13,
15,
317,
286,
1430,
8657,
7,
15,
13,
15,
11,
220,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_index_metadata_binary_value() {
let metadata = IndexMetadata {
identifier: NonZeroU64::new(12).unwrap(),
index_type: IndexType::ProofList,
state: Some(16_u64),
};
let bytes = metadata.to_bytes();
assert_eq!(IndexMetadata::from_bytes(bytes.into()).unwrap(), metadata);
let metadata = IndexMetadata {
identifier: NonZeroU64::new(12).unwrap(),
index_type: IndexType::ProofList,
state: None::<u64>,
};
let bytes = metadata.to_bytes();
assert_eq!(IndexMetadata::from_bytes(bytes.into()).unwrap(), metadata);
} | rust_cleaned_test_functions.jsonl/13033 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 309
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3560,
22220,
31761,
3142,
368,
341,
286,
1077,
11160,
284,
8008,
14610,
341,
310,
12816,
25,
11581,
17999,
52,
21,
19,
486,
931,
7,
16,
17,
568,
15454,
3148,
310,
1922,
1819,
25,
8008,
929,
48... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_get_ip_forwarding() {
let mut test_config = create_test_config_no_paths();
test_config.device_config = Some(build_full_config());
assert_eq!(test_config.get_ip_forwarding_state(), true);
// removing the ip forwarding config should still return the default of false.
test_config.device_config =
Some(DeviceConfig { device: Device { acls: None, interfaces: None, services: None } });
assert_eq!(test_config.get_ip_forwarding_state(), false);
} | rust_cleaned_test_functions.jsonl/83814 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 206
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
10385,
32121,
287,
368,
341,
286,
1077,
5206,
1273,
5332,
284,
1855,
4452,
5332,
6536,
24152,
543,
286,
1273,
5332,
18355,
5332,
284,
4329,
43333,
16372,
5332,
1423,
286,
2060,
10714,
10297,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_blob_bucket() {
// load test fixture files:
let image_1 = load_fixture(Path::new("images").join("rgb.jpeg"));
let image_1_meta = BlobMeta::new(image_1.len());
let image_2 = load_fixture(Path::new("images").join("rgb.png"));
let image_2_meta = BlobMeta::new(image_2.len());
let image_3 = load_fixture(Path::new("images").join("rgba.png"));
let image_3_meta = BlobMeta::new(image_3.len());
let dir = tempdir().expect("expected to write temporary directory!");
let config = BucketBlobStorageConfig {
path: dir.path().to_path_buf(),
max_size: 1024 * 1024 * 1024 * 24,
};
BucketBlobStorage::init(&config).expect("Error in init of bucket storage!");
let mut storage = BucketBlobStorage::new(config).expect("error creating the blob storage");
// put images into bucket:
let reference_1 = storage.put(&image_1_meta, image_1.to_vec()).expect("put blob failed!");
let reference_2 = storage.put(&image_2_meta, image_2.to_vec()).expect("put blob failed!");
let reference_3 = storage.put(&image_3_meta, image_3.to_vec()).expect("put blob failed!");
// read back again
let image_1_res = storage.get(&image_1_meta, &reference_1).expect("get blob failed!").to_vec();
let image_2_res = storage.get(&image_2_meta, &reference_2).expect("get blob failed!").to_vec();
let image_3_res = storage.get(&image_3_meta, &reference_3).expect("get blob failed!").to_vec();
assert_eq!(image_1.len(), image_1_res.len());
assert_eq!(image_2.len(), image_2_res.len());
assert_eq!(image_3.len(), image_3_res.len());
assert_eq!(image_1, image_1_res);
assert_eq!(image_2, image_2_res);
assert_eq!(image_3, image_3_res);
} | rust_cleaned_test_functions.jsonl/73122 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 796
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
45908,
38749,
368,
341,
286,
442,
2795,
1273,
12507,
3542,
510,
286,
1077,
2168,
62,
16,
284,
2795,
74409,
33030,
486,
931,
445,
3642,
1827,
5987,
445,
16509,
30675,
4010,
286,
1077,
2168,
62,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_str() {
assert_ser_eq!("a", &[Token::Str("a")]);
assert_ser_eq!("a", &[Token::BorrowedStr("a")]);
assert_ser_eq!("a", &[Token::String("a")]);
assert_ser_eq!("a".to_string(), &[Token::Str("a")]);
assert_ser_eq!("a".to_string(), &[Token::BorrowedStr("a")]);
assert_ser_eq!("a".to_string(), &[Token::String("a")]);
} | rust_cleaned_test_functions.jsonl/44207 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 169
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2895,
368,
341,
262,
2060,
75861,
10714,
17223,
64,
497,
44590,
3323,
486,
2580,
445,
64,
899,
2558,
262,
2060,
75861,
10714,
17223,
64,
497,
44590,
3323,
486,
33,
7768,
291,
2580,
445,
64,
899,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parse_css_color_32() {
assert_eq!(
parse_css_color("hsl(240deg , )"),
Err(CssColorParseError::MissingColorComponent(
CssColorComponent::Saturation
))
);
} | rust_cleaned_test_functions.jsonl/114048 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 138
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
25924,
6714,
62,
18,
17,
368,
341,
286,
2060,
10714,
33673,
310,
4715,
25924,
6714,
445,
71,
3226,
7,
17,
19,
15,
16508,
1154,
220,
873,
4461,
310,
15495,
3025,
778,
1636,
14463,
1454,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_stream_fin_after_headers() {
let (mut client, mut server, request_stream_id) = connect_and_send_request(true);
server_send_response_and_exchange_packet(
&mut client,
&mut server,
request_stream_id,
HTTP_RESPONSE_HEADER_ONLY_2,
true,
);
// Recv HeaderReady with headers and fin.
let e = client.events().next().unwrap();
if let Http3ClientEvent::HeaderReady {
stream_id,
headers,
interim,
fin,
} = e
{
assert_eq!(stream_id, request_stream_id);
check_response_header_2(&headers);
assert!(fin);
assert!(!interim);
} else {
panic!("wrong event type");
}
// Stream should now be closed and gone
let mut buf = [0_u8; 100];
assert_eq!(
client.read_response_data(now(), 0, &mut buf),
Err(Error::InvalidStreamId)
);
} | rust_cleaned_test_functions.jsonl/101913 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 548
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12673,
39737,
19844,
26719,
368,
341,
286,
1077,
320,
6984,
2943,
11,
5206,
3538,
11,
1681,
12673,
842,
8,
284,
4564,
8378,
13565,
7893,
3715,
626,
286,
3538,
13565,
9655,
8378,
59212,
21078,
1006... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_proof_illegal_lower_bound() {
let dir = TempDir::new(super::gen_tempdir_name().as_str()).unwrap();
let path = dir.path();
let db = create_database(path);
super::proof_illegal_lower_bound(db);
} | rust_cleaned_test_functions.jsonl/115562 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 113
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
86757,
26743,
6428,
30425,
19447,
368,
341,
286,
1077,
5419,
284,
19944,
6184,
486,
931,
56040,
486,
4370,
11771,
3741,
1269,
1005,
300,
2895,
6011,
15454,
543,
286,
1077,
1815,
284,
5419,
3875,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_pretty_print() {
let d = BerObject::from_obj(BerObjectContent::Sequence(vec![
BerObject::from_int_slice(b"\x01\x00\x01"),
BerObject::from_int_slice(b"\x01\x00\x01"),
BerObject::from_obj(BerObjectContent::Set(vec![
BerObject::from_int_slice(b"\x01"),
BerObject::from_int_slice(b"\x02"),
])),
]));
println!("{:?}", d.as_pretty(0, 2));
let mut pp = d.as_pretty(0, 4);
pp.set_flag(PrettyPrinterFlag::ShowHeader);
println!("{:?}", pp);
} | rust_cleaned_test_functions.jsonl/37528 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 320
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
21322,
10064,
368,
341,
286,
1077,
294,
284,
8907,
1190,
486,
1499,
7328,
5349,
261,
1190,
2762,
486,
14076,
25592,
90515,
310,
8907,
1190,
486,
1499,
4042,
26488,
1883,
11934,
87,
15,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_calc_score() {
let hand = vec![BJCard::Two];
assert_eq!(2, calc_score(&hand));
let hand = vec![BJCard::Three];
assert_eq!(3, calc_score(&hand));
let hand = vec![BJCard::Jack];
assert_eq!(10, calc_score(&hand));
let hand = vec![BJCard::Two, BJCard::Two];
assert_eq!(4, calc_score(&hand));
let hand = vec![BJCard::Ace];
assert_eq!(11, calc_score(&hand));
let hand = vec![BJCard::Ace, BJCard::Ace, BJCard::Ace];
assert_eq!(13, calc_score(&hand));
let hand = vec![BJCard::Ace, BJCard::King];
assert_eq!(21, calc_score(&hand));
let hand = vec![BJCard::Ace, BJCard::Eight, BJCard::Four];
assert_eq!(13, calc_score(&hand));
} | rust_cleaned_test_functions.jsonl/74257 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 389
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
38241,
10405,
368,
341,
286,
1077,
1424,
284,
7486,
20703,
14978,
5770,
486,
11613,
935,
286,
2060,
10714,
10297,
17,
11,
10035,
10405,
2099,
10661,
3237,
286,
1077,
1424,
284,
7486,
20703,
14978,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_chrome_channel_data() -> Result<()> {
let mut data = vec![];
let mut messages = vec![];
// Decoding hex data into binary.
for h in &CHANDATA_TEST_HEX {
let b = match hex::decode(h) {
Ok(b) => b,
Err(_) => return Err(Error::new("hex decode error".to_owned()).into()),
};
data.push(b);
}
// All hex streams decoded to raw binary format and stored in data slice.
// Decoding packets to messages.
for packet in data {
let mut m = ChannelData::default();
m.raw = packet;
m.decode()?;
let mut encoded = ChannelData {
data: m.data.clone(),
number: m.number,
..Default::default()
};
encoded.encode();
let mut decoded = ChannelData::default();
decoded.raw = encoded.raw.clone();
decoded.decode()?;
assert_eq!(decoded, m, "should be equal");
messages.push(m);
}
assert_eq!(messages.len(), 2, "unexpected message slice list");
Ok(())
} | rust_cleaned_test_functions.jsonl/76716 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 487
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4138,
6648,
14571,
1769,
368,
1464,
5714,
71698,
341,
262,
1077,
5206,
821,
284,
7486,
0,
15078,
262,
1077,
5206,
6605,
284,
7486,
0,
40901,
262,
442,
3714,
3700,
12371,
821,
1119,
7868,
624,
26... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
#[test]
fn test_display() -> Result<(), Error> {
let public_key1: PublicKey = KEY_PUBLIC_ASN1_HEX.parse()?;
let public_key2: PublicKey = public_key1.to_string().parse()?;
let secret_key1: SecretKey = KEY_SECRET_ASN1_HEX.parse()?;
let secret_key2: SecretKey = secret_key1.to_string().parse()?;
assert_eq!(public_key1, public_key2);
assert_eq!(secret_key1.as_bytes(), secret_key2.as_bytes());
Ok(())
} | rust_cleaned_test_functions.jsonl/77 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 219
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14825,
368,
1464,
5714,
68843,
4600,
29,
341,
286,
1077,
584,
3097,
16,
25,
70280,
284,
12013,
36209,
1566,
18966,
16,
86502,
4632,
94136,
286,
1077,
584,
3097,
17,
25,
70280,
284,
584,
3097,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
#[test]
fn test_inbound_resend_loop_detection() {
define_dictionary!(
Logon,
Logout,
Heartbeat,
ResendRequest,
SequenceReset,
TestRequest,
);
//Connect and logon.
let (mut test_server, mut client, connection) =
TestStream::setup_test_server_and_logon(build_dictionary());
//Have server send TestRequest so Engine responds with a Heartbeat.
let mut message = new_fixt_message!(TestRequest);
message.msg_seq_num = 2;
message.test_req_id = b"test".to_vec();
test_server.send_message(message);
engine_poll_message!(client, connection, TestRequest);
let message = test_server.recv_message::<Heartbeat>();
assert_eq!(message.msg_seq_num, 2);
assert_eq!(message.test_req_id, b"test");
//Have server ignore the Heartbeat response by sending ResendRequest a few times. The client
//should eventually logout and disconnect.
const BASE_MSG_SEQ_NUM: u64 = 3;
for x in 0..AUTO_DISCONNECT_AFTER_INBOUND_RESEND_REQUEST_LOOP_COUNT {
let mut message = new_fixt_message!(ResendRequest);
message.msg_seq_num = BASE_MSG_SEQ_NUM + x;
message.begin_seq_no = 2;
message.end_seq_no = 0;
test_server.send_message(message);
engine_gap_fill_resend_request!(client, connection, 2..3);
let _ = engine_poll_message!(client, connection, ResendRequest);
let message = test_server.recv_message::<SequenceReset>();
assert_eq!(message.gap_fill_flag, true);
assert_eq!(message.new_seq_no, 3);
assert_eq!(message.msg_seq_num, 2);
}
let mut message = new_fixt_message!(ResendRequest);
message.msg_seq_num =
BASE_MSG_SEQ_NUM + AUTO_DISCONNECT_AFTER_INBOUND_RESEND_REQUEST_LOOP_COUNT;
message.begin_seq_no = 2;
message.end_seq_no = 0;
test_server.send_message(message);
let message = test_server.recv_message::<Logout>();
assert_eq!(
message.text,
b"Detected ResendRequest loop for BeginSeqNo 2".to_vec()
);
engine_poll_event!(client,EngineEvent::ConnectionTerminated(terminated_connection,reason) => {
assert_eq!(terminated_connection,connection);
assert!(if let ConnectionTerminatedReason::InboundResendRequestLoopError = reason { true } else { false });
});
assert!(test_server.is_stream_closed(Duration::from_secs(3)));
} | rust_cleaned_test_functions.jsonl/36 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 987
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1243,
10891,
4918,
408,
17198,
57505,
368,
341,
262,
6979,
42605,
33673,
286,
2835,
263,
345,
286,
46285,
345,
286,
17965,
22227,
345,
286,
1800,
408,
1900,
345,
286,
28871,
14828,
345,
286,
3393,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_outer_join() -> Result<()> {
let (temp, rain) = create_frames();
let joined = temp.outer_join(&rain, "days", "days")?;
println!("{:?}", &joined);
assert_eq!(joined.height(), 5);
assert_eq!(joined.column("days")?.sum::<i32>(), Some(7));
let df_left = df!(
"a"=> ["a", "b", "a", "z"],
"b"=>[1, 2, 3, 4],
"c"=>[6, 5, 4, 3]
)?;
let df_right = df!(
"a"=> ["b", "c", "b", "a"],
"k"=> [0, 3, 9, 6],
"c"=> [1, 0, 2, 1]
)?;
let out = df_left.outer_join(&df_right, "a", "a")?;
assert_eq!(out.column("c_right")?.null_count(), 1);
Ok(())
} | rust_cleaned_test_functions.jsonl/10280 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 450
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
67258,
31017,
368,
1464,
5714,
71698,
341,
286,
1077,
320,
3888,
11,
11174,
8,
284,
1855,
29319,
543,
286,
1077,
10859,
284,
2730,
53719,
31017,
2099,
29093,
11,
330,
13778,
497,
330,
13778,
899,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
#[test]
fn test_allows_unparsed_newlines_at_finish() {
let mut dec = MultiResponseDecoder::<TO>::new();
{
let mut stream = dec.process_next_chunk(b"\n");
assert!(stream.next().is_none());
}
assert!(dec.finish().is_ok());
} | rust_cleaned_test_functions.jsonl/14566 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 149
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5705,
4241,
4907,
41030,
5921,
7969,
3752,
42980,
368,
341,
286,
1077,
5206,
1622,
284,
17439,
2582,
20732,
27638,
5207,
6831,
931,
1428,
286,
341,
310,
1077,
5206,
4269,
284,
1622,
16988,
11257,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_consistency_tools() {
let dir = tempfile::Builder::new()
.prefix("test_consistency_tools")
.tempdir()
.unwrap();
let cfg = Config {
dir: dir.path().to_str().unwrap().to_owned(),
target_file_size: ReadableSize(128),
..Default::default()
};
let engine = Arc::new(Engine::open(cfg.clone()).unwrap());
let data = vec![b'x'; 128];
for index in 1..=100 {
for rid in 1..=10 {
if index == rid * rid {
fail::cfg("log_batch::corrupted_items", "return").unwrap();
}
append(&engine, rid, index, index + 1, Some(&data));
if index == rid * rid {
fail::remove("log_batch::corrupted_items");
}
}
}
drop(engine);
let ids = Engine::consistency_check(dir.path()).unwrap();
for (id, index) in ids.iter() {
assert_eq!(id * id, index + 1);
}
assert!(catch_unwind_silent(|| Engine::open(cfg.clone())).is_err());
} | rust_cleaned_test_functions.jsonl/25316 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 494
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31971,
47094,
39723,
368,
341,
262,
1077,
5419,
284,
54819,
486,
3297,
486,
931,
741,
286,
659,
11849,
445,
1944,
31971,
47094,
39723,
1138,
286,
659,
3888,
3741,
741,
286,
659,
15454,
543,
262,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
#[test]
fn test_serde() {
use rand::SeedableRng;
use rand_xorshift::XorShiftRng;
use serde_test::{assert_tokens, Token};
let mut rng = XorShiftRng::from_seed([1; 16]);
let priv_key = RSAPrivateKey::new(&mut rng, 64).expect("failed to generate key");
let priv_tokens = [
Token::Struct {
name: "RSAPrivateKey",
len: 3,
},
Token::Str("pubkey_components"),
Token::Struct {
name: "RSAPublicKey",
len: 2,
},
Token::Str("n"),
Token::Seq { len: Some(2) },
Token::U32(1296829443),
Token::U32(2444363981),
Token::SeqEnd,
Token::Str("e"),
Token::Seq { len: Some(1) },
Token::U32(65537),
Token::SeqEnd,
Token::StructEnd,
Token::Str("d"),
Token::Seq { len: Some(2) },
Token::U32(298985985),
Token::U32(2349628418),
Token::SeqEnd,
Token::Str("primes"),
Token::Seq { len: Some(2) },
Token::Seq { len: Some(1) },
Token::U32(3238068481),
Token::SeqEnd,
Token::Seq { len: Some(1) },
Token::U32(3242199299),
Token::SeqEnd,
Token::SeqEnd,
Token::StructEnd,
];
assert_tokens(&priv_key, &priv_tokens);
let priv_tokens = [
Token::Struct {
name: "RSAPublicKey",
len: 2,
},
Token::Str("n"),
Token::Seq { len: Some(2) },
Token::U32(1296829443),
Token::U32(2444363981),
Token::SeqEnd,
Token::Str("e"),
Token::Seq { len: Some(1) },
Token::U32(65537),
Token::SeqEnd,
Token::StructEnd,
];
assert_tokens(&RSAPublicKey::from(priv_key), &priv_tokens);
} | rust_cleaned_test_functions.jsonl/29039 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1209
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
75861,
450,
368,
341,
286,
990,
10382,
486,
41471,
480,
49,
968,
280,
286,
990,
10382,
76462,
13418,
486,
55,
269,
24841,
49,
968,
280,
286,
990,
61570,
4452,
22964,
2207,
28838,
11,
9660,
2315,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_find_summands_for_number() {
let list = vec![
35, 20, 15, 25, 47, 40, 62, 55, 65, 95, 102, 117, 150, 182, 127,
];
let expected: &[u64] = &[15, 25, 47, 40];
assert_eq!(find_summands_for_number(127, &list), Ok(expected));
} | rust_cleaned_test_functions.jsonl/54492 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 130
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21814,
10160,
1928,
82,
5478,
5500,
368,
341,
262,
1077,
1140,
284,
7486,
90515,
414,
220,
18,
20,
11,
220,
17,
15,
11,
220,
16,
20,
11,
220,
17,
20,
11,
220,
19,
22,
11,
220,
19,
15,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_quaternion() {
let quaternion = Quaternion::new(2f32, 3f32, 4f32, 5f32);
let matrix_short = Matrix4::from(quaternion);
let matrix_long = Matrix3::from(quaternion);
let matrix_long = Matrix4::from(matrix_long);
assert_approx_eq!(matrix_short, matrix_long);
} | rust_cleaned_test_functions.jsonl/30185 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 175
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11280,
16351,
368,
341,
310,
1077,
66775,
284,
24801,
486,
931,
7,
17,
69,
18,
17,
11,
220,
18,
69,
18,
17,
11,
220,
19,
69,
18,
17,
11,
220,
20,
69,
18,
17,
626,
310,
1077,
6172,
16673,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_copy_cache_info() {
let env = create_env();
// Create the required chroot dir hierarchy.
fs::create_dir_all(env.chroot_dir()).expect("Could not create dir hierarchy.");
assert!(env.copy_cache_info().is_ok());
// Make sure that the needed files truly exist.
const JAILER_CACHE_INFO: &str = "sys/devices/system/cpu/cpu0/cache";
let dest_path = env.chroot_dir.join(JAILER_CACHE_INFO);
assert!(fs::metadata(&dest_path).is_ok());
let index_dest_path = dest_path.join("index0");
assert!(fs::metadata(&index_dest_path).is_ok());
let entries = fs::read_dir(&index_dest_path).unwrap();
assert_eq!(entries.enumerate().count(), 6);
} | rust_cleaned_test_functions.jsonl/44162 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 323
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16096,
11529,
3109,
368,
341,
286,
1077,
6105,
284,
1855,
15879,
1428,
286,
442,
4230,
279,
2567,
521,
2888,
5419,
28922,
624,
286,
8619,
486,
3182,
4334,
5705,
16978,
5329,
2888,
4334,
6011,
1711... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_serialize_then_deserialize_with_many_options_is_equal_to_starting_value() {
let mut msg = new_test_msg();
msg.options.push(ConfigOption {
code: OptionCode::SubnetMask,
value: vec![255, 255, 255, 0],
});
msg.options.push(ConfigOption {
code: OptionCode::NameServer,
value: vec![8, 8, 8, 8],
});
msg.options.push(ConfigOption {
code: OptionCode::DhcpMessageType,
value: vec![MessageType::DHCPDISCOVER.into()],
});
assert_eq!(Message::from_buffer(&msg.serialize()).unwrap(), msg);
} | rust_cleaned_test_functions.jsonl/93672 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 315
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
88686,
68367,
15768,
9050,
6615,
22101,
8743,
6892,
11478,
2346,
4906,
287,
3142,
368,
341,
286,
1077,
5206,
3750,
284,
501,
4452,
6483,
543,
286,
3750,
10912,
2552,
33687,
5341,
341,
310,
2038,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_send_admin_direct_message_via_standard_circuit() {
// Set up dispatcher and mock sender
let mock_sender = MockSender::new();
let mut dispatcher = Dispatcher::new(Box::new(mock_sender.clone()));
let table = RoutingTable::default();
let reader: Box<dyn RoutingTableReader> = Box::new(table.clone());
let mut writer: Box<dyn RoutingTableWriter> = Box::new(table.clone());
let node_1234 = CircuitNode::new("1234".to_string(), vec!["123.0.0.1:0".to_string()], None);
let node_5678 = CircuitNode::new("5678".to_string(), vec!["123.0.0.1:1".to_string()], None);
let service_abc = Service::new(
"abc".to_string(),
"test".to_string(),
"1234".to_string(),
vec![],
);
let service_def = Service::new(
"def".to_string(),
"test".to_string(),
"5678".to_string(),
vec![],
);
// Add circuit and service to splinter state
let circuit = Circuit::new(
"alpha".into(),
vec![service_abc.clone(), service_def.clone()],
vec!["123".into(), "345".into()],
AuthorizationType::Trust,
);
writer
.add_circuit(
circuit.circuit_id().into(),
circuit,
vec![node_1234, node_5678],
)
.expect("Unable to add circuit");
let handler = AdminDirectMessageHandler::new("1234".into(), reader, vec![]);
dispatcher.set_handler(Box::new(handler));
let mut direct_message = AdminDirectMessage::new();
direct_message.set_circuit("alpha".into());
direct_message.set_sender("admin::1234".into());
direct_message.set_recipient("admin::5678".into());
direct_message.set_payload(b"test".to_vec());
direct_message.set_correlation_id("random_corr_id".into());
let direct_bytes = direct_message.write_to_bytes().unwrap();
assert!(dispatcher
.dispatch(
PeerTokenPair::new(
PeerAuthorizationToken::from_peer_id("1234"),
PeerAuthorizationToken::from_peer_id("5678"),
)
.into(),
&CircuitMessageType::ADMIN_DIRECT_MESSAGE,
direct_bytes
)
.is_ok());
let (id, message) = mock_sender.next_outbound().expect("No message was sent");
assert_network_message(
message,
id.into(),
PeerTokenPair::new(
PeerAuthorizationToken::from_peer_id("5678"),
PeerAuthorizationToken::from_peer_id("1234"),
),
CircuitMessageType::ADMIN_DIRECT_MESSAGE,
|msg: AdminDirectMessage| {
assert_eq!(msg.get_circuit(), "alpha");
assert_eq!(msg.get_sender(), "admin::1234");
assert_eq!(msg.get_recipient(), "admin::5678");
assert_eq!(msg.get_payload(), b"test");
assert_eq!(msg.get_correlation_id(), "random_corr_id");
},
)
} | rust_cleaned_test_functions.jsonl/128133 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1594
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13565,
12207,
32871,
6462,
80710,
48688,
666,
37268,
368,
341,
286,
442,
2573,
705,
38799,
323,
7860,
4646,
198,
286,
1077,
7860,
54356,
284,
14563,
20381,
486,
931,
543,
286,
1077,
5206,
38799,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parse_complex_expression() {
check(
"-(2-((10+10)))*20+-5",
expect![[r#"
Root@0..20
Exp_Binary@0..20
Exp_Binary@0..17
Exp_UnaryPrefix@0..14
Sym_Minus@0..1 "-"
Exp_Paren@1..14
Sym_LParen@1..2 "("
Exp_Binary@2..13
Exp_Literal@2..3
Lit_Integer@2..3 "2"
Sym_Minus@3..4 "-"
Exp_Paren@4..13
Sym_LParen@4..5 "("
Exp_Paren@5..12
Sym_LParen@5..6 "("
Exp_Binary@6..11
Exp_Literal@6..8
Lit_Integer@6..8 "10"
Sym_Plus@8..9 "+"
Exp_Literal@9..11
Lit_Integer@9..11 "10"
Sym_RParen@11..12 ")"
Sym_RParen@12..13 ")"
Sym_RParen@13..14 ")"
Sym_Asterisk@14..15 "*"
Exp_Literal@15..17
Lit_Integer@15..17 "20"
Sym_Plus@17..18 "+"
Exp_UnaryPrefix@18..20
Sym_Minus@18..19 "-"
Exp_Literal@19..20
Lit_Integer@19..20 "5"
"#]],
)
} | rust_cleaned_test_functions.jsonl/40935 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1253
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
41522,
28068,
368,
341,
286,
1779,
1006,
310,
6523,
7,
17,
12,
1188,
16,
15,
10,
16,
15,
593,
4806,
17,
15,
21473,
20,
756,
310,
1720,
0,
15505,
81,
2,
698,
394,
18854,
31,
15,
496,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_find_all_refs_with_scope() {
let code = r#"
//- /lib.rs
mod foo;
mod bar;
pub fn quux<|>() {}
//- /foo.rs
fn f() { super::quux(); }
//- /bar.rs
fn f() { super::quux(); }
"#;
check_with_scope(
code,
None,
expect![[r#"
quux Function FileId(0) 19..35 26..30 Other
FileId(1) 16..20 StructLiteral
FileId(2) 16..20 StructLiteral
"#]],
);
check_with_scope(
code,
Some(SearchScope::single_file(FileId(2))),
expect![[r#"
quux Function FileId(0) 19..35 26..30 Other
FileId(2) 16..20 StructLiteral
"#]],
);
} | rust_cleaned_test_functions.jsonl/47779 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 531
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21814,
5705,
60638,
6615,
23199,
368,
341,
286,
1077,
2038,
284,
435,
2,
698,
310,
78406,
608,
2740,
25638,
198,
310,
1463,
15229,
280,
310,
1463,
3619,
401,
310,
6675,
5168,
922,
2200,
27,
91,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_2() {
let s = String::from("");
let t = String::from("y");
assert_eq!(Solution::find_the_difference(s, t), 'y');
} | rust_cleaned_test_functions.jsonl/56115 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 84
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
17,
368,
341,
286,
1077,
274,
284,
923,
486,
1499,
13056,
286,
1077,
259,
284,
923,
486,
1499,
445,
88,
3071,
286,
2060,
10714,
10297,
36842,
486,
3903,
16068,
47525,
1141,
11,
259,
701,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_locate_binary_2_args() {
let test_cases = vec![
(None, None, None),
(None, Some("abc"), None),
(Some("abc"), None, None),
(Some(""), Some("foobArbar"), Some(1)),
(Some(""), Some(""), Some(1)),
(Some("xxx"), Some(""), Some(0)),
(Some("BaR"), Some("foobArbar"), Some(0)),
(Some("bar"), Some("foobArbar"), Some(7)),
(
Some("好世"),
Some("你好世界"),
Some(1 + "你好世界".find("好世").unwrap() as i64),
),
];
for (substr, s, expect_output) in test_cases {
let output = RpnFnScalarEvaluator::new()
.push_param(substr.map(|v| v.as_bytes().to_vec()))
.push_param(s.map(|v| v.as_bytes().to_vec()))
.evaluate(ScalarFuncSig::LocateBinary2Args)
.unwrap();
assert_eq!(output, expect_output);
}
} | rust_cleaned_test_functions.jsonl/71414 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 584
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13400,
349,
31761,
62,
17,
8384,
368,
341,
286,
1077,
1273,
41427,
284,
7486,
90515,
310,
320,
4064,
11,
2240,
11,
2240,
1326,
310,
320,
4064,
11,
4329,
445,
13683,
3975,
2240,
1326,
310,
320,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_superimpose_style_sections_1() {
let sections_1 = vec![(*SYNTAX_STYLE, "ab")];
let sections_2 = vec![(*SYNTAX_HIGHLIGHTED_STYLE, "ab")];
let superimposed = vec![(*SUPERIMPOSED_STYLE, "ab".to_string())];
assert_eq!(
superimpose_style_sections(§ions_1, §ions_2, true, SyntectStyle::default()),
superimposed
);
} | rust_cleaned_test_functions.jsonl/13388 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 236
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
38886,
318,
2900,
15117,
59485,
62,
16,
368,
341,
310,
1077,
14158,
62,
16,
284,
7486,
20703,
4071,
18416,
78221,
41775,
11,
330,
370,
899,
935,
310,
1077,
14158,
62,
17,
284,
7486,
20703,
4071,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_slice_from() {
assert_eq!(&"abcd"[0..], "abcd");
assert_eq!(&"abcd"[2..], "cd");
assert_eq!(&"abcd"[4..], "");
} | rust_cleaned_test_functions.jsonl/63092 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 78
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26488,
5673,
368,
341,
262,
2060,
10714,
0,
2099,
1,
68644,
36864,
15,
496,
1125,
330,
68644,
797,
262,
2060,
10714,
0,
2099,
1,
68644,
36864,
17,
496,
1125,
330,
4385,
797,
262,
2060,
10714,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_positive_float_number() {
fn valid_parse(float_str: &str, expected_val: f64, expected_remaining: &str) {
let (val, remaining) = positive_float_number().parse(float_str).unwrap();
assert_eq!(remaining, expected_remaining);
assert_nearly_equals(val, expected_val);
}
fn error_parse(float_str: &str) {
assert!(positive_float_number().parse(float_str).is_err());
}
valid_parse("1.0", 1.0, "");
valid_parse("1", 1.0, "");
valid_parse("0.234234 aaa", 0.234234f64, " aaa");
error_parse(".3332");
error_parse("1.");
error_parse("-1.");
} | rust_cleaned_test_functions.jsonl/64401 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 336
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
54160,
17586,
5500,
368,
341,
286,
5168,
2697,
21039,
8268,
2895,
25,
609,
495,
11,
3601,
6189,
25,
282,
21,
19,
11,
3601,
59244,
25,
609,
495,
8,
341,
310,
1077,
320,
831,
11,
9664,
8,
284,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.