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_is_latin() {
assert_eq!(is_latin('z'), true);
assert_eq!(is_latin('A'), true);
assert_eq!(is_latin('č'), true);
assert_eq!(is_latin('š'), true);
assert_eq!(is_latin('Ĵ'), true);
assert_eq!(is_latin('ж'), false);
} | rust_cleaned_test_functions.jsonl/123596 | {
"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,
6892,
907,
14768,
368,
341,
286,
2060,
10714,
10297,
285,
907,
14768,
492,
89,
4567,
830,
317,
286,
2060,
10714,
10297,
285,
907,
14768,
492,
32,
4567,
830,
317,
286,
2060,
10714,
10297,
285,
90... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_extract_package_version_with_null_version() -> io::Result<()> {
let config_name = "package.json";
let config_content = json::json!({
"name": "starship",
"version": null
})
.to_string();
let project_dir = create_project_dir()?;
fill_config(&project_dir, config_name, Some(&config_content))?;
expect_output(&project_dir, None, None)?;
project_dir.close()
} | rust_cleaned_test_functions.jsonl/19238 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 217
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39123,
26328,
9438,
6615,
15162,
9438,
368,
1464,
6399,
486,
2077,
71698,
341,
286,
1077,
2193,
1269,
284,
330,
1722,
4323,
876,
286,
1077,
2193,
7495,
284,
2951,
486,
2236,
0,
2262,
310,
330,
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... | 4 |
#[test]
fn test_default() {
let po = Command::new(PROGNAME)
.output()
.unwrap_or_else(|err| panic!("{}", err));
let out = str::from_utf8(&po.stdout[..]).unwrap().trim_right();
let expected = env::current_dir().unwrap().into_os_string().into_string().unwrap();
assert_eq!(out, expected);
} | rust_cleaned_test_functions.jsonl/24480 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 143
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9993,
368,
341,
262,
1077,
3193,
284,
7348,
486,
931,
55681,
38,
7535,
340,
286,
659,
3006,
741,
286,
659,
15454,
8734,
62628,
22428,
615,
91,
21975,
79878,
1848,
3237,
262,
1077,
700,
284,
607,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_history_rejects_invalid_versions() {
for (api_level, abi_revision, err) in [
(
"some-version",
"1",
"invalid value: string \"some-version\", expected an unsigned integer at line 1 column 123",
),
(
"-1",
"1",
"invalid value: string \"-1\", expected an unsigned integer at line 1 column 113",
),
(
"1",
"some-revision",
"invalid value: string \"some-revision\", expected a hex unsigned integer at line 1 column 107",
),
(
"1",
"-1",
"invalid value: string \"-1\", expected a hex unsigned integer at line 1 column 96",
),
] {
let expected_bytes = serde_json::to_vec(&serde_json::json!({
"data": {
"name": VERSION_HISTORY_NAME,
"type": VERSION_HISTORY_TYPE,
"versions": [
{
"api_level": api_level,
"abi_revision": abi_revision,
},
],
},
"schema_id": VERSION_HISTORY_SCHEMA_ID,
}))
.unwrap();
assert_eq!(parse_version_history(&expected_bytes[..]).unwrap_err().to_string(), err);
}
} | rust_cleaned_test_functions.jsonl/30913 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 896
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
19802,
1288,
583,
82,
31433,
65148,
368,
341,
286,
369,
320,
2068,
8274,
11,
61050,
59856,
11,
1848,
8,
304,
2278,
310,
2399,
394,
330,
14689,
45367,
756,
394,
330,
16,
756,
394,
330,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_add_mul() {
let a = backprop(scalar(3.0));
let b = backprop(scalar(2.0));
let c = backprop(scalar(1.0));
let y = a.clone() * b.clone() + c.clone();
assert_eq!(*y, scalar(7.0));
let grads = gradients(&[y], &vec![a.clone(), b.clone()], false);
assert_eq!(&*grads[0], scalar(2.0));
assert_eq!(&*grads[1], scalar(3.0));
} | rust_cleaned_test_functions.jsonl/35594 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 188
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
24944,
368,
341,
262,
1077,
264,
284,
1182,
2674,
1141,
59153,
7,
18,
13,
15,
1106,
262,
1077,
293,
284,
1182,
2674,
1141,
59153,
7,
17,
13,
15,
1106,
262,
1077,
272,
284,
1182,
2674,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_sources_get_length_utf16() {
let (sources, _) = setup();
let c = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
let tests = c.join("tests");
let specifier = ModuleSpecifier::resolve_path(
&tests.join("001_hello.js").to_string_lossy(),
)
.unwrap();
let actual = sources.get_length_utf16(&specifier);
assert!(actual.is_some());
let actual = actual.unwrap();
assert_eq!(actual, 28);
} | rust_cleaned_test_functions.jsonl/63553 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 197
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
52896,
3062,
5118,
39453,
16,
21,
368,
341,
262,
1077,
320,
39651,
11,
27439,
284,
6505,
543,
262,
1077,
272,
284,
7933,
15064,
486,
1499,
16978,
486,
947,
29387,
445,
34,
7581,
46,
25143,
91120... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_empty0() {
assert_decompressed_input_matches_output(include_bytes!("../../testdata/empty.compressed.00"),
include_bytes!("../../testdata/empty"),
65536,
65536);
} | rust_cleaned_test_functions.jsonl/26432 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 199
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15124,
15,
368,
341,
220,
2060,
2259,
45703,
5898,
38344,
7645,
77863,
12524,
17223,
2748,
92425,
14,
3194,
905,
14318,
13,
15,
15,
4461,
14265,
2924,
12524,
17223,
2748,
92425,
14,
3194,
4461,
14... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_fq_sqrt() {
let mut rng = XorShiftRng::from_seed([
0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc,
0xe5,
]);
assert_eq!(Fq::zero().sqrt().unwrap(), Fq::zero());
for _ in 0..1000 {
let a = Fq::random(&mut rng);
let nega = a.neg();
let b = a.square();
let b = b.sqrt().unwrap();
assert!(a == b || nega == b);
}
for _ in 0..1000 {
let a = Fq::random(&mut rng);
let tmp = a.sqrt();
if tmp.is_some().into() {
assert_eq!(a, tmp.unwrap().square());
}
}
} | rust_cleaned_test_functions.jsonl/79194 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 385
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
761,
80,
92199,
368,
341,
262,
1077,
5206,
28422,
284,
1599,
269,
24841,
49,
968,
486,
1499,
33809,
8956,
286,
220,
15,
87,
20,
24,
11,
220,
15,
87,
21,
17,
11,
220,
15,
42459,
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,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
#[test]
fn test_overlap() {
DelayPlusPoolProblem { input: vec![0.0, 1.0], pulse: 1, delay: 0, stride: 1, pool_window: 2 }
.run()
.unwrap()
} | rust_cleaned_test_functions.jsonl/125717 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 83
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
65794,
368,
341,
262,
39793,
21807,
10551,
31198,
314,
1946,
25,
7486,
20703,
15,
13,
15,
11,
220,
16,
13,
15,
1125,
27235,
25,
220,
16,
11,
7626,
25,
220,
15,
11,
19228,
25,
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,
1,
1
] | 1 |
#[test]
fn test_issue486_multi_types() {
let hdr = indoc! {"
namespace a {
namespace spanner {
struct Key {};
}
} // namespace a
namespace b {
namespace spanner {
typedef int Key;
}
} // namespace b
namespace c {
namespace spanner {
enum Key { A, B };
}
} // namespace c
namespace spanner {
class Key {
public:
bool a(a::spanner::Key &);
bool b(b::spanner::Key &);
bool c(c::spanner::Key &);
};
} // namespace spanner
"};
let rs = quote! {};
run_test(
"",
hdr,
rs,
&["spanner::Key", "a::spanner::Key", "b::spanner::Key"],
&[],
);
} | rust_cleaned_test_functions.jsonl/9977 | {
"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,
53340,
19,
23,
21,
25133,
9763,
368,
341,
262,
1077,
36615,
284,
1257,
509,
0,
314,
698,
286,
4473,
264,
341,
310,
4473,
9390,
1194,
341,
394,
2036,
5309,
9321,
310,
456,
286,
335,
442,
4473,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_overlap_cleanup() {
let mut cluster = new_node_cluster(0, 3);
// Disable raft log gc in this test case.
cluster.cfg.raft_store.raft_log_gc_tick_interval = ReadableDuration::secs(60);
let gen_snapshot_fp = "region_gen_snap";
let pd_client = Arc::clone(&cluster.pd_client);
// Disable default max peer count check.
pd_client.disable_default_operator();
let region_id = cluster.run_conf_change();
pd_client.must_add_peer(region_id, new_peer(2, 2));
cluster.must_put(b"k1", b"v1");
must_get_equal(&cluster.get_engine(2), b"k1", b"v1");
cluster.must_transfer_leader(region_id, new_peer(2, 2));
// can still work as expected.
fail::cfg(gen_snapshot_fp, "pause").unwrap();
pd_client.must_add_peer(region_id, new_peer(3, 3));
cluster.must_put(b"k3", b"v3");
assert_snapshot(&cluster.get_snap_dir(2), region_id, true);
let region1 = cluster.get_region(b"k1");
cluster.must_split(®ion1, b"k2");
must_get_equal(&cluster.get_engine(3), b"k1", b"v1");
fail::cfg(gen_snapshot_fp, "pause").unwrap();
// Overlap snapshot should be deleted.
assert_snapshot(&cluster.get_snap_dir(3), region_id, false);
fail::remove(gen_snapshot_fp);
} | rust_cleaned_test_functions.jsonl/68037 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 538
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
65794,
42444,
368,
341,
262,
1077,
5206,
10652,
284,
501,
5084,
28441,
7,
15,
11,
220,
18,
317,
262,
442,
28027,
52455,
1487,
22122,
304,
419,
1273,
1142,
624,
262,
10652,
30481,
13,
2944,
14809... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_big_endian_from_limbs_same_length() {
#[cfg(target_pointer_width = "32")]
let limbs = [
0xbccddeef, 0x89900aab, 0x45566778, 0x01122334, 0xddeeff00, 0x99aabbcc, 0x55667788,
0x11223344,
];
#[cfg(target_pointer_width = "64")]
let limbs = [
0x89900aab_bccddeef,
0x01122334_45566778,
0x99aabbcc_ddeeff00,
0x11223344_55667788,
];
let expected = [
0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee,
0xff, 0x00, 0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x90, 0x0a, 0xab,
0xbc, 0xcd, 0xde, 0xef,
];
let mut out = [0xabu8; 32];
big_endian_from_limbs(&limbs[..], &mut out);
assert_eq!(&out[..], &expected[..]);
} | rust_cleaned_test_functions.jsonl/10666 | {
"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,
36386,
87193,
5673,
58191,
1279,
33574,
5118,
368,
341,
286,
11506,
14072,
8637,
21425,
7927,
284,
330,
18,
17,
5422,
286,
1077,
48595,
284,
2278,
310,
220,
15,
7929,
638,
88089,
823,
11,
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... | 1 |
#[test]
fn test_parse_patch_machine_config_request() {
assert!(parse_patch_machine_config(&Body::new("invalid_payload")).is_err());
let body = r#"{}"#;
assert!(parse_patch_machine_config(&Body::new(body)).is_err());
let body = r#"{
"vcpu_count": 8,
"mem_size_mib": 1024
}"#;
assert!(parse_patch_machine_config(&Body::new(body)).is_ok());
let body = r#"{
"vcpu_count": 8,
"mem_size_mib": 1024,
"ht_enabled": false
}"#;
assert!(parse_patch_machine_config(&Body::new(body)).is_ok());
} | rust_cleaned_test_functions.jsonl/33420 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 356
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
39643,
38695,
5332,
7893,
368,
341,
286,
2060,
10297,
6400,
39643,
38695,
5332,
2099,
5444,
486,
931,
445,
11808,
32813,
15197,
285,
9266,
5231,
286,
1077,
2487,
284,
435,
55543,
6257,
57676,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_checksum() {
assert_eq!(checksum(&[0x01, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00]), 0x79);
} | rust_cleaned_test_functions.jsonl/86327 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 72
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
64038,
368,
341,
286,
2060,
10714,
10297,
70740,
2099,
58,
15,
87,
15,
16,
11,
220,
15,
87,
23,
21,
11,
220,
15,
87,
15,
15,
11,
220,
15,
87,
15,
15,
11,
220,
15,
87,
15,
15,
11,
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_route_monitoring_to_another_slack_channel() -> Result<()> {
test_parse_and_merge(TestSet {
manifest_yml: r###"---
sentry:
silent: false"###
.into(),
env_yml: r###"---
sentry:
# it's not possible to turn sentry off if defined in the service manifest
silent: true
slack: COVERRIDE"###
.into(),
default_channel: "CDEFTEAM8".into(),
crd_expected: r###"---
sentry:
slack: COVERRIDE
silent: true"###
.into(),
})
} | rust_cleaned_test_functions.jsonl/90980 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 278
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28109,
40112,
287,
2346,
12008,
1575,
11886,
473,
14571,
368,
1464,
5714,
71698,
341,
286,
1273,
21039,
8378,
20888,
31159,
1649,
341,
310,
14455,
4178,
1014,
25,
435,
14374,
1,
10952,
82,
4085,
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_outer_line_comment() {
let tokens = quote! {
/// doc
};
let expected = "# [doc = r\" doc\"]";
assert_eq!(expected, tokens.to_string());
} | rust_cleaned_test_functions.jsonl/53418 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 82
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
67258,
6528,
17638,
368,
341,
262,
1077,
11211,
284,
12641,
0,
341,
286,
1048,
4629,
198,
262,
2605,
262,
1077,
3601,
284,
5869,
508,
5236,
284,
435,
2105,
4629,
75104,
876,
262,
2060,
10714,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_multi_union_schema() {
let schema = Schema::from_str(r#"["null", "int", "float", "string", "bytes"]"#);
assert!(schema.is_ok());
let schema = schema.unwrap();
let node = schema.top_node();
assert_eq!(SchemaKind::from(&schema), SchemaKind::Union);
let union_schema = match node.inner {
SchemaPiece::Union(u) => u,
_ => unreachable!(),
};
assert_eq!(union_schema.variants().len(), 5);
let mut variants = union_schema.variants().iter();
assert_eq!(
SchemaKind::from(node.step(variants.next().unwrap())),
SchemaKind::Null
);
assert_eq!(
SchemaKind::from(node.step(variants.next().unwrap())),
SchemaKind::Int
);
assert_eq!(
SchemaKind::from(node.step(variants.next().unwrap())),
SchemaKind::Float
);
assert_eq!(
SchemaKind::from(node.step(variants.next().unwrap())),
SchemaKind::String
);
assert_eq!(
SchemaKind::from(node.step(variants.next().unwrap())),
SchemaKind::Bytes
);
assert_eq!(variants.next(), None);
} | rust_cleaned_test_functions.jsonl/23005 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 632
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25133,
51621,
25371,
368,
341,
286,
1077,
10802,
284,
12539,
486,
1499,
2895,
2601,
55543,
1183,
2921,
497,
330,
396,
497,
330,
3649,
497,
330,
917,
497,
330,
9651,
1341,
57676,
317,
286,
2060,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_max_by() {
let xs: &[int] = &[-3, 0, 1, 5, -10];
assert_eq!(*xs.iter().max_by(|x| x.abs()).unwrap(), -10);
} | rust_cleaned_test_functions.jsonl/1018 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 90
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6345,
3710,
368,
341,
286,
1077,
11943,
25,
44590,
396,
60,
284,
609,
7609,
18,
11,
220,
15,
11,
220,
16,
11,
220,
20,
11,
481,
16,
15,
935,
286,
2060,
10714,
0,
4071,
18561,
19471,
1005,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_angle_z_rotate_vector1() {
let rotation = Rotation3::from_angle_z(Degrees(90_f64));
let vector = Vector3::unit_x();
let expected = Vector3::unit_y();
let result = rotation.rotate_vector(&vector);
assert!(relative_eq!(result, expected, epsilon = 1e-8));
} | rust_cleaned_test_functions.jsonl/70497 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 147
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5673,
21727,
6415,
60834,
12247,
16,
368,
341,
286,
1077,
12695,
284,
47528,
18,
486,
1499,
21727,
6415,
5432,
791,
7858,
7,
24,
15,
761,
21,
19,
1106,
286,
1077,
4621,
284,
4196,
18,
486,
384... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_not_all_plains() {
// Check that the `ChunkBiomes` was overridden correctly.
let gen = DistortedVoronoiBiomeGenerator::default();
let chunk = ChunkPosition::new(5433, 132);
let biomes = gen.generate_for_chunk(chunk, 8344);
println!("{:?}", biomes);
let mut num_plains = 0;
for x in 0..16 {
for z in 0..16 {
if biomes.biome_at(x, z) == Biome::Plains {
num_plains += 1;
}
}
}
assert_ne!(num_plains, 16 * 16);
} | rust_cleaned_test_functions.jsonl/43347 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 318
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7913,
5705,
6317,
1735,
368,
341,
286,
442,
4248,
429,
279,
1565,
28304,
36096,
20347,
63,
572,
51456,
12440,
624,
286,
1077,
4081,
284,
27604,
13595,
53,
84850,
6728,
36096,
635,
12561,
486,
2258... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_offline_pay_tx() {
let TestValidator {
server,
leader_data,
alice,
ledger_path,
..
} = TestValidator::run();
let bob_pubkey = Pubkey::new_rand();
let (sender, receiver) = channel();
run_local_faucet(alice, sender, None);
let faucet_addr = receiver.recv().unwrap();
let rpc_client = RpcClient::new_socket(leader_data.rpc);
let default_signer = Keypair::new();
let default_offline_signer = Keypair::new();
let mut config_offline = CliConfig::default();
config_offline.json_rpc_url =
format!("http://{}:{}", leader_data.rpc.ip(), leader_data.rpc.port());
config_offline.signers = vec![&default_offline_signer];
let mut config_online = CliConfig::default();
config_online.json_rpc_url =
format!("http://{}:{}", leader_data.rpc.ip(), leader_data.rpc.port());
config_online.signers = vec![&default_signer];
assert_ne!(
config_offline.signers[0].pubkey(),
config_online.signers[0].pubkey()
);
request_and_confirm_airdrop(
&rpc_client,
&faucet_addr,
&config_offline.signers[0].pubkey(),
50,
)
.unwrap();
request_and_confirm_airdrop(
&rpc_client,
&faucet_addr,
&config_online.signers[0].pubkey(),
50,
)
.unwrap();
check_balance(50, &rpc_client, &config_offline.signers[0].pubkey());
check_balance(50, &rpc_client, &config_online.signers[0].pubkey());
let (blockhash, _) = rpc_client.get_recent_blockhash().unwrap();
config_offline.command = CliCommand::Pay(PayCommand {
lamports: 10,
to: bob_pubkey,
blockhash_query: BlockhashQuery::None(blockhash),
sign_only: true,
..PayCommand::default()
});
let sig_response = process_command(&config_offline).unwrap();
check_balance(50, &rpc_client, &config_offline.signers[0].pubkey());
check_balance(50, &rpc_client, &config_online.signers[0].pubkey());
check_balance(0, &rpc_client, &bob_pubkey);
let sign_only = parse_sign_only_reply_string(&sig_response);
assert!(sign_only.has_all_signers());
let offline_presigner = sign_only
.presigner_of(&config_offline.signers[0].pubkey())
.unwrap();
let online_pubkey = config_online.signers[0].pubkey();
config_online.signers = vec![&offline_presigner];
config_online.command = CliCommand::Pay(PayCommand {
lamports: 10,
to: bob_pubkey,
blockhash_query: BlockhashQuery::FeeCalculator(blockhash_query::Source::Cluster, blockhash),
..PayCommand::default()
});
process_command(&config_online).unwrap();
check_balance(40, &rpc_client, &config_offline.signers[0].pubkey());
check_balance(50, &rpc_client, &online_pubkey);
check_balance(10, &rpc_client, &bob_pubkey);
server.close().unwrap();
remove_dir_all(ledger_path).unwrap();
} | rust_cleaned_test_functions.jsonl/88224 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1289
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13651,
1056,
28925,
17805,
368,
341,
262,
1077,
3393,
14256,
341,
286,
3538,
345,
286,
7653,
1769,
345,
286,
70433,
345,
286,
46933,
2638,
345,
286,
54538,
262,
335,
284,
3393,
14256,
486,
6108,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_utf8() {
let bytes_name = Name::from_labels(vec![b"WWW" as &[u8], b"example", b"COM"]).unwrap();
let utf8_name = Name::from_utf8("WWW.example.COM.").unwrap();
let lower_name = Name::from_utf8("www.example.com.").unwrap();
assert!(!bytes_name.eq_case(&utf8_name));
assert!(lower_name.eq_case(&utf8_name));
} | rust_cleaned_test_functions.jsonl/38221 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 183
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5673,
39453,
23,
368,
341,
286,
1077,
5820,
1269,
284,
3988,
486,
1499,
14547,
25592,
20703,
65,
1,
45508,
1,
438,
44590,
84,
23,
1125,
293,
1,
8687,
497,
293,
1,
8696,
45014,
15454,
543,
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_check_async_commit_txn_status() {
let do_test = |rollback_if_not_exist: bool| {
let engine = TestEngineBuilder::new().build().unwrap();
let r = rollback_if_not_exist;
must_prewrite_put_async_commit(&engine, b"k1", b"v", b"k1", &Some(vec![]), 1, 2);
// All following check_txn_status should return the unchanged lock information
// caller_start_ts == current_ts == 0
must_success(
&engine,
b"k1",
1,
0,
0,
r,
false,
false,
uncommitted(100, 2, false),
);
// caller_start_ts != 0
must_success(
&engine,
b"k1",
1,
5,
0,
r,
false,
false,
uncommitted(100, 2, false),
);
// current_ts != 0
must_success(
&engine,
b"k1",
1,
0,
8,
r,
false,
false,
uncommitted(100, 2, false),
);
must_success(
&engine,
b"k1",
1,
10,
12,
r,
false,
false,
uncommitted(100, 2, false),
);
// caller_start_ts == u64::MAX
must_success(
&engine,
b"k1",
1,
TimeStamp::max(),
12,
r,
false,
false,
uncommitted(100, 2, false),
);
// current_ts == u64::MAX
must_success(
&engine,
b"k1",
1,
12,
TimeStamp::max(),
r,
false,
false,
uncommitted(100, 2, false),
);
// force_sync_commit = true
must_success(
&engine,
b"k1",
1,
12,
TimeStamp::max(),
r,
true,
false,
|s| s == TtlExpire,
);
must_unlocked(&engine, b"k1");
must_get_rollback_protected(&engine, b"k1", 1, false);
must_acquire_pessimistic_lock(&engine, b"k2", b"k2", 15, 15);
must_pessimistic_prewrite_put_async_commit(
&engine,
b"k2",
b"v",
b"k2",
&Some(vec![]),
15,
16,
true,
17,
);
// All following check_txn_status should return the unchanged lock information
// caller_start_ts == current_ts == 0
must_success(
&engine,
b"k2",
15,
0,
0,
r,
false,
false,
uncommitted(100, 17, false),
);
// caller_start_ts != 0
must_success(
&engine,
b"k2",
15,
18,
0,
r,
false,
false,
uncommitted(100, 17, false),
);
// current_ts != 0
must_success(
&engine,
b"k2",
15,
0,
18,
r,
false,
false,
uncommitted(100, 17, false),
);
must_success(
&engine,
b"k2",
15,
19,
20,
r,
false,
false,
uncommitted(100, 17, false),
);
// caller_start_ts == u64::MAX
must_success(
&engine,
b"k2",
15,
TimeStamp::max(),
20,
r,
false,
false,
uncommitted(100, 17, false),
);
// current_ts == u64::MAX
must_success(
&engine,
b"k2",
15,
20,
TimeStamp::max(),
r,
false,
false,
uncommitted(100, 17, false),
);
// force_sync_commit = true
must_success(
&engine,
b"k2",
15,
20,
TimeStamp::max(),
r,
true,
false,
|s| s == TtlExpire,
);
must_unlocked(&engine, b"k2");
must_get_rollback_protected(&engine, b"k2", 15, true);
must_acquire_pessimistic_lock_for_large_txn(&engine, b"k3", b"k3", 20, 20, 100);
must_acquire_pessimistic_lock_for_large_txn(&engine, b"k4", b"k3", 20, 25, 100);
must_pessimistic_prewrite_put_async_commit(
&engine,
b"k4",
b"v",
b"k3",
&Some(vec![]),
20,
25,
true,
28,
);
must_success(
&engine,
b"k3",
20,
0,
0,
r,
false,
false,
uncommitted(100, 21, false),
);
must_acquire_pessimistic_lock_with_ttl(&engine, b"k5", b"k5", 30, 30, 100);
must_acquire_pessimistic_lock_with_ttl(&engine, b"k6", b"k5", 30, 35, 100);
must_pessimistic_prewrite_put_async_commit(
&engine,
b"k6",
b"v",
b"k5",
&Some(vec![]),
30,
35,
true,
36,
);
must_success(
&engine,
b"k5",
30,
0,
0,
r,
false,
false,
uncommitted(100, 0, false),
);
};
do_test(true);
do_test(false);
} | rust_cleaned_test_functions.jsonl/125139 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 4858
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7200,
28346,
36346,
92299,
4773,
368,
341,
286,
1077,
653,
4452,
284,
760,
33559,
11119,
7913,
35906,
25,
1807,
91,
341,
310,
1077,
4712,
284,
3393,
4571,
3297,
486,
931,
1005,
5834,
1005,
15454,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_close_session_on_stream_opened() {
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async {
let (remote, local) = MockSocket::new();
let config = Config::default();
let mut session = Session::new_server(local, config);
tokio::spawn(async move {
while let Some(Ok(mut stream)) = session.next().await {
tokio::spawn(async move {
let mut buf = [0; 100];
let _ignore = stream.read(&mut buf).await;
});
}
});
let mut client = Session::new_client(remote, config);
let mut control = client.control();
let mut stream = client.open_stream().unwrap();
tokio::spawn(async move {
loop {
match client.next().await {
Some(Ok(_)) => (),
Some(Err(_)) => {
break;
}
None => {
break;
}
}
}
});
tokio::spawn(async move {
control.close().await;
});
let mut buf = [0; 100];
let _ignore = stream.read(&mut buf).await;
})
} | rust_cleaned_test_functions.jsonl/74921 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 853
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12704,
12316,
4470,
12673,
11311,
291,
368,
341,
286,
1077,
16677,
284,
9628,
815,
486,
22255,
486,
15123,
486,
931,
1005,
15454,
1428,
286,
16677,
15697,
4470,
18285,
341,
310,
1077,
320,
18147,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_process_entrypoint_without_adopt_shred_version() {
let node_keypair = Arc::new(Keypair::new());
let cluster_info = Arc::new(ClusterInfo::new(
{
let mut contact_info =
ContactInfo::new_localhost(&node_keypair.pubkey(), timestamp());
contact_info.shred_version = 2;
contact_info
},
node_keypair,
));
assert_eq!(cluster_info.my_shred_version(), 2);
// address
let entrypoint_gossip_addr = socketaddr!("127.0.0.2:1234");
let mut entrypoint = ContactInfo::new_localhost(&Pubkey::default(), timestamp());
entrypoint.gossip = entrypoint_gossip_addr;
assert_eq!(entrypoint.shred_version, 0);
cluster_info.set_entrypoint(entrypoint);
// Simulate getting entrypoint ContactInfo from gossip
let mut gossiped_entrypoint_info =
ContactInfo::new_localhost(&solana_sdk::pubkey::new_rand(), timestamp());
gossiped_entrypoint_info.gossip = entrypoint_gossip_addr;
gossiped_entrypoint_info.shred_version = 1;
cluster_info.insert_info(gossiped_entrypoint_info.clone());
// Adopt the entrypoint's gossiped contact info and verify
let entrypoints_processed = ClusterInfo::process_entrypoints(&cluster_info);
assert_eq!(cluster_info.entrypoints.read().unwrap().len(), 1);
assert_eq!(
cluster_info.entrypoints.read().unwrap()[0],
gossiped_entrypoint_info
);
assert!(entrypoints_processed);
assert_eq!(cluster_info.my_shred_version(), 2); // <--- No change to shred version
} | rust_cleaned_test_functions.jsonl/11678 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 754
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11305,
9078,
2768,
39904,
62,
98238,
3712,
1151,
9438,
368,
341,
286,
1077,
2436,
3097,
12670,
284,
19689,
486,
931,
7,
6608,
1082,
1310,
486,
931,
1423,
286,
1077,
10652,
3109,
284,
19689,
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_serialize_with_parent() {
let item = SearchIndexItem {
index: vec!["superadmin".to_string(), "super_admin".to_string()],
name: "SUPER_ADMIN".to_string(),
kind: "enumitem".to_string(),
parent_name: Some("AccountType".to_string()),
parent_kind: Some("enum".to_string()),
};
let value = serde_json::to_value(&item).unwrap();
assert_eq!(
value,
json!([
["superadmin", "super_admin"],
"SUPER_ADMIN",
"enumitem",
"AccountType",
"enum"
])
);
} | rust_cleaned_test_functions.jsonl/95218 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 379
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
88686,
6615,
15960,
368,
341,
286,
1077,
1509,
284,
7542,
1552,
1234,
341,
310,
1922,
25,
7486,
0,
1183,
9522,
2882,
3263,
983,
3904,
1507,
330,
9522,
12207,
3263,
983,
3904,
73845,
310,
829,
25... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_multiline_comment() {
let arena = Arena::new();
assert_syntaxes(
&parse(&arena, "/* foo\nbar */", &lang()),
&[Syntax::new_atom(
&arena,
vec![
SingleLineSpan {
line: 0.into(),
start_col: 0,
end_col: 6,
},
SingleLineSpan {
line: 1.into(),
start_col: 0,
end_col: 6,
},
],
"/* foo\nbar */",
AtomKind::Comment,
)],
);
} | rust_cleaned_test_functions.jsonl/52650 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 504
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
26290,
26560,
17638,
368,
341,
286,
1077,
24902,
284,
27047,
486,
931,
1428,
286,
2060,
78894,
288,
1006,
310,
609,
6400,
2099,
30527,
11,
330,
1057,
15229,
1699,
2257,
639,
497,
609,
5205,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_fetch_multiple_indexes() {
let tmp_dir = tempfile::tempdir().unwrap();
let path = tmp_dir.path().join("test_fetch_multiple_indexes");
let name = path.to_str().unwrap();
let index1 = "index_one";
let index2 = "index_two";
let doc_store = DocumentStore::open(
name,
vec![
IndexSpec::new(index1, vec!["index1_field"]),
IndexSpec::new(index2, vec!["index2_field"]),
],
)
.expect("should not result in error");
let fld1 = append_random("msf1_");
let fld2 = append_random("msf2_");
let doc = json!({
"index1_field": fld1,
"index2_field": fld2
});
doc_store
.insert(&doc.to_string())
.expect("should not store with missing index fields.");
let mut filter1 = HashMap::new();
filter1.insert("index1_field", fld1.as_str());
let mut filter2 = HashMap::new();
filter2.insert("index2_field", fld2.as_str());
let res: String = doc_store
.fetch(index1, filter1)
.expect("Should have fetched without error.") // expect Ok
.expect("Should have found a document."); // expect Some
assert_eq!(doc.to_string(), res);
let res: String = doc_store
.fetch(index2, filter2)
.expect("Should have fetched without error.") // expect Ok
.expect("Should have found a document."); // expect Some
assert_eq!(doc.to_string(), res);
} | rust_cleaned_test_functions.jsonl/110738 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 763
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11803,
45233,
50161,
368,
341,
286,
1077,
4174,
4334,
284,
54819,
486,
3888,
3741,
1005,
15454,
543,
286,
1077,
1815,
284,
4174,
4334,
3875,
1005,
5987,
445,
1944,
11803,
45233,
50161,
797,
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... | 1 |
#[test]
fn test_n_leaves() {
// make sure we handle an empty MMR correctly
assert_eq!(pmmr::n_leaves(0), 0);
// and various sizes on non-empty MMRs
assert_eq!(pmmr::n_leaves(1), 1);
assert_eq!(pmmr::n_leaves(2), 2);
assert_eq!(pmmr::n_leaves(3), 2);
assert_eq!(pmmr::n_leaves(4), 3);
assert_eq!(pmmr::n_leaves(5), 4);
assert_eq!(pmmr::n_leaves(6), 4);
assert_eq!(pmmr::n_leaves(7), 4);
assert_eq!(pmmr::n_leaves(8), 5);
assert_eq!(pmmr::n_leaves(9), 6);
assert_eq!(pmmr::n_leaves(10), 6);
} | rust_cleaned_test_functions.jsonl/89897 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 265
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1089,
11751,
4693,
368,
341,
197,
322,
1281,
2704,
582,
3705,
458,
4287,
386,
18446,
12440,
198,
6948,
10714,
10297,
79,
3821,
81,
486,
77,
11751,
4693,
7,
15,
701,
220,
15,
626,
197,
322,
323... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_tee_no_more_writeable_2() {
// should be equals to 'tee out1 out2 >/dev/full <multi_read' call
// but currently there is no way to redirect stdout to /dev/full
// so this test is disabled
let (_at, mut ucmd) = at_and_ucmd!();
let _content = (1..=10).map(|x| format!("{}\n", x)).collect::<String>();
let file_out_a = "tee_file_out_a";
let file_out_b = "tee_file_out_b";
let _result = ucmd
.arg(file_out_a)
.arg(file_out_b)
.pipe_in("/dev/full")
.succeeds();
// TODO: comment in after https://github.com/uutils/coreutils/issues/1805 is fixed
} | rust_cleaned_test_functions.jsonl/40788 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 304
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
528,
2127,
6536,
36664,
9165,
480,
62,
17,
368,
341,
262,
442,
1265,
387,
16819,
311,
364,
6547,
700,
16,
700,
17,
61359,
3583,
62975,
366,
26268,
6443,
6,
1618,
198,
262,
442,
714,
5023,
1052... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_nil_block() {
let genesis_block = Block::make_genesis_block();
let quorum_cert = QuorumCert::certificate_for_genesis();
let nil_block = Block::make_nil_block(&genesis_block, 1, quorum_cert);
assert_eq!(
nil_block.quorum_cert().certified_block_id(),
genesis_block.id()
);
assert_eq!(nil_block.round(), 1);
assert_eq!(
nil_block.timestamp_usecs(),
genesis_block.timestamp_usecs() + 1
);
assert_eq!(nil_block.is_nil_block(), true);
assert!(nil_block.author().is_none());
let dummy_verifier = Arc::new(ValidatorVerifier::<Ed25519PublicKey>::new(HashMap::new()));
assert!(nil_block.verify(dummy_verifier.as_ref()).is_ok());
let signer = ValidatorSigner::random(None);
let payload = 101;
let nil_block_qc = placeholder_certificate_for_block(
vec![&signer],
nil_block.id(),
nil_block.round(),
nil_block.quorum_cert().certified_block_id(),
nil_block.quorum_cert().certified_block_round(),
nil_block.quorum_cert().certified_parent_block_id(),
nil_block.quorum_cert().certified_parent_block_round(),
);
let nil_block_child = Block::make_block(
&nil_block,
payload,
2,
get_current_timestamp().as_micros() as u64,
nil_block_qc.clone(),
&signer,
);
assert_eq!(nil_block_child.is_nil_block(), false);
assert_eq!(nil_block_child.round(), 2);
assert_eq!(nil_block_child.parent_id(), nil_block.id());
} | rust_cleaned_test_functions.jsonl/542 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 683
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36175,
7113,
368,
341,
262,
1077,
59366,
7113,
284,
8362,
486,
6927,
16322,
13774,
7113,
543,
262,
1077,
922,
33006,
37097,
284,
3406,
33006,
36934,
486,
63586,
5478,
16322,
13774,
1428,
262,
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... | 1 |
#[test]
fn test_submessage_variant_roundtrip() {
let variants = [
"InfoDestination",
"InfoReply",
"InfoSource",
"InfoTimestamp",
"AckNack",
"Data",
"DataFrag",
"Gap",
"Heartbeat",
"HeartbeatFrag",
"NackFrag",
"Pad"
];
let mut buf = [0; 64 * 1024];
for variant_str in variants.iter() {
let variant = Submessage::create_variant(variant_str);
let bytes_written = {
let cursor = io::Cursor::new(&mut buf[..]);
let mut serializer = cdr::CdrSerializer::new(cursor);
variant.serialize(&mut serializer).unwrap();
serializer.write_handle.position() as usize
};
let variant_rt: Submessage = {
let mut cursor = io::Cursor::new(&mut buf[0..bytes_written]);
let mut de = cdr::CdrDeserializer::new(&mut cursor);
Deserialize::deserialize(&mut de).unwrap()
};
if variant_rt != variant {
panic!("{:?} failed on {:?}", variant_str, &buf[0..bytes_written]);
}
assert_eq!(variant_rt, variant);
}
} | rust_cleaned_test_functions.jsonl/73307 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 569
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5228,
1994,
46112,
29896,
32981,
368,
341,
262,
1077,
26012,
284,
2278,
286,
330,
1731,
33605,
756,
286,
330,
1731,
20841,
756,
286,
330,
1731,
3608,
756,
286,
330,
1731,
20812,
25897,
286,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_simple_operator_empty_json_parse() {
let json = "{}";
let query = parse_from_json(json).unwrap();
let expected = Operator::And(vec![]);
assert_eq!(query, expected);
} | rust_cleaned_test_functions.jsonl/11808 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 102
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
30015,
40594,
15124,
9455,
21039,
368,
341,
286,
1077,
2951,
284,
35503,
3302,
286,
1077,
3239,
284,
4715,
5673,
9455,
9304,
568,
15454,
1428,
286,
1077,
3601,
284,
28498,
486,
3036,
25592,
0,
129... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_input() {
let actual = parse_input("The first floor contains a thulium generator, a thulium-compatible microchip, a plutonium generator, and a strontium generator.
The second floor contains a plutonium-compatible microchip and a strontium-compatible microchip.
The fourth floor contains nothing relevant.");
let floors: Vec<BTreeSet<ScienceThing>> = vec![
[
gen("thulium"), chip("thulium"), gen("plutonium"), gen("strontium")
].iter().cloned().collect(),
[
chip("plutonium"), chip("strontium")
].iter().cloned().collect(),
BTreeSet::new()
];
let expected = State { floors: floors, current_floor: 0 };
assert_eq!(expected, actual);
} | rust_cleaned_test_functions.jsonl/55905 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 221
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
5898,
368,
341,
10217,
5042,
284,
4715,
5898,
445,
785,
1156,
6422,
5610,
264,
270,
360,
2356,
13823,
11,
264,
270,
360,
2356,
80215,
8003,
29662,
11,
264,
59487,
89244,
13823,
11,
323,
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_enforce() {
let epoch = test_epoch(10);
let mut cs = TestConstraintSystem::<Fr>::new();
let index = to_fr(&mut cs.ns(|| "index"), Some(9u32)).unwrap();
epoch
.constrain(&mut cs.ns(|| "constraint"), &index, false)
.unwrap();
assert!(cs.is_satisfied());
} | rust_cleaned_test_functions.jsonl/78212 | {
"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,
6205,
8833,
368,
341,
286,
1077,
16342,
284,
1273,
20682,
7,
16,
15,
317,
286,
1077,
5206,
10532,
284,
3393,
17890,
2320,
27638,
22560,
6831,
931,
543,
286,
1077,
1922,
284,
311,
41537,
2099,
69... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_first_ordinals_not_in_set_1() {
let schedule = "0 0/10 * * * * *".parse::<Schedule>().unwrap();
let start_time_1 = NaiveDate::from_ymd(2017, 10, 24).and_hms(0, 0, 59);
let start_time_1 = Utc.from_utc_datetime(&start_time_1);
let next_time_1 = schedule.after(&start_time_1).next().unwrap();
let start_time_2 = NaiveDate::from_ymd(2017, 10, 24).and_hms(0, 1, 0);
let start_time_2 = Utc.from_utc_datetime(&start_time_2);
let next_time_2 = schedule.after(&start_time_2).next().unwrap();
assert_eq!(next_time_1, next_time_2);
} | rust_cleaned_test_functions.jsonl/50823 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 296
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12978,
67324,
23695,
7913,
1243,
2602,
62,
16,
368,
341,
286,
1077,
9700,
284,
330,
15,
220,
15,
14,
16,
15,
353,
353,
353,
353,
353,
3263,
6400,
27638,
32210,
10483,
15454,
543,
286,
1077,
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_transport_worker_send_exists() {
let (_, stop_rx) = mpsc::channel();
let (_, worker_rx) = mpsc::channel();
let (worker_tx, rx) = mpsc::channel();
let worker = TransportWorker {
stop: stop_rx,
timeout: Duration::from_micros(0),
rx: worker_rx,
txs: HashMap::from_iter(vec![(1, worker_tx)].into_iter()),
};
let data = vec![1, 2];
worker.send(data);
match rx.recv().unwrap() {
Event::Data(output) => assert_eq!(output, vec![2]),
e => panic!(format!("Unexpected output: {:?}", e)),
}
} | rust_cleaned_test_functions.jsonl/126111 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 337
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
46398,
40385,
13565,
9766,
368,
341,
286,
1077,
39464,
2936,
24330,
8,
284,
296,
81984,
486,
10119,
543,
286,
1077,
39464,
11864,
24330,
8,
284,
296,
81984,
486,
10119,
543,
286,
1077,
320,
21462,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_word_boundary_split_should_preserve_empty_lines() {
new_ucmd!()
.arg("-s")
.pipe_in("\n")
.succeeds()
.stdout_is("\n");
new_ucmd!()
.args(&["-w1", "-s"])
.pipe_in("0\n1\n\n2\n\n\n")
.succeeds()
.stdout_is("0\n1\n\n2\n\n\n");
} | rust_cleaned_test_functions.jsonl/23268 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 207
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13533,
54004,
17052,
43378,
32116,
5852,
15124,
18323,
368,
341,
262,
501,
68887,
2277,
0,
741,
286,
659,
858,
13645,
82,
1138,
286,
659,
13768,
1243,
4921,
77,
1138,
286,
659,
82,
29264,
82,
74... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_sort_deglob_str() {
assert_eq!(sort_deglob_str(""), "");
assert_eq!(sort_deglob_str("foo"), "foo");
assert_eq!(sort_deglob_str("a, b"), "a, b");
assert_eq!(sort_deglob_str("b, a"), "a, b");
assert_eq!(sort_deglob_str("foo, bar, baz"), "bar, baz, foo");
} | rust_cleaned_test_functions.jsonl/118340 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 174
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18435,
46057,
1684,
2895,
368,
341,
286,
2060,
10714,
10297,
6860,
46057,
1684,
2895,
86076,
14498,
286,
2060,
10714,
10297,
6860,
46057,
1684,
2895,
445,
7975,
3975,
330,
7975,
797,
286,
2060,
1071... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_display_create_table() {
let stmt = Statement::CreateTable {
if_not_exists: true,
database: Some(Identifier {
name: "db".to_owned(),
quote: Some('`'),
}),
table: Identifier {
name: "table".to_owned(),
quote: Some('`'),
},
columns: vec![ColumnDefinition {
name: Identifier {
name: "column".to_owned(),
quote: None,
},
data_type: TypeName::Int(None),
nullable: false,
default_value: Some(Literal::Number("123".to_owned())),
}],
engine: "".to_string(),
options: vec![],
like_db: None,
like_table: None,
};
assert_eq!(
format!("{}", stmt),
r#"CREATE TABLE IF NOT EXISTS `db`.`table` (column INTEGER NOT NULL DEFAULT 123)"#
);
} | rust_cleaned_test_functions.jsonl/94669 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 481
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14825,
8657,
5237,
368,
341,
262,
1077,
20020,
284,
21756,
486,
4021,
2556,
341,
286,
421,
7913,
9766,
25,
830,
345,
286,
4625,
25,
4329,
7,
8714,
341,
310,
829,
25,
330,
1999,
3263,
983,
5197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_convert_pos_table() {
let mut writer = Cursor::new(vec![]);
DictionaryBuilder::convert_pos_table(
&mut writer,
&[String::from("a,b,c,d,e,f"), String::from("g,h,i,j,k,l")],
)
.unwrap();
assert_eq!(2 + 3 * 12, writer.get_ref().len());
} | rust_cleaned_test_functions.jsonl/134074 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 143
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34910,
6479,
5237,
368,
341,
262,
1077,
5206,
6916,
284,
28067,
486,
931,
25592,
0,
56703,
262,
10466,
3297,
486,
14166,
6479,
5237,
1006,
414,
609,
6984,
6916,
345,
414,
44590,
703,
486,
1499,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_try_future() {
System::new().block_on(async {
let addr = MyStreamActor2 { counter: 0 }.start();
let res = addr.send(TryFutureMsg(5)).await.unwrap();
assert_eq!(res.err().unwrap(), 996u32);
})
} | rust_cleaned_test_functions.jsonl/82650 | {
"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,
53283,
59740,
368,
341,
262,
739,
486,
931,
1005,
4574,
4470,
18285,
341,
286,
1077,
10789,
284,
3017,
3027,
18870,
17,
314,
5546,
25,
220,
15,
16908,
2468,
543,
286,
1077,
592,
284,
10789,
5219... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_proposal_id_candid_encoding() {
local_test_on_sns_subnet(|runtime| {
async move {
// Initialize the ledger with an account for a user.
let user = Sender::from_keypair(&TEST_USER1_KEYPAIR);
let alloc = Tokens::from_tokens(1000).unwrap();
let sns_init_payload = SnsInitPayloadsBuilder::new()
.with_ledger_account(user.get_principal_id().into(), alloc)
.build();
let sns_canisters = SnsCanisters::set_up(&runtime, sns_init_payload).await;
let res: Result<Vec<u8>, String> = sns_canisters
.governance
.query_("get_proposal", bytes, b"This is not valid candid!".to_vec())
.await;
match res {
Err(e) => assert!(e.contains("Deserialization Failed")),
Ok(_) => panic!("get_proposal should fail to deserialize"),
};
Ok(())
}
});
} | rust_cleaned_test_functions.jsonl/93507 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 509
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34199,
21663,
32556,
842,
666,
4551,
37613,
368,
341,
262,
2205,
4452,
4470,
643,
4412,
95681,
22428,
22255,
91,
341,
286,
3312,
3271,
341,
310,
442,
9008,
279,
46933,
448,
458,
2692,
369,
264,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_shortest_path_same_origin_and_destination() {
let res = 8;
let origin = H3Cell::from_coordinate(&Coordinate::from((23.3, 12.3)), res).unwrap();
let edge = origin.unidirectional_edges().first().unwrap();
let destination = edge.destination_index_unchecked();
// build a micro-graph
let prepared_graph: PreparedH3EdgeGraph<_> = {
let mut graph = H3EdgeGraph::new(res);
graph.add_edge(edge, 5_u32).unwrap();
graph.try_into().unwrap()
};
let paths = prepared_graph
.shortest_path_many_to_many(
&vec![origin],
&vec![origin, destination],
&DefaultShortestPathOptions::default(),
)
.unwrap();
assert_eq!(paths.len(), 1);
let path_vec = paths.get(&origin).unwrap();
assert_eq!(path_vec.len(), 2);
for path in path_vec.iter() {
let path_destination = path.destination_cell().unwrap();
if path_destination == origin {
assert!(path.is_empty());
assert_eq!(path.cost(), &0);
} else if path_destination == destination {
assert!(!path.is_empty());
assert_eq!(path.cost(), &5);
} else {
unreachable!()
}
}
} | rust_cleaned_test_functions.jsonl/10971 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 722
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16673,
477,
2638,
33574,
34043,
8378,
56344,
368,
341,
286,
1077,
592,
284,
220,
23,
280,
286,
1077,
6238,
284,
472,
18,
3599,
486,
1499,
68649,
2099,
28589,
486,
1499,
1188,
17,
18,
13,
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... | 4 |
#[test]
fn test_check_txn_status_with_max_ts() {
let (_cluster, client, ctx) = must_new_cluster_and_kv_client();
let (k, v) = (b"key".to_vec(), b"value".to_vec());
let lock_ts = 10;
// Prewrite
let mut mutation = Mutation::default();
mutation.set_op(Op::Put);
mutation.set_key(k.clone());
mutation.set_value(v);
must_kv_prewrite(&client, ctx.clone(), vec![mutation], k.clone(), lock_ts);
// Should return MinCommitTsPushed even if caller_start_ts is max.
let status = must_check_txn_status(
&client,
ctx.clone(),
&k,
lock_ts,
std::u64::MAX,
lock_ts + 1,
);
assert_eq!(status.lock_ttl, 3000);
assert_eq!(status.action, Action::MinCommitTsPushed);
// The min_commit_ts of k shouldn't be pushed.
must_kv_commit(&client, ctx, vec![k], lock_ts, lock_ts + 1, lock_ts + 1);
} | rust_cleaned_test_functions.jsonl/61698 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 408
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7200,
92299,
4773,
6615,
6345,
25023,
368,
341,
262,
1077,
5453,
18855,
11,
2943,
11,
5635,
8,
284,
1969,
5921,
28441,
8378,
97066,
8179,
543,
262,
1077,
320,
74,
11,
348,
8,
284,
320,
65,
1,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_account_update() {
let accounts = AccountsDb::new_single();
let mut pubkeys: Vec<Pubkey> = vec![];
create_account(&accounts, &mut pubkeys, 0, 100, 0, 0);
update_accounts(&accounts, &pubkeys, 0, 99);
assert!(check_storage(&accounts, 0, 100));
} | rust_cleaned_test_functions.jsonl/1346 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 139
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13500,
8882,
368,
341,
286,
1077,
9618,
284,
40655,
7994,
486,
931,
19487,
543,
286,
1077,
5206,
6675,
10563,
25,
11312,
21604,
392,
792,
29,
284,
7486,
0,
15078,
286,
1855,
13500,
2099,
26206,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_full_codebook_msb() {
let mut cb_desc: Vec<FullCodebookDesc<i8>> = vec![FullCodebookDesc {
code: 0b0,
bits: 1,
sym: 16,
},
FullCodebookDesc {
code: 0b10,
bits: 2,
sym: -3,
},
FullCodebookDesc {
code: 0b110,
bits: 3,
sym: 42,
},
FullCodebookDesc {
code: 0b1110,
bits: 4,
sym: -42,
}];
let buf = &BITS;
let mut br = BitReadBE::new(buf);
let cb = Codebook::new(&mut cb_desc, CodebookMode::MSB).unwrap();
assert_eq!(br.read_cb(&cb).unwrap(), 16);
assert_eq!(br.read_cb(&cb).unwrap(), -3);
assert_eq!(br.read_cb(&cb).unwrap(), 42);
assert_eq!(br.read_cb(&cb).unwrap(), -42);
let ret = br.read_cb(&cb);
if let Err(e) = ret {
assert_matches!(e, InvalidCode);
} else {
assert_eq!(0, 1);
}
} | rust_cleaned_test_functions.jsonl/33953 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1565
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16372,
4136,
2190,
717,
16892,
368,
341,
286,
1077,
5206,
9858,
10986,
25,
11312,
27,
9432,
2078,
2190,
11065,
21897,
23,
2452,
284,
7486,
20703,
9432,
2078,
2190,
11065,
341,
31979,
2038,
25,
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... | 2 |
#[test]
fn test_dotnet_framework_future_version() {
let mut runtime = RuntimeContext {
raw_description: ".NET Framework 200.0".to_string().into(),
build: LenientString("999999".to_string()).into(),
..RuntimeContext::default()
};
// Unmapped build number doesn't override version
normalize_runtime_context(&mut runtime);
assert_eq_dbg!(Some(".NET Framework"), runtime.name.as_str());
assert_eq_dbg!(Some("200.0"), runtime.version.as_str());
} | rust_cleaned_test_functions.jsonl/68949 | {
"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,
30941,
4711,
27565,
59740,
9438,
368,
341,
262,
1077,
5206,
15592,
284,
10954,
1972,
341,
286,
7112,
11448,
25,
5933,
15373,
23752,
220,
17,
15,
15,
13,
15,
3263,
983,
3904,
1005,
18122,
3148,
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_rstar_network_large_push() {
solana_logger::setup();
let mut network = rstar_network_create(4000);
network_simulator(&mut network, 0.9);
} | rust_cleaned_test_functions.jsonl/1104 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 71
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1710,
11870,
20966,
45228,
14218,
368,
341,
262,
2048,
3362,
27413,
486,
15188,
543,
262,
1077,
5206,
3922,
284,
435,
11870,
20966,
8657,
7,
19,
15,
15,
15,
317,
262,
3922,
18314,
10511,
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 |
#[test]
fn test_msgpack_deserialize_body_with_args() {
let message = Message {
properties: MessageProperties {
correlation_id: "aaa".into(),
content_type: "application/x-msgpack".into(),
content_encoding: "utf-8".into(),
reply_to: None,
},
headers: MessageHeaders {
id: "aaa".into(),
task: "TestTask".into(),
..Default::default()
},
raw_body: MSGPACK.to_vec(),
};
let body = message.body::<TestTask>().unwrap();
assert_eq!(body.1.a, 4);
} | rust_cleaned_test_functions.jsonl/97962 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 291
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6483,
4748,
15768,
9050,
14114,
6615,
8384,
368,
341,
262,
1077,
1943,
284,
4856,
341,
286,
5888,
25,
4856,
7903,
341,
310,
25588,
842,
25,
330,
32646,
3263,
18122,
3148,
310,
2213,
1819,
25,
33... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_ilint() {
let mut reader = ByteArrayReader::new(&ILINT_SAMPLE_BIN);
let v = match reader.deserialize_ilint() {
Ok(v) => v,
_ => panic!(),
};
assert_eq!(v, ILINT_SAMPLE);
let mut reader = ByteArrayReader::new(&ILINT_SAMPLE_BIN[..ILINT_SAMPLE_BIN.len() - 1]);
match reader.deserialize_ilint() {
Err(ErrorKind::IOError(_)) => (),
_ => panic!(),
};
} | rust_cleaned_test_functions.jsonl/25682 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 205
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15768,
9050,
26743,
396,
368,
341,
262,
1077,
5206,
6604,
284,
32920,
5062,
486,
931,
2099,
1715,
3221,
41439,
55720,
317,
262,
1077,
348,
284,
2432,
6604,
50755,
26743,
396,
368,
341,
286,
7622,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_into_string_d() {
let d: String = DurationString::try_from(String::from("1d")).unwrap().into();
assert_eq!(d, "1d");
} | rust_cleaned_test_functions.jsonl/97556 | {
"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,
45514,
3904,
814,
368,
341,
286,
1077,
294,
25,
923,
284,
21045,
703,
486,
1539,
5673,
2242,
486,
1499,
445,
16,
67,
15197,
15454,
1005,
18122,
543,
286,
2060,
10714,
10297,
67,
11,
330,
16,
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 |
#[test]
fn test_align_up_to() {
// We are doing some sort of property testing here:
// The resulting `new_pos` must:
use rand::{thread_rng, Rng};
let mut rng = thread_rng();
for _ in 0..100_000 {
let x = rng.gen_range(1usize, 256);
let y = rng.gen_range(0, x);
let pos = rng.gen_range(0usize, 65536);
let new_pos = align_up_to(pos, x, y);
assert!(new_pos >= pos);
assert_eq!((new_pos - y) % x, 0);
assert!((pos..new_pos).all(|p| (p + x - y) % x != 0))
}
} | rust_cleaned_test_functions.jsonl/43497 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 485
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
37015,
8237,
2346,
368,
341,
310,
442,
1205,
525,
3730,
1045,
3378,
315,
3343,
7497,
1588,
510,
3374,
310,
442,
576,
12942,
1565,
931,
6479,
63,
1969,
510,
34642,
3374,
310,
990,
10382,
22964,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_function_selector_behavior() {
use crate::type_engine::IntegerBits;
let decl = TypedFunctionDeclaration {
purity: Default::default(),
name: Ident::new_with_override(
"foo",
Span {
span: pest::Span::new(" ".into(), 0, 0).unwrap(),
path: None,
},
),
body: TypedCodeBlock {
contents: vec![],
whole_block_span: Span {
span: pest::Span::new(" ".into(), 0, 0).unwrap(),
path: None,
},
},
parameters: vec![],
span: Span {
span: pest::Span::new(" ".into(), 0, 0).unwrap(),
path: None,
},
return_type: 0,
type_parameters: vec![],
return_type_span: Span {
span: pest::Span::new(" ".into(), 0, 0).unwrap(),
path: None,
},
visibility: Visibility::Public,
is_contract_call: false,
};
let selector_text = match decl.to_selector_name().value {
Some(value) => value,
_ => panic!("test failure"),
};
assert_eq!(selector_text, "foo()".to_string());
let decl = TypedFunctionDeclaration {
purity: Default::default(),
name: Ident::new_with_override(
"bar",
Span {
span: pest::Span::new(" ".into(), 0, 0).unwrap(),
path: None,
},
),
body: TypedCodeBlock {
contents: vec![],
whole_block_span: Span {
span: pest::Span::new(" ".into(), 0, 0).unwrap(),
path: None,
},
},
parameters: vec![
TypedFunctionParameter {
name: Ident::new_with_override(
"foo",
Span {
span: pest::Span::new(" ".into(), 0, 0).unwrap(),
path: None,
},
),
r#type: crate::type_engine::insert_type(TypeInfo::Str(5)),
type_span: Span {
span: pest::Span::new(" ".into(), 0, 0).unwrap(),
path: None,
},
},
TypedFunctionParameter {
name: Ident::new_with_override(
"baz",
Span {
span: pest::Span::new(" ".into(), 0, 0).unwrap(),
path: None,
},
),
r#type: insert_type(TypeInfo::UnsignedInteger(IntegerBits::ThirtyTwo)),
type_span: Span {
span: pest::Span::new(" ".into(), 0, 0).unwrap(),
path: None,
},
},
],
span: Span {
span: pest::Span::new(" ".into(), 0, 0).unwrap(),
path: None,
},
return_type: 0,
type_parameters: vec![],
return_type_span: Span {
span: pest::Span::new(" ".into(), 0, 0).unwrap(),
path: None,
},
visibility: Visibility::Public,
is_contract_call: false,
};
let selector_text = match decl.to_selector_name().value {
Some(value) => value,
_ => panic!("test failure"),
};
assert_eq!(selector_text, "bar(str[5],u32)".to_string());
} | rust_cleaned_test_functions.jsonl/19428 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1920
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9174,
28890,
74540,
368,
341,
262,
990,
17717,
486,
1313,
24823,
486,
3486,
19920,
280,
262,
1077,
3963,
284,
50554,
5152,
24489,
341,
286,
52400,
25,
7899,
486,
2258,
3148,
286,
829,
25,
22507,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_symbolfile_from_crlf_file() {
test_symbolfile_from_file(
"testdata/symbols/test_app.pdb/6A9832E5287241C1838ED98914E9B7FF1/test_app.sym",
);
} | rust_cleaned_test_functions.jsonl/54413 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 114
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21179,
1192,
5673,
666,
2381,
69,
2458,
368,
341,
286,
1273,
21179,
1192,
5673,
2458,
1006,
310,
330,
92425,
2687,
11786,
12697,
8191,
556,
1999,
14,
21,
32,
24,
23,
18,
17,
36,
20,
17,
23,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_sighash_errors() {
let dumb_tx = Transaction {
version: 0,
lock_time: 0,
input: vec![TxIn::default()],
output: vec![],
};
let mut c = SighashCache::new(&dumb_tx);
// 1.29 fixes
let empty_vec = vec![];
let empty_prevouts : Prevouts<TxOut> = Prevouts::All(&empty_vec);
assert_eq!(
c.taproot_signature_hash(0, &empty_prevouts, None, None, SchnorrSighashType::All),
Err(Error::PrevoutsSize)
);
let two = vec![TxOut::default(), TxOut::default()];
let too_many_prevouts = Prevouts::All(&two);
assert_eq!(
c.taproot_signature_hash(0, &too_many_prevouts, None, None, SchnorrSighashType::All),
Err(Error::PrevoutsSize)
);
let tx_out = TxOut::default();
let prevout = Prevouts::One(1, &tx_out);
assert_eq!(
c.taproot_signature_hash(0, &prevout, None, None, SchnorrSighashType::All),
Err(Error::PrevoutKind)
);
assert_eq!(
c.taproot_signature_hash(0, &prevout, None, None, SchnorrSighashType::AllPlusAnyoneCanPay),
Err(Error::PrevoutIndex)
);
assert_eq!(
c.taproot_signature_hash(10, &prevout, None, None, SchnorrSighashType::AllPlusAnyoneCanPay),
Err(Error::IndexOutOfInputsBounds {
index: 10,
inputs_size: 1
})
);
let prevout = Prevouts::One(0, &tx_out);
assert_eq!(
c.taproot_signature_hash(0, &prevout, None, None, SchnorrSighashType::SinglePlusAnyoneCanPay),
Err(Error::SingleWithoutCorrespondingOutput {
index: 0,
outputs_size: 0
})
);
assert_eq!(
c.legacy_signature_hash(10, &Script::default(), 0u32),
Err(Error::IndexOutOfInputsBounds {
index: 10,
inputs_size: 1
})
);
} | rust_cleaned_test_functions.jsonl/115162 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1089
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
643,
1090,
988,
20196,
368,
341,
286,
1077,
29255,
17805,
284,
17869,
341,
310,
2319,
25,
220,
15,
345,
310,
5296,
3009,
25,
220,
15,
345,
310,
1946,
25,
7486,
20703,
31584,
641,
486,
2258,
73... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_bpf_loader_upgradeable_set_upgrade_authority() {
let instruction = bincode::serialize(&UpgradeableLoaderInstruction::SetAuthority).unwrap();
let slot = 0;
let upgrade_authority_address = Pubkey::new_unique();
let upgrade_authority_account = AccountSharedData::new_ref(1, 0, &Pubkey::new_unique());
let new_upgrade_authority_address = Pubkey::new_unique();
let new_upgrade_authority_account = AccountSharedData::new_ref(1, 0, &Pubkey::new_unique());
let program_address = Pubkey::new_unique();
let (programdata_address, _) = Pubkey::find_program_address(
&[program_address.as_ref()],
&bpf_loader_upgradeable::id(),
);
let programdata_account = AccountSharedData::new_ref(
1,
UpgradeableLoaderState::programdata_len(0).unwrap(),
&bpf_loader_upgradeable::id(),
);
// Case: Set to new authority
programdata_account
.borrow_mut()
.set_state(&UpgradeableLoaderState::ProgramData {
slot,
upgrade_authority_address: Some(upgrade_authority_address),
})
.unwrap();
let keyed_accounts = vec![
KeyedAccount::new(&programdata_address, false, &programdata_account),
KeyedAccount::new_readonly(
&upgrade_authority_address,
true,
&upgrade_authority_account,
),
KeyedAccount::new_readonly(
&new_upgrade_authority_address,
false,
&new_upgrade_authority_account,
),
];
assert_eq!(
Ok(()),
process_instruction(
&bpf_loader_upgradeable::id(),
&instruction,
&mut MockInvokeContext::new(keyed_accounts)
)
);
let state: UpgradeableLoaderState = programdata_account.borrow().state().unwrap();
assert_eq!(
state,
UpgradeableLoaderState::ProgramData {
slot,
upgrade_authority_address: Some(new_upgrade_authority_address),
}
);
// Case: Not upgradeable
programdata_account
.borrow_mut()
.set_state(&UpgradeableLoaderState::ProgramData {
slot,
upgrade_authority_address: Some(upgrade_authority_address),
})
.unwrap();
let keyed_accounts = vec![
KeyedAccount::new(&programdata_address, false, &programdata_account),
KeyedAccount::new_readonly(
&upgrade_authority_address,
true,
&upgrade_authority_account,
),
];
assert_eq!(
Ok(()),
process_instruction(
&bpf_loader_upgradeable::id(),
&instruction,
&mut MockInvokeContext::new(keyed_accounts)
)
);
let state: UpgradeableLoaderState = programdata_account.borrow().state().unwrap();
assert_eq!(
state,
UpgradeableLoaderState::ProgramData {
slot,
upgrade_authority_address: None,
}
);
// Case: Authority did not sign
programdata_account
.borrow_mut()
.set_state(&UpgradeableLoaderState::ProgramData {
slot,
upgrade_authority_address: Some(upgrade_authority_address),
})
.unwrap();
let keyed_accounts = vec![
KeyedAccount::new(&programdata_address, false, &programdata_account),
KeyedAccount::new_readonly(
&upgrade_authority_address,
false,
&upgrade_authority_account,
),
];
assert_eq!(
Err(InstructionError::MissingRequiredSignature),
process_instruction(
&bpf_loader_upgradeable::id(),
&instruction,
&mut MockInvokeContext::new(keyed_accounts)
)
);
// Case: wrong authority
programdata_account
.borrow_mut()
.set_state(&UpgradeableLoaderState::ProgramData {
slot,
upgrade_authority_address: Some(upgrade_authority_address),
})
.unwrap();
let invalid_upgrade_authority_address = Pubkey::new_unique();
let keyed_accounts = vec![
KeyedAccount::new(&programdata_address, false, &programdata_account),
KeyedAccount::new_readonly(
&invalid_upgrade_authority_address,
true,
&upgrade_authority_account,
),
KeyedAccount::new_readonly(
&new_upgrade_authority_address,
false,
&new_upgrade_authority_account,
),
];
assert_eq!(
Err(InstructionError::IncorrectAuthority),
process_instruction(
&bpf_loader_upgradeable::id(),
&instruction,
&mut MockInvokeContext::new(keyed_accounts)
)
);
// Case: No authority
programdata_account
.borrow_mut()
.set_state(&UpgradeableLoaderState::ProgramData {
slot,
upgrade_authority_address: None,
})
.unwrap();
let invalid_upgrade_authority_address = Pubkey::new_unique();
let keyed_accounts = vec![
KeyedAccount::new(&programdata_address, false, &programdata_account),
KeyedAccount::new_readonly(
&invalid_upgrade_authority_address,
true,
&upgrade_authority_account,
),
];
assert_eq!(
Err(InstructionError::Immutable),
process_instruction(
&bpf_loader_upgradeable::id(),
&bincode::serialize(&UpgradeableLoaderInstruction::SetAuthority).unwrap(),
&mut MockInvokeContext::new(keyed_accounts)
)
);
// Case: Not a ProgramData account
programdata_account
.borrow_mut()
.set_state(&UpgradeableLoaderState::Program {
programdata_address: Pubkey::new_unique(),
})
.unwrap();
let invalid_upgrade_authority_address = Pubkey::new_unique();
let keyed_accounts = vec![
KeyedAccount::new(&programdata_address, false, &programdata_account),
KeyedAccount::new_readonly(
&invalid_upgrade_authority_address,
true,
&upgrade_authority_account,
),
];
assert_eq!(
Err(InstructionError::InvalidArgument),
process_instruction(
&bpf_loader_upgradeable::id(),
&bincode::serialize(&UpgradeableLoaderInstruction::SetAuthority).unwrap(),
&mut MockInvokeContext::new(keyed_accounts)
)
);
} | rust_cleaned_test_functions.jsonl/35385 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 3763
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
880,
15897,
22139,
67794,
480,
2602,
67794,
22938,
487,
368,
341,
286,
1077,
7600,
284,
9544,
1851,
486,
24166,
2099,
43861,
480,
9181,
16664,
486,
1649,
45532,
568,
15454,
543,
286,
1077,
9446,
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_background_processor() {
// re-persistence and is successfully re-persisted.
let nodes = create_nodes(2, "test_background_processor".to_string());
// Go through the channel creation process so that each node has something to persist. Since
// avoid a race with processing events.
let tx = open_channel!(nodes[0], nodes[1], 100000);
// Initiate the background processors to watch each node.
let data_dir = nodes[0].persister.get_data_dir();
let persister = move |node: &ChannelManager<InMemorySigner, Arc<ChainMonitor>, Arc<test_utils::TestBroadcaster>, Arc<KeysManager>, Arc<test_utils::TestFeeEstimator>, Arc<test_utils::TestLogger>>| FilesystemPersister::persist_manager(data_dir.clone(), node);
let event_handler = |_: &_| {};
let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].net_graph_msg_handler.clone(), nodes[0].peer_manager.clone(), nodes[0].logger.clone());
macro_rules! check_persisted_data {
($node: expr, $filepath: expr, $expected_bytes: expr) => {
loop {
$expected_bytes.clear();
match $node.write(&mut $expected_bytes) {
Ok(()) => {
match std::fs::read($filepath) {
Ok(bytes) => {
if bytes == $expected_bytes {
break
} else {
continue
}
},
Err(_) => continue
}
},
Err(e) => panic!("Unexpected error: {}", e)
}
}
}
}
// Check that the initial channel manager data is persisted as expected.
let filepath = get_full_filepath("test_background_processor_persister_0".to_string(), "manager".to_string());
let mut expected_bytes = Vec::new();
check_persisted_data!(nodes[0].node, filepath.clone(), expected_bytes);
loop {
if !nodes[0].node.get_persistence_condvar_value() { break }
}
// Force-close the channel.
nodes[0].node.force_close_channel(&OutPoint { txid: tx.txid(), index: 0 }.to_channel_id()).unwrap();
// Check that the force-close updates are persisted.
let mut expected_bytes = Vec::new();
check_persisted_data!(nodes[0].node, filepath.clone(), expected_bytes);
loop {
if !nodes[0].node.get_persistence_condvar_value() { break }
}
assert!(bg_processor.stop().is_ok());
} | rust_cleaned_test_functions.jsonl/26263 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 893
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
24103,
50127,
368,
341,
18363,
197,
197,
322,
312,
2268,
8026,
323,
374,
7790,
312,
2268,
4975,
291,
624,
197,
10217,
7798,
284,
1855,
14896,
7,
17,
11,
330,
1944,
24103,
50127,
3263,
983,
3904,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_terminated_ap() {
let mut exec = fuchsia_async::Executor::new().expect("failed to create an executor");
let test_values = test_setup(&mut exec);
let selector = Arc::new(NetworkSelector::new(
test_values.saved_networks.clone(),
create_mock_cobalt_sender(),
));
// Create an interface manager with an unconfigured client interface.
let (mut iface_manager, _next_sme_req) =
create_iface_manager_with_client(&test_values, true);
// Create remaining boilerplate to call handle_terminated_state_machine.
let iface_manager_client = Arc::new(Mutex::new(FakeIfaceManagerRequester::new()));
let mut disconnected_clients = HashSet::new();
let mut network_selection_futures = FuturesUnordered::new();
let metadata = StateMachineMetadata {
role: fidl_fuchsia_wlan_device::MacRole::Ap,
iface_id: TEST_AP_IFACE_ID,
};
{
let fut = handle_terminated_state_machine(
metadata,
&mut iface_manager,
iface_manager_client,
selector,
&mut disconnected_clients,
&mut network_selection_futures,
);
pin_mut!(fut);
assert_eq!(exec.run_until_stalled(&mut fut), Poll::Ready(()));
}
// Verify that the IfaceManagerService does not have an AP interface.
assert!(iface_manager.aps.is_empty());
} | rust_cleaned_test_functions.jsonl/62739 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 704
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
68659,
21093,
368,
341,
286,
1077,
5206,
3883,
284,
282,
73391,
28346,
486,
25255,
486,
931,
1005,
17119,
445,
16091,
311,
1855,
458,
31558,
797,
286,
1077,
1273,
9146,
284,
1273,
21363,
2099,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_dep_group() {
let tx1 = build_tx(vec![(&h256!("0x1").pack(), 0)], 1);
let tx1_out_point = OutPoint::new(tx1.hash(), 0);
// Dep group cell
let tx2_data = vec![tx1_out_point.clone()].pack().as_bytes();
let tx2 = TransactionBuilder::default()
.input(CellInput::new(OutPoint::new(h256!("0x2").pack(), 0), 0))
.output(
CellOutput::new_builder()
.capacity(Capacity::bytes(1000).unwrap().pack())
.build(),
)
.output_data(tx2_data.pack())
.build();
let tx2_out_point = OutPoint::new(tx2.hash(), 0);
// Transaction use dep group
let dep = CellDep::new_builder()
.out_point(tx2_out_point.clone())
.dep_type(DepType::DepGroup.into())
.build();
let tx3 = TransactionBuilder::default()
.cell_dep(dep)
.input(CellInput::new(OutPoint::new(h256!("0x3").pack(), 0), 0))
.output(
CellOutput::new_builder()
.capacity(Capacity::bytes(3).unwrap().pack())
.build(),
)
.output_data(Bytes::new().pack())
.build();
let tx3_out_point = OutPoint::new(tx3.hash(), 0);
let get_cell_data = |out_point: &OutPoint| -> Option<Bytes> {
if out_point == &tx2_out_point {
Some(tx2_data.clone())
} else {
None
}
};
let mut pool = ProposedPool::new(DEFAULT_MAX_ANCESTORS_SIZE);
for tx in &[&tx1, &tx2, &tx3] {
pool.add_entry(TxEntry::new(
dummy_resolve((*tx).clone(), get_cell_data),
MOCK_CYCLES,
MOCK_FEE,
MOCK_SIZE,
))
.unwrap();
}
let get_deps_len = |pool: &ProposedPool, out_point: &OutPoint| -> usize {
pool.edges
.deps
.get(out_point)
.map(|deps| deps.len())
.unwrap_or_default()
};
assert_eq!(get_deps_len(&pool, &tx1_out_point), 1);
assert_eq!(get_deps_len(&pool, &tx2_out_point), 1);
assert_eq!(get_deps_len(&pool, &tx3_out_point), 0);
pool.remove_committed_tx(
&tx3,
&get_related_dep_out_points(&tx3, &get_cell_data).unwrap(),
);
assert_eq!(get_deps_len(&pool, &tx1_out_point), 0);
assert_eq!(get_deps_len(&pool, &tx2_out_point), 0);
assert_eq!(get_deps_len(&pool, &tx3_out_point), 0);
} | rust_cleaned_test_functions.jsonl/50526 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1485
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
49258,
6288,
368,
341,
286,
1077,
9854,
16,
284,
1936,
17805,
25592,
20703,
2099,
71,
17,
20,
21,
17223,
15,
87,
16,
1827,
4748,
1507,
220,
15,
25035,
220,
16,
317,
286,
1077,
9854,
16,
6068,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_parse_client_final_success() {
let (gs2head, nonce, proof) = parse_client_final("c=abc,r=abcefg,p=783232").unwrap();
assert_eq!(gs2head, "abc");
assert_eq!(nonce, "abcefg");
assert_eq!(proof, "783232");
let (gs2head, nonce, proof) = parse_client_final("c=,r=,p=").unwrap();
assert_eq!(gs2head, "");
assert_eq!(nonce, "");
assert_eq!(proof, "");
} | rust_cleaned_test_functions.jsonl/10294 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 224
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
8179,
20676,
18632,
368,
341,
286,
1077,
320,
5857,
17,
1983,
11,
39676,
11,
11064,
8,
284,
4715,
8179,
20676,
445,
66,
28,
13683,
15883,
28,
370,
346,
4817,
7237,
28,
22,
23,
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... | 1 |
#[test]
fn test_leader_transfer_second_transfer_to_same_node() {
let l = default_logger();
let mut nt = Network::new(vec![None, None, None], &l);
nt.send(vec![new_message(1, 1, MessageType::MsgHup, 0)]);
nt.isolate(3);
nt.send(vec![new_message(3, 1, MessageType::MsgTransferLeader, 0)]);
assert_eq!(nt.peers[&1].lead_transferee.unwrap(), 3);
let heartbeat_timeout = nt.peers[&1].heartbeat_timeout();
for _ in 0..heartbeat_timeout {
nt.peers.get_mut(&1).unwrap().tick();
}
// Second transfer leadership request to the same node.
nt.send(vec![new_message(3, 1, MessageType::MsgTransferLeader, 0)]);
let election_timeout = nt.peers[&1].election_timeout();
for _ in 0..election_timeout - heartbeat_timeout {
nt.peers.get_mut(&1).unwrap().tick();
}
check_leader_transfer_state(&nt.peers[&1], StateRole::Leader, 1);
} | rust_cleaned_test_functions.jsonl/19171 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 375
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
79991,
35403,
29644,
35403,
2346,
33574,
5084,
368,
341,
262,
1077,
326,
284,
1638,
27413,
543,
262,
1077,
5206,
31412,
284,
8141,
486,
931,
25592,
20703,
4064,
11,
2240,
11,
2240,
1125,
609,
75,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_constant_optimization() {
let code = compile_exec("1 + 2 + 3 + 4\n1.5 * 2.5");
assert_eq!(
code.instructions,
vec![
LoadConst {
value: Integer { value: 10.into() }
},
Pop,
LoadConst {
value: Float { value: 3.75 }
},
Pop,
LoadConst { value: None },
ReturnValue,
]
);
} | rust_cleaned_test_functions.jsonl/85619 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 337
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34967,
15032,
65964,
368,
341,
286,
1077,
2038,
284,
19192,
18430,
445,
16,
488,
220,
17,
488,
220,
18,
488,
220,
19,
1699,
16,
13,
20,
353,
220,
17,
13,
20,
797,
286,
2060,
10714,
33673,
31... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_variant_unnamed_field() {
let variant = VariantDef::new("Hello", Fields::Unnamed);
assert_eq!(variant.name(), "Hello");
assert!(matches!(variant.fields(), Fields::Unnamed));
} | rust_cleaned_test_functions.jsonl/55830 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 82
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
46112,
4907,
30245,
5013,
368,
341,
262,
1077,
11424,
284,
39292,
2620,
486,
931,
445,
9707,
497,
24580,
486,
78925,
626,
262,
2060,
10714,
10297,
15969,
2644,
1507,
330,
9707,
797,
262,
2060,
102... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_iterator_flatten_fold() {
let xs = [0, 3, 6];
let ys = [1, 2, 3, 4, 5, 6, 7];
let mut it = xs.iter().map(|&x| x..x+3).flatten();
assert_eq!(it.next(), Some(0));
assert_eq!(it.next_back(), Some(8));
let i = it.fold(0, |i, x| {
assert_eq!(x, ys[i]);
i + 1
});
assert_eq!(i, ys.len());
let mut it = xs.iter().map(|&x| x..x+3).flatten();
assert_eq!(it.next(), Some(0));
assert_eq!(it.next_back(), Some(8));
let i = it.rfold(ys.len(), |i, x| {
assert_eq!(x, ys[i - 1]);
i - 1
});
assert_eq!(i, 0);
} | rust_cleaned_test_functions.jsonl/54105 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 334
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13491,
5081,
14456,
61187,
368,
341,
262,
1077,
11943,
284,
508,
15,
11,
220,
18,
11,
220,
21,
935,
262,
1077,
31810,
284,
508,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
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_drain() {
let mut ooc = OffchainOverlayedChanges::default();
ooc.set(STORAGE_PREFIX, b"kkk", b"vvv");
let drained = ooc.drain().count();
assert_eq!(drained, 1);
let leftover = ooc.iter().count();
assert_eq!(leftover, 0);
ooc.set(STORAGE_PREFIX, b"a", b"v");
ooc.set(STORAGE_PREFIX, b"b", b"v");
ooc.set(STORAGE_PREFIX, b"c", b"v");
ooc.set(STORAGE_PREFIX, b"d", b"v");
ooc.set(STORAGE_PREFIX, b"e", b"v");
assert_eq!(ooc.iter().count(), 5);
} | rust_cleaned_test_functions.jsonl/96081 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 254
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26680,
466,
368,
341,
197,
10217,
5206,
297,
509,
284,
4114,
8819,
32755,
291,
11317,
486,
2258,
543,
197,
22229,
509,
980,
40650,
27708,
18519,
11,
293,
1,
19196,
74,
497,
293,
1,
33075,
85,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_bool_array_and_sliced_same_offset() {
let a = BooleanArray::from_slice(vec![
false, false, false, false, false, false, false, false, false, false, true, true,
]);
let b = BooleanArray::from_slice(vec![
false, false, false, false, false, false, false, false, false, true, false, true,
]);
let a = a.slice(8, 4);
let b = b.slice(8, 4);
let c = and(&a, &b).unwrap();
let expected = BooleanArray::from_slice(vec![false, false, false, true]);
assert_eq!(expected, c);
} | rust_cleaned_test_functions.jsonl/36448 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 273
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
22159,
3858,
8378,
643,
74630,
33574,
6917,
368,
341,
286,
1077,
264,
284,
6992,
1857,
486,
1499,
26488,
25592,
90515,
310,
895,
11,
895,
11,
895,
11,
895,
11,
895,
11,
895,
11,
895,
11,
895,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_bad_requests() {
let bad_requests = [
"bad request\r\n\r\n", // 2 tokens
"yet another bad request\r\n\r\n", // 4 tokens
"CONNECT foo.bar.cøm:443 HTTP/1.1\r\n\r\n", // non-ascii
"CONNECT foo.bar.com:443 HTTP/1.1\r\n\r\n", // double-space
"CONNECT foo.bar.com:443\tHTTP/1.1\r\n\r\n", // CTL
];
bad_requests.iter().for_each(|r| {
let mut codec = build_codec();
let mut buffer = BytesMut::new();
buffer.put_slice(r.as_bytes());
let result = codec.decode(&mut buffer);
assert_eq!(
result,
Err(EstablishTunnelResult::BadRequest),
"Didn't reject {}",
r
);
});
} | rust_cleaned_test_functions.jsonl/8076 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 503
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
34199,
37216,
368,
341,
286,
1077,
3873,
37216,
284,
2278,
310,
330,
13855,
1681,
12016,
1699,
12016,
1699,
497,
5180,
442,
220,
17,
11211,
198,
310,
330,
46392,
2441,
3873,
1681,
12016,
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_build_lookup() {
let morphs = vec![Morph {
surface: "す",
left_id: 1,
right_id: 1,
weight: 1,
contents: "contents 1",
},
Morph {
surface: "す",
left_id: 2,
right_id: 2,
weight: 2,
contents: "contents 2",
},
Morph {
surface: "すも",
left_id: 3,
right_id: 3,
weight: 3,
contents: "contents 3",
},
Morph {
surface: "すもも",
left_id: 4,
right_id: 4,
weight: 4,
contents: "contents 4",
}];
let dict = FstDic::build(&morphs);
let results = dict.lookup_str("すもも");
assert_eq!(results.len(), morphs.len());
// the order of lookup results is not fixed.
for result in results {
assert!(morphs.iter().any(|m| *m == result),
"invalid result: {:?}",
result);
}
} | rust_cleaned_test_functions.jsonl/97716 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1137
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20801,
27464,
368,
341,
286,
1077,
26351,
82,
284,
7486,
20703,
44,
16347,
341,
4597,
7329,
25,
330,
17219,
756,
4597,
2115,
842,
25,
220,
16,
345,
4597,
1290,
842,
25,
220,
16,
345,
4597,
468... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_glx() {
let _ = unsafe { glx::GetProcAddress(std::mem::uninitialized()) };
unsafe { glx::SwapBuffers(std::mem::uninitialized(), std::mem::uninitialized()) };
} | rust_cleaned_test_functions.jsonl/70567 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 74
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1889,
31447,
368,
341,
262,
1077,
716,
284,
19860,
314,
2770,
87,
486,
97558,
5194,
486,
10536,
486,
359,
36161,
2140,
2605,
262,
19860,
314,
2770,
87,
486,
46179,
36219,
5194,
486,
10536,
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 |
#[test]
fn test_build_upload_policy_with_callback_body_with_body_type() -> Result<(), Box<dyn Error>> {
let policy = UploadPolicyBuilder::new_policy_for_bucket("test_bucket", &Config::default())
.callback(
&["https://1.1.1.1", "https://2.2.2.2", "https://3.3.3.3"],
"www.qiniu.com",
"a=b&c=d",
mime::FORM_MIME,
)
.build();
assert_eq!(
policy.callback_urls().map(|urls| urls.collect::<Vec<&str>>()),
Some(vec!["https://1.1.1.1", "https://2.2.2.2", "https://3.3.3.3"])
);
assert_eq!(policy.callback_host(), Some("www.qiniu.com"));
assert_eq!(policy.callback_body(), Some("a=b&c=d"));
assert_eq!(policy.callback_body_type(), Some(mime::FORM_MIME));
let v: Value = serde_json::from_str(policy.as_json().as_str())?;
assert_eq!(v["callbackUrl"], "https://1.1.1.1;https://2.2.2.2;https://3.3.3.3");
assert_eq!(v["callbackHost"], "www.qiniu.com");
assert_eq!(v["callbackBody"], "a=b&c=d");
assert_eq!(v["callbackBodyType"], mime::FORM_MIME);
Ok(())
} | rust_cleaned_test_functions.jsonl/2359 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 626
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20801,
21691,
22773,
6615,
12519,
14114,
6615,
14114,
1819,
368,
1464,
5714,
68843,
8261,
92846,
4600,
2452,
341,
286,
1077,
4842,
284,
24996,
13825,
3297,
486,
931,
22773,
5478,
38749,
445,
1944,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_unicode_multiple_codepoints() {
let invalid = ["नी", "👨👨"];
for c in &invalid {
assert_invalid_str(c);
}
} | rust_cleaned_test_functions.jsonl/4162 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 103
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
54662,
45233,
4136,
7706,
368,
341,
286,
1077,
8318,
284,
4383,
60096,
43647,
497,
330,
145367,
378,
235,
145367,
378,
235,
6332,
286,
369,
272,
304,
609,
11808,
341,
310,
2060,
31433,
2895,
1337,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_signer_t_different_shares() {
let data = "Hello world".as_bytes();
let signers = Signer::generate_signers(N, T);
let identifier = SignatureIdentifier { id: 0, index: 0 };
dbg!(signers.len());
let shares1 = signers
.iter()
.take(T)
.enumerate()
.map(|(i, signer)| (i, signer.sign(data, &identifier)))
.collect();
dbg!(&shares1);
let shares2 = signers
.iter()
.enumerate()
.rev()
.take(T)
.map(|(i, signer)| (i, signer.sign(data, &identifier)))
.collect();
dbg!(&shares2);
let signatures1: Vec<_> = signers
.iter()
.map(|s| s.combine_signatures(&shares1, &identifier))
.collect();
let signatures2: Vec<_> = signers
.iter()
.map(|s| s.combine_signatures(&shares2, &identifier))
.collect();
dbg!(&signatures1);
for (i, sig) in signatures1.iter().enumerate() {
assert!(signers[i].verify_signature(&sig, &data));
}
dbg!(&signatures2);
for (i, sig) in signatures2.iter().enumerate() {
assert!(signers[i].verify_signature(&sig, &data));
}
} | rust_cleaned_test_functions.jsonl/104901 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 717
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11172,
261,
528,
82741,
3712,
5403,
368,
341,
286,
1077,
821,
284,
330,
9707,
1879,
3263,
300,
12524,
543,
286,
1077,
1841,
388,
284,
7075,
261,
486,
19366,
11172,
388,
8204,
11,
350,
317,
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... | 3 |
#[test]
fn test_run_interval() {
const MAX_WAIT: Duration = Duration::from_millis(10_000);
let (sender, receiver) = mpsc::channel();
std::thread::spawn(move || {
let sys = System::new();
sys.block_on(async move {
let _addr = IntervalActor::new(10, sender).start();
});
sys.run().unwrap();
});
let result = receiver
.recv_timeout(MAX_WAIT)
.expect("To receive response in time");
// We wait 10 intervals by ~100ms
assert_eq!(result.elapsed().as_secs(), 1);
} | rust_cleaned_test_functions.jsonl/14480 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 244
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14007,
20541,
368,
341,
262,
733,
8334,
32091,
25,
21045,
284,
21045,
486,
1499,
717,
56212,
7,
16,
15,
62,
15,
15,
15,
626,
262,
1077,
320,
11644,
11,
13964,
8,
284,
296,
81984,
486,
10119,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_parse_serialize_full_tcp() {
use crate::testdata::tls_client_hello_v4::*;
let mut buf = ETHERNET_FRAME.bytes;
let frame = buf.parse_with::<_, EthernetFrame<_>>(EthernetFrameLengthCheck::Check).unwrap();
verify_ethernet_frame(&frame, ETHERNET_FRAME);
let mut body = frame.body();
let packet = body.parse::<Ipv4Packet<_>>().unwrap();
verify_ipv4_packet(&packet, IPV4_PACKET);
let buffer = packet
.body()
.into_serializer()
.encapsulate(packet.builder())
.encapsulate(frame.builder())
.serialize_vec_outer()
.unwrap();
assert_eq!(buffer.as_ref(), ETHERNET_FRAME.bytes);
} | rust_cleaned_test_functions.jsonl/31686 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 365
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
88686,
16372,
45562,
368,
341,
286,
990,
17717,
486,
92425,
486,
34488,
8179,
96724,
2273,
19,
79304,
286,
1077,
5206,
6607,
284,
17768,
3012,
15373,
22260,
42697,
280,
286,
1077,
4034,
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 |
#[test]
fn test_transport_type_tor() {
unsafe {
let mut error = 0;
let error_ptr = &mut error as *mut c_int;
let address_control = CString::new("/ip4/127.0.0.1/tcp/8080").unwrap();
let address_control_str: *const c_char = CString::into_raw(address_control) as *const c_char;
let _transport = transport_tor_create(
address_control_str,
ptr::null_mut(),
8080,
ptr::null_mut(),
ptr::null_mut(),
error_ptr,
);
assert_eq!(error, 0);
}
} | rust_cleaned_test_functions.jsonl/66626 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 361
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
46398,
1819,
528,
269,
368,
341,
286,
19860,
341,
310,
1077,
5206,
1465,
284,
220,
15,
280,
310,
1077,
1465,
4348,
284,
609,
6984,
1465,
438,
353,
6984,
272,
4042,
280,
310,
1077,
2621,
13436,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_remove_client_iface() {
let mut exec = fuchsia_async::Executor::new().expect("failed to create an executor");
// Create an IfaceManager with a client and an AP.
let test_values = test_setup(&mut exec);
let (mut iface_manager, _next_sme_req) =
create_iface_manager_with_client(&test_values, true);
let ap_iface = ApIfaceContainer {
iface_id: TEST_AP_IFACE_ID,
config: None,
ap_state_machine: Box::new(FakeAp {
start_succeeds: true,
stop_succeeds: true,
exit_succeeds: true,
}),
};
iface_manager.aps.push(ap_iface);
// Notify the IfaceManager that the client interface has been removed.
{
let fut = iface_manager.handle_removed_iface(TEST_CLIENT_IFACE_ID);
pin_mut!(fut);
assert_variant!(exec.run_until_stalled(&mut fut), Poll::Ready(()));
}
assert!(iface_manager.clients.is_empty());
assert!(!iface_manager.aps.is_empty());
} | rust_cleaned_test_functions.jsonl/62721 | {
"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,
18193,
8179,
67666,
368,
341,
286,
1077,
5206,
3883,
284,
282,
73391,
28346,
486,
25255,
486,
931,
1005,
17119,
445,
16091,
311,
1855,
458,
31558,
3071,
286,
442,
4230,
458,
1416,
578,
2043,
448,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_tokenizer_2numbers() {
let test_str = ".4 -2";
let tokens: Vec<Token> = Tokens::from_str(test_str).collect();
assert_eq!(tokens, vec![Token::Number(0.4), Token::Number(-2.0)]);
} | rust_cleaned_test_functions.jsonl/109318 | {
"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,
6458,
3135,
62,
17,
37378,
368,
341,
262,
1077,
1273,
2895,
284,
5933,
19,
481,
17,
876,
262,
1077,
11211,
25,
11312,
83416,
29,
284,
58166,
486,
1499,
2895,
8623,
2895,
568,
17384,
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... | 1 |
#[test]
fn test_fudge_dice() {
let s = "2dF";
let roll: Roll = s.parse().expect("Bad parse");
assert_eq!(roll.dice_count, 2);
assert_eq!(roll.sides, 6);
assert_eq!(roll.values, vec![1, 1, 0, 0, -1, -1]);
} | rust_cleaned_test_functions.jsonl/52854 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 141
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
761,
19561,
97196,
368,
341,
286,
1077,
274,
284,
330,
17,
67,
37,
876,
286,
1077,
6502,
25,
14686,
284,
274,
4632,
1005,
17119,
445,
17082,
4715,
797,
286,
2060,
10714,
10297,
1100,
950,
558,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_fr_add_assign() {
{
// Random number
let mut tmp = Fr([
0x437ce7616d580765,
0xd42d1ccb29d1235b,
0xed8f753821bd1423,
0x4eede1c9c89528ca,
]);
assert!(tmp.is_valid());
// Test that adding zero has no effect.
tmp.add_assign(&Fr([0, 0, 0, 0]));
assert_eq!(
tmp,
Fr([
0x437ce7616d580765,
0xd42d1ccb29d1235b,
0xed8f753821bd1423,
0x4eede1c9c89528ca
])
);
// Add one and test for the result.
tmp.add_assign(&Fr([1, 0, 0, 0]));
assert_eq!(
tmp,
Fr([
0x437ce7616d580766,
0xd42d1ccb29d1235b,
0xed8f753821bd1423,
0x4eede1c9c89528ca
])
);
// Add another random number that exercises the reduction.
tmp.add_assign(&Fr([
0x946f435944f7dc79,
0xb55e7ee6533a9b9b,
0x1e43b84c2f6194ca,
0x58717ab525463496,
]));
assert_eq!(
tmp,
Fr([
0xd7ec2abbb24fe3de,
0x35cdf7ae7d0d62f7,
0xd899557c477cd0e9,
0x3371b52bc43de018
])
);
tmp = Fr([
0xffffffff00000000,
0x53bda402fffe5bfe,
0x3339d80809a1d805,
0x73eda753299d7d48,
]);
tmp.add_assign(&Fr([1, 0, 0, 0]));
assert!(tmp.is_zero());
// Add a random number to another one such that the result is r - 1
tmp = Fr([
0xade5adacdccb6190,
0xaa21ee0f27db3ccd,
0x2550f4704ae39086,
0x591d1902e7c5ba27,
]);
tmp.add_assign(&Fr([
0x521a525223349e70,
0xa99bb5f3d8231f31,
0xde8e397bebe477e,
0x1ad08e5041d7c321,
]));
assert_eq!(
tmp,
Fr([
0xffffffff00000000,
0x53bda402fffe5bfe,
0x3339d80809a1d805,
0x73eda753299d7d48
])
);
// Add one to the result and test for it.
tmp.add_assign(&Fr([1, 0, 0, 0]));
assert!(tmp.is_zero());
}
// Test associativity
let mut rng = XorShiftRng::from_seed([
0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc,
0xe5,
]);
for _ in 0..1000 {
let a = Fr::random(&mut rng);
let b = Fr::random(&mut rng);
let c = Fr::random(&mut rng);
let mut tmp1 = a;
tmp1.add_assign(&b);
tmp1.add_assign(&c);
let mut tmp2 = b;
tmp2.add_assign(&c);
tmp2.add_assign(&a);
assert!(tmp1.is_valid());
assert!(tmp2.is_valid());
assert_eq!(tmp1, tmp2);
}
} | rust_cleaned_test_functions.jsonl/100646 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1952
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
41537,
2891,
20688,
368,
341,
262,
341,
286,
442,
10612,
1372,
198,
286,
1077,
5206,
4174,
284,
2869,
8956,
310,
220,
15,
87,
19,
18,
22,
346,
22,
21,
16,
21,
67,
20,
23,
15,
22,
21,
20,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_unregister() {
let mut event_manager = EventManager::new().unwrap();
let dummy_subscriber = Arc::new(Mutex::new(DummySubscriber::new()));
event_manager
.add_subscriber(dummy_subscriber.clone())
.unwrap();
dummy_subscriber.lock().unwrap().unregister_ev1();
event_manager.run().unwrap();
assert!(dummy_subscriber.lock().unwrap().processed_ev1_out());
dummy_subscriber.lock().unwrap().reset_state();
event_manager.run_with_timeout(100).unwrap();
assert!(!dummy_subscriber.lock().unwrap().processed_ev1_out());
} | rust_cleaned_test_functions.jsonl/92053 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 302
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
68992,
368,
341,
286,
1077,
5206,
1538,
12144,
284,
3665,
2043,
486,
931,
1005,
15454,
543,
286,
1077,
17292,
5228,
20351,
284,
19689,
486,
931,
3189,
9371,
486,
931,
5432,
8574,
40236,
486,
931,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_can_print_warnings() {
let dep_graph = DepGraph::new(false);
{
let matches = getopts(&[
"-Awarnings".to_string()
], &optgroups()).unwrap();
let registry = errors::registry::Registry::new(&[]);
let (sessopts, _) = build_session_options_and_crate_config(&matches);
let sess = build_session(sessopts, &dep_graph, None, registry,
Rc::new(DummyCrateStore));
assert!(!sess.diagnostic().can_emit_warnings);
}
{
let matches = getopts(&[
"-Awarnings".to_string(),
"-Dwarnings".to_string()
], &optgroups()).unwrap();
let registry = errors::registry::Registry::new(&[]);
let (sessopts, _) = build_session_options_and_crate_config(&matches);
let sess = build_session(sessopts, &dep_graph, None, registry,
Rc::new(DummyCrateStore));
assert!(sess.diagnostic().can_emit_warnings);
}
{
let matches = getopts(&[
"-Adead_code".to_string()
], &optgroups()).unwrap();
let registry = errors::registry::Registry::new(&[]);
let (sessopts, _) = build_session_options_and_crate_config(&matches);
let sess = build_session(sessopts, &dep_graph, None, registry,
Rc::new(DummyCrateStore));
assert!(sess.diagnostic().can_emit_warnings);
}
} | rust_cleaned_test_functions.jsonl/122240 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 854
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
27421,
10064,
87658,
368,
341,
286,
1077,
2170,
14738,
284,
4148,
11212,
486,
931,
3576,
317,
286,
341,
310,
1077,
9071,
284,
633,
10518,
2099,
9640,
394,
6523,
22600,
14857,
3263,
983,
3904,
741,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_compaction_guard_should_partition_binary_search() {
let guard = CompactionGuardGenerator {
cf_name: CfNames::default,
boundaries: vec![
b"aaa00".to_vec(),
b"aaa01".to_vec(),
b"aaa02".to_vec(),
b"aaa03".to_vec(),
b"aaa04".to_vec(),
b"aaa05".to_vec(),
b"aaa06".to_vec(),
b"aaa07".to_vec(),
b"aaa08".to_vec(),
b"aaa09".to_vec(),
b"aaa10".to_vec(),
b"aaa11".to_vec(),
b"aaa12".to_vec(),
b"aaa13".to_vec(),
b"aaa14".to_vec(),
b"aaa15".to_vec(),
],
min_output_file_size: 8 << 20, // 8MB
pos: Cell::new(0),
};
// Binary search meet exact match.
guard.pos.set(0);
let mut req = SstPartitionerRequest {
prev_user_key: b"aaa12",
current_user_key: b"aaa131",
current_output_file_size: 32 << 20,
};
assert_eq!(guard.should_partition(&req), SstPartitionerResult::Required);
assert_eq!(guard.pos.get(), 13);
// Binary search doesn't find exact match.
guard.pos.set(0);
req = SstPartitionerRequest {
prev_user_key: b"aaa121",
current_user_key: b"aaa122",
current_output_file_size: 32 << 20,
};
assert_eq!(
guard.should_partition(&req),
SstPartitionerResult::NotRequired
);
assert_eq!(guard.pos.get(), 13);
} | rust_cleaned_test_functions.jsonl/24456 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 953
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18177,
1311,
36796,
43378,
43840,
31761,
10716,
368,
341,
286,
1077,
7616,
284,
13317,
1311,
20806,
12561,
341,
310,
24111,
1269,
25,
89894,
7980,
486,
2258,
345,
310,
22711,
25,
7486,
90515,
394,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_vectors_snow() {
let file = OpenOptions::new().write(true).create_new(true).open("tests/vectors/snow.txt");
if let Ok(mut file) = file {
serde_json::to_writer_pretty(&mut file, &generate_vector_set()).unwrap();
}
let mut file = File::open("tests/vectors/snow.txt").unwrap();
let mut contents = String::new();
file.read_to_string(&mut contents).unwrap();
test_vectors_from_json(&contents);
} | rust_cleaned_test_functions.jsonl/75130 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 181
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
49158,
643,
3328,
368,
341,
262,
1077,
1034,
284,
5264,
3798,
486,
931,
1005,
4934,
3715,
568,
3182,
5921,
3715,
568,
2508,
445,
23841,
5457,
10605,
2687,
3328,
3909,
797,
262,
421,
1077,
7622,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_materialize_1() -> Result<()> {
let query = parse(
r#"
func count x -> s"count({x})"
from employees
aggregate [
count salary
]
"#,
)?;
let mat = resolve_and_materialize(query).unwrap();
assert_yaml_snapshot!(mat,
@r###"
---
- Transform:
From:
name: employees
alias: ~
declared_at: 39
- Transform:
Aggregate:
assigns:
- SString:
- String: count(
- Expr:
Ident: salary
- String: )
by: []
"###
);
Ok(())
} | rust_cleaned_test_functions.jsonl/90561 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 496
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
33884,
551,
62,
16,
368,
1464,
5714,
71698,
341,
286,
1077,
3239,
284,
4715,
1006,
310,
435,
2,
698,
286,
2915,
1760,
856,
1464,
220,
274,
1,
1830,
2306,
87,
5410,
1837,
286,
504,
8256,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_do_work() {
assert_eq!(
"fd9528b920d6d3956e9e16114523e1889c751e8c1e040182116d4c906b43f558".to_string(),
do_work(&[0x99])
);
} | rust_cleaned_test_functions.jsonl/78267 | {
"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,
26309,
11498,
368,
341,
286,
2060,
10714,
33673,
310,
330,
6902,
24,
20,
17,
23,
65,
24,
17,
15,
67,
21,
67,
18,
24,
20,
21,
68,
24,
68,
16,
21,
16,
16,
19,
20,
17,
18,
68,
16,
23,
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_invalid_argument() {
let mut runner = Runner::new();
let mut query = runner.proxy.start_logging(
"test",
&mut vec![&mut Metric::CpuLoad(CpuLoad { interval_ms: 0 })].into_iter(),
200,
false,
false,
);
// Check `InvalidSamplingInterval` is returned when interval_ms is 0.
assert_matches!(
runner.executor.run_until_stalled(&mut query),
Poll::Ready(Ok(Err(fmetrics::MetricsLoggerError::InvalidSamplingInterval)))
);
let mut query = runner.proxy.start_logging(
"test",
&mut vec![&mut Metric::CpuLoad(CpuLoad { interval_ms: 200 })].into_iter(),
1_000,
true,
false,
);
// Check `InvalidSamplingInterval` is returned when logging samples to syslog at an interval
// smaller than MIN_INTERVAL_FOR_SYSLOG_MS.
assert_matches!(
runner.executor.run_until_stalled(&mut query),
Poll::Ready(Ok(Err(fmetrics::MetricsLoggerError::InvalidSamplingInterval)))
);
let mut query = runner.proxy.start_logging(
"test",
&mut vec![&mut Metric::CpuLoad(CpuLoad { interval_ms: 200 })].into_iter(),
100,
false,
false,
);
// Check `InvalidSamplingInterval` is returned when logging samples to syslog at an interval
// larger than `duration_ms`.
assert_matches!(
runner.executor.run_until_stalled(&mut query),
Poll::Ready(Ok(Err(fmetrics::MetricsLoggerError::InvalidSamplingInterval)))
);
} | rust_cleaned_test_functions.jsonl/66705 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 810
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31433,
9025,
368,
341,
286,
1077,
5206,
22259,
284,
44946,
486,
931,
1428,
286,
1077,
5206,
3239,
284,
22259,
41103,
4962,
59982,
1006,
310,
330,
1944,
756,
310,
609,
6984,
7486,
20703,
5,
6984,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_interrupt() {
let code = String::from(SYSTEM_HEADER) + "\
(j RESET_HANDLER)
(nop)
(nop)
(nop)
(label TRAP_HANDLER)
; write to output
(lw t1 t3 0)
(sw t2 t1 0)
(lui t4 end_pc_target)
(addi t4 t4 end_pc_target)
(jalr zero t4 0)
(label RESET_HANDLER)
; enable global interrupt
(csrrsi zero 0x4 mstatus)
(li t0 0x800)
(csrrs zero t0 mie)
; t2 output
; t3 input
(lui t2 output)
(addi t2 t2 output)
(lui t3 input)
(addi t3 t3 input)
(wfi)
";
let bin = asm::assemble_mem(&code).expect("assemble");
let (mut m, output_device, input_device) = vpc(&bin, Vec::<u8>::new());
// This should wfi
match m.run(10, true) {
Ok(cycles) => assert_eq!(cycles, 9),
Err(e) => panic!("{:?}", e),
}
// Write to input
input_device.borrow_mut().input("a");
// This should terminate
match m.run(10, true) {
Ok(cycles) => panic!("unexpected wfi"),
Err(RunError::Terminated) => (),
Err(e) => panic!("{:?}", e),
}
let output = output_device.borrow().writer.clone();
assert_eq!(output.len(), 1);
assert_eq!(output[0], b'a');
} | rust_cleaned_test_functions.jsonl/134296 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 532
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
42606,
368,
341,
262,
1077,
2038,
284,
923,
486,
1499,
3759,
58761,
20330,
8,
488,
93317,
3325,
53215,
42472,
340,
1445,
453,
340,
1445,
453,
340,
1445,
453,
692,
13345,
4984,
2537,
42472,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_array_windows_infer() {
let v: &[i32] = &[0, 1, 0, 1];
assert_eq!(v.array_windows::<2>().count(), 3);
let c = v.array_windows();
for &[a, b] in c {
assert_eq!(a + b, 1);
}
let v2: &[i32] = &[0, 1, 2, 3, 4, 5, 6];
let total = v2.array_windows().map(|&[a, b, c]| a + b + c).sum::<i32>();
assert_eq!(total, 3 + 6 + 9 + 12 + 15);
} | rust_cleaned_test_functions.jsonl/9656 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 211
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3858,
58220,
1243,
802,
368,
341,
262,
1077,
348,
25,
44590,
72,
18,
17,
60,
284,
44590,
15,
11,
220,
16,
11,
220,
15,
11,
220,
16,
935,
262,
2060,
10714,
10297,
85,
7234,
58220,
27638,
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... | 2 |
#[test]
fn test_id() {
let method = test_method();
let mut new = method.clone();
*new.id_mut() = "did:diff:123".parse().unwrap();
let diff = method.diff(&new).unwrap();
assert!(diff.controller.is_none());
assert!(diff.key_data.is_none());
assert!(diff.key_type.is_none());
assert!(diff.properties.is_none());
assert_eq!(diff.id, Some(DiffString(Some("did:diff:123".to_string()))));
let merge = method.merge(diff).unwrap();
assert_eq!(merge, new);
} | rust_cleaned_test_functions.jsonl/124419 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 210
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
842,
368,
341,
262,
1077,
1714,
284,
1273,
9032,
543,
262,
1077,
5206,
501,
284,
1714,
15997,
543,
262,
353,
931,
1764,
29523,
368,
284,
330,
22920,
25,
13490,
25,
16,
17,
18,
3263,
6400,
1005... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_push_vote() {
let mut rng = rand::thread_rng();
let keys = Keypair::new();
let contact_info = ContactInfo::new_localhost(&keys.pubkey(), 0);
let cluster_info = ClusterInfo::new_with_invalid_keypair(contact_info);
// make sure empty crds is handled correctly
let now = timestamp();
let (_, votes, max_ts) = cluster_info.get_votes(now);
assert_eq!(votes, vec![]);
assert_eq!(max_ts, now);
// add a vote
let vote = Vote::new(
vec![1, 3, 7], // slots
solana_sdk::hash::new_rand(&mut rng),
);
let ix = vote_instruction::vote(
&Pubkey::new_unique(), // vote_pubkey
&Pubkey::new_unique(), // authorized_voter_pubkey
vote,
);
let tx = Transaction::new_with_payer(
&[ix], // instructions
None, // payer
);
let tower = vec![7]; // Last slot in the vote.
cluster_info.push_vote(&tower, tx.clone());
cluster_info.flush_push_queue();
// -1 to make sure that the clock is strictly lower then when insert occurred
let (labels, votes, max_ts) = cluster_info.get_votes(now - 1);
assert_eq!(votes, vec![tx]);
assert_eq!(labels.len(), 1);
match labels[0] {
CrdsValueLabel::Vote(_, pubkey) => {
assert_eq!(pubkey, keys.pubkey());
}
_ => panic!("Bad match"),
}
assert!(max_ts >= now - 1);
// make sure timestamp filter works
let (_, votes, new_max_ts) = cluster_info.get_votes(max_ts);
assert_eq!(votes, vec![]);
assert_eq!(max_ts, new_max_ts);
} | rust_cleaned_test_functions.jsonl/20368 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 835
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14218,
54360,
368,
341,
286,
1077,
5206,
28422,
284,
10382,
486,
4528,
66849,
543,
286,
1077,
6894,
284,
6569,
1082,
1310,
486,
931,
543,
286,
1077,
3645,
3109,
284,
9180,
1731,
486,
931,
62,
83... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_clone() {
let mock_handle = Box::into_raw(Box::new(MockGarbageCollector::default()));
let count = Arc::new(AtomicUsize::new(1));
let value = RefCounter::new(count);
let shared1 = SharedGeneric::<RefCounter, MockGarbageCollector, MockNode<RefCounter>>::new(
mock_handle,
value,
);
set_drop_command(&shared1, mock_ptr(1));
let current_count = get_node_ref_count(&shared1);
assert_eq!(
current_count, 1,
"Ref count is not 1, but there's only 1 ref"
);
#[allow(clippy::redundant_clone)]
let shared2 = shared1.clone();
let current_count = get_node_ref_count(&shared2);
assert_eq!(current_count, 2, "Ref count is not 2, but there're 2 refs");
} | rust_cleaned_test_functions.jsonl/48709 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 378
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
54742,
368,
341,
286,
1077,
7860,
10630,
284,
8261,
486,
18122,
16067,
67758,
486,
931,
66436,
43930,
20652,
53694,
486,
2258,
7392,
286,
1077,
1760,
284,
19689,
486,
931,
7,
65857,
52,
2141,
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_no_inline_aliases5b() {
test_same("var x = this.foo(); this.bar(); var y; y = x; this.bing(); this.baz(y); x = 3;");
} | rust_cleaned_test_functions.jsonl/27686 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 68
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6536,
41871,
90233,
20,
65,
368,
341,
262,
1273,
33574,
445,
947,
856,
284,
419,
58432,
2129,
419,
22001,
2129,
762,
379,
26,
379,
284,
856,
26,
419,
948,
287,
2129,
419,
948,
1370,
7021,
1215... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_fill_data() {
let mut builder = BooleanArrayBuilder::with_capacity(16);
builder.append_value(true);
builder.append_value(false);
builder.append_null();
builder.append_option(Some(false));
builder.append_option(None);
let data_array: DFBooleanArray = builder.finish();
let mut iter = data_array.into_iter();
assert_eq!(Some(Some(true)), iter.next());
assert_eq!(Some(Some(false)), iter.next());
assert_eq!(Some(None), iter.next());
assert_eq!(Some(Some(false)), iter.next());
assert_eq!(Some(None), iter.next());
assert_eq!(None, iter.next());
} | rust_cleaned_test_functions.jsonl/53498 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 241
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
30728,
1769,
368,
341,
262,
1077,
5206,
7363,
284,
6992,
1857,
3297,
486,
4197,
35603,
7,
16,
21,
317,
262,
7363,
2057,
3142,
3715,
317,
262,
7363,
2057,
3142,
3576,
317,
262,
7363,
2057,
15162,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_mkfifoat_directory_none() {
let _m = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");
// mkfifoat should fail if a directory is given
assert!(!mkfifoat(None, &env::temp_dir(), Mode::S_IRUSR).is_ok());
} | rust_cleaned_test_functions.jsonl/30592 | {
"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,
64861,
74031,
266,
14846,
31488,
368,
341,
262,
1077,
716,
76,
284,
3504,
34,
17563,
27661,
4125,
1005,
17119,
445,
38099,
2684,
70498,
553,
2441,
1273,
3071,
262,
442,
23789,
74031,
266,
1265,
36... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_terms_query() {
let terms_query = Query::build_terms("field_name")
.with_values(vec!["a", "b", "c"])
.build();
assert_eq!("{\"terms\":{\"field_name\":[\"a\",\"b\",\"c\"]}}",
serde_json::to_string(&terms_query).unwrap());
let terms_query_2 = Query::build_terms("field_name")
.with_values(["a", "b", "c"].as_ref())
.build();
assert_eq!("{\"terms\":{\"field_name\":[\"a\",\"b\",\"c\"]}}",
serde_json::to_string(&terms_query_2).unwrap());
let terms_query_3 = Query::build_terms("field_name")
.with_values(TermsQueryLookup::new(123, "blah.de.blah").with_index("other"))
.build();
assert_eq!("{\"terms\":{\"field_name\":{\"id\":123,\"index\":\"other\",\"path\":\"blah.de.blah\"}}}",
serde_json::to_string(&terms_query_3).unwrap());
} | rust_cleaned_test_functions.jsonl/4270 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 474
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
37498,
5738,
368,
341,
286,
1077,
3793,
5738,
284,
11361,
486,
5834,
37498,
445,
2566,
1269,
1138,
310,
659,
4197,
9146,
25592,
0,
1183,
64,
497,
330,
65,
497,
330,
66,
14108,
310,
659,
5834,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_lr0_automaton() {
let GrammarUtil { grammar, .. } = create_grammar();
let automaton = grammar.lr0_automaton();
assert_eq!(automaton.states.len(), 12);
} | rust_cleaned_test_functions.jsonl/24527 | {
"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,
46086,
15,
62,
27073,
23535,
368,
341,
286,
1077,
61977,
2742,
314,
31428,
11,
5241,
335,
284,
1855,
62,
41094,
543,
286,
1077,
5006,
23535,
284,
31428,
63349,
15,
62,
27073,
23535,
1428,
286,
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 |
#[test]
fn test_traverse_subnet() {
let tmpdir = tempfile::Builder::new().prefix("test").tempdir().unwrap();
let mut state = ReplicatedState::new_rooted_at(
subnet_test_id(1),
SubnetType::Application,
tmpdir.path().into(),
);
state.metadata.network_topology.subnets = btreemap! {
subnet_test_id(0) => SubnetTopology {
public_key: vec![1, 2, 3, 4],
nodes: btreemap!{},
subnet_type: SubnetType::Application,
},
subnet_test_id(1) => SubnetTopology {
public_key: vec![5, 6, 7, 8],
nodes: btreemap!{},
subnet_type: SubnetType::Application,
}
};
fn id_range(from: u64, to: u64) -> CanisterIdRange {
CanisterIdRange {
start: CanisterId::from_u64(from),
end: CanisterId::from_u64(to),
}
}
state.metadata.network_topology.routing_table = RoutingTable(btreemap! {
id_range(0, 10) => subnet_test_id(0),
id_range(11, 20) => subnet_test_id(1),
id_range(21, 30) => subnet_test_id(0),
});
let visitor = TracingVisitor::new(NoopVisitor);
state.metadata.certification_version = 2;
assert_eq!(
vec![
E::StartSubtree,
edge("canister"),
E::StartSubtree,
E::EndSubtree, // canisters
edge("metadata"),
E::VisitBlob(encode_metadata(SystemMetadata {
id_counter: 0,
prev_state_hash: None
})),
edge("request_status"),
E::StartSubtree,
E::EndSubtree, // request_status
edge("streams"),
E::StartSubtree,
E::EndSubtree, // streams
edge("subnet"),
E::StartSubtree,
E::EnterEdge(subnet_test_id(0).get().into_vec()),
E::StartSubtree,
edge("public_key"),
E::VisitBlob(vec![1, 2, 3, 4]),
E::EndSubtree, // subnet
E::EnterEdge(subnet_test_id(1).get().into_vec()),
E::StartSubtree,
edge("public_key"),
E::VisitBlob(vec![5, 6, 7, 8]),
E::EndSubtree, // subnet
E::EndSubtree, // subnets
edge("time"),
leb_num(0),
E::EndSubtree, // global
],
traverse(&state, visitor).0
);
let patter = Pattern::match_only("subnet", Pattern::all());
let visitor = SubtreeVisitor::new(&patter, TracingVisitor::new(NoopVisitor));
state.metadata.certification_version = 3;
assert_eq!(
vec![
E::StartSubtree,
edge("subnet"),
E::StartSubtree,
E::EnterEdge(subnet_test_id(0).get().into_vec()),
E::StartSubtree,
edge("canister_ranges"),
// 00000000000000000101 # "\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01"
// 000000000000000A0101 # "\x00\x00\x00\x00\x00\x00\x00\n\x01\x01"
// 00000000000000150101 # "\x00\x00\x00\x00\x00\x00\x00\x15\x01\x01"
// 000000000000001E0101 # "\x00\x00\x00\x00\x00\x00\x00\x1E\x01\x01"
E::VisitBlob(hex::decode("d9d9f782824a000000000000000001014a000000000000000a0101824a000000000000001501014a000000000000001e0101").unwrap()),
edge("public_key"),
E::VisitBlob(vec![1, 2, 3, 4]),
E::EndSubtree, // subnet
E::EnterEdge(subnet_test_id(1).get().into_vec()),
E::StartSubtree,
edge("canister_ranges"),
// 000000000000000B0101 # "\x00\x00\x00\x00\x00\x00\x00\v\x01\x01"
// 00000000000000140101 # "\x00\x00\x00\x00\x00\x00\x00\x14\x01\x01"
E::VisitBlob(hex::decode("d9d9f781824a000000000000000b01014a00000000000000140101").unwrap()),
edge("public_key"),
E::VisitBlob(vec![5, 6, 7, 8]),
E::EndSubtree, // subnet
E::EndSubtree, // subnets
E::EndSubtree, // global
],
traverse(&state, visitor).0
);
} | rust_cleaned_test_functions.jsonl/98357 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2870
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3547,
22439,
95681,
368,
341,
286,
1077,
4174,
3741,
284,
54819,
486,
3297,
486,
931,
1005,
11849,
445,
1944,
1827,
3888,
3741,
1005,
15454,
543,
286,
1077,
5206,
1584,
284,
3321,
13724,
1397,
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_remove_branch_1_7_11() {
let mut block_tree = create_block_tree();
block_tree.remove_branch(id(1));
for i in 1..=11 {
let block = block_tree.get_block(id(i));
match i {
1 | 2 | 3 | 4 | 5 => assert!(block.is_none()),
_ => assert!(block.is_some()),
}
}
block_tree.remove_branch(id(7));
for i in 1..=11 {
let block = block_tree.get_block(id(i));
match i {
1 | 2 | 3 | 4 | 5 | 7 | 8 => assert!(block.is_none()),
_ => assert!(block.is_some()),
}
}
block_tree.remove_branch(id(11));
for i in 1..=11 {
let block = block_tree.get_block(id(i));
match i {
1 | 2 | 3 | 4 | 5 | 7 | 8 | 11 => assert!(block.is_none()),
_ => assert!(block.is_some()),
}
}
} | rust_cleaned_test_functions.jsonl/87729 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 453
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18193,
28031,
62,
16,
62,
22,
62,
16,
16,
368,
341,
262,
1077,
5206,
2504,
11663,
284,
1855,
7113,
11663,
1428,
262,
2504,
11663,
4850,
28031,
3724,
7,
16,
1106,
262,
369,
600,
304,
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... | 7 |
#[test]
fn test_construct() {
let mut bytes = vec![0xa5; 12];
let mut packet = Packet::new_unchecked(&mut bytes);
packet.set_src_port(48896);
packet.set_dst_port(53);
packet.set_len(12);
packet.set_checksum(0xffff);
packet.payload_mut().copy_from_slice(&PAYLOAD_BYTES[..]);
packet.fill_checksum(&SRC_ADDR.into(), &DST_ADDR.into());
assert_eq!(&packet.into_inner()[..], &PACKET_BYTES[..]);
} | rust_cleaned_test_functions.jsonl/36416 | {
"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,
64803,
368,
341,
286,
1077,
5206,
5820,
284,
7486,
20703,
15,
9591,
20,
26,
220,
16,
17,
935,
286,
1077,
5206,
10151,
284,
28889,
486,
931,
4907,
7549,
2099,
6984,
5820,
317,
286,
10151,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.