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_union() {
let schema = Schema::from_str(UNION_SCHEMA).unwrap();
let union = Value::Union {
index: 1,
inner: Box::new(Value::Long(3)),
n_variants: 2,
null_variant: Some(0),
};
let mut expected = Vec::new();
zig_i64(1, &mut expected);
zig_i64(3, &mut expected);
assert_eq!(to_avro_datum(&schema, union).unwrap(), expected);
} | rust_cleaned_test_functions.jsonl/43034 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 241
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
51621,
368,
341,
286,
1077,
10802,
284,
12539,
486,
1499,
2895,
7,
1861,
1271,
46220,
568,
15454,
543,
286,
1077,
11300,
284,
5162,
486,
32658,
341,
310,
1922,
25,
220,
16,
345,
310,
9179,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parse_dir_entries_rejects_invalid_utf8() {
#[rustfmt::skip]
let buf = &[
// entry 0
// ino
1, 0, 0, 0, 0, 0, 0, 0,
// name length
1,
// type
fio::DIRENT_TYPE_FILE,
0x80,
// entry 1
// ino
2, 0, 0, 0, 0, 0, 0, 0,
// name length
4,
// type
fio::DIRENT_TYPE_FILE,
// name
'o' as u8, 'k' as u8, 'a' as u8, 'y' as u8,
];
let expected_err = std::str::from_utf8(&[0x80]).unwrap_err();
assert_eq!(
parse_dir_entries(buf),
vec![
Err(DecodeDirentError::InvalidUtf8(expected_err)),
Ok(DirEntry { name: "okay".to_string(), kind: DirentKind::File })
]
);
} | rust_cleaned_test_functions.jsonl/4609 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 580
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
4334,
26092,
1288,
583,
82,
31433,
39453,
23,
368,
341,
286,
11506,
35788,
12501,
486,
20599,
921,
286,
1077,
6607,
284,
609,
9640,
310,
442,
4343,
220,
15,
198,
310,
442,
304,
78,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_job_failed() {
fn fn_err(_: String, _: Vec<String>) -> Result<String, Box<Error>> {
sleep(Duration::from_millis(1000));
Err(From::from("err"))
}
let queue = Queue::new("redis://localhost/", "test-failed");
queue.drop().unwrap();
let uuid = queue.enqueue(vec![], 10).unwrap();
queue.work(fn_err,
Some(1),
Some(5),
Some(1),
Some(5),
Some(false),
Some(false))
.unwrap();
let status = queue.status(&uuid).unwrap();
assert!(status == Status::FAILED);
} | rust_cleaned_test_functions.jsonl/124824 | {
"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,
20298,
35060,
368,
341,
262,
5168,
5168,
9266,
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_alias_before_cast() -> Result<()> {
let out = df![
"a" => [1, 2, 3],
]?
.lazy()
.select([col("a").alias("d").cast(DataType::Int32)])
.select([all()])
.collect()?;
assert_eq!(
Vec::from(out.column("d")?.i32()?),
&[Some(1), Some(2), Some(3)]
);
Ok(())
} | rust_cleaned_test_functions.jsonl/5218 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 181
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
35947,
23708,
5303,
368,
1464,
5714,
71698,
341,
262,
1077,
700,
284,
6764,
90515,
286,
330,
64,
1,
589,
508,
16,
11,
220,
17,
11,
220,
18,
1259,
262,
2279,
5267,
262,
659,
49013,
741,
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... | 5 |
#[test]
fn test_discovery_scan_result_not_scanning() {
let mut sched = create_sched();
let (_inspector, sme_inspect) = sme_inspect();
assert_variant!(
sched.on_mlme_scan_result(
fidl_mlme::ScanResult {
txn_id: 0,
timestamp_nanos: zx::Time::get_monotonic().into_nanos(),
bss: fidl_internal::BssDescription {
bssid: [1; 6],
..fake_fidl_bss_description!(Open, ssid: Ssid::try_from("foo").unwrap())
},
},
&sme_inspect,
),
Err(Error::ScanResultNotScanning)
);
} | rust_cleaned_test_functions.jsonl/8145 | {
"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,
9932,
7449,
28857,
5287,
7913,
13171,
5947,
368,
341,
286,
1077,
5206,
5575,
284,
1855,
67394,
543,
286,
1077,
5453,
1330,
18997,
11,
90467,
34386,
987,
8,
284,
90467,
34386,
987,
543,
286,
2060,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_load_rules() {
let data = vec![
"0: 4 1 5",
"1: 2 3 | 3 2",
"2: 4 4 | 5 5",
"3: 4 5 | 5 4",
"4: \"a\"",
"5: \"b\"",
];
let rules = load_rules(&data);
assert_eq!(rules.len(), 6);
assert_eq!(*rules.get(&0).unwrap(), Rule::And(vec![4, 1, 5]));
assert_eq!(*rules.get(&1).unwrap(), Rule::Or(vec![2, 3], vec![3, 2]));
assert_eq!(*rules.get(&4).unwrap(), Rule::A);
assert_eq!(*rules.get(&5).unwrap(), Rule::B);
} | rust_cleaned_test_functions.jsonl/50119 | {
"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,
12411,
21407,
368,
341,
262,
1077,
821,
284,
7486,
90515,
414,
330,
15,
25,
220,
19,
220,
16,
220,
20,
756,
414,
330,
16,
25,
220,
17,
220,
18,
760,
220,
18,
220,
17,
756,
414,
330,
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_state_push_write_panic_wrong_sequence_number_equal() {
let state =
MockBufferSharedState::empty_with_n_sequencers(NonZeroU32::try_from(2).unwrap());
state.push_lp(Sequence::new(0, 13), "upc,region=east user=1 100");
state.push_lp(Sequence::new(0, 13), "upc,region=east user=1 100");
} | rust_cleaned_test_functions.jsonl/53063 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 158
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4387,
14218,
9165,
620,
31270,
75198,
23735,
5500,
11478,
368,
341,
286,
1077,
1584,
4035,
310,
14563,
4095,
16997,
1397,
486,
3194,
6615,
1089,
3453,
446,
62294,
7,
8121,
17999,
52,
18,
17,
486,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_non_square_matrix_high() {
let input = vec![vec![1, 5], vec![3, 6], vec![2, 7], vec![3, 8]];
assert_eq!(vec![(0, 1)], find_saddle_points(&input));
} | rust_cleaned_test_functions.jsonl/26643 | {
"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,
21637,
39794,
10193,
22680,
368,
341,
262,
1077,
1946,
284,
7486,
20703,
4083,
20703,
16,
11,
220,
20,
1125,
7486,
20703,
18,
11,
220,
21,
1125,
7486,
20703,
17,
11,
220,
22,
1125,
7486,
20703,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_configure_vcpu() {
let (vm, mut vcpu) = setup_vcpu();
let vm_config = VmConfig::default();
assert!(vcpu.configure(&vm_config, GuestAddress(0), &vm).is_ok());
// Test configure while using the T2 template.
let mut vm_config = VmConfig::default();
vm_config.cpu_template = Some(CpuFeaturesTemplate::T2);
assert!(vcpu.configure(&vm_config, GuestAddress(0), &vm).is_ok());
// Test configure while using the C3 template.
let mut vm_config = VmConfig::default();
vm_config.cpu_template = Some(CpuFeaturesTemplate::C3);
assert!(vcpu.configure(&vm_config, GuestAddress(0), &vm).is_ok());
} | rust_cleaned_test_functions.jsonl/26653 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 294
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
75887,
2273,
16475,
368,
341,
286,
1077,
320,
7338,
11,
5206,
348,
16475,
8,
284,
6505,
2273,
16475,
1428,
286,
1077,
10995,
5332,
284,
647,
76,
2648,
486,
2258,
543,
286,
2060,
10297,
85,
16475... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_split_more_than_staked() {
let rent = Rent::default();
let rent_exempt_reserve = rent.minimum_balance(StakeState::size_of());
let minimum_delegation = crate::get_minimum_delegation(&FeatureSet::all_enabled());
let stake_lamports = (rent_exempt_reserve + minimum_delegation) * 2;
let stake_address = solana_sdk::pubkey::new_rand();
let stake_account = AccountSharedData::new_data_with_space(
stake_lamports,
&just_stake(
Meta {
rent_exempt_reserve,
..Meta::auto(&stake_address)
},
stake_lamports / 2 - 1,
),
StakeState::size_of(),
&id(),
)
.unwrap();
let split_to_address = solana_sdk::pubkey::new_rand();
let split_to_account = AccountSharedData::new_data_with_space(
0,
&StakeState::Uninitialized,
StakeState::size_of(),
&id(),
)
.unwrap();
let transaction_accounts = vec![
(stake_address, stake_account),
(split_to_address, split_to_account),
(
sysvar::rent::id(),
account::create_account_shared_data_for_test(&rent),
),
];
let instruction_accounts = vec![
AccountMeta {
pubkey: stake_address,
is_signer: true,
is_writable: false,
},
AccountMeta {
pubkey: split_to_address,
is_signer: false,
is_writable: false,
},
];
process_instruction(
&serialize(&StakeInstruction::Split(stake_lamports / 2)).unwrap(),
transaction_accounts,
instruction_accounts,
Err(StakeError::InsufficientStake.into()),
);
} | rust_cleaned_test_functions.jsonl/31657 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1048
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17052,
36664,
51613,
1261,
7741,
368,
341,
286,
1077,
8016,
284,
29737,
486,
2258,
543,
286,
1077,
8016,
95736,
89591,
284,
8016,
57790,
29396,
7,
623,
726,
1397,
486,
2141,
3575,
1423,
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_numbers_128bit() {
// unsigned positive
the_same(5u128);
the_same(u128::max_value());
// signed positive
the_same(5i128);
the_same(i128::max_value());
// signed negative
the_same(-5i128);
the_same(i128::min_value());
} | rust_cleaned_test_functions.jsonl/24923 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 125
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
32964,
62,
16,
17,
23,
4489,
368,
341,
262,
442,
3774,
6785,
198,
262,
279,
33574,
7,
20,
84,
16,
17,
23,
317,
262,
279,
33574,
8154,
16,
17,
23,
486,
2810,
3142,
1423,
262,
442,
8499,
678... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parses_sdk_info_from_header() {
let mut event = Annotated::new(Event::default());
let mut processor = NormalizeProcessor::new(
Arc::new(StoreConfig {
client: Some("_fooBar/0.0.0".to_string()),
..StoreConfig::default()
}),
None,
);
process_value(&mut event, &mut processor, ProcessingState::root()).unwrap();
assert_eq_dbg!(
event.value().unwrap().client_sdk,
Annotated::new(ClientSdkInfo {
name: Annotated::new("_fooBar".to_string()),
version: Annotated::new("0.0.0".to_string()),
..ClientSdkInfo::default()
})
);
} | rust_cleaned_test_functions.jsonl/14103 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 321
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
77113,
288,
61783,
3109,
5673,
8757,
368,
341,
262,
1077,
5206,
1538,
284,
1527,
87029,
486,
931,
30469,
486,
2258,
1423,
262,
1077,
5206,
17654,
284,
68092,
22946,
486,
931,
1006,
286,
19689,
486... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_execute_issue_not_found_fails() {
run_test(|| {
ext::vault_registry::get_active_vault_from_id::<Test>
.mock_safe(|_| MockResult::Return(Ok(init_zero_vault(VAULT))));
assert_noop!(execute_issue(USER, &H256([0; 32])), TestError::IssueIdNotFound);
})
} | rust_cleaned_test_functions.jsonl/104084 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 149
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
44329,
53340,
7913,
21480,
761,
6209,
368,
341,
262,
1598,
4452,
79453,
341,
286,
1303,
486,
82983,
50650,
486,
455,
12930,
2273,
945,
5673,
842,
27638,
2271,
397,
310,
659,
16712,
34067,
22428,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_hover_test_has_action() {
check_actions(
r#"
#[test]
fn foo_<|>test() {}
"#,
expect![[r#"
[
Runnable(
Runnable {
nav: NavigationTarget {
file_id: FileId(
0,
),
full_range: 0..24,
focus_range: Some(
11..19,
),
name: "foo_test",
kind: FN,
container_name: None,
description: None,
docs: None,
},
kind: Test {
test_id: Path(
"foo_test",
),
attr: TestAttr {
ignore: false,
},
},
cfg_exprs: [],
},
),
]
"#]],
);
} | rust_cleaned_test_functions.jsonl/66160 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1077
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
53445,
4452,
21778,
7931,
368,
341,
286,
1779,
25368,
1006,
310,
435,
2,
698,
13353,
1944,
921,
8822,
15229,
41743,
91,
29,
1944,
368,
5613,
57676,
345,
310,
1720,
0,
15505,
81,
2,
698,
394,
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_local_request() {
let mut ctx = CsmTestContext::new(ConnState::LocalInit);
// Host-initiated connections should first yield a connection request packet.
assert!(ctx.conn.has_pending_rx());
// armed.
assert!(!ctx.conn.will_expire());
ctx.recv();
assert_eq!(ctx.pkt.op(), uapi::VSOCK_OP_REQUEST);
assert!(ctx.conn.will_expire());
assert!(!ctx.conn.has_expired());
ctx.init_pkt(uapi::VSOCK_OP_RESPONSE, 0);
ctx.send();
assert_eq!(ctx.conn.state, ConnState::Established);
assert!(!ctx.conn.will_expire());
} | rust_cleaned_test_functions.jsonl/83285 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 339
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13564,
7893,
368,
341,
286,
1077,
5206,
5635,
284,
356,
3563,
2271,
1972,
486,
931,
7,
9701,
1397,
486,
7319,
3803,
317,
286,
442,
16102,
54773,
10029,
13234,
1265,
1156,
7540,
264,
3633,
1681,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_index_aggr_first() {
let data = vec![
(1, Some("name:0"), 2),
(2, Some("name:3"), 3),
(4, Some("name:0"), 1),
(5, Some("name:5"), 4),
(6, Some("name:5"), 4),
(7, None, 4),
];
let product = ProductTable::new();
let (_, endpoint) = init_with_data(&product, &data);
let exp = vec![
(Datum::Null, 7),
(Datum::Bytes(b"name:0".to_vec()), 4),
(Datum::Bytes(b"name:3".to_vec()), 2),
(Datum::Bytes(b"name:5".to_vec()), 5),
];
// for dag
let req = DAGSelect::from_index(&product.table, &product.name)
.first(&product.id)
.group_by(&[&product.name])
.build();
let mut resp = handle_select(&endpoint, req);
let mut row_count = 0;
let exp_len = exp.len();
let spliter = DAGChunkSpliter::new(resp.take_chunks().into_vec(), 2);
for (row, (name, id)) in spliter.zip(exp) {
let expected_datum = vec![Datum::I64(id), name];
let expected_encoded = datum::encode_value(&expected_datum).unwrap();
let result_encoded = datum::encode_value(&row).unwrap();
assert_eq!(&*result_encoded, &*expected_encoded);
row_count += 1;
}
assert_eq!(row_count, exp_len);
} | rust_cleaned_test_functions.jsonl/34864 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 610
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3560,
20587,
901,
12978,
368,
341,
262,
1077,
821,
284,
7486,
90515,
286,
320,
16,
11,
4329,
445,
606,
25,
15,
3975,
220,
17,
1326,
286,
320,
17,
11,
4329,
445,
606,
25,
18,
3975,
220,
18,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_parse_radial_gradient_1() {
assert_eq!(parse_css_background("radial-gradient(circle, lime, blue, yellow)"),
Ok(StyleBackground::RadialGradient(RadialGradientPreInfo {
shape: Shape::Circle,
extend_mode: ExtendMode::Clamp,
stops: vec![
GradientStopPre {
offset: Some(PercentageValue::new(0.0)),
color: ColorU { r: 0, g: 255, b: 0, a: 255 },
},
GradientStopPre {
offset: Some(PercentageValue::new(50.0)),
color: ColorU { r: 0, g: 0, b: 255, a: 255 },
},
GradientStopPre {
offset: Some(PercentageValue::new(100.0)),
color: ColorU { r: 255, g: 255, b: 0, a: 255 },
}],
})));
} | rust_cleaned_test_functions.jsonl/37095 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 512
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
39764,
530,
49482,
62,
16,
368,
341,
286,
2060,
10714,
10297,
6400,
25924,
24103,
445,
13281,
530,
42738,
86154,
11,
41719,
11,
6303,
11,
13753,
8,
4461,
310,
7622,
7,
2323,
8706,
486,
41... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_sample_simple_messages_columns() {
let mut output = Cursor::new(Vec::new());
let parquet = api::tests::temp_file("msg", ".parquet");
let path_str = parquet.path().to_str().unwrap();
let path = parquet.path();
let expected = vec![
"field_boolean field_int32",
"false 1",
"true 2",
"",
]
.join("\n");
let subcomand = def();
let msgs = api::tests::create_simple_messages(2);
let arg_vec = vec!["sample", path_str, "-c=field_boolean", "-c=field_int32"];
let args = subcomand.get_matches_from_safe(arg_vec).unwrap();
api::tests::write_simple_messages_parquet(&path, &msgs);
assert_eq!(true, run(&args, &mut output).is_ok());
let vec = output.into_inner();
let actual = str::from_utf8(&vec).unwrap();
assert_eq!(actual, expected);
} | rust_cleaned_test_functions.jsonl/118651 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 466
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17491,
30015,
23428,
22590,
368,
341,
286,
1077,
5206,
2550,
284,
28067,
486,
931,
49923,
486,
931,
1423,
286,
1077,
1346,
23300,
284,
6330,
486,
23841,
486,
3888,
2458,
445,
3236,
497,
5933,
1732... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_consts() {
// check our constants are what Complex::new creates
fn test(c: Complex64, r: f64, i: f64) {
assert_eq!(c, Complex::new(r, i));
}
test(_0_0i, 0.0, 0.0);
test(_1_0i, 1.0, 0.0);
test(_1_1i, 1.0, 1.0);
test(_neg1_1i, -1.0, 1.0);
test(_05_05i, 0.5, 0.5);
assert_eq!(_0_0i, Zero::zero());
assert_eq!(_1_0i, One::one());
} | rust_cleaned_test_functions.jsonl/105652 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 265
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
48530,
368,
341,
286,
442,
1779,
1039,
18021,
525,
1128,
22096,
486,
931,
11450,
198,
286,
5168,
1273,
1337,
25,
22096,
21,
19,
11,
435,
25,
282,
21,
19,
11,
600,
25,
282,
21,
19,
8,
341,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_coersion() -> Result<()> {
test_coercion!(
Int32Array,
DataType::Int32,
vec![1i32, 2i32],
UInt32Array,
DataType::UInt32,
vec![1u32, 2u32],
Operator::Plus,
Int32Array,
DataType::Int32,
vec![2i32, 4i32]
);
test_coercion!(
Int32Array,
DataType::Int32,
vec![1i32],
UInt16Array,
DataType::UInt16,
vec![1u16],
Operator::Plus,
Int32Array,
DataType::Int32,
vec![2i32]
);
test_coercion!(
Float32Array,
DataType::Float32,
vec![1f32],
UInt16Array,
DataType::UInt16,
vec![1u16],
Operator::Plus,
Float32Array,
DataType::Float32,
vec![2f32]
);
test_coercion!(
Float32Array,
DataType::Float32,
vec![2f32],
UInt16Array,
DataType::UInt16,
vec![1u16],
Operator::Multiply,
Float32Array,
DataType::Float32,
vec![2f32]
);
test_coercion!(
StringArray,
DataType::Utf8,
vec!["hello world", "world"],
StringArray,
DataType::Utf8,
vec!["%hello%", "%hello%"],
Operator::Like,
BooleanArray,
DataType::Boolean,
vec![true, false]
);
test_coercion!(
StringArray,
DataType::Utf8,
vec!["1994-12-13", "1995-01-26"],
Date32Array,
DataType::Date32(DateUnit::Day),
vec![9112, 9156],
Operator::Eq,
BooleanArray,
DataType::Boolean,
vec![true, true]
);
test_coercion!(
StringArray,
DataType::Utf8,
vec!["1994-12-13", "1995-01-26"],
Date32Array,
DataType::Date32(DateUnit::Day),
vec![9113, 9154],
Operator::Lt,
BooleanArray,
DataType::Boolean,
vec![true, false]
);
test_coercion!(
StringArray,
DataType::Utf8,
vec!["1994-12-13", "1995-01-26"],
Date64Array,
DataType::Date64(DateUnit::Millisecond),
vec![787276800000, 791078400000],
Operator::Eq,
BooleanArray,
DataType::Boolean,
vec![true, true]
);
test_coercion!(
StringArray,
DataType::Utf8,
vec!["1994-12-13", "1995-01-26"],
Date64Array,
DataType::Date64(DateUnit::Millisecond),
vec![787276800001, 791078399999],
Operator::Lt,
BooleanArray,
DataType::Boolean,
vec![true, false]
);
Ok(())
} | rust_cleaned_test_functions.jsonl/22556 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1936
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1819,
11393,
1325,
368,
1464,
5714,
71698,
341,
286,
1273,
11393,
2962,
290,
33673,
310,
1333,
18,
17,
1857,
345,
310,
33172,
486,
1072,
18,
17,
345,
310,
7486,
20703,
16,
72,
18,
17,
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_decoder_receive_return_value() {
let seed = "Wolf";
let message_size = 1000;
let max_fragment_length = 10;
let message = crate::xoshiro::test_utils::make_message(seed, message_size);
let mut encoder = Encoder::new(&message, max_fragment_length);
let mut decoder = Decoder::default();
let part = encoder.next_part().unwrap();
assert!(decoder.receive(part.clone()).unwrap());
// same indexes
assert!(!decoder.receive(part).unwrap());
// non-valid
let mut part = encoder.next_part().unwrap();
part.checksum += 1;
assert!(!decoder.receive(part).unwrap());
// decoder complete
while !decoder.complete() {
let part = encoder.next_part().unwrap();
decoder.receive(part).unwrap();
}
let part = encoder.next_part().unwrap();
assert!(!decoder.receive(part).unwrap());
} | rust_cleaned_test_functions.jsonl/106875 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 435
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
49843,
38557,
12511,
3142,
368,
341,
286,
1077,
10320,
284,
330,
95434,
876,
286,
1077,
1943,
2368,
284,
220,
16,
15,
15,
15,
280,
286,
1077,
1932,
43012,
5118,
284,
220,
16,
15,
401,
286,
107... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_roundtrip_hyphenated() {
let uuid_orig = new();
let orig_str = uuid_orig.to_hyphenated().to_string();
let uuid_out = Uuid::parse_str(&orig_str).unwrap();
assert_eq!(uuid_orig, uuid_out);
} | rust_cleaned_test_functions.jsonl/114741 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 122
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
29896,
32981,
1523,
88,
14769,
657,
368,
341,
286,
1077,
16040,
35328,
284,
501,
543,
286,
1077,
2713,
2895,
284,
16040,
35328,
2389,
1523,
88,
14769,
657,
1005,
983,
3904,
543,
286,
1077,
16040,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_incr() {
assert_eq!(incr("key", 1), "incr key 1\r\n");
assert_eq!(incr("key", 1000), "incr key 1000\r\n");
} | rust_cleaned_test_functions.jsonl/26813 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 83
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1243,
5082,
368,
341,
286,
2060,
10714,
10297,
98428,
445,
792,
497,
220,
16,
701,
330,
98428,
1376,
220,
16,
12016,
1699,
797,
286,
2060,
10714,
10297,
98428,
445,
792,
497,
220,
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 |
#[test]
fn test_partial_factors_divide_by() {
for n in 2..200 {
let factors = PartialFactors::compute(n);
for power2 in 0..5 {
for power3 in 0..4 {
for power5 in 0..3 {
for power7 in 0..3 {
for power11 in 0..2 {
for power13 in 0..2 {
let divisor_product = (3.pow(power3)
* 5.pow(power5)
* 7.pow(power7)
* 11.pow(power11)
* 13.pow(power13))
<< power2;
let divisor = PartialFactors::compute(divisor_product);
if let Some(quotient) = factors.divide_by(&divisor) {
assert_eq!(quotient.product(), n / divisor_product);
} else {
assert!(n % divisor_product > 0);
}
}
}
}
}
}
}
}
} | rust_cleaned_test_functions.jsonl/33863 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 987
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
52068,
73040,
16237,
577,
3710,
368,
341,
286,
369,
308,
304,
220,
17,
496,
17,
15,
15,
341,
310,
1077,
9363,
284,
24552,
97769,
486,
27706,
1445,
626,
310,
369,
2355,
17,
304,
220,
15,
496,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
#[test]
fn test_is_utf8_latin1_invalid() {
assert!(!is_utf8_latin1(b"\xC3"));
assert!(!is_utf8_latin1(b"a\xC3"));
assert!(!is_utf8_latin1(b"\xFF"));
assert!(!is_utf8_latin1(b"a\xFF"));
assert!(!is_utf8_latin1(b"\xC3\xFF"));
assert!(!is_utf8_latin1(b"a\xC3\xFF"));
} | rust_cleaned_test_functions.jsonl/27306 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 213
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6892,
39453,
23,
907,
14768,
16,
31433,
368,
341,
286,
2060,
0,
3471,
285,
39453,
23,
907,
14768,
16,
1883,
11934,
12125,
18,
4010,
286,
2060,
0,
3471,
285,
39453,
23,
907,
14768,
16,
1883,
56... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_chan_drop_order() {
// we make the async just block on a channel which we can control from outside
let (tx, rx) = chan::bounded(1);
let a = Async::run(crate::logging::test_logger(), move || rx.recv());
let c = a.chan();
assert_eq!(
c.recv_timeout(std::time::Duration::from_millis(1)),
Err(chan::RecvTimeoutError::Timeout)
);
tx.send(42).unwrap();
assert_eq!(
c.recv_timeout(std::time::Duration::from_millis(100)),
Ok(Ok(42))
);
drop(a)
} | rust_cleaned_test_functions.jsonl/42283 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 329
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
45552,
29584,
7869,
368,
341,
286,
442,
582,
1281,
279,
3312,
1101,
2504,
389,
264,
5496,
892,
582,
646,
2524,
504,
4889,
198,
286,
1077,
320,
3998,
11,
19111,
8,
284,
26023,
486,
65686,
7,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_domain_type_object_array_object() {
// FIXME
let ty = DomainType {
annotation: Default::default(),
id: "ty".to_string(),
r#type: Type::Object(vec![Property {
annotation: Default::default(),
name: "object".into(),
r#type: Type::Array(Box::new(Type::Object(vec![]))),
}]),
};
let prog = Context::new_root(&Default::default())
.with_domain("foo")
.render_with(&ty);
let expect = quote! {
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct TyObject {}
impl TyObject {
pub fn new() -> Self {
Default::default()
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Ty {
#[serde(rename = "object")]
r#object: Vec<TyObject>,
}
impl Ty {
pub fn new(r#object: Vec<TyObject>) -> Self {
Self {
r#object,
}
}
pub fn r#object(&self) -> &[TyObject] {
&self.r#object
}
}
impl Deref for Ty {
type Target = Vec<TyObject>;
fn deref(&self) -> &Self::Target {
&self.r#object
}
}
};
assert_eq(&prog, &expect);
} | rust_cleaned_test_functions.jsonl/26910 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 746
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20111,
1819,
5314,
3858,
5314,
368,
341,
262,
442,
27475,
198,
262,
1077,
13580,
284,
21070,
929,
341,
286,
21223,
25,
7899,
486,
2258,
3148,
286,
877,
25,
330,
1881,
3263,
983,
3904,
3148,
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_decode() {
let buf:Vec<u8> = vec![0u8, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 10, 0, 15, 0, 1, 0, 2, 104, 105];
let msg = Testproto::decode(&mut &buf[..]).unwrap();
assert!(Testproto::Message { a: 10, b: 15, c: Arr::<u16,String>::new(vec!["hi".to_string()]) } == msg);
} | rust_cleaned_test_functions.jsonl/69299 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 166
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15227,
368,
341,
286,
1077,
6607,
25,
10050,
34837,
23,
29,
284,
7486,
20703,
15,
84,
23,
11,
220,
15,
11,
220,
15,
11,
220,
15,
11,
220,
15,
11,
220,
15,
11,
220,
15,
11,
220,
15,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_vcx_connection_create() {
init!("true");
let cb = return_types_u32::Return_U32_U32::new().unwrap();
let rc = vcx_connection_create(cb.command_handle,
CString::new("test_create").unwrap().into_raw(),
Some(cb.get_callback()));
assert_eq!(rc, error::SUCCESS.code_num);
assert!(cb.receive(Some(Duration::from_secs(10))).unwrap() > 0);
} | rust_cleaned_test_functions.jsonl/25719 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 259
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2273,
25844,
15866,
8657,
368,
341,
286,
2930,
17223,
1866,
797,
286,
1077,
9858,
284,
470,
9763,
7300,
18,
17,
486,
5598,
6665,
18,
17,
6665,
18,
17,
486,
931,
1005,
15454,
543,
286,
1077,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_compression_ratio() {
let path = TempDir::new("_util_rocksdb_test_compression_ratio").expect("");
let path_str = path.path().to_str().unwrap();
let opts = DBOptions::new();
let cf_opts = CFOptions::new(CF_DEFAULT, ColumnFamilyOptions::new());
let db = new_engine_opt(path_str, opts, vec![cf_opts]).unwrap();
let cf = db.cf_handle(CF_DEFAULT).unwrap();
assert!(get_engine_compression_ratio_at_level(&db, cf, 0).is_none());
db.put_cf(cf, b"a", b"a").unwrap();
db.flush_cf(cf, true).unwrap();
assert!(get_engine_compression_ratio_at_level(&db, cf, 0).is_some());
} | rust_cleaned_test_functions.jsonl/90345 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 312
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2965,
4011,
19917,
368,
341,
286,
1077,
1815,
284,
19944,
6184,
486,
931,
16975,
1314,
26608,
14553,
1999,
4452,
2965,
4011,
19917,
1827,
17119,
13056,
286,
1077,
1815,
2895,
284,
1815,
3875,
1005,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_get_valid_block_invalid_node_state() {
let state = NodeState::Joining;
let blockhash = SHA256Hash::from_slice(&hex::decode(HASH).unwrap()[..]).unwrap();
assert!(get_valid_block(&state, blockhash).is_err());
} | rust_cleaned_test_functions.jsonl/75389 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 113
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
8337,
7113,
31433,
5084,
4387,
368,
341,
286,
1077,
1584,
284,
6018,
1397,
486,
12292,
287,
280,
286,
1077,
2504,
8296,
284,
21721,
17,
20,
21,
6370,
486,
1499,
26488,
2099,
17308,
486,
18... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_batch() {
let keyspace = MyKeyspace::new();
let req = keyspace
.batch()
.logged()
.insert(&3, &9.0)
.update_query(&3, &8.0)
.insert_prepared(&3, &8.0)
.delete_prepared::<_, f32>(&3)
.consistency(Consistency::One)
.build()
.unwrap()
.compute_token(&3);
let id = keyspace.insert_id::<u32, f32>();
let statement = req.get_statement(&id).unwrap();
assert_eq!(statement, keyspace.insert_statement::<u32, f32>());
let worker = BatchWorker { request: req.clone() };
let _res = req.clone().send_local(Box::new(worker));
} | rust_cleaned_test_functions.jsonl/37456 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 384
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14534,
368,
341,
286,
1077,
6894,
1306,
284,
3017,
8850,
1306,
486,
931,
543,
286,
1077,
4232,
284,
6894,
1306,
198,
310,
659,
14049,
741,
310,
659,
24867,
368,
715,
310,
659,
4208,
2099,
18,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_longest_consecutive_3() {
let tree = tree_node!(1, tree_node!(2, tree_leaf!(4), None), tree_leaf!(3));
assert_eq!(Solution::longest_consecutive(tree), 2);
} | rust_cleaned_test_functions.jsonl/88516 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 96
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17799,
477,
3382,
85780,
62,
18,
368,
341,
286,
1077,
4916,
284,
4916,
5084,
10297,
16,
11,
4916,
5084,
10297,
17,
11,
4916,
38909,
10297,
19,
701,
2240,
701,
4916,
38909,
10297,
18,
1106,
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 |
#[test]
fn test_input() {
use super::*;
let input_json = r#"
{
"root": "/home/user/rust_projects/tikv",
"file": "src/utils.rs",
"pos": "12:10: 12:31"
}"#;
let input_struct: Input = serde_json::from_str(input_json).unwrap();
let input_struct_2 = Input {
root: "/home/user/rust_projects/tikv".to_string(),
file: "src/utils.rs".to_string(),
pos: "12:10: 12:31".to_string(),
};
assert_eq!(input_struct, input_struct_2);
} | rust_cleaned_test_functions.jsonl/99535 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 300
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5898,
368,
341,
286,
990,
2256,
56162,
286,
1077,
1946,
9455,
284,
435,
2,
698,
286,
341,
7472,
330,
2888,
788,
3521,
5117,
11739,
7382,
590,
58774,
5523,
1579,
85,
756,
7472,
330,
1192,
788,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_erasure_generate_coding_reset_on_new_slot() {
morgan_logger::setup();
let mut coding_generator = CodingGenerator::default();
// test coding by iterating one blob at a time
let data_blobs = generate_test_blobs(0, NUM_DATA * 2);
for i in NUM_DATA..NUM_DATA * 2 {
data_blobs[i].write().unwrap().set_slot(1);
}
let coding_blobs = coding_generator.next(&data_blobs[0..NUM_DATA - 1]);
assert!(coding_blobs.is_empty());
let coding_blobs = coding_generator.next(&data_blobs[NUM_DATA..]);
assert_eq!(coding_blobs.len(), NUM_CODING);
test_toss_and_recover(
&coding_generator.session,
&data_blobs,
&coding_blobs,
NUM_DATA,
);
} | rust_cleaned_test_functions.jsonl/12501 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 397
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
80604,
3970,
48851,
666,
3700,
18983,
4470,
5921,
27563,
368,
341,
286,
296,
8462,
27413,
486,
15188,
1428,
286,
1077,
5206,
10822,
25813,
284,
48075,
12561,
486,
2258,
1428,
286,
442,
1273,
10822,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_vaporization_order_test() {
let map = string_to_asteroid_map(
".#....#####...#..\n\
##...##.#####..##\n\
##...#...#.#####.\n\
..#.....#...###..\n\
..#.#.....#....##",
);
let station_loc = AsteroidLocation::new(8, 3);
let vaporization_order = plan_vaporization(&map, &station_loc);
assert_eq!(vaporization_order.len(), map.len() - 1);
assert_eq!(vaporization_order[0], AsteroidLocation::new(8, 1));
assert_eq!(vaporization_order[1], AsteroidLocation::new(9, 0));
assert_eq!(vaporization_order[2], AsteroidLocation::new(9, 1));
assert_eq!(vaporization_order[3], AsteroidLocation::new(10, 0));
} | rust_cleaned_test_functions.jsonl/69388 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 375
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2273,
20715,
2022,
7869,
4452,
368,
341,
286,
1077,
2415,
284,
914,
2346,
62,
2300,
588,
5376,
1006,
310,
5933,
2,
1934,
67331,
1112,
2,
60402,
77,
5661,
1797,
7704,
1112,
565,
13,
67331,
496,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_process_new_vote_state_slots_not_ordered() {
let mut vote_state1 = VoteState::default();
let bad_votes: VecDeque<Lockout> = vec![
Lockout {
slot: 1,
confirmation_count: 2,
},
Lockout {
slot: 0,
confirmation_count: 1,
},
]
.into_iter()
.collect();
assert_eq!(
vote_state1.process_new_vote_state(
bad_votes,
None,
None,
vote_state1.current_epoch(),
None
),
Err(VoteError::SlotsNotOrdered)
);
let bad_votes: VecDeque<Lockout> = vec![
Lockout {
slot: 1,
confirmation_count: 2,
},
Lockout {
slot: 1,
confirmation_count: 1,
},
]
.into_iter()
.collect();
assert_eq!(
vote_state1.process_new_vote_state(
bad_votes,
None,
None,
vote_state1.current_epoch(),
None
),
Err(VoteError::SlotsNotOrdered)
);
} | rust_cleaned_test_functions.jsonl/6120 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 813
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11305,
5921,
54360,
4387,
54161,
7913,
75272,
368,
341,
286,
1077,
5206,
6910,
4387,
16,
284,
34034,
1397,
486,
2258,
1428,
286,
1077,
3873,
65116,
25,
11312,
73891,
27,
11989,
411,
29,
284,
7486,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_readuntil() {
run_on(|| {
let (mut sender, payload) = Payload::create(false);
let mut payload = PayloadBuffer::new(payload);
assert_eq!(None, payload.read_until(b"ne").unwrap());
sender.feed_data(Bytes::from("line1"));
sender.feed_data(Bytes::from("line2"));
payload.poll_stream().unwrap();
assert_eq!(
Some(Bytes::from("line")),
payload.read_until(b"ne").unwrap()
);
assert_eq!(payload.buf.len(), 6);
assert_eq!(
Some(Bytes::from("1line2")),
payload.read_until(b"2").unwrap()
);
assert_eq!(payload.buf.len(), 0);
})
} | rust_cleaned_test_functions.jsonl/43770 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 425
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
38730,
368,
341,
286,
1598,
4470,
79453,
341,
310,
1077,
320,
6984,
4646,
11,
7729,
8,
284,
52916,
486,
3182,
3576,
317,
310,
1077,
5206,
7729,
284,
52916,
4095,
486,
931,
26772,
626,
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... | 2 |
#[test]
fn test_transcribes_thymine_to_adenine() {
assert_eq!(dna::RibonucleicAcid::new("A"), dna::DeoxyribonucleicAcid::new("T").to_rna());
} | rust_cleaned_test_functions.jsonl/36949 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 74
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7965,
55136,
5854,
1600,
482,
2346,
10027,
268,
482,
368,
341,
262,
2060,
10714,
10297,
92877,
486,
98884,
263,
22147,
292,
11654,
307,
486,
931,
445,
32,
3975,
75334,
486,
1912,
60163,
1897,
263,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_list() {
test_encode_ok(&[
(vec![], "[]"),
(vec![true], "[true]"),
(vec![true, false], "[true,false]"),
]);
test_encode_ok(&[
(vec![vec![], vec![], vec![]], "[[],[],[]]"),
(vec![vec![1, 2, 3], vec![], vec![]], "[[1,2,3],[],[]]"),
(vec![vec![], vec![1, 2, 3], vec![]], "[[],[1,2,3],[]]"),
(vec![vec![], vec![], vec![1, 2, 3]], "[[],[],[1,2,3]]"),
]);
test_pretty_encode_ok(&[
(vec![vec![], vec![], vec![]], pretty_str!([[], [], []])),
(
vec![vec![1, 2, 3], vec![], vec![]],
pretty_str!([[1, 2, 3], [], []]),
),
(
vec![vec![], vec![1, 2, 3], vec![]],
pretty_str!([[], [1, 2, 3], []]),
),
(
vec![vec![], vec![], vec![1, 2, 3]],
pretty_str!([[], [], [1, 2, 3]]),
),
]);
test_pretty_encode_ok(&[
(vec![], "[]"),
(vec![true], pretty_str!([true])),
(vec![true, false], pretty_str!([true, false])),
]);
let long_test_list = json!([false, null, ["foo\nbar", 3.5]]);
test_encode_ok(&[(
long_test_list.clone(),
json_str!([false, null, ["foo\nbar", 3.5]]),
)]);
test_pretty_encode_ok(&[(
long_test_list,
pretty_str!([false, null, ["foo\nbar", 3.5]]),
)]);
} | rust_cleaned_test_functions.jsonl/29820 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 797
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9165,
2019,
368,
341,
262,
1273,
11224,
19817,
2099,
9640,
286,
320,
4083,
0,
12995,
330,
1294,
4461,
286,
320,
4083,
20703,
1866,
1125,
10545,
1866,
60,
4461,
286,
320,
4083,
20703,
1866,
11,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_simple_name() -> Result<()> {
let name = SqlName::new("safe_name").safe();
assert_eq!(&name, "safe_name");
let name = SqlName::new("safe_name").alias("sn").safe();
assert_eq!(&name, "safe_name AS sn");
let name = name!("safe_name");
assert_eq!(&name, "safe_name");
let name = name!("safe_name"; "sn");
assert_eq!(&name, "safe_name AS sn");
Ok(())
} | rust_cleaned_test_functions.jsonl/74805 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 213
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
30015,
1269,
368,
1464,
5714,
71698,
341,
286,
1077,
829,
284,
7224,
675,
486,
931,
445,
18675,
1269,
1827,
18675,
543,
286,
2060,
10714,
0,
2099,
606,
11,
330,
18675,
1269,
3071,
286,
1077,
829... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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() {
assert_eq!(
rsass(
"a {b: type-of(ie-hex-str(#daddee))}\
\n"
)
.unwrap(),
"a {\
\n b: string;\
\n}\
\n"
);
} | rust_cleaned_test_functions.jsonl/73578 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 193
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1819,
368,
341,
286,
2060,
10714,
33673,
310,
10036,
395,
1006,
394,
330,
64,
314,
65,
25,
943,
8668,
7,
645,
2832,
327,
41628,
32735,
55844,
57894,
593,
92,
5661,
310,
1124,
77,
698,
310,
172... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_debug_error() {
let code = 6;
let msg = error_string(code);
let err = Error { repr: super::Repr::Os(code) };
let expected = format!("Error {{ repr: Os {{ code: {:?}, message: {:?} }} }}", code, msg);
assert_eq!(format!("{:?}", err), expected);
} | rust_cleaned_test_functions.jsonl/8215 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 141
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15446,
4096,
368,
341,
286,
1077,
2038,
284,
220,
21,
280,
286,
1077,
3750,
284,
1465,
3904,
15842,
317,
286,
1077,
1848,
284,
4600,
314,
30636,
25,
2256,
486,
693,
649,
486,
28867,
15842,
8,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parse_bits() {
let bits = EXAMPLE_BITS.chars().map(|c| if c == '1' { H } else { L });
let packet = Packet::parse_bits(bits).unwrap();
assert_eq!(packet.version_sum(), 7 + 2 + 4 + 1);
} | rust_cleaned_test_functions.jsonl/129857 | {
"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,
21039,
20034,
368,
341,
286,
1077,
9472,
284,
66246,
32695,
85062,
1005,
2186,
22428,
66,
91,
421,
272,
621,
364,
16,
6,
314,
472,
335,
770,
314,
444,
1625,
286,
1077,
10151,
284,
28889,
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... | 2 |
#[test]
fn test_apply_pwa() {
use crate::apps_registry::AppsRegistry;
use crate::config;
use config::Config;
use std::env;
let _ = env_logger::try_init();
// Init apps from test-fixtures/webapps and verify in test-apps-dir-pwa.
let current = env::current_dir().unwrap();
let root_path = format!("{}/test-fixtures/webapps", current.display());
let test_dir = format!("{}/test-fixtures/test-apps-dir-pwa", current.display());
let test_path = Path::new(&test_dir);
// This dir is created during the test.
// Tring to remove it at the beginning to make the test at local easy.
let _ = remove_dir_all(&test_path);
println!("Register from: {}", &root_path);
let config = Config {
root_path,
data_path: test_dir.clone(),
uds_path: String::from("uds_path"),
cert_type: String::from("test"),
updater_socket: String::from("updater_socket"),
};
let vhost_port = 80;
let mut registry = match AppsRegistry::initialize(&config, vhost_port) {
Ok(v) => v,
Err(err) => {
panic!("err: {:?}", err);
}
};
println!("registry.count(): {}", registry.count());
assert_eq!(4, registry.count());
// Test 1: apply from a local dir
let src_manifest = current.join("test-fixtures/apps-from/pwa/manifest.webmanifest");
let update_url = "https://pwa1.test/manifest.webmanifest";
let download_dir = AppsStorage::get_app_dir(
&test_path.join("downloading"),
&format!("{}", hash(update_url)),
)
.unwrap();
let download_manifest = download_dir.join("manifest.webmanifest");
if let Err(err) = std::fs::create_dir_all(download_dir.as_path()) {
println!("{:?}", err);
}
let _ = std::fs::copy(&src_manifest, &download_manifest).unwrap();
let manifest = Manifest::read_from(&download_manifest).unwrap();
let app_name = registry
.get_unique_name(&manifest.get_name(), &update_url)
.unwrap();
if let Some(icons_value) = manifest.get_icons() {
let icons: Vec<Icons> = serde_json::from_value(icons_value).unwrap_or_else(|_| vec![]);
assert_eq!(4, icons.len());
} else {
panic!();
}
let mut apps_item = AppsItem::default(&app_name, vhost_port);
apps_item.set_install_state(AppsInstallState::Installing);
apps_item.set_update_url(&update_url);
match registry.apply_pwa(
&mut apps_item,
&download_dir.as_path(),
&manifest,
&test_path,
) {
Ok(_) => {
assert_eq!(apps_item.get_name(), "helloworld");
assert_eq!(apps_item.get_install_state(), AppsInstallState::Installed);
}
Err(err) => {
println!("err: {:?}", err);
panic!();
}
}
let shared_data = &*APPS_SHARED_SHARED_DATA;
// Test 2: download and apply from a remote url
let app_url = "https://testpwa.github.io/manifest.webmanifest";
let mut request = AppsRequest::new(shared_data.clone());
match request.download_and_apply_pwa(&test_dir, app_url) {
Ok(app) => {
assert_eq!(app.name, "hellopwa");
assert_eq!(app.removable, true);
}
Err(err) => {
println!("err: {:?}", err);
panic!();
}
}
if let Some(app) = shared_data.lock().registry.get_by_update_url(app_url) {
assert_eq!(app.get_name(), "hellopwa");
let cached_dir = test_path.join("cached").join(app.get_name());
let update_manifest = cached_dir.join("manifest.webmanifest");
let manifest = Manifest::read_from(&update_manifest).unwrap();
// start url should be absolute url of remote address
assert_eq!(
manifest.get_start_url(),
"https://testpwa.github.io/index.html"
);
// icon url should be relative path of local cached address
if let Some(icons_value) = manifest.get_icons() {
let icons: Vec<Icons> = serde_json::from_value(icons_value).unwrap_or_else(|_| vec![]);
assert_eq!(4, icons.len());
let manifest_url_base = Url::parse(&app.get_manifest_url()).unwrap().join("/");
for icon in icons {
let icon_src = icon.get_src();
let icon_url_base = Url::parse(&icon_src).unwrap().join("/");
assert_eq!(icon_url_base, manifest_url_base);
}
} else {
panic!();
}
} else {
panic!();
}
} | rust_cleaned_test_functions.jsonl/127288 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2036
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36551,
620,
9991,
368,
341,
262,
990,
17717,
486,
27635,
50650,
486,
53602,
15603,
280,
262,
990,
17717,
486,
1676,
280,
262,
990,
2193,
486,
2648,
280,
262,
990,
1460,
486,
3160,
401,
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... | 9 |
#[test]
fn test_status() {
let list = SongList::new_from_initial_batch(batch(0));
assert_eq!(list.status(0), SongIndexStatus::Present);
assert_eq!(list.status(6), SongIndexStatus::Absent);
assert_eq!(list.status(10), SongIndexStatus::OutOfBounds);
} | rust_cleaned_test_functions.jsonl/101860 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 127
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4773,
368,
341,
286,
1077,
1140,
284,
18971,
852,
486,
931,
5673,
15809,
14534,
30139,
7,
15,
1106,
286,
2060,
10714,
10297,
1607,
4299,
7,
15,
701,
18971,
1552,
2522,
486,
21195,
317,
286,
2060... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_system_path() {
let mut pathbufs: Vec<PathBuf> = Vec::new();
pathbufs.push(shim_dir());
pathbufs.push(PathBuf::from("C:\\\\somebin"));
pathbufs.push(PathBuf::from("D:\\\\ProbramFlies"));
let path_with_shims = std::env::join_paths(pathbufs.iter())
.unwrap()
.into_string()
.expect("Could not create path containing shim dir");
std::env::set_var("PATH", path_with_shims);
let expected_path = String::from("C:\\\\somebin;D:\\\\ProbramFlies");
assert_eq!(System::path().unwrap().into_string().unwrap(), expected_path);
} | rust_cleaned_test_functions.jsonl/132774 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 302
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17687,
2638,
368,
341,
286,
1077,
5206,
1815,
5909,
82,
25,
11312,
82883,
15064,
29,
284,
11312,
486,
931,
543,
286,
1815,
5909,
82,
2552,
23254,
318,
4334,
1423,
286,
1815,
5909,
82,
2552,
3303... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_latest_slot() {
let slot_slice = vec![(0, true), (5, true), (3, true), (7, true)];
let index = AccountsIndex::<bool>::default();
assert!(index.latest_slot(None, &slot_slice, None).is_none());
index.add_root(5, false);
assert_eq!(index.latest_slot(None, &slot_slice, None).unwrap(), 1);
assert_eq!(index.latest_slot(None, &slot_slice, Some(5)).unwrap(), 1);
assert!(index.latest_slot(None, &slot_slice, Some(4)).is_none());
// ancestors should not be affected
let ancestors = vec![(3, 1), (7, 1)].into_iter().collect();
assert_eq!(
index
.latest_slot(Some(&ancestors), &slot_slice, Some(4))
.unwrap(),
3
);
assert_eq!(
index
.latest_slot(Some(&ancestors), &slot_slice, Some(7))
.unwrap(),
3
);
assert_eq!(
index
.latest_slot(Some(&ancestors), &slot_slice, None)
.unwrap(),
3
);
} | rust_cleaned_test_functions.jsonl/2238 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 637
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
64880,
27563,
368,
341,
286,
1077,
9446,
26488,
284,
7486,
0,
9697,
15,
11,
830,
701,
320,
20,
11,
830,
701,
320,
18,
11,
830,
701,
320,
22,
11,
830,
12587,
286,
1077,
1922,
284,
40655,
1552... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_initialized() {
with_rewards_default(|_, accounts| {
for (picasso_account, remote_account) in accounts.into_iter() {
assert_noop!(remote_account.associate(picasso_account), Error::<Test>::NotInitialized);
}
});
} | rust_cleaned_test_functions.jsonl/41088 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 96
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7913,
62421,
368,
341,
46948,
77997,
9993,
22428,
6878,
9618,
91,
341,
197,
2023,
320,
15587,
28863,
13500,
11,
8699,
13500,
8,
304,
9618,
39860,
11723,
368,
341,
298,
6948,
6536,
453,
10297,
1814... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_records_nested_in_records_not_supported_yet() {
let ir = ir_from_cc("struct SomeStruct { struct NestedStruct {}; };").unwrap();
assert_ir_matches!(
ir,
quote! { UnsupportedItem {
name: "SomeStruct::NestedStruct",
message: "Nested classes are not supported yet" ...
}}
);
} | rust_cleaned_test_functions.jsonl/37197 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 155
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31279,
66279,
1243,
31279,
7913,
57885,
4178,
295,
368,
341,
262,
1077,
6216,
284,
6216,
5673,
28955,
445,
1235,
4329,
9422,
314,
2036,
71742,
9422,
52166,
20066,
1827,
15454,
543,
262,
2060,
51433,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_avg_return_type() -> Result<()> {
let observed = return_type(&AggregateFunction::Avg, &[DataType::Float32])?;
assert_eq!(DataType::Float64, observed);
let observed = return_type(&AggregateFunction::Avg, &[DataType::Float64])?;
assert_eq!(DataType::Float64, observed);
let observed = return_type(&AggregateFunction::Avg, &[DataType::Int32])?;
assert_eq!(DataType::Float64, observed);
let observed = return_type(&AggregateFunction::Avg, &[DataType::Decimal(10, 6)])?;
assert_eq!(DataType::Decimal(14, 10), observed);
let observed = return_type(&AggregateFunction::Avg, &[DataType::Decimal(36, 6)])?;
assert_eq!(DataType::Decimal(38, 10), observed);
Ok(())
} | rust_cleaned_test_functions.jsonl/4598 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 321
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26631,
12511,
1819,
368,
1464,
5714,
71698,
341,
286,
1077,
13166,
284,
470,
1819,
2099,
64580,
5152,
486,
39447,
11,
44590,
22653,
486,
5442,
18,
17,
2467,
37445,
286,
2060,
10714,
10297,
22653,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_conf_change_check_before_campaign() {
let l = default_logger();
let mut nt = Network::new(vec![None, None, None], &l);
nt.send(vec![new_message(1, 1, MessageType::MsgHup, 0)]);
assert_eq!(nt.peers[&1].state, StateRole::Leader);
let mut m = new_message(1, 1, MessageType::MsgPropose, 0);
let mut e = Entry::default();
e.set_entry_type(EntryType::EntryConfChange);
let mut cc = ConfChange::default();
cc.set_change_type(ConfChangeType::RemoveNode);
cc.node_id = 3;
e.data = protobuf::Message::write_to_bytes(&cc).unwrap();
m.mut_entries().push(e);
nt.send(vec![m]);
// trigger campaign in node 2
nt.peers
.get_mut(&2)
.unwrap()
.reset_randomized_election_timeout();
let timeout = nt.peers[&2].randomized_election_timeout();
for _ in 0..timeout {
nt.peers.get_mut(&2).unwrap().tick();
}
// It's still follower because committed conf change is not applied.
assert_eq!(nt.peers[&2].state, StateRole::Follower);
// Transfer leadership to peer 2.
nt.send(vec![new_message(2, 1, MessageType::MsgTransferLeader, 0)]);
assert_eq!(nt.peers[&1].state, StateRole::Leader);
// It's still follower because committed conf change is not applied.
assert_eq!(nt.peers[&2].state, StateRole::Follower);
// Abort transfer leader.
nt.peers.get_mut(&1).unwrap().abort_leader_transfer();
let committed = nt.peers[&2].raft_log.committed;
nt.peers.get_mut(&2).unwrap().commit_apply(committed);
nt.peers
.get_mut(&2)
.unwrap()
.apply_conf_change(&remove_node(3))
.unwrap();
// transfer leadership to peer 2 again.
nt.send(vec![new_message(2, 1, MessageType::MsgTransferLeader, 0)]);
assert_eq!(nt.peers[&1].state, StateRole::Follower);
assert_eq!(nt.peers[&2].state, StateRole::Leader);
nt.peers.get_mut(&1).unwrap().commit_apply(committed);
nt.peers
.get_mut(&1)
.unwrap()
.apply_conf_change(&remove_node(3))
.unwrap();
// trigger campaign in node 1
nt.peers
.get_mut(&1)
.unwrap()
.reset_randomized_election_timeout();
let timeout = nt.peers[&1].randomized_election_timeout();
for _ in 0..timeout {
nt.peers.get_mut(&1).unwrap().tick();
}
assert_eq!(nt.peers[&1].state, StateRole::Candidate);
} | rust_cleaned_test_functions.jsonl/19192 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1042
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16059,
15947,
7200,
23708,
58561,
368,
341,
262,
1077,
326,
284,
1638,
27413,
543,
262,
1077,
5206,
31412,
284,
8141,
486,
931,
25592,
20703,
4064,
11,
2240,
11,
2240,
1125,
609,
75,
317,
262,
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... | 3 |
#[test]
fn test_format_mem_access() {
let mut bus = Bus::new(test_rom(), |ppu: &NesPPU, &mut Joypad| {});
bus.mem_write(100, 0x11);
bus.mem_write(101, 0x33);
// Data
bus.mem_write(0x33, 00);
bus.mem_write(0x34, 04);
// Target Cell
bus.mem_write(0x400, 0xAA);
let mut cpu = CPU::new(bus);
cpu.program_counter = 0x64;
cpu.register_y = 0;
let mut result: Vec<String> = vec![];
cpu.run_with_callback(|cpu| {
result.push(trace(cpu));
});
assert_eq!(
"0064 11 33 ORA ($33),Y = 0400 @ 0400 = AA A:00 X:00 Y:00 P:24 SP:FD",
result[0]
);
} | rust_cleaned_test_functions.jsonl/82245 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 408
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8955,
12976,
12759,
368,
341,
286,
1077,
5206,
5828,
284,
18598,
486,
931,
8623,
81383,
1507,
760,
602,
84,
25,
609,
45,
288,
4406,
52,
11,
609,
6984,
10946,
54295,
91,
35311,
1789,
286,
5828,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_aes128_cmac() {
// NOTE: CMAC-KEY 为 前面的一半。
let key = hex::decode("2b7e151628aed2a6abf7158809cf4f3c\
fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0").unwrap();
let cipher = AesSivCmac256::new(&key);
let k1 = &cipher.cmac_k1;
let k2 = &cipher.cmac_k2;
assert_eq!(&k1[..], &hex::decode("fbeed618357133667c85e08f7236a8de").unwrap()[..]);
assert_eq!(&k2[..], &hex::decode("f7ddac306ae266ccf90bc11ee46d513b").unwrap()[..]);
let m = hex::decode("").unwrap();
let tag = cipher.cmac(&m, None);
assert_eq!(&tag[..], &hex::decode("bb1d6929e95937287fa37d129b756746").unwrap()[..] );
let m = hex::decode("6bc1bee22e409f96e93d7e117393172a").unwrap();
let tag = cipher.cmac(&m, None);
assert_eq!(&tag[..], &hex::decode("070a16b46b4d4144f79bdd9dd04a287c").unwrap()[..] );
let m = hex::decode("6bc1bee22e409f96e93d7e117393172a\
ae2d8a571e03ac9c9eb76fac45af8e51\
30c81c46a35ce411").unwrap();
let tag = cipher.cmac(&m, None);
assert_eq!(&tag[..], &hex::decode("dfa66747de9ae63030ca32611497c827").unwrap()[..] );
let m = hex::decode("\
6bc1bee22e409f96e93d7e117393172a\
ae2d8a571e03ac9c9eb76fac45af8e51\
30c81c46a35ce411e5fbc1191a0a52ef\
f69f2445df4f9b17ad2b417be66c3710").unwrap();
let tag = cipher.cmac(&m, None);
assert_eq!(&tag[..], &hex::decode("51f0bebf7e3b9d92fc49741779363cfe").unwrap()[..] );
} | rust_cleaned_test_functions.jsonl/78461 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 727
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
90958,
16,
17,
23,
666,
11948,
368,
341,
262,
442,
16743,
25,
18090,
1706,
12,
4784,
220,
17714,
4891,
231,
235,
27091,
99774,
99369,
8997,
262,
1077,
1376,
284,
12371,
486,
18196,
445,
17,
65,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_issues_16() {
// See: https://github.com/sile/libflate/issues/16
let encoded =
include_bytes!("../data/issues_16/crash-1bb6d408475a5bd57247ee40f290830adfe2086e");
assert_eq!(
decode_all(&encoded[..]).err().map(|e| e.to_string()),
Some("The value of HDIST is too big: max=30, actual=32".to_owned())
);
let encoded =
include_bytes!("../data/issues_16/crash-369e8509a0e76356f4549c292ceedee429cfe125");
assert_eq!(
decode_all(&encoded[..]).err().map(|e| e.to_string()),
Some("The value of HDIST is too big: max=30, actual=32".to_owned())
);
let encoded =
include_bytes!("../data/issues_16/crash-e75959d935650306881140df7f6d1d73e33425cb");
assert_eq!(
decode_all(&encoded[..]).err().map(|e| e.to_string()),
Some("The value of HDIST is too big: max=30, actual=32".to_owned())
);
} | rust_cleaned_test_functions.jsonl/37992 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 510
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
90232,
62,
16,
21,
368,
341,
286,
442,
3496,
25,
3703,
1110,
5204,
905,
2687,
457,
8194,
16716,
38745,
14,
16,
21,
271,
286,
1077,
20498,
4035,
310,
2924,
12524,
17223,
1244,
691,
38745,
62,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_lambda() {
assert_eq!(lambda("||{}"), nom_ok(Expr::Lambda(vec![], Block::new())));
assert_eq!(lambda("|a|{ a::b; }"), nom_ok(Expr::Lambda(
vec!["a".to_string()],
nom_eval(block_body("a::b;")),
)));
} | rust_cleaned_test_functions.jsonl/14403 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 156
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
51884,
368,
341,
286,
2060,
10714,
10297,
12935,
445,
8484,
6257,
3975,
9662,
19817,
7,
16041,
486,
58266,
25592,
0,
12995,
8362,
486,
931,
45722,
286,
2060,
10714,
10297,
12935,
38547,
64,
91,
90... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_crypto1() {
let ev = new_fin_event(100);
let mut encrypt_ctx = CryptoContext::new(
METHOD_CHACHA20_POLY1305,
"21321321321321312321321321212asdfasdasdas1",
21321312,
);
let mut decrypt_ctx = encrypt_ctx.clone();
let mut buf = BytesMut::new();
encrypt_ctx.encrypt(&ev, &mut buf);
println!("encoded buf len:{} {}", buf.capacity(), buf.len());
let r = decrypt_ctx.decrypt(&mut buf).unwrap();
assert_eq!(r.header.stream_id, 100);
assert_eq!(r.header.len(), 0);
assert_eq!(buf.len(), 0);
} | rust_cleaned_test_functions.jsonl/34285 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 329
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
78298,
16,
368,
341,
286,
1077,
3637,
284,
501,
39737,
6748,
7,
16,
15,
15,
317,
286,
1077,
5206,
29625,
15147,
284,
32886,
1972,
486,
931,
1006,
310,
32397,
6466,
11873,
32,
17,
15,
33165,
56... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_arithmetic() {
let input = "echo $((foo bar baz bing 3 * 2))";
let expected = vec![
WordToken::Normal("echo".into(), false, false),
WordToken::Whitespace(" "),
WordToken::Arithmetic("foo bar baz bing 3 * 2"),
];
compare(input, expected);
} | rust_cleaned_test_functions.jsonl/33791 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 129
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25842,
25922,
368,
341,
262,
1077,
1946,
284,
330,
3047,
400,
1188,
7975,
3619,
50247,
293,
287,
220,
18,
353,
220,
17,
593,
876,
262,
1077,
3601,
284,
7486,
90515,
286,
9322,
3323,
486,
12206,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_compute_num_bits() {
assert_eq!(compute_num_bits(1), 1u8);
assert_eq!(compute_num_bits(0), 0u8);
assert_eq!(compute_num_bits(2), 2u8);
assert_eq!(compute_num_bits(3), 2u8);
assert_eq!(compute_num_bits(4), 3u8);
assert_eq!(compute_num_bits(255), 8u8);
assert_eq!(compute_num_bits(256), 9u8);
assert_eq!(compute_num_bits(5_000_000_000), 33u8);
} | rust_cleaned_test_functions.jsonl/86451 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 241
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
57028,
4273,
20034,
368,
341,
286,
2060,
10714,
10297,
27706,
4273,
20034,
7,
16,
701,
220,
16,
84,
23,
317,
286,
2060,
10714,
10297,
27706,
4273,
20034,
7,
15,
701,
220,
15,
84,
23,
317,
286,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ldxb_all() {
test_interpreter_and_jit_asm!(
"
mov r0, r1
ldxb r9, [r0+0]
lsh r9, 0
ldxb r8, [r0+1]
lsh r8, 4
ldxb r7, [r0+2]
lsh r7, 8
ldxb r6, [r0+3]
lsh r6, 12
ldxb r5, [r0+4]
lsh r5, 16
ldxb r4, [r0+5]
lsh r4, 20
ldxb r3, [r0+6]
lsh r3, 24
ldxb r2, [r0+7]
lsh r2, 28
ldxb r1, [r0+8]
lsh r1, 32
ldxb r0, [r0+9]
lsh r0, 36
or r0, r1
or r0, r2
or r0, r3
or r0, r4
or r0, r5
or r0, r6
or r0, r7
or r0, r8
or r0, r9
exit",
[
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09,
],
(),
{ |_vm, res: Result| { res.unwrap() == 0x9876543210 } },
31
);
} | rust_cleaned_test_functions.jsonl/58987 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 677
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
50573,
7929,
5705,
368,
341,
262,
1273,
15318,
28637,
8378,
5374,
275,
67529,
33673,
286,
6228,
286,
1974,
435,
15,
11,
435,
16,
198,
286,
26129,
7929,
435,
24,
11,
508,
81,
15,
10,
15,
921,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_page_iterator() {
let file = get_test_file("alltypes_plain.parquet");
let file_reader = Arc::new(SerializedFileReader::new(file).unwrap());
let mut page_iterator = FilePageIterator::new(0, file_reader.clone()).unwrap();
// read first page
let page = page_iterator.next();
assert!(page.is_some());
assert!(page.unwrap().is_ok());
// reach end of file
let page = page_iterator.next();
assert!(page.is_none());
let row_group_indices = Box::new(0..1);
let mut page_iterator =
FilePageIterator::with_row_groups(0, row_group_indices, file_reader).unwrap();
// read first page
let page = page_iterator.next();
assert!(page.is_some());
assert!(page.unwrap().is_ok());
// reach end of file
let page = page_iterator.next();
assert!(page.is_none());
} | rust_cleaned_test_functions.jsonl/27263 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 412
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6129,
13491,
368,
341,
286,
1077,
1034,
284,
633,
4452,
2458,
445,
541,
9242,
41015,
33277,
23300,
797,
286,
1077,
1034,
22306,
284,
19689,
486,
931,
3759,
67577,
1703,
5062,
486,
931,
4866,
568,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_nonexistent_file_does_not_exist() {
new_ucmd!()
.args(&["-e", "nonexistent_file"])
.run()
.status_code(1);
} | rust_cleaned_test_functions.jsonl/11008 | {
"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,
21637,
64085,
2458,
96374,
7913,
35906,
368,
341,
262,
501,
68887,
2277,
0,
741,
286,
659,
2116,
2099,
1183,
12,
68,
497,
330,
6280,
64085,
2458,
14108,
286,
659,
6108,
741,
286,
659,
2829,
4136... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_contrast_color_variables() {
let mut w = Writer {
table: HashMap::new(),
highlights: &[],
term_colors: DUMMY_TERM_COLORS,
airline_theme: dummy_airline_theme(),
out: Vec::new(),
};
w.write_contrast_color_variables().unwrap();
assert_eq!(str::from_utf8(&w.out).unwrap(), "\n");
let mut m = HashMap::new();
m.insert(
"hi",
Color {
gui: ColorCode::Normal("#123456"),
cterm: ColorCode::Contrast(12, 34),
},
);
m.insert(
"hello",
Color {
gui: ColorCode::Contrast("#123456", "#7890ab"),
cterm: ColorCode::Contrast(123, 234),
},
);
m.insert(
"hey",
Color {
gui: ColorCode::Normal("#123456"),
cterm: ColorCode::Normal(123),
},
);
m.insert(
"goodbye",
Color {
gui: ColorCode::Contrast("#000000", "#ffffff"),
cterm: ColorCode::Normal(123),
},
);
let mut w = Writer {
table: m,
highlights: &[],
term_colors: DUMMY_TERM_COLORS,
airline_theme: dummy_airline_theme(),
out: Vec::new(),
};
w.write_contrast_color_variables().unwrap();
for (actual, expected) in [
"let s:goodbye_gui = g:spring_night_high_contrast ? '#000000' : '#ffffff'",
"let s:hello_gui = g:spring_night_high_contrast ? '#123456' : '#7890ab'",
"let s:hello_cterm = g:spring_night_high_contrast ? 123 : 234",
"let s:hi_cterm = g:spring_night_high_contrast ? 12 : 34",
"",
]
.iter()
.zip(str::from_utf8(&w.out).unwrap().lines())
{
assert_eq!(*actual, expected);
}
} | rust_cleaned_test_functions.jsonl/76925 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 895
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9165,
62663,
559,
6714,
28182,
368,
341,
262,
1077,
5206,
289,
284,
29404,
341,
286,
1965,
25,
10528,
486,
931,
3148,
286,
21314,
25,
44590,
1259,
286,
4647,
33670,
25,
422,
58673,
75220,
85436,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_indexed_u64() {
let mut schema_builder = Schema::builder();
let field = schema_builder.add_u64_field("value", INDEXED);
let schema = schema_builder.build();
let index = Index::create_in_ram(schema);
let mut index_writer = index.writer_with_num_threads(1, 3_000_000).unwrap();
index_writer.add_document(doc!(field=>1u64));
index_writer.commit().unwrap();
let reader = index.reader().unwrap();
let searcher = reader.searcher();
let term = Term::from_field_u64(field, 1u64);
let mut postings = searcher
.segment_reader(0)
.inverted_index(term.field())
.read_postings(&term, IndexRecordOption::Basic)
.unwrap();
assert!(postings.advance());
assert_eq!(postings.doc(), 0);
assert!(!postings.advance());
} | rust_cleaned_test_functions.jsonl/41946 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 405
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3560,
291,
7300,
21,
19,
368,
341,
286,
1077,
5206,
10802,
28532,
284,
12539,
486,
17850,
543,
286,
1077,
2070,
284,
10802,
28532,
1364,
7300,
21,
19,
5013,
445,
957,
497,
39300,
1479,
317,
286,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_touch_leave_event() {
let event: TouchLeave = js!(
return new TouchEvent( @{TouchLeave::EVENT_TYPE} );
).try_into().unwrap();
assert_eq!( event.event_type(), TouchLeave::EVENT_TYPE );
} | rust_cleaned_test_functions.jsonl/86595 | {
"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,
60840,
62666,
6748,
368,
341,
286,
1077,
1538,
25,
19338,
21833,
284,
6994,
33673,
310,
470,
501,
19338,
1556,
7,
33267,
11309,
21833,
486,
37349,
4189,
92,
1439,
286,
7457,
1539,
45514,
1005,
154... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_trait_for_vec_empty() {
let program_id = Pubkey::default();
let mut bumps = std::collections::BTreeMap::new();
let mut accounts = &[][..];
Vec::<Test>::try_accounts(&program_id, &mut accounts, &[], &mut bumps).unwrap();
} | rust_cleaned_test_functions.jsonl/74419 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 127
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
55665,
78491,
5478,
13251,
15124,
368,
341,
286,
1077,
2025,
842,
284,
22611,
792,
486,
2258,
543,
286,
1077,
5206,
64722,
284,
1460,
486,
51137,
486,
33,
6533,
2227,
486,
931,
543,
286,
1077,
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_optflag_short_arg() {
let args = vec!["-t".to_string(), "20".to_string()];
match Options::new().optflag("t", "test", "testing").parse(&args) {
Ok(ref m) => {
// The next variable after the flag is just a free argument
assert!(m.free[0] == "20");
}
_ => panic!(),
}
} | rust_cleaned_test_functions.jsonl/52368 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 165
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15032,
9903,
16673,
6057,
368,
341,
262,
1077,
2827,
284,
7486,
0,
1183,
12,
83,
3263,
983,
3904,
1507,
330,
17,
15,
3263,
983,
3904,
33800,
262,
2432,
14566,
486,
931,
1005,
2912,
9903,
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... | 2 |
#[test]
fn test_parsing() {
let mut arena = Arena::default();
let doc = arena.parse_str("");
let root = doc.root;
assert_eq!(root.text(&arena), "");
assert_eq!(0, root.level(&arena));
assert!(root.parent(&arena).is_none());
assert_eq!(0, root.children(&arena).count());
let doc = arena.parse_str("* ");
let root = doc.root;
assert_eq!(root.text(&arena), "");
assert_eq!(0, root.level(&arena));
assert_eq!(1, root.children(&arena).count());
let child_id = root.children(&arena).next().unwrap();
assert_eq!(0, child_id.children(&arena).count());
assert_eq!(child_id.parent(&arena), Some(root));
for text in &[
" ",
"\n",
" \n",
"hello",
"hello\n",
"hello\nworld",
"hello\nworld",
] {
let doc = arena.parse_str(text);
let root = doc.root;
if text.ends_with("\n") {
assert_eq!(root.text(&arena), text[..text.len() - 1]);
} else {
assert_eq!(root.text(&arena), *text);
}
assert_eq!(0, root.level(&arena));
assert!(root.parent(&arena).is_none());
assert_eq!(0, root.children(&arena).count());
}
for text in &[
"* ",
"* \n",
"* *\n",
"* * ",
"* Hello",
"* Hello\n",
"*** Hello!!!",
"* Has body\n Body",
"*** Has bullets\n * B1\n * B2\n",
"* Comma\n,* Hello!\n",
] {
let doc = arena.parse_str(text);
let root = doc.root;
assert!(root.text(&arena).is_empty());
assert!(doc.empty_root_section);
assert_eq!(0, root.level(&arena));
assert_eq!(1, root.children(&arena).count());
let child_id = root.children(&arena).next().unwrap();
assert_eq!(0, child_id.children(&arena).count());
assert_eq!(child_id.parent(&arena), Some(root));
if text.ends_with("\n") {
assert_eq!(child_id.text(&arena), text[..text.len() - 1]);
} else {
assert_eq!(child_id.text(&arena), *text);
}
}
let doc = arena.parse_str("* Curved\n* Swords");
let root = doc.root;
assert!(root.text(&arena).is_empty());
assert!(doc.empty_root_section);
assert_eq!(0, root.level(&arena));
assert_eq!(2, root.children(&arena).count());
let mut ci = root.children(&arena);
let child_id1 = ci.next().unwrap();
let child_id2 = ci.next().unwrap();
assert_eq!(0, child_id1.children(&arena).count());
assert_eq!(child_id1.parent(&arena), Some(root));
assert_eq!(0, child_id2.children(&arena).count());
assert_eq!(child_id2.parent(&arena), Some(doc.root));
assert_eq!(child_id1.text(&arena), "* Curved");
assert_eq!(child_id2.text(&arena), "* Swords");
let doc = arena.parse_str("\n* One\n** Two\n** Another\n* One\n*** Three\n Hello!\n");
let root = doc.root;
assert!(root.text(&arena).is_empty());
assert!(!doc.empty_root_section);
assert_eq!(0, root.level(&arena));
assert_eq!(2, root.children(&arena).count());
let mut ci = root.children(&arena);
let one_id = ci.next().unwrap();
let one_id2 = ci.next().unwrap();
assert_eq!(2, one_id.children(&arena).count());
assert_eq!(1, one_id2.children(&arena).count());
let two_id = one_id.children(&arena).next().unwrap();
let another_id = one_id.children(&arena).skip(1).next().unwrap();
let three_id = one_id2.children(&arena).next().unwrap();
assert_eq!(one_id.text(&arena), "* One");
assert_eq!(one_id.level(&arena), 1);
assert_eq!(another_id.text(&arena), "** Another");
assert_eq!(another_id.level(&arena), 2);
assert_eq!(one_id2.text(&arena), "* One");
assert_eq!(one_id2.level(&arena), 1);
assert_eq!(three_id.text(&arena), "*** Three\n Hello!");
assert_eq!(three_id.level(&arena), 3);
assert_eq!(two_id.text(&arena), "** Two");
assert_eq!(two_id.level(&arena), 2);
} | rust_cleaned_test_functions.jsonl/5627 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1874
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
28598,
368,
341,
262,
1077,
5206,
24902,
284,
27047,
486,
2258,
1428,
262,
1077,
4629,
284,
24902,
4632,
2895,
13056,
262,
1077,
3704,
284,
4629,
12576,
280,
262,
2060,
10714,
10297,
2888,
27... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
#[test]
fn test_single_tank() {
let single_tank = Key::Tank {
ns: prawnspace(),
id: 1,
};
assert_eq!(single_tank.to_string(), "prawnspace/tanks/1");
} | rust_cleaned_test_functions.jsonl/64451 | {
"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,
19487,
528,
1180,
368,
341,
286,
1077,
3175,
528,
1180,
284,
5309,
486,
66033,
341,
310,
12268,
25,
548,
39996,
1306,
3148,
310,
877,
25,
220,
16,
345,
286,
2605,
286,
2060,
10714,
10297,
15338,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_sum(){
let mut data = DataSet::new();
data.push(&[0f64, 0f64], &[0f64]);
data.push(&[1f64, 0f64], &[1f64]);
data.push(&[0f64, 1f64], &[1f64]);
data.push(&[1f64, 1f64], &[0f64]);
let (x, y) = data.sum();
assert_eq!(x[0], 2.0);
assert_eq!(x[1], 2.0);
assert_eq!(y[0], 2.0);
} | rust_cleaned_test_functions.jsonl/84735 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 189
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10160,
3032,
262,
1077,
5206,
821,
284,
27036,
486,
931,
1428,
262,
821,
2552,
2099,
58,
15,
69,
21,
19,
11,
220,
15,
69,
21,
19,
1125,
44590,
15,
69,
21,
19,
2558,
262,
821,
2552,
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_port() -> Result<()> {
init();
let mut counter = 0;
let prop = prop::for_all(gens::port_gen(), move |s| {
counter += 1;
log::debug!("{:>03}, port:string = {}", counter, s);
let input = s.as_bytes();
let result = (port() - end()).parse(input).to_result();
let port = result.unwrap();
log::debug!("{:>03}, port:object = {:?}", counter, port);
assert_eq!(port.to_string(), s);
true
});
prop::test_with_prop(prop, 5, TEST_COUNT, RNG::new())
} | rust_cleaned_test_functions.jsonl/83597 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 240
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8716,
368,
1464,
5714,
71698,
341,
262,
2930,
543,
262,
1077,
5206,
5546,
284,
220,
15,
280,
262,
1077,
2004,
284,
2004,
486,
1958,
5705,
3268,
724,
486,
403,
16322,
1507,
3271,
760,
82,
91,
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_flow_controller_basic() {
let stub = EngineStub::new();
let (_tx, rx) = mpsc::channel();
let flow_controller = FlowController::new(&FlowControlConfig::default(), stub, rx);
// enable flow controller
assert_eq!(flow_controller.enabled(), true);
assert_eq!(flow_controller.should_drop(), false);
assert_eq!(flow_controller.is_unlimited(), true);
assert_eq!(flow_controller.consume(0), Duration::ZERO);
assert_eq!(flow_controller.consume(1000), Duration::ZERO);
// disable flow controller
flow_controller.enable(false);
assert_eq!(flow_controller.enabled(), false);
// re-enable flow controller
flow_controller.enable(true);
assert_eq!(flow_controller.enabled(), true);
assert_eq!(flow_controller.should_drop(), false);
assert_eq!(flow_controller.is_unlimited(), true);
assert_eq!(flow_controller.consume(1), Duration::ZERO);
} | rust_cleaned_test_functions.jsonl/120659 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 401
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
27441,
21600,
34729,
368,
341,
286,
1077,
13633,
284,
8200,
33838,
486,
931,
543,
286,
1077,
5453,
3998,
11,
19111,
8,
284,
296,
81984,
486,
10119,
543,
286,
1077,
6396,
21600,
284,
22452,
2051,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_zigzag_decode() {
// zigzag'
let zigzagp = VarintEncoding::zigzag_decode;
for x in (0..512).map(|x| x * 2) {
assert_eq!(zigzagp(x), x as i64 / 2);
assert_eq!(zigzagp(x + 1), -(x as i64) / 2 - 1);
}
} | rust_cleaned_test_functions.jsonl/518 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 173
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6415,
343,
92674,
15227,
368,
972,
286,
442,
85812,
92674,
9739,
286,
1077,
85812,
92674,
79,
284,
8735,
396,
14690,
486,
35363,
92674,
15227,
463,
286,
369,
856,
304,
320,
15,
496,
20,
16,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_cancel() {
let mut g = Gn::<()>::new(|| {
let mut i = 0;
loop {
yield_with(i);
i += 1;
}
i
});
loop {
// rust 1.17 can't deduce the output type!
let i: i32 = g.next().unwrap();
if i > 10 {
unsafe {
g.cancel();
}
break;
}
}
assert!(g.is_done());
} | rust_cleaned_test_functions.jsonl/91422 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 269
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28895,
368,
341,
262,
1077,
5206,
342,
284,
95151,
27638,
368,
6831,
931,
79453,
341,
286,
1077,
5206,
600,
284,
220,
15,
280,
286,
6337,
341,
310,
7540,
6615,
1956,
317,
310,
600,
1421,
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... | 3 |
#[test]
fn test_binary_array_alignment() {
let ptr = memory::allocate_aligned(8);
let buf = unsafe { Buffer::from_raw_parts(ptr, 8, 8) };
let buf2 = buf.slice(1);
let values: [u8; 12] = [0; 12];
let array_data = ArrayData::builder(DataType::Binary)
.add_buffer(buf2)
.add_buffer(Buffer::from(&values[..]))
.build();
BinaryArray::from(array_data);
} | rust_cleaned_test_functions.jsonl/11639 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 218
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31761,
3858,
51006,
368,
341,
286,
1077,
10087,
284,
4938,
486,
31191,
66385,
7,
23,
317,
286,
1077,
6607,
284,
19860,
314,
10312,
486,
1499,
16067,
33217,
23866,
11,
220,
23,
11,
220,
23,
8,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_implementation() {
let input = buffer(r#"(@interface implement (func 0) (func 1))"#);
let output = Interface::Implementation(Implementation {
core_function_type: 0,
adapter_function_type: 1,
});
assert_eq!(parser::parse::<Interface>(&input).unwrap(), output);
} | rust_cleaned_test_functions.jsonl/102977 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 149
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
14369,
368,
341,
286,
1077,
1946,
284,
4147,
2601,
55543,
5957,
4970,
4211,
320,
2830,
220,
15,
8,
320,
2830,
220,
16,
593,
57676,
317,
286,
1077,
2550,
284,
20019,
486,
36850,
7,
36850,
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_device_info() {
let start_addr1 = GuestAddress(0x0);
let start_addr2 = GuestAddress(0x1000);
let guest_mem = GuestMemory::new(&[(start_addr1, 0x1000), (start_addr2, 0x1000)]).unwrap();
let mut device_manager =
MMIODeviceManager::new(guest_mem, &mut 0xd000_0000, (arch::IRQ_BASE, arch::IRQ_MAX));
let mut cmdline = kernel_cmdline::Cmdline::new(4096);
let dummy_box = Box::new(DummyDevice { dummy: 0 });
let vmm = create_vmm_object();
let type_id = 0;
let id = String::from("foo");
if let Ok(addr) = device_manager.register_virtio_device(
vmm.vm.fd(),
dummy_box,
&mut cmdline,
type_id,
&id,
) {
assert!(device_manager
.get_device(DeviceType::Virtio(type_id), &id)
.is_some());
assert_eq!(
addr,
device_manager.id_to_dev_info[&(DeviceType::Virtio(type_id), id.clone())].addr
);
assert_eq!(
arch::IRQ_BASE,
device_manager.id_to_dev_info[&(DeviceType::Virtio(type_id), id.clone())].irq
);
}
let id = "bar";
assert!(device_manager
.get_device(DeviceType::Virtio(type_id), &id)
.is_none());
} | rust_cleaned_test_functions.jsonl/102332 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 750
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9204,
3109,
368,
341,
286,
1077,
1191,
7387,
16,
284,
26215,
4286,
7,
15,
87,
15,
317,
286,
1077,
1191,
7387,
17,
284,
26215,
4286,
7,
15,
87,
16,
15,
15,
15,
317,
286,
1077,
8640,
12976,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_cast_by_str() -> Result<()> {
struct Test {
name: &'static str,
literal: &'static str,
value: DataValue,
}
let tests = vec![
Test {
name: "zero",
literal: "0",
value: DataValue::UInt8(Some(0)),
},
Test {
name: "positive",
literal: "31",
value: DataValue::UInt8(Some(31)),
},
Test {
name: "negative",
literal: "-1",
value: DataValue::Int8(Some(-1)),
},
Test {
name: "i8::MIN",
literal: "-128",
value: DataValue::Int8(Some(i8::MIN)),
},
Test {
name: "i16::MIN",
literal: "-32768",
value: DataValue::Int16(Some(i16::MIN)),
},
Test {
name: "i32::MIN",
literal: "-2147483648",
value: DataValue::Int32(Some(i32::MIN)),
},
Test {
name: "i64::MIN",
literal: "-9223372036854775808",
value: DataValue::Int64(Some(i64::MIN)),
},
Test {
name: "u8::MAX",
literal: "255",
value: DataValue::UInt8(Some(u8::MAX)),
},
Test {
name: "u16::MAX",
literal: "65535",
value: DataValue::UInt16(Some(u16::MAX)),
},
Test {
name: "u32::MAX",
literal: "4294967295",
value: DataValue::UInt32(Some(u32::MAX)),
},
Test {
name: "i64::MAX",
literal: "18446744073709551615",
value: DataValue::UInt64(Some(u64::MAX)),
},
Test {
name: "f64",
literal: "1844674407370955244444",
value: DataValue::Float64(Some(1844674407370955200000.0f64)),
},
];
for test in tests {
let literal = test.literal;
let result = DataValue::try_from_literal(literal, None)?;
assert_eq!(result.data_type(), test.value.data_type());
assert_eq!(&result, &test.value, "test with {}", test.name);
}
Ok(())
} | rust_cleaned_test_functions.jsonl/61760 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1242
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5303,
3710,
2895,
368,
1464,
5714,
71698,
341,
262,
2036,
3393,
341,
286,
829,
25,
30136,
1978,
607,
345,
286,
23141,
25,
30136,
1978,
607,
345,
286,
897,
25,
2885,
1130,
345,
262,
555,
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... | 3 |
#[test]
fn test_error_handling() {
let tests = vec![
("5 + true;", "type mismatch: INTEGER + BOOLEAN"),
("5 + true; 5;", "type mismatch: INTEGER + BOOLEAN"),
("-true", "unknown operator: -BOOLEAN"),
("true + false", "unknown operator: BOOLEAN + BOOLEAN"),
("5; true + false; 5", "unknown operator: BOOLEAN + BOOLEAN"),
(
"if (10 > 1) { true + false; }",
"unknown operator: BOOLEAN + BOOLEAN",
),
(
"
if (10 > 1) {
if (10 > 1) {
return true + false;
}
return 1;
}
",
"unknown operator: BOOLEAN + BOOLEAN",
),
("foobar", "identifier not found: foobar"),
("\"Hello\" - \"World\"", "unknown operator: STRING - STRING"),
];
for (input, msg) in tests {
assert_eq!(eval(input), Object::Error(String::from(msg)));
}
} | rust_cleaned_test_functions.jsonl/84231 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 523
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4096,
75642,
368,
341,
262,
1077,
7032,
284,
7486,
90515,
286,
3489,
20,
488,
830,
32503,
330,
1313,
35301,
25,
30381,
488,
59393,
4461,
286,
3489,
20,
488,
830,
26,
220,
20,
32503,
330,
1313,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_marksof () {
let stopname = 242;
let name1 = 243;
let mut t = new_sctable_internal();
assert_eq!(marksof_internal (EMPTY_CTXT,stopname,&t),Vec::new());
// FIXME #5074: ANF'd to dodge nested calls
{ let ans = unfold_marks(vec!(4,98),EMPTY_CTXT,&mut t);
assert_eq! (marksof_internal (ans,stopname,&t),vec!(4,98));}
// does xoring work?
{ let ans = unfold_marks(vec!(5,5,16),EMPTY_CTXT,&mut t);
assert_eq! (marksof_internal (ans,stopname,&t), vec!(16));}
// does nested xoring work?
{ let ans = unfold_marks(vec!(5,10,10,5,16),EMPTY_CTXT,&mut t);
assert_eq! (marksof_internal (ans, stopname,&t), vec!(16));}
// rename where stop doesn't match:
{ let chain = vec!(M(9),
R(id(name1,
new_mark_internal (4, EMPTY_CTXT,&mut t)),
100101102),
M(14));
let ans = unfold_test_sc(chain,EMPTY_CTXT,&mut t);
assert_eq! (marksof_internal (ans, stopname, &t), vec!(9,14));}
// rename where stop does match
{ let name1sc = new_mark_internal(4, EMPTY_CTXT, &mut t);
let chain = vec!(M(9),
R(id(name1, name1sc),
stopname),
M(14));
let ans = unfold_test_sc(chain,EMPTY_CTXT,&mut t);
assert_eq! (marksof_internal (ans, stopname, &t), vec!(9)); }
} | rust_cleaned_test_functions.jsonl/105290 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 825
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18924,
704,
69,
1719,
341,
286,
1077,
2936,
606,
284,
220,
17,
19,
17,
280,
286,
1077,
829,
16,
284,
220,
17,
19,
18,
280,
286,
1077,
5206,
259,
284,
501,
643,
302,
480,
23472,
543,
286,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_random() -> Fallible<()> {
let cryptosys = LibSodiumCryptoSystem::new(Default::default())?;
let mut bytes = [0u8; 16];
cryptosys.fill_random_bytes(&mut bytes);
assert_ne!(&bytes, &[0u8; 16]);
Ok(())
} | rust_cleaned_test_functions.jsonl/49534 | {
"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,
22644,
368,
1464,
14785,
1238,
71698,
341,
286,
1077,
14436,
436,
1047,
284,
5688,
50,
46776,
58288,
2320,
486,
931,
87874,
486,
2258,
2140,
69493,
286,
1077,
5206,
5820,
284,
508,
15,
84,
23,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_unary_minus_float() {
assert_has_variable!(interpret("X = -1.1"), "X!", -1.1_f32);
assert_has_variable!(interpret("X = -1.1#"), "X!", -1.1_f32);
assert_has_variable!(interpret("X = -1"), "X!", -1.0_f32);
assert_linter_err!("X = -\"hello\"", LinterError::TypeMismatch, 1, 6);
} | rust_cleaned_test_functions.jsonl/22657 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 187
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4907,
658,
38457,
17586,
368,
341,
310,
2060,
21778,
14635,
10297,
16897,
445,
55,
284,
481,
16,
13,
16,
3975,
330,
55,
18789,
481,
16,
13,
16,
761,
18,
17,
317,
310,
2060,
21778,
14635,
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_seq_strings() {
let gil = Python::acquire_gil();
let py = gil.python();
let v = vec!["It", "was", "the", "worst", "of", "times"];
let seq = v.to_py_object(py).into_object().cast_into::<PySequence>(py).unwrap();
let bad_needle = "blurst".to_py_object(py);
assert_eq!(false, seq.contains(py, bad_needle).unwrap());
let good_needle = "worst".to_py_object(py);
assert_eq!(true, seq.contains(py, good_needle).unwrap());
} | rust_cleaned_test_functions.jsonl/22532 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 241
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14486,
33500,
368,
341,
286,
1077,
342,
321,
284,
13027,
486,
580,
984,
1889,
321,
543,
286,
1077,
4510,
284,
342,
321,
43193,
543,
286,
1077,
348,
284,
7486,
0,
1183,
2132,
497,
330,
16123,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_bitvec_pb_convert() {
let bv = BitVec::from_bytes(&[0b_1010_0000, 0b_0001_0010]);
let pb_bv = bv.to_pb();
let pb_round_trip: BitVec = ProtobufConvert::from_pb(pb_bv).unwrap();
assert_eq!(pb_round_trip, bv);
} | rust_cleaned_test_functions.jsonl/14333 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 127
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13996,
4083,
31409,
34910,
368,
341,
262,
1077,
56937,
284,
6495,
10050,
486,
1499,
12524,
2099,
58,
15,
65,
62,
16,
15,
16,
15,
62,
15,
15,
15,
15,
11,
220,
15,
65,
62,
15,
15,
15,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_to_avro_datum() {
let schema = Schema::parse_str(SCHEMA).unwrap();
let mut record = Record::new(&schema).unwrap();
record.put("a", 27i64);
record.put("b", "foo");
let mut expected = Vec::new();
zig_i64(27, &mut expected);
zig_i64(3, &mut expected);
expected.extend(vec![b'f', b'o', b'o'].into_iter());
assert_eq!(to_avro_datum(&schema, record).unwrap(), expected);
} | rust_cleaned_test_functions.jsonl/37656 | {
"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,
2346,
26173,
299,
15353,
372,
368,
341,
286,
1077,
10802,
284,
12539,
486,
6400,
2895,
59461,
35839,
568,
15454,
543,
286,
1077,
5206,
3255,
284,
13583,
486,
931,
2099,
17349,
568,
15454,
543,
286... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_storage() {
let tmpdir = starcoin_config::temp_dir();
let storage = Storage::new(StorageInstance::new_cache_and_db_instance(
CacheStorage::new(None),
DBStorage::new(tmpdir.path(), RocksdbConfig::default(), None).unwrap(),
))
.unwrap();
let transaction_info1 = RichTransactionInfo::new(
HashValue::random(),
rand::random(),
TransactionInfo::new(
HashValue::random(),
HashValue::zero(),
vec![].as_slice(),
0,
KeptVMStatus::Executed,
),
rand::random(),
rand::random(),
);
let id = transaction_info1.id();
storage
.transaction_info_storage
.put(id, transaction_info1.clone())
.unwrap();
let transaction_info2 = storage.transaction_info_storage.get(id).unwrap();
assert!(transaction_info2.is_some());
assert_eq!(transaction_info1, transaction_info2.unwrap());
} | rust_cleaned_test_functions.jsonl/73684 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 429
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
23310,
368,
341,
262,
1077,
4174,
3741,
284,
6774,
7160,
5332,
486,
3888,
4334,
543,
262,
1077,
5819,
284,
14693,
486,
931,
7,
5793,
2523,
486,
931,
11529,
8378,
8685,
11904,
1006,
286,
19479,
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_get_neuron_ids_by_principal() {
let principal1 = principal(1);
let principal2 = principal(2);
let principal3 = principal(3);
let principal4 = principal(4);
let mut driver = fake::FakeDriver::default();
let neuron_a = Neuron {
id: Some(NeuronId { id: 1 }),
controller: Some(principal1),
account: driver.random_byte_array().to_vec(),
..Default::default()
};
let neuron_b = Neuron {
id: Some(NeuronId { id: 2 }),
controller: Some(principal2),
account: driver.random_byte_array().to_vec(),
..Default::default()
};
let neuron_c = Neuron {
id: Some(NeuronId { id: 3 }),
controller: Some(principal2),
account: driver.random_byte_array().to_vec(),
..Default::default()
};
let neuron_d = Neuron {
id: Some(NeuronId { id: 4 }),
controller: Some(principal2),
hot_keys: vec![principal4],
account: driver.random_byte_array().to_vec(),
..Default::default()
};
let mut gov_proto = empty_fixture();
gov_proto.neurons = vec![(1, neuron_a), (2, neuron_b), (3, neuron_c), (4, neuron_d)]
.into_iter()
.collect();
let driver = fake::FakeDriver::default();
let gov = Governance::new(gov_proto, driver.get_fake_env(), driver.get_fake_ledger());
let mut principal2_neuron_ids = gov.get_neuron_ids_by_principal(&principal2);
principal2_neuron_ids.sort_unstable();
assert_eq!(gov.get_neuron_ids_by_principal(&principal1), vec![1]);
assert_eq!(principal2_neuron_ids, vec![2, 3, 4]);
assert_eq!(
gov.get_neuron_ids_by_principal(&principal3),
Vec::<u64>::new()
);
assert_eq!(gov.get_neuron_ids_by_principal(&principal4), vec![4]);
} | rust_cleaned_test_functions.jsonl/1140 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 816
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
13925,
36090,
8077,
3710,
82402,
368,
341,
262,
1077,
12435,
16,
284,
12435,
7,
16,
317,
262,
1077,
12435,
17,
284,
12435,
7,
17,
317,
262,
1077,
12435,
18,
284,
12435,
7,
18,
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_half_connect() {
let mut data = bm(&[
0b00010000, 39, 0x00, 0x04, 'M' as u8, 'Q' as u8, 'T' as u8, 'T' as u8, 0x04,
0b11001110,
0x00,
0x0a, // 10 sec
]);
assert_eq!(Ok(None), decode(&mut data));
assert_eq!(12, data.len());
} | rust_cleaned_test_functions.jsonl/95612 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 260
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
40626,
15720,
368,
341,
262,
1077,
5206,
821,
284,
34868,
2099,
9640,
286,
220,
15,
65,
15,
15,
15,
16,
15,
15,
15,
15,
11,
220,
18,
24,
11,
220,
15,
87,
15,
15,
11,
220,
15,
87,
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... | 1 |
#[test]
fn test_encode_and_decode_jwt_hs256() {
let p1 = json!({
"key1" : "val1",
"key2" : "val2",
"key3" : "val3"
});
let secret = "secret123".to_string();
let header = json!({});
let jwt1 = encode(header, &secret, &p1, Algorithm::HS256).unwrap();
let maybe_res = decode(&jwt1, &secret, Algorithm::HS256);
assert!(maybe_res.is_ok());
} | rust_cleaned_test_functions.jsonl/45836 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 236
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11224,
8378,
15227,
95576,
85956,
17,
20,
21,
368,
341,
286,
1077,
281,
16,
284,
2951,
0,
2262,
310,
330,
792,
16,
1,
549,
330,
831,
16,
756,
310,
330,
792,
17,
1,
549,
330,
831,
17,
756,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_mul_5() {
let z = c(3i32, 2i32);
assert_eq!(z * 3, c(9, 6));
} | rust_cleaned_test_functions.jsonl/99220 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 59
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
24944,
62,
20,
368,
341,
262,
1077,
1147,
284,
272,
7,
18,
72,
18,
17,
11,
220,
17,
72,
18,
17,
317,
262,
2060,
10714,
10297,
89,
353,
220,
18,
11,
272,
7,
24,
11,
220,
21,
1106,
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 |
#[test]
fn test_progress_update() {
let (prev_m, prev_n) = (3u64, 5u64);
let tests = vec![
(prev_m - 1, prev_m, prev_n, false),
(prev_m, prev_m, prev_n, false),
(prev_m + 1, prev_m + 1, prev_n, true),
(prev_m + 2, prev_m + 2, prev_n + 1, true),
];
for (i, &(update, wm, wn, wok)) in tests.iter().enumerate() {
let mut p = Progress::new(prev_n, 256);
p.matched = prev_m;
let ok = p.maybe_update(update);
if ok != wok {
panic!("#{}: ok= {}, want {}", i, ok, wok);
}
if p.matched != wm {
panic!("#{}: match= {}, want {}", i, p.matched, wm);
}
if p.next_idx != wn {
panic!("#{}: next= {}, want {}", i, p.next_idx, wn);
}
}
} | rust_cleaned_test_functions.jsonl/30236 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 436
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
27200,
8882,
368,
341,
262,
1077,
320,
9883,
717,
11,
7872,
1089,
8,
284,
320,
18,
84,
21,
19,
11,
220,
20,
84,
21,
19,
317,
262,
1077,
7032,
284,
7486,
90515,
286,
320,
9883,
717,
481,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
#[test]
fn test_ipv4_fragment_not_multiple_of_offset_unit() {
let mut ctx = DummyCtx::<Ipv4>::default();
let mut cache = IpPacketFragmentCache::<Ipv4>::default();
let fragment_id = 0;
assert_eq!(cache.size, 0);
// Test that fragment bodies must be a multiple of
// Process fragment #0
process_ipv4_fragment(&mut cache, &mut ctx, fragment_id, 0, true, ExpectedResult::NeedMore);
// Process fragment #1 (body size is not a multiple of
let mut builder = get_ipv4_builder();
builder.id(fragment_id);
builder.fragment_offset(1);
builder.mf_flag(true);
// Body with 1 byte less than `FRAGMENT_BLOCK_SIZE` so it is not a
// multiple of `FRAGMENT_BLOCK_SIZE`.
let mut body: Vec<u8> = Vec::new();
body.extend(FRAGMENT_BLOCK_SIZE..FRAGMENT_BLOCK_SIZE * 2 - 1);
let mut buffer = Buf::new(body, ..).encapsulate(builder).serialize_vec_outer().unwrap();
let packet = buffer.parse::<Ipv4Packet<_>>().unwrap();
assert_frag_proc_state_invalid!(cache.process_fragment::<_, &[u8]>(&mut ctx, packet));
// Process fragment #1 (body size is not a multiple of
// allowed to not be a multiple of `FRAGMENT_BLOCK_SIZE`.
let mut builder = get_ipv4_builder();
builder.id(fragment_id);
builder.fragment_offset(1);
builder.mf_flag(false);
// Body with 1 byte less than `FRAGMENT_BLOCK_SIZE` so it is not a
// multiple of `FRAGMENT_BLOCK_SIZE`.
let mut body: Vec<u8> = Vec::new();
body.extend(FRAGMENT_BLOCK_SIZE..FRAGMENT_BLOCK_SIZE * 2 - 1);
let mut buffer = Buf::new(body, ..).encapsulate(builder).serialize_vec_outer().unwrap();
let packet = buffer.parse::<Ipv4Packet<_>>().unwrap();
let (key, packet_len) = assert_frag_proc_state_ready!(
cache.process_fragment::<_, &[u8]>(&mut ctx, packet),
DUMMY_CONFIG_V4.remote_ip.get(),
DUMMY_CONFIG_V4.local_ip.get(),
fragment_id,
35
);
validate_size(&cache);
let mut buffer: Vec<u8> = vec![0; packet_len];
let mut buffer = &mut buffer[..];
let packet =
cache.reassemble_packet::<_, &mut [u8], _>(&mut ctx, &key, &mut buffer).unwrap();
let mut expected_body: Vec<u8> = Vec::new();
expected_body.extend(0..15);
assert_eq!(packet.body(), &expected_body[..]);
assert_eq!(cache.size, 0);
} | rust_cleaned_test_functions.jsonl/52572 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1197
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
49378,
19,
43012,
7913,
45233,
3575,
6917,
14832,
368,
341,
286,
1077,
5206,
5635,
284,
50567,
23684,
27638,
80656,
19,
6831,
2258,
543,
286,
1077,
5206,
6500,
284,
35033,
16679,
9488,
8233,
27638,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_change_shared_block_cache() {
let (mut cfg, _dir) = TiKvConfig::with_tmp().unwrap();
cfg.storage.block_cache.shared = true;
cfg.validate().unwrap();
let (storage, cfg_controller, ..) = new_engines(cfg);
let db = storage.get_engine().get_rocksdb();
// Can not update shared block cache through rocksdb module
assert!(
cfg_controller
.update_config("rocksdb.defaultcf.block-cache-size", "256MB")
.is_err()
);
cfg_controller
.update_config("storage.block-cache.capacity", "256MB")
.unwrap();
let defaultcf_opts = db.get_options_cf(CF_DEFAULT).unwrap();
assert_eq!(
defaultcf_opts.get_block_cache_capacity(),
ReadableSize::mb(256).0
);
} | rust_cleaned_test_functions.jsonl/2158 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 417
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15947,
20405,
7113,
11529,
368,
341,
286,
1077,
320,
6984,
13286,
11,
716,
3741,
8,
284,
22325,
42,
85,
2648,
486,
4197,
16125,
1005,
15454,
543,
286,
13286,
22403,
15697,
11529,
18062,
284,
830,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_mark_valid_invalid_forks() {
let mut heaviest_subtree_fork_choice = setup_forks();
let stake = 100;
let (bank, vote_pubkeys) = bank_utils::setup_bank_and_vote_pubkeys(3, stake);
let pubkey_votes: Vec<(Pubkey, SlotHashKey)> = vec![
(vote_pubkeys[0], (6, Hash::default())),
(vote_pubkeys[1], (6, Hash::default())),
(vote_pubkeys[2], (2, Hash::default())),
];
let expected_best_slot = 6;
assert_eq!(
heaviest_subtree_fork_choice.add_votes(
pubkey_votes.iter(),
bank.epoch_stakes_map(),
bank.epoch_schedule()
),
(expected_best_slot, Hash::default()),
);
// not the other for at 4.
let invalid_candidate = (5, Hash::default());
heaviest_subtree_fork_choice.mark_fork_invalid_candidate(&invalid_candidate);
assert_eq!(heaviest_subtree_fork_choice.best_overall_slot().0, 3);
assert!(!heaviest_subtree_fork_choice
.is_candidate_slot(&invalid_candidate)
.unwrap());
// The ancestor is still a candidate
assert!(heaviest_subtree_fork_choice
.is_candidate_slot(&(3, Hash::default()))
.unwrap());
// Adding another descendant to the invalid candidate won't
let new_leaf_slot7 = 7;
heaviest_subtree_fork_choice.add_new_leaf_slot(
(new_leaf_slot7, Hash::default()),
Some((6, Hash::default())),
);
let invalid_slot_ancestor = 3;
assert_eq!(
heaviest_subtree_fork_choice.best_overall_slot().0,
invalid_slot_ancestor
);
let pubkey_votes: Vec<(Pubkey, SlotHashKey)> =
vec![(vote_pubkeys[0], (new_leaf_slot7, Hash::default()))];
assert_eq!(
heaviest_subtree_fork_choice.add_votes(
pubkey_votes.iter(),
bank.epoch_stakes_map(),
bank.epoch_schedule()
),
(invalid_slot_ancestor, Hash::default()),
);
// Adding a descendant to the ancestor of the invalid candidate *should* update
let new_leaf_slot8 = 8;
heaviest_subtree_fork_choice.add_new_leaf_slot(
(new_leaf_slot8, Hash::default()),
Some((invalid_slot_ancestor, Hash::default())),
);
assert_eq!(
heaviest_subtree_fork_choice.best_overall_slot().0,
new_leaf_slot8,
);
heaviest_subtree_fork_choice.mark_fork_valid_candidate(&invalid_candidate);
assert!(heaviest_subtree_fork_choice
.is_candidate_slot(&invalid_candidate)
.unwrap());
assert_eq!(
heaviest_subtree_fork_choice.best_overall_slot().0,
// Should pick the smaller slot of the two new equally weighted leaves
new_leaf_slot7
);
} | rust_cleaned_test_functions.jsonl/85883 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1519
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18924,
8337,
31433,
761,
73302,
368,
341,
286,
1077,
5206,
566,
98362,
5228,
9344,
761,
669,
31936,
284,
6505,
761,
73302,
543,
286,
1077,
18279,
284,
220,
16,
15,
15,
280,
286,
1077,
320,
17033... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_auth_enc_ciphertext_less_than_41_err() {
let key = SecretKey::default();
let ciphertext = [0u8; XCHACHA_NONCESIZE + POLY1305_OUTSIZE];
assert!(open(&key, &ciphertext).is_err());
} | rust_cleaned_test_functions.jsonl/104185 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 129
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14014,
13781,
666,
45043,
50747,
51613,
62,
19,
16,
9266,
368,
341,
310,
1077,
1376,
284,
8599,
1592,
486,
2258,
543,
310,
1077,
69789,
284,
508,
15,
84,
23,
26,
1599,
2149,
11873,
32,
22128,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_execute_cost_table_upsert_within_capacity() {
solana_logger::setup();
let mut testee = ExecuteCostTable::default();
let key1 = Pubkey::new_unique();
let key2 = Pubkey::new_unique();
let cost1: u64 = 100;
let cost2: u64 = 110;
// query empty table
assert!(testee.get_cost(&key1).is_none());
// insert one record
testee.upsert(&key1, &cost1);
assert_eq!(1, testee.get_count());
assert_eq!(cost1, testee.get_average());
assert_eq!(cost1, testee.get_mode());
assert_eq!(&cost1, testee.get_cost(&key1).unwrap());
// insert 2nd record
testee.upsert(&key2, &cost2);
assert_eq!(2, testee.get_count());
assert_eq!((cost1 + cost2) / 2_u64, testee.get_average());
assert_eq!(cost2, testee.get_mode());
assert_eq!(&cost1, testee.get_cost(&key1).unwrap());
assert_eq!(&cost2, testee.get_cost(&key2).unwrap());
// update 1st record
testee.upsert(&key1, &cost2);
assert_eq!(2, testee.get_count());
assert_eq!(((cost1 + cost2) / 2 + cost2) / 2, testee.get_average());
assert_eq!((cost1 + cost2) / 2, testee.get_mode());
assert_eq!(&((cost1 + cost2) / 2), testee.get_cost(&key1).unwrap());
assert_eq!(&cost2, testee.get_cost(&key2).unwrap());
} | rust_cleaned_test_functions.jsonl/71275 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 663
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
44329,
15890,
5237,
8237,
6047,
72385,
35603,
368,
341,
286,
2048,
3362,
27413,
486,
15188,
543,
286,
1077,
5206,
1273,
2127,
284,
20848,
14940,
2556,
486,
2258,
1428,
286,
1077,
1376,
16,
284,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_get_timeout() {
let mut event_loop = Runtime::new().unwrap();
let pool = event_loop
.block_on(lazy(|| {
Pool::builder()
.max_size(1)
.connection_timeout(Duration::from_millis(100))
.build(OkManager::<FakeConnection>::new())
}))
.unwrap();
let (tx1, rx1) = oneshot::channel();
let (tx2, rx2) = oneshot::channel();
event_loop.spawn(
pool.run(move |conn| {
tx1.send(()).unwrap();
rx2.then(|r| match r {
Ok(v) => Ok((v, conn)),
Err(_) => Err((Error, conn)),
})
})
.map_err(|_| ()),
);
// Get the first connection.
assert!(event_loop.block_on(rx1).is_ok());
let e = event_loop.block_on(
pool.run(move |conn| {
let r: Result<_, (Error, _)> = Ok(((), conn));
r.into_future()
})
.map_err(|_| ()),
);
assert!(e.is_err());
tx2.send(()).unwrap();
let r: Result<(), ()> = Ok(());
event_loop.block_on(r.into_future()).unwrap();
} | rust_cleaned_test_functions.jsonl/127890 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 605
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
20537,
368,
341,
262,
1077,
5206,
1538,
17198,
284,
10954,
486,
931,
1005,
15454,
543,
262,
1077,
7314,
284,
1538,
17198,
198,
286,
659,
4574,
4470,
2333,
13619,
79453,
341,
310,
22728,
486,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_ungetch() {
let w = initscr();
let chars = [
'a', 'b', 'c', 'ä', 'ö', 'å', 'A', 'B', 'C', 'Ä', 'Ö', 'Å', '𤭢', '𐍈',
'€', 'ᚠ', 'ᛇ', 'ᚻ', 'þ', 'ð', 'γ', 'λ', 'ώ', 'б', 'е', 'р', 'ვ',
'ე', 'პ', 'ხ', 'இ', 'ங', 'க', 'ಬ', 'ಇ', 'ಲ', 'ಸ',
];
chars.iter().for_each(|c| {
_ungetch(&Input::Character(*c));
assert_eq!(_wgetch(w).unwrap(), Input::Character(*c));
});
SPECIAL_KEY_CODES.iter().for_each(|i| {
_ungetch(i);
assert_eq!(_wgetch(w).unwrap(), *i);
});
endwin();
} | rust_cleaned_test_functions.jsonl/45141 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 425
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4907,
455,
331,
368,
341,
286,
1077,
289,
284,
304,
1199,
5082,
1428,
286,
1077,
23000,
284,
2278,
310,
364,
64,
516,
364,
65,
516,
364,
66,
516,
364,
2305,
516,
364,
2956,
516,
364,
3785,
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_ptrace_peekpoke() {
use nix::sys::ptrace;
use nix::sys::signal::{raise, Signal};
use nix::sys::wait::{waitpid, WaitStatus};
use nix::unistd::fork;
use nix::unistd::ForkResult::*;
let _m = ::FORK_MTX.lock().expect(
"Mutex got poisoned by another test",
);
// FIXME: qemu-user doesn't implement ptrace on all architectures
// and retunrs ENOSYS in this case.
// and skip the test then.
// is already tested by `test_ptrace`.
let err = ptrace::attach(getpid()).unwrap_err();
if err == Error::Sys(Errno::ENOSYS) {
return;
}
match fork() {
Ok(Child) => {
ptrace::traceme().unwrap();
// until the parent is ready to continue
raise(Signal::SIGTRAP).unwrap();
unsafe {
let size = 10000;
let ptr = libc::calloc(size, 1);
libc::getcwd(ptr as *mut i8, size);
libc::free(ptr);
libc::getpriority(0, 42);
libc::_exit(0);
}
}
Ok(Parent { child }) => {
assert_eq!(
waitpid(child, None),
Ok(WaitStatus::Stopped(child, Signal::SIGTRAP))
);
let mut syscall_no = None;
let mut getpriority_checked = false;
let mut getcwd_checked = false;
ptrace::setoptions(child, ptrace::PTRACE_O_TRACESYSGOOD).unwrap();
loop {
ptrace::syscall(child).unwrap();
match waitpid(child, None).unwrap() {
WaitStatus::PtraceSyscall(child) => {
match syscall_no {
None => {
let no = ptrace::peekuser(child, syscall_arg!(0)).unwrap();
syscall_no = Some(no);
if no as i64 == libc::SYS_getpriority as i64 {
let arg2 = ptrace::peekuser(child, syscall_arg!(2)).unwrap();
assert_eq!(arg2, 42);
unsafe {
ptrace::pokeuser(child, syscall_arg!(2), 0).unwrap();
}
let arg2 = ptrace::peekuser(child, syscall_arg!(2)).unwrap();
assert_eq!(arg2, 0);
getpriority_checked = true;
}
}
Some(no) => {
syscall_no = None;
if no as i64 == libc::SYS_getcwd as i64 {
let ret = ptrace::peekuser(child, syscall_arg!(0)).unwrap();
assert!(ret != 0); // no error occured
let buf = ptrace::peekuser(child, syscall_arg!(1)).unwrap();
unsafe {
let word = ptrace::peekdata(child, buf).unwrap();
assert!(word != 0); // something was written to the buffer
ptrace::pokedata(child, buf, 0).unwrap();
let new_word = ptrace::peekdata(child, buf).unwrap();
assert_eq!(new_word, 0);
}
getcwd_checked = true;
}
}
}
}
WaitStatus::Exited(_, code) => {
assert_eq!(code, 0);
break;
}
_ => {}
}
}
assert!(getpriority_checked);
assert!(getcwd_checked);
}
Err(_) => panic!("Error: Fork Failed"),
}
} | rust_cleaned_test_functions.jsonl/63568 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2579
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4348,
578,
62,
29107,
48098,
368,
341,
262,
990,
308,
941,
486,
7791,
486,
3505,
578,
280,
262,
990,
308,
941,
486,
7791,
486,
26622,
22964,
18704,
11,
27230,
2440,
262,
990,
308,
941,
486,
77... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
#[test]
fn test_bytes() {
// The test case is copied from
use serde_test::{assert_de_tokens, assert_tokens, Token};
use serde_with::Bytes;
use std::borrow::Cow;
#[serde_as]
#[derive(Serialize, Deserialize, PartialEq, Debug)]
struct Test<'a> {
#[serde_as(as = "Bytes")]
array: [u8; 52],
#[serde_as(as = "Bytes")]
slice: &'a [u8],
#[serde_as(as = "Bytes")]
vec: Vec<u8>,
#[serde_as(as = "Bytes")]
cow_slice: Cow<'a, [u8]>,
#[serde_as(as = "Box<Bytes>")]
boxed_array: Box<[u8; 52]>,
#[serde_as(as = "Bytes")]
boxed_array2: Box<[u8; 52]>,
#[serde_as(as = "Bytes")]
boxed_slice: Box<[u8]>,
#[serde_as(as = "Option<Bytes>")]
opt_slice: Option<&'a [u8]>,
#[serde_as(as = "Option<Bytes>")]
opt_vec: Option<Vec<u8>>,
#[serde_as(as = "Option<Bytes>")]
opt_cow_slice: Option<Cow<'a, [u8]>>,
}
let test = Test {
array: *b"ABCDEFGHIJKLMNOPQRSTUVWXZYabcdefghijklmnopqrstuvwxyz",
slice: b"...",
vec: b"...".to_vec(),
cow_slice: Cow::Borrowed(b"..."),
boxed_array: Box::new(*b"ABCDEFGHIJKLMNOPQRSTUVWXZYabcdefghijklmnopqrstuvwxyz"),
boxed_array2: Box::new(*b"ABCDEFGHIJKLMNOPQRSTUVWXZYabcdefghijklmnopqrstuvwxyz"),
boxed_slice: b"...".to_vec().into_boxed_slice(),
opt_slice: Some(b"..."),
opt_vec: Some(b"...".to_vec()),
opt_cow_slice: Some(Cow::Borrowed(b"...")),
};
assert_tokens(
&test,
&[
Token::Struct {
name: "Test",
len: 10,
},
Token::Str("array"),
Token::BorrowedBytes(b"ABCDEFGHIJKLMNOPQRSTUVWXZYabcdefghijklmnopqrstuvwxyz"),
Token::Str("slice"),
Token::BorrowedBytes(b"..."),
Token::Str("vec"),
Token::Bytes(b"..."),
Token::Str("cow_slice"),
Token::BorrowedBytes(b"..."),
Token::Str("boxed_array"),
Token::BorrowedBytes(b"ABCDEFGHIJKLMNOPQRSTUVWXZYabcdefghijklmnopqrstuvwxyz"),
Token::Str("boxed_array2"),
Token::BorrowedBytes(b"ABCDEFGHIJKLMNOPQRSTUVWXZYabcdefghijklmnopqrstuvwxyz"),
Token::Str("boxed_slice"),
Token::Bytes(b"..."),
Token::Str("opt_slice"),
Token::Some,
Token::BorrowedBytes(b"..."),
Token::Str("opt_vec"),
Token::Some,
Token::Bytes(b"..."),
Token::Str("opt_cow_slice"),
Token::Some,
Token::BorrowedBytes(b"..."),
Token::StructEnd,
],
);
// Test string deserialization
assert_de_tokens(
&test,
&[
Token::Struct {
name: "Test",
len: 10,
},
Token::Str("array"),
Token::BorrowedStr("ABCDEFGHIJKLMNOPQRSTUVWXZYabcdefghijklmnopqrstuvwxyz"),
Token::Str("slice"),
Token::BorrowedStr("..."),
Token::Str("vec"),
Token::Bytes(b"..."),
Token::Str("cow_slice"),
Token::BorrowedStr("..."),
Token::Str("boxed_array"),
Token::BorrowedStr("ABCDEFGHIJKLMNOPQRSTUVWXZYabcdefghijklmnopqrstuvwxyz"),
Token::Str("boxed_array2"),
Token::BorrowedStr("ABCDEFGHIJKLMNOPQRSTUVWXZYabcdefghijklmnopqrstuvwxyz"),
Token::Str("boxed_slice"),
Token::Bytes(b"..."),
Token::Str("opt_slice"),
Token::Some,
Token::BorrowedStr("..."),
Token::Str("opt_vec"),
Token::Some,
Token::Bytes(b"..."),
Token::Str("opt_cow_slice"),
Token::Some,
Token::BorrowedStr("..."),
Token::StructEnd,
],
);
} | rust_cleaned_test_functions.jsonl/45735 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2243
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12524,
368,
341,
262,
442,
576,
1273,
1142,
374,
21774,
504,
7213,
14808,
262,
990,
61570,
4452,
22964,
2207,
2259,
28838,
11,
2060,
28838,
11,
9660,
2440,
262,
990,
61570,
6615,
486,
7078,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.