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_equality() {
assert_eq!(Scalar::zero(), Scalar::zero());
assert_eq!(Scalar::one(), Scalar::one());
assert_ne!(Scalar::zero(), Scalar::one());
assert_ne!(Scalar::one(), R2);
} | rust_cleaned_test_functions.jsonl/54651 | {
"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,
2204,
10473,
368,
341,
286,
2060,
10714,
10297,
20639,
486,
14154,
1507,
35176,
486,
14154,
1423,
286,
2060,
10714,
10297,
20639,
486,
603,
1507,
35176,
486,
603,
5231,
286,
2060,
13925,
10297,
2063... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_iter_two_split() {
let assr = contigs![(2, 6), (4, 1), (1, 0)];
let segments: Vec<_> = assr.iter_data(100).collect();
assert_eq!(segments, vec![(102, 108), (112, 113)]);
} | rust_cleaned_test_functions.jsonl/52024 | {
"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,
11723,
23241,
17052,
368,
341,
286,
1077,
1071,
81,
284,
683,
14462,
0,
9697,
17,
11,
220,
21,
701,
320,
19,
11,
220,
16,
701,
320,
16,
11,
220,
15,
12587,
286,
1077,
20632,
25,
11312,
32399... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_neg() {
let cases = vec![
(Datum::I64(123), Datum::I64(-124)),
(Datum::I64(-123), Datum::I64(122)),
(Datum::Null, Datum::Null),
];
let mut ctx = EvalContext::default();
for (arg, exp) in cases {
let args = &[datum_expr(arg)];
let op =
Expression::build(&ctx, scalar_func_expr(ScalarFuncSig::BitNegSig, args)).unwrap();
let res = op.eval(&mut ctx, &[]).unwrap();
assert_eq!(res, exp);
}
} | rust_cleaned_test_functions.jsonl/16157 | {
"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,
13996,
28209,
368,
341,
286,
1077,
5048,
284,
7486,
90515,
310,
320,
68036,
486,
40,
21,
19,
7,
16,
17,
18,
701,
68459,
486,
40,
21,
19,
4080,
16,
17,
19,
6965,
310,
320,
68036,
486,
40,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_download_sst_wrong_key_prefix() {
let (_ext_sst_dir, backend, meta) = create_sample_external_sst_file().unwrap();
let importer_dir = tempfile::tempdir().unwrap();
let importer = SSTImporter::new(&importer_dir, None).unwrap();
let sst_writer = create_sst_writer_with_db(&importer, &meta).unwrap();
let result = importer.download::<TestEngine>(
&meta,
&backend,
"sample.sst",
&new_rewrite_rule(b"xxx", b"yyy", 0),
Limiter::new(INFINITY),
sst_writer,
);
match &result {
Err(Error::WrongKeyPrefix(_, key, prefix)) => {
assert_eq!(key, b"t123_r01");
assert_eq!(prefix, b"xxx");
}
_ => panic!("unexpected download result: {:?}", result),
}
} | rust_cleaned_test_functions.jsonl/4971 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 449
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
35939,
643,
267,
75198,
3097,
13974,
368,
341,
286,
1077,
5453,
427,
643,
267,
4334,
11,
19163,
11,
8823,
8,
284,
1855,
17491,
47432,
643,
267,
2458,
1005,
15454,
543,
286,
1077,
62561,
4334,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_mention_with_member() {
let value = Mention {
avatar: None,
bot: false,
discriminator: "0001".to_owned(),
id: UserId(1),
member: Some(PartialMember {
deaf: false,
joined_at: None,
mute: true,
nick: Some("bar".to_owned()),
permissions: None,
premium_since: None,
roles: Vec::new(),
user: None,
}),
name: "foo".to_owned(),
public_flags: UserFlags::empty(),
};
serde_test::assert_tokens(
&value,
&[
Token::Struct {
name: "Mention",
len: 7,
},
Token::Str("avatar"),
Token::None,
Token::Str("bot"),
Token::Bool(false),
Token::Str("discriminator"),
Token::Str("0001"),
Token::Str("id"),
Token::NewtypeStruct { name: "UserId" },
Token::Str("1"),
Token::Str("member"),
Token::Some,
Token::Struct {
name: "PartialMember",
len: 7,
},
Token::Str("deaf"),
Token::Bool(false),
Token::Str("joined_at"),
Token::None,
Token::Str("mute"),
Token::Bool(true),
Token::Str("nick"),
Token::Some,
Token::Str("bar"),
Token::Str("permissions"),
Token::None,
Token::Str("roles"),
Token::Seq { len: Some(0) },
Token::SeqEnd,
Token::Str("user"),
Token::None,
Token::StructEnd,
Token::Str("username"),
Token::Str("foo"),
Token::Str("public_flags"),
Token::U64(0),
Token::StructEnd,
],
);
} | rust_cleaned_test_functions.jsonl/67374 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1357
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26985,
290,
6615,
19388,
368,
341,
286,
1077,
897,
284,
85148,
341,
310,
20701,
25,
2240,
345,
310,
10924,
25,
895,
345,
310,
81738,
25,
330,
15,
15,
15,
16,
3263,
983,
51973,
3148,
310,
877,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_vote_serialization() {
let dt = "2017-12-25T03:00:01.234Z".parse::<DateTime<Utc>>().unwrap();
let vote = Vote {
vote_type: Type::Prevote,
height: Height::from(12345_u32),
round: Round::from(2_u16),
timestamp: Some(dt.into()),
block_id: Some(BlockId {
hash: Hash::try_from(b"DEADBEEFDEADBEEFBAFBAFBAFBAFBAFA".to_vec()).unwrap(),
part_set_header: Header::new(
1_000_000,
Hash::try_from(b"0022446688AACCEE1133557799BBDDFF".to_vec()).unwrap(),
)
.unwrap(),
}),
validator_address: AccountId::try_from(vec![
0xa3, 0xb2, 0xcc, 0xdd, 0x71, 0x86, 0xf1, 0x68, 0x5f, 0x21, 0xf2, 0x48, 0x2a, 0xf4,
0xfb, 0x34, 0x46, 0xa8, 0x4b, 0x35,
])
.unwrap(),
validator_index: ValidatorIndex::try_from(56789).unwrap(),
signature: Signature::new(vec![
130u8, 246, 183, 50, 153, 248, 28, 57, 51, 142, 55, 217, 194, 24, 134, 212, 233,
100, 211, 10, 24, 174, 179, 117, 41, 65, 141, 134, 149, 239, 65, 174, 217, 42, 6,
184, 112, 17, 7, 97, 255, 221, 252, 16, 60, 144, 30, 212, 167, 39, 67, 35, 118,
192, 133, 130, 193, 115, 32, 206, 152, 91, 173, 10,
])
.unwrap(),
};
let mut got = vec![];
let request = SignVoteRequest {
vote,
chain_id: ChainId::from_str("test_chain_id").unwrap(),
};
// Option 1 using bytes:
let _have = request.to_signable_bytes(&mut got);
// Option 2 using Vec<u8>:
let got2 = request.to_signable_vec().unwrap();
// the following vector is generated via:
let want = vec![
124, 8, 1, 17, 57, 48, 0, 0, 0, 0, 0, 0, 25, 2, 0, 0, 0, 0, 0, 0, 0, 34, 74, 10, 32,
68, 69, 65, 68, 66, 69, 69, 70, 68, 69, 65, 68, 66, 69, 69, 70, 66, 65, 70, 66, 65, 70,
66, 65, 70, 66, 65, 70, 66, 65, 70, 65, 18, 38, 8, 192, 132, 61, 18, 32, 48, 48, 50,
50, 52, 52, 54, 54, 56, 56, 65, 65, 67, 67, 69, 69, 49, 49, 51, 51, 53, 53, 55, 55, 57,
57, 66, 66, 68, 68, 70, 70, 42, 11, 8, 177, 211, 129, 210, 5, 16, 128, 157, 202, 111,
50, 13, 116, 101, 115, 116, 95, 99, 104, 97, 105, 110, 95, 105, 100,
];
assert_eq!(got, want);
assert_eq!(got2, want);
} | rust_cleaned_test_functions.jsonl/113698 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1427
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
54360,
25602,
2022,
368,
341,
286,
1077,
7594,
284,
330,
17,
15,
16,
22,
12,
16,
17,
12,
17,
20,
51,
15,
18,
25,
15,
15,
25,
15,
16,
13,
17,
18,
19,
57,
3263,
6400,
27638,
7689,
36397,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_process_ledger_options_override_threads() {
let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(123);
let (ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_config);
let blockstore = Blockstore::open(&ledger_path).unwrap();
let opts = ProcessOptions {
override_num_threads: Some(1),
accounts_db_test_hash_calculation: true,
..ProcessOptions::default()
};
process_blockstore(&genesis_config, &blockstore, Vec::new(), opts, None).unwrap();
PAR_THREAD_POOL.with(|pool| {
assert_eq!(pool.borrow().current_num_threads(), 1);
});
} | rust_cleaned_test_functions.jsonl/70854 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 308
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11305,
38367,
1389,
8743,
48576,
29725,
368,
341,
286,
1077,
40788,
2648,
1731,
314,
59366,
5332,
11,
5241,
335,
284,
1855,
16322,
13774,
5332,
7,
16,
17,
18,
317,
286,
1077,
320,
50704,
2638,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_partition_point() {
let b: [i32; 0] = [];
assert_eq!(b.partition_point(|&x| x < 5), 0);
let b = [4];
assert_eq!(b.partition_point(|&x| x < 3), 0);
assert_eq!(b.partition_point(|&x| x < 4), 0);
assert_eq!(b.partition_point(|&x| x < 5), 1);
let b = [1, 2, 4, 6, 8, 9];
assert_eq!(b.partition_point(|&x| x < 5), 3);
assert_eq!(b.partition_point(|&x| x < 6), 3);
assert_eq!(b.partition_point(|&x| x < 7), 4);
assert_eq!(b.partition_point(|&x| x < 8), 4);
let b = [1, 2, 4, 5, 6, 8];
assert_eq!(b.partition_point(|&x| x < 9), 6);
let b = [1, 2, 4, 6, 7, 8, 9];
assert_eq!(b.partition_point(|&x| x < 6), 3);
assert_eq!(b.partition_point(|&x| x < 5), 3);
assert_eq!(b.partition_point(|&x| x < 8), 5);
let b = [1, 2, 4, 5, 6, 8, 9];
assert_eq!(b.partition_point(|&x| x < 7), 5);
assert_eq!(b.partition_point(|&x| x < 0), 0);
let b = [1, 3, 3, 3, 7];
assert_eq!(b.partition_point(|&x| x < 0), 0);
assert_eq!(b.partition_point(|&x| x < 1), 0);
assert_eq!(b.partition_point(|&x| x < 2), 1);
assert_eq!(b.partition_point(|&x| x < 3), 1);
assert_eq!(b.partition_point(|&x| x < 4), 4);
assert_eq!(b.partition_point(|&x| x < 5), 4);
assert_eq!(b.partition_point(|&x| x < 6), 4);
assert_eq!(b.partition_point(|&x| x < 7), 4);
assert_eq!(b.partition_point(|&x| x < 8), 5);
} | rust_cleaned_test_functions.jsonl/9611 | {
"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,
43840,
6085,
368,
341,
262,
1077,
293,
25,
508,
72,
18,
17,
26,
220,
15,
60,
284,
5907,
262,
2060,
10714,
10297,
65,
79009,
6085,
22428,
5,
87,
91,
856,
366,
220,
20,
701,
220,
15,
626,
26... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_sort_list() {
test_sort_list_arrays::<Int8Type>(
vec![
Some(vec![Some(1)]),
Some(vec![Some(4)]),
Some(vec![Some(2)]),
Some(vec![Some(3)]),
],
Some(SortOptions {
descending: false,
nulls_first: false,
}),
vec![
Some(vec![Some(1)]),
Some(vec![Some(2)]),
Some(vec![Some(3)]),
Some(vec![Some(4)]),
],
Some(1),
);
test_sort_list_arrays::<Int32Type>(
vec![
Some(vec![Some(1), Some(0)]),
Some(vec![Some(4), Some(3), Some(2), Some(1)]),
Some(vec![Some(2), Some(3), Some(4)]),
Some(vec![Some(3), Some(3), Some(3), Some(3)]),
Some(vec![Some(1), Some(1)]),
],
Some(SortOptions {
descending: false,
nulls_first: false,
}),
vec![
Some(vec![Some(1), Some(0)]),
Some(vec![Some(1), Some(1)]),
Some(vec![Some(2), Some(3), Some(4)]),
Some(vec![Some(3), Some(3), Some(3), Some(3)]),
Some(vec![Some(4), Some(3), Some(2), Some(1)]),
],
None,
);
test_sort_list_arrays::<Int32Type>(
vec![
None,
Some(vec![Some(4), None, Some(2)]),
Some(vec![Some(2), Some(3), Some(4)]),
None,
Some(vec![Some(3), Some(3), None]),
],
Some(SortOptions {
descending: false,
nulls_first: false,
}),
vec![
Some(vec![Some(2), Some(3), Some(4)]),
Some(vec![Some(3), Some(3), None]),
Some(vec![Some(4), None, Some(2)]),
None,
None,
],
Some(3),
);
} | rust_cleaned_test_functions.jsonl/39274 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1367
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18435,
2019,
368,
341,
286,
1273,
18435,
2019,
68983,
27638,
1072,
23,
929,
17055,
310,
7486,
90515,
394,
4329,
25592,
20703,
8373,
7,
16,
7252,
1326,
394,
4329,
25592,
20703,
8373,
7,
19,
7252,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_lines() {
let in_buf = MemReader::new(Vec::from_slice(b"a\nb\nc"));
let mut reader = BufferedReader::with_capacity(2, in_buf);
let mut it = reader.lines();
assert_eq!(it.next(), Some(Ok("a\n".to_string())));
assert_eq!(it.next(), Some(Ok("b\n".to_string())));
assert_eq!(it.next(), Some(Ok("c".to_string())));
assert_eq!(it.next(), None);
} | rust_cleaned_test_functions.jsonl/83710 | {
"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,
18323,
368,
341,
286,
1077,
304,
10363,
284,
13550,
5062,
486,
931,
49923,
486,
1499,
26488,
1883,
56693,
1699,
65,
59,
1016,
4010,
286,
1077,
5206,
6604,
284,
25568,
486,
4197,
35603,
7,
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_from_ndarray4_0() {
let hw = RefCell::new(CpuHardware::new());
let src = ndarray::Array4::<f32>::from_shape_vec((0, 0, 0, 0), vec![]).unwrap();
let dest = src.into_array(&hw);
assert_eq!(*dest.shape(), Shape::new([0, 0, 0, 0]));
assert_eq!(dest.get_values_f32(), vec![]);
} | rust_cleaned_test_functions.jsonl/73993 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 147
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5673,
43544,
1653,
19,
62,
15,
368,
341,
262,
1077,
31256,
284,
8550,
3599,
486,
931,
3025,
5584,
66862,
486,
931,
1423,
262,
1077,
2286,
284,
66883,
486,
1857,
19,
27638,
69,
18,
17,
6831,
14... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_possible_qualified_property_reverts_to_array() {
let input = "a.b$(1)";
let eol_reader = EolReader::from(input);
let mut parser = word_p();
let (_, result) = parser.parse(eol_reader).expect("Should parse");
assert_eq!(
result,
Some(Expression::func("a.b$".into(), vec![1.as_lit_expr(1, 6)]))
);
} | rust_cleaned_test_functions.jsonl/102682 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 307
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
71244,
62,
36335,
16638,
1288,
28163,
2346,
3858,
368,
341,
503,
1077,
1946,
284,
330,
64,
948,
8525,
16,
24023,
503,
1077,
384,
337,
22306,
284,
468,
337,
5062,
486,
1499,
5384,
317,
503,
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_max_vacation_days_2() {
let flights = vec![
vec![0,0,0],vec![0,0,0],vec![0,0,0]
];
let days = vec![
vec![1,1,1], vec![7,7,7], vec![7,7,7]
];
assert_eq!(Solution::max_vacation_days(flights, days), 3);
} | rust_cleaned_test_functions.jsonl/132369 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 184
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6345,
2273,
580,
367,
28353,
62,
17,
368,
341,
286,
1077,
24908,
284,
7486,
90515,
310,
7486,
20703,
15,
11,
15,
11,
15,
1125,
4083,
20703,
15,
11,
15,
11,
15,
1125,
4083,
20703,
15,
11,
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_rewrite_with_pending_transaction() {
let override_rule = rule!("fuchsia.com" => "fuchsia.com", "/a" => "/c");
let dynamic_config =
make_rule_config(vec![rule!("fuchsia.com" => "fuchsia.com", "/a" => "/b")]);
let mut manager = RewriteManagerBuilder::new(Some(&dynamic_config)).unwrap().build();
let mut transaction = manager.transaction();
transaction.add(override_rule.clone());
// new rule is not yet committed and should not be used yet
let url: PkgUrl = "fuchsia-pkg://fuchsia.com/a".parse().unwrap();
assert_eq!(manager.rewrite(&url), "fuchsia-pkg://fuchsia.com/b".parse().unwrap());
manager.apply(transaction).unwrap();
let url = "fuchsia-pkg://fuchsia.com/a".parse().unwrap();
assert_eq!(manager.rewrite(&url), "fuchsia-pkg://fuchsia.com/c".parse().unwrap());
} | rust_cleaned_test_functions.jsonl/46501 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 379
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
74052,
6615,
37861,
28884,
368,
341,
286,
1077,
2812,
21124,
284,
5912,
17223,
69,
73391,
905,
1,
589,
330,
69,
73391,
905,
497,
3521,
64,
1,
589,
3521,
66,
797,
286,
1077,
8741,
5332,
4035,
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_retransmit_medium() {
let num_nodes = 2000;
let stakes: Vec<_> = (0..num_nodes).map(|i| i).collect();
run_simulation(&stakes, 200);
} | rust_cleaned_test_functions.jsonl/36196 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 76
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1288,
1458,
1763,
54867,
368,
341,
262,
1077,
1629,
14896,
284,
220,
17,
15,
15,
15,
280,
262,
1077,
44425,
25,
11312,
32399,
29,
284,
320,
15,
496,
2413,
14896,
568,
2186,
22428,
72,
91,
600,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_thread_list() {
assert_eq!(
query(&b"qfThreadInfo"[..]),
Done(&b""[..], Query::ThreadList(true))
);
assert_eq!(
query(&b"qsThreadInfo"[..]),
Done(&b""[..], Query::ThreadList(false))
);
} | rust_cleaned_test_functions.jsonl/40120 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 130
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10814,
2019,
368,
341,
262,
2060,
10714,
33673,
286,
3239,
2099,
65,
1,
80,
69,
6855,
1731,
36864,
496,
17036,
286,
27357,
2099,
65,
3014,
95874,
1125,
11361,
486,
6855,
852,
3715,
1171,
262,
14... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_iltagcreatorengine_new() {
let e: ILTagCreatorEngine = ILTagCreatorEngine::new(false);
assert!(!e.strict());
let e: ILTagCreatorEngine = ILTagCreatorEngine::new(true);
assert!(e.strict());
} | rust_cleaned_test_functions.jsonl/25704 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 97
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
2963,
351,
837,
44009,
70891,
5921,
368,
341,
262,
1077,
384,
25,
11344,
5668,
31865,
4571,
284,
11344,
5668,
31865,
4571,
486,
931,
3576,
317,
262,
2060,
0,
3471,
68,
40699,
5231,
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_base58_encode() {
// Basics
assert_eq!(&_encode_slice(&[0][..]), "1");
assert_eq!(&_encode_slice(&[1][..]), "2");
assert_eq!(&_encode_slice(&[58][..]), "21");
assert_eq!(&_encode_slice(&[13, 36][..]), "211");
// Leading zeroes
assert_eq!(&_encode_slice(&[0, 13, 36][..]), "1211");
assert_eq!(&_encode_slice(&[0, 0, 0, 0, 13, 36][..]), "1111211");
// Addresses
let addr = from_hex("00f8917303bfa8ef24f292e8fa1419b20460ba064d").unwrap();
assert_eq!(
&check_encode_slice(&addr[..]),
"1PfJpZsjreyVrqeoAfabrRwwjQyoSQMmHH"
);
} | rust_cleaned_test_functions.jsonl/42585 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 293
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7651,
20,
23,
11224,
368,
341,
197,
197,
322,
67176,
198,
197,
6948,
10714,
0,
49038,
6180,
26488,
2099,
58,
15,
1457,
496,
9719,
330,
16,
797,
197,
6948,
10714,
0,
49038,
6180,
26488,
2099,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_limit_typecheck() {
assert_cli::Assert::main_binary()
.with_args(&["* | limit 0"])
.fails()
.and()
.stderr()
.contains("Error: Limit must be a non-zero integer, found 0")
.unwrap();
assert_cli::Assert::main_binary()
.with_args(&["* | limit 0.1"])
.fails()
.and()
.stderr()
.contains("Error: Limit must be a non-zero integer, found 0.1")
.unwrap();
} | rust_cleaned_test_functions.jsonl/15996 | {
"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,
14763,
1819,
2028,
368,
341,
286,
2060,
47147,
486,
8534,
486,
3817,
31761,
741,
310,
659,
4197,
8384,
2099,
1183,
9,
760,
3930,
220,
15,
14108,
310,
659,
59631,
741,
310,
659,
437,
741,
310,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parse_escapes() {
assert_eq!(
FormatString::parse("abc\\0\\t\\n\\\\\\141de\\cf")
.unwrap()
.components,
vec![
FormatComponent::Literal("abc".to_owned()),
FormatComponent::Literal("\0".to_owned()),
FormatComponent::Literal("\t".to_owned()),
FormatComponent::Literal("\n".to_owned()),
FormatComponent::Literal("\\".to_owned()),
FormatComponent::Literal("a".to_owned()),
FormatComponent::Literal("de".to_owned()),
FormatComponent::Flush,
FormatComponent::Literal("f".to_owned())
]
);
assert!(FormatString::parse("\\X").is_err());
assert!(FormatString::parse("\\").is_err());
} | rust_cleaned_test_functions.jsonl/69243 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 455
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
92196,
9337,
368,
341,
286,
2060,
10714,
33673,
310,
15042,
703,
486,
6400,
445,
13683,
3422,
15,
3422,
83,
3422,
77,
51007,
3422,
16,
19,
16,
450,
3422,
9792,
1138,
394,
659,
15454,
741,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_memory_pool() -> Result<()> {
let pool = MemoryPool::new(
&ModuleLimits {
imported_functions: 0,
imported_tables: 0,
imported_memories: 0,
imported_globals: 0,
types: 0,
functions: 0,
tables: 0,
memories: 3,
globals: 0,
table_elements: 0,
memory_pages: 1,
},
&InstanceLimits { count: 5 },
&Tunables {
static_memory_bound: 1,
static_memory_offset_guard_size: 0,
..Tunables::default()
},
)?;
assert_eq!(pool.memory_size, WASM_PAGE_SIZE as usize);
assert_eq!(pool.max_memories, 3);
assert_eq!(pool.max_instances, 5);
assert_eq!(pool.max_wasm_pages, 1);
let base = pool.mapping.as_ptr() as usize;
for i in 0..5 {
let mut iter = pool.get(i);
for j in 0..3 {
assert_eq!(
iter.next().unwrap() as usize - base,
((i * 3) + j) * pool.memory_size
);
}
assert_eq!(iter.next(), None);
}
Ok(())
} | rust_cleaned_test_functions.jsonl/48874 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 790
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19195,
15709,
368,
1464,
5714,
71698,
341,
286,
1077,
7314,
284,
13850,
10551,
486,
931,
1006,
310,
609,
3332,
94588,
341,
394,
24928,
31708,
25,
220,
15,
345,
394,
24928,
35632,
25,
220,
15,
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_validate_is_bad() {
assert!(phrase_is_ok(
&"spark remain person kitchen mule spell knee armed position rail grid ankle park remain person kitchen mule spell knee armed position rail grid ankle".split_whitespace().collect::<Vec<&str>>()
).is_err())
} | rust_cleaned_test_functions.jsonl/44000 | {
"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,
42681,
6892,
34199,
368,
341,
286,
2060,
10297,
27710,
6892,
19817,
1006,
310,
609,
1,
53782,
7146,
1697,
9780,
296,
1111,
12845,
21381,
17445,
2309,
13569,
5827,
38348,
6118,
7146,
1697,
9780,
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_exclusion_list() {
let crypto = OpenMlsRustCrypto::default();
for ciphersuite in Config::supported_ciphersuites() {
// Number of nodes in the tree
const NODES: usize = 31;
// Resolution for the root node of that tree
const FULL_RESOLUTION: &[usize] =
&[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30];
const EXCLUSION_LIST: &[usize] = &[5, 6, 7, 8, 9, 10, 11];
// Expected filtered resolution (the nodes from the exclusion list should be
// stripped from the full resolution)
const FILTERED_RESOLUTION: &[usize] = &[0, 2, 4, 6, 8, 24, 26, 28, 30];
let mut nodes = vec![];
let mut key_package_bundles = vec![];
for i in 0..NODES {
let credential_bundle = CredentialBundle::new(
vec![i as u8],
CredentialType::Basic,
ciphersuite.signature_scheme(),
&crypto,
)
.unwrap();
let key_package_bundle =
KeyPackageBundle::new(&[ciphersuite.name()], &credential_bundle, &crypto, vec![])
.unwrap();
// We build a leaf node from the key packages
let leaf_node = Node {
node_type: NodeType::Leaf,
key_package: Some(key_package_bundle.key_package().clone()),
node: None,
};
key_package_bundles.push(key_package_bundle);
nodes.push(Some(leaf_node));
if i != NODES - 1 {
// We insert blank parent nodes to get a longer resolution list
nodes.push(None);
}
}
// The first key package bundle is used for the tree holder
let key_package_bundle = key_package_bundles.remove(0);
let tree = RatchetTree::new_from_nodes(&crypto, key_package_bundle, &nodes).unwrap();
let root = treemath::root(LeafIndex::from(NODES / 2));
// Test full resolution
let exclusion_list = HashSet::new();
let full_resolution = tree
.resolve(root, &exclusion_list)
.iter()
.map(|node_index| node_index.as_usize())
.collect::<Vec<usize>>();
// We expect to have all resolved nodes
assert_eq!(FULL_RESOLUTION, full_resolution);
// Test resolution with exclusion list
let exclusion_list_node_indexes = EXCLUSION_LIST
.iter()
.map(|&index| LeafIndex::from(index))
.collect::<Vec<LeafIndex>>();
let exclusion_list = exclusion_list_node_indexes.iter().collect();
let filtered_resultion = tree
.resolve(root, &exclusion_list)
.iter()
.map(|node_index| node_index.as_usize())
.collect::<Vec<usize>>();
// We expect to only see the nodes that were not removed by the filtering
assert_eq!(FILTERED_RESOLUTION, filtered_resultion);
}
} | rust_cleaned_test_functions.jsonl/82138 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1476
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2702,
8957,
2019,
368,
341,
262,
1077,
19028,
284,
5264,
44,
4730,
49,
590,
58288,
486,
2258,
543,
262,
369,
272,
82077,
9302,
304,
5532,
486,
18216,
666,
82077,
3083,
288,
368,
341,
286,
442,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
#[test]
fn test_sort_assemble_sorters_by_extension() {
let tmp_dir = tempdir().expect("failed to create temp dir");
// Create the file with rs extension;
let path_a = tmp_dir.path().join("aaa.rs");
File::create(&path_a).expect("failed to create file");
let meta_a = Meta::from_path(&path_a, false).expect("failed to get meta");
// Create the file with rs extension;
let path_z = tmp_dir.path().join("zzz.rs");
File::create(&path_z).expect("failed to create file");
let meta_z = Meta::from_path(&path_z, false).expect("failed to get meta");
// Create the file with js extension;
let path_j = tmp_dir.path().join("zzz.js");
File::create(&path_j).expect("failed to create file");
let meta_j = Meta::from_path(&path_j, false).expect("failed to get meta");
// Create the file with txt extension;
let path_t = tmp_dir.path().join("zzz.txt");
File::create(&path_t).expect("failed to create file");
let meta_t = Meta::from_path(&path_t, false).expect("failed to get meta");
let mut flags = Flags::default();
flags.sorting.column = SortColumn::Extension;
// Sort by extension
let sorter = assemble_sorters(&flags);
assert_eq!(by_meta(&sorter, &meta_a, &meta_z), Ordering::Equal);
let sorter = assemble_sorters(&flags);
assert_eq!(by_meta(&sorter, &meta_a, &meta_j), Ordering::Greater);
let sorter = assemble_sorters(&flags);
assert_eq!(by_meta(&sorter, &meta_a, &meta_t), Ordering::Less);
} | rust_cleaned_test_functions.jsonl/17866 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 667
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18435,
11898,
15790,
18435,
388,
3710,
31035,
368,
341,
286,
1077,
4174,
4334,
284,
2730,
3741,
1005,
17119,
445,
16091,
311,
1855,
2730,
5419,
3071,
286,
442,
4230,
279,
1034,
448,
10036,
8894,
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_wallet_witness_tx() {
let (server, leader_data, alice, ledger_path) = new_validator_for_tests();
let bob_pubkey = Pubkey::new_rand();
let (sender, receiver) = channel();
run_local_drone(alice, sender, None);
let drone_addr = receiver.recv().unwrap();
let rpc_client = RpcClient::new_socket(leader_data.rpc);
let mut config_payer = WalletConfig::default();
config_payer.json_rpc_url =
format!("http://{}:{}", leader_data.rpc.ip(), leader_data.rpc.port());
let mut config_witness = WalletConfig::default();
config_witness.json_rpc_url = config_payer.json_rpc_url.clone();
assert_ne!(
config_payer.keypair.pubkey(),
config_witness.keypair.pubkey()
);
request_and_confirm_airdrop(&rpc_client, &drone_addr, &config_payer.keypair.pubkey(), 50)
.unwrap();
request_and_confirm_airdrop(
&rpc_client,
&drone_addr,
&config_witness.keypair.pubkey(),
1,
)
.unwrap();
config_payer.command = WalletCommand::Pay(
10,
bob_pubkey,
None,
None,
Some(vec![config_witness.keypair.pubkey()]),
None,
);
let sig_response = process_command(&config_payer);
let object: Value = serde_json::from_str(&sig_response.unwrap()).unwrap();
let process_id_str = object.get("processId").unwrap().as_str().unwrap();
let process_id_vec = bs58::decode(process_id_str)
.into_vec()
.expect("base58-encoded public key");
let process_id = Pubkey::new(&process_id_vec);
check_balance(40, &rpc_client, &config_payer.keypair.pubkey()); // config_payer balance
check_balance(10, &rpc_client, &process_id); // contract balance
check_balance(0, &rpc_client, &bob_pubkey); // recipient balance
// Sign transaction by config_witness
config_witness.command = WalletCommand::Witness(bob_pubkey, process_id);
process_command(&config_witness).unwrap();
check_balance(40, &rpc_client, &config_payer.keypair.pubkey()); // config_payer balance
check_balance(0, &rpc_client, &process_id); // contract balance
check_balance(10, &rpc_client, &bob_pubkey); // recipient balance
server.close().unwrap();
remove_dir_all(ledger_path).unwrap();
} | rust_cleaned_test_functions.jsonl/38405 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 943
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62308,
1670,
8091,
17805,
368,
341,
262,
1077,
320,
4030,
11,
7653,
1769,
11,
70433,
11,
46933,
2638,
8,
284,
501,
64959,
5478,
32509,
543,
262,
1077,
35192,
34014,
792,
284,
22611,
792,
486,
93... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_iterator_empty() {
let nums = &vec![];
let mut sap = SumPairs::new(&nums);
assert_eq!(sap.next(), None);
assert_eq!(sap.next(), None);
} | rust_cleaned_test_functions.jsonl/2007 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 102
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13491,
15124,
368,
341,
286,
1077,
10307,
284,
609,
4083,
0,
15078,
286,
1077,
5206,
34635,
284,
8116,
54228,
486,
931,
2099,
26350,
626,
286,
2060,
10714,
10297,
64613,
4529,
1507,
2240,
317,
286... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_that_python_code_parses_and_passes_pyre_check() {
let registry = get_diem_registry();
let abis = get_stdlib_script_abis();
let dir = tempdir().unwrap();
let src_dir_path = dir.path().join("src");
let installer =
serdegen::python3::Installer::new(src_dir_path.clone(), /* package */ None);
let paths = std::fs::read_dir("examples/python3/custom_diem_code")
.unwrap()
.map(|e| e.unwrap().path());
let config = serdegen::CodeGeneratorConfig::new("diem_types".to_string())
.with_encodings(vec![serdegen::Encoding::Bcs])
.with_custom_code(buildgen::read_custom_code_from_paths(
&["diem_types"],
paths,
));
installer.install_module(&config, ®istry).unwrap();
installer.install_serde_runtime().unwrap();
installer.install_bcs_runtime().unwrap();
let stdlib_dir_path = src_dir_path.join("diem_framework");
std::fs::create_dir_all(stdlib_dir_path.clone()).unwrap();
let source_path = stdlib_dir_path.join("__init__.py");
let mut source = std::fs::File::create(&source_path).unwrap();
buildgen::python3::output(&mut source, None, None, &abis).unwrap();
std::fs::copy(
"examples/python3/stdlib_demo.py",
dir.path().join("src/stdlib_demo.py"),
)
.unwrap();
let python_path = format!(
"{}:{}",
std::env::var("PYTHONPATH").unwrap_or_default(),
src_dir_path.to_string_lossy(),
);
let output = Command::new("python3")
.env("PYTHONPATH", python_path)
.arg(dir.path().join("src/stdlib_demo.py"))
.output()
.unwrap();
eprintln!("{}", std::str::from_utf8(&output.stderr).unwrap());
assert!(output.status.success());
assert_eq!(
std::str::from_utf8(&output.stdout).unwrap(),
EXPECTED_OUTPUT
);
let site_packages = Command::new("python3")
.arg("-c")
.arg("import os; import numpy; print(os.path.dirname(numpy.__path__[0]), end='')")
.output()
.unwrap()
.stdout;
let local_bin_path = which::which("pyre")
.unwrap()
.parent()
.unwrap()
.to_path_buf();
let status = Command::new("pyre")
.current_dir(dir.path())
.arg("--source-directory")
.arg("src")
.arg("--noninteractive")
.arg("--binary")
.arg(local_bin_path.join("pyre.bin"))
.arg("--typeshed")
.arg(local_bin_path.join("../lib/pyre_check/typeshed"))
.arg("--search-path")
.arg(String::from_utf8_lossy(&site_packages).as_ref())
.arg("check")
.status()
.unwrap();
assert!(status.success());
} | rust_cleaned_test_functions.jsonl/3889 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1257
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
70197,
55869,
4136,
77113,
288,
8378,
15464,
288,
40291,
265,
7200,
368,
341,
262,
1077,
19424,
284,
633,
814,
26862,
50650,
543,
262,
1077,
668,
285,
284,
633,
15656,
2740,
14660,
62,
15367,
543,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_random_bit_extraction() {
// Length of the data vector we'll be extracting from.
let len = 20;
let rng = &mut XorShiftRng::from_seed(crate::TEST_SEED);
let data: Vec<u8> = (0..len).map(|_| rng.gen()).collect();
// TODO: Evaluate designing a scattered pattered of `pos` and `num_bits`
// instead of repeating too many iterations with any number.
for _ in 0..100 {
let pos = rng.gen_range(0, data.len() / 2);
let num_bits = rng.gen_range(1, data.len() * 8 - pos);
let new_offset = rng.gen_range(0, 8);
let mut bv = BitVecLEu8::new();
bv.extend(
BitVecLEu8::from(&data[..])
.into_iter()
.skip(pos)
.take(num_bits),
);
let shifted_bv: BitVecLEu8 = bv >> new_offset;
assert_eq!(
shifted_bv.as_ref(),
&extract_bits_and_shift(&data, pos, num_bits, new_offset)[..],
);
}
} | rust_cleaned_test_functions.jsonl/32992 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 584
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
22644,
13996,
94842,
368,
341,
286,
442,
17287,
315,
279,
821,
4621,
582,
3278,
387,
59408,
504,
624,
286,
1077,
2422,
284,
220,
17,
15,
401,
286,
1077,
28422,
284,
609,
6984,
1599,
269,
24841,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_parser() {
let p = Commands::default().line_parser();
assert_eq!(
p.parse(":set foo = value"),
Ok((
Command::Set("foo".to_owned(), Value::Ident(String::from("value"))),
""
))
);
assert_eq!(
p.parse(":set scale = 1.0"),
Ok((Command::Set("scale".to_owned(), Value::F64(1.0)), ""))
);
assert_eq!(
p.parse(":set foo=value"),
Ok((
Command::Set("foo".to_owned(), Value::Ident(String::from("value"))),
""
))
);
assert_eq!(
p.parse(":set foo"),
Ok((Command::Set("foo".to_owned(), Value::Bool(true)), ""))
);
assert_eq!(
param::<platform::Key>()
.parse("<hello>")
.unwrap_err()
.0
.to_string(),
"unknown key <hello>"
);
assert_eq!(p.parse(":").unwrap(), (Command::Noop, ""));
} | rust_cleaned_test_functions.jsonl/95931 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 622
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18517,
368,
341,
286,
1077,
281,
284,
47183,
486,
2258,
1005,
1056,
18517,
1428,
286,
2060,
10714,
33673,
310,
281,
4632,
18893,
746,
15229,
284,
897,
4461,
310,
7622,
94702,
394,
7348,
486,
1649,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_persist_transaction_status() {
let GenesisConfigInfo {
genesis_config,
mint_keypair,
..
} = create_genesis_config(1000);
let (ledger_path, _) = create_new_tmp_ledger!(&genesis_config);
{
let blockstore = Blockstore::open(&ledger_path)
.expect("Expected to successfully open database ledger");
let blockstore = Arc::new(blockstore);
let keypair1 = Keypair::new();
let keypair2 = Keypair::new();
let keypair3 = Keypair::new();
let bank0 = Arc::new(Bank::new(&genesis_config));
bank0
.transfer(4, &mint_keypair, &keypair2.pubkey())
.unwrap();
let bank1 = Arc::new(Bank::new_from_parent(&bank0, &Pubkey::default(), 1));
let slot = bank1.slot();
let signatures = create_test_transactions_and_populate_blockstore(
vec![&mint_keypair, &keypair1, &keypair2, &keypair3],
bank0.slot(),
bank1,
blockstore.clone(),
Arc::new(AtomicU64::default()),
);
let confirmed_block = blockstore.get_rooted_block(slot, false).unwrap();
assert_eq!(confirmed_block.transactions.len(), 3);
for TransactionWithStatusMeta { transaction, meta } in
confirmed_block.transactions.into_iter()
{
if transaction.signatures[0] == signatures[0] {
let meta = meta.unwrap();
assert_eq!(meta.status, Ok(()));
} else if transaction.signatures[0] == signatures[1] {
let meta = meta.unwrap();
assert_eq!(
meta.status,
Err(TransactionError::InstructionError(
0,
InstructionError::Custom(1)
))
);
} else {
assert_eq!(meta, None);
}
}
}
Blockstore::destroy(&ledger_path).unwrap();
} | rust_cleaned_test_functions.jsonl/11054 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1203
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9165,
620,
4975,
28884,
4773,
368,
341,
286,
1077,
40788,
2648,
1731,
341,
310,
59366,
5332,
345,
310,
28337,
3097,
12670,
345,
310,
54538,
286,
335,
284,
1855,
16322,
13774,
5332,
7,
16,
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... | 4 |
#[test]
fn test_obscure_problems() {
test_stdout(
"[]++++++++++[>>+>+>++++++[<<+<+++>>>-]<<<<-]\"A*$\";?@![#>>+<<]>[>>]<<<<[>++<[-]]>.>.",
"H\n",
);
} | rust_cleaned_test_functions.jsonl/101574 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 118
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36322,
2388,
552,
2540,
21699,
368,
341,
1066,
262,
1273,
67416,
1006,
286,
330,
1294,
25393,
1027,
58,
2452,
10,
95326,
29,
14565,
1027,
58,
2442,
10,
27,
62730,
20154,
12,
60,
35684,
12,
60,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_copy() {
Python::with_gil(|py| {
let dict = [(7, 32)].into_py_dict(py);
let ndict = dict.copy().unwrap();
assert_eq!(32, ndict.get_item(7i32).unwrap().extract::<i32>().unwrap());
assert!(ndict.get_item(8i32).is_none());
});
} | rust_cleaned_test_functions.jsonl/7717 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 174
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16096,
368,
341,
286,
13027,
486,
4197,
1889,
321,
22428,
3288,
91,
341,
310,
1077,
6451,
284,
17826,
22,
11,
220,
18,
17,
26169,
18122,
40291,
5243,
46827,
626,
310,
1077,
15581,
849,
284,
6451... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_string() {
{
// Empty file
assert!(read_string(&mut &Vec::new()[..]).is_err());
}
{
// Just the prefix
let mut data = &0_i32.to_le_bytes()[..];
assert_eq!(read_string(&mut data).unwrap(), "");
}
// Invalid lengths
let cases: &[&[u8]] = &[
&i32::MIN.to_le_bytes()[..],
&(i32::MIN + 1).to_le_bytes()[..],
&i32::MAX.to_le_bytes()[..],
];
for data in cases {
assert!(read_string(&mut &data.to_vec()[..]).is_err());
}
// Various strings
for test_string in &["", "a", "abc"] {
let encoded = to_encoding(test_string.as_bytes());
assert_eq!(read_string(&mut encoded.as_slice()).unwrap(), *test_string);
}
{
// UTF-16
let test_string = "abc";
let utf16: Vec<u16> = test_string.encode_utf16().collect();
let mut utf16_bytes: Vec<u8> = Vec::new();
for n in utf16 {
utf16_bytes.extend_from_slice(&n.to_le_bytes());
}
let encoded: Vec<u8> = (-(utf16_bytes.len() as i32 + 2))
.to_le_bytes()
.iter()
.chain(utf16_bytes.iter())
.chain([b'\0', b'\0'].iter())
.copied()
.collect();
assert_eq!(read_string(&mut encoded.as_slice()).unwrap(), test_string);
}
} | rust_cleaned_test_functions.jsonl/37246 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 872
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
3904,
368,
341,
286,
341,
310,
442,
22228,
1034,
198,
310,
2060,
10297,
878,
3904,
2099,
6984,
609,
10050,
486,
931,
10116,
496,
10697,
285,
9266,
1423,
286,
456,
286,
341,
310,
442,
4599,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_serde_laporan_status() {
let laporan_status = LaporanStatus::TerkirimBelumDiApprove;
let laporan_status_in_json = laporan_status.to_json();
let expected_laporan_status_in_json = "\"terkirim_belum_di_approve\"";
assert_eq!(laporan_status_in_json, expected_laporan_status_in_json);
} | rust_cleaned_test_functions.jsonl/8641 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 161
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
75861,
450,
907,
71739,
4773,
368,
341,
286,
1077,
326,
71739,
4773,
284,
444,
71739,
2522,
486,
51,
16754,
61372,
21666,
372,
21685,
28588,
586,
280,
286,
1077,
326,
71739,
4773,
1243,
9455,
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_zero_on_nonzero_integer_i64() {
let bytes = &[0; 8];
assert_eq!(
std::num::NonZeroI64::try_from_slice(bytes)
.unwrap_err()
.to_string(),
ERROR_INVALID_ZERO_VALUE
);
} | rust_cleaned_test_functions.jsonl/103724 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 134
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19359,
4470,
21637,
14154,
31725,
5318,
21,
19,
368,
341,
262,
1077,
5820,
284,
44590,
15,
26,
220,
23,
935,
262,
2060,
10714,
33673,
286,
1460,
486,
2413,
486,
8121,
17999,
40,
21,
19,
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... | 1 |
#[test]
fn test_valid_vm_config_cpus() {
vec![
(
vec![
"cloud-hypervisor",
"--kernel",
"/path/to/kernel",
"--cpus",
"boot=1",
],
r#"{
"kernel": {"path": "/path/to/kernel"},
"cpus": {"boot_vcpus": 1, "max_vcpus": 1}
}"#,
true,
),
(
vec![
"cloud-hypervisor",
"--kernel",
"/path/to/kernel",
"--cpus",
"boot=1,max=3",
],
r#"{
"kernel": {"path": "/path/to/kernel"},
"cpus": {"boot_vcpus": 1, "max_vcpus": 3}
}"#,
true,
),
(
vec![
"cloud-hypervisor",
"--kernel",
"/path/to/kernel",
"--cpus",
"boot=2,max=4",
],
r#"{
"kernel": {"path": "/path/to/kernel"},
"cpus": {"boot_vcpus": 1, "max_vcpus": 3}
}"#,
false,
),
]
.iter()
.for_each(|(cli, openapi, equal)| {
compare_vm_config_cli_vs_json(cli, openapi, *equal);
});
} | rust_cleaned_test_functions.jsonl/4720 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1098
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8337,
39008,
5332,
90673,
368,
341,
286,
7486,
90515,
310,
2399,
394,
7486,
90515,
503,
330,
12361,
2832,
1082,
31396,
756,
503,
14482,
23248,
756,
503,
3521,
2343,
32429,
58343,
756,
503,
14482,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_rate_limiter_configs() {
const SIZE: u64 = 1024 * 1024;
const ONE_TIME_BURST: u64 = 1024;
const REFILL_TIME: u64 = 1000;
let b: TokenBucket = TokenBucketConfig {
size: SIZE,
one_time_burst: Some(ONE_TIME_BURST),
refill_time: REFILL_TIME,
}
.into();
assert_eq!(b.capacity(), SIZE);
assert_eq!(b.one_time_burst(), ONE_TIME_BURST);
assert_eq!(b.refill_time_ms(), REFILL_TIME);
let mut rlconf = RateLimiterConfig {
bandwidth: Some(TokenBucketConfig {
size: SIZE,
one_time_burst: Some(ONE_TIME_BURST),
refill_time: REFILL_TIME,
}),
ops: Some(TokenBucketConfig {
size: SIZE * 2,
one_time_burst: None,
refill_time: REFILL_TIME * 2,
}),
};
let rl: RateLimiter = rlconf.try_into().unwrap();
assert_eq!(rl.bandwidth().unwrap().capacity(), SIZE);
assert_eq!(rl.bandwidth().unwrap().one_time_burst(), ONE_TIME_BURST);
assert_eq!(rl.bandwidth().unwrap().refill_time_ms(), REFILL_TIME);
assert_eq!(rl.ops().unwrap().capacity(), SIZE * 2);
assert_eq!(rl.ops().unwrap().one_time_burst(), 0);
assert_eq!(rl.ops().unwrap().refill_time_ms(), REFILL_TIME * 2);
rlconf.update(&RateLimiterConfig {
bandwidth: Some(TokenBucketConfig {
size: SIZE * 2,
one_time_burst: Some(ONE_TIME_BURST * 2),
refill_time: REFILL_TIME * 2,
}),
ops: None,
});
assert_eq!(rlconf.bandwidth.unwrap().size, SIZE * 2);
assert_eq!(
rlconf.bandwidth.unwrap().one_time_burst,
Some(ONE_TIME_BURST * 2)
);
assert_eq!(rlconf.bandwidth.unwrap().refill_time, REFILL_TIME * 2);
assert_eq!(rlconf.ops.unwrap().size, SIZE * 2);
assert_eq!(rlconf.ops.unwrap().one_time_burst, None);
assert_eq!(rlconf.ops.unwrap().refill_time, REFILL_TIME * 2);
} | rust_cleaned_test_functions.jsonl/88255 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1123
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9246,
907,
17700,
59150,
368,
341,
286,
733,
25341,
25,
575,
21,
19,
284,
220,
16,
15,
17,
19,
353,
220,
16,
15,
17,
19,
280,
286,
733,
24038,
10051,
1668,
1511,
784,
25,
575,
21,
19,
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_domain_socket() {
use std::io::prelude::*;
use std::thread;
use tempdir::TempDir;
use unix_socket::UnixListener;
let dir = TempDir::new("unix_socket").expect("failed to create dir");
let socket_path = dir.path().join("sock");
let listener = UnixListener::bind(&socket_path).expect("failed to create socket");
let thread = thread::spawn(move || {
let mut stream = listener.accept().expect("failed to accept connection").0;
stream
.write_all(b"a\tb")
.expect("failed to write test data");
});
new_ucmd!()
.args(&[socket_path])
.succeeds()
.stdout_only("a\tb");
thread.join().unwrap();
} | rust_cleaned_test_functions.jsonl/90945 | {
"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,
20111,
19555,
368,
341,
262,
990,
1460,
486,
815,
486,
1726,
52538,
56162,
262,
990,
1460,
486,
4528,
280,
262,
990,
2730,
3741,
486,
12151,
6184,
280,
262,
990,
51866,
19555,
486,
55832,
2743,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_seek() {
for &input_len in crate::test::TEST_CASES {
println!();
println!("input_len {}", input_len);
let input = make_test_input(input_len);
let (encoded, hash) = encode::encode(&input);
for &seek in crate::test::TEST_CASES {
println!("seek {}", seek);
// Test all three types of seeking.
let mut seek_froms = Vec::new();
seek_froms.push(SeekFrom::Start(seek as u64));
seek_froms.push(SeekFrom::End(seek as i64 - input_len as i64));
seek_froms.push(SeekFrom::Current(seek as i64));
for seek_from in seek_froms {
println!("seek_from {:?}", seek_from);
let mut decoder = Decoder::new(Cursor::new(&encoded), &hash);
let mut output = Vec::new();
decoder.seek(seek_from).expect("seek error");
decoder.read_to_end(&mut output).expect("decoder error");
let input_start = cmp::min(seek, input.len());
assert_eq!(
&input[input_start..],
&output[..],
"output doesn't match input"
);
}
}
}
} | rust_cleaned_test_functions.jsonl/118136 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 764
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
74473,
368,
341,
286,
369,
609,
1355,
6043,
304,
17717,
486,
1944,
486,
10033,
28540,
50,
341,
310,
13751,
0,
543,
310,
13751,
17223,
1355,
6043,
24689,
1946,
6043,
317,
310,
1077,
1946,
284,
12... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
#[test]
fn test_get_rust_src_path_does_not_exist() {
use std::env;
let _guard = TEST_SEMAPHORE.lock().unwrap();
let original = env::var_os("RUST_SRC_PATH");
env::set_var("RUST_SRC_PATH", "test_path");
let result = get_rust_src_path();
match original {
Some(path) => env::set_var("RUST_SRC_PATH", path),
None => env::remove_var("RUST_SRC_PATH"),
}
assert_eq!(
Err(RustSrcPathError::DoesNotExist(path::PathBuf::from(
"test_path"
))),
result
);
} | rust_cleaned_test_functions.jsonl/126172 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 263
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
1710,
590,
16274,
2638,
96374,
7913,
35906,
368,
341,
262,
990,
1460,
486,
3160,
401,
262,
1077,
716,
26098,
284,
13602,
3620,
17617,
39,
5881,
21003,
1005,
15454,
1428,
262,
1077,
4024,
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_trigger_right_hook() {
let mut host = CoprocessorHost::<PanicEngine>::default();
let ob = TestCoprocessor::default();
host.registry
.register_admin_observer(1, BoxAdminObserver::new(ob.clone()));
host.registry
.register_query_observer(1, BoxQueryObserver::new(ob.clone()));
host.registry
.register_apply_snapshot_observer(1, BoxApplySnapshotObserver::new(ob.clone()));
host.registry
.register_role_observer(1, BoxRoleObserver::new(ob.clone()));
host.registry
.register_region_change_observer(1, BoxRegionChangeObserver::new(ob.clone()));
host.registry
.register_cmd_observer(1, BoxCmdObserver::new(ob.clone()));
let region = Region::default();
let mut admin_req = RaftCmdRequest::default();
admin_req.set_admin_request(AdminRequest::default());
host.pre_propose(®ion, &mut admin_req).unwrap();
assert_all!(&[&ob.called], &[1]);
host.pre_apply(®ion, &admin_req);
assert_all!(&[&ob.called], &[3]);
let mut admin_resp = RaftCmdResponse::default();
admin_resp.set_admin_response(AdminResponse::default());
host.post_apply(®ion, &mut Cmd::new(0, admin_req, admin_resp));
assert_all!(&[&ob.called], &[6]);
let mut query_req = RaftCmdRequest::default();
query_req.set_requests(vec![Request::default()].into());
host.pre_propose(®ion, &mut query_req).unwrap();
assert_all!(&[&ob.called], &[10]);
host.pre_apply(®ion, &query_req);
assert_all!(&[&ob.called], &[15]);
let query_resp = RaftCmdResponse::default();
host.post_apply(®ion, &mut Cmd::new(0, query_req, query_resp));
assert_all!(&[&ob.called], &[21]);
host.on_role_change(®ion, StateRole::Leader);
assert_all!(&[&ob.called], &[28]);
host.on_region_changed(®ion, RegionChangeEvent::Create, StateRole::Follower);
assert_all!(&[&ob.called], &[36]);
host.post_apply_plain_kvs_from_snapshot(®ion, "default", &[]);
assert_all!(&[&ob.called], &[45]);
host.post_apply_sst_from_snapshot(®ion, "default", "");
assert_all!(&[&ob.called], &[55]);
let observe_id = ObserveID::new();
host.prepare_for_apply(observe_id, 0);
assert_all!(&[&ob.called], &[66]);
host.on_apply_cmd(
observe_id,
0,
Cmd::new(0, RaftCmdRequest::default(), RaftCmdResponse::default()),
);
assert_all!(&[&ob.called], &[78]);
host.on_flush_apply(PanicEngine);
assert_all!(&[&ob.called], &[91]);
} | rust_cleaned_test_functions.jsonl/17206 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1252
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
32925,
10539,
32005,
368,
341,
286,
1077,
5206,
3468,
284,
24946,
40848,
269,
9296,
27638,
47,
31270,
4571,
6831,
2258,
543,
286,
1077,
1508,
284,
3393,
56277,
40848,
269,
486,
2258,
543,
286,
346... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_multiple_origins() {
let cors = Cors::build()
.allowed_origin("https://example.com")
.allowed_origin("https://example.org")
.allowed_methods(vec![Method::GET])
.finish();
let req = TestRequest::with_header("Origin", "https://example.com")
.method(Method::GET)
.finish();
let resp: HttpResponse = HttpResponse::Ok().into();
let resp = cors.response(&req, resp).unwrap().response();
print!("{:?}", resp);
assert_eq!(
&b"https://example.com"[..],
resp.headers()
.get(header::ACCESS_CONTROL_ALLOW_ORIGIN)
.unwrap()
.as_bytes()
);
let req = TestRequest::with_header("Origin", "https://example.org")
.method(Method::GET)
.finish();
let resp: HttpResponse = HttpResponse::Ok().into();
let resp = cors.response(&req, resp).unwrap().response();
assert_eq!(
&b"https://example.org"[..],
resp.headers()
.get(header::ACCESS_CONTROL_ALLOW_ORIGIN)
.unwrap()
.as_bytes()
);
} | rust_cleaned_test_functions.jsonl/90073 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 641
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
45233,
35328,
1330,
368,
341,
286,
1077,
43911,
284,
52518,
486,
5834,
741,
310,
659,
20967,
34043,
445,
2428,
1110,
8687,
905,
1138,
310,
659,
20967,
34043,
445,
2428,
1110,
8687,
2659,
1138,
310... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_encoding() {
assert_eq!(
Label::from_utf8("abc").unwrap(),
Label::from_raw_bytes(b"abc").unwrap()
);
assert_eq!(
Label::from_utf8("ABC").unwrap(),
Label::from_raw_bytes(b"ABC").unwrap()
);
assert_eq!(
Label::from_utf8("🦀").unwrap(),
Label::from_raw_bytes(b"xn--zs9h").unwrap()
);
assert_eq!(
Label::from_utf8("rust-🦀-icon").unwrap(),
Label::from_raw_bytes(b"xn--rust--icon-9447i").unwrap()
);
assert_eq!(
Label::from_ascii("ben.fry").unwrap(),
Label::from_raw_bytes(b"ben.fry").unwrap()
);
assert_eq!(Label::from_utf8("🦀").unwrap().to_utf8(), "🦀");
assert_eq!(Label::from_utf8("🦀").unwrap().to_ascii(), "xn--zs9h");
} | rust_cleaned_test_functions.jsonl/5048 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 506
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
37613,
368,
341,
286,
2060,
10714,
33673,
310,
9402,
486,
1499,
39453,
23,
445,
13683,
1827,
15454,
3148,
310,
9402,
486,
1499,
16067,
12524,
1883,
1,
13683,
1827,
15454,
741,
286,
1439,
1789,
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_swap() {
let mut m = SmallIntMap::new();
assert_eq!(m.swap(1, 2), None);
assert_eq!(m.swap(1, 3), Some(2));
assert_eq!(m.swap(1, 4), Some(3));
} | rust_cleaned_test_functions.jsonl/7536 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 117
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
40991,
368,
341,
286,
1077,
5206,
296,
284,
14994,
1072,
2227,
486,
931,
543,
286,
2060,
10714,
10297,
76,
54537,
7,
16,
11,
220,
17,
701,
2240,
317,
286,
2060,
10714,
10297,
76,
54537,
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_not_in_array() {
let result = linear_search(&vec![1, 2, 3, 4, 5], 6);
assert_eq!(result, None);
} | rust_cleaned_test_functions.jsonl/50279 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 73
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7913,
1243,
3858,
368,
341,
286,
1077,
1102,
284,
13482,
10716,
2099,
4083,
20703,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
1125,
220,
21,
317,
286,
2060,
10714,
10297,
1382,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_Py_GetVersion() {
let version = unsafe { CStr::from_ptr(Py_GetVersion()) }.to_str().unwrap();
println!("Py_GetVersion: {}", version);
} | rust_cleaned_test_functions.jsonl/118936 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 68
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1088,
88,
13614,
5637,
368,
341,
262,
1077,
2319,
284,
19860,
314,
356,
2580,
486,
1499,
4348,
41998,
13614,
5637,
2140,
16908,
983,
2895,
1005,
15454,
543,
262,
13751,
17223,
13828,
13614,
5637,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_eval_remember_state() {
let cie = make_test_cie();
let ctx = UnwindContext::new();
let mut expected = ctx.clone();
expected.push_row().unwrap();
let instructions = [(Ok(false), CallFrameInstruction::RememberState)];
assert_eval(ctx, expected, cie, None, instructions);
} | rust_cleaned_test_functions.jsonl/9364 | {
"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,
21296,
1288,
9597,
4387,
368,
341,
286,
1077,
272,
645,
284,
1281,
4452,
666,
645,
543,
286,
1077,
5635,
284,
1230,
19154,
1972,
486,
931,
543,
286,
1077,
5206,
3601,
284,
5635,
15997,
543,
286,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_waypoint_parsing() {
let waypoint = Waypoint {
version: 123,
value: HashValue::random(),
};
let waypoint_str = waypoint.to_string();
let parsed_waypoint = Waypoint::from_str(&waypoint_str).unwrap();
assert_eq!(waypoint, parsed_waypoint);
} | rust_cleaned_test_functions.jsonl/17487 | {
"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,
48936,
2768,
620,
28598,
368,
341,
286,
1077,
65176,
284,
12149,
2768,
341,
310,
2319,
25,
220,
16,
17,
18,
345,
310,
897,
25,
6531,
1130,
486,
11463,
3148,
286,
2605,
286,
1077,
65176,
2895,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_comment() {
let res = expression(Span::new("--comment\n"));
assert!(res.is_ok());
assert_eq!(res.unwrap().1, Expr::Comment("comment"))
} | rust_cleaned_test_functions.jsonl/32923 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 77
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
17638,
368,
341,
262,
1077,
592,
284,
7493,
3759,
848,
486,
931,
21549,
6182,
1699,
14929,
262,
2060,
10297,
416,
2079,
19817,
5231,
262,
2060,
10714,
10297,
416,
55395,
1005,
16,
11,
28819... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_encode_datetime() {
let mut buf = PgRawBuffer::default();
Encode::<Postgres>::encode(&POSTGRES_EPOCH, &mut buf);
assert_eq!(&**buf, [0; 8]);
buf.clear();
// one hour past epoch
let date = POSTGRES_EPOCH + 1.hours();
Encode::<Postgres>::encode(&date, &mut buf);
assert_eq!(&**buf, 3_600_000_000i64.to_be_bytes());
buf.clear();
// some random date
let date = PrimitiveDateTime::new(date!(2019 - 12 - 11), time!(11:01:05));
let expected = (date - POSTGRES_EPOCH).whole_microseconds() as i64;
Encode::<Postgres>::encode(&date, &mut buf);
assert_eq!(&**buf, expected.to_be_bytes());
buf.clear();
} | rust_cleaned_test_functions.jsonl/21436 | {
"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,
11224,
28943,
368,
341,
262,
1077,
5206,
6607,
284,
97265,
20015,
4095,
486,
2258,
1428,
262,
56562,
27638,
4133,
17818,
6831,
6180,
2099,
2946,
91891,
2089,
69945,
11,
609,
6984,
6607,
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_miles_to_au() {
let res = Mile::new(1.0e7).convert_scalar(&DistanceUnit::AstronomicalUnit);
assert!(res.is_ok());
assert!(is_close(0.107_642_264, res.unwrap()), "res was {:?}", res);
} | rust_cleaned_test_functions.jsonl/111639 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 118
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
717,
3658,
2346,
62,
2863,
368,
341,
286,
1077,
592,
284,
38597,
486,
931,
7,
16,
13,
15,
68,
22,
568,
14166,
41652,
2099,
14778,
4562,
486,
32,
495,
14274,
938,
4562,
626,
286,
2060,
10297,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_accounts_db_purge1() {
solana_logger::setup();
let some_lamport = 223;
let zero_lamport = 0;
let no_data = 0;
let owner = Account::default().owner;
let account = Account::new(some_lamport, no_data, &owner);
let pubkey = Pubkey::new_rand();
let zero_lamport_account = Account::new(zero_lamport, no_data, &owner);
let accounts = AccountsDB::new_single();
accounts.add_root(0);
let mut current_slot = 1;
accounts.set_hash(current_slot, current_slot - 1);
accounts.store(current_slot, &[(&pubkey, &account)]);
accounts.add_root(current_slot);
current_slot += 1;
accounts.set_hash(current_slot, current_slot - 1);
accounts.store(current_slot, &[(&pubkey, &zero_lamport_account)]);
accounts.add_root(current_slot);
assert_load_account(&accounts, current_slot, pubkey, zero_lamport);
// Otherwise slot 2 will not be removed
current_slot += 1;
accounts.set_hash(current_slot, current_slot - 1);
accounts.add_root(current_slot);
print_accounts("pre_purge", &accounts);
let ancestors = linear_ancestors(current_slot);
info!("ancestors: {:?}", ancestors);
let hash = accounts.update_accounts_hash(current_slot, &ancestors);
accounts.clean_accounts();
assert_eq!(
accounts.update_accounts_hash(current_slot, &ancestors),
hash
);
print_accounts("post_purge", &accounts);
// Make sure the index is for pubkey cleared
assert!(accounts
.accounts_index
.read()
.unwrap()
.account_maps
.get(&pubkey)
.is_none());
assert_no_stores(&accounts, 1);
assert_no_stores(&accounts, 2);
} | rust_cleaned_test_functions.jsonl/33682 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 865
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
55665,
8685,
620,
39823,
16,
368,
341,
286,
2048,
3362,
27413,
486,
15188,
543,
286,
1077,
1045,
907,
309,
403,
284,
220,
17,
17,
18,
280,
286,
1077,
7168,
907,
309,
403,
284,
220,
15,
280,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_mvcc_txn_prewrite() {
test_mvcc_txn_prewrite_imp(b"k1", b"v1");
let long_value = gen_value(b'v', SHORT_VALUE_MAX_LEN + 1);
test_mvcc_txn_prewrite_imp(b"k2", &long_value);
} | rust_cleaned_test_functions.jsonl/23326 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 130
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
73187,
638,
92299,
620,
52473,
368,
341,
286,
1273,
73187,
638,
92299,
620,
52473,
36788,
1883,
62911,
16,
497,
293,
1,
85,
16,
3071,
286,
1077,
1293,
3142,
284,
4081,
3142,
1883,
6,
85,
516,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_linking_with_period_crossing() {
run_test_with_periodicity(Timestamp::new(100.0), || {
let ipps1 = [
TTFPoint {
at: Timestamp::ZERO,
val: FlWeight::new(105.0),
},
TTFPoint {
at: Timestamp::new(50.0),
val: FlWeight::new(95.0),
},
TTFPoint {
at: period(),
val: FlWeight::new(105.0),
},
];
let ipps2 = [
TTFPoint {
at: Timestamp::ZERO,
val: FlWeight::new(10.0),
},
TTFPoint {
at: Timestamp::new(60.0),
val: FlWeight::new(15.0),
},
TTFPoint {
at: period(),
val: FlWeight::new(10.0),
},
];
let linked = PeriodicPiecewiseLinearFunction::new(&ipps1).link(&PeriodicPiecewiseLinearFunction::new(&ipps2));
assert_eq!(5, linked.len())
});
} | rust_cleaned_test_functions.jsonl/38573 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 774
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7233,
287,
6615,
20818,
35284,
287,
368,
341,
286,
1598,
4452,
6615,
20818,
61691,
4140,
4702,
486,
931,
7,
16,
15,
15,
13,
15,
701,
1369,
341,
310,
1077,
5997,
1690,
16,
284,
2278,
394,
350,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_iterator_peekable_rfold() {
let xs = [0, 1, 2, 3, 4, 5];
let mut it = xs.iter().peekable();
assert_eq!(it.peek(), Some(&&0));
let i = it.rfold(0, |i, &x| {
assert_eq!(x, xs[xs.len() - 1 - i]);
i + 1
});
assert_eq!(i, xs.len());
} | rust_cleaned_test_functions.jsonl/70161 | {
"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,
13491,
62,
29107,
480,
1710,
19961,
368,
341,
262,
1077,
11943,
284,
508,
15,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
935,
262,
1077,
5206,
432,
284,
11943,
19471,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_breakpad_functions() -> Result<(), Error> {
let view = ByteView::open(fixture("windows/crash.sym"))?;
let object = Object::parse(&view)?;
let session = object.debug_session()?;
let functions = session.functions().collect::<Result<Vec<_>, _>>()?;
insta::assert_debug_snapshot!("breakpad_functions", FunctionsDebug(&functions[..10], 0));
Ok(())
} | rust_cleaned_test_functions.jsonl/82871 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 148
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39494,
13242,
31708,
368,
1464,
5714,
68843,
4600,
29,
341,
262,
1077,
1651,
284,
10906,
851,
486,
2508,
94886,
445,
27077,
2899,
81,
988,
50901,
2761,
37445,
262,
1077,
1633,
284,
3002,
486,
6400... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_schema_config_changes() {
use storage::StorageValue;
let sandbox = timestamping_sandbox();
let sandbox_state = SandboxState::new();
add_one_height(&sandbox, &sandbox_state);
let (tx_cfg, following_cfg) = {
let mut consensus_cfg = sandbox.cfg();
consensus_cfg.consensus.txs_block_limit = 2000;
consensus_cfg.actual_from = sandbox.current_height().next().next();
consensus_cfg.previous_cfg_hash = sandbox.cfg().hash();
let tx = TxConfig::new(
&sandbox.p(VALIDATOR_0),
&consensus_cfg.clone().into_bytes(),
consensus_cfg.actual_from,
sandbox.s(VALIDATOR_0),
);
(tx, consensus_cfg)
};
let prev_cfg = sandbox.cfg();
// Check configuration from genesis block
assert_eq!(
Schema::new(&sandbox.blockchain_ref().snapshot()).actual_configuration(),
prev_cfg
);
// Try to get configuration from non exists height
assert_eq!(
Schema::new(&sandbox.blockchain_ref().snapshot()).configuration_by_height(HEIGHT_FOUR),
prev_cfg
);
// Commit a new configuration
add_one_height_with_transactions(&sandbox, &sandbox_state, &[tx_cfg.raw().clone()]);
// Check that following configuration is visible
assert_eq!(
Schema::new(&sandbox.blockchain_ref().snapshot()).following_configuration(),
Some(following_cfg.clone())
);
// Make following configuration actual
add_one_height(&sandbox, &sandbox_state);
add_one_height_with_transactions(&sandbox, &sandbox_state, &[]);
// Check that following configuration becomes actual
assert_eq!(
Schema::new(&sandbox.blockchain_ref().snapshot()).actual_configuration(),
following_cfg
);
// Check previous configuration
assert_eq!(
Schema::new(&sandbox.blockchain_ref().snapshot())
.previous_configuration()
.unwrap(),
prev_cfg
);
// Finally check configuration for some heights
assert_eq!(
Schema::new(&sandbox.blockchain_ref().snapshot()).configuration_by_height(HEIGHT_ZERO),
prev_cfg
);
assert_eq!(
Schema::new(&sandbox.blockchain_ref().snapshot())
.configuration_by_height(sandbox.current_height()),
following_cfg
);
} | rust_cleaned_test_functions.jsonl/8888 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 961
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25371,
5332,
47526,
368,
341,
262,
990,
5819,
486,
5793,
1130,
401,
262,
1077,
42754,
284,
11441,
287,
643,
31536,
543,
262,
1077,
42754,
4387,
284,
96860,
1397,
486,
931,
1428,
262,
912,
11667,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_option() {
assert_missing!(eval!("Option()"), "Every value was missing");
assert_missing!(eval!("Option(a, b, c, d)"), "Every value was missing");
assert_eq!(eval!("Option(5)"), i(5));
assert_eq!(eval!("Option(5, a)"), i(5));
assert_eq!(eval!("Option(a, 5, a)"), i(5));
assert_eq!(eval!("Option(a, b, c, d, 5)"), i(5));
assert_eq!(eval!("Option(a, b, [], d)"), MetricValue::Vector(vec![]));
assert_eq!(eval!("Option(a, b, [], d, [5])"), MetricValue::Vector(vec![i(5)]));
assert_eq!(eval!("Option(a, b, 5, d, [5])"), i(5));
assert_eq!(eval!("Option(a, b, [5], d, 5)"), MetricValue::Vector(vec![i(5)]));
} | rust_cleaned_test_functions.jsonl/68260 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 356
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9672,
368,
341,
286,
2060,
40447,
10297,
14170,
17223,
5341,
368,
3975,
330,
11510,
897,
572,
7402,
797,
286,
2060,
40447,
10297,
14170,
17223,
5341,
2877,
11,
293,
11,
272,
11,
294,
8,
3975,
33... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_exec() {
let toml_str = include_str!("./genesis_services.toml");
let genesis: Genesis = toml::from_str(toml_str).unwrap();
let db = Arc::new(MemoryDB::new(false));
let root = ServiceExecutor::create_genesis(
genesis.services,
Arc::clone(&db),
Arc::new(MockStorage {}),
Arc::new(MockServiceMapping {}),
)
.unwrap();
let mut executor = ServiceExecutor::with_root(
root.clone(),
Arc::clone(&db),
Arc::new(MockStorage {}),
Arc::new(MockServiceMapping {}),
)
.unwrap();
let params = ExecutorParams {
state_root: root,
height: 1,
timestamp: 0,
cycles_limit: std::u64::MAX,
proposer: Address::from_hash(Hash::from_empty()).unwrap(),
};
let stx = mock_signed_tx();
let txs = vec![stx];
let executor_resp = executor.exec(Context::new(), ¶ms, &txs).unwrap();
let receipt = &executor_resp.receipts[0];
assert_eq!(receipt.response.response.code, 0);
let asset: Asset = serde_json::from_str(&receipt.response.response.succeed_data).unwrap();
assert_eq!(asset.name, "MutaToken2");
assert_eq!(asset.symbol, "MT2");
assert_eq!(asset.supply, 320_000_011);
} | rust_cleaned_test_functions.jsonl/50147 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 578
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18430,
368,
341,
262,
1077,
311,
1014,
2895,
284,
2924,
2895,
0,
13988,
77894,
39846,
73494,
75,
797,
262,
1077,
59366,
25,
40788,
284,
311,
1014,
486,
1499,
2895,
1155,
316,
75,
2895,
568,
1545... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_instant_and_data() {
// verify implementation of InstantAndData to be used as a complex type
// in a BinaryHeap:
let mut heap = BinaryHeap::<InstantAndData<usize>>::new();
let now = DummyInstant::default();
fn new_data(time: DummyInstant, id: usize) -> InstantAndData<usize> {
InstantAndData::new(time, id)
}
heap.push(new_data(now + Duration::from_secs(1), 1));
heap.push(new_data(now + Duration::from_secs(2), 2));
// earlier timer is popped first
assert!(heap.pop().unwrap().1 == 1);
assert!(heap.pop().unwrap().1 == 2);
assert!(heap.pop().is_none());
heap.push(new_data(now + Duration::from_secs(1), 1));
heap.push(new_data(now + Duration::from_secs(1), 1));
// can pop twice with identical data:
assert!(heap.pop().unwrap().1 == 1);
assert!(heap.pop().unwrap().1 == 1);
assert!(heap.pop().is_none());
} | rust_cleaned_test_functions.jsonl/29517 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 450
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1243,
4706,
8378,
1769,
368,
341,
286,
442,
10146,
8129,
315,
18058,
3036,
1043,
311,
387,
1483,
438,
264,
6351,
943,
198,
286,
442,
304,
264,
17718,
27909,
510,
286,
1077,
5206,
17364,
284,
177... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_plain_into_header_value() {
let challenge = Basic {
realm: None,
};
let value = challenge.try_into();
assert!(value.is_ok());
let value = value.unwrap();
assert_eq!(value, "Basic");
} | rust_cleaned_test_functions.jsonl/52032 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 134
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
41015,
45514,
8757,
3142,
368,
341,
286,
1077,
8645,
284,
14625,
341,
310,
21889,
25,
2240,
345,
286,
3634,
286,
1077,
897,
284,
8645,
48779,
45514,
543,
286,
2060,
10297,
957,
2079,
19817,
1423,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_sort_classes_vec() {
assert_eq!(
sort_classes_vec(
vec![
"inline",
"inline-block",
"random-class",
"py-2",
"justify-end",
"px-2",
"flex"
]
.into_iter()
),
vec![
"inline-block",
"inline",
"flex",
"justify-end",
"py-2",
"px-2",
"random-class",
]
)
} | rust_cleaned_test_functions.jsonl/70801 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 385
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18435,
16833,
13251,
368,
341,
262,
2060,
10714,
33673,
286,
3378,
16833,
13251,
1006,
310,
7486,
90515,
394,
330,
5057,
756,
394,
330,
5057,
9425,
756,
394,
330,
11463,
14800,
756,
394,
330,
3288... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ipranges() {
let app = app(Forwarding::trust_ips(["10.10.10.10", "192.168.0.0/16"]));
assert_ok!(
get("/")
.with_request_header(("forwarded", "for=192.0.2.60;proto=https;host=example.com"))
.with_peer_ip("10.10.10.10".parse().unwrap())
.on(&app),
"true Some(192.0.2.60) Some(\"example.com\")"
);
assert_ok!(
get("/")
.with_request_header(("forwarded", "for=192.0.2.60;proto=https;host=example.com"))
.with_peer_ip("192.168.1.1".parse().unwrap())
.on(&app),
"true Some(192.0.2.60) Some(\"example.com\")"
);
assert_ok!(
get("/")
.with_request_header(("forwarded", "for=192.0.2.60;proto=https"))
.with_peer_ip("10.10.10.1".parse().unwrap())
.on(&app),
"false Some(10.10.10.1) None"
);
assert_ok!(
get("/")
.with_request_header(("forwarded", "for=192.0.2.60;proto=https"))
.with_peer_ip("192.169.1.1".parse().unwrap())
.on(&app),
"false Some(192.169.1.1) None"
);
} | rust_cleaned_test_functions.jsonl/76808 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 628
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10385,
66562,
368,
341,
262,
1077,
906,
284,
906,
7,
25925,
287,
486,
56655,
71074,
19065,
16,
15,
13,
16,
15,
13,
16,
15,
13,
16,
15,
497,
330,
16,
24,
17,
13,
16,
21,
23,
13,
15,
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... | 1 |
#[test]
fn test_solid_field_be_empty() {
let mut cmd = assert_cmd::Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap();
cmd.args(&["-s", "-d", ",", "-f", "3-", "grep", "G"])
.write_stdin("AAA,BBB,CCC,DDD\nEEE,FFF,GGG,HHH\n")
.assert()
.stdout("AAA,BBB,,\nEEE,FFF,GGG,\n");
} | rust_cleaned_test_functions.jsonl/7938 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 194
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
643,
5192,
5013,
21263,
15124,
368,
341,
286,
1077,
5206,
5439,
284,
2060,
11684,
486,
4062,
486,
66715,
21816,
16978,
17223,
34,
7581,
46,
94126,
4708,
15197,
15454,
543,
286,
5439,
16365,
2099,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_aead_encrypt() {
const pt: [u8; AES_BLOCKSIZE] = [
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
0x41, 0x41,
];
const assocdata: [u8; 16] = [
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
];
let mut ct = [0u8; pt.len()];
const ct_exp: [u8; pt.len()] = [
0x42, 0xc9, 0x9b, 0x8f, 0x21, 0xf7, 0xe2, 0xd3, 0xb2, 0x69, 0x83, 0xf8, 0x30, 0xf3,
0xbf, 0x39,
];
const taglen: usize = 16;
const assoclen: usize = assocdata.len();
let mut tag = [0u8; taglen];
const tag_exp: [u8; taglen] = [
0x10, 0x8f, 0x8e, 0x8f, 0x78, 0xdd, 0x83, 0xd0, 0xf, 0xe2, 0xa2, 0x79, 0xc3, 0xce,
0xb2, 0x43,
];
let key = [0u8; AES128_KEYSIZE];
let iv = [0u8; AES_BLOCKSIZE];
let alg = CString::new("gcm(aes)").expect("Failed to init CString");
let mut outbuf = [0u8; pt.len() + taglen + assoclen];
let assocdata_offset: usize = 0;
let ct_offset = assocdata_offset + assoclen;
let tag_offset = ct_offset + taglen;
outbuf[assocdata_offset..ct_offset].clone_from_slice(&assocdata);
outbuf[ct_offset..tag_offset].clone_from_slice(&pt);
let mut ret: i64;
unsafe {
let mut handle =
Box::into_raw(Box::new(kcapi_handle { _unused: [0u8; 0] })) as *mut kcapi_handle;
ret = (kcapi_aead_init(&mut handle as *mut _, alg.as_ptr(), 0))
.try_into()
.expect("Failed to convert i32 to i64");
assert_eq!(ret, 0);
ret = (kcapi_aead_settaglen(handle, taglen as u32))
.try_into()
.expect("Failed to convert i32 to i64");
assert_eq!(ret, 0);
kcapi_aead_setassoclen(handle, assoclen as u64);
let mut newiv = &mut [0u8; 48] as *mut u8;
let mut newivlen: u32 = 0;
ret = (kcapi_pad_iv(
handle,
iv.as_ptr(),
iv.len() as u32,
&mut newiv as *mut _,
&mut newivlen as *mut u32,
))
.try_into()
.expect("Failed to convert i32 to i64");
assert_eq!(ret, 0);
let outbuflen =
kcapi_aead_outbuflen_enc(handle, pt.len() as u64, assoclen as u64, taglen as u64);
let inbuflen =
kcapi_aead_inbuflen_enc(handle, pt.len() as u64, assoclen as u64, taglen as u64);
ret = (kcapi_aead_setkey(handle, key.as_ptr(), key.len() as u32))
.try_into()
.expect("Failed to convert i32 to i64");
assert_eq!(ret, 0);
ret = kcapi_aead_encrypt(
handle,
outbuf.as_ptr(),
inbuflen,
newiv,
outbuf.as_mut_ptr(),
outbuflen,
KCAPI_ACCESS_HEURISTIC as i32,
);
assert_eq!(ret, outbuf.len() as i64);
ct.clone_from_slice(&outbuf[assocdata.len()..assocdata.len() + pt.len()]);
tag.clone_from_slice(&outbuf[tag_offset..]);
}
assert_eq!(ct, ct_exp);
assert_eq!(tag, tag_exp);
} | rust_cleaned_test_functions.jsonl/9068 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2035
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4306,
3149,
66593,
368,
341,
286,
733,
10817,
25,
508,
84,
23,
26,
38841,
18756,
20494,
60,
284,
2278,
310,
220,
15,
87,
19,
16,
11,
220,
15,
87,
19,
16,
11,
220,
15,
87,
19,
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... | 1 |
#[test]
fn test_large_sigs() {
// use any large number to be misinterpreted as 2 bytes when decoded as short_vec
let required_num_sigs = 214;
let actual_num_sigs = 5;
let packet = packet_from_num_sigs(required_num_sigs, actual_num_sigs);
let unsanitized_packet_offsets = sigverify::do_get_packet_offsets(&packet, 0);
assert_eq!(
unsanitized_packet_offsets,
Err(PacketError::MismatchSignatureLen)
);
} | rust_cleaned_test_functions.jsonl/70704 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 229
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
45228,
643,
14462,
368,
341,
286,
442,
990,
894,
3460,
1372,
311,
387,
5786,
93461,
438,
220,
17,
5820,
979,
29213,
438,
2805,
13251,
198,
286,
1077,
2567,
4273,
643,
14462,
284,
220,
17,
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_shortest_distance() {
assert_eq!(Solution::shortest_distance(vec_vec_i32![[1, 0, 2, 0, 1], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0]]), 7);
} | rust_cleaned_test_functions.jsonl/81683 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 88
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16673,
477,
19464,
368,
341,
286,
2060,
10714,
10297,
36842,
486,
8676,
477,
19464,
25592,
13251,
5318,
18,
17,
0,
15505,
16,
11,
220,
15,
11,
220,
17,
11,
220,
15,
11,
220,
16,
1125,
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,
1... | 1 |
#[test]
fn test_parse_valid_sqs_delete_message_batch() {
let mock_response = MockResponseReader::read_response(
"test_resources/generated/valid",
"sqs-delete-message-batch.xml",
);
let mock = MockRequestDispatcher::with_status(200).with_body(&mock_response);
let client = SqsClient::new_with(mock, MockCredentialsProvider, rusoto_region::UsEast1);
let request = DeleteMessageBatchRequest::default();
let result = client.delete_message_batch(request).sync();
assert!(result.is_ok(), "parse error: {:?}", result);
} | rust_cleaned_test_functions.jsonl/49935 | {
"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,
8337,
643,
26358,
11353,
6462,
14534,
368,
341,
286,
1077,
7860,
9655,
284,
14563,
2582,
5062,
486,
878,
9655,
1006,
310,
330,
1944,
35569,
79372,
14,
1891,
756,
310,
330,
82,
26358,
40904,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_create_subkey_disposition() {
let hkcu = RegKey::predef(HKEY_CURRENT_USER);
let path = "Software\\WinRegRsTestCreateSubkey";
let (_subkey, disp) = hkcu.create_subkey(path).unwrap();
assert_eq!(disp, REG_CREATED_NEW_KEY);
let (_subkey2, disp2) = hkcu.create_subkey(path).unwrap();
assert_eq!(disp2, REG_OPENED_EXISTING_KEY);
hkcu.delete_subkey_all(&path).unwrap();
} | rust_cleaned_test_functions.jsonl/128083 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 186
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8657,
5228,
792,
9932,
3487,
368,
341,
262,
1077,
83381,
20199,
284,
3184,
1592,
486,
1726,
750,
10896,
4784,
32938,
9107,
317,
262,
1077,
1815,
284,
330,
19250,
3422,
16970,
3477,
42327,
2271,
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... | 1 |
#[test]
fn test_pop() {
let mut list = ConcurrentList::new();
list.push("1".to_owned());
list.push("2".to_owned());
list.push("3".to_owned());
assert_eq!(list.pop().unwrap(), "3");
assert_eq!(list.pop().unwrap(), "2");
assert_eq!(list.pop().unwrap(), "1");
assert_eq!(list.pop(), None);
list.push("1".to_owned());
list.push("2".to_owned());
list.push("3".to_owned());
let mut iter = list.into_iter();
assert_eq!(iter.next().unwrap(), "3");
drop(iter);
} | rust_cleaned_test_functions.jsonl/99284 | {
"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,
17061,
368,
341,
262,
1077,
5206,
1140,
284,
42704,
852,
486,
931,
1428,
262,
1140,
2552,
445,
16,
3263,
983,
51973,
1423,
262,
1140,
2552,
445,
17,
3263,
983,
51973,
1423,
262,
1140,
2552,
445,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_verify_account_references() {
let accounts = vec![(
solana_sdk::pubkey::new_rand(),
Rc::new(RefCell::new(AccountSharedData::default())),
)];
assert!(MessageProcessor::verify_account_references(&accounts).is_ok());
let mut _borrowed = accounts[0].1.borrow();
assert_eq!(
MessageProcessor::verify_account_references(&accounts),
Err(InstructionError::AccountBorrowOutstanding)
);
} | rust_cleaned_test_functions.jsonl/15691 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 235
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
35638,
13500,
92702,
368,
341,
286,
1077,
9618,
284,
7486,
20703,
1006,
310,
2048,
3362,
61783,
486,
9585,
792,
486,
931,
33864,
3148,
310,
81463,
486,
931,
7,
3945,
3599,
486,
931,
65360,
16997,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_hook10() {
test("((function () {}), true) ? a() : b()", "a()");
test(
"((function () {alert(x)})(), true) ? a() : b()",
"(function(){alert(x)})(),a()",
);
} | rust_cleaned_test_functions.jsonl/439 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 103
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
32005,
16,
15,
368,
341,
262,
1273,
445,
1188,
1688,
1719,
4687,
701,
830,
8,
937,
264,
368,
549,
293,
50514,
330,
64,
45961,
262,
1273,
1006,
286,
330,
1188,
1688,
1719,
314,
5083,
2075,
9832... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_format_docs_handles_rust_alias() {
let comment = "```ignore\nlet z = 55;\n```";
assert_eq!(format_docs(comment), "```rust\nlet z = 55;\n```");
} | rust_cleaned_test_functions.jsonl/57085 | {
"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,
8955,
49692,
68017,
1710,
590,
35947,
368,
341,
286,
1077,
3980,
284,
330,
73594,
13130,
1699,
1149,
1147,
284,
220,
20,
20,
17882,
77,
73594,
876,
286,
2060,
10714,
10297,
2243,
49692,
39327,
701... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_import_mode_timeout() {
let temp_dir = Builder::new()
.prefix("test_import_mode_timeout")
.tempdir()
.unwrap();
let db = new_test_engine(temp_dir.path().to_str().unwrap(), &["a", "b"]);
let import_db_options = ImportModeDBOptions::new();
let normal_db_options = ImportModeDBOptions::new_options(&db);
let import_cf_options = ImportModeCFOptions::new();
let normal_cf_options = ImportModeCFOptions::new_options(&db, "default");
fn mf(_cf: &str, _name: &str, _v: f64) {}
let cfg = Config {
import_mode_timeout: ReadableDuration::millis(300),
..Config::default()
};
let threads = futures_cpupool::Builder::new()
.name_prefix("sst-importer")
.pool_size(cfg.num_threads)
.create();
let mut switcher = ImportModeSwitcher::new(&cfg, &threads, db.clone());
check_import_options(&db, &normal_db_options, &normal_cf_options);
switcher.enter_import_mode(mf).unwrap();
check_import_options(&db, &import_db_options, &import_cf_options);
thread::sleep(Duration::from_secs(1));
check_import_options(&db, &normal_db_options, &normal_cf_options);
} | rust_cleaned_test_functions.jsonl/29500 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 583
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18434,
7302,
20537,
368,
341,
286,
1077,
2730,
4334,
284,
20626,
486,
931,
741,
310,
659,
11849,
445,
1944,
18434,
7302,
20537,
1138,
310,
659,
3888,
3741,
741,
310,
659,
15454,
543,
286,
1077,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_u32_bigendian() {
let mut storage = vec![0; 1024];
type Field1 = PrimitiveField<u32, BigEndian, 5>;
type Field2 = PrimitiveField<u32, BigEndian, 20>;
Field1::write(&mut storage, 10u32.pow(8));
Field2::write(&mut storage, 10u32.pow(7));
assert_eq!(
10u32.pow(8),
u32::from_be_bytes((&storage[5..9]).try_into().unwrap())
);
assert_eq!(
10u32.pow(7),
u32::from_be_bytes((&storage[20..24]).try_into().unwrap())
);
assert_eq!(10u32.pow(8), Field1::read(&storage));
assert_eq!(10u32.pow(7), Field2::read(&storage));
assert_eq!(Some(4), PrimitiveField::<u32, BigEndian, 5>::SIZE);
assert_eq!(Some(4), PrimitiveField::<u32, BigEndian, 5>::SIZE);
} | rust_cleaned_test_functions.jsonl/35732 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 430
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7300,
18,
17,
36386,
408,
1103,
368,
341,
286,
1077,
5206,
5819,
284,
7486,
20703,
15,
26,
220,
16,
15,
17,
19,
4821,
286,
943,
8601,
16,
284,
51460,
1877,
34837,
18,
17,
11,
6164,
43231,
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_write_read_many() {
let mut t: Turbine<TestSlot> = Turbine::new(1024);
let e1 = t.ep_new().unwrap();
let event_processor = t.ep_finalize(e1);
let (tx, rx): (Sender<isize>, Receiver<isize>) = channel();
let _future = thread::spawn(move|| {
let counter = AtomicUsize::new(0);
event_processor.start::<_, BusyWait>(|data: &[TestSlot]| -> Result<(),()> {
let mut last = 0;
let mut previous = 0;
for x in data.iter() {
debug!("EP:: last: {}, value: {}", last, x.value);
assert!(last + 1 == x.value);
previous = counter.fetch_add(1, Ordering::SeqCst);
last = x.value;
debug!("EP::counter: {}", counter.load(Ordering::SeqCst));
}
if previous == 1000 {
return Err(());
} else {
return Ok(());
}
});
let _ = tx.send(1);
});
assert!(t.current_pos == 0);
for i in 0u64..1000 {
let mut x: TestSlot = Slot::new();
x.value = i as i32;
debug!("Writing: {}", x.value);
t.write(x);
}
if rx.recv().is_err() == true {panic!()}
} | rust_cleaned_test_functions.jsonl/65717 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 793
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9165,
6443,
22101,
368,
341,
286,
1077,
5206,
259,
25,
8705,
46561,
71273,
19877,
29,
284,
8705,
46561,
486,
931,
7,
16,
15,
17,
19,
317,
286,
1077,
384,
16,
284,
259,
33376,
5921,
1005,
15454... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
#[test]
fn test_or_with_one_gte_to_string() {
let name1 = _random_vector(10);
let value1 = _random_string(10);
let query = Operator::Or(
vec![
Operator::Gte(
TagName::PlainTagName(name1.clone()),
TargetValue::Unencrypted(value1.clone())
)
]
);
let json = query.to_string();
let expected = format!(r#"{{"$or":[{{"~{}":{{"$gte":"{}"}}}}]}}"#, base64::encode(&name1), value1);
assert_eq!(json, expected);
} | rust_cleaned_test_functions.jsonl/11911 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 315
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8734,
6615,
11667,
1889,
665,
2346,
3904,
368,
341,
286,
1077,
829,
16,
284,
716,
11463,
12247,
7,
16,
15,
317,
286,
1077,
897,
16,
284,
716,
11463,
3904,
7,
16,
15,
626,
286,
1077,
3239,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_source_code_headers_get_and_save() {
let (_temp_dir, fetcher) = test_setup();
let url = Url::parse("http://example.com/f.js").unwrap();
let headers_filepath = fetcher.deps_cache.location.join(
fetcher
.deps_cache
.get_cache_filename_with_extension(&url, "headers.json"),
);
if let Some(ref parent) = headers_filepath.parent() {
fs::create_dir_all(parent).unwrap();
};
let _ = deno_fs::write_file(
headers_filepath.as_path(),
"{\"mime_type\":\"text/javascript\",\"redirect_to\":\"http://example.com/a.js\"}",
0o666,
);
let headers = fetcher.get_source_code_headers(&url);
assert_eq!(headers.mime_type.clone().unwrap(), "text/javascript");
assert_eq!(headers.redirect_to.unwrap(), "http://example.com/a.js");
assert_eq!(headers.etag, None);
let _ = fetcher.save_source_code_headers(
&url,
Some("text/typescript".to_owned()),
Some("http://deno.land/a.js".to_owned()),
Some("W/\"04572f4749af993f4961a7e5daa1e4d5\"".to_owned()),
);
let headers2 = fetcher.get_source_code_headers(&url);
assert_eq!(headers2.mime_type.clone().unwrap(), "text/typescript");
assert_eq!(headers2.redirect_to.unwrap(), "http://deno.land/a.js");
assert_eq!(
headers2.etag.unwrap(),
"W/\"04572f4749af993f4961a7e5daa1e4d5\""
);
} | rust_cleaned_test_functions.jsonl/16749 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 625
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10347,
4136,
26719,
3062,
8378,
15376,
368,
341,
262,
1077,
5453,
3888,
4334,
11,
7807,
261,
8,
284,
1273,
21363,
543,
262,
1077,
2515,
284,
22840,
486,
6400,
445,
1254,
1110,
8687,
905,
6663,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_read_hash_sync() {
let tmp = tempfile::tempdir().unwrap();
let dir = tmp.path().to_owned();
let sri = crate::write_sync(&dir, "my-key", b"hello world").unwrap();
let data = crate::read_hash_sync(&dir, &sri).unwrap();
assert_eq!(data, b"hello world");
} | rust_cleaned_test_functions.jsonl/64596 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 146
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
8950,
23008,
368,
341,
286,
1077,
4174,
284,
54819,
486,
3888,
3741,
1005,
15454,
543,
286,
1077,
5419,
284,
4174,
3875,
1005,
983,
51973,
543,
286,
1077,
274,
461,
284,
17717,
486,
4934,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_scalar_repr_vartime_conversion() {
let a = Scalar::from(1);
let mut expected_bytes = [0u8; 32];
expected_bytes[0] = 1;
assert_eq!(a, Scalar::from_repr_vartime(a.to_repr()).unwrap());
assert_eq!(a.to_repr(), expected_bytes);
assert_eq!(a, Scalar::from_repr_vartime(expected_bytes).unwrap());
let a = Scalar::from(12);
let mut expected_bytes = [0u8; 32];
expected_bytes[0] = 12;
assert_eq!(a, Scalar::from_repr_vartime(a.to_repr()).unwrap());
assert_eq!(a.to_repr(), expected_bytes);
assert_eq!(a, Scalar::from_repr_vartime(expected_bytes).unwrap());
} | rust_cleaned_test_functions.jsonl/54681 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 338
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
41652,
68535,
2273,
471,
545,
64132,
368,
341,
286,
1077,
264,
284,
35176,
486,
1499,
7,
16,
317,
286,
1077,
5206,
3601,
12524,
284,
508,
15,
84,
23,
26,
220,
18,
17,
935,
286,
3601,
12524,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_g1_doubling_correctness() {
let mut p = G1Projective::new(
Fq::from_repr(BigInteger768([
0x6064ee639b9adce5,
0x1149f14300102ddd,
0x395f28b5c8101bd0,
0xa764e4bdd6b33c5a,
0x51e645dfb580ecac,
0x2ca75c22f9d5b856,
0x4314a9a2a058df54,
0x75886b456ad32bfa,
0x3f4c758a65245bdb,
0x49129d70da6fe6a8,
0xbc4dac6eb4f07c3b,
0x47acb9975aa8,
])),
Fq::from_repr(BigInteger768([
0xaa39a144b0311d5e,
0x89f04b3a9adebdaf,
0xd32e9cc742b76970,
0x6672d161ca75793e,
0x6e8c03b3f80c227c,
0xc32a6f51615d8fba,
0xcbad4d6317f1cf55,
0x1eafa5de19fc6007,
0xfd55c1cf34af1159,
0xb2522dd8a5b9e91b,
0x540709a8841364c3,
0x50e2d88b5db9,
])),
Fq::from_repr(BigInteger768([
0x624f5f5b6e628648,
0xb43340d2bb9406b4,
0xd997cb8475d5b4cf,
0xc22fdbdc06ba16e8,
0x92220503c51b8328,
0x42916d7ff8dd732,
0x6d3df7f377a02d2c,
0x5b3e1058294a7493,
0x653fd02a7f2ab972,
0x111806291f570f83,
0x800bce7fd996bb00,
0x938c7238a9a7,
])),
);
p.double_in_place();
let p = G1Affine::from(p);
assert_eq!(
p,
G1Affine::new(
Fq::from_repr(BigInteger768([
0x7548af158fa3fc51,
0x6cd80c3910403c9e,
0x6c9f15e06b5ba60d,
0xb6a754b513529f07,
0x23c496e83a606680,
0x21ce1759ba83590c,
0xb407ab047a9edef1,
0x6fd97e8ab8d36ab6,
0x6d82dcd641f777e4,
0x6caf6c3a77a44722,
0xbbfc52c0db6b150f,
0x1b5aab811e031,
])),
Fq::from_repr(BigInteger768([
0xb23c84ab63b585ed,
0xefb84ff2c341b21,
0x86b0efe06b5887f1,
0x49b1982bc6146cea,
0x72c68986a18645ae,
0x7eee2d44d74827a9,
0xe03d44233741d59d,
0x285deaac6cec108d,
0xe4aea4c6b9967a8d,
0x9c83e0356b9eeedd,
0xbbeb2089d3321306,
0x1bffa53113921,
])),
false,
)
);
} | rust_cleaned_test_functions.jsonl/52501 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1870
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1889,
16,
814,
283,
9695,
31550,
2090,
368,
341,
262,
1077,
5206,
281,
284,
479,
16,
7849,
533,
486,
931,
1006,
286,
434,
80,
486,
1499,
68535,
91756,
22,
21,
23,
8956,
310,
220,
15,
87,
21,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_leader_stepdown_when_quorum_active() {
setup_for_test();
let mut sm = new_test_raft(1, vec![1, 2, 3], 5, 1, new_storage());
sm.check_quorum = true;
sm.become_candidate();
sm.become_leader();
for _ in 0..=sm.get_election_timeout() {
let mut m = new_message(2, 0, MessageType::MsgHeartbeatResponse, 0);
m.set_term(sm.term);
sm.step(m).expect("");
sm.tick();
}
assert_eq!(sm.state, StateRole::Leader);
} | rust_cleaned_test_functions.jsonl/107124 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 228
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
79991,
11946,
2923,
47636,
11280,
33006,
12930,
368,
341,
262,
6505,
5478,
4452,
543,
262,
1077,
5206,
1525,
284,
501,
4452,
62,
2944,
7,
16,
11,
7486,
20703,
16,
11,
220,
17,
11,
220,
18,
112... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_handler_prefix() {
let mut app = App::new()
.prefix("/app")
.handler("/test", |_| HttpResponse::Ok())
.finish();
let req = TestRequest::with_uri("/test").finish();
let resp = app.run(req);
assert_eq!(resp.as_msg().status(), StatusCode::NOT_FOUND);
let req = TestRequest::with_uri("/app/test").finish();
let resp = app.run(req.clone());
assert_eq!(resp.as_msg().status(), StatusCode::OK);
assert_eq!(req.prefix_len(), 9);
let req = TestRequest::with_uri("/app/test/").finish();
let resp = app.run(req);
assert_eq!(resp.as_msg().status(), StatusCode::OK);
let req = TestRequest::with_uri("/app/test/app").finish();
let resp = app.run(req);
assert_eq!(resp.as_msg().status(), StatusCode::OK);
let req = TestRequest::with_uri("/app/testapp").finish();
let resp = app.run(req);
assert_eq!(resp.as_msg().status(), StatusCode::NOT_FOUND);
let req = TestRequest::with_uri("/app/blah").finish();
let resp = app.run(req);
assert_eq!(resp.as_msg().status(), StatusCode::NOT_FOUND);
} | rust_cleaned_test_functions.jsonl/24274 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 550
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10183,
13974,
368,
341,
286,
1077,
5206,
906,
284,
1845,
486,
931,
741,
310,
659,
11849,
4283,
676,
1138,
310,
659,
17905,
4283,
1944,
497,
66091,
17580,
486,
11578,
2398,
310,
659,
30150,
1428,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_list_offsets() {
// Test the case where offset != 0
let a = create_fixed_size_list_array(&[
Some(&[1, 2, 3]),
None,
None,
Some(&[4, 5, 6]),
None,
None,
]);
let b = create_fixed_size_list_array(&[
Some(&[1, 2, 3]),
None,
None,
Some(&[3, 6, 9]),
None,
None,
]);
let a_slice = a.slice(0, 3);
let b_slice = b.slice(0, 3);
test_equal(&a_slice, &b_slice, true);
let a_slice = a.slice(0, 5);
let b_slice = b.slice(0, 5);
test_equal(&a_slice, &b_slice, false);
let a_slice = a.slice(4, 1);
let b_slice = b.slice(4, 1);
test_equal(&a_slice, &b_slice, true);
} | rust_cleaned_test_functions.jsonl/24227 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 498
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
37839,
2019,
56924,
368,
341,
286,
442,
3393,
279,
1142,
1380,
4347,
961,
220,
15,
198,
286,
1077,
264,
284,
1855,
37839,
2368,
2019,
3858,
2099,
9640,
310,
4329,
2099,
58,
16,
11,
220,
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_job_lost() {
fn fn_ok(_: String, _: Vec<String>) -> Result<String, Box<Error>> {
sleep(Duration::from_millis(10000));
Ok("ok".to_string())
}
let queue = Queue::new("redis://localhost/", "test-lost");
queue.drop().unwrap();
let uuid = queue.enqueue(vec![], 10).unwrap();
queue.work(fn_ok,
Some(1),
Some(5),
Some(1),
Some(5),
Some(false),
Some(false))
.unwrap();
let status = queue.status(&uuid).unwrap();
assert!(status == Status::LOST);
} | rust_cleaned_test_functions.jsonl/124825 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 308
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20298,
88661,
368,
341,
262,
5168,
5168,
19817,
73834,
923,
11,
58536,
11312,
3464,
9231,
1464,
5714,
3464,
11,
8261,
27,
1454,
2452,
341,
286,
6084,
64114,
486,
1499,
717,
56212,
7,
16,
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_pool_gc() {
assert_eq!(STR_POOL.pool.len(), 0);
STR_POOL.intern("asd", Arc::from);
assert_eq!(STR_POOL.pool.len(), 1);
let h = STR_POOL.intern("123", Arc::from);
assert_eq!(STR_POOL.pool.len(), 2);
STR_POOL.collect_garbage();
assert_eq!(STR_POOL.pool.len(), 1);
drop(h);
assert_eq!(STR_POOL.pool.len(), 1);
STR_POOL.collect_garbage();
assert_eq!(STR_POOL.pool.len(), 0);
} | rust_cleaned_test_functions.jsonl/38596 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 262
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15709,
49423,
368,
341,
286,
2060,
10714,
10297,
6666,
51924,
38963,
19406,
1507,
220,
15,
317,
286,
12152,
51924,
6403,
932,
445,
79102,
497,
19689,
486,
1499,
317,
286,
2060,
10714,
10297,
6666,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_type_parameters_multi() {
check(
"<T: A, U :B>",
type_parameters,
TypeParameterListSyntax {
open: TokenSyntax::from("<"),
elements: vec![
TypeParameterElementSyntax {
element: TypeParam {
name: TokenSyntax::from("T"),
type_constraint: Some(TypeConstraintSyntax {
sep: TokenSyntax::from(":"),
constraint: TypeName::Simple(SimpleTypeName {
name: TokenSyntax::from("A"),
type_args: None,
})
.with_leading_trivia(Trivia::from(TriviaPiece::Spaces(1))),
}),
},
trailing_comma: Some(TokenSyntax::from(",")),
},
TypeParameterElementSyntax {
element: TypeParam {
name: TokenSyntax::from("U")
.with_leading_trivia(Trivia::from(TriviaPiece::Spaces(1))),
type_constraint: Some(TypeConstraintSyntax {
sep: TokenSyntax::from(":")
.with_leading_trivia(Trivia::from(TriviaPiece::Spaces(1))),
constraint: TypeName::Simple(SimpleTypeName {
name: TokenSyntax::from("B"),
type_args: None,
}),
}),
},
trailing_comma: None,
},
],
close: TokenSyntax::from(">"),
},
);
} | rust_cleaned_test_functions.jsonl/129311 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1279
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1819,
18263,
25133,
368,
341,
286,
1779,
1006,
310,
4055,
51,
25,
362,
11,
547,
549,
33,
35452,
310,
943,
18263,
345,
310,
3990,
4971,
852,
33890,
341,
394,
1787,
25,
9660,
33890,
486,
1499,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_policy_for_sh_multi_partial_1of2() {
let secp = Secp256k1::new();
let (prvkey0, _pubkey0, fingerprint0) = setup_keys(TPRV0_STR, PATH, &secp);
let (_prvkey1, pubkey1, fingerprint1) = setup_keys(TPRV1_STR, PATH, &secp);
let desc = descriptor!(sh(multi(2, prvkey0, pubkey1))).unwrap();
let (wallet_desc, keymap) = desc
.into_wallet_descriptor(&secp, Network::Testnet)
.unwrap();
let signers_container = Arc::new(SignersContainer::build(keymap, &wallet_desc, &secp));
let policy = wallet_desc
.extract_policy(&signers_container, BuildSatisfaction::None, &secp)
.unwrap()
.unwrap();
assert!(
matches!(&policy.item, Multisig { keys, threshold } if threshold == &2usize
&& keys[0] == PkOrF::Fingerprint(fingerprint0)
&& keys[1] == PkOrF::Fingerprint(fingerprint1))
);
assert!(
matches!(&policy.contribution, Satisfaction::Partial { n, m, items, conditions, ..} if n == &2usize
&& m == &2usize
&& items.len() == 1
&& conditions.contains_key(&0)
)
);
} | rust_cleaned_test_functions.jsonl/77141 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 606
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39123,
22773,
5478,
3712,
25133,
52068,
62,
16,
1055,
17,
368,
341,
286,
1077,
511,
4672,
284,
4520,
79,
17,
20,
21,
74,
16,
486,
931,
543,
286,
1077,
320,
649,
85,
792,
15,
11,
716,
9585,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
#[test]
fn test_parse_names() -> io::Result<()> {
let data = b"noodles\x00tabix\x00";
let actual = parse_names(&data[..])?;
let expected = vec![String::from("noodles"), String::from("tabix")];
assert_eq!(actual, expected);
let data = b"";
assert!(parse_names(&data[..])?.is_empty());
Ok(())
} | rust_cleaned_test_functions.jsonl/80138 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 174
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
9187,
368,
1464,
6399,
486,
2077,
71698,
341,
286,
1077,
821,
284,
293,
1,
77,
97121,
3462,
15,
15,
6192,
941,
3462,
15,
15,
876,
286,
1077,
5042,
284,
4715,
9187,
2099,
691,
95874,
246... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_split_default() {
let (at, mut ucmd) = at_and_ucmd!();
let name = "split_default";
RandomFile::new(&at, name).add_lines(2000);
ucmd.args(&[name]).succeeds();
let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$");
assert_eq!(glob.count(), 2);
assert_eq!(glob.collate(), at.read_bytes(name));
} | rust_cleaned_test_functions.jsonl/25851 | {
"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,
17052,
9993,
368,
341,
262,
1077,
320,
266,
11,
5206,
575,
8710,
8,
284,
518,
8378,
68887,
2277,
0,
543,
262,
1077,
829,
284,
330,
6960,
9993,
876,
262,
10612,
1703,
486,
931,
2099,
266,
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_iterator() {
let mut m = VecMap::new();
assert!(m.insert(0, 1).is_none());
assert!(m.insert(1, 2).is_none());
assert!(m.insert(3, 5).is_none());
assert!(m.insert(6, 10).is_none());
assert!(m.insert(10, 11).is_none());
let mut it = m.iter();
assert_eq!(it.size_hint(), (0, Some(11)));
assert_eq!(it.next().unwrap(), (0, &1));
assert_eq!(it.size_hint(), (0, Some(10)));
assert_eq!(it.next().unwrap(), (1, &2));
assert_eq!(it.size_hint(), (0, Some(9)));
assert_eq!(it.next().unwrap(), (3, &5));
assert_eq!(it.size_hint(), (0, Some(7)));
assert_eq!(it.next().unwrap(), (6, &10));
assert_eq!(it.size_hint(), (0, Some(4)));
assert_eq!(it.next().unwrap(), (10, &11));
assert_eq!(it.size_hint(), (0, Some(0)));
assert!(it.next().is_none());
} | rust_cleaned_test_functions.jsonl/53270 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 487
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13491,
368,
341,
286,
1077,
5206,
296,
284,
11312,
2227,
486,
931,
1428,
286,
2060,
10297,
76,
7030,
7,
15,
11,
220,
16,
568,
285,
31488,
1423,
286,
2060,
10297,
76,
7030,
7,
16,
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... | 1 |
#[test]
fn test_tor_version() {
use super::*;
use std::ffi::CString;
let args = [
CString::new("tor").unwrap(),
CString::new("--version").unwrap(),
];
let args_ptr = [args[0].as_ptr(), args[1].as_ptr()];
unsafe {
let config = tor_main_configuration_new();
tor_main_configuration_set_command_line(config, 2, args_ptr.as_ptr());
tor_run_main(config);
tor_main_configuration_free(config);
}
} | rust_cleaned_test_functions.jsonl/8472 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 274
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
528,
269,
9438,
368,
341,
286,
990,
2256,
56162,
286,
990,
1460,
486,
53799,
486,
63677,
401,
286,
1077,
2827,
284,
2278,
310,
56956,
486,
931,
445,
10980,
1827,
15454,
3148,
310,
56956,
486,
93... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_to_toml_encode() {
let mut change = HashMap::new();
change.insert(
"raftstore.pd-heartbeat-tick-interval".to_owned(),
"1h".to_owned(),
);
change.insert(
"coprocessor.region-split-keys".to_owned(),
"10000".to_owned(),
);
change.insert("gc.max-write-bytes-per-sec".to_owned(), "100MB".to_owned());
change.insert(
"rocksdb.defaultcf.titan.blob-run-mode".to_owned(),
"read-only".to_owned(),
);
let res = to_toml_encode(change).unwrap();
assert_eq!(
res.get("raftstore.pd-heartbeat-tick-interval"),
Some(&"\"1h\"".to_owned())
);
assert_eq!(
res.get("coprocessor.region-split-keys"),
Some(&"10000".to_owned())
);
assert_eq!(
res.get("gc.max-write-bytes-per-sec"),
Some(&"\"100MB\"".to_owned())
);
assert_eq!(
res.get("rocksdb.defaultcf.titan.blob-run-mode"),
Some(&"\"read-only\"".to_owned())
);
} | rust_cleaned_test_functions.jsonl/31097 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 619
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2346,
528,
316,
75,
11224,
368,
341,
286,
1077,
5206,
2297,
284,
10528,
486,
931,
543,
286,
2297,
7030,
1006,
310,
330,
2944,
4314,
556,
67,
42244,
22227,
2385,
865,
20052,
6152,
3263,
983,
5197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_update_last_wins() {
let key = Keypair::new();
let index = AccountsIndex::<bool>::default();
let ancestors = vec![(0, 0)].into_iter().collect();
let mut gc = Vec::new();
index.upsert(
0,
&key.pubkey(),
&Pubkey::default(),
&[],
&AccountSecondaryIndexes::default(),
true,
&mut gc,
);
assert!(gc.is_empty());
let (list, idx) = index.get(&key.pubkey(), Some(&ancestors), None).unwrap();
assert_eq!(list.slot_list()[idx], (0, true));
drop(list);
let mut gc = Vec::new();
index.upsert(
0,
&key.pubkey(),
&Pubkey::default(),
&[],
&AccountSecondaryIndexes::default(),
false,
&mut gc,
);
assert_eq!(gc, vec![(0, true)]);
let (list, idx) = index.get(&key.pubkey(), Some(&ancestors), None).unwrap();
assert_eq!(list.slot_list()[idx], (0, false));
} | rust_cleaned_test_functions.jsonl/45177 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 581
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8882,
12195,
1670,
1330,
368,
341,
286,
1077,
1376,
284,
6569,
1082,
1310,
486,
931,
543,
286,
1077,
1922,
284,
40655,
1552,
27638,
2641,
6831,
2258,
543,
286,
1077,
37518,
284,
7486,
0,
9697,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_process_blockstore_with_supermajority_root() {
run_test_process_blockstore_with_supermajority_root(None);
run_test_process_blockstore_with_supermajority_root(Some(1))
} | rust_cleaned_test_functions.jsonl/118177 | {
"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,
11305,
7113,
4314,
6615,
38886,
36505,
487,
12993,
368,
341,
286,
1598,
4452,
11305,
7113,
4314,
6615,
38886,
36505,
487,
12993,
26717,
317,
286,
1598,
4452,
11305,
7113,
4314,
6615,
38886,
36505,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_runnables() {
let (analysis, pos) = analysis_and_position(
r#"
//- /lib.rs
<|> //empty
fn main() {}
#[test]
fn test_foo() {}
#[test]
#[ignore]
fn test_foo() {}
"#,
);
let runnables = analysis.runnables(pos.file_id).unwrap();
assert_debug_snapshot!(&runnables,
@r#"[
Runnable {
range: [1; 21),
kind: Bin,
},
Runnable {
range: [22; 46),
kind: Test {
name: "test_foo",
},
},
Runnable {
range: [47; 81),
kind: Test {
name: "test_foo",
},
},
]"#
);
} | rust_cleaned_test_functions.jsonl/56179 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 438
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14007,
77,
4788,
368,
341,
286,
1077,
320,
34484,
11,
1133,
8,
284,
6358,
8378,
9661,
1006,
310,
435,
2,
698,
286,
78406,
608,
2740,
25638,
198,
286,
82639,
29,
442,
3194,
198,
286,
5168,
1887... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_polygon_extreme_wrapper_convex() {
let poly1 = polygon![
(x: 1.0, y: 0.0),
(x: 2.0, y: 1.0),
(x: 1.75, y: 1.75),
(x: 1.0, y: 2.0),
(x: 0.0, y: 1.0),
(x: 1.0, y: 0.0)
];
let extremes = find_extreme_indices(polymax_naive_indices, &poly1.convex_hull()).unwrap();
let correct = Extremes {
ymin: 0,
xmax: 1,
ymax: 3,
xmin: 4,
};
assert_eq!(extremes, correct);
} | rust_cleaned_test_functions.jsonl/100479 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 367
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
73542,
9927,
9634,
23561,
22716,
327,
368,
341,
1789,
286,
1077,
9861,
16,
284,
29372,
90515,
310,
320,
87,
25,
220,
16,
13,
15,
11,
379,
25,
220,
15,
13,
15,
1326,
310,
320,
87,
25,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_remove_or_add_edge_added() {
let mut edges = vec![(1, 2), (6, 5)];
remove_or_add_edge(&mut edges, (4, 3));
assert_eq!(3, edges.len());
assert_eq!((4, 3), edges[2]);
} | rust_cleaned_test_functions.jsonl/5105 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 120
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18193,
8734,
2891,
17932,
37653,
368,
341,
286,
1077,
5206,
12822,
284,
7486,
0,
9697,
16,
11,
220,
17,
701,
320,
21,
11,
220,
20,
12587,
286,
4057,
8734,
2891,
17932,
2099,
6984,
12822,
11,
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_storage_term() {
setup_for_test();
let ents = vec![new_entry(3, 3), new_entry(4, 4), new_entry(5, 5)];
let mut tests = vec![
(2, Err(RaftError::Store(StorageError::Compacted))),
(3, Ok(3)),
(4, Ok(4)),
(5, Ok(5)),
(6, Err(RaftError::Store(StorageError::Unavailable))),
];
for (i, (idx, wterm)) in tests.drain(..).enumerate() {
let storage = MemStorage::new();
storage.wl().entries = ents.clone();
let t = storage.term(idx);
if t != wterm {
panic!("#{}: expect res {:?}, got {:?}", i, wterm, t);
}
}
} | rust_cleaned_test_functions.jsonl/50257 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 396
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
23310,
17464,
368,
341,
286,
6505,
5478,
4452,
543,
286,
1077,
36852,
284,
7486,
20703,
931,
9078,
7,
18,
11,
220,
18,
701,
501,
9078,
7,
19,
11,
220,
19,
701,
501,
9078,
7,
20,
11,
220,
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... | 3 |
#[test]
fn test_exists() {
let db = Connection::open_in_memory().unwrap();
let sql = "BEGIN;
CREATE TABLE foo(x INTEGER);
INSERT INTO foo VALUES(1);
INSERT INTO foo VALUES(2);
END;";
db.execute_batch(sql).unwrap();
let mut stmt = db.prepare("SELECT 1 FROM foo WHERE x = ?").unwrap();
assert!(stmt.exists(&[1i32]).unwrap());
assert!(stmt.exists(&[2i32]).unwrap());
assert!(!stmt.exists(&[0i32]).unwrap());
} | rust_cleaned_test_functions.jsonl/57181 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 293
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9766,
368,
341,
286,
1077,
2927,
284,
11032,
486,
2508,
1243,
19195,
1005,
15454,
543,
286,
1077,
5704,
284,
330,
37588,
280,
4293,
30776,
14363,
15229,
2075,
30381,
317,
4293,
39518,
12496,
15229,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.