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_big_query_rect() {
let mut g: SparseShapeGrid<(), [f32; 2]> = SparseShapeGrid::new(10);
for i in 0..100 {
g.insert([i as f32, 0.0], ());
}
let q: Vec<_> = g
.query(AABB::new([5.5, 1.0].into(), [15.5, -1.0].into()))
.map(|x| x.0)
.collect();
assert_eq!(q.len(), 10);
} | rust_cleaned_test_functions.jsonl/32144 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 240
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36386,
5738,
16979,
368,
972,
286,
1077,
5206,
342,
25,
71794,
12301,
3543,
68843,
508,
69,
18,
17,
26,
220,
17,
25669,
284,
71794,
12301,
3543,
486,
931,
7,
16,
15,
3079,
286,
369,
600,
304,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_univariate_kf_setup() {
let mut kf: KalmanFilter<f32, U1, U1, U1> = KalmanFilter::<f32, U1, U1, U1>::default();
for i in 0..1000 {
let zf = i as f32;
let z = Vector1::new(zf);
kf.predict(None, None, None, None);
kf.update(&z, None, None);
assert_approx_eq!(zf, kf.z.clone().unwrap()[0]);
}
} | rust_cleaned_test_functions.jsonl/25007 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 231
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4907,
55422,
4698,
69,
21363,
368,
341,
286,
1077,
5206,
85580,
25,
26832,
1515,
5632,
63895,
18,
17,
11,
547,
16,
11,
547,
16,
11,
547,
16,
29,
284,
26832,
1515,
5632,
27638,
69,
18,
17,
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... | 2 |
#[test]
fn test_aes192_ctr() {
let pt = "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710";
let ct = "1abc932417521ca24f2b0459fe7e6e0b090339ec0aa6faefd5ccc2c6f4ce8e941e36b26bd1ebc670d1bd1d665620abf74f78a7f6d29809585a97daec58c6b050";
let key = "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b";
let iv = "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff";
cipher_test(super::Cipher::aes_192_ctr(), pt, ct, key, iv);
} | rust_cleaned_test_functions.jsonl/110540 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 338
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
90958,
16,
24,
17,
69096,
368,
341,
23459,
286,
1077,
10817,
284,
330,
21,
8904,
16,
32031,
17,
17,
68,
19,
15,
24,
69,
24,
21,
68,
24,
18,
67,
22,
68,
16,
16,
22,
18,
24,
18,
16,
22,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_messages() -> Result<(), AmqpCodecError> {
let msg1 = InMessage::default().set_properties(|props| props.message_id = Some(1.into()));
let msg2 = InMessage::default().set_properties(|props| props.message_id = Some(2.into()));
let msg = InMessage::default().set_body(|body| {
body.messages.push(msg1.clone().into());
body.messages.push(msg2.clone().into());
});
let mut buf = BytesMut::with_capacity(msg.encoded_size());
msg.encode(&mut buf);
let msg3 = InMessage::decode(&buf)?.1;
let msg4 = InMessage::decode(&msg3.body.data().unwrap())?.1;
assert_eq!(msg1.properties, msg4.properties);
let msg5 = InMessage::decode(&msg3.body.data[1])?.1;
assert_eq!(msg2.properties, msg5.properties);
Ok(())
} | rust_cleaned_test_functions.jsonl/38639 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 381
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
23428,
368,
1464,
5714,
68843,
3303,
32763,
36913,
1454,
29,
341,
286,
1077,
3750,
16,
284,
758,
2052,
486,
2258,
1005,
746,
25158,
22428,
4761,
91,
6914,
6698,
842,
284,
4329,
7,
16,
39860,
739... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_verify_seal_fr32_validation() {
let convertible_to_fr_bytes = [0; 32];
let out = bytes_into_fr::<Bls12>(&convertible_to_fr_bytes);
assert!(out.is_ok(), "tripwire");
let not_convertible_to_fr_bytes = [255; 32];
let out = bytes_into_fr::<Bls12>(¬_convertible_to_fr_bytes);
assert!(out.is_err(), "tripwire");
{
let result = verify_seal(
PoRepConfig {
sector_size: SectorSize(SECTOR_SIZE_ONE_KIB),
partitions: PoRepProofPartitions(
*POREP_PARTITIONS
.read()
.unwrap()
.get(&SECTOR_SIZE_ONE_KIB)
.unwrap(),
),
},
not_convertible_to_fr_bytes,
convertible_to_fr_bytes,
[0; 32],
SectorId::from(0),
[0; 32],
[0; 32],
&[],
);
if let Err(err) = result {
let needle = "Invalid all zero commitment";
let haystack = format!("{}", err);
assert!(
haystack.contains(needle),
format!("\"{}\" did not contain \"{}\"", haystack, needle)
);
} else {
panic!("should have failed comm_r to Fr32 conversion");
}
}
{
let result = verify_seal(
PoRepConfig {
sector_size: SectorSize(SECTOR_SIZE_ONE_KIB),
partitions: PoRepProofPartitions(
*POREP_PARTITIONS
.read()
.unwrap()
.get(&SECTOR_SIZE_ONE_KIB)
.unwrap(),
),
},
convertible_to_fr_bytes,
not_convertible_to_fr_bytes,
[0; 32],
SectorId::from(0),
[0; 32],
[0; 32],
&[],
);
if let Err(err) = result {
let needle = "Invalid all zero commitment";
let haystack = format!("{}", err);
assert!(
haystack.contains(needle),
format!("\"{}\" did not contain \"{}\"", haystack, needle)
);
} else {
panic!("should have failed comm_d to Fr32 conversion");
}
}
} | rust_cleaned_test_functions.jsonl/53306 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1666
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
35638,
3453,
278,
41537,
18,
17,
19416,
368,
341,
286,
1077,
67613,
2346,
41537,
12524,
284,
508,
15,
26,
220,
18,
17,
935,
286,
1077,
700,
284,
5820,
45514,
41537,
27638,
33,
4730,
16,
17,
44... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_bytewise_fold_before_tab_with_narrow_width() {
new_ucmd!()
.args(&["-w7", "-b"])
.pipe_in("a\t1")
.succeeds()
.stdout_is("a\t1");
} | rust_cleaned_test_functions.jsonl/23310 | {
"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,
3710,
83,
24350,
61187,
23708,
17344,
6615,
1089,
6044,
7927,
368,
341,
262,
501,
68887,
2277,
0,
741,
286,
659,
2116,
2099,
1183,
12,
86,
22,
497,
6523,
65,
14108,
286,
659,
13768,
1243,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_urlencoded_error() {
let mut req = TestRequest::with_header(
header::CONTENT_TYPE,
"application/x-www-form-urlencoded",
)
.header(header::CONTENT_LENGTH, "xxxx")
.finish();
assert_eq!(
req.urlencoded::<Info>().poll().err().unwrap(),
UrlencodedError::UnknownLength
);
let mut req = TestRequest::with_header(
header::CONTENT_TYPE,
"application/x-www-form-urlencoded",
)
.header(header::CONTENT_LENGTH, "1000000")
.finish();
assert_eq!(
req.urlencoded::<Info>().poll().err().unwrap(),
UrlencodedError::Overflow
);
let mut req = TestRequest::with_header(header::CONTENT_TYPE, "text/plain")
.header(header::CONTENT_LENGTH, "10")
.finish();
assert_eq!(
req.urlencoded::<Info>().poll().err().unwrap(),
UrlencodedError::ContentType
);
} | rust_cleaned_test_functions.jsonl/12551 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 522
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2903,
19329,
4096,
368,
341,
286,
1077,
5206,
4232,
284,
3393,
1900,
486,
4197,
8757,
1006,
310,
4247,
486,
67872,
4189,
345,
310,
330,
5132,
10776,
41242,
8460,
44557,
756,
286,
1727,
286,
659,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_version_create() {
let hdr: MapxOrdRawKeyVs<usize> = MapxOrdRawKeyVs::new();
pnk!(hdr.version_create(VersionName(b"v-001")));
assert!(hdr.version_create(VersionName(b"v-001")).is_err());
assert!(hdr.is_empty());
pnk!(hdr.version_create(VersionName(b"v-002")));
assert!(hdr.is_empty());
} | rust_cleaned_test_functions.jsonl/53987 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 157
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9438,
8657,
368,
341,
262,
1077,
36615,
25,
5027,
87,
24621,
20015,
1592,
51737,
90244,
29,
284,
5027,
87,
24621,
20015,
1592,
51737,
486,
931,
543,
262,
43050,
74,
10297,
28785,
19484,
8657,
7,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_slice_partition_dedup_one() {
let mut slice = [12];
let (dedup, duplicates) = slice.partition_dedup();
assert_eq!(dedup, [12]);
assert_eq!(duplicates, []);
} | rust_cleaned_test_functions.jsonl/9703 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 89
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26488,
43840,
814,
291,
454,
11667,
368,
341,
262,
1077,
5206,
15983,
284,
508,
16,
17,
4821,
262,
1077,
320,
9789,
454,
11,
42328,
8,
284,
15983,
79009,
814,
291,
454,
1428,
262,
2060,
10714,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_custom_new_in_folded_graph() {
let mol = molecule::Molecule::from_smiles("c1ccccc1CN");
let new_custom = Atom::custom_new_in_folded_graph(200, &(5, 6), &mol.atoms);
assert_eq!(new_custom.kind, "CustomAtom".to_string());
assert_eq!(new_custom.bonds.len(), 1);
assert_eq!(new_custom.bonds[0].tid, 5);
} | rust_cleaned_test_functions.jsonl/128008 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 180
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15875,
5921,
1243,
61187,
291,
14738,
368,
341,
286,
1077,
21609,
284,
41930,
486,
44,
54169,
486,
1499,
15874,
3658,
445,
66,
16,
638,
37054,
16,
28668,
797,
286,
1077,
501,
15875,
284,
39516,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_valid_array() {
let deserializer = &mut Deserializer::from_str(r#"[1,2]"#);
let mut meta_map = MetaMap::new();
meta_map.insert("0".to_string(), Meta::from_error("a"));
meta_map.insert("1".to_string(), Meta::from_error("b"));
let value = Annotated::from(vec![
Annotated::new(1, Meta::from_error("a")),
Annotated::new(2, Meta::from_error("b")),
]);
assert_eq_dbg!(value, deserialize_meta(deserializer, meta_map).unwrap());
} | rust_cleaned_test_functions.jsonl/126355 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 256
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8337,
3858,
368,
341,
286,
1077,
939,
41939,
284,
609,
6984,
3874,
41939,
486,
1499,
2895,
2601,
2,
36864,
16,
11,
17,
19177,
2,
317,
286,
1077,
5206,
8823,
5376,
284,
15819,
2227,
486,
931,
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_peer_store_persistent() {
let now_ms = faketime::unix_time_as_millis();
let mut peer_store = PeerStore::default();
// add addrs to addr manager
let addr_manager = peer_store.mut_addr_manager();
let addr1 = {
let addr: Multiaddr = "/ip4/127.0.0.1/tcp/42".parse().unwrap();
AddrInfo::new(
PeerId::random(),
addr.extract_ip_addr().unwrap(),
addr,
0,
60,
)
};
let addr2 = {
let addr: Multiaddr = "/ip4/127.0.0.5/tcp/42".parse().unwrap();
let mut addr_info = AddrInfo::new(
PeerId::random(),
addr.extract_ip_addr().unwrap(),
addr,
100,
30,
);
addr_info.mark_tried(now_ms);
addr_info
};
addr_manager.add(addr1.clone());
addr_manager.add(addr2.clone());
// add addrs to ban list
let ban_list = peer_store.mut_ban_list();
let addr3 = multiaddr_to_ip_network(&"/ip4/127.0.0.1/tcp/42".parse().unwrap()).unwrap();
let addr4 = multiaddr_to_ip_network(&"/ip4/127.0.0.2/tcp/42".parse().unwrap()).unwrap();
let addr5 = multiaddr_to_ip_network(&"/ip4/255.0.0.1/tcp/42".parse().unwrap()).unwrap();
let ban1 = BannedAddr {
address: addr3,
ban_until: now_ms + 10_000,
ban_reason: "test1".into(),
created_at: now_ms,
};
let ban2 = BannedAddr {
address: addr4,
ban_until: now_ms + 20_000,
ban_reason: "test2".into(),
created_at: now_ms + 1,
};
let ban3 = BannedAddr {
address: addr5,
ban_until: now_ms + 30_000,
ban_reason: "test3".into(),
created_at: now_ms + 2,
};
ban_list.ban(ban1.clone());
ban_list.ban(ban2.clone());
ban_list.ban(ban3.clone());
// dump and load
let dir = tempfile::tempdir().unwrap();
peer_store.dump_to_dir(&dir.path()).unwrap();
let peer_store2 = PeerStore::load_from_dir(&dir.path()).unwrap();
// check addr manager
let addr_manager2 = peer_store2.addr_manager();
let addrs = addr_manager2.addrs_iter().cloned().map(|mut paddr| {
paddr.random_id_pos = 0;
paddr
});
assert_eq!(
addrs.collect::<HashSet<_>>(),
vec![addr1, addr2].into_iter().collect::<HashSet<_>>()
);
// check ban list
let ban_list2 = peer_store2.ban_list();
assert_eq!(
ban_list2
.get_banned_addrs()
.into_iter()
.collect::<HashSet<_>>(),
vec![ban1, ban2, ban3].into_iter().collect::<HashSet<_>>()
);
} | rust_cleaned_test_functions.jsonl/59453 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1316
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
45159,
14809,
620,
13931,
368,
341,
262,
1077,
1431,
21416,
284,
282,
585,
4107,
486,
56646,
3009,
11898,
717,
56212,
543,
262,
1077,
5206,
14397,
14809,
284,
45147,
6093,
486,
2258,
1428,
262,
44... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_native_libs_tracking_hash_different_values() {
let mut v1 = Options::default();
let mut v2 = Options::default();
let mut v3 = Options::default();
let mut v4 = Options::default();
// Reference
v1.libs = vec![
(String::from("a"), None, Some(cstore::NativeStatic)),
(String::from("b"), None, Some(cstore::NativeFramework)),
(String::from("c"), None, Some(cstore::NativeUnknown)),
];
// Change label
v2.libs = vec![
(String::from("a"), None, Some(cstore::NativeStatic)),
(String::from("X"), None, Some(cstore::NativeFramework)),
(String::from("c"), None, Some(cstore::NativeUnknown)),
];
// Change kind
v3.libs = vec![
(String::from("a"), None, Some(cstore::NativeStatic)),
(String::from("b"), None, Some(cstore::NativeStatic)),
(String::from("c"), None, Some(cstore::NativeUnknown)),
];
// Change new-name
v4.libs = vec![
(String::from("a"), None, Some(cstore::NativeStatic)),
(String::from("b"), Some(String::from("X")), Some(cstore::NativeFramework)),
(String::from("c"), None, Some(cstore::NativeUnknown)),
];
assert!(v1.dep_tracking_hash() != v2.dep_tracking_hash());
assert!(v1.dep_tracking_hash() != v3.dep_tracking_hash());
assert!(v1.dep_tracking_hash() != v4.dep_tracking_hash());
// Check clone
assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
assert_eq!(v4.dep_tracking_hash(), v4.clone().dep_tracking_hash());
} | rust_cleaned_test_functions.jsonl/31996 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 694
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
44494,
16142,
82,
66105,
8950,
82741,
9146,
368,
341,
262,
1077,
5206,
348,
16,
284,
14566,
486,
2258,
543,
262,
1077,
5206,
348,
17,
284,
14566,
486,
2258,
543,
262,
1077,
5206,
348,
18,
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_failpoints_smoketest() {
let scenario = FailScenario::setup();
tokio::runtime::Builder::new()
.basic_scheduler()
.enable_all()
.build()
.unwrap()
.block_on(async {
fail::cfg("filepersistor.load.spawn_blocking", "return").unwrap();
let tmp_dir = TempDir::new().unwrap();
let path = tmp_dir.path().to_owned();
let mut persistor = FilePersistor::new(path, VersionedFileFormat::default());
let result = persistor.load().await;
matches::assert_matches!(result, Err(PersistError::TaskJoin(_)));
});
scenario.teardown();
} | rust_cleaned_test_functions.jsonl/28538 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 308
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
22121,
7706,
15874,
562,
57824,
368,
341,
262,
1077,
15048,
284,
39645,
54031,
486,
15188,
543,
262,
9628,
815,
486,
22255,
486,
3297,
486,
931,
741,
286,
659,
22342,
53646,
741,
286,
659,
12552,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_scan() {
let storage = TestStorageBuilder::new().build().unwrap();
let (tx, rx) = channel();
storage
.async_prewrite(
Context::new(),
vec![
Mutation::Put((Key::from_raw(b"a"), b"aa".to_vec())),
Mutation::Put((Key::from_raw(b"b"), b"bb".to_vec())),
Mutation::Put((Key::from_raw(b"c"), b"cc".to_vec())),
],
b"a".to_vec(),
1,
Options::default(),
expect_ok_callback(tx.clone(), 0),
)
.unwrap();
rx.recv().unwrap();
// Forward
expect_multi_values(
vec![None, None, None],
storage
.async_scan(
Context::new(),
Key::from_raw(b"\x00"),
None,
1000,
5,
Options::default(),
)
.wait(),
);
// Backward
expect_multi_values(
vec![None, None, None],
storage
.async_scan(
Context::new(),
Key::from_raw(b"\xff"),
None,
1000,
5,
Options::default().reverse_scan(),
)
.wait(),
);
// Forward with bound
expect_multi_values(
vec![None, None],
storage
.async_scan(
Context::new(),
Key::from_raw(b"\x00"),
Some(Key::from_raw(b"c")),
1000,
5,
Options::default(),
)
.wait(),
);
// Backward with bound
expect_multi_values(
vec![None, None],
storage
.async_scan(
Context::new(),
Key::from_raw(b"\xff"),
Some(Key::from_raw(b"b")),
1000,
5,
Options::default().reverse_scan(),
)
.wait(),
);
// Forward with limit
expect_multi_values(
vec![None, None],
storage
.async_scan(
Context::new(),
Key::from_raw(b"\x00"),
None,
2,
5,
Options::default(),
)
.wait(),
);
// Backward with limit
expect_multi_values(
vec![None, None],
storage
.async_scan(
Context::new(),
Key::from_raw(b"\xff"),
None,
2,
5,
Options::default().reverse_scan(),
)
.wait(),
);
storage
.async_commit(
Context::new(),
vec![
Key::from_raw(b"a"),
Key::from_raw(b"b"),
Key::from_raw(b"c"),
],
1,
2,
expect_ok_callback(tx.clone(), 1),
)
.unwrap();
rx.recv().unwrap();
// Forward
expect_multi_values(
vec![
Some((b"a".to_vec(), b"aa".to_vec())),
Some((b"b".to_vec(), b"bb".to_vec())),
Some((b"c".to_vec(), b"cc".to_vec())),
],
storage
.async_scan(
Context::new(),
Key::from_raw(b"\x00"),
None,
1000,
5,
Options::default(),
)
.wait(),
);
// Backward
expect_multi_values(
vec![
Some((b"c".to_vec(), b"cc".to_vec())),
Some((b"b".to_vec(), b"bb".to_vec())),
Some((b"a".to_vec(), b"aa".to_vec())),
],
storage
.async_scan(
Context::new(),
Key::from_raw(b"\xff"),
None,
1000,
5,
Options::default().reverse_scan(),
)
.wait(),
);
// Forward with bound
expect_multi_values(
vec![
Some((b"a".to_vec(), b"aa".to_vec())),
Some((b"b".to_vec(), b"bb".to_vec())),
],
storage
.async_scan(
Context::new(),
Key::from_raw(b"\x00"),
Some(Key::from_raw(b"c")),
1000,
5,
Options::default(),
)
.wait(),
);
// Backward with bound
expect_multi_values(
vec![
Some((b"c".to_vec(), b"cc".to_vec())),
Some((b"b".to_vec(), b"bb".to_vec())),
],
storage
.async_scan(
Context::new(),
Key::from_raw(b"\xff"),
Some(Key::from_raw(b"b")),
1000,
5,
Options::default().reverse_scan(),
)
.wait(),
);
// Forward with limit
expect_multi_values(
vec![
Some((b"a".to_vec(), b"aa".to_vec())),
Some((b"b".to_vec(), b"bb".to_vec())),
],
storage
.async_scan(
Context::new(),
Key::from_raw(b"\x00"),
None,
2,
5,
Options::default(),
)
.wait(),
);
// Backward with limit
expect_multi_values(
vec![
Some((b"c".to_vec(), b"cc".to_vec())),
Some((b"b".to_vec(), b"bb".to_vec())),
],
storage
.async_scan(
Context::new(),
Key::from_raw(b"\xff"),
None,
2,
5,
Options::default().reverse_scan(),
)
.wait(),
);
} | rust_cleaned_test_functions.jsonl/22307 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 4558
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28857,
368,
341,
286,
1077,
5819,
284,
3393,
5793,
3297,
486,
931,
1005,
5834,
1005,
15454,
543,
286,
1077,
320,
3998,
11,
19111,
8,
284,
5496,
543,
286,
5819,
198,
310,
659,
7692,
620,
52473,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_api_getter() {
let record = TestRequest {
value2: 10,
..Default::default()
};
assert_eq!(record.value2, 10);
} | rust_cleaned_test_functions.jsonl/60575 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 79
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11697,
3062,
465,
368,
341,
262,
1077,
3255,
284,
3393,
1900,
341,
286,
897,
17,
25,
220,
16,
15,
345,
286,
5241,
3675,
486,
2258,
741,
262,
2605,
262,
2060,
10714,
10297,
8548,
2824,
17,
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 |
#[test]
fn test_tags_ruby() {
let language = get_language("ruby");
let locals_query =
fs::read_to_string(get_language_queries_path("ruby").join("locals.scm")).unwrap();
let tags_config = TagsConfiguration::new(language, RUBY_TAG_QUERY, &locals_query).unwrap();
let source = strip_whitespace(
8,
"
b = 1
def foo=()
c = 1
# a is a method because it is not in scope
# b is a method because `b` doesn't capture variables from its containing scope
bar a, b, c
[1, 2, 3].each do |a|
# a is a parameter
# b is a method
# c is a variable, because the block captures variables from its containing scope.
baz a, b, c
end
end",
);
let mut tag_context = TagsContext::new();
let tags = tag_context
.generate_tags(&tags_config, source.as_bytes(), None)
.unwrap()
.0
.collect::<Result<Vec<_>, _>>()
.unwrap();
assert_eq!(
tags.iter()
.map(|t| (
substr(source.as_bytes(), &t.name_range),
tags_config.syntax_type_name(t.syntax_type_id),
(t.span.start.row, t.span.start.column),
))
.collect::<Vec<_>>(),
&[
("foo=", "method", (2, 4)),
("bar", "call", (7, 4)),
("a", "call", (7, 8)),
("b", "call", (7, 11)),
("each", "call", (9, 14)),
("baz", "call", (13, 8)),
("b", "call", (13, 15),),
]
);
} | rust_cleaned_test_functions.jsonl/66038 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 875
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16333,
1710,
20028,
368,
341,
262,
1077,
4128,
284,
633,
29021,
445,
46275,
797,
262,
1077,
24914,
5738,
4035,
286,
8619,
486,
878,
2346,
3904,
5433,
29021,
65588,
2638,
445,
46275,
1827,
5987,
44... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_look_at_lh_at_origin() {
let eye = Point3::new(0.0, 0.0, 0.0);
let target = Point3::new(1.0, 1.0, 1.0);
let up = Vector3::unit_y();
let unit_z = Vector3::unit_z();
let look_at = Matrix4x4::look_at_lh(&eye, &target, &up);
let direction = target - Point3::origin();
let expected = unit_z.extend(0.0);
let result = look_at * direction.normalize().extend(0.0);
assert!(relative_eq!(result, expected, epsilon = 1e-7));
} | rust_cleaned_test_functions.jsonl/129138 | {
"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,
24271,
3752,
907,
71,
3752,
34043,
368,
341,
286,
1077,
7912,
284,
5126,
18,
486,
931,
7,
15,
13,
15,
11,
220,
15,
13,
15,
11,
220,
15,
13,
15,
317,
286,
1077,
2169,
284,
5126,
18,
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_lcg128xsl64_true_values() {
let mut rng = Lcg128Xsl64::new(42, 54);
let mut results = [0u64; 6];
for i in results.iter_mut() {
*i = rng.next_u64();
}
let expected: [u64; 6] = [
0x86b1da1d72062b68,
0x1304aa46c9853d39,
0xa3670e9e0dd50358,
0xf9090e529a7dae00,
0xc85b9fd837996f2c,
0x606121f8e3919196,
];
assert_eq!(results, expected);
} | rust_cleaned_test_functions.jsonl/94598 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 263
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
907,
27446,
16,
17,
23,
87,
3226,
21,
19,
16082,
9146,
368,
341,
1066,
262,
1077,
5206,
28422,
284,
444,
27446,
16,
17,
23,
55,
3226,
21,
19,
486,
931,
7,
19,
17,
11,
220,
20,
19,
626,
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... | 2 |
#[test]
fn test_dispatch_stack_zero_copy_bufs() {
let (mut runtime, dispatch_count) = setup(Mode::AsyncZeroCopy(2));
runtime
.execute(
"filename.js",
r#"
let zero_copy_a = new Uint8Array([0]);
let zero_copy_b = new Uint8Array([1]);
Deno.core.send(1, zero_copy_a, zero_copy_b);
"#,
)
.unwrap();
assert_eq!(dispatch_count.load(Ordering::Relaxed), 1);
} | rust_cleaned_test_functions.jsonl/4853 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 219
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
42991,
15528,
19359,
16096,
10363,
82,
368,
341,
262,
1077,
320,
6984,
15592,
11,
6845,
3180,
8,
284,
6505,
3189,
534,
486,
6525,
17999,
12106,
7,
17,
1106,
262,
15592,
198,
414,
659,
10257,
100... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_glyph_lookup_format_4() {
use font::EncodingFormat4;
let encoding4 = EncodingFormat4(KOSUGI_MARU_ENCODING_4);
for kanji in KANJI.chars() {
assert!(encoding4.lookup_glyph_id(kanji as u16).is_some());
}
assert!(encoding4.lookup_glyph_id('\n' as u16).is_none());
} | rust_cleaned_test_functions.jsonl/32199 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 178
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
88703,
27464,
8955,
62,
19,
368,
341,
286,
990,
3301,
486,
14690,
4061,
19,
280,
286,
1077,
11170,
19,
284,
29330,
4061,
19,
16738,
3126,
2941,
40,
1245,
934,
52,
73029,
62,
19,
317,
286,
369,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_lz4_compress_decompress_4095_bytes() {
let buf = vec![0x2u8; 4095];
let compressed = lz4_compress(&buf).unwrap();
let mut decompressed = vec![0; buf.len()];
let sz = decompress(
&compressed,
None,
decompressed.as_mut_slice(),
Algorithm::LZ4Block,
)
.unwrap();
assert_eq!(sz, 4095);
assert_eq!(buf, decompressed);
} | rust_cleaned_test_functions.jsonl/106794 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 249
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
907,
89,
19,
87845,
2259,
38360,
62,
19,
15,
24,
20,
12524,
368,
341,
286,
1077,
6607,
284,
7486,
20703,
15,
87,
17,
84,
23,
26,
220,
19,
15,
24,
20,
935,
286,
1077,
30649,
284,
95982,
19,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_write_transaction_log() {
let mut db =
PickleDb::new_yaml(NamedTempFile::new().unwrap(), PickleDbDumpPolicy::NeverDump);
let signature = Signature::default();
let transaction_info = TransactionInfo::default();
db.set(&signature.to_string(), &transaction_info).unwrap();
let csv_file = NamedTempFile::new().unwrap();
write_transaction_log(&db, &csv_file).unwrap();
let mut rdr = ReaderBuilder::new().trim(Trim::All).from_reader(csv_file);
let signed_infos: Vec<SignedTransactionInfo> =
rdr.deserialize().map(|entry| entry.unwrap()).collect();
let signed_info = SignedTransactionInfo {
recipient: Pubkey::default().to_string(),
signature: Signature::default().to_string(),
..SignedTransactionInfo::default()
};
assert_eq!(signed_infos, vec![signed_info]);
} | rust_cleaned_test_functions.jsonl/73560 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 394
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9165,
28884,
5224,
368,
341,
286,
1077,
5206,
2927,
4035,
310,
19725,
89506,
486,
931,
64380,
8204,
3606,
12151,
1703,
486,
931,
1005,
15454,
1507,
19725,
89506,
51056,
13825,
486,
26155,
51056,
317... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_perfect_matching() {
let haystack = "111 a 111b";
let needle = "111 a 111b";
search_test!(haystack, needle, Some(0));
} | rust_cleaned_test_functions.jsonl/19386 | {
"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,
5678,
3751,
70763,
368,
341,
286,
1077,
88447,
284,
330,
16,
16,
16,
264,
220,
16,
16,
16,
65,
876,
286,
1077,
30309,
284,
330,
16,
16,
16,
264,
220,
16,
16,
16,
65,
876,
286,
2711,
4452,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_c_callback() {
fn callback(s: String) -> usize {
if s == "2020" {
cxx_test_suite_set_correct();
}
0
}
#[allow(clippy::ptr_arg)]
fn callback_ref(s: &String) {
if s == "2020" {
cxx_test_suite_set_correct();
}
}
fn callback_mut(s: &mut String) {
if s == "2020" {
cxx_test_suite_set_correct();
}
}
check!(ffi::c_take_callback(callback));
check!(ffi::c_take_callback_ref(callback_ref));
check!(ffi::c_take_callback_ref_lifetime(callback_ref));
check!(ffi::c_take_callback_mut(callback_mut));
} | rust_cleaned_test_functions.jsonl/50898 | {
"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,
666,
12519,
368,
341,
262,
5168,
4822,
1141,
25,
923,
8,
1464,
22301,
341,
286,
421,
274,
621,
330,
17,
15,
17,
15,
1,
341,
310,
272,
4146,
4452,
57239,
2602,
31550,
543,
286,
456,
286,
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_optional_lockup_for_stake_program_v4() {
let stake_pubkey = paychains_sdk::pubkey::new_rand();
let stake_lamports = 42;
let stake_account = AccountSharedData::new_ref_data_with_space(
stake_lamports,
&StakeState::Uninitialized,
std::mem::size_of::<StakeState>(),
&id(),
)
.expect("stake_account");
let stake_keyed_account = KeyedAccount::new(&stake_pubkey, false, &stake_account);
let custodian = paychains_sdk::pubkey::new_rand();
stake_keyed_account
.initialize(
&Authorized::auto(&stake_pubkey),
&Lockup {
unix_timestamp: 1,
epoch: 1,
custodian,
},
&Rent::free(),
)
.unwrap();
// Lockup in force: authorized withdrawer cannot change it
assert_eq!(
stake_keyed_account.set_lockup(
&LockupArgs {
unix_timestamp: Some(2),
epoch: None,
custodian: None
},
&vec![stake_pubkey].into_iter().collect(),
Some(&Clock::default())
),
Err(InstructionError::MissingRequiredSignature)
);
// Lockup in force: custodian can change it
assert_eq!(
stake_keyed_account.set_lockup(
&LockupArgs {
unix_timestamp: Some(2),
epoch: None,
custodian: None
},
&vec![custodian].into_iter().collect(),
Some(&Clock::default())
),
Ok(())
);
// Lockup expired: custodian cannot change it
assert_eq!(
stake_keyed_account.set_lockup(
&LockupArgs::default(),
&vec![custodian].into_iter().collect(),
Some(&Clock {
unix_timestamp: UnixTimestamp::MAX,
epoch: Epoch::MAX,
..Clock::default()
})
),
Err(InstructionError::MissingRequiredSignature)
);
// Lockup expired: authorized withdrawer can change it
assert_eq!(
stake_keyed_account.set_lockup(
&LockupArgs::default(),
&vec![stake_pubkey].into_iter().collect(),
Some(&Clock {
unix_timestamp: UnixTimestamp::MAX,
epoch: Epoch::MAX,
..Clock::default()
})
),
Ok(())
);
// Change authorized withdrawer
let new_withdraw_authority = paychains_sdk::pubkey::new_rand();
assert_eq!(
stake_keyed_account.authorize(
&vec![stake_pubkey].into_iter().collect(),
&new_withdraw_authority,
StakeAuthorize::Withdrawer,
false,
&Clock::default(),
None
),
Ok(())
);
// Previous authorized withdrawer cannot change the lockup anymore
assert_eq!(
stake_keyed_account.set_lockup(
&LockupArgs::default(),
&vec![stake_pubkey].into_iter().collect(),
Some(&Clock {
unix_timestamp: UnixTimestamp::MAX,
epoch: Epoch::MAX,
..Clock::default()
})
),
Err(InstructionError::MissingRequiredSignature)
);
} | rust_cleaned_test_functions.jsonl/51773 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2100
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
74644,
9818,
454,
5478,
1261,
726,
25096,
2273,
19,
368,
341,
286,
1077,
18279,
34014,
792,
284,
2291,
58358,
61783,
486,
9585,
792,
486,
931,
33864,
543,
286,
1077,
18279,
907,
309,
3394,
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_datetime_add() {
fn check(
(y, m, d, h, n, s): (i32, u32, u32, u32, u32, u32),
rhs: Duration,
result: Option<(i32, u32, u32, u32, u32, u32)>,
) {
let lhs = NaiveDate::from_ymd(y, m, d).and_hms(h, n, s);
let sum =
result.map(|(y, m, d, h, n, s)| NaiveDate::from_ymd(y, m, d).and_hms(h, n, s));
assert_eq!(lhs.checked_add_signed(rhs), sum);
assert_eq!(lhs.checked_sub_signed(-rhs), sum);
}
check(
(2014, 5, 6, 7, 8, 9),
Duration::seconds(3600 + 60 + 1),
Some((2014, 5, 6, 8, 9, 10)),
);
check(
(2014, 5, 6, 7, 8, 9),
Duration::seconds(-(3600 + 60 + 1)),
Some((2014, 5, 6, 6, 7, 8)),
);
check((2014, 5, 6, 7, 8, 9), Duration::seconds(86399), Some((2014, 5, 7, 7, 8, 8)));
check((2014, 5, 6, 7, 8, 9), Duration::seconds(86_400 * 10), Some((2014, 5, 16, 7, 8, 9)));
check((2014, 5, 6, 7, 8, 9), Duration::seconds(-86_400 * 10), Some((2014, 4, 26, 7, 8, 9)));
check((2014, 5, 6, 7, 8, 9), Duration::seconds(86_400 * 10), Some((2014, 5, 16, 7, 8, 9)));
// overflow check
// assumes that we have correct values for MAX/MIN_DAYS_FROM_YEAR_0 from `naive::date`.
let max_days_from_year_0 = MAX_DATE.signed_duration_since(NaiveDate::from_ymd(0, 1, 1));
check((0, 1, 1, 0, 0, 0), max_days_from_year_0, Some((MAX_DATE.year(), 12, 31, 0, 0, 0)));
check(
(0, 1, 1, 0, 0, 0),
max_days_from_year_0 + Duration::seconds(86399),
Some((MAX_DATE.year(), 12, 31, 23, 59, 59)),
);
check((0, 1, 1, 0, 0, 0), max_days_from_year_0 + Duration::seconds(86_400), None);
check((0, 1, 1, 0, 0, 0), Duration::max_value(), None);
let min_days_from_year_0 = MIN_DATE.signed_duration_since(NaiveDate::from_ymd(0, 1, 1));
check((0, 1, 1, 0, 0, 0), min_days_from_year_0, Some((MIN_DATE.year(), 1, 1, 0, 0, 0)));
check((0, 1, 1, 0, 0, 0), min_days_from_year_0 - Duration::seconds(1), None);
check((0, 1, 1, 0, 0, 0), Duration::min_value(), None);
} | rust_cleaned_test_functions.jsonl/76820 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1200
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28943,
2891,
368,
341,
286,
5168,
1779,
1006,
310,
320,
88,
11,
296,
11,
294,
11,
305,
11,
308,
11,
274,
1648,
320,
72,
18,
17,
11,
575,
18,
17,
11,
575,
18,
17,
11,
575,
18,
17,
11,
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_push_back() {
let mut fixed = test_new::<[Foo; 4]>();
#[derive(Debug, Default, PartialEq, Eq)]
struct Foo {
data: u64,
}
fixed.push_back().data = 1;
fixed.push_back().data = 2;
assert_eq!(Some(&mut Foo { data: 1 }), fixed.pop_front());
assert_eq!(Some(&mut Foo { data: 2 }), fixed.pop_front());
assert_eq!(None, fixed.pop_front());
} | rust_cleaned_test_functions.jsonl/3284 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 225
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14218,
3895,
368,
341,
286,
1077,
5206,
8356,
284,
1273,
5921,
27638,
58,
40923,
26,
220,
19,
60,
10448,
286,
11506,
27098,
42618,
11,
7899,
11,
55039,
11,
33122,
5563,
286,
2036,
33428,
341,
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_generate_multicast_dnsname() -> Result<()> {
let name = generate_multicast_dns_name();
let re = Regex::new(
r"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}.local+$",
);
if let Ok(re) = re {
assert!(
re.is_match(&name),
"mDNS name must be UUID v4 + \".local\" suffix, got {}",
name
);
} else {
panic!("expected ok, but got err");
}
Ok(())
} | rust_cleaned_test_functions.jsonl/79763 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 295
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
48851,
26290,
35446,
71125,
606,
368,
1464,
5714,
71698,
341,
262,
1077,
829,
284,
6923,
26290,
35446,
71125,
1269,
1428,
262,
1077,
312,
284,
26146,
486,
931,
1006,
286,
435,
1,
27736,
15,
12,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_snapshot_clean_up_logs_with_log_gc() {
let mut cluster = new_node_cluster(0, 4);
cluster.cfg.raft_store.raft_log_gc_count_limit = 50;
cluster.cfg.raft_store.raft_log_gc_threshold = 50;
// Speed up log gc.
cluster.cfg.raft_store.raft_log_compact_sync_interval = ReadableDuration::millis(1);
let pd_client = cluster.pd_client.clone();
// Disable default max peer number check.
pd_client.disable_default_operator();
let r = cluster.run_conf_change();
pd_client.must_add_peer(r, new_peer(2, 2));
pd_client.must_add_peer(r, new_peer(3, 3));
cluster.add_send_filter(IsolationFilterFactory::new(2));
pd_client.must_add_peer(r, new_peer(4, 4));
pd_client.must_remove_peer(r, new_peer(3, 3));
cluster.must_transfer_leader(r, new_peer(4, 4));
cluster.must_put(b"k1", b"v1");
must_get_equal(&cluster.get_engine(4), b"k1", b"v1");
cluster.clear_send_filters();
cluster.add_send_filter(IsolationFilterFactory::new(1));
must_get_equal(&cluster.get_engine(2), b"k1", b"v1");
let raft_engine = cluster.engines[&2].raft.clone();
let mut dest = vec![];
raft_engine.get_all_entries_to(1, &mut dest).unwrap();
assert!(dest.is_empty(), "{:?}", dest);
} | rust_cleaned_test_functions.jsonl/94648 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 547
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
53265,
19573,
8237,
42899,
6615,
5224,
49423,
368,
341,
262,
1077,
5206,
10652,
284,
501,
5084,
28441,
7,
15,
11,
220,
19,
317,
262,
10652,
30481,
13,
2944,
14809,
13,
2944,
5224,
49423,
3180,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_packet_roundtrip_0009() {
packet_roundtrip(
"0009",
vec![
(37, 3960), // non canoncial length encoding
(39, 3960), // non canoncial length encoding
(258, 75), // non canoncial length encoding
(260, 78), // non canoncial length encoding
(1053, 3181), // non canoncial length encoding
(1473, 5196), // non canoncial length encoding
(1895, 4243), // non canoncial length encoding
],
)
} | rust_cleaned_test_functions.jsonl/54780 | {
"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,
21078,
29896,
32981,
62,
15,
15,
15,
24,
368,
341,
286,
10151,
29896,
32981,
1006,
310,
330,
15,
15,
15,
24,
756,
310,
7486,
90515,
394,
320,
18,
22,
11,
220,
18,
24,
21,
15,
701,
256,
442... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_count() {
let infile = String::from("tests/test.fa");
let outfile = String::from("tests/polya.txt");
let t = String::from("10");
let k = String::from("10");
let a = String::from("8");
scan_polya_reads(&infile, &outfile, &t, &k, &a).expect("Failed");
} | rust_cleaned_test_functions.jsonl/80667 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 155
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3180,
368,
341,
286,
1077,
48989,
284,
923,
486,
1499,
445,
23841,
12697,
63114,
797,
286,
1077,
33178,
284,
923,
486,
1499,
445,
23841,
4322,
5730,
64,
3909,
3071,
286,
1077,
259,
284,
923,
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_push() {
let mut buffer = CircleBuffer::with_capacity(3);
buffer.push(1);
assert_eq!(&[1], buffer.as_slice());
buffer.push(2);
assert_eq!(&[1, 2], buffer.as_slice());
buffer.push(3);
assert_eq!(&[1, 2, 3], buffer.as_slice());
buffer.push(4);
assert_eq!(&[2, 3, 4], buffer.as_slice());
buffer.push(5);
assert_eq!(&[3, 4, 5], buffer.as_slice());
buffer.push(6);
assert_eq!(&[4, 5, 6], buffer.as_slice());
buffer.push(7);
assert_eq!(&[5, 6, 7], buffer.as_slice());
buffer.push(8);
assert_eq!(&[6, 7, 8], buffer.as_slice());
buffer.push(9);
assert_eq!(&[7, 8, 9], buffer.as_slice());
buffer.push(10);
assert_eq!(&[8, 9, 10], buffer.as_slice());
buffer.push(11);
assert_eq!(&[9, 10, 11], buffer.as_slice());
buffer.push(12);
assert_eq!(&[10, 11, 12], buffer.as_slice());
buffer.push(13);
assert_eq!(&[11, 12, 13], buffer.as_slice());
buffer.push(14);
assert_eq!(&[12, 13, 14], buffer.as_slice());
buffer.push(15);
assert_eq!(&[13, 14, 15], buffer.as_slice());
buffer.push(16);
assert_eq!(&[14, 15, 16], buffer.as_slice());
buffer.push(17);
assert_eq!(&[15, 16, 17], buffer.as_slice());
} | rust_cleaned_test_functions.jsonl/50999 | {
"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,
14218,
368,
341,
286,
1077,
5206,
4147,
284,
21224,
4095,
486,
4197,
35603,
7,
18,
317,
286,
4147,
2552,
7,
16,
317,
286,
2060,
10714,
0,
2099,
58,
16,
1125,
4147,
5357,
26488,
1423,
286,
4147... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_uint_uint_multiply() {
let should_pass = vec![
(7, 11, Some(77)),
(1, 2, Some(2)),
(std::u64::MAX as i64, 1, Some(std::u64::MAX as i64)),
];
for (lhs, rhs, expected) in should_pass {
assert_eq!(
expected,
RpnFnScalarEvaluator::new()
.push_param_with_field_type(
lhs,
FieldTypeBuilder::new()
.tp(FieldTypeTp::LongLong)
.flag(FieldTypeFlag::UNSIGNED)
)
.push_param_with_field_type(
rhs,
FieldTypeBuilder::new()
.tp(FieldTypeTp::LongLong)
.flag(FieldTypeFlag::UNSIGNED)
)
.evaluate(ScalarFuncSig::MultiplyIntUnsigned)
.unwrap()
);
}
let should_fail = vec![(std::u64::MAX as i64, 2)];
for (lhs, rhs) in should_fail {
assert!(
RpnFnScalarEvaluator::new()
.push_param_with_field_type(
lhs,
FieldTypeBuilder::new()
.tp(FieldTypeTp::LongLong)
.flag(FieldTypeFlag::UNSIGNED)
)
.push_param_with_field_type(
rhs,
FieldTypeBuilder::new()
.tp(FieldTypeTp::LongLong)
.flag(FieldTypeFlag::UNSIGNED)
)
.evaluate::<Int>(ScalarFuncSig::MultiplyIntUnsigned)
.is_err(),
"{} * {} should fail",
lhs,
rhs
);
}
} | rust_cleaned_test_functions.jsonl/5298 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1296
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15807,
15807,
93054,
368,
341,
286,
1077,
1265,
15464,
284,
7486,
90515,
310,
320,
22,
11,
220,
16,
16,
11,
4329,
7,
22,
22,
6965,
310,
320,
16,
11,
220,
17,
11,
4329,
7,
17,
6965,
310,
32... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_signed_public_key_binary_representation() {
let mut seed_and_lms_tree_identifier = SeedAndLmsTreeIdentifier::default();
OsRng.fill_bytes(&mut seed_and_lms_tree_identifier.seed);
let mut keypair = lms::generate_key_pair::<Sha256>(
&seed_and_lms_tree_identifier,
&HssParameter::construct_default_parameters(),
&0,
&mut None,
);
let message = [3, 54, 32, 45, 67, 32, 12, 58, 29, 49];
let mut signature_randomizer = ArrayVec::from([0u8; 32]);
OsRng.fill_bytes(&mut signature_randomizer);
let signature = LmsSignature::sign(
&mut keypair.private_key,
&message,
&signature_randomizer,
&mut None,
)
.expect("Signing should work");
let signed_public_key = HssSignedPublicKey {
public_key: keypair.public_key,
sig: signature,
};
let binary_representation = signed_public_key.to_binary_representation();
let deserialized = InMemoryHssSignedPublicKey::new(binary_representation.as_slice())
.expect("Deserialization should work.");
assert!(deserialized == signed_public_key);
} | rust_cleaned_test_functions.jsonl/39477 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 581
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
55617,
27074,
3097,
31761,
94263,
368,
341,
286,
1077,
5206,
10320,
8378,
907,
1011,
11663,
33176,
284,
35822,
3036,
43,
1011,
6533,
8714,
486,
2258,
543,
286,
15433,
49,
968,
12467,
12524,
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_recommendation_api() {
let collection_dir = TempDir::new("collection").unwrap();
let (_rt, collection) = simple_collection_fixture(collection_dir.path());
let insert_points = CollectionUpdateOperations::PointOperation(
PointOperations::UpsertPoints(BatchPoints {
ids: vec![0, 1, 2, 3, 4, 5, 6, 7, 8],
vectors: vec![
vec![0.0, 0.0, 1.0, 1.0],
vec![1.0, 0.0, 0.0, 0.0],
vec![1.0, 0.0, 0.0, 0.0],
vec![0.0, 1.0, 0.0, 0.0],
vec![0.0, 1.0, 0.0, 0.0],
vec![0.0, 0.0, 1.0, 0.0],
vec![0.0, 0.0, 1.0, 0.0],
vec![0.0, 0.0, 0.0, 1.0],
vec![0.0, 0.0, 0.0, 1.0],
],
payloads: None,
})
);
collection.update(insert_points, true).unwrap();
let result = collection.recommend(Arc::new(RecommendRequest {
positive: vec![0],
negative: vec![8],
filter: None,
params: None,
top: 5
})).unwrap();
assert!(result.len() > 0);
let top1 = result[0];
assert!(top1.id == 5 || top1.id == 6);
} | rust_cleaned_test_functions.jsonl/127876 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 673
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
99084,
367,
11697,
368,
341,
262,
1077,
4426,
4334,
284,
19944,
6184,
486,
931,
445,
13421,
1827,
15454,
543,
262,
1077,
5453,
3342,
11,
4426,
8,
284,
4285,
25019,
74409,
35866,
4334,
3875,
5231,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_invalid_parent() {
let mut chain = Chain::new();
// Transactions
let (t0, _) = Transaction::debug_make_register(format!("SN1337BIKE"));
let (t1, _) = Transaction::debug_make_register(format!("MYCOOLBIKE"));
// Blocks
let block_0 = Block::new(chain.get_genesis_block().calc_hash(), t0);
let block_1 = Block::new(hash::EMPTY_HASH, t1);
chain.push(block_0, true).expect("Chain::push failure (0)");
chain.push(block_1, true).expect("Chain::push failure (1)");
} | rust_cleaned_test_functions.jsonl/102219 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 249
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31433,
15960,
368,
341,
286,
1077,
5206,
8781,
284,
28525,
486,
931,
1428,
286,
442,
55285,
198,
286,
1077,
320,
83,
15,
11,
27439,
284,
17869,
486,
8349,
28230,
14000,
20698,
17223,
18966,
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_rotate_bicubic_rgba() {
fn rotate_bicubic_about_center(image: &RgbaImage) -> RgbaImage {
rotate_about_center(
image,
std::f32::consts::PI / 4f32,
Interpolation::Bicubic,
Rgba::black(),
)
}
compare_to_truth_with_tolerance(
"elephant_rgba.png",
"elephant_rotate_bicubic_rgba.png",
rotate_bicubic_about_center,
2,
);
} | rust_cleaned_test_functions.jsonl/81465 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 256
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
60834,
880,
292,
41181,
95229,
368,
341,
262,
5168,
16919,
880,
292,
41181,
57975,
21087,
10075,
25,
609,
49,
56380,
1906,
8,
1464,
431,
56380,
1906,
341,
286,
16919,
57975,
21087,
1006,
310,
2168... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_config_get_options() {
let query = String::from("query");
let file = File::open("./test-data/test.txt").unwrap();
let config = Config {
options: Some(Options::new(true, false)),
query: query,
file: file,
};
let options_struct = Options::new(true, false);
assert_eq!(config.get_options().is_some(), true);
assert_eq!(config.get_options().unwrap(), &options_struct);
} | rust_cleaned_test_functions.jsonl/63339 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 222
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5332,
3062,
8743,
368,
341,
286,
1077,
3239,
284,
923,
486,
1499,
445,
1631,
797,
286,
1077,
1034,
284,
2887,
486,
2508,
13988,
1944,
13945,
12697,
3909,
1827,
15454,
543,
286,
1077,
2193,
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_parse_object() {
test_parse_err::<BTreeMap<String, u32>>(&[
("{", "EOF while parsing an object at line 1 column 1"),
("{ ", "EOF while parsing an object at line 1 column 2"),
("{1", "key must be a string at line 1 column 2"),
("{ \"a\"", "EOF while parsing an object at line 1 column 5"),
("{\"a\"", "EOF while parsing an object at line 1 column 4"),
("{\"a\" ", "EOF while parsing an object at line 1 column 5"),
("{\"a\" 1", "expected `:` at line 1 column 6"),
("{\"a\":", "EOF while parsing a value at line 1 column 5"),
("{\"a\":1", "EOF while parsing an object at line 1 column 6"),
("{\"a\":1 1", "expected `,` or `}` at line 1 column 8"),
("{\"a\":1,", "EOF while parsing a value at line 1 column 7"),
("{}a", "trailing characters at line 1 column 3"),
]);
test_parse_ok(vec![
("{}", treemap!()),
("{ }", treemap!()),
("{\"a\":3}", treemap!("a".to_string() => 3u64)),
("{ \"a\" : 3 }", treemap!("a".to_string() => 3)),
(
"{\"a\":3,\"b\":4}",
treemap!("a".to_string() => 3, "b".to_string() => 4),
),
(
" { \"a\" : 3 , \"b\" : 4 } ",
treemap!("a".to_string() => 3, "b".to_string() => 4),
),
]);
test_parse_ok(vec![(
"{\"a\": {\"b\": 3, \"c\": 4}}",
treemap!(
"a".to_string() => treemap!(
"b".to_string() => 3u64,
"c".to_string() => 4
)
),
)]);
test_parse_ok(vec![("{\"c\":null}", treemap!('c' => ()))]);
} | rust_cleaned_test_functions.jsonl/29840 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 832
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
5314,
368,
341,
262,
1273,
21039,
9266,
27638,
33,
6533,
2227,
3464,
11,
575,
18,
17,
2452,
2099,
9640,
286,
3489,
90,
497,
330,
23483,
1393,
22314,
458,
1633,
518,
1555,
220,
16,
3250,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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() {
let mut s = InlinableString::new();
for _ in 0..INLINE_STRING_CAPACITY {
s.push('a');
}
s.push('a');
assert_eq!(
s,
String::from_iter((0..INLINE_STRING_CAPACITY + 1).map(|_| 'a'))
);
} | rust_cleaned_test_functions.jsonl/109708 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 182
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14218,
368,
341,
286,
1077,
5206,
274,
284,
758,
3732,
480,
703,
486,
931,
1428,
286,
369,
716,
304,
220,
15,
496,
55737,
12283,
92153,
341,
310,
274,
2552,
492,
64,
1157,
286,
456,
286,
274,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_pass_increase_allowance() {
ExtBuilder::build().execute_with(|| {
let bob = account_key("Bob"); // owner address
let risa = account_key("Risa"); // spender address
approve(bob, risa, 100);
assert_ok!(CelerPayModule::increase_allowance(
Origin::signed(bob),
risa,
50
));
})
} | rust_cleaned_test_functions.jsonl/81776 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 233
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15464,
73807,
55731,
681,
368,
341,
286,
9447,
3297,
486,
5834,
1005,
10257,
6615,
79453,
314,
5872,
310,
1077,
35192,
284,
2692,
3097,
445,
32388,
5038,
442,
6372,
2621,
198,
310,
1077,
9824,
64,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_sql_value_example() {
let v_integer = SqlValue::NotNull(NnSqlValue::Integer(42));
let v_smallint = SqlValue::NotNull(NnSqlValue::SmallInt(42));
let v_bigint = SqlValue::NotNull(NnSqlValue::BigInt(42));
let v_null = SqlValue::Null;
assert_eq!(v_integer, v_integer);
assert_eq!(
v_smallint, v_bigint,
"Comparing SmallInt with BigInt is valid"
);
assert_ne!(v_null, v_null, "NULL != NULL");
let mut hash_set = HashSet::<SqlValueHashKey>::new();
assert!(hash_set.insert(SqlValueHashKey::from(&v_integer)));
assert!(
!hash_set.insert(SqlValueHashKey::from(&v_integer)),
"same value is already inserted"
);
assert!(
!hash_set.insert(SqlValueHashKey::from(&v_smallint)),
"same hash values are generated from both SmallInt and Integer"
);
assert!(hash_set.insert(SqlValueHashKey::from(&v_null)),);
assert!(
hash_set.insert(SqlValueHashKey::from(&v_null)),
"two NULL values are different"
);
assert_ne!(
SqlValueHashKey::from(&v_null),
SqlValueHashKey::from(&v_null),
"two NULL values generates different Hash value"
);
} | rust_cleaned_test_functions.jsonl/40001 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 647
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18063,
3142,
39304,
368,
341,
286,
1077,
348,
31725,
284,
7224,
1130,
486,
11005,
8204,
77,
8269,
1130,
486,
3486,
7,
19,
17,
1106,
286,
1077,
348,
31966,
396,
284,
7224,
1130,
486,
11005,
8204,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_multiline_basic_strings() {
let env_var_name = "env_var_value_multiline";
env::set_var(env_var_name, "Roses");
let parsed_data =
common::get_file_content_parsed(PARENT_FOLDER, "multiline_basic.ura").unwrap();
env::remove_var(env_var_name);
assert_eq!(parsed_data, get_expected_multiline_basic());
} | rust_cleaned_test_functions.jsonl/11161 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 156
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26290,
26560,
34729,
33500,
368,
341,
262,
1077,
6105,
4612,
1269,
284,
330,
3160,
4612,
3142,
26290,
26560,
876,
262,
6105,
486,
746,
4612,
16978,
4612,
1269,
11,
330,
49,
19696,
797,
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_relu() {
let x: Array2<f64> = array![[-5., 8., -6., 0.], [2., 0., -1., 105.]];
assert_eq!(
array![[0., 8., 0., 0.], [2., 0., 0., 105.]],
maths::activations::relu(x.clone(), false)
);
assert_eq!(
array![[0., 1., 0., 1.], [1., 1., 0., 1.]],
maths::activations::relu(x, true)
);
} | rust_cleaned_test_functions.jsonl/106054 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 189
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
76282,
368,
341,
262,
1077,
856,
25,
2910,
17,
63895,
21,
19,
29,
284,
1334,
20703,
7609,
20,
2572,
220,
23,
2572,
481,
21,
2572,
220,
15,
13,
1125,
508,
17,
2572,
220,
15,
2572,
481,
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_basic() {
let server = httptest::Server::run();
server.expect(
Expectation::matching(request::method_path("GET", "/todos/1"))
.respond_with(json_encoded(json!({
"title": "get another cat"
}))));
let mut rt = Runtime::new().unwrap();
let client = init_client();
let cfg = ServerCfg{
cats_url: server.url_str("/"),
todo_url: server.url_str("/"),
};
// start server
rt.spawn(_run_server(cfg));
// wait for server to come up
std::thread::sleep(std::time::Duration::from_millis(50));
// make requests
let req_fut = client.request(
Request::builder()
.method(Method::GET)
.uri("http://localhost:3000/basic")
.body(Body::empty())
.unwrap(),
);
let res = rt.block_on(req_fut).unwrap();
let body = rt.block_on(to_bytes(res.into_body())).unwrap();
assert_eq!(std::str::from_utf8(&body).unwrap(), "get another cat");
} | rust_cleaned_test_functions.jsonl/35909 | {
"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,
34729,
368,
341,
286,
1077,
3538,
284,
54320,
70334,
486,
5475,
486,
6108,
543,
286,
3538,
25952,
1006,
310,
32085,
367,
486,
89043,
4875,
486,
4393,
2638,
445,
3806,
497,
3521,
49188,
14,
16,
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_part2_ex3() {
let actual = part2(&parse("880086C3E88112"));
assert_eq!(actual, 7);
} | rust_cleaned_test_functions.jsonl/21393 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 69
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10495,
17,
2702,
18,
368,
341,
286,
1077,
5042,
284,
949,
17,
2099,
6400,
445,
23,
23,
15,
15,
23,
21,
34,
18,
36,
23,
23,
16,
16,
17,
4010,
286,
2060,
10714,
10297,
11944,
11,
220,
22,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_gstring_from_str() {
let gstring: GString = "foo".into();
assert_eq!(gstring.as_str(), "foo");
let foo: Box<str> = gstring.into();
assert_eq!(foo.as_ref(), "foo");
} | rust_cleaned_test_functions.jsonl/58208 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 113
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1889,
917,
5673,
2895,
368,
341,
286,
1077,
342,
917,
25,
479,
703,
284,
330,
7975,
3263,
18122,
543,
286,
2060,
10714,
10297,
70,
917,
5357,
2895,
1507,
330,
7975,
797,
286,
1077,
15229,
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_definition() {
let wgs84 = "+proj=longlat +datum=WGS84 +no_defs";
let proj = Proj::new(wgs84).unwrap();
assert_eq!(
proj.def().unwrap(),
"proj=longlat datum=WGS84 no_defs ellps=WGS84 towgs84=0,0,0"
);
} | rust_cleaned_test_functions.jsonl/104005 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 164
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31698,
368,
341,
286,
1077,
289,
5857,
23,
19,
284,
6630,
30386,
28,
4825,
5524,
488,
55933,
69547,
16522,
23,
19,
488,
2152,
56535,
876,
286,
1077,
21333,
284,
42952,
486,
931,
3622,
5857,
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_create_show_table_instance() {
let instance = Instance {
id: "foo".to_string(),
main_dicom_tags: hashmap! {
"SOPInstanceUID".to_string() => "suid_1".to_string(),
"InstanceNumber".to_string() => "in_1".to_string(),
},
parent_series: "foo_series".to_string(),
index_in_series: Some(13),
file_uuid: "file_uuid".to_string(),
file_size: 139402,
modified_from: None,
entity: EntityKind::Instance,
anonymized_from: None,
};
assert_eq!(
format_table(create_show_table(instance, &INSTANCE_DICOM_TAGS)),
include_str!("../tests/data/unit/show_instance").trim_end()
);
} | rust_cleaned_test_functions.jsonl/76489 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 419
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8657,
15267,
5237,
11904,
368,
341,
286,
1077,
2867,
284,
19283,
341,
310,
877,
25,
330,
7975,
3263,
983,
3904,
3148,
310,
1887,
39154,
316,
16333,
25,
92148,
0,
341,
394,
330,
50,
3067,
2523,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_var_lifting_integration() {
test("if(true);else var a;", "");
test("if(false) foo();else var a;", "");
test("if(true)var a;else;", "");
test("if(false)var a;else;", "");
test("if(false)var a,b;", "");
test("if(false){var a;var a;}", "");
test("if(false)var a=function(){var b};", "");
test("if(a)if(false)var a;else var b;", "if(a) var a;");
} | rust_cleaned_test_functions.jsonl/114462 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 195
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4612,
907,
17680,
90250,
368,
341,
262,
1273,
445,
333,
3715,
1215,
1503,
762,
264,
32503,
14498,
262,
1273,
445,
333,
3576,
8,
15229,
2129,
1503,
762,
264,
32503,
14498,
262,
1273,
445,
333,
37... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_burn_it() {
// Set up environment.
let mut ledger = InMemoryLedger::with_bootstrap();
let mut executor = TransactionExecutor::new(&mut ledger, 0, 0);
let key = executor.new_public_key();
let account = executor.new_account(key);
let package = executor.publish_package(include_code!());
// Test the `new` function.
let transaction = TransactionBuilder::new(&executor)
.call_function(package, "FixBurn", "new", vec![], None)
.drop_all_bucket_refs()
.deposit_all_buckets(account) // needed when returning a bucket
.build(vec![key])
.unwrap();
let receipt = executor.run(transaction, true).unwrap();
println!("{:?}\n", receipt);
assert!(receipt.success);
// Test the `burn_it` method.
let component_addr = receipt.component(0).unwrap();
let auth_addr = receipt.resource_def(1).unwrap();
let flam_addr = receipt.resource_def(2).unwrap();
let inflam_addr = receipt.resource_def(3).unwrap();
let transaction = TransactionBuilder::new(&executor)
.call_method(
component_addr,
"burn_it",
vec![format!("100,{}", flam_addr), format!("1,{}", auth_addr)],
Some(account),
)
.drop_all_bucket_refs()
.deposit_all_buckets(account)
.build(vec![key])
.unwrap();
let receipt = executor.run(transaction, true).unwrap();
println!("{:?}\n", receipt);
assert!(receipt.success);
// Test the `burn_it` method < 5
let transaction = TransactionBuilder::new(&executor)
.call_method(
component_addr,
"burn_it",
vec![format!("3,{}", flam_addr), format!("1,{}", auth_addr)],
Some(account),
)
.drop_all_bucket_refs()
.deposit_all_buckets(account)
.build(vec![key])
.unwrap();
let receipt = executor.run(transaction, true).unwrap();
println!("{:?}\n", receipt);
assert!(receipt.success);
let transaction = TransactionBuilder::new(&executor)
.call_method(
component_addr,
"burn_it",
vec![
format!("10,{}", inflam_addr),
format!("1,{}", auth_addr),
],
Some(account),
)
.drop_all_bucket_refs()
.deposit_all_buckets(account)
.build(vec![key])
.unwrap();
let receipt = executor.run(transaction, true).unwrap();
println!("{:?}\n", receipt);
assert!(!receipt.success);
let transaction = TransactionBuilder::new(&executor)
.call_method(
component_addr,
"burn_it",
vec![
format!("3,{}", inflam_addr),
format!("1,{}", auth_addr),
],
Some(account),
)
.drop_all_bucket_refs()
.deposit_all_buckets(account)
.build(vec![key])
.unwrap();
let receipt = executor.run(transaction, true).unwrap();
println!("{:?}\n", receipt);
assert!(!receipt.success);
} | rust_cleaned_test_functions.jsonl/130704 | {
"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,
880,
399,
14631,
368,
341,
262,
442,
2573,
705,
4573,
624,
262,
1077,
5206,
46933,
284,
758,
10642,
60850,
1389,
486,
4197,
88424,
543,
262,
1077,
5206,
31558,
284,
17869,
25255,
486,
931,
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_to_rgb() {
assert_eq!((0, 0, 0), to_rgb(0.0, 0.0, 0.0));
assert_eq!((255, 255, 255), to_rgb(0.0, 0.0, 1.0));
assert_eq!((255, 0, 0), to_rgb(0.0, 1.0, 1.0));
assert_eq!((0, 255, 0), to_rgb(120.0, 1.0, 1.0));
assert_eq!((0, 0, 255), to_rgb(240.0, 1.0, 1.0));
} | rust_cleaned_test_functions.jsonl/119105 | {
"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,
2346,
37407,
368,
341,
286,
2060,
10714,
0,
1188,
15,
11,
220,
15,
11,
220,
15,
701,
311,
37407,
7,
15,
13,
15,
11,
220,
15,
13,
15,
11,
220,
15,
13,
15,
1106,
286,
2060,
10714,
0,
1188,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_FX65() {
// 0xFX65 - Fill registers V0 to VX inclusive with the values stored in memory starting at address I
let opcode = 0xF465;
let mut vm = get_vm();
vm.i = 0x0;
vm.memory[0x0] = 0x0;
vm.memory[0x1] = 0x1;
vm.memory[0x2] = 0x2;
vm.memory[0x3] = 0x3;
vm.memory[0x4] = 0x4;
vm.execute_instruction(decode_opcode(opcode), opcode);
assert_eq!(vm.v[0x0], 0x00);
assert_eq!(vm.v[0x1], 0x01);
assert_eq!(vm.v[0x2], 0x02);
assert_eq!(vm.v[0x3], 0x03);
assert_eq!(vm.v[0x4], 0x04);
assert_eq!(vm.i, 0x05);
} | rust_cleaned_test_functions.jsonl/272 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 315
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1400,
55,
21,
20,
368,
341,
262,
442,
220,
15,
9770,
55,
21,
20,
481,
21979,
24740,
647,
15,
311,
78177,
28308,
448,
279,
2750,
9768,
304,
4938,
5916,
518,
2621,
358,
271,
262,
1077,
30028,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_multiple_mapper() {
const FORMAT_STR: &str = "$a$b$c";
let formatter = StringFormatter::new(FORMAT_STR)
.unwrap()
.map(|var| match var {
"a" => Some(Ok("$a")),
"b" => Some(Ok("$b")),
_ => None,
})
.map(|var| match var {
"b" => Some(Ok("$B")),
"c" => Some(Ok("$c")),
_ => None,
});
let result = formatter.parse(None).unwrap();
let mut result_iter = result.iter();
match_next!(result_iter, "$a", None);
match_next!(result_iter, "$b", None);
match_next!(result_iter, "$c", None);
} | rust_cleaned_test_functions.jsonl/71886 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 413
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
45233,
76664,
368,
341,
286,
733,
52225,
7159,
25,
609,
495,
284,
5201,
64,
67284,
29835,
3302,
286,
1077,
24814,
284,
923,
14183,
486,
931,
7832,
98084,
7159,
340,
310,
659,
15454,
741,
310,
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... | 3 |
#[test]
fn test_logical_xor() {
let test_cases = vec![
(Some(1), Some(1), Some(0)),
(Some(1), Some(0), Some(1)),
(Some(0), Some(0), Some(0)),
(Some(2), Some(-1), Some(0)),
(Some(-1), Some(0), Some(1)),
(Some(0), None, None),
(None, Some(1), None),
];
for (arg0, arg1, expect_output) in test_cases {
let output = RpnFnScalarEvaluator::new()
.push_param(arg0)
.push_param(arg1)
.evaluate(ScalarFuncSig::LogicalXor)
.unwrap();
assert_eq!(output, expect_output);
}
} | rust_cleaned_test_functions.jsonl/29745 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 404
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
86484,
76462,
368,
341,
286,
1077,
1273,
41427,
284,
7486,
90515,
310,
320,
8373,
7,
16,
701,
4329,
7,
16,
701,
4329,
7,
15,
6965,
310,
320,
8373,
7,
16,
701,
4329,
7,
15,
701,
4329,
7,
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... | 2 |
#[test]
fn test_timestamp_diff_secs() {
let secs_a = 1;
let timestamp_diff = TimestampDiff::from_secs(secs_a);
let secs_b = timestamp_diff.as_secs();
assert_eq!(secs_a, secs_b);
} | rust_cleaned_test_functions.jsonl/32115 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 98
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
23073,
15850,
68718,
368,
341,
262,
1077,
49749,
4306,
284,
220,
16,
280,
262,
1077,
11441,
15850,
284,
32758,
21751,
486,
1499,
68718,
10478,
4837,
4306,
626,
262,
1077,
49749,
880,
284,
11441,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_query_and_then_fails() -> Result<()> {
let db = checked_memory_handle();
let sql = "BEGIN;
CREATE TABLE foo(x INTEGER, y TEXT);
INSERT INTO foo VALUES(4, 'hello');
INSERT INTO foo VALUES(3, ', ');
INSERT INTO foo VALUES(2, 'world');
INSERT INTO foo VALUES(1, '!');
END;";
db.execute_batch(sql)?;
let mut query = db.prepare("SELECT x, y FROM foo ORDER BY x DESC")?;
let bad_type: Result<Vec<f64>> = query.query_and_then([], |row| row.get(1))?.collect();
match bad_type.unwrap_err() {
Error::InvalidColumnType(..) => (),
err => panic!("Unexpected error {}", err),
}
let bad_idx: Result<Vec<String>> = query.query_and_then([], |row| row.get(3))?.collect();
match bad_idx.unwrap_err() {
Error::InvalidColumnIndex(_) => (),
err => panic!("Unexpected error {}", err),
}
Ok(())
} | rust_cleaned_test_functions.jsonl/113069 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 627
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5738,
8378,
68367,
761,
6209,
368,
1464,
5714,
71698,
341,
310,
1077,
2927,
284,
10067,
19195,
10630,
543,
310,
1077,
5704,
284,
330,
37588,
280,
5180,
30776,
14363,
15229,
2075,
30381,
11,
379,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_get_stream_latency() {
if let Some(device) = test_get_default_device(Scope::Input) {
let streams = get_device_streams(device, DeviceType::INPUT).unwrap();
for stream in streams {
let latency = get_stream_latency(stream, DeviceType::INPUT).unwrap();
println!("latency of the input stream {} is {}", stream, latency);
}
} else {
println!("No input device.");
}
if let Some(device) = test_get_default_device(Scope::Output) {
let streams = get_device_streams(device, DeviceType::OUTPUT).unwrap();
for stream in streams {
let latency = get_stream_latency(stream, DeviceType::OUTPUT).unwrap();
println!("latency of the output stream {} is {}", stream, latency);
}
} else {
println!("No output device.");
}
} | rust_cleaned_test_functions.jsonl/113832 | {
"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,
3062,
12673,
74832,
368,
341,
262,
421,
1077,
4329,
17848,
8,
284,
1273,
3062,
9993,
9204,
3759,
2417,
486,
2505,
8,
341,
286,
1077,
23045,
284,
633,
9204,
74872,
17848,
11,
13903,
929,
486,
294... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_edition_parsing() {
// test default edition
let options = Options::default();
assert!(options.edition == DEFAULT_EDITION);
let matches = optgroups().parse(&["--edition=2018".to_string()]).unwrap();
let (sessopts, _) = build_session_options_and_crate_config(matches);
assert!(sessopts.edition == Edition::Edition2018)
} | rust_cleaned_test_functions.jsonl/16057 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 135
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
32370,
680,
620,
28598,
368,
341,
262,
442,
1273,
1638,
13688,
198,
262,
1077,
2606,
284,
14566,
486,
2258,
543,
262,
2060,
10297,
2875,
10059,
680,
621,
11955,
32860,
7092,
626,
262,
1077,
9071,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_aces_can_end_a_straight_high() {
test(&["4S 5H 4C 8D 4H", "10D JH QS KD AC"], &["10D JH QS KD AC"])
} | rust_cleaned_test_functions.jsonl/49908 | {
"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,
62,
2434,
27421,
6213,
4306,
2895,
7386,
22680,
368,
341,
1066,
262,
1273,
2099,
1183,
19,
50,
220,
20,
39,
220,
19,
34,
220,
23,
35,
220,
19,
39,
497,
330,
16,
15,
35,
619,
39,
77746,
629... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_decode_one_bytes_as_boolean() {
let mut byte_array = [6].to_vec();
let value = decode_bool(byte_array.pop().unwrap());
assert_eq!(value, true);
} | rust_cleaned_test_functions.jsonl/16125 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 79
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15227,
11667,
12524,
11898,
46642,
368,
341,
262,
1077,
5206,
4922,
3858,
284,
508,
21,
936,
983,
13251,
543,
262,
1077,
897,
284,
16895,
22159,
19738,
3858,
8288,
1005,
15454,
1423,
262,
2060,
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 |
#[test]
fn test_update() {
// root
// y key3
// x placeholder
// key1 key2
let key1 = b"aaaaa".test_only_hash();
let key2 = b"bb".test_only_hash();
let key3 = b"cccc".test_only_hash();
assert_eq!(key1[0], 0b0000_0100);
assert_eq!(key2[0], 0b0010_0100);
assert_eq!(key3[0], 0b1110_0111);
let value1 = AccountStateBlob::from(b"value1".to_vec());
let value1_hash = value1.hash();
let value2_hash = AccountStateBlob::from(b"value2".to_vec()).hash();
let value3_hash = AccountStateBlob::from(b"value3".to_vec()).hash();
// A new key at the "placeholder" position.
let key4 = b"d".test_only_hash();
assert_eq!(key4[0], 0b0100_1100);
let value4 = AccountStateBlob::from(b"value".to_vec());
// Create a proof for this new key.
let leaf1_hash = hash_leaf(key1, value1_hash);
let leaf2_hash = hash_leaf(key2, value2_hash);
let leaf3_hash = hash_leaf(key3, value3_hash);
let x_hash = hash_internal(leaf1_hash, leaf2_hash);
let y_hash = hash_internal(x_hash, *SPARSE_MERKLE_PLACEHOLDER_HASH);
let old_root_hash = hash_internal(y_hash, leaf3_hash);
let proof = SparseMerkleProof::new(None, vec![leaf3_hash, x_hash]);
assert!(proof.verify(old_root_hash, key4, None).is_ok());
// Create the old tree and update the tree with new value and proof.
let proof_reader = ProofReader::new(vec![(key4, proof)]);
let old_smt = SparseMerkleTree::new(old_root_hash);
let smt1 = old_smt
.update(vec![(key4, value4.clone())], &proof_reader)
.unwrap();
// Now smt1 should look like this:
// root
// x key4
assert_eq!(smt1.get(key1), AccountState::Unknown);
assert_eq!(smt1.get(key2), AccountState::Unknown);
assert_eq!(smt1.get(key3), AccountState::Unknown);
assert_eq!(
smt1.get(key4),
AccountState::ExistsInScratchPad(value4.clone())
);
let non_existing_key = b"foo".test_only_hash();
assert_eq!(non_existing_key[0], 0b0111_0110);
assert_eq!(smt1.get(non_existing_key), AccountState::DoesNotExist);
// Verify root hash.
let value4_hash = value4.hash();
let leaf4_hash = hash_leaf(key4, value4_hash);
let y_hash = hash_internal(x_hash, leaf4_hash);
let root_hash = hash_internal(y_hash, leaf3_hash);
assert_eq!(smt1.root_hash(), root_hash);
let proof = SparseMerkleProof::new(
Some((key1, value1_hash)),
vec![leaf3_hash, *SPARSE_MERKLE_PLACEHOLDER_HASH, leaf2_hash],
);
assert!(proof.verify(old_root_hash, key1, Some(&value1)).is_ok());
let value1 = AccountStateBlob::from(b"value11111".to_vec());
let proof_reader = ProofReader::new(vec![(key1, proof)]);
let smt2 = smt1
.update(vec![(key1, value1.clone())], &proof_reader)
.unwrap();
// Now the tree looks like:
// root
// x key4
assert_eq!(
smt2.get(key1),
AccountState::ExistsInScratchPad(value1.clone())
);
assert_eq!(smt2.get(key2), AccountState::Unknown);
assert_eq!(smt2.get(key3), AccountState::Unknown);
assert_eq!(
smt2.get(key4),
AccountState::ExistsInScratchPad(value4.clone())
);
// Verify root hash.
let value1_hash = value1.hash();
let leaf1_hash = hash_leaf(key1, value1_hash);
let x_hash = hash_internal(leaf1_hash, leaf2_hash);
let y_hash = hash_internal(x_hash, leaf4_hash);
let root_hash = hash_internal(y_hash, leaf3_hash);
assert_eq!(smt2.root_hash(), root_hash);
// We now try to create another branch on top of smt1.
let value4 = AccountStateBlob::from(b"new value 4444444444".to_vec());
// key4 already exists in the tree.
let proof_reader = ProofReader::default();
let smt22 = smt1
.update(vec![(key4, value4.clone())], &proof_reader)
.unwrap();
assert_eq!(smt22.get(key1), AccountState::Unknown);
assert_eq!(smt22.get(key2), AccountState::Unknown);
assert_eq!(smt22.get(key3), AccountState::Unknown);
assert_eq!(
smt22.get(key4),
AccountState::ExistsInScratchPad(value4.clone())
);
// Now prune smt1.
smt1.prune();
// key1.
assert_eq!(
smt2.get(key1),
AccountState::ExistsInScratchPad(value1.clone())
);
assert_eq!(smt2.get(key2), AccountState::Unknown);
assert_eq!(smt2.get(key3), AccountState::Unknown);
assert_eq!(smt2.get(key4), AccountState::Unknown);
// key4.
assert_eq!(smt22.get(key1), AccountState::Unknown);
assert_eq!(smt22.get(key2), AccountState::Unknown);
assert_eq!(smt22.get(key3), AccountState::Unknown);
assert_eq!(
smt22.get(key4),
AccountState::ExistsInScratchPad(value4.clone())
);
} | rust_cleaned_test_functions.jsonl/15422 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2239
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8882,
368,
341,
1066,
262,
442,
1797,
3704,
7213,
262,
442,
1843,
379,
414,
1376,
18,
7213,
262,
442,
260,
856,
256,
5878,
7213,
262,
442,
262,
1376,
16,
256,
1376,
17,
198,
262,
1077,
1376,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_and_with_multiple_lte_to_string() {
let name1 = _random_vector(10);
let value1 = _random_string(10);
let name2 = _random_vector(10);
let value2 = _random_string(10);
let name3 = _random_vector(10);
let value3 = _random_string(10);
let query = Operator::And(
vec![
Operator::Lte(
TagName::PlainTagName(name1.clone()),
TargetValue::Unencrypted(value1.clone())
),
Operator::Lte(
TagName::PlainTagName(name2.clone()),
TargetValue::Unencrypted(value2.clone())
),
Operator::Lte(
TagName::PlainTagName(name3.clone()),
TargetValue::Unencrypted(value3.clone())
),
]
);
let json = query.to_string();
let expected = format!(r#"{{"$and":[{{"~{}":{{"$lte":"{}"}}}},{{"~{}":{{"$lte":"{}"}}}},{{"~{}":{{"$lte":"{}"}}}}]}}"#,
base64::encode(&name1), value1,
base64::encode(&name2), value2,
base64::encode(&name3), value3
);
assert_eq!(json, expected);
} | rust_cleaned_test_functions.jsonl/11903 | {
"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,
8378,
6615,
45233,
907,
665,
2346,
3904,
368,
341,
286,
1077,
829,
16,
284,
716,
11463,
12247,
7,
16,
15,
317,
286,
1077,
897,
16,
284,
716,
11463,
3904,
7,
16,
15,
317,
286,
1077,
829,
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_can_resume_to() {
assert!(
TLS13_AES_128_GCM_SHA256
.tls13()
.unwrap()
.can_resume_from(TLS13_CHACHA20_POLY1305_SHA256)
.is_some()
);
assert!(
TLS13_AES_256_GCM_SHA384
.tls13()
.unwrap()
.can_resume_from(TLS13_CHACHA20_POLY1305_SHA256)
.is_none()
);
} | rust_cleaned_test_functions.jsonl/134630 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 323
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
27421,
58132,
2346,
368,
341,
286,
2060,
33673,
310,
41654,
16,
18,
69381,
62,
16,
17,
23,
2646,
9985,
38096,
17,
20,
21,
198,
394,
659,
34488,
16,
18,
741,
394,
659,
15454,
741,
394,
659,
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... | 1 |
#[test]
fn test_key_params_mismatch() {
let available_key_params = [
&rcgen::PKCS_RSA_SHA256,
&rcgen::PKCS_ECDSA_P256_SHA256,
&rcgen::PKCS_ECDSA_P384_SHA384,
&rcgen::PKCS_ED25519,
];
for (i, kalg_1) in available_key_params.iter().enumerate() {
for (j, kalg_2) in available_key_params.iter().enumerate() {
if i == j {
assert_eq!(*kalg_1, *kalg_2);
assert_eq!(generate_hash(*kalg_1), generate_hash(*kalg_2));
continue;
}
assert_ne!(*kalg_1, *kalg_2);
assert_ne!(generate_hash(*kalg_1), generate_hash(*kalg_2));
let mut wrong_params = util::default_params();
if i != 0 {
wrong_params.key_pair = Some(KeyPair::generate(kalg_1).unwrap());
} else {
let kp = KeyPair::from_pem(util::RSA_TEST_KEY_PAIR_PEM).unwrap();
wrong_params.key_pair = Some(kp);
}
wrong_params.alg = *kalg_2;
assert_eq!(
Certificate::from_params(wrong_params).err(),
Some(RcgenError::CertificateKeyPairMismatch),
"i: {} j: {}", i, j);
}
}
} | rust_cleaned_test_functions.jsonl/118247 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 486
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3097,
6745,
717,
24976,
368,
341,
10217,
2500,
3097,
6745,
284,
2278,
197,
197,
5,
1287,
4370,
486,
22242,
6412,
76994,
38096,
17,
20,
21,
345,
197,
197,
5,
1287,
4370,
486,
22242,
6412,
69510,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_truncate_bytes_size() {
new_ucmd!()
.args(&["--size", "1024R", "file"])
.fails()
.code_is(1)
.stderr_only("truncate: Invalid number: '1024R'");
#[cfg(not(target_pointer_width = "128"))]
new_ucmd!()
.args(&["--size", "1Y", "file"])
.fails()
.code_is(1)
.stderr_only("truncate: Invalid number: '1Y': Value too large for defined data type");
#[cfg(target_pointer_width = "32")]
{
let sizes = ["1000G", "10T"];
for size in &sizes {
new_ucmd!()
.args(&["--size", size, "file"])
.fails()
.code_is(1)
.stderr_only(format!(
"truncate: Invalid number: '{}': Value too large for defined data type",
size
));
}
}
} | rust_cleaned_test_functions.jsonl/77098 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 512
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3547,
26900,
12524,
2368,
368,
341,
80719,
262,
501,
68887,
2277,
0,
741,
286,
659,
2116,
2099,
1183,
313,
2141,
497,
330,
16,
15,
17,
19,
49,
497,
330,
1192,
14108,
286,
659,
59631,
741,
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... | 2 |
#[test]
fn test_struct_array_reader_list() {
use arrow::datatypes::Int32Type;
let expected_l =
Arc::new(ListArray::from_iter_primitive::<Int32Type, _, _>(vec![
Some(vec![Some(1), Some(2), None]),
Some(vec![]),
None,
None,
]));
let validity = Buffer::from([0b00000111]);
let struct_fields = vec![(
Field::new("foo", expected_l.data_type().clone(), true),
expected_l.clone() as ArrayRef,
)];
let expected = StructArray::from((struct_fields, validity));
let array = Arc::new(Int32Array::from_iter(vec![
Some(1),
Some(2),
None,
None,
None,
None,
]));
let reader = InMemoryArrayReader::new(
ArrowType::Int32,
array,
Some(vec![4, 4, 3, 2, 1, 0]),
Some(vec![0, 1, 1, 0, 0, 0]),
);
let list_reader = ListArrayReader::<i32>::new(
Box::new(reader),
expected_l.data_type().clone(),
ArrowType::Int32,
3,
1,
true,
);
let mut struct_reader = StructArrayReader::new(
expected.data_type().clone(),
vec![Box::new(list_reader)],
1,
0,
true,
);
let actual = struct_reader.next_batch(1024).unwrap();
let actual = actual.as_any().downcast_ref::<StructArray>().unwrap();
assert_eq!(actual, &expected)
} | rust_cleaned_test_functions.jsonl/62333 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 938
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15126,
3858,
22306,
2019,
368,
341,
286,
990,
17921,
486,
5911,
60913,
486,
1072,
18,
17,
929,
280,
16885,
73363,
23459,
286,
1077,
3601,
907,
4035,
310,
19689,
486,
931,
10278,
1857,
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_net_version() {
let mut client = ConnectionWrapper::new_from_env(None);
rpc_call_test_expected(&mut client, rpc::net_version(), String::from("1337"));
} | rust_cleaned_test_functions.jsonl/39918 | {
"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,
19722,
9438,
368,
341,
262,
1077,
5206,
2943,
284,
11032,
11542,
486,
931,
5673,
15879,
26717,
317,
262,
35596,
13429,
4452,
32190,
2099,
6984,
2943,
11,
35596,
486,
4711,
9438,
1507,
923,
486,
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 |
#[test]
fn test_struct() {
#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct Test {
int: u32,
seq: Vec<String>,
}
let test = Test {
int: 1,
seq: vec!["a".to_string(), "b".to_string()],
};
let config = Config::try_from(&test).unwrap();
let actual: Test = config.try_into().unwrap();
assert_eq!(test, actual);
} | rust_cleaned_test_functions.jsonl/126085 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 233
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15126,
368,
341,
286,
11506,
27098,
42618,
11,
39900,
11,
48440,
11,
55039,
5563,
286,
2036,
3393,
341,
310,
526,
25,
575,
18,
17,
345,
310,
12981,
25,
11312,
3464,
12520,
286,
555,
286,
1077,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_time_options_threshold() {
let unit = TimeThreshold::new(Duration::from_millis(50), Duration::from_millis(100));
let integration = TimeThreshold::new(Duration::from_millis(500), Duration::from_millis(1000));
let doc = TimeThreshold::new(Duration::from_millis(5000), Duration::from_millis(10000));
let options = TestTimeOptions {
error_on_excess: false,
colored: false,
unit_threshold: unit.clone(),
integration_threshold: integration.clone(),
doctest_threshold: doc.clone(),
};
let test_vector = [
(TestType::UnitTest, unit.warn.as_millis() - 1, false, false),
(TestType::UnitTest, unit.warn.as_millis(), true, false),
(TestType::UnitTest, unit.critical.as_millis(), true, true),
(TestType::IntegrationTest, integration.warn.as_millis() - 1, false, false),
(TestType::IntegrationTest, integration.warn.as_millis(), true, false),
(TestType::IntegrationTest, integration.critical.as_millis(), true, true),
(TestType::DocTest, doc.warn.as_millis() - 1, false, false),
(TestType::DocTest, doc.warn.as_millis(), true, false),
(TestType::DocTest, doc.critical.as_millis(), true, true),
];
for (test_type, time, expected_warn, expected_critical) in test_vector.iter() {
let test_desc = typed_test_desc(*test_type);
let exec_time = test_exec_time(*time as u64);
assert_eq!(options.is_warn(&test_desc, &exec_time), *expected_warn);
assert_eq!(options.is_critical(&test_desc, &exec_time), *expected_critical);
}
} | rust_cleaned_test_functions.jsonl/7710 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 639
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3009,
8743,
21858,
368,
341,
262,
1077,
4982,
284,
4120,
37841,
486,
931,
64114,
486,
1499,
717,
56212,
7,
20,
15,
701,
21045,
486,
1499,
717,
56212,
7,
16,
15,
15,
1106,
262,
1077,
17590,
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... | 2 |
#[test]
fn test_env() {
let output = exec! {
"printenv",
clear_env: true,
env: {
USER: "root",
COFFEE: "a lot"
},
modify_path: false,
log: true,
stderr: []
};
assert!(if output.stdout == b"COFFEE=a lot\nUSER=root\n" ||
output.stdout == b"USER=root\nCOFFEE=a lot\n" {
true
} else {
false
});
} | rust_cleaned_test_functions.jsonl/72684 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 247
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15879,
368,
341,
262,
1077,
2550,
284,
3883,
0,
341,
286,
330,
1350,
3160,
756,
286,
2797,
15879,
25,
830,
345,
286,
6105,
25,
341,
310,
13872,
25,
330,
2888,
756,
310,
7284,
1748,
7099,
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... | 3 |
#[test]
fn test_transaction_info() {
let allocator = Arena::new();
let module_cache = VMModuleCache::new(&allocator);
let main_module = fake_script().into_module();
let loaded_main = LoadedModule::new(main_module);
let entry_func = FunctionRef::new(&loaded_main, CompiledScript::MAIN_INDEX);
let txn_info = {
let (_, public_key) = crypto::signing::generate_genesis_keypair();
TransactionMetadata {
sender: AccountAddress::default(),
public_key,
sequence_number: 10,
max_gas_amount: 100_000_009,
gas_unit_price: 5,
transaction_size: 100,
}
};
let data_cache = FakeDataCache::new();
let mut vm = TransactionExecutor::new(module_cache, &data_cache, txn_info);
vm.execution_stack.push_frame(entry_func);
test_simple_instruction(
&mut vm,
Bytecode::GetTxnMaxGasUnits,
vec![],
vec![Local::u64(100_000_009)],
vec![],
vec![],
1,
);
test_simple_instruction(
&mut vm,
Bytecode::GetTxnSequenceNumber,
vec![],
vec![Local::u64(10)],
vec![],
vec![],
1,
);
test_simple_instruction(
&mut vm,
Bytecode::GetTxnGasUnitPrice,
vec![],
vec![Local::u64(5)],
vec![],
vec![],
1,
);
} | rust_cleaned_test_functions.jsonl/65240 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 697
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28884,
3109,
368,
341,
262,
1077,
43655,
284,
27047,
486,
931,
543,
262,
1077,
4688,
11529,
284,
17792,
3332,
8233,
486,
931,
2099,
57631,
317,
262,
1077,
1887,
10750,
284,
12418,
14660,
1005,
181... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_externally_b_de() {
let s = "VariantB(foo:1,bar:2,)";
let e = EnumStructExternally::VariantB {
foo: 1,
bar: 2,
};
test_de(s, e);
} | rust_cleaned_test_functions.jsonl/110476 | {
"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,
62,
4301,
745,
880,
2259,
368,
341,
262,
1077,
274,
284,
330,
20746,
33,
71880,
25,
16,
11,
2257,
25,
17,
11,
24023,
262,
1077,
384,
284,
14086,
9422,
84210,
745,
486,
20746,
33,
341,
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_cube_assoc() {
let mut rng = rand::thread_rng();
for _ in 0..1000 {
let p1: Permutation = rng.gen();
let p2: Permutation = rng.gen();
let c: Cube = rng.gen();
assert_eq!(c.apply(p1).apply(p2), c.apply(p1 + p2));
}
} | rust_cleaned_test_functions.jsonl/31489 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 180
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
64065,
18891,
368,
341,
286,
1077,
5206,
28422,
284,
10382,
486,
4528,
66849,
543,
286,
369,
716,
304,
220,
15,
496,
16,
15,
15,
15,
341,
310,
1077,
281,
16,
25,
3616,
30971,
284,
28422,
22822... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_sample() {
use std::collections::HashMap;
use nakamoto_common::bitcoin::network::address::Address;
use nakamoto_common::bitcoin::network::constants::ServiceFlags;
use nakamoto_common::block::time::{LocalDuration, LocalTime};
use nakamoto_common::p2p::peer::Source;
let cfg = Config::default();
let mut addrmgr = AddressManager::new(cfg, fastrand::Rng::new(), HashMap::new(), ());
let mut time = LocalTime::now();
addrmgr.initialize(time);
// Addresses controlled by an adversary.
let adversary_addrs = vec![
Address::new(&([111, 8, 55, 2], 8333).into(), ServiceFlags::NONE),
Address::new(&([111, 8, 43, 11], 8333).into(), ServiceFlags::NONE),
Address::new(&([111, 8, 89, 6], 8333).into(), ServiceFlags::NONE),
Address::new(&([111, 8, 124, 41], 8333).into(), ServiceFlags::NONE),
Address::new(&([111, 8, 65, 4], 8333).into(), ServiceFlags::NONE),
Address::new(&([111, 8, 161, 73], 8333).into(), ServiceFlags::NONE),
];
addrmgr.insert(
adversary_addrs
.iter()
.cloned()
.map(|a| (time.block_time(), a)),
Source::Dns,
);
let safe_addrs = vec![
Address::new(&([183, 8, 55, 2], 8333).into(), ServiceFlags::NONE),
Address::new(&([211, 48, 99, 4], 8333).into(), ServiceFlags::NONE),
Address::new(&([241, 44, 12, 5], 8333).into(), ServiceFlags::NONE),
Address::new(&([99, 129, 2, 15], 8333).into(), ServiceFlags::NONE),
];
addrmgr.insert(
safe_addrs.iter().cloned().map(|a| (time.block_time(), a)),
Source::Dns,
);
let mut adversary = 0;
let mut safe = 0;
for _ in 0..99 {
let (addr, _) = addrmgr.sample(ServiceFlags::NONE).unwrap();
// Make sure we can re-sample the same addresses for the purpose of this example.
time = time + LocalDuration::from_mins(60);
addrmgr.received_tick(time);
if adversary_addrs.contains(&addr) {
adversary += 1;
} else if safe_addrs.contains(&addr) {
safe += 1;
}
}
// are picked much more often.
assert!(
safe > adversary * 2,
"safe addresses are picked twice more often"
);
} | rust_cleaned_test_functions.jsonl/79213 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1218
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17491,
368,
341,
286,
990,
1460,
486,
51137,
486,
18497,
401,
286,
990,
40886,
56860,
21107,
486,
83910,
486,
17511,
486,
4995,
486,
4286,
280,
286,
990,
40886,
56860,
21107,
486,
83910,
486,
1751... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_long() {
use rand::{thread_rng, RngCore};
let mut rng = thread_rng();
for i in 1..100 {
for j in 1..50 {
let mut data = vec![0u8; i * j];
rng.fill_bytes(&mut data);
let mut buf = Vec::new();
let mut reader = Fr32Reader::new(Cursor::new(&data));
reader.read_to_end(&mut buf).expect("in-memory read failed");
assert_eq!(
buf.into_boxed_slice(),
bit_vec_padding(data),
"{} - {}",
i,
j
);
}
}
} | rust_cleaned_test_functions.jsonl/25674 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 430
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17799,
368,
341,
286,
990,
10382,
22964,
4528,
66849,
11,
431,
968,
5386,
2315,
286,
1077,
5206,
28422,
284,
4516,
66849,
543,
286,
369,
600,
304,
220,
16,
496,
16,
15,
15,
341,
310,
369,
502,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_iterating_instruction_cost_by_program_keys() {
solana_logger::setup();
let mut testee = CostModel::default();
let mut test_key_and_cost = HashMap::<Pubkey, u64>::new();
(0u64..10u64).for_each(|n| {
test_key_and_cost.insert(Pubkey::new_unique(), n);
});
test_key_and_cost.iter().for_each(|(key, cost)| {
let _ = testee.upsert_instruction_cost(key, *cost).unwrap();
info!("key {:?} cost {}", key, cost);
});
let keys = testee.get_program_keys();
// verify each key has pre-set value
keys.iter().for_each(|key| {
let expected_cost = test_key_and_cost.get(key).unwrap();
info!(
"check key {:?} expect {} find {}",
key,
expected_cost,
testee.find_instruction_cost(key)
);
assert_eq!(*expected_cost, testee.find_instruction_cost(key));
});
} | rust_cleaned_test_functions.jsonl/81988 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 514
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11723,
1095,
54923,
15890,
3710,
25096,
12631,
368,
341,
286,
2048,
3362,
27413,
486,
15188,
543,
286,
1077,
5206,
1273,
2127,
284,
11194,
1712,
486,
2258,
1428,
286,
1077,
5206,
1273,
3097,
8378,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_string_info_tag_number_a() {
let mut reader = Reader::from_path("test/test-info-multi-string-number=A.vcf").unwrap();
let mut rec = reader.empty_record();
let _ = reader.read(&mut rec);
assert_eq!(
rec.info_shared_buffer(b"X", Buffer::new())
.string()
.unwrap()
.unwrap()
.len(),
2
);
} | rust_cleaned_test_functions.jsonl/8781 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 247
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25133,
3904,
3109,
9372,
5500,
4306,
368,
341,
286,
1077,
5206,
6604,
284,
25166,
486,
1499,
2638,
445,
1944,
12697,
12505,
95669,
30881,
25854,
46623,
3133,
9792,
1827,
15454,
543,
286,
1077,
5206,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_permissions_net_connect_allow_deno_land() {
let (_, err) = util::run_and_collect_output(
false,
"run --allow-net=deno.land complex_permissions_test.ts netConnect 127.0.0.1:4546",
None,
None,
true,
);
assert!(err.contains(util::PERMISSION_DENIED_PATTERN));
} | rust_cleaned_test_functions.jsonl/5604 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 136
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
44767,
19722,
15720,
55731,
814,
11790,
60506,
368,
341,
220,
1077,
39464,
1848,
8,
284,
4094,
486,
6108,
8378,
68140,
7645,
1006,
262,
895,
345,
298,
197,
1,
6108,
1177,
7183,
66496,
28,
5183,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_explicit_call_init() {
check_output_default(
"class Foo {\
init(val) {\
this.val = val;\
}\
}\
\
var foo1 = Foo(42);\
print foo1.val;\
var foo2 = foo1.init(1337);\
print foo2.val;\
print foo1.val;",
"42\n1337\n1337",
)
} | rust_cleaned_test_functions.jsonl/111856 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 287
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14214,
6026,
13429,
6137,
368,
341,
286,
1779,
7645,
9993,
1006,
310,
330,
1040,
33428,
95519,
2290,
2930,
9098,
8,
95519,
338,
419,
10835,
284,
1044,
55783,
2290,
335,
5661,
1797,
335,
5661,
1797... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_should_panic_bad_message() {
use crate::tests::TrFailedMsg;
fn f() {
panic!("an error message");
}
let expected = "foobar";
let failed_msg = r#"panic did not contain expected string
panic message: `"an error message"`,
expected substring: `"foobar"`"#;
let desc = TestDescAndFn {
desc: TestDesc {
name: StaticTestName("whatever"),
ignore: false,
should_panic: ShouldPanic::YesWithMessage(expected),
allow_fail: false,
compile_fail: false,
no_run: false,
test_type: TestType::Unknown,
},
testfn: DynTestFn(Box::new(f)),
};
let (tx, rx) = channel();
run_test(&TestOpts::new(), false, TestId(0), desc, RunStrategy::InProcess, tx, Concurrent::No);
let result = rx.recv().unwrap().result;
assert_eq!(result, TrFailedMsg(failed_msg.to_string()));
} | rust_cleaned_test_functions.jsonl/7704 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 419
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
43378,
620,
31270,
34199,
6462,
368,
341,
262,
990,
17717,
486,
23841,
486,
1282,
9408,
6611,
280,
262,
5168,
282,
368,
341,
286,
21975,
17223,
276,
1465,
1943,
797,
262,
456,
262,
1077,
3601,
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_remez() {
let prec = 1000;
let exps = (2..=50).step_by(2).collect::<Vec<_>>();
println!("exps = {exps:?}, len = {}", exps.len());
let f = |x: &Float| {
let y = x.clone().exp();
x * (y.clone() + 1.0f64) / (y.clone() - 1.0f64) - 2.0
};
let coeffs = gen_coeff_remez(f, &exps, 0.0, 2.0f64.ln() / 2.0, prec);
assert!(false);
} | rust_cleaned_test_functions.jsonl/20100 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 248
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1288,
82156,
368,
341,
286,
1077,
5833,
284,
220,
16,
15,
15,
15,
280,
286,
1077,
1343,
82,
284,
320,
17,
496,
28,
20,
15,
568,
9520,
3710,
7,
17,
568,
17384,
27638,
10050,
32399,
37038,
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_serialization_stability() -> TestResult {
let mut hasher = XxHash32::with_seed(0);
hasher.write(b"Hello, world!\0");
hasher.finish();
let serialized = r#"{
"total_len": 14,
"seed": 0,
"core": {
"v1": 606290984,
"v2": 2246822519,
"v3": 0,
"v4": 1640531535
},
"buffer": [
72, 101, 108, 108, 111, 44, 32, 119,
111, 114, 108, 100, 33, 0, 0, 0
],
"buffer_usage": 14
}"#;
let unserialized: XxHash32 = serde_json::from_str(serialized).unwrap();
assert_eq!(hasher, unserialized);
Ok(())
} | rust_cleaned_test_functions.jsonl/126799 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 445
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25602,
2022,
1261,
2897,
368,
1464,
3393,
2077,
341,
286,
1077,
5206,
90819,
284,
1599,
87,
6370,
18,
17,
486,
4197,
33809,
7,
15,
317,
286,
90819,
3836,
1883,
1,
9707,
11,
1879,
14771,
15,
79... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_test_msgs_wstring() -> () {
let mut msg = test_msgs::msg::WStrings::default();
let rust_str = "ハローワールド";
msg.wstring_value = rust_str.to_string();
let native = WrappedNativeMsg::<test_msgs::msg::WStrings>::from(&msg);
println!("msg: {:?}", msg);
let msg2 = test_msgs::msg::WStrings::from_native(&native);
assert_eq!(msg.wstring_value, msg2.wstring_value);
} | rust_cleaned_test_functions.jsonl/28027 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 208
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4452,
20777,
1670,
917,
368,
1464,
1719,
341,
286,
1077,
5206,
3750,
284,
1273,
20777,
486,
3236,
486,
54,
20859,
486,
2258,
543,
286,
1077,
23071,
2895,
284,
330,
124654,
41534,
24041,
107,
63078... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_apply() {
let locks: Vec<_> = vec![
(b"k0", 10),
(b"k1", 110),
(b"k5", 100),
(b"k2", 101),
(b"k3", 90),
(b"k2", 99),
]
.into_iter()
.map(|(k, ts)| {
let mut lock_info = LockInfo::default();
lock_info.set_key(k.to_vec());
lock_info.set_primary_lock(k.to_vec());
lock_info.set_lock_type(Op::Put);
lock_info.set_lock_version(ts);
lock_info
})
.collect();
let lock_kvs: Vec<_> = locks
.iter()
.map(|lock| lock_info_to_kv(lock.clone()))
.collect();
let (c, coprocessor_host) = new_test_collector();
let mut expected_result = vec![];
start_collecting(&c, 100).unwrap();
assert_eq!(get_collected_locks(&c, 100).unwrap(), (vec![], true));
// Only puts in lock cf will be monitered.
let req = vec![
make_apply_request(
lock_kvs[0].0.clone(),
lock_kvs[0].1.clone(),
CF_LOCK,
CmdType::Put,
),
make_apply_request(b"1".to_vec(), b"1".to_vec(), CF_DEFAULT, CmdType::Put),
make_apply_request(b"2".to_vec(), b"2".to_vec(), CF_LOCK, CmdType::Delete),
];
coprocessor_host.post_apply(&Region::default(), &make_raft_cmd(req));
expected_result.push(locks[0].clone());
assert_eq!(
get_collected_locks(&c, 100).unwrap(),
(expected_result.clone(), true)
);
start_collecting(&c, 100).unwrap();
assert_eq!(
get_collected_locks(&c, 100).unwrap(),
(expected_result.clone(), true)
);
// Only locks with ts <= 100 will be collected.
let req: Vec<_> = lock_kvs
.iter()
.map(|(k, v)| make_apply_request(k.clone(), v.clone(), CF_LOCK, CmdType::Put))
.collect();
expected_result.extend(
locks
.iter()
.filter(|l| l.get_lock_version() <= 100)
.cloned(),
);
coprocessor_host.post_apply(&Region::default(), &make_raft_cmd(req.clone()));
assert_eq!(
get_collected_locks(&c, 100).unwrap(),
(expected_result, true)
);
// dropped.
start_collecting(&c, 110).unwrap();
assert_eq!(get_collected_locks(&c, 110).unwrap(), (vec![], true));
coprocessor_host.post_apply(&Region::default(), &make_raft_cmd(req));
assert_eq!(get_collected_locks(&c, 110).unwrap(), (locks, true));
} | rust_cleaned_test_functions.jsonl/15209 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1482
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36551,
368,
341,
286,
1077,
31676,
25,
11312,
32399,
29,
284,
7486,
90515,
310,
320,
65,
62911,
15,
497,
220,
16,
15,
1326,
310,
320,
65,
62911,
16,
497,
220,
16,
16,
15,
1326,
310,
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 |
#[test]
fn test_multi_line_aggregation() {
let (tx, rx) = futures::sync::mpsc::channel(10);
let (trigger, tripwire) = Tripwire::new();
let dir = tempdir().unwrap();
let config = file::FileConfig {
include: vec![dir.path().join("*")],
message_start_indicator: Some("INFO".into()),
multi_line_timeout: 25,
..test_default_file_config(&dir)
};
let source = file::file_source(&config, config.data_dir.clone().unwrap(), tx);
let mut rt = tokio::runtime::Runtime::new().unwrap();
rt.spawn(source.select(tripwire).map(|_| ()).map_err(|_| ()));
let path = dir.path().join("file");
let mut file = File::create(&path).unwrap();
sleep(); // The files must be observed at their original lengths before writing to them
writeln!(&mut file, "leftover foo").unwrap();
writeln!(&mut file, "INFO hello").unwrap();
writeln!(&mut file, "INFO goodbye").unwrap();
writeln!(&mut file, "part of goodbye").unwrap();
sleep();
writeln!(&mut file, "INFO hi again").unwrap();
writeln!(&mut file, "and some more").unwrap();
writeln!(&mut file, "INFO hello").unwrap();
sleep();
writeln!(&mut file, "too slow").unwrap();
writeln!(&mut file, "INFO doesn't have").unwrap();
writeln!(&mut file, "to be INFO in").unwrap();
writeln!(&mut file, "the middle").unwrap();
sleep();
drop(trigger);
shutdown_on_idle(rt);
let received = wait_with_timeout(
rx.map(|event| event.as_log().get(&event::MESSAGE).unwrap().clone())
.collect(),
);
assert_eq!(
received,
vec![
"leftover foo".into(),
"INFO hello".into(),
"INFO goodbye\npart of goodbye".into(),
"INFO hi again\nand some more".into(),
"INFO hello".into(),
"too slow".into(),
"INFO doesn't have".into(),
"to be INFO in\nthe middle".into(),
]
);
} | rust_cleaned_test_functions.jsonl/13346 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1025
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25133,
6528,
20587,
34442,
368,
341,
286,
1077,
320,
3998,
11,
19111,
8,
284,
36823,
486,
12996,
486,
1307,
2388,
486,
10119,
7,
16,
15,
317,
286,
1077,
320,
18468,
11,
8411,
35531,
8,
284,
26... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_unit_version_unknown_version() {
let buf = [0x02, 0x00, 0x00, 0x00, 0xab, 0xcd];
let rest = &mut EndianSlice::new(&buf, LittleEndian);
match parse_unit_header(rest) {
Err(Error::UnknownVersion(0xcdab)) => assert!(true),
otherwise => panic!("Unexpected result: {:?}", otherwise),
};
let buf = [0x02, 0x00, 0x00, 0x00, 0x1, 0x0];
let rest = &mut EndianSlice::new(&buf, LittleEndian);
match parse_unit_header(rest) {
Err(Error::UnknownVersion(1)) => assert!(true),
otherwise => panic!("Unexpected result: {:?}", otherwise),
};
} | rust_cleaned_test_functions.jsonl/101997 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 317
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14832,
9438,
57507,
9438,
368,
341,
286,
1077,
6607,
284,
508,
15,
87,
15,
17,
11,
220,
15,
87,
15,
15,
11,
220,
15,
87,
15,
15,
11,
220,
15,
87,
15,
15,
11,
220,
15,
52616,
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... | 3 |
#[test]
fn test_quat_slice() {
let a: [f32; 4] = Quat::from_rotation_ypr(deg(30.0), deg(60.0), deg(90.0)).into();
let b = Quat::from_slice_unaligned(&a);
let c: [f32; 4] = b.into();
assert_eq!(a, c);
let mut d = [0.0, 0.0, 0.0, 0.0];
b.write_to_slice_unaligned(&mut d[..]);
assert_eq!(a, d);
} | rust_cleaned_test_functions.jsonl/73795 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 175
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11280,
266,
26488,
368,
341,
262,
1077,
264,
25,
508,
69,
18,
17,
26,
220,
19,
60,
284,
3406,
266,
486,
1499,
44813,
4178,
649,
77127,
7,
18,
15,
13,
15,
701,
5254,
7,
21,
15,
13,
15,
70... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_label_value() {
let instruction = Instruction::Label(0);
let raw_instruction = instruction.to_raw();
assert_eq!(raw_instruction.0[0], 5 << 4);
assert_eq!(raw_instruction.0[1], 0);
assert_eq!(raw_instruction.operation(), 5)
} | rust_cleaned_test_functions.jsonl/82117 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 133
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6106,
3142,
368,
341,
286,
1077,
7600,
284,
29051,
486,
2476,
7,
15,
317,
286,
1077,
7112,
54923,
284,
7600,
2389,
16067,
543,
286,
2060,
10714,
10297,
1041,
54923,
13,
15,
58,
15,
1125,
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_reached_leader_tick() {
solana_logger::setup();
let ledger_path = get_tmp_ledger_path!();
{
let blocktree =
Blocktree::open(&ledger_path).expect("Expected to be able to open database ledger");
let GenesisBlockInfo { genesis_block, .. } = create_genesis_block(2);
let bank = Arc::new(Bank::new(&genesis_block));
let prev_hash = bank.last_blockhash();
let (mut poh_recorder, _entry_receiver) = PohRecorder::new(
0,
prev_hash,
0,
None,
bank.ticks_per_slot(),
&Pubkey::default(),
&Arc::new(blocktree),
&Arc::new(LeaderScheduleCache::new_from_bank(&bank)),
&Arc::new(PohConfig::default()),
);
assert_eq!(poh_recorder.reached_leader_tick().0, false);
poh_recorder.reset(bank.last_blockhash(), 0, None);
assert_eq!(poh_recorder.reached_leader_tick().0, false);
// Provide a leader slot 1 slot down
poh_recorder.reset(bank.last_blockhash(), 0, Some((2, 2)));
let init_ticks = poh_recorder.tick_height();
// Send one slot worth of ticks
for _ in 0..bank.ticks_per_slot() {
poh_recorder.tick();
}
// Tick should be recorded
assert_eq!(
poh_recorder.tick_height(),
init_ticks + bank.ticks_per_slot()
);
// Test that we don't reach the leader tick because of grace ticks
assert_eq!(poh_recorder.reached_leader_tick().0, false);
// reset poh now. we should immediately be leader
poh_recorder.reset(bank.last_blockhash(), 1, Some((2, 2)));
assert_eq!(poh_recorder.reached_leader_tick().0, true);
assert_eq!(poh_recorder.reached_leader_tick().1, 0);
// Now test that with grace ticks we can reach leader ticks
// Set the leader slot 1 slot down
poh_recorder.reset(bank.last_blockhash(), 1, Some((3, 3)));
for _ in 0..bank.ticks_per_slot() {
poh_recorder.tick();
}
assert_eq!(poh_recorder.reached_leader_tick().0, false);
// Send 1 less tick than the grace ticks
for _ in 0..bank.ticks_per_slot() * NUM_CONSECUTIVE_LEADER_SLOTS / GRACE_TICKS_FACTOR {
poh_recorder.tick();
}
// We should be the leader now
assert_eq!(poh_recorder.reached_leader_tick().0, true);
assert_eq!(
poh_recorder.reached_leader_tick().1,
bank.ticks_per_slot() * NUM_CONSECUTIVE_LEADER_SLOTS / GRACE_TICKS_FACTOR
);
// Let's test that correct grace ticks are reported
// Set the leader slot 1 slot down
poh_recorder.reset(bank.last_blockhash(), 2, Some((4, 4)));
// send ticks for a slot
for _ in 0..bank.ticks_per_slot() {
poh_recorder.tick();
}
assert_eq!(poh_recorder.reached_leader_tick().0, false);
poh_recorder.reset(bank.last_blockhash(), 3, Some((4, 4)));
assert_eq!(poh_recorder.reached_leader_tick().0, true);
assert_eq!(poh_recorder.reached_leader_tick().1, 0);
// Let's test that if a node overshoots the ticks for its target
// Set the leader slot 1 slot down
poh_recorder.reset(bank.last_blockhash(), 4, Some((5, 5)));
for _ in 0..4 * bank.ticks_per_slot() {
poh_recorder.tick();
}
// We are overdue to lead
assert_eq!(poh_recorder.reached_leader_tick().0, true);
}
Blocktree::destroy(&ledger_path).unwrap();
} | rust_cleaned_test_functions.jsonl/31731 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2112
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1288,
3854,
79991,
43612,
368,
341,
286,
2048,
3362,
27413,
486,
15188,
1428,
286,
1077,
46933,
2638,
284,
633,
16125,
38367,
1389,
2638,
0,
543,
286,
341,
310,
1077,
2504,
9344,
4035,
394,
8362,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_parse_dns_name_label() {
let input = b"\x05abcde";
let output = msg::parse_dns_name_label(&input[..]).unwrap().1;
assert_eq!(output, msg::NameUnit::Label("abcde".to_string()));
} | rust_cleaned_test_functions.jsonl/83417 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 94
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
71125,
1269,
6106,
368,
341,
262,
1077,
1946,
284,
293,
11934,
87,
15,
20,
13683,
450,
876,
262,
1077,
2550,
284,
3750,
486,
6400,
71125,
1269,
6106,
2099,
1355,
95874,
10697,
15454,
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 |
#[test]
fn test_wrap_return_type_not_applicable_when_return_type_is_not_result_or_option() {
check_diagnostics(
r#"
//- minicore: option, result
enum SomeOtherEnum { Ok(i32), Err(String) }
fn foo() -> SomeOtherEnum { 0 }
"#,
);
} | rust_cleaned_test_functions.jsonl/51841 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 129
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
38550,
12511,
1819,
7913,
8191,
46114,
47636,
12511,
1819,
6892,
7913,
5287,
8734,
9672,
368,
341,
286,
1779,
814,
18938,
1006,
310,
435,
2,
698,
61463,
1308,
292,
460,
25,
2999,
11,
1102,
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... | 1 |
#[test]
fn test_async_wait_all() {
let runner = SingleTaskRunner::default();
let rt = runner.startup().unwrap();
thread::spawn(move || {
loop {
if let Err(e) = runner.run() {
println!("!!!!!!run failed, reason: {:?}", e);
break;
}
thread::sleep(Duration::from_millis(10));
}
});
let pool: MultiTaskRuntimeBuilder<()> = MultiTaskRuntimeBuilder::default();
let rt0 = pool.build();
let pool: MultiTaskRuntimeBuilder<()> = MultiTaskRuntimeBuilder::default();
let rt1 = pool.build();
{
struct SendableFn(Box<dyn FnOnce(&mut Vec<u8>) -> Vec<u8> + Send + 'static>);
let rt_copy = rt.clone();
let rt0_copy = rt0.clone();
rt.spawn(rt.alloc(), async move {
let mut map_reduce = rt_copy.map_reduce(10);
let cb: SendableFn = SendableFn(Box::new(move |v: &mut Vec<u8>| {
v.clone()
}));
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(cb)
});
let cb: SendableFn = SendableFn(Box::new(move |v: &mut Vec<u8>| {
v.clone()
}));
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(cb)
});
let mut vec = vec![0xff, 0xff, 0xff];
for r in map_reduce.reduce(true).await.unwrap() {
if let Ok(cb) = r {
assert_eq!(cb.0(&mut vec), vec);
}
}
});
}
thread::sleep(Duration::from_millis(1000));
{
let rt_copy = rt.clone();
let rt0_copy = rt0.clone();
let rt1_copy = rt1.clone();
let future = async move {
let mut map_reduce = rt_copy.map_reduce(10);
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(0)
});
map_reduce.map(AsyncRuntime::Multi(rt1_copy.clone()), async move {
Ok(1)
});
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(2)
});
map_reduce.map(AsyncRuntime::Multi(rt1_copy.clone()), async move {
Ok(3)
});
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(4)
});
map_reduce.map(AsyncRuntime::Multi(rt1_copy.clone()), async move {
Ok(5)
});
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(6)
});
map_reduce.map(AsyncRuntime::Multi(rt1_copy.clone()), async move {
Ok(7)
});
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(8)
});
map_reduce.map(AsyncRuntime::Multi(rt1_copy.clone()), async move {
Ok(9)
});
println!("!!!!!!map result: {:?}", map_reduce.reduce(false).await);
let mut map_reduce = rt_copy.map_reduce(10);
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(0)
});
map_reduce.map(AsyncRuntime::Multi(rt1_copy.clone()), async move {
Ok(1)
});
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(2)
});
map_reduce.map(AsyncRuntime::Multi(rt1_copy.clone()), async move {
Ok(3)
});
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(4)
});
map_reduce.map(AsyncRuntime::Multi(rt1_copy.clone()), async move {
Ok(5)
});
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(6)
});
map_reduce.map(AsyncRuntime::Multi(rt1_copy.clone()), async move {
Ok(7)
});
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(8)
});
map_reduce.map(AsyncRuntime::Multi(rt1_copy.clone()), async move {
Ok(9)
});
println!("!!!!!!map result by order: {:?}", map_reduce.reduce(true).await);
};
rt.spawn(rt.alloc(), future);
}
thread::sleep(Duration::from_millis(1000));
{
let counter = Arc::new(AtomicCounter(AtomicUsize::new(0), Instant::now()));
let start = Instant::now();
for _ in 0..1000000 {
let rt0_copy = rt0.clone();
let counter_copy = counter.clone();
let future = async move {
let mut map_reduce = rt0_copy.map_reduce(10);
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(0)
});
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(1)
});
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(2)
});
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(3)
});
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(4)
});
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(5)
});
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(6)
});
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(7)
});
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(8)
});
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(9)
});
if let Ok(_) = map_reduce.reduce(true).await {
counter_copy.0.fetch_add(1, Ordering::Relaxed);
}
};
rt0.spawn(rt0.alloc(), future);
}
println!("!!!!!!spawn ok, time: {:?}", Instant::now() - start);
}
thread::sleep(Duration::from_millis(30000));
{
let counter = Arc::new(AtomicCounter(AtomicUsize::new(0), Instant::now()));
let start = Instant::now();
for _ in 0..1000000 {
let rt_copy = rt.clone();
let rt0_copy = rt0.clone();
let rt1_copy = rt1.clone();
let counter_copy = counter.clone();
let future = async move {
let mut map_reduce = rt_copy.map_reduce(10);
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(0)
});
map_reduce.map(AsyncRuntime::Multi(rt1_copy.clone()), async move {
Ok(1)
});
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(2)
});
map_reduce.map(AsyncRuntime::Multi(rt1_copy.clone()), async move {
Ok(3)
});
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(4)
});
map_reduce.map(AsyncRuntime::Multi(rt1_copy.clone()), async move {
Ok(5)
});
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(6)
});
map_reduce.map(AsyncRuntime::Multi(rt1_copy.clone()), async move {
Ok(7)
});
map_reduce.map(AsyncRuntime::Multi(rt0_copy.clone()), async move {
Ok(8)
});
map_reduce.map(AsyncRuntime::Multi(rt1_copy.clone()), async move {
Ok(9)
});
if let Ok(_) = map_reduce.reduce(true).await {
counter_copy.0.fetch_add(1, Ordering::Relaxed);
}
};
rt.spawn(rt.alloc(), future);
}
println!("!!!!!!spawn ok, time: {:?}", Instant::now() - start);
}
thread::sleep(Duration::from_millis(100000000));
} | rust_cleaned_test_functions.jsonl/62464 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 5111
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28346,
18760,
5705,
368,
972,
262,
1077,
22259,
284,
11327,
6262,
19486,
486,
2258,
1647,
262,
1077,
16677,
284,
22259,
4962,
454,
1005,
15454,
7317,
262,
4516,
486,
46087,
34081,
1369,
972,
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... | 9 |
#[test]
fn test_eval_binary_function_scalar_vector() {
#[derive(Debug, Clone, Copy)]
struct FnFoo;
impl_template_fn! { 2 arg @ FnFoo }
impl FnFoo {
fn call(
_ctx: &mut EvalContext,
_payload: RpnFnCallPayload<'_>,
v1: &Option<f64>,
v2: &Option<i64>,
) -> Result<Option<f64>> {
Ok(Some(v1.unwrap() - v2.unwrap() as f64))
}
}
let mut columns = LazyBatchColumnVec::from(vec![{
let mut col = LazyBatchColumn::decoded_with_capacity_and_tp(3, EvalType::Int);
col.mut_decoded().push_int(Some(1));
col.mut_decoded().push_int(Some(5));
col.mut_decoded().push_int(Some(-4));
col
}]);
let schema = &[{
let mut ft = FieldType::new();
ft.as_mut_accessor().set_tp(FieldTypeTp::LongLong);
ft
}];
let rpn_nodes = vec![
RpnExpressionNode::Constant {
value: ScalarValue::Real(Some(1.5)),
field_type: {
let mut ft = FieldType::new();
ft.as_mut_accessor().set_tp(FieldTypeTp::Double);
ft
},
},
RpnExpressionNode::ColumnRef { offset: 0 },
RpnExpressionNode::FnCall {
func: Box::new(FnFoo),
field_type: {
let mut ft = FieldType::new();
ft.as_mut_accessor().set_tp(FieldTypeTp::Double);
ft
},
},
];
let exp = RpnExpression::from(rpn_nodes);
let mut ctx = EvalContext::default();
let result = exp.eval(&mut ctx, 3, schema, &mut columns);
let val = result.unwrap();
assert!(val.is_vector());
assert_eq!(
val.vector_value().unwrap().as_real_slice(),
[Some(0.5), Some(-3.5), Some(5.5)]
);
assert_eq!(val.field_type().tp(), FieldTypeTp::Double);
} | rust_cleaned_test_functions.jsonl/121514 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1213
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21296,
31761,
9174,
41652,
12247,
368,
341,
394,
11506,
27098,
42618,
11,
27913,
11,
14540,
5563,
286,
2036,
50182,
40923,
401,
286,
11605,
8693,
15246,
0,
314,
220,
17,
1392,
569,
50182,
40923,
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_nested_object() {
let data = [
0xc9, 0x2e, 0x01, 0x00, 0x03, 0x00, 0xe2, 0x28, 0x01, 0x00, 0x0c, 0x00, 0x01, 0x00,
0x00, 0x00, 0xe3, 0x28, 0x01, 0x00, 0x0c, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xc7, 0x2e,
0x01, 0x00, 0x0c, 0x00, 0x04, 0x00, 0x00, 0x00, 0xc8, 0x2e, 0x01, 0x00, 0x0c, 0x00,
0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
];
assert_eq!(
parse(&data[..]).unwrap().token_tape,
vec![
BinaryToken::Token(0x2ec9),
BinaryToken::Object(10),
BinaryToken::Token(0x28e2),
BinaryToken::I32(1),
BinaryToken::Token(0x28e3),
BinaryToken::I32(11),
BinaryToken::Token(0x2ec7),
BinaryToken::I32(4),
BinaryToken::Token(0x2ec8),
BinaryToken::I32(0),
BinaryToken::End(1),
]
);
} | rust_cleaned_test_functions.jsonl/109413 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 647
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
66279,
5314,
368,
341,
286,
1077,
821,
284,
2278,
310,
220,
15,
8148,
24,
11,
220,
15,
87,
17,
68,
11,
220,
15,
87,
15,
16,
11,
220,
15,
87,
15,
15,
11,
220,
15,
87,
15,
18,
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_import_wallet_fails_with_invalid_backup_key() {
let _setup = SetupDefaults::init();
let bad_backup = "456";
let (export_wallet_path, wallet_name) = export_test_wallet();
delete_wallet(&wallet_name, None, None, None).unwrap();
let import_config = json!({
settings::CONFIG_WALLET_NAME: settings::DEFAULT_WALLET_NAME,
settings::CONFIG_WALLET_KEY: settings::DEFAULT_WALLET_KEY,
settings::CONFIG_EXPORTED_WALLET_PATH: export_wallet_path.path,
settings::CONFIG_WALLET_BACKUP_KEY: bad_backup,
}).to_string();
let res = import(&import_config).unwrap_err();
assert_eq!(res.kind(), VcxErrorKind::LibindyInvalidStructure);
} | rust_cleaned_test_functions.jsonl/118717 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 340
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18434,
62308,
761,
6209,
6615,
31433,
44710,
3097,
368,
341,
286,
1077,
716,
15188,
284,
18626,
16273,
486,
2327,
1428,
286,
1077,
3873,
44710,
284,
330,
19,
20,
21,
3302,
286,
1077,
320,
1533,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_timeout() -> common_exception::Result<()> {
// prepare test data
let mut fake_apis = FakeStoreApis::new();
fake_apis.inject_timeout(Duration::from_secs(6));
let provider = Arc::new(FakeStoreApisProvider::new(fake_apis));
let store_client = RemoteMetaStoreClient::create(provider);
// timeout fault only injected for get_database operation
let res = store_client.get_database("test_db");
assert!(res.is_err());
if let Err(e) = res {
assert_eq!(e.code(), ErrorCode::Timeout("").code());
}
Ok(())
} | rust_cleaned_test_functions.jsonl/59321 | {
"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,
20537,
368,
1464,
4185,
17499,
486,
2077,
71698,
341,
262,
442,
10549,
1273,
821,
198,
262,
1077,
5206,
12418,
62,
13725,
284,
36965,
6093,
91121,
486,
931,
543,
262,
12418,
62,
13725,
24143,
2053... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_arrnum_int_mult() {
let factor: Vec<u8> = vec![1, 2];
let base_num = 10;
let base_ten_int_fact: u8 = 4;
let should_output: Vec<u8> = vec![4, 8];
let product = arrnum_int_mult(&factor, base_num, base_ten_int_fact);
assert!(product == should_output);
} | rust_cleaned_test_functions.jsonl/7362 | {
"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,
11210,
2413,
4042,
26290,
368,
341,
1066,
262,
1077,
8168,
25,
11312,
34837,
23,
29,
284,
7486,
20703,
16,
11,
220,
17,
935,
262,
1077,
2331,
4273,
284,
220,
16,
15,
280,
262,
1077,
2331,
7582... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_env_setenv() {
let n = make_rand_name();
let mut e = env();
setenv(&n, "VALUE");
assert!(!e.contains(&(n.clone(), "VALUE".to_string())));
e = env();
assert!(e.contains(&(n, "VALUE".to_string())));
} | rust_cleaned_test_functions.jsonl/72110 | {
"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,
15879,
2602,
3160,
368,
341,
286,
1077,
308,
284,
1281,
33864,
1269,
1428,
286,
1077,
5206,
384,
284,
6105,
543,
286,
738,
3160,
2099,
77,
11,
330,
23832,
797,
286,
2060,
0,
3471,
68,
8786,
29... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.