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_parse_error() {
// brackets without escape
{
const FORMAT_STR: &str = "[";
assert!(StringFormatter::new(FORMAT_STR).is_err());
}
// Dollar without variable
{
const FORMAT_STR: &str = "$ ";
assert!(StringFormatter::new(FORMAT_STR).is_err());
}
} | rust_cleaned_test_functions.jsonl/71894 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 191
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
4096,
368,
341,
286,
442,
38929,
2041,
12449,
198,
286,
341,
310,
733,
52225,
7159,
25,
609,
495,
284,
10545,
876,
310,
2060,
10297,
703,
14183,
486,
931,
7832,
98084,
7159,
568,
285,
926... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_dsa_parsing() {
for test in wycheproof::dsa::TestName::all() {
let _kat = wycheproof::dsa::TestSet::load(test).unwrap();
}
} | rust_cleaned_test_functions.jsonl/5831 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 80
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
814,
9081,
620,
28598,
368,
341,
262,
369,
1273,
304,
289,
5641,
747,
75636,
486,
96780,
486,
2271,
675,
486,
541,
368,
341,
286,
1077,
716,
33755,
284,
289,
5641,
747,
75636,
486,
96780,
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
] | 2 |
#[test]
fn test_invalid_ip_ipv4() {
let event = DhcpEvent::LeaseAdded {
event_timestamp: DateTime::<FixedOffset>::from(Local::now()),
lease_info: full_lease_info_v4(),
};
let mut result_command = Command::new(namib_dnsmasq_hook_exe());
let (mut args, envs) = create_args_and_env_map_from_event(&event);
args.push("192.168.123.256".to_string());
args.swap_remove(2);
assert_eq!(
4,
result_command
.args(args)
.env_clear()
.envs(envs)
.stdout(Stdio::null())
.stderr(Stdio::null())
.status()
.expect("Error while running command.")
.code()
.expect("Command was terminated by a signal.")
);
} | rust_cleaned_test_functions.jsonl/48451 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 477
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31433,
10385,
49378,
19,
368,
341,
286,
1077,
1538,
284,
43227,
4672,
1556,
486,
2304,
519,
19337,
341,
310,
1538,
23073,
25,
6520,
27638,
13520,
6446,
6831,
1499,
42718,
486,
3328,
14702,
310,
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_is_mate_with_kyou_gote() {
let blank_banmen = Banmen([[Blank; 9]; 9]);
let mut banmen = blank_banmen.clone();
banmen.0[8-3][8-4] = SOu;
banmen.0[8-8][8-4] = GKyou;
banmen.0[8-5][8-4] = SKin;
let mut state = State::new(banmen);
let mut mc = MochigomaCollections::Empty;
let mv = Move::To(KomaSrcPosition(9-(8-4),(8-3)+1),KomaDstToPosition(9-(8-4),(8-4)+1,false));
match Rule::apply_move_none_check(&state,Teban::Gote,&mc,mv.to_applied_move()) {
(next,nmc,_) => {
state = next;
mc = nmc;
}
}
let mv = Move::To(KomaSrcPosition(9-(8-4),(8-5)+1),KomaDstToPosition(9-(8-3),(8-5)+1,false));
match Rule::apply_move_none_check(&state,Teban::Gote,&mc,mv.to_applied_move()) {
(next,_,_) => {
state = next;
}
}
assert!(Rule::is_mate(Teban::Gote,&state),"assertion failed, move = {:?}, {:?}",mv,state.get_banmen());
} | rust_cleaned_test_functions.jsonl/72960 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 470
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6892,
717,
349,
6615,
4698,
9330,
1889,
1272,
368,
972,
10217,
10113,
880,
276,
5676,
284,
22730,
5676,
27119,
22770,
26,
220,
24,
5265,
220,
24,
55531,
10217,
5206,
8943,
5676,
284,
10113,
880,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_zero_sglist() {
let sg0 = zero_sglist(100);
assert_eq!(&sg0[0][..], &[0u8; 100][..]);
assert_eq!(sg0.len(), 1);
let sg1 = zero_sglist(ZERO_REGION_LEN + 100);
assert_eq!(&sg1[0][..], &[0u8; ZERO_REGION_LEN][..]);
assert_eq!(&sg1[1][..], &[0u8; 100][..]);
assert_eq!(sg1.len(), 2);
} | rust_cleaned_test_functions.jsonl/17565 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 183
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19359,
76318,
1607,
368,
341,
262,
1077,
30673,
15,
284,
7168,
76318,
1607,
7,
16,
15,
15,
317,
262,
2060,
10714,
0,
2099,
1991,
15,
58,
15,
1457,
496,
1125,
44590,
15,
84,
23,
26,
220,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_decode_ubfx() {
assert_eq!(
decode_32(0xf3c00140),
Instruction::UBFX {
params: UbfxParams {
rd: Reg::R1,
rn: Reg::R0,
lsb: 1,
widthminus1: 0,
}
}
);
} | rust_cleaned_test_functions.jsonl/64805 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 206
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15227,
66794,
8298,
368,
341,
1066,
262,
2060,
10714,
33673,
286,
16895,
62,
18,
17,
7,
15,
5848,
18,
66,
15,
15,
16,
19,
15,
1326,
286,
29051,
486,
4493,
16381,
341,
310,
3628,
25,
26461,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_block_header() {
//generated with from helper_scripts directory:
let data = include_bytes!(
"../test_data/blk_0000000000000000000215160a3490f82c7203d9683802148a56282d1f80993d.bin"
);
let (_, header) = parse_block_header(data).unwrap();
assert_eq!(header.version, 536870912);
assert_eq!(
header.prev_block_hash,
Hash256::new(
&hex::decode("21e4e008ffdaa5382ffe57d4419641dc89c7f610906104000000000000000000")
.unwrap()
)
);
assert_eq!(
header.merkle_root_hash,
Hash256::new(
&hex::decode("2e13f67bd6f0944b17f385008364b9120cfc362c546a384db7066b02eb938e88")
.unwrap()
)
);
assert_eq!(header.time, 1576880064);
assert_eq!(header.bits, Bytes::new(&hex::decode("d0bc1517").unwrap()));
assert_eq!(header.nonce, Bytes::new(&hex::decode("6129429F").unwrap()));
assert_eq!(
header.hash,
Hash256::new(
&hex::decode("3d99801f2d28568a14023868d903722cf890340a161502000000000000000000")
.unwrap()
)
);
let data = include_bytes!(
"../test_data/blk_0000000000000000000b0a682f47f187a712c42badd4ca1989c494d401457c3f.bin"
);
let (_, header) = parse_block_header(data).unwrap();
assert_eq!(header.version, 1073725440);
assert_eq!(
header.prev_block_hash,
Hash256::new(
&hex::decode("66c810e611643b26ddc0bf0a4d9fc21f409d5ad9a6ac09000000000000000000")
.unwrap()
)
);
assert_eq!(
header.merkle_root_hash,
Hash256::new(
&hex::decode("96cf49dcc64a3f405ca144c9e61752896f5bcde78fe0089b61952d48ee0826b7")
.unwrap()
)
);
assert_eq!(header.time, 1576151029);
assert_eq!(header.bits, Bytes::new(&hex::decode("d2db1517").unwrap()));
assert_eq!(header.nonce, Bytes::new(&hex::decode("9AB9308D").unwrap()));
assert_eq!(
header.hash,
Hash256::new(
&hex::decode("3f7c4501d494c48919cad4ad2bc412a787f1472f680a0b000000000000000000")
.unwrap()
)
);
let data = include_bytes!(
"../test_data/blk_000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f.bin"
);
let (_, header) = parse_block_header(data).unwrap();
assert_eq!(header.version, 1);
assert_eq!(
header.prev_block_hash,
Hash256::new(
&hex::decode("0000000000000000000000000000000000000000000000000000000000000000")
.unwrap()
)
);
assert_eq!(
header.merkle_root_hash,
Hash256::new(
&hex::decode("3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a")
.unwrap()
)
);
assert_eq!(header.time, 1231006505);
assert_eq!(header.bits, Bytes::new(&hex::decode("ffff001d").unwrap()));
assert_eq!(header.nonce, Bytes::new(&hex::decode("1DAC2B7C").unwrap()));
assert_eq!(
header.hash,
Hash256::new(
&hex::decode("6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000")
.unwrap()
)
);
} | rust_cleaned_test_functions.jsonl/69152 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2057
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
7113,
8757,
368,
341,
286,
442,
16187,
448,
504,
13137,
35789,
6220,
510,
1789,
286,
1077,
821,
284,
2924,
12524,
33673,
310,
7005,
1944,
1769,
14,
34989,
62,
15,
15,
15,
15,
15,
15,
15... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_anonymous_ip() {
let buffer = std::fs::read("./testdata/GeoIP2-Anonymous-IP-Test.mmdb").unwrap();
let reader = Reader::<AnonymousIP>::from_bytes(&buffer).unwrap();
{
let result = reader
.lookup(IpAddr::from_str("81.2.69.0").unwrap())
.unwrap();
assert_eq!(result.is_anonymous, Some(true));
assert_eq!(result.is_anonymous_vpn, Some(true));
assert_eq!(result.is_hosting_provider, Some(true));
assert_eq!(result.is_public_proxy, Some(true));
assert_eq!(result.is_tor_exit_node, Some(true));
assert_eq!(result.is_residential_proxy, Some(true));
}
{
let result = reader
.lookup(IpAddr::from_str("186.30.236.0").unwrap())
.unwrap();
assert_eq!(result.is_anonymous, Some(true));
assert_eq!(result.is_anonymous_vpn, None);
assert_eq!(result.is_hosting_provider, None);
assert_eq!(result.is_public_proxy, Some(true));
assert_eq!(result.is_tor_exit_node, None);
assert_eq!(result.is_residential_proxy, None);
}
} | rust_cleaned_test_functions.jsonl/37380 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 631
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12008,
9757,
10385,
368,
341,
286,
1077,
4147,
284,
1460,
486,
3848,
486,
878,
13988,
92425,
14,
37344,
3298,
17,
12,
32684,
12,
3298,
12,
2271,
37008,
1999,
1827,
15454,
543,
286,
1077,
6604,
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_dep_set_inter() {
let s = |x: &[u64]| DepSet::from(HashTrieSet::from_iter(x.iter().copied().map(Dep::new)));
assert_eq!(s(&[4, 7]).intersect(&s(&[1, 4, 3])), s(&[4]));
assert_eq!(s(&[1, 4, 3]).intersect(&s(&[4, 7])), s(&[4]));
} | rust_cleaned_test_functions.jsonl/3507 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 152
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
49258,
2602,
15318,
368,
341,
286,
1077,
274,
284,
760,
87,
25,
44590,
84,
21,
19,
29685,
4148,
1649,
486,
1499,
7,
6370,
51,
7231,
1649,
486,
1499,
11723,
2075,
19471,
1005,
37728,
1122,
1005,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_adjust_lockouts_after_replay_empty() {
let mut tower = Tower::new_for_tests(10, 0.9);
let mut slot_history = SlotHistory::default();
slot_history.add(0);
let replayed_root_slot = 0;
tower = tower
.adjust_lockouts_after_replay(replayed_root_slot, &slot_history)
.unwrap();
assert_eq!(tower.voted_slots(), vec![] as Vec<Slot>);
assert_eq!(tower.root(), replayed_root_slot);
} | rust_cleaned_test_functions.jsonl/61171 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 227
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
44153,
9818,
11672,
19844,
1288,
1363,
15124,
368,
341,
286,
1077,
5206,
21271,
284,
21938,
486,
931,
5478,
32509,
7,
16,
15,
11,
220,
15,
13,
24,
626,
286,
1077,
5206,
9446,
19802,
284,
31316,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_message_data_offsets() {
let offsets = Ed25519SignatureOffsets {
message_data_offset: 99,
message_data_size: 1,
..Ed25519SignatureOffsets::default()
};
assert_eq!(test_case(1, &offsets), Err(Ed25519Error::InvalidSignature));
let offsets = Ed25519SignatureOffsets {
message_data_offset: 100,
message_data_size: 1,
..Ed25519SignatureOffsets::default()
};
assert_eq!(
test_case(1, &offsets),
Err(Ed25519Error::InvalidDataOffsets)
);
let offsets = Ed25519SignatureOffsets {
message_data_offset: 100,
message_data_size: 1000,
..Ed25519SignatureOffsets::default()
};
assert_eq!(
test_case(1, &offsets),
Err(Ed25519Error::InvalidDataOffsets)
);
let offsets = Ed25519SignatureOffsets {
message_data_offset: std::u16::MAX,
message_data_size: std::u16::MAX,
..Ed25519SignatureOffsets::default()
};
assert_eq!(
test_case(1, &offsets),
Err(Ed25519Error::InvalidDataOffsets)
);
} | rust_cleaned_test_functions.jsonl/44026 | {
"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,
6462,
1769,
56924,
368,
341,
286,
1077,
35046,
284,
3199,
17,
20,
20,
16,
24,
25088,
81095,
341,
310,
1943,
1769,
6917,
25,
220,
24,
24,
345,
310,
1943,
1769,
2368,
25,
220,
16,
345,
310,
52... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_lutimes() {
let tempdir = tempfile::tempdir().unwrap();
let target = tempdir.path().join("target");
let fullpath = tempdir.path().join("symlink");
drop(File::create(&target).unwrap());
symlink(&target, &fullpath).unwrap();
let exp_target_metadata = fs::symlink_metadata(&target).unwrap();
lutimes(&fullpath, &TimeVal::seconds(4560), &TimeVal::seconds(1230)).unwrap();
assert_times_eq(4560, 1230, &fs::symlink_metadata(&fullpath).unwrap());
let target_metadata = fs::symlink_metadata(&target).unwrap();
assert_eq!(exp_target_metadata.accessed().unwrap(), target_metadata.accessed().unwrap(),
"atime of symlink target was unexpectedly modified");
assert_eq!(exp_target_metadata.modified().unwrap(), target_metadata.modified().unwrap(),
"mtime of symlink target was unexpectedly modified");
} | rust_cleaned_test_functions.jsonl/48644 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 328
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
907,
332,
1733,
368,
341,
262,
1077,
2730,
3741,
284,
54819,
486,
3888,
3741,
1005,
15454,
543,
262,
1077,
2169,
284,
2730,
3741,
3875,
1005,
5987,
445,
5657,
797,
262,
1077,
2480,
2343,
284,
27... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_angle_clock() {
let test_cases = vec![
(3, 30, 75.0),
(12, 30, 165.0),
(4, 50, 155.0),
(3, 15, 7.5),
(12, 0, 0.0),
];
for (h,m,expect) in test_cases {
let t = Solution::angle_clock(h,m);
assert_eq!(t-expect < 1e-5, true, "h:{}. m:{}, result:{}", h, m, t);
}
} | rust_cleaned_test_functions.jsonl/114561 | {
"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,
21727,
23062,
368,
341,
286,
1077,
1273,
41427,
284,
7486,
90515,
310,
320,
18,
11,
220,
18,
15,
11,
220,
22,
20,
13,
15,
1326,
310,
320,
16,
17,
11,
220,
18,
15,
11,
220,
16,
21,
20,
13... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_sequence_parse() {
assert_parses_cb(
&[
(Ok((1, 2)), b"\x30\x06\x02\x01\x01\x02\x01\x02"),
(
Err(ParseError::new(ParseErrorKind::ShortData)),
b"\x30\x03\x02\x01\x01",
),
(
Err(ParseError::new(ParseErrorKind::ExtraData)),
b"\x30\x07\x02\x01\x01\x02\x01\x02\x00",
),
],
|p| {
p.read_element::<Sequence>()?
.parse(|p| Ok((p.read_element::<i64>()?, p.read_element::<i64>()?)))
},
);
} | rust_cleaned_test_functions.jsonl/40838 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 464
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
23735,
21039,
368,
341,
286,
2060,
77113,
288,
16450,
1006,
310,
609,
9640,
394,
320,
11578,
1188,
16,
11,
220,
17,
5731,
293,
11934,
87,
18,
15,
3462,
15,
21,
3462,
15,
17,
3462,
15,
16,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_from_char() {
assert_eq!(TinyString::<[u8; 16]>::from('a'), 'a'.to_string());
let s: TinyString<[u8; 16]> = 'x'.into();
assert_eq!(s, 'x'.to_string());
} | rust_cleaned_test_functions.jsonl/3650 | {
"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,
5673,
9232,
368,
341,
6948,
10714,
10297,
85693,
703,
27638,
58,
84,
23,
26,
220,
16,
21,
60,
6831,
1499,
492,
64,
4567,
364,
64,
4427,
983,
3904,
1423,
10217,
274,
25,
47974,
703,
66746,
84,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_get_identified_any_client_state_ok() {
let range = (0..10).into_iter().collect::<Vec<u8>>();
let mut client_state_vec = vec![];
let mut gp_client_id_vec = vec![];
for index in range.clone() {
let gp_client_id = ClientId::new(ClientType::Grandpa, index as u64).unwrap();
let gp_client_state = GPClientState::new(
ChainId::new("ibc".to_string(), 0),
Height::new(0, index as u64),
Height::new(0, index as u64),
)
.unwrap();
let client_state = AnyClientState::Grandpa(gp_client_state);
gp_client_id_vec.push(gp_client_id);
client_state_vec.push(client_state);
}
let mut context: Context<Test> = Context::new();
new_test_ext().execute_with(|| {
for index in 0..range.len() {
assert_eq!(
context
.store_client_state(
gp_client_id_vec[index].clone(),
client_state_vec[index].clone()
)
.is_ok(),
true
);
}
let result = Pallet::<Test>::get_identified_any_client_state();
assert_eq!(result.len(), range.len());
for index in range {
let (client_id, client_state) = result[index as usize].clone();
let client_id =
ClientId::from_str(String::from_utf8(client_id).unwrap().as_str()).unwrap();
let client_state = AnyClientState::decode_vec(&*client_state).unwrap();
assert_eq!(gp_client_id_vec.iter().find(|&val| val == &client_id).is_some(), true);
assert_eq!(client_state_vec.iter().find(|&val| val == &client_state).is_some(), true);
}
})
} | rust_cleaned_test_functions.jsonl/60062 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 623
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
38399,
1870,
37248,
8179,
4387,
19817,
368,
341,
10217,
2088,
284,
320,
15,
496,
16,
15,
568,
18122,
11723,
1005,
17384,
27638,
10050,
34837,
23,
79279,
10217,
5206,
2943,
4387,
13251,
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... | 5 |
#[test]
fn test_parse_header_good() -> Result<()> {
let headers = headers();
assert_eq!(parse_header::<i64>(&headers, "x-ratelimit-limit")?.unwrap(), 5);
assert_eq!(
parse_header::<i64>(&headers, "x-ratelimit-remaining")?.unwrap(),
4,
);
assert_eq!(
parse_header::<f64>(&headers, "x-ratelimit-reset")?.unwrap(),
1_560_704_880.423,
);
Ok(())
} | rust_cleaned_test_functions.jsonl/27072 | {
"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,
21039,
8757,
44781,
368,
1464,
5714,
71698,
341,
286,
1077,
7102,
284,
7102,
1428,
286,
2060,
10714,
10297,
6400,
8757,
27638,
72,
21,
19,
44784,
7713,
11,
330,
87,
3795,
83326,
2353,
71159,
899,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
#[test]
fn test_more_keys() {
let input = input_from(&[(1, vec!['A', 'E']), (2, vec!['D', 'G'])]);
let expected = expected_from(&[('a', 1), ('e', 1), ('d', 2), ('g', 2)]);
assert_eq!(expected, etl::transform(&input));
} | rust_cleaned_test_functions.jsonl/19632 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 109
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36664,
12631,
368,
341,
262,
1077,
1946,
284,
1946,
5673,
2099,
9697,
16,
11,
7486,
0,
677,
32,
516,
364,
36,
32087,
320,
17,
11,
7486,
0,
677,
35,
516,
364,
38,
5078,
10149,
262,
1077,
3601... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_division_by_zero() {
Variant::VLong(1)
.divide(Variant::VSingle(0.0))
.expect_err("Division by zero");
Variant::VLong(1)
.divide(Variant::VDouble(0.0))
.expect_err("Division by zero");
Variant::VLong(1)
.divide(Variant::VInteger(0))
.expect_err("Division by zero");
Variant::VLong(1)
.divide(Variant::VLong(0))
.expect_err("Division by zero");
} | rust_cleaned_test_functions.jsonl/84635 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 382
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16237,
1816,
3710,
19359,
368,
341,
394,
39292,
486,
53,
6583,
7,
16,
340,
503,
659,
59394,
12410,
15341,
486,
53,
10888,
7,
15,
13,
15,
1171,
503,
659,
17119,
9266,
445,
51237,
553,
7168,
797... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_bit_vec_extend() {
let mut bit_vec = BitVec::from_bytes(&[0b10110110, 0b00000000, 0b11111111]);
let ext = BitVec::from_bytes(&[0b01001001, 0b10010010, 0b10111101]);
bit_vec.extend(ext.iter());
assert_eq!(bit_vec, BitVec::from_bytes(&[0b10110110, 0b00000000, 0b11111111,
0b01001001, 0b10010010, 0b10111101]));
} | rust_cleaned_test_functions.jsonl/62103 | {
"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,
13996,
13251,
70265,
368,
341,
286,
1077,
5206,
2699,
13251,
284,
6495,
10050,
486,
1499,
12524,
2099,
58,
15,
65,
16,
15,
16,
16,
15,
16,
16,
15,
11,
220,
15,
65,
15,
15,
15,
15,
15,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_four_bit_adder() {
for (a, b) in (0..std::u8::MAX).map(|n| (n >> 4, n & 15)) {
let nib_a = Nibble::from_u8(a);
let nib_b = Nibble::from_u8(b);
let (result, carry) = four_bit_adder(nib_a, nib_b, false);
assert_eq!(a + b, result.to_u8(carry));
let (result, carry) = four_bit_adder(nib_a, nib_b, true);
assert_eq!(a + b + 1, result.to_u8(carry));
}
} | rust_cleaned_test_functions.jsonl/90318 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 200
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
56142,
13996,
2891,
261,
368,
341,
220,
369,
320,
64,
11,
293,
8,
304,
320,
15,
496,
1834,
486,
84,
23,
486,
10586,
568,
2186,
22428,
77,
91,
320,
77,
3578,
220,
19,
11,
308,
609,
220,
16,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_regex_selection() -> Result<()> {
let df = df![
"anton" => [1, 2, 3],
"arnold schwars" => [1, 2, 3],
"annie" => [1, 2, 3]
]?;
let out = df.lazy().select([col("^a.*o.*$")]).collect()?;
assert_eq!(out.get_column_names(), &["anton", "arnold schwars"]);
Ok(())
} | rust_cleaned_test_functions.jsonl/159 | {
"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,
41832,
23672,
368,
1464,
5714,
71698,
341,
262,
1077,
6764,
284,
6764,
90515,
262,
330,
30954,
1,
589,
508,
16,
11,
220,
17,
11,
220,
18,
1259,
262,
330,
1885,
813,
35515,
1561,
1,
589,
508,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_script_find_and_remove() {
let mut v = vec![101u8, 102, 103, 104, 102, 103, 104, 102, 103, 104, 105, 106, 107, 108, 109];
assert_eq!(script_find_and_remove(&mut v, &[]), 0);
assert_eq!(script_find_and_remove(&mut v, &[105, 105, 105]), 0);
assert_eq!(v, vec![101, 102, 103, 104, 102, 103, 104, 102, 103, 104, 105, 106, 107, 108, 109]);
assert_eq!(script_find_and_remove(&mut v, &[105, 106, 107]), 1);
assert_eq!(v, vec![101, 102, 103, 104, 102, 103, 104, 102, 103, 104, 108, 109]);
assert_eq!(script_find_and_remove(&mut v, &[104, 108, 109]), 1);
assert_eq!(v, vec![101, 102, 103, 104, 102, 103, 104, 102, 103]);
assert_eq!(script_find_and_remove(&mut v, &[101]), 1);
assert_eq!(v, vec![102, 103, 104, 102, 103, 104, 102, 103]);
assert_eq!(script_find_and_remove(&mut v, &[102]), 3);
assert_eq!(v, vec![103, 104, 103, 104, 103]);
assert_eq!(script_find_and_remove(&mut v, &[103, 104]), 2);
assert_eq!(v, vec![103]);
assert_eq!(script_find_and_remove(&mut v, &[105, 105, 5]), 0);
assert_eq!(script_find_and_remove(&mut v, &[105]), 0);
assert_eq!(script_find_and_remove(&mut v, &[103]), 1);
assert_eq!(v, Vec::<u8>::new());
assert_eq!(script_find_and_remove(&mut v, &[105, 105, 5]), 0);
assert_eq!(script_find_and_remove(&mut v, &[105]), 0);
} | rust_cleaned_test_functions.jsonl/80480 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 688
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14660,
21814,
8378,
18193,
368,
341,
286,
1077,
5206,
348,
284,
7486,
20703,
16,
15,
16,
84,
23,
11,
220,
16,
15,
17,
11,
220,
16,
15,
18,
11,
220,
16,
15,
19,
11,
220,
16,
15,
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... | 1 |
#[test]
fn test_lohit() {
run_test(
&TEST_DATA,
"harfbuzz/good-lohit.te",
"telugu/lohit_te.ttf",
&[JOINER_GLYPH_INDEX],
73,
);
} | rust_cleaned_test_functions.jsonl/91174 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 216
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5560,
22492,
368,
341,
394,
1598,
4452,
1006,
503,
609,
10033,
7896,
345,
503,
330,
12982,
10798,
8889,
4846,
1386,
26480,
22492,
31853,
756,
503,
330,
22924,
29785,
14,
385,
22492,
38678,
45192,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_get_container_title() {
let app = App::default();
assert_eq!(
get_container_title(&app, 3, "hello"),
"Pods (ns: all) [0] -> Containers [3] hello"
);
} | rust_cleaned_test_functions.jsonl/66714 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 93
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
15847,
6112,
368,
341,
262,
1077,
906,
284,
1845,
486,
2258,
543,
262,
2060,
10714,
33673,
414,
633,
15847,
6112,
2099,
676,
11,
220,
18,
11,
330,
14990,
4461,
414,
330,
23527,
82,
320,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_parse_css_border_radius_1() {
assert_eq!(parse_css_border_radius("15px"), Ok(StyleBorderRadius::uniform(PixelValue::px(15.0))));
} | rust_cleaned_test_functions.jsonl/37117 | {
"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,
21039,
25924,
31940,
28936,
62,
16,
368,
341,
286,
2060,
10714,
10297,
6400,
25924,
31940,
28936,
445,
16,
20,
1767,
3975,
7622,
7,
2323,
10691,
8289,
486,
38351,
5304,
5941,
1130,
486,
1767,
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 |
#[test]
fn test_lexicographical_partition_single_column() -> Result<()> {
let input = vec![SortColumn {
values: Arc::new(Int64Array::from(vec![1, 2, 2, 2, 2, 2, 2, 2, 9]))
as ArrayRef,
options: Some(SortOptions {
descending: false,
nulls_first: true,
}),
}];
{
let results = lexicographical_partition_points(&input)?;
assert_eq!(vec![0, 1, 8, 9], results);
}
{
let results = lexicographical_partition_ranges(&input)?;
assert_eq!(
vec![(0_usize..1_usize), (1_usize..8_usize), (8_usize..9_usize)],
results
);
}
Ok(())
} | rust_cleaned_test_functions.jsonl/119213 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 437
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
74547,
292,
31177,
43840,
19487,
8744,
368,
1464,
5714,
71698,
341,
286,
1077,
1946,
284,
7486,
20703,
10231,
2933,
341,
310,
2750,
25,
19689,
486,
931,
24123,
21,
19,
1857,
486,
1499,
25592,
2070... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_try_from_put_balloon() {
let (mut sender, receiver) = UnixStream::pair().unwrap();
let mut connection = HttpConnection::new(receiver);
let body = "{ \
\"amount_mib\": 0, \
\"deflate_on_oom\": false, \
\"stats_polling_interval_s\": 0 \
}";
sender
.write_all(http_request("PUT", "/balloon", Some(&body)).as_bytes())
.unwrap();
assert!(connection.try_read().is_ok());
let req = connection.pop_parsed_request().unwrap();
assert!(ParsedRequest::try_from_request(&req).is_ok());
} | rust_cleaned_test_functions.jsonl/106578 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 303
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
53283,
5673,
15557,
56441,
31335,
368,
341,
286,
1077,
320,
6984,
4646,
11,
13964,
8,
284,
46995,
3027,
486,
12670,
1005,
15454,
543,
286,
1077,
5206,
3633,
284,
4823,
4526,
486,
931,
78126,
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_node_with_smaller_term_can_complete_election() {
let l = default_logger();
let mut n1 = new_test_raft_with_prevote(1, vec![1, 2, 3], 10, 1, new_storage(), true, &l);
let mut n2 = new_test_raft_with_prevote(2, vec![1, 2, 3], 10, 1, new_storage(), true, &l);
let mut n3 = new_test_raft_with_prevote(3, vec![1, 2, 3], 10, 1, new_storage(), true, &l);
n1.become_follower(1, INVALID_ID);
n2.become_follower(1, INVALID_ID);
n3.become_follower(1, INVALID_ID);
// cause a network partition to isolate node 3
let mut config = Network::default_config();
config.pre_vote = true;
let mut nt = Network::new_with_config(vec![Some(n1), Some(n2), Some(n3)], &config, &l);
nt.cut(1, 3);
nt.cut(2, 3);
nt.send(vec![new_message(1, 1, MessageType::MsgHup, 0)]);
assert_eq!(nt.peers[&1].state, StateRole::Leader);
assert_eq!(nt.peers[&2].state, StateRole::Follower);
nt.send(vec![new_message(3, 3, MessageType::MsgHup, 0)]);
assert_eq!(nt.peers[&3].state, StateRole::PreCandidate);
nt.send(vec![new_message(2, 2, MessageType::MsgHup, 0)]);
// check whether the term values are expected
// a.Term == 3
// b.Term == 3
// c.Term == 1
assert_eq!(nt.peers[&1].term, 3);
assert_eq!(nt.peers[&2].term, 3);
assert_eq!(nt.peers[&3].term, 1);
// check state
// a == follower
// b == leader
// c == pre-candidate
assert_eq!(nt.peers[&1].state, StateRole::Follower);
assert_eq!(nt.peers[&2].state, StateRole::Leader);
assert_eq!(nt.peers[&3].state, StateRole::PreCandidate);
// recover the network then immediately isolate b which is currently
nt.recover();
nt.cut(2, 1);
nt.cut(2, 3);
// call for election
nt.send(vec![new_message(3, 3, MessageType::MsgHup, 0)]);
nt.send(vec![new_message(1, 1, MessageType::MsgHup, 0)]);
// do we have a leader?
assert!(
nt.peers[&1].state == StateRole::Leader || nt.peers[&3].state == StateRole::Leader,
"no leader"
);
} | rust_cleaned_test_functions.jsonl/19173 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 924
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5084,
6615,
15874,
13956,
17464,
27421,
27675,
2204,
1170,
368,
341,
262,
1077,
326,
284,
1638,
27413,
543,
262,
1077,
5206,
308,
16,
284,
501,
4452,
62,
2944,
6615,
25566,
1272,
7,
16,
11,
7486... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_arena_default() {
let a = Arena::<usize>::default();
assert!(a.is_empty());
assert_eq!(0, a.len());
assert_eq!(0, a.capacity());
} | rust_cleaned_test_functions.jsonl/30751 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 100
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
30527,
9993,
368,
341,
286,
1077,
264,
284,
27047,
27638,
51878,
6831,
2258,
543,
286,
2060,
10297,
64,
2079,
15124,
1423,
286,
2060,
10714,
10297,
15,
11,
264,
19406,
1423,
286,
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 |
#[test]
fn test_read_uint8() {
let test_hex: &str = "01000200000003";
let test_bytes: Vec<u8> = hex::decode(test_hex).expect("");
let mut binary_parser = BinaryParser::from(test_bytes.as_ref());
let result = binary_parser.read_uint8();
assert!(result.is_ok());
assert_eq!(result, Ok(1));
} | rust_cleaned_test_functions.jsonl/20414 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 163
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
15807,
23,
368,
341,
286,
1077,
1273,
32655,
25,
609,
495,
284,
330,
15,
16,
15,
15,
15,
17,
15,
15,
15,
15,
15,
15,
15,
18,
876,
286,
1077,
1273,
12524,
25,
11312,
34837,
23,
29,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_anonymous_fn() -> Result<(), Box<EvalAltResult>> {
let calc_func = Func::<(INT, INT, INT), INT>::create_from_script(
Engine::new(),
"fn calc(x, y, z,) { (x + y) * z }",
"calc",
)?;
assert_eq!(calc_func(42, 123, 9)?, 1485);
let calc_func = Func::<(INT, String, INT), INT>::create_from_script(
Engine::new(),
"fn calc(x, y, z) { (x + len(y)) * z }",
"calc",
)?;
assert_eq!(calc_func(42, "hello".to_string(), 9)?, 423);
let calc_func = Func::<(INT, String, INT), INT>::create_from_script(
Engine::new(),
"private fn calc(x, y, z) { (x + len(y)) * z }",
"calc",
)?;
assert_eq!(calc_func(42, "hello".to_string(), 9)?, 423);
Ok(())
} | rust_cleaned_test_functions.jsonl/5443 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 389
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12008,
9757,
15246,
368,
1464,
5714,
68843,
8261,
23835,
831,
26017,
2077,
2452,
341,
262,
1077,
10035,
9596,
284,
18016,
27638,
7,
3221,
11,
9221,
11,
9221,
701,
9221,
6831,
3182,
5673,
14660,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
#[test]
fn test_event_with_description() {
let mut event = Event::new("error");
event.with_description("description");
assert!(event
.into_query()
.build()
.unwrap()
.get()
.starts_with("event title=\"error\",description=\"description\" "))
} | rust_cleaned_test_functions.jsonl/77369 | {
"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,
6748,
6615,
11448,
368,
341,
286,
1077,
5206,
1538,
284,
3665,
486,
931,
445,
841,
797,
286,
1538,
18164,
11448,
445,
4684,
797,
286,
2060,
10297,
3087,
198,
310,
659,
18122,
5738,
741,
310,
659... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_decimal_equal() {
let a = create_decimal_array(&[Some(8_887_000_000), Some(-8_887_000_000)]);
let b = create_decimal_array(&[Some(8_887_000_000), Some(-8_887_000_000)]);
test_equal(&a, &b, true);
let b = create_decimal_array(&[Some(15_887_000_000), Some(-8_887_000_000)]);
test_equal(&a, &b, false);
} | rust_cleaned_test_functions.jsonl/24222 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 183
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
74429,
11478,
368,
341,
286,
1077,
264,
284,
1855,
74429,
3858,
2099,
58,
8373,
7,
23,
62,
23,
23,
22,
62,
15,
15,
15,
62,
15,
15,
15,
701,
4329,
4080,
23,
62,
23,
23,
22,
62,
15,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_set_weight() {
let new_weight: f32 = 129.4;
let mut user = User::new(NAME.into(), AGE, WEIGHT);
user.set_weight(new_weight);
assert!((user.weight() - new_weight).abs() < f32::EPSILON);
} | rust_cleaned_test_functions.jsonl/133583 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 100
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2602,
15876,
368,
341,
262,
1077,
501,
15876,
25,
282,
18,
17,
284,
220,
16,
17,
24,
13,
19,
280,
262,
1077,
5206,
1196,
284,
2657,
486,
931,
72383,
39860,
1507,
90588,
11,
95820,
317,
262,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_vec3mask_hash() {
use std::collections::hash_map::DefaultHasher;
use std::hash::Hash;
use std::hash::Hasher;
let a = Vec3AMask::new(true, false, true);
let b = Vec3AMask::new(true, false, true);
let c = Vec3AMask::new(false, true, true);
let mut hasher = DefaultHasher::new();
a.hash(&mut hasher);
let a_hashed = hasher.finish();
let mut hasher = DefaultHasher::new();
b.hash(&mut hasher);
let b_hashed = hasher.finish();
let mut hasher = DefaultHasher::new();
c.hash(&mut hasher);
let c_hashed = hasher.finish();
assert_eq!(a, b);
assert_eq!(a_hashed, b_hashed);
assert_ne!(a, c);
assert_ne!(a_hashed, c_hashed);
} | rust_cleaned_test_functions.jsonl/23503 | {
"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,
13251,
18,
11258,
8950,
368,
341,
262,
990,
1460,
486,
51137,
486,
8296,
5376,
486,
3675,
6370,
261,
280,
262,
990,
1460,
486,
8296,
486,
6370,
280,
262,
990,
1460,
486,
8296,
486,
6370,
261,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_json_regexp_literal() {
let n = RegexpLit {
base: BaseNode::default(),
value: ".*".to_string(),
};
let serialized = serde_json::to_string(&n).unwrap();
assert_eq!(serialized, r#"{"type":"RegexpLiteral","value":".*"}"#);
let deserialized: RegexpLit = serde_json::from_str(serialized.as_str()).unwrap();
assert_eq!(deserialized, n)
} | rust_cleaned_test_functions.jsonl/40447 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 181
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9455,
4920,
4580,
34100,
368,
341,
262,
1077,
308,
284,
3184,
4580,
68954,
341,
286,
2331,
25,
5351,
1955,
486,
2258,
3148,
286,
897,
25,
330,
4908,
3263,
983,
3904,
3148,
262,
2605,
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_vec3_serde() {
let a = Vec3::new(1.0, 2.0, 3.0);
let serialized = serde_json::to_string(&a).unwrap();
assert_eq!(serialized, "[1.0,2.0,3.0]");
let deserialized = serde_json::from_str(&serialized).unwrap();
assert_eq!(a, deserialized);
let deserialized = serde_json::from_str::<Vec3>("[]");
assert!(deserialized.is_err());
let deserialized = serde_json::from_str::<Vec3>("[1.0]");
assert!(deserialized.is_err());
let deserialized = serde_json::from_str::<Vec3>("[1.0,2.0]");
assert!(deserialized.is_err());
let deserialized = serde_json::from_str::<Vec3>("[1.0,2.0,3.0,4.0]");
assert!(deserialized.is_err());
} | rust_cleaned_test_functions.jsonl/48605 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 326
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13251,
18,
75861,
450,
368,
341,
262,
1077,
264,
284,
11312,
18,
486,
931,
7,
16,
13,
15,
11,
220,
17,
13,
15,
11,
220,
18,
13,
15,
317,
262,
1077,
32916,
284,
61570,
9455,
486,
983,
3904,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_mmap_path() {
assert_eq!(MMapPath::from("[stack]").unwrap(), MMapPath::Stack);
assert_eq!(MMapPath::from("[foo]").unwrap(), MMapPath::Other("foo".to_owned()));
assert_eq!(MMapPath::from("").unwrap(), MMapPath::Anonymous);
assert_eq!(MMapPath::from("[stack:154]").unwrap(), MMapPath::TStack(154));
assert_eq!(
MMapPath::from("/lib/libfoo.so").unwrap(),
MMapPath::Path(PathBuf::from("/lib/libfoo.so"))
);
} | rust_cleaned_test_functions.jsonl/17544 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 210
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
717,
2186,
2638,
368,
341,
262,
2060,
10714,
10297,
44,
2227,
1820,
486,
1499,
10937,
7693,
44891,
15454,
1507,
386,
2227,
1820,
486,
4336,
317,
262,
2060,
10714,
10297,
44,
2227,
1820,
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_lambda_lift_nested_lambdas_happy() {
dangerously_reset_gensym_count();
let exp = parse(
&lexpr::from_str(
r#"(let ((f (lambda ((x : int)) : (-> int int)
(lambda ((y : int)) : int (+ x y)))))
((f 4) 3))"#,
)
.unwrap(),
)
.unwrap();
let cc_exp = closure_convert(&exp).unwrap();
let expected_exp = parse(
&lexpr::from_str(
r#"(let ((f (pack (make-tuple func11 (make-record))
(record)
(exists T5 (tuple (-> T5 int (exists T4 (tuple (-> T4 int int) T4))) T5)))))
(unpack (temp6
(unpack (temp7 f T8)
((tuple-ref temp7 0) (tuple-ref temp7 1) 4))
T9)
((tuple-ref temp6 0) (tuple-ref temp6 1) 3)))"#,
)
.unwrap(),
)
.unwrap();
let prog = lambda_lift(&cc_exp).unwrap();
assert_eq!(prog.fns.len(), 2);
assert_eq!(prog.exp, expected_exp);
assert_eq!(type_check_prog(&prog).is_err(), false);
} | rust_cleaned_test_functions.jsonl/98587 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 545
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
51884,
87004,
66279,
907,
2969,
34889,
1523,
11144,
368,
341,
262,
58494,
18983,
1889,
724,
1600,
3180,
1428,
262,
1077,
1343,
284,
4715,
1006,
286,
609,
2571,
649,
486,
1499,
2895,
1006,
310,
435... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_peer_down_notification() {
let input = "4f424d500107006400000033800c6184b9c2000c602cbf4f072f3ae149d23486024bc3dadfc4000a69732d63632d626d7031c677060bdd020a9e92be000200de2e3180df3369000000000000000000000000000c726f7574652d76696577733500000001030000003302000000000000000000000000000000000000000000003fda060e00000da30000000061523c36000c0e1c0200000a";
let decoded = hex::decode(input).unwrap();
let mut reader = DataBytes::new(&decoded);
let _header = parse_openbmp_header(&mut reader).unwrap();
let msg = parse_bmp_msg(&mut reader).unwrap();
dbg!(msg);
} | rust_cleaned_test_functions.jsonl/120446 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 267
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
45159,
13998,
34296,
368,
341,
286,
1077,
1946,
284,
330,
19,
69,
19,
17,
19,
67,
20,
15,
15,
16,
15,
22,
15,
15,
21,
19,
15,
15,
15,
15,
15,
15,
18,
18,
23,
15,
15,
66,
21,
16,
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_read_to_end_capacity() -> io::Result<()> {
let input = &b"foo"[..];
// exact size needed.
let mut vec1 = Vec::with_capacity(input.len());
ExampleSliceReader { slice: input }.read_to_end(&mut vec1)?;
assert_eq!(vec1.len(), input.len());
assert_eq!(vec1.capacity(), input.len(), "did not allocate more");
Ok(())
} | rust_cleaned_test_functions.jsonl/13642 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 153
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
2346,
6213,
35603,
368,
1464,
6399,
486,
2077,
71698,
341,
262,
1077,
1946,
284,
609,
65,
1,
7975,
36864,
496,
4821,
1066,
262,
442,
4734,
1379,
4362,
624,
262,
1077,
5206,
7486,
16,
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_0xa9_lda_zero_flag() {
let bus = Bus::new();
let mut cpu = CPU::new(bus);
cpu.load(vec![0xa9, 0x00, 0x00]);
cpu.reset();
cpu.program_counter = 0x0600;
cpu.run();
assert!(cpu.status & 0b0000_0010 == 0b10);
} | rust_cleaned_test_functions.jsonl/56540 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 158
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
15,
9591,
24,
50573,
64,
19359,
10933,
368,
341,
286,
1077,
5828,
284,
18598,
486,
931,
543,
286,
1077,
5206,
17319,
284,
13940,
486,
931,
60872,
626,
286,
17319,
5104,
25592,
20703,
15,
959... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_remove_last() {
let mut cache = Cache::with_capacity(100);
let dbs = Box::new(DivBufShared::from(vec![0u8; 6]));
let key = Key::Rid(RID(0));
cache.insert(key, dbs);
assert_eq!(cache.remove(&key).unwrap().len(), 6);
assert_eq!(cache.size(), 0);
assert!(cache.lru.is_none());
assert!(cache.mru.is_none());
assert_eq!(cache.size(), 0);
} | rust_cleaned_test_functions.jsonl/90051 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 181
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18193,
12195,
368,
341,
262,
1077,
5206,
6500,
284,
19479,
486,
4197,
35603,
7,
16,
15,
15,
317,
262,
1077,
84581,
284,
8261,
486,
931,
5432,
344,
15064,
16997,
486,
1499,
25592,
20703,
15,
84,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_lastn() {
let m = list_from(&[0,1,2,3,4,5]);
assert_eq!(m.lastn(0).head(), None);
assert_eq!(m.lastn(8), m);
assert_eq!(m.lastn(4), m.tail().tail());
} | rust_cleaned_test_functions.jsonl/64461 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 123
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12195,
77,
368,
341,
286,
1077,
296,
284,
1140,
5673,
2099,
58,
15,
11,
16,
11,
17,
11,
18,
11,
19,
11,
20,
2558,
286,
2060,
10714,
10297,
76,
9110,
77,
7,
15,
568,
1983,
1507,
2240,
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_min_moves2() {
assert_eq!(Solution::min_moves2(vec![1, 2, 3]), 2);
assert_eq!(Solution::min_moves2(vec![1, 10, 2, 9]), 16);
} | rust_cleaned_test_functions.jsonl/71272 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 92
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7260,
45390,
17,
368,
341,
286,
2060,
10714,
10297,
36842,
486,
1065,
45390,
17,
25592,
20703,
16,
11,
220,
17,
11,
220,
18,
9719,
220,
17,
317,
286,
2060,
10714,
10297,
36842,
486,
1065,
45390,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_invalid_upfront_shutdown_script() {
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42, None).unwrap();
// Use a segwit v0 script with an unsupported witness program
let mut open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
open_channel.shutdown_scriptpubkey = Present(Builder::new().push_int(0)
.push_slice(&[0, 0])
.into_script());
nodes[0].node.handle_open_channel(&nodes[0].node.get_our_node_id(), InitFeatures::known(), &open_channel);
let events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
match events[0] {
MessageSendEvent::HandleError { action: ErrorAction::SendErrorMessage { ref msg }, node_id } => {
assert_eq!(node_id, nodes[0].node.get_our_node_id());
assert_eq!(msg.data, "Peer is signaling upfront_shutdown but has provided an unacceptable scriptpubkey format: Script(OP_0 OP_PUSHBYTES_2 0000)");
},
_ => panic!("Unexpected event"),
}
} | rust_cleaned_test_functions.jsonl/6684 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 483
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31433,
8237,
6951,
54804,
14660,
368,
341,
10217,
26023,
1645,
18343,
82,
284,
1855,
45552,
1645,
18343,
82,
7,
17,
317,
10217,
2436,
18343,
82,
284,
1855,
5084,
18343,
82,
7,
17,
11,
609,
5658,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_new_map() {
let mut initial: BTreeMap<i64, StateGroupEntry> = BTreeMap::new();
let mut prev = None;
for i in 0i64..=13i64 {
initial.insert(
i,
StateGroupEntry {
prev_state_group: prev,
state_map: StateMap::new(),
},
);
prev = Some(i)
}
let compressor = Compressor::compress(&initial, &[3, 3]);
let new_state = compressor.new_state_group_map;
let expected_edges: BTreeMap<i64, i64> = vec![
(1, 0),
(2, 1),
(4, 3),
(5, 4),
(6, 3),
(7, 6),
(8, 7),
(9, 6),
(10, 9),
(11, 10),
(13, 12),
]
.into_iter()
.collect();
for sg in 0i64..=13i64 {
assert_eq!(
expected_edges.get(&sg).cloned(),
new_state[&sg].prev_state_group,
"state group {} did not match expected",
sg,
);
}
} | rust_cleaned_test_functions.jsonl/42332 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 562
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5921,
5376,
368,
341,
262,
1077,
5206,
2856,
25,
425,
6533,
2227,
21897,
21,
19,
11,
3234,
2808,
5874,
29,
284,
425,
6533,
2227,
486,
931,
1428,
262,
1077,
5206,
7872,
284,
2240,
280,
262,
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... | 3 |
#[test]
fn test_merge_different_fields() {
let user_no_last_name = json!({
"user_id" : 123,
"first_name" : "John",
"address" : {
"postcode": "abc123",
"numbers": 5.0
}
});
let user_no_address = json!({
"user_id" : 123,
"first_name" : "John",
"last_name": "Smith"
});
let user_no_last_name_as_array = as_array![user_no_last_name];
let user_no_address_as_array = as_array![user_no_address];
let collection_name = Name::from_str("users").unwrap();
let mut ns = Namespace::default();
ns.create_collection(&collection_name, &user_no_last_name)
.unwrap();
assert!(ns
.accepts(&collection_name, &user_no_last_name_as_array)
.is_ok());
assert!(ns
.accepts(&collection_name, &user_no_address_as_array)
.is_err());
ns.try_update(
OptionalMergeStrategy,
&collection_name,
&user_no_address_as_array,
)
.unwrap();
assert!(ns
.accepts(&collection_name, &user_no_last_name_as_array)
.is_ok());
assert!(ns
.accepts(&collection_name, &user_no_address_as_array)
.is_ok());
} | rust_cleaned_test_functions.jsonl/72458 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 747
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20888,
82741,
12132,
368,
341,
286,
1077,
1196,
6536,
12195,
1269,
284,
2951,
0,
2262,
310,
330,
872,
842,
1,
549,
220,
16,
17,
18,
345,
310,
330,
3896,
1269,
1,
549,
330,
13079,
756,
310,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_scope_with_state_root() {
struct State;
let app = App::new()
.scope("/app", |scope| {
scope.with_state("/t1", State, |scope| {
scope
.resource("", |r| r.f(|_| HttpResponse::Ok()))
.resource("/", |r| r.f(|_| HttpResponse::Created()))
})
})
.finish();
let req = TestRequest::with_uri("/app/t1").request();
let resp = app.run(req);
assert_eq!(resp.as_msg().status(), StatusCode::OK);
let req = TestRequest::with_uri("/app/t1/").request();
let resp = app.run(req);
assert_eq!(resp.as_msg().status(), StatusCode::CREATED);
} | rust_cleaned_test_functions.jsonl/22446 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 406
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
23199,
6615,
4387,
12993,
368,
341,
286,
2036,
3234,
401,
286,
1077,
906,
284,
1845,
486,
931,
741,
310,
659,
4186,
4283,
676,
497,
760,
4186,
91,
341,
394,
6891,
18164,
4387,
4283,
83,
16,
49... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_disabled() {
let dir = tempfile::tempdir().expect("Can't create temporary directory");
let config_path = dir.path().join("cache-config.toml");
let config_content = "[cache]\n\
enabled = true\n";
fs::write(&config_path, config_content).expect("Failed to write test config file");
let conf = CacheConfig::from_file(false, Some(&config_path));
assert!(!conf.enabled());
assert!(conf.errors.is_empty());
let config_content = "[cache]\n\
enabled = false\n";
fs::write(&config_path, config_content).expect("Failed to write test config file");
let conf = CacheConfig::from_file(true, Some(&config_path));
assert!(!conf.enabled());
assert!(conf.errors.is_empty());
} | rust_cleaned_test_functions.jsonl/48292 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 309
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
51401,
368,
341,
262,
1077,
5419,
284,
54819,
486,
3888,
3741,
1005,
17119,
445,
6713,
944,
1855,
13340,
6220,
797,
262,
1077,
2193,
2638,
284,
5419,
3875,
1005,
5987,
445,
9360,
25130,
73494,
75,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_get_source_code_1() {
let http_server_guard = crate::test_util::http_server();
let (temp_dir, fetcher) = test_setup();
let fetcher_1 = fetcher.clone();
let fetcher_2 = fetcher.clone();
let module_url =
Url::parse("http://localhost:4545/tests/subdir/mod2.ts").unwrap();
let module_url_1 = module_url.clone();
let module_url_2 = module_url.clone();
let headers_file_name = fetcher.deps_cache.location.join(
fetcher
.deps_cache
.get_cache_filename_with_extension(&module_url, "headers.json"),
);
let headers_file_name_1 = headers_file_name.clone();
let headers_file_name_2 = headers_file_name.clone();
let headers_file_name_3 = headers_file_name;
let fut = fetcher
.get_source_file_async(&module_url, true, false, false)
.then(move |result| {
assert!(result.is_ok());
let r = result.unwrap();
assert_eq!(
r.source_code,
"export { printHello } from \"./print_hello.ts\";\n".as_bytes()
);
assert_eq!(&(r.media_type), &msg::MediaType::TypeScript);
assert!(fs::read_to_string(&headers_file_name_1).is_err());
let _ = fs::write(
&headers_file_name_1,
"{ \"mime_type\": \"text/javascript\" }",
);
fetcher_1.get_source_file_async(&module_url, true, false, false)
})
.then(move |result2| {
assert!(result2.is_ok());
let r2 = result2.unwrap();
assert_eq!(
r2.source_code,
"export { printHello } from \"./print_hello.ts\";\n".as_bytes()
);
assert_eq!(&(r2.media_type), &msg::MediaType::JavaScript);
assert_eq!(
fetcher_2
.get_source_code_headers(&module_url_1)
.mime_type
.unwrap(),
"text/javascript"
);
let _ = fetcher_2.save_source_code_headers(
&module_url_1,
Some("application/json".to_owned()),
None,
None,
);
fetcher_2.get_source_file_async(&module_url_1, true, false, false)
})
.then(move |result3| {
assert!(result3.is_ok());
let r3 = result3.unwrap();
assert_eq!(
r3.source_code,
"export { printHello } from \"./print_hello.ts\";\n".as_bytes()
);
assert_eq!(&(r3.media_type), &msg::MediaType::Json);
assert!(fs::read_to_string(&headers_file_name_2)
.unwrap()
.contains("application/json"));
// and don't use cache
let fetcher = setup_file_fetcher(temp_dir.path());
fetcher.get_source_file_async(&module_url_2, false, false, false)
})
.map(move |result4| {
assert!(result4.is_ok());
let r4 = result4.unwrap();
let expected4 =
"export { printHello } from \"./print_hello.ts\";\n".as_bytes();
assert_eq!(r4.source_code, expected4);
assert_eq!(&(r4.media_type), &msg::MediaType::TypeScript);
assert!(fs::read_to_string(&headers_file_name_3).is_err());
});
// http_util::fetch_sync_string requires tokio
tokio_util::run(fut);
drop(http_server_guard);
} | rust_cleaned_test_functions.jsonl/16751 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1636
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
10347,
4136,
62,
16,
368,
341,
262,
1077,
1758,
12015,
36796,
284,
17717,
486,
1944,
18974,
486,
1254,
12015,
543,
262,
1077,
320,
3888,
4334,
11,
7807,
261,
8,
284,
1273,
21363,
543,
262,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_reject_stale_term_message() {
let mut r = new_test_raft(1, vec![1, 2, 3], 10, 1, new_storage());
r.allow_step = false;
r.load_state(hard_state(2, 0, 0));
let mut m = new_message(0, 0, MessageType::MsgAppend, 0);
m.set_term(r.term - 1);
r.step(m).expect("");
} | rust_cleaned_test_functions.jsonl/130676 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 147
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1288,
583,
1261,
1574,
17464,
6462,
368,
341,
262,
1077,
5206,
435,
284,
501,
4452,
62,
2944,
7,
16,
11,
7486,
20703,
16,
11,
220,
17,
11,
220,
18,
1125,
220,
16,
15,
11,
220,
16,
11,
501,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_invalid_length() {
let bytes = hex!("02 ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10");
let _ = parse_ber(&bytes).err().expect("expected error");
let _ = ber_read_element_header(&bytes)
.err()
.expect("expected error");
let bytes = hex!("02 85 ff ff ff ff ff 00");
let res = parse_ber(&bytes).expect_err("parsing should have returned error");
// get error
match res {
Err::Error(e) => {
assert_eq!(e, BerError::InvalidLength);
}
_ => panic!("not the expected nom error kind {:?}", res),
}
let bytes = hex!("02 02 00");
let res = parse_der(&bytes).err().expect("expected error");
assert_eq!(res, Err::Incomplete(Needed::new(2)));
} | rust_cleaned_test_functions.jsonl/67471 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 320
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31433,
5118,
368,
341,
262,
1077,
5820,
284,
12371,
17223,
15,
17,
25539,
220,
15,
15,
220,
15,
16,
220,
15,
17,
220,
15,
18,
220,
15,
19,
220,
15,
20,
220,
15,
21,
220,
15,
22,
220,
15,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_serde_df_json() {
let df = sample_dataframe();
let json = serde_json::to_string(&df).unwrap();
dbg!(&json);
let out = serde_json::from_str::<DataFrame>(&json).unwrap(); // uses `Deserialize<'de>`
assert!(df.frame_equal_missing(&out));
} | rust_cleaned_test_functions.jsonl/82052 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 144
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
75861,
450,
10894,
9455,
368,
341,
286,
1077,
6764,
284,
6077,
77570,
543,
286,
1077,
2951,
284,
61570,
9455,
486,
983,
3904,
2099,
2940,
568,
15454,
543,
286,
47904,
0,
2099,
2236,
317,
286,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_overlong() {
let mut bytes = vec![];
bytes.extend(&REPR_PACKET_BYTES[..]);
bytes.push(0);
assert_eq!(
Packet::new_unchecked(&bytes).payload().len(),
REPR_PAYLOAD_BYTES.len()
);
assert_eq!(
Packet::new_unchecked(&mut bytes).payload_mut().len(),
REPR_PAYLOAD_BYTES.len()
);
} | rust_cleaned_test_functions.jsonl/126217 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 230
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15431,
4825,
368,
341,
286,
1077,
5206,
5820,
284,
7486,
0,
15078,
286,
5820,
15831,
2099,
787,
6480,
40328,
40705,
95874,
2558,
286,
5820,
2552,
7,
15,
626,
286,
2060,
10714,
33673,
310,
28889,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_parsing_after_editing_tree_that_depends_on_column_values() {
let (grammar, path) = get_test_grammar("uses_current_column");
let (grammar_name, parser_code) = generate_parser_for_grammar(&grammar).unwrap();
let mut parser = Parser::new();
parser
.set_language(get_test_language(
&grammar_name,
&parser_code,
path.as_ref().map(AsRef::as_ref),
))
.unwrap();
let mut code = b"
a = b
c = do d
e + f
g
h + i
"
.to_vec();
let mut tree = parser.parse(&code, None).unwrap();
assert_eq!(
tree.root_node().to_sexp(),
concat!(
"(block ",
"(binary_expression (identifier) (identifier)) ",
"(binary_expression (identifier) (do_expression (block (identifier) (binary_expression (identifier) (identifier)) (identifier)))) ",
"(binary_expression (identifier) (identifier)))",
)
);
perform_edit(
&mut tree,
&mut code,
&Edit {
position: 8,
deleted_length: 0,
inserted_text: b"1234".to_vec(),
},
);
assert_eq!(
code,
b"
a = b
c1234 = do d
e + f
g
h + i
"
);
let mut recorder = ReadRecorder::new(&code);
let tree = parser
.parse_with(&mut |i, _| recorder.read(i), Some(&tree))
.unwrap();
assert_eq!(
tree.root_node().to_sexp(),
concat!(
"(block ",
"(binary_expression (identifier) (identifier)) ",
"(binary_expression (identifier) (do_expression (block (identifier)))) ",
"(binary_expression (identifier) (identifier)) ",
"(identifier) ",
"(binary_expression (identifier) (identifier)))",
)
);
assert_eq!(
recorder.strings_read(),
vec!["\nc1234 = do d\n e + f\n g\n"]
);
} | rust_cleaned_test_functions.jsonl/73165 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 969
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
28598,
19844,
13156,
287,
11663,
70197,
49258,
1412,
4470,
8744,
9146,
368,
341,
262,
1077,
320,
41094,
11,
1815,
8,
284,
633,
4452,
62,
41094,
445,
4776,
11080,
8744,
797,
262,
1077,
320,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_lexing_symbols() {
let source = "+-/*!@&^;:.`|'~";
let expected_toktype = vec![
TokenType::Plus,
TokenType::Minus,
TokenType::Slash,
TokenType::Star,
TokenType::Bang,
TokenType::At,
TokenType::Ampersand,
TokenType::Superscript,
TokenType::Semicolon,
TokenType::Colon,
TokenType::Period,
TokenType::Quote2,
TokenType::Vert,
TokenType::Quote,
TokenType::Tilde,
];
let lex = Lexer::new(source);
let lexed_token = lex
.clone()
.map(|lextok| lextok.token.toktype)
.collect::<Vec<TokenType>>();
let lexed_literal = lex
.map(|lextok| lextok.token.literal)
.collect::<Vec<String>>()
.concat();
assert_eq!(lexed_token, expected_toktype);
assert_eq!(lexed_literal, source.to_string());
} | rust_cleaned_test_functions.jsonl/108893 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 462
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
74547,
287,
55752,
368,
341,
262,
1077,
2530,
284,
6630,
12,
18684,
31,
5,
61,
26,
25,
14908,
91,
6,
93,
876,
262,
1077,
3601,
76162,
1313,
284,
7486,
90515,
286,
56582,
486,
21807,
345,
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_dev_full_show_all() {
let mut buf = [0; 2048];
let mut proc = new_ucmd!().args(&["-A", "/dev/full"]).run_no_wait();
let mut proc_stdout = proc.stdout.take().unwrap();
proc_stdout.read_exact(&mut buf).unwrap();
let expected: Vec<u8> = (0..buf.len())
.map(|n| if n & 1 == 0 { b'^' } else { b'@' })
.collect();
assert_eq!(&buf[..], &expected[..]);
proc.kill().unwrap();
} | rust_cleaned_test_functions.jsonl/90944 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 204
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10433,
16372,
15267,
5705,
368,
341,
262,
1077,
5206,
6607,
284,
508,
15,
26,
220,
17,
15,
19,
23,
935,
262,
1077,
5206,
13674,
284,
501,
68887,
2277,
0,
1005,
2116,
2099,
1183,
12,
32,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_assembler_label_registry_addition() {
test_case(&["DAT 1",
":label",
"DAT 2",
"SET A, [I + label]"],
&[1, 2, 0x5801, 0x0001]);
test_case(&["DAT 1",
":label",
"DAT 2",
"SET A, [label + I]"],
&[1, 2, 0x5801, 0x0001]);
test_case(&["DAT 1",
":label",
"DAT 2, 3",
":label2",
"DAT 4",
"SET [label + A], [label2 + J]"],
&[1, 2, 3, 4, 0x5e01, 0x0003, 0x0001]);
} | rust_cleaned_test_functions.jsonl/44770 | {
"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,
11898,
35401,
6106,
50650,
2891,
680,
368,
341,
262,
1273,
19096,
2099,
1183,
47892,
220,
16,
756,
394,
13022,
1502,
756,
394,
330,
47892,
220,
17,
756,
394,
330,
5884,
362,
11,
508,
40,
488,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_too_small_buf() {
let buf = [0x00, 0x00, 0x00]; // Too small.
assert_matches!(
ParameterNegotiationParams::decode(&buf[..]),
Err(FrameParseError::InvalidBufferLength(DLC_PARAMETER_NEGOTIATION_LENGTH, 3))
);
} | rust_cleaned_test_functions.jsonl/69342 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 147
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
2346,
78,
31966,
10363,
368,
341,
286,
1077,
6607,
284,
508,
15,
87,
15,
15,
11,
220,
15,
87,
15,
15,
11,
220,
15,
87,
15,
15,
5265,
442,
24599,
2613,
624,
286,
2060,
38344,
33673,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_server_data_frame_on_control_stream() {
test_wrong_frame_on_control_stream(&[0x0, 0x2, 0x1, 0x2]);
} | rust_cleaned_test_functions.jsonl/52183 | {
"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,
12015,
1769,
8929,
4470,
13436,
12673,
368,
341,
286,
1273,
75198,
8929,
4470,
13436,
12673,
2099,
58,
15,
87,
15,
11,
220,
15,
87,
17,
11,
220,
15,
87,
16,
11,
220,
15,
87,
17,
2558,
262,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_array_with_two_integers_and_nested_tag() {
let data = vec![0x82, 0xc6, 0x01, 0x02];
let parsed: ParsedArray<super::ParsedArraySize2> =
ParsedArray::deserialize_data(&data).expect("Failed to parse");
assert_eq!(parsed.raw_values(), vec![vec![0xc6, 0x01], vec![0x02]]);
let item_0: serde_cbor::tags::Tagged<u8> = parsed.get(0).unwrap();
assert_eq!(item_0.tag, Some(6));
assert_eq!(item_0.value, 1);
assert_eq!(parsed.get::<u8>(1).unwrap(), 2);
assert_eq!(parsed.tag(), None);
let serialized = parsed.serialize_data().expect("Failed to serialize");
assert_eq!(serialized, data);
} | rust_cleaned_test_functions.jsonl/10821 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 344
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3858,
6615,
23241,
4042,
67592,
8378,
66279,
9372,
368,
341,
286,
1077,
821,
284,
7486,
20703,
15,
87,
23,
17,
11,
220,
15,
8148,
21,
11,
220,
15,
87,
15,
16,
11,
220,
15,
87,
15,
17,
935,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_tabs_with_specifier_only_allowed_with_last_value() {
fn run_cmd(arg: &str, specifier: &str) {
let expected_msg = format!(
"{} specifier only allowed with the last value",
specifier.quote()
);
new_ucmd!().arg(arg).fails().stderr_contains(expected_msg);
}
run_cmd("--tabs=/1,2,3", "/");
run_cmd("--tabs=1,/2,3", "/");
new_ucmd!().arg("--tabs=1,2,/3").succeeds();
run_cmd("--tabs=+1,2,3", "+");
run_cmd("--tabs=1,+2,3", "+");
new_ucmd!().arg("--tabs=1,2,+3").succeeds();
} | rust_cleaned_test_functions.jsonl/121808 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 297
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
57953,
6615,
13594,
3049,
18410,
42155,
6615,
12195,
3142,
368,
341,
262,
5168,
1598,
11684,
9404,
25,
609,
495,
11,
97616,
25,
609,
495,
8,
341,
286,
1077,
3601,
6483,
284,
3561,
33673,
310,
35... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_inverse_none() {
assert!(Mat::create_scale(2.0, 0.0).inverse().is_none());
assert!(Mat::create_scale(2.0, 2.0).inverse().is_some());
} | rust_cleaned_test_functions.jsonl/597 | {
"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,
63333,
31488,
368,
341,
286,
2060,
10297,
11575,
486,
3182,
16727,
7,
17,
13,
15,
11,
220,
15,
13,
15,
568,
61482,
1005,
285,
31488,
1423,
286,
2060,
10297,
11575,
486,
3182,
16727,
7,
17,
13,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_some_arrows() {
let labels: Trivial = SomeNodesLabelled(vec![Some("A"), None]);
let styles = Some(vec![Style::None, Style::Dotted]);
let start = Arrow::from_arrow(ArrowShape::tee());
let end = Arrow::from_arrow(ArrowShape::Crow(Side::Left));
let result = test_input(LabelledGraph::new("test_some_labelled",
labels,
vec![edge_with_arrows(0, 1, "A-1", Style::None, start, end, None)],
styles));
assert_eq!(result.unwrap(),
r#"digraph test_some_labelled {
N0[label="A"];
N1[label="N1"][style="dotted"];
N0 -> N1[label="A-1"][arrowhead="lcrow" dir="both" arrowtail="tee"];
}
"#);
} | rust_cleaned_test_functions.jsonl/54686 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 453
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
61855,
25842,
1811,
368,
341,
286,
1077,
9201,
25,
1163,
26658,
284,
4329,
12288,
2476,
832,
25592,
20703,
8373,
445,
32,
3975,
2240,
2558,
286,
1077,
9222,
284,
4329,
25592,
20703,
2323,
486,
406... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_rw_inside_test_and_js_dir() {
const PERMISSION_VARIANTS: [&str; 2] = ["read", "write"];
let test_dir = util::root_path()
.join("cli")
.join("tests")
.into_os_string()
.into_string()
.unwrap();
let js_dir = util::root_path()
.join("js")
.into_os_string()
.into_string()
.unwrap();
for permission in &PERMISSION_VARIANTS {
let (_, err) = util::run_and_collect_output(
true,
&format!(
"run --allow-{0}={1},{2} complex_permissions_test.ts {0} {3}",
permission, test_dir, js_dir, "complex_permissions_test.ts"
),
None,
None,
false,
);
assert!(!err.contains(util::PERMISSION_DENIED_PATTERN));
}
} | rust_cleaned_test_functions.jsonl/19953 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 349
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
44767,
49566,
72860,
4452,
8378,
26250,
4334,
368,
341,
220,
733,
96540,
2334,
16028,
37125,
25,
34336,
495,
26,
220,
17,
60,
284,
4383,
878,
497,
330,
4934,
6332,
220,
1077,
1273,
4334,
284,
40... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_put_value_roundtrip() {
test_put_value_rand_numbers(32, 2);
test_put_value_rand_numbers(32, 3);
test_put_value_rand_numbers(32, 4);
test_put_value_rand_numbers(32, 5);
test_put_value_rand_numbers(32, 6);
test_put_value_rand_numbers(32, 7);
test_put_value_rand_numbers(32, 8);
test_put_value_rand_numbers(64, 16);
test_put_value_rand_numbers(64, 24);
test_put_value_rand_numbers(64, 32);
} | rust_cleaned_test_functions.jsonl/115741 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 257
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15557,
3142,
29896,
32981,
368,
341,
286,
1273,
15557,
3142,
33864,
32964,
7,
18,
17,
11,
220,
17,
317,
286,
1273,
15557,
3142,
33864,
32964,
7,
18,
17,
11,
220,
18,
317,
286,
1273,
15557,
314... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_bool_array_and() {
let a = BooleanArray::from(vec![false, false, true, true]);
let b = BooleanArray::from(vec![false, true, false, true]);
let c = and(&a, &b).unwrap();
assert_eq!(false, c.value(0));
assert_eq!(false, c.value(1));
assert_eq!(false, c.value(2));
assert_eq!(true, c.value(3));
} | rust_cleaned_test_functions.jsonl/118975 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 185
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
22159,
3858,
8378,
368,
341,
286,
1077,
264,
284,
6992,
1857,
486,
1499,
25592,
20703,
3849,
11,
895,
11,
830,
11,
830,
2558,
286,
1077,
293,
284,
6992,
1857,
486,
1499,
25592,
20703,
3849,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_renaming_of_load_instruction() {
// Given: x := [x]
let mut instruction =
il::Instruction::load(0, il::scalar("x", 64), il::expr_scalar("x", 64));
let mut versioning = ScalarVersioning::new();
versioning.start_new_scope();
versioning.new_version(&il::scalar("x", 64));
instruction.rename_scalars(&mut versioning).unwrap();
// Expected: x_2 := [x_1]
assert_eq!(
instruction,
il::Instruction::load(0, scalar_ssa("x", 64, 2), expr_scalar_ssa("x", 64, 1))
);
} | rust_cleaned_test_functions.jsonl/60303 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 292
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1288,
77,
6469,
3575,
12411,
54923,
368,
341,
286,
442,
16246,
25,
856,
1669,
508,
87,
921,
286,
1077,
5206,
7600,
4035,
310,
3815,
486,
16664,
486,
1078,
7,
15,
11,
3815,
486,
35342,
445,
87,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_get_block_index_by_tx_out_index() {
let mut ledger_db = create_db();
let n_blocks = 43;
let (_expected_blocks, expected_block_contents) = populate_db(&mut ledger_db, n_blocks, 1);
for (block_index, block_contents) in expected_block_contents.iter().enumerate() {
for tx_out in block_contents.outputs.iter() {
let tx_out_index = ledger_db
.get_tx_out_index_by_public_key(&tx_out.public_key)
.expect("Failed getting tx out index");
let block_index_by_tx_out = ledger_db
.get_block_index_by_tx_out_index(tx_out_index)
.expect("Failed getting block index by tx out index");
assert_eq!(block_index as u64, block_index_by_tx_out);
}
}
} | rust_cleaned_test_functions.jsonl/89693 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 431
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
7113,
3560,
3710,
17805,
6068,
3560,
368,
341,
286,
1077,
5206,
46933,
8685,
284,
1855,
8685,
543,
286,
1077,
308,
25201,
284,
220,
19,
18,
280,
286,
1077,
5453,
7325,
25201,
11,
3601,
711... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_ecdsa_pool_insert() {
let mut ecdsa_pool = EcdsaPoolImpl::new(
ic_logger::replica_logger::no_op_logger(),
MetricsRegistry::new(),
);
let time_source = FastForwardTimeSource::new();
let msg_id_1 = {
let ecdsa_dealing = create_ecdsa_dealing(IDkgTranscriptId(100));
let key = ecdsa_dealing.key();
let msg_id = EcdsaDealing::key_to_outer_hash(&key);
ecdsa_pool.insert(UnvalidatedArtifact {
message: EcdsaMessage::EcdsaDealing(ecdsa_dealing),
peer_id: NODE_1,
timestamp: time_source.get_relative_time(),
});
msg_id
};
let msg_id_2 = {
let ecdsa_dealing = create_ecdsa_dealing(IDkgTranscriptId(200));
let key = ecdsa_dealing.key();
let msg_id = EcdsaDealing::key_to_outer_hash(&key);
ecdsa_pool.insert(UnvalidatedArtifact {
message: EcdsaMessage::EcdsaDealing(ecdsa_dealing),
peer_id: NODE_1,
timestamp: time_source.get_relative_time(),
});
msg_id
};
check_state(&ecdsa_pool, &[msg_id_1, msg_id_2], &[]);
} | rust_cleaned_test_functions.jsonl/43947 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 689
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36844,
96780,
15709,
17678,
368,
341,
286,
1077,
5206,
384,
4385,
9081,
15709,
284,
468,
4385,
9081,
10551,
9673,
486,
931,
1006,
310,
17902,
27413,
486,
9995,
15317,
27413,
486,
2152,
10287,
27413,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_counting_writer() {
let buffer: Vec<u8> = vec![];
let mut counting_writer = CountingWriter::wrap(buffer);
let bytes = (0u8..10u8).collect::<Vec<u8>>();
counting_writer.write_all(&bytes).unwrap();
let len = counting_writer.written_bytes();
let buffer_restituted: Vec<u8> = counting_writer.finish();
assert_eq!(len, 10u64);
assert_eq!(buffer_restituted.len(), 10);
} | rust_cleaned_test_functions.jsonl/7314 | {
"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,
3180,
287,
28908,
368,
341,
286,
1077,
4147,
25,
11312,
34837,
23,
29,
284,
7486,
0,
15078,
286,
1077,
5206,
25009,
28908,
284,
4504,
287,
6492,
486,
10097,
12584,
317,
286,
1077,
5820,
284,
320... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_demote_writable_program() {
let key0 = Pubkey::new_unique();
let key1 = Pubkey::new_unique();
let key2 = Pubkey::new_unique();
let message = LoadedMessage {
message: v0::Message {
header: MessageHeader {
num_required_signatures: 1,
num_readonly_signed_accounts: 0,
num_readonly_unsigned_accounts: 0,
},
account_keys: vec![key0],
instructions: vec![CompiledInstruction {
program_id_index: 2,
accounts: vec![1],
data: vec![],
}],
..v0::Message::default()
},
loaded_addresses: LoadedAddresses {
writable: vec![key1, key2],
readonly: vec![],
},
};
assert!(message.is_writable_index(2));
assert!(!message.is_writable(2));
} | rust_cleaned_test_functions.jsonl/34146 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 574
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
69403,
1272,
1670,
22533,
25096,
368,
341,
286,
1077,
1376,
15,
284,
22611,
792,
486,
931,
21218,
543,
286,
1077,
1376,
16,
284,
22611,
792,
486,
931,
21218,
543,
286,
1077,
1376,
17,
284,
22611... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_issuer_handle_credential_send_message_from_request_received_state_with_invalid_request() {
let _setup = TestModeSetup::init();
let mut issuer_sm = _issuer_sm();
issuer_sm = issuer_sm.handle_message(CredentialIssuanceMessage::CredentialInit(mock_connection())).unwrap();
issuer_sm = issuer_sm.handle_message(CredentialIssuanceMessage::CredentialRequest(CredentialRequest::create())).unwrap();
issuer_sm = issuer_sm.handle_message(CredentialIssuanceMessage::CredentialSend()).unwrap();
assert_match!(IssuerState::Finished(_), issuer_sm.state);
assert_eq!(Status::Failed(ProblemReport::default()).code(), issuer_sm.credential_status());
} | rust_cleaned_test_functions.jsonl/20331 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 304
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
66817,
10630,
666,
30320,
13565,
6462,
5673,
7893,
40783,
4387,
6615,
31433,
7893,
368,
341,
310,
1077,
716,
15188,
284,
3393,
3636,
21821,
486,
2327,
1428,
310,
1077,
5206,
54835,
15874,
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_sendfile() {
let addr = run_server();
let fd = fs::File::open("Cargo.toml").unwrap();
let done = TcpStream::connect(&addr)
.and_then(|stream| aio::write_all(stream, [32]))
.and_then(move |(stream, _)| zio::sendfile(stream, fd, ..32))
.and_then(|(stream, fd, len)| aio::read_exact(stream, vec![0; len])
.map(move |(stream, buf)| (stream, fd, buf))
);
let (_, mut fd, buf) = current_thread::block_on_all(done).unwrap();
let mut buf2 = vec![0; buf.len()];
fd.read_exact(&mut buf2).unwrap();
assert_ne!(buf[0], 0);
assert_eq!(buf.len(), 32);
assert_eq!(buf, buf2);
} | rust_cleaned_test_functions.jsonl/91937 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 321
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13565,
1192,
368,
341,
262,
1077,
10789,
284,
1598,
12015,
1428,
262,
1077,
12414,
284,
8619,
486,
1703,
486,
2508,
445,
98228,
73494,
75,
1827,
15454,
1428,
262,
1077,
2814,
284,
64876,
3027,
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_write_enum_to_chunk_by_payload_compact_bytes() {
let field_type = get_enum_field_type();
let src: [&[u8]; 3] = [
&[2, 3], // 1st
&[2, 2], // 2nd
&[2, 1], // 3rd
];
let mut dest = Vec::new();
let res: &[u8] = &[
3, 0, 0, 0, 0, 0, 0, 0, 97, // 1st
2, 0, 0, 0, 0, 0, 0, 0, 98, // 2nd
1, 0, 0, 0, 0, 0, 0, 0, 99, // 3rd
];
for data in &src {
dest.write_enum_to_chunk_by_datum_payload_compact_bytes(*data, &field_type)
.expect("write_enum_to_chunk_by_payload_compact_bytes");
}
assert_eq!(&dest, res);
} | rust_cleaned_test_functions.jsonl/77403 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 417
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9165,
31054,
2346,
30539,
3710,
32813,
18177,
531,
12524,
368,
341,
286,
1077,
2070,
1819,
284,
633,
31054,
5013,
1819,
1428,
286,
1077,
2286,
25,
34336,
58,
84,
23,
5265,
220,
18,
60,
284,
2278... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_range_intersects() {
assert!(Range::new(1, 2).intersects(Range::new(1, 1)));
assert!(Range::new(1, 2).intersects(Range::new(2, 2)));
assert!(!Range::new(1, 2).intersects(Range::new(0, 0)));
assert!(!Range::new(1, 2).intersects(Range::new(3, 10)));
assert!(!Range::new(1, 3).intersects(Range::new(5, 5)));
} | rust_cleaned_test_functions.jsonl/75324 | {
"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,
9698,
15318,
54429,
368,
341,
286,
2060,
10297,
6046,
486,
931,
7,
16,
11,
220,
17,
568,
2245,
54429,
2785,
844,
486,
931,
7,
16,
11,
220,
16,
4945,
286,
2060,
10297,
6046,
486,
931,
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... | 1 |
#[test]
fn test_rule_index() -> TestResult {
let p = polar();
p.load_str(
r#"f(1, 1, "x");
f(1, 1, "y");
f(1, x, "y") if x = 2;
f(1, 2, {b: "y"});
f(1, 3, {c: "z"});"#,
)?;
// Exercise the index.
qeval(&p, r#"f(1, 1, "x")"#);
qeval(&p, r#"f(1, 1, "y")"#);
qvar(&p, r#"f(1, x, "y")"#, "x", values![1, 2]);
qnull(&p, r#"f(1, 1, "z")"#);
qnull(&p, r#"f(1, 2, "x")"#);
qeval(&p, r#"f(1, 2, {b: "y"})"#);
qeval(&p, r#"f(1, 3, {c: "z"})"#);
Ok(())
} | rust_cleaned_test_functions.jsonl/68156 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 366
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21124,
3560,
368,
1464,
3393,
2077,
341,
262,
1077,
281,
284,
24660,
543,
262,
281,
5104,
2895,
1006,
286,
435,
55543,
69,
7,
16,
11,
220,
16,
11,
330,
87,
797,
1843,
282,
7,
16,
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... | 2 |
#[test]
fn test_decode_utf16() {
fn check(s: &[u16], expected: &[Result<char, u16>]) {
let v = char::decode_utf16(s.iter().cloned())
.map(|r| r.map_err(|e| e.unpaired_surrogate()))
.collect::<Vec<_>>();
assert_eq!(v, expected);
}
check(&[0xD800, 0x41, 0x42], &[Err(0xD800), Ok('A'), Ok('B')]);
check(&[0xD800, 0], &[Err(0xD800), Ok('\0')]);
} | rust_cleaned_test_functions.jsonl/109592 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 245
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15227,
39453,
16,
21,
368,
341,
262,
5168,
1779,
1141,
25,
44590,
84,
16,
21,
1125,
3601,
25,
44590,
2077,
21919,
11,
575,
16,
21,
29,
2467,
341,
286,
1077,
348,
284,
1161,
486,
18196,
39453,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_null() {
let a = NullArray::new(2);
let a = a.data();
let b = NullArray::new(2);
let b = b.data();
test_equal(&a, &b, true);
let b = NullArray::new(1);
let b = b.data();
test_equal(&a, &b, false);
} | rust_cleaned_test_functions.jsonl/24215 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 159
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15162,
368,
341,
286,
1077,
264,
284,
18084,
1857,
486,
931,
7,
17,
317,
286,
1077,
264,
284,
264,
2196,
543,
286,
1077,
293,
284,
18084,
1857,
486,
931,
7,
17,
317,
286,
1077,
293,
284,
293... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_fixed_restore_signal() {
let mut outputs = [ &mut [-729, -722, -667, -19, -16, 17, -23, -7, 16
, -16, -5, 3, -8, -13, -15, -1][..]
, &mut [21877, 27482, -6513][..]
];
fixed_restore_signal(3, 16, &mut outputs[0]);
fixed_restore_signal(2, 3, &mut outputs[1]);
assert_eq!(&outputs[0], &[-729, -722, -667, -583, -486, -359, -225, -91
, 59, 209, 354, 497, 630, 740, 812, 845]);
assert_eq!(&outputs[1], &[21877, 27482, 26574]);
} | rust_cleaned_test_functions.jsonl/61776 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 334
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
37839,
62677,
21137,
368,
341,
262,
1077,
5206,
16275,
284,
508,
609,
6984,
10055,
22,
17,
24,
11,
481,
22,
17,
17,
11,
481,
21,
21,
22,
11,
481,
16,
24,
11,
481,
16,
21,
11,
220,
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_wallet_encryption() {
unsafe {
let mut error = 0;
let error_ptr = &mut error as *mut c_int;
let secret_key_alice = private_key_generate();
let public_key_alice = public_key_from_private_key(secret_key_alice, error_ptr);
let db_name_alice = CString::new(random::string(8).as_str()).unwrap();
let db_name_alice_str: *const c_char = CString::into_raw(db_name_alice) as *const c_char;
let alice_temp_dir = tempdir().unwrap();
let db_path_alice = CString::new(alice_temp_dir.path().to_str().unwrap()).unwrap();
let db_path_alice_str: *const c_char = CString::into_raw(db_path_alice) as *const c_char;
let transport_type_alice = transport_memory_create();
let address_alice = transport_memory_get_address(transport_type_alice, error_ptr);
let address_alice_str = CStr::from_ptr(address_alice).to_str().unwrap().to_owned();
let address_alice_str: *const c_char = CString::new(address_alice_str).unwrap().into_raw() as *const c_char;
let alice_config = comms_config_create(
address_alice_str,
transport_type_alice,
db_name_alice_str,
db_path_alice_str,
20,
10800,
error_ptr,
);
let alice_wallet = wallet_create(
alice_config,
ptr::null(),
0,
0,
ptr::null(),
ptr::null(),
received_tx_callback,
received_tx_reply_callback,
received_tx_finalized_callback,
broadcast_callback,
mined_callback,
mined_unconfirmed_callback,
direct_send_callback,
store_and_forward_send_callback,
tx_cancellation_callback,
utxo_validation_complete_callback,
stxo_validation_complete_callback,
invalid_txo_validation_complete_callback,
transaction_validation_complete_callback,
saf_messages_received_callback,
error_ptr,
);
let generated = wallet_test_generate_data(alice_wallet, db_path_alice_str, error_ptr);
assert!(generated);
let passphrase =
"A pretty long passphrase that should test the hashing to a 32-bit key quite well".to_string();
let passphrase_str = CString::new(passphrase).unwrap();
let passphrase_const_str: *const c_char = CString::into_raw(passphrase_str) as *const c_char;
wallet_apply_encryption(alice_wallet, passphrase_const_str, error_ptr);
assert_eq!(error, 0);
comms_config_destroy(alice_config);
wallet_destroy(alice_wallet);
let alice_config = comms_config_create(
address_alice_str,
transport_type_alice,
db_name_alice_str,
db_path_alice_str,
20,
10800,
error_ptr,
);
// no passphrase
let _alice_wallet = wallet_create(
alice_config,
ptr::null(),
0,
0,
ptr::null(),
ptr::null(),
received_tx_callback,
received_tx_reply_callback,
received_tx_finalized_callback,
broadcast_callback,
mined_callback,
mined_unconfirmed_callback,
direct_send_callback,
store_and_forward_send_callback,
tx_cancellation_callback,
utxo_validation_complete_callback,
stxo_validation_complete_callback,
invalid_txo_validation_complete_callback,
transaction_validation_complete_callback,
saf_messages_received_callback,
error_ptr,
);
assert_eq!(error, 426);
let wrong_passphrase = "wrong pf".to_string();
let wrong_passphrase_str = CString::new(wrong_passphrase).unwrap();
let wrong_passphrase_const_str: *const c_char = CString::into_raw(wrong_passphrase_str) as *const c_char;
let _alice_wallet = wallet_create(
alice_config,
ptr::null(),
0,
0,
wrong_passphrase_const_str,
ptr::null(),
received_tx_callback,
received_tx_reply_callback,
received_tx_finalized_callback,
broadcast_callback,
mined_callback,
mined_unconfirmed_callback,
direct_send_callback,
store_and_forward_send_callback,
tx_cancellation_callback,
utxo_validation_complete_callback,
stxo_validation_complete_callback,
invalid_txo_validation_complete_callback,
transaction_validation_complete_callback,
saf_messages_received_callback,
error_ptr,
);
assert_eq!(error, 428);
let alice_wallet = wallet_create(
alice_config,
ptr::null(),
0,
0,
passphrase_const_str,
ptr::null(),
received_tx_callback,
received_tx_reply_callback,
received_tx_finalized_callback,
broadcast_callback,
mined_callback,
mined_unconfirmed_callback,
direct_send_callback,
store_and_forward_send_callback,
tx_cancellation_callback,
utxo_validation_complete_callback,
stxo_validation_complete_callback,
invalid_txo_validation_complete_callback,
transaction_validation_complete_callback,
saf_messages_received_callback,
error_ptr,
);
assert_eq!(error, 0);
// Try a read of an encrypted value to check the wallet is using the ciphers
let seed_words = wallet_get_seed_words(alice_wallet, error_ptr);
assert_eq!(error, 0);
wallet_remove_encryption(alice_wallet, error_ptr);
assert_eq!(error, 0);
comms_config_destroy(alice_config);
wallet_destroy(alice_wallet);
let alice_config = comms_config_create(
address_alice_str,
transport_type_alice,
db_name_alice_str,
db_path_alice_str,
20,
10800,
error_ptr,
);
let alice_wallet = wallet_create(
alice_config,
ptr::null(),
0,
0,
ptr::null(),
ptr::null(),
received_tx_callback,
received_tx_reply_callback,
received_tx_finalized_callback,
broadcast_callback,
mined_callback,
mined_unconfirmed_callback,
direct_send_callback,
store_and_forward_send_callback,
tx_cancellation_callback,
utxo_validation_complete_callback,
stxo_validation_complete_callback,
invalid_txo_validation_complete_callback,
transaction_validation_complete_callback,
saf_messages_received_callback,
error_ptr,
);
assert_eq!(error, 0);
string_destroy(db_name_alice_str as *mut c_char);
string_destroy(db_path_alice_str as *mut c_char);
string_destroy(address_alice_str as *mut c_char);
string_destroy(passphrase_const_str as *mut c_char);
string_destroy(wrong_passphrase_const_str as *mut c_char);
private_key_destroy(secret_key_alice);
public_key_destroy(public_key_alice);
transport_type_destroy(transport_type_alice);
comms_config_destroy(alice_config);
seed_words_destroy(seed_words);
wallet_destroy(alice_wallet);
}
} | rust_cleaned_test_functions.jsonl/66633 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 4634
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62308,
13781,
15597,
368,
341,
286,
19860,
341,
310,
1077,
5206,
1465,
284,
220,
15,
280,
310,
1077,
1465,
4348,
284,
609,
6984,
1465,
438,
353,
6984,
272,
4042,
401,
310,
1077,
6234,
3097,
8418... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_waiter_on_timeout() {
let mut core = Core::new().unwrap();
// The timeout handler should be invoked after timeout.
let (waiter, _, _) = new_test_waiter(10.into(), 20.into(), 20);
waiter.reset_timeout(Instant::now() + Duration::from_millis(100));
let (tx, rx) = mpsc::sync_channel(1);
let f = waiter.on_timeout(move || tx.send(1).unwrap());
assert_elapsed(|| core.run(f).unwrap(), 50, 200);
rx.try_recv().unwrap();
// The timeout handler shouldn't be invoked after waiter has been notified.
let (waiter, _, _) = new_test_waiter(10.into(), 20.into(), 20);
waiter.reset_timeout(Instant::now() + Duration::from_millis(100));
let (tx, rx) = mpsc::sync_channel(1);
let f = waiter.on_timeout(move || tx.send(1).unwrap());
waiter.notify();
assert_elapsed(|| core.run(f).unwrap(), 0, 200);
rx.try_recv().unwrap_err();
} | rust_cleaned_test_functions.jsonl/32485 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 425
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18760,
261,
4470,
20537,
368,
341,
286,
1077,
5206,
6200,
284,
9518,
486,
931,
1005,
15454,
1428,
286,
442,
576,
9632,
7013,
1265,
387,
26881,
1283,
9632,
624,
286,
1077,
320,
11489,
261,
11,
83... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
#[test]
fn test_create_cred_def() {
let _setup = SetupMocks::init();
let (_, handle) = create_cred_def_real(false);
let payment = &get_cred_def_payment_txn(handle).unwrap();
assert!(payment.amount > 0);
} | rust_cleaned_test_functions.jsonl/96764 | {
"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,
8657,
73475,
7844,
368,
341,
286,
1077,
716,
15188,
284,
18626,
72577,
486,
2327,
1428,
286,
1077,
39464,
3705,
8,
284,
1855,
73475,
7844,
15266,
3576,
626,
286,
1077,
8160,
284,
609,
455,
73475,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_extract_struct_keep_comments_and_attrs_on_variant_struct() {
check_assist(
extract_struct_from_enum_variant,
r#"
enum A {
/* comment */
// other
/// comment
#[attr]
$0One {
a: u32
}
}"#,
r#"
/* comment */
// other
/// comment
#[attr]
struct One{
a: u32
}
enum A {
One(One)
}"#,
);
} | rust_cleaned_test_functions.jsonl/36300 | {
"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,
39123,
15126,
50293,
30359,
8378,
39578,
4470,
46112,
15126,
368,
341,
286,
1779,
12083,
380,
1006,
310,
8649,
15126,
5673,
31054,
46112,
345,
310,
435,
2,
698,
9018,
362,
341,
262,
1391,
3980,
73... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_select_first_3_harry_potter_books() -> Result<()> {
let sql = SqlBuilder::select_from("books")
.field("title")
.field("price")
.and_where_like_left("title", "Harry Potter")
.order_asc("title")
.limit(3)
.sql()?;
assert_eq!(&sql, "SELECT title, price FROM books WHERE title LIKE 'Harry Potter%' ORDER BY title LIMIT 3;");
Ok(())
} | rust_cleaned_test_functions.jsonl/12596 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 223
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13051,
12978,
62,
18,
1523,
11433,
57952,
465,
73084,
368,
1464,
5714,
71698,
341,
286,
1077,
5704,
284,
7224,
3297,
486,
1742,
5673,
445,
12110,
1138,
310,
659,
2566,
445,
2102,
1138,
310,
659,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_kill() {
let he = 0;
let she = 1;
let mut room = Room::new(vec![He, She]);
assert!(!room.objects[she].matches(&Dead.into()));
assert!(!room.objects[he].matches(&Murderer.into()));
room.action(&He.kills(She)).unwrap();
assert!(room.objects[she].matches(&Dead.into()));
assert!(room.objects[he].matches(&Murderer.into()));
assert!(room.objects[she].was_killed_by(He));
assert!(room.objects[he].killed(She));
let peter = 0;
let john = 1;
let sheila = 2;
let mut room = Room::new(vec![called("Peter"), called("John"), called("Sheila")]);
assert!(!room.objects[peter].matches(&Dead.into()));
assert!(!room.objects[peter].killed(called("John")));
assert!(!room.objects[peter].was_killed_by(called("Sheila")));
assert!(!room.objects[john].matches(&Dead.into()));
assert!(!room.objects[john].was_killed_by(called("Peter")));
assert!(!room.objects[sheila].matches(&Dead.into()));
assert!(!room.objects[sheila].killed(killed(called("John"))));
room.action(&called("Peter").kills(called("John"))).unwrap();
room.action(&called("Sheila").kills(killed(called("John")))).unwrap();
assert!(room.objects[peter].matches(&Dead.into()));
assert!(room.objects[peter].killed(called("John")));
assert!(room.objects[peter].was_killed_by(called("Sheila")));
assert!(room.objects[john].matches(&Dead.into()));
assert!(room.objects[john].was_killed_by(called("Peter")));
assert!(!room.objects[sheila].matches(&Dead.into()));
assert!(room.objects[sheila].killed(killed(called("John"))));
} | rust_cleaned_test_functions.jsonl/38384 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 759
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
73327,
368,
341,
286,
1077,
566,
284,
220,
15,
280,
286,
1077,
1340,
284,
220,
16,
280,
286,
1077,
5206,
3054,
284,
10420,
486,
931,
25592,
20703,
1519,
11,
2932,
2558,
286,
2060,
0,
3471,
296... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_display() {
macro_rules! t(
($path:expr, $exp:expr, $expf:expr) => (
{
let path = Path::new($path);
let f = format!("{}", path.display());
assert!(f.as_slice() == $exp);
let f = format!("{}", path.filename_display());
assert!(f.as_slice() == $expf);
}
)
)
t!(b!("foo"), "foo", "foo");
t!(b!("foo/bar"), "foo/bar", "bar");
t!(b!("/"), "/", "");
t!(b!("foo", 0xff), "foo\uFFFD", "foo\uFFFD");
t!(b!("foo", 0xff, "/bar"), "foo\uFFFD/bar", "bar");
t!(b!("foo/", 0xff, "bar"), "foo/\uFFFDbar", "\uFFFDbar");
t!(b!(0xff, "foo/bar", 0xff), "\uFFFDfoo/bar\uFFFD", "bar\uFFFD");
} | rust_cleaned_test_functions.jsonl/105872 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 503
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14825,
368,
341,
286,
18072,
21407,
0,
259,
1006,
310,
1711,
2343,
96011,
11,
400,
4580,
96011,
11,
400,
4580,
69,
96011,
8,
589,
2399,
394,
341,
503,
1077,
1815,
284,
7933,
486,
931,
699,
234... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_accountsdb_latest_ancestor() {
solana_logger::setup();
let db = AccountsDB::new(Vec::new(), &ClusterType::Development);
let key = Pubkey::default();
let account0 = Account::new(1, 0, &key);
db.store_uncached(0, &[(&key, &account0)]);
let account1 = Account::new(0, 0, &key);
db.store_uncached(1, &[(&key, &account1)]);
let ancestors = vec![(1, 1)].into_iter().collect();
assert_eq!(&db.load_slow(&ancestors, &key).unwrap().0, &account1);
let ancestors = vec![(1, 1), (0, 0)].into_iter().collect();
assert_eq!(&db.load_slow(&ancestors, &key).unwrap().0, &account1);
let accounts: Vec<Account> =
db.unchecked_scan_accounts("", &ancestors, |accounts: &mut Vec<Account>, option| {
accounts.push(option.1.account());
});
assert_eq!(accounts, vec![account1]);
} | rust_cleaned_test_functions.jsonl/60855 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 433
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
55665,
1999,
64880,
62,
66878,
368,
341,
286,
2048,
3362,
27413,
486,
15188,
543,
286,
1077,
2927,
284,
40655,
3506,
486,
931,
49923,
486,
931,
1507,
609,
28678,
929,
486,
39419,
317,
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_dataspace_encode() -> Result<()> {
let space = Dataspace::try_new((5, 6..=10, 7..))?;
let encoded = space.encode()?;
let decoded = Dataspace::decode(&encoded)?;
assert_eq!(decoded.extents().unwrap(), space.extents().unwrap());
Ok(())
} | rust_cleaned_test_functions.jsonl/101074 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 145
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
46530,
1306,
11224,
368,
1464,
5714,
71698,
341,
286,
1077,
3550,
284,
422,
19346,
1306,
486,
1539,
5921,
1188,
20,
11,
220,
21,
496,
28,
16,
15,
11,
220,
22,
496,
593,
37445,
286,
1077,
20498... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_decimal() {
let ddl = "
CREATE TABLE clickhouse_decimal (
x Decimal(8, 3),
ox Nullable(Decimal(10, 2))
) Engine=Memory";
let query = "SELECT x, ox FROM clickhouse_decimal";
let block = Block::new()
.column("x", vec![Decimal::of(1.234, 3), Decimal::of(5, 3)])
.column("ox", vec![None, Some(Decimal::of(1.23, 2))]);
let pool = Pool::new(database_url());
let done = pool
.get_handle()
.and_then(|c| c.execute("DROP TABLE IF EXISTS clickhouse_decimal"))
.and_then(move |c| c.execute(ddl))
.and_then(move |c| c.insert("clickhouse_decimal", block))
.and_then(move |c| c.query(query).fetch_all())
.and_then(move |(_, block)| {
let x: Decimal = block.get(0, "x")?;
let ox: Option<Decimal> = block.get(1, "ox")?;
let ox0: Option<Decimal> = block.get(0, "ox")?;
assert_eq!(2, block.row_count());
assert_eq!(1.234, x.into());
assert_eq!(Some(1.23), ox.map(|v| v.into()));
assert_eq!(None, ox0);
Ok(())
});
run(done).unwrap();
} | rust_cleaned_test_functions.jsonl/30942 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 608
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
74429,
368,
341,
262,
1077,
55780,
284,
6228,
286,
30776,
14363,
4205,
7675,
74429,
2399,
310,
856,
220,
26728,
7,
23,
11,
220,
18,
1326,
310,
18952,
52655,
7,
11269,
7,
16,
15,
11,
220,
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... | 4 |
#[test]
fn test_named_type() {
let source = "string";
let arena = Arena::new();
let mut p = Parser::new(source, &arena);
let res = p.type_node().unwrap();
assert_debug_snapshot!(res);
} | rust_cleaned_test_functions.jsonl/94266 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 114
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
71834,
1819,
368,
341,
286,
1077,
2530,
284,
330,
917,
876,
286,
1077,
24902,
284,
27047,
486,
931,
543,
286,
1077,
5206,
281,
284,
21102,
486,
931,
12437,
11,
609,
30527,
317,
286,
1077,
592,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_virtio_read_config() {
let block = default_block();
let mut actual_config_space = [0u8; CONFIG_SPACE_SIZE];
block.read_config(0, &mut actual_config_space);
// This will read the number of sectors.
// The config space is little endian.
let expected_config_space: [u8; CONFIG_SPACE_SIZE] =
[0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
assert_eq!(actual_config_space, expected_config_space);
// Invalid read.
let expected_config_space: [u8; CONFIG_SPACE_SIZE] =
[0xd, 0xe, 0xa, 0xd, 0xb, 0xe, 0xe, 0xf];
actual_config_space = expected_config_space;
block.read_config(CONFIG_SPACE_SIZE as u64 + 1, &mut actual_config_space);
assert_eq!(actual_config_space, expected_config_space);
} | rust_cleaned_test_functions.jsonl/73915 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 399
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2273,
2106,
815,
6443,
5332,
368,
341,
286,
1077,
2504,
284,
1638,
7113,
1428,
286,
1077,
5206,
5042,
5332,
14663,
284,
508,
15,
84,
23,
26,
13202,
38404,
4098,
935,
286,
2504,
4125,
5332,
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_stake_delegate() {
let mut vote_state = VoteState::default();
for i in 0..1000 {
vote_state.process_slot_vote_unchecked(i);
}
let vote_state_credits = vote_state.credits();
let vote_address = solana_sdk::pubkey::new_rand();
let vote_address_2 = solana_sdk::pubkey::new_rand();
let mut vote_account =
vote_state::create_account(&vote_address, &solana_sdk::pubkey::new_rand(), 0, 100);
let mut vote_account_2 =
vote_state::create_account(&vote_address_2, &solana_sdk::pubkey::new_rand(), 0, 100);
vote_account
.set_state(&VoteStateVersions::new_current(vote_state.clone()))
.unwrap();
vote_account_2
.set_state(&VoteStateVersions::new_current(vote_state))
.unwrap();
let minimum_delegation = crate::get_minimum_delegation(&FeatureSet::all_enabled());
let stake_lamports = minimum_delegation;
let stake_address = solana_sdk::pubkey::new_rand();
let mut stake_account = AccountSharedData::new_data_with_space(
stake_lamports,
&StakeState::Initialized(Meta {
authorized: Authorized {
staker: stake_address,
withdrawer: stake_address,
},
..Meta::default()
}),
StakeState::size_of(),
&id(),
)
.unwrap();
let mut clock = Clock {
epoch: 1,
..Clock::default()
};
let mut transaction_accounts = vec![
(stake_address, stake_account.clone()),
(vote_address, vote_account),
(vote_address_2, vote_account_2.clone()),
(
sysvar::clock::id(),
account::create_account_shared_data_for_test(&clock),
),
(
sysvar::stake_history::id(),
account::create_account_shared_data_for_test(&StakeHistory::default()),
),
(
stake_config::id(),
config::create_account(0, &stake_config::Config::default()),
),
];
let mut instruction_accounts = vec![
AccountMeta {
pubkey: stake_address,
is_signer: true,
is_writable: false,
},
AccountMeta {
pubkey: vote_address,
is_signer: false,
is_writable: false,
},
AccountMeta {
pubkey: sysvar::clock::id(),
is_signer: false,
is_writable: false,
},
AccountMeta {
pubkey: sysvar::stake_history::id(),
is_signer: false,
is_writable: false,
},
AccountMeta {
pubkey: stake_config::id(),
is_signer: false,
is_writable: false,
},
];
instruction_accounts[0].is_signer = false;
process_instruction(
&serialize(&StakeInstruction::DelegateStake).unwrap(),
transaction_accounts.clone(),
instruction_accounts.clone(),
Err(InstructionError::MissingRequiredSignature),
);
instruction_accounts[0].is_signer = true;
// should pass
let accounts = process_instruction(
&serialize(&StakeInstruction::DelegateStake).unwrap(),
transaction_accounts.clone(),
instruction_accounts.clone(),
Ok(()),
);
assert_eq!(
stake_from(&accounts[0]).unwrap(),
Stake {
delegation: Delegation {
voter_pubkey: vote_address,
stake: stake_lamports,
activation_epoch: clock.epoch,
deactivation_epoch: std::u64::MAX,
..Delegation::default()
},
credits_observed: vote_state_credits,
}
);
// verify that delegate fails as stake is active and not deactivating
clock.epoch += 1;
transaction_accounts[0] = (stake_address, accounts[0].clone());
transaction_accounts[3] = (
sysvar::clock::id(),
account::create_account_shared_data_for_test(&clock),
);
process_instruction(
&serialize(&StakeInstruction::DelegateStake).unwrap(),
transaction_accounts.clone(),
instruction_accounts.clone(),
Err(StakeError::TooSoonToRedelegate.into()),
);
// deactivate
let accounts = process_instruction(
&serialize(&StakeInstruction::Deactivate).unwrap(),
transaction_accounts.clone(),
vec![
AccountMeta {
pubkey: stake_address,
is_signer: true,
is_writable: false,
},
AccountMeta {
pubkey: sysvar::clock::id(),
is_signer: false,
is_writable: false,
},
],
Ok(()),
);
// verify that delegate to a different vote account fails
// during deactivation
transaction_accounts[0] = (stake_address, accounts[0].clone());
instruction_accounts[1].pubkey = vote_address_2;
process_instruction(
&serialize(&StakeInstruction::DelegateStake).unwrap(),
transaction_accounts.clone(),
instruction_accounts.clone(),
Err(StakeError::TooSoonToRedelegate.into()),
);
instruction_accounts[1].pubkey = vote_address;
// verify that delegate succeeds to same vote account
// when stake is deactivating
let accounts_2 = process_instruction(
&serialize(&StakeInstruction::DelegateStake).unwrap(),
transaction_accounts.clone(),
instruction_accounts.clone(),
Ok(()),
);
// verify that deactivation has been cleared
let stake = stake_from(&accounts_2[0]).unwrap();
assert_eq!(stake.delegation.deactivation_epoch, std::u64::MAX);
// verify that delegate to a different vote account fails
// if stake is still active
transaction_accounts[0] = (stake_address, accounts_2[0].clone());
instruction_accounts[1].pubkey = vote_address_2;
process_instruction(
&serialize(&StakeInstruction::DelegateStake).unwrap(),
transaction_accounts.clone(),
instruction_accounts.clone(),
Err(StakeError::TooSoonToRedelegate.into()),
);
clock.epoch += 1;
transaction_accounts[3] = (
sysvar::clock::id(),
account::create_account_shared_data_for_test(&clock),
);
transaction_accounts[0] = (stake_address, accounts[0].clone());
let accounts = process_instruction(
&serialize(&StakeInstruction::DelegateStake).unwrap(),
transaction_accounts.clone(),
instruction_accounts.clone(),
Ok(()),
);
instruction_accounts[1].pubkey = vote_address;
assert_eq!(
stake_from(&accounts[0]).unwrap(),
Stake {
delegation: Delegation {
voter_pubkey: vote_address_2,
stake: stake_lamports,
activation_epoch: clock.epoch,
deactivation_epoch: std::u64::MAX,
..Delegation::default()
},
credits_observed: vote_state_credits,
}
);
// signed but faked vote account
transaction_accounts[1] = (vote_address_2, vote_account_2);
transaction_accounts[1]
.1
.set_owner(solana_sdk::pubkey::new_rand());
process_instruction(
&serialize(&StakeInstruction::DelegateStake).unwrap(),
transaction_accounts.clone(),
instruction_accounts.clone(),
Err(solana_sdk::instruction::InstructionError::IncorrectProgramId),
);
let stake_state = StakeState::RewardsPool;
stake_account.set_state(&stake_state).unwrap();
transaction_accounts[0] = (stake_address, stake_account);
process_instruction(
&serialize(&StakeInstruction::DelegateStake).unwrap(),
transaction_accounts,
instruction_accounts,
Err(solana_sdk::instruction::InstructionError::IncorrectProgramId),
);
} | rust_cleaned_test_functions.jsonl/31639 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 4485
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1261,
726,
55312,
368,
341,
286,
1077,
5206,
6910,
4387,
284,
34034,
1397,
486,
2258,
543,
286,
369,
600,
304,
220,
15,
496,
16,
15,
15,
15,
341,
310,
6910,
4387,
16988,
27563,
54360,
4907,
75... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_genaddr_initdata() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin(BIN_NAME)?;
cmd.arg("genaddr")
.arg("tests/data.tvc")
.arg("tests/data.abi.json")
.arg("--genkey")
.arg("key1")
.arg("--save")
.arg("--data")
.arg(r#"{"m_id":"0x2e0d054dfe43198d971c0f8eaa5f98ca8d08928ecb48a362a900997faecff2e5"}"#);
cmd.assert()
.success()
.stdout(predicate::str::contains("TVC file updated"))
.stdout(predicate::str::contains("Succeeded"));
Ok(())
} | rust_cleaned_test_functions.jsonl/118317 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 306
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16322,
6214,
6137,
691,
368,
1464,
5714,
68843,
8261,
92846,
1460,
486,
841,
486,
1454,
2452,
341,
262,
1077,
5206,
5439,
284,
7348,
486,
66715,
21816,
5349,
687,
4708,
40007,
262,
5439,
21186,
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... | 2 |
#[test]
fn test_process_store_ok() {
solana_logger::setup();
let (bank, mint_keypair) = create_bank(10_000);
let keys = vec![];
let (bank_client, config_keypair) = create_config_account(bank, &mint_keypair, keys.clone());
let config_pubkey = config_keypair.pubkey();
let my_config = MyConfig::new(42);
let instruction = config_instruction::store(&config_pubkey, true, keys.clone(), &my_config);
let message = Message::new_with_payer(vec![instruction], Some(&mint_keypair.pubkey()));
bank_client
.send_message(&[&mint_keypair, &config_keypair], message)
.unwrap();
let config_account_data = bank_client
.get_account_data(&config_pubkey)
.unwrap()
.unwrap();
assert_eq!(
Some(my_config),
deserialize(get_config_data(&config_account_data).unwrap()).ok()
);
} | rust_cleaned_test_functions.jsonl/125662 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 361
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11305,
14809,
19817,
368,
341,
262,
2048,
3362,
27413,
486,
15188,
543,
262,
1077,
320,
17033,
11,
28337,
3097,
12670,
8,
284,
1855,
35733,
7,
16,
15,
62,
15,
15,
15,
317,
262,
1077,
6894,
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_controller_from_core() {
let controller: DID = valid_did();
let document: IotaDocument = iota_document_from_core(&controller);
let expected_controller: Option<IotaDID> = Some(IotaDID::try_from_owned(controller).unwrap());
assert_eq!(document.controller(), expected_controller.as_ref());
} | rust_cleaned_test_functions.jsonl/84332 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 115
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21600,
5673,
15467,
368,
341,
262,
1077,
6461,
25,
59119,
284,
2697,
814,
307,
543,
262,
1077,
2197,
25,
358,
6089,
7524,
284,
81910,
26231,
5673,
15467,
2099,
7152,
317,
262,
1077,
3601,
21600,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_resizing_clone_from() {
let mut buf = Buffer::allocate(5);
assert_eq!(buf.capacity(), 7);
let mut buf2 = Buffer::allocate(4);
assert_eq!(buf2.capacity(), 6);
for i in 0..4 {
buf2.push(i);
}
buf.resizing_clone_from(&buf2);
assert_eq!(buf.capacity(), 7);
assert_eq!(&buf[..], [0, 1, 2, 3]);
let mut buf3 = Buffer::allocate(100);
for i in 0..100 {
buf3.push(i);
}
buf.resizing_clone_from(&buf3);
assert_eq!(buf.capacity(), Buffer::default_capacity(100));
assert_eq!(buf.len(), 100);
buf.resizing_clone_from(&buf2);
assert_eq!(buf.capacity(), 6);
assert_eq!(&buf[..], [0, 1, 2, 3]);
} | rust_cleaned_test_functions.jsonl/87220 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 405
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4918,
4849,
54742,
5673,
368,
341,
286,
1077,
5206,
6607,
284,
10312,
486,
31191,
7,
20,
317,
286,
2060,
10714,
10297,
5909,
59168,
1507,
220,
22,
626,
286,
1077,
5206,
6607,
17,
284,
10312,
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... | 3 |
#[test]
fn test_rfc_8285_one_byte_extension() -> Result<()> {
let raw_pkt = Bytes::from_static(&[
0x90, 0xe0, 0x69, 0x8f, 0xd9, 0xc2, 0x93, 0xda, 0x1c, 0x64, 0x27, 0x82, 0xBE, 0xDE, 0x00,
0x01, 0x50, 0xAA, 0x00, 0x00, 0x98, 0x36, 0xbe, 0x88, 0x9e,
]);
let buf = &mut raw_pkt.clone();
Packet::unmarshal(buf)?;
let p = Packet {
header: Header {
marker: true,
extension: true,
extension_profile: 0xBEDE,
extensions: vec![Extension {
id: 5,
payload: Bytes::from_static(&[0xAA]),
}],
version: 2,
payload_type: 96,
sequence_number: 27023,
timestamp: 3653407706,
ssrc: 476325762,
csrc: vec![],
..Default::default()
},
payload: raw_pkt.slice(20..),
};
let dst = p.marshal()?;
assert_eq!(dst, raw_pkt);
Ok(())
} | rust_cleaned_test_functions.jsonl/128729 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 570
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1710,
8316,
62,
23,
17,
23,
20,
11667,
19737,
31035,
368,
1464,
5714,
71698,
341,
262,
1077,
7112,
42051,
284,
30024,
486,
1499,
25360,
2099,
9640,
286,
220,
15,
87,
24,
15,
11,
220,
15,
8371,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.