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_minting_enable_disable() {
let check_mnt_storage = |pool_id, speed, borrow_index, supply_index, block_number| {
assert_eq!(MntToken::mnt_speeds(pool_id), speed);
assert_eq!(
MntToken::mnt_pools_state(pool_id),
MntPoolState {
supply_state: MntState {
mnt_distribution_index: supply_index,
index_updated_at_block: block_number
},
borrow_state: MntState {
mnt_distribution_index: borrow_index,
index_updated_at_block: block_number
}
}
);
};
ExtBuilder::default()
.user_balance(ADMIN, MDOT, 100 * DOLLARS)
.pool_total_borrowed(DOT, 50 * DOLLARS)
.pool_total_borrowed(KSM, 50 * DOLLARS)
.mnt_account_balance(100 * DOLLARS)
.build()
.execute_with(|| {
// Try to disable minting for invalid underlying asset id
assert_noop!(
MntToken::set_speed(admin_origin(), MNT, Balance::zero()),
Error::<Runtime>::NotValidUnderlyingAssetId
);
// The dispatch origin of this call must be Root or 2/3 MinterestCouncil.
assert_noop!(MntToken::set_speed(alice_origin(), DOT, 1 * DOLLARS), BadOrigin);
// Unable to enable minting for non existing pool
assert_noop!(
MntToken::set_speed(admin_origin(), ETH, 2 * DOLLARS),
Error::<Runtime>::PoolNotFound
);
// Enable the distribution of MNT tokens in the DOT liquidity pool
let dot_speed = 2 * DOLLARS;
assert_ok!(MntToken::set_speed(admin_origin(), DOT, dot_speed));
let speed_changed_event = Event::MntToken(crate::Event::MntSpeedChanged(DOT, dot_speed));
assert!(System::events()
.iter()
.any(|record| record.event == speed_changed_event));
check_mnt_storage(DOT, dot_speed, Rate::one(), Rate::one(), 1);
System::set_block_number(5);
// Unable to disable an already disabled pool
assert_noop!(
MntToken::set_speed(admin_origin(), KSM, Balance::zero()),
Error::<Runtime>::MntMintingNotEnabled
);
// Enable the distribution of MNT tokens in the KSM liquidity pool
let ksm_speed = 2 * DOLLARS;
assert_ok!(MntToken::set_speed(admin_origin(), KSM, ksm_speed));
let speed_changed_event = Event::MntToken(crate::Event::MntSpeedChanged(KSM, ksm_speed));
assert!(System::events()
.iter()
.any(|record| record.event == speed_changed_event));
check_mnt_storage(KSM, ksm_speed, Rate::one(), Rate::one(), 5);
System::set_block_number(10);
// Disable the distribution of MNT tokens in the DOT liquidity pool
assert_ok!(MntToken::set_speed(admin_origin(), DOT, Balance::zero()));
let speed_changed_event = Event::MntToken(crate::Event::MntSpeedChanged(DOT, Balance::zero()));
assert!(System::events()
.iter()
.any(|record| record.event == speed_changed_event));
assert!(!crate::MntSpeeds::<Runtime>::contains_key(DOT));
check_mnt_storage(
DOT,
Balance::zero(),
Rate::from_inner(1_540000000000000000),
Rate::from_inner(1_180000000000000000),
10,
);
System::set_block_number(15);
assert_ok!(MntToken::update_mnt_supply_index(DOT));
assert_ok!(MntToken::update_mnt_borrow_index(DOT));
// Check that indices hadn't been updated while distribution is off
check_mnt_storage(
DOT,
Balance::zero(),
Rate::from_inner(1_540000000000000000),
Rate::from_inner(1_180000000000000000),
10,
);
System::set_block_number(20);
// Enable the distribution of MNT tokens in the DOT liquidity pool
// Check that the indexes have been saved and the block number has changed.
assert_ok!(MntToken::set_speed(admin_origin(), DOT, dot_speed));
check_mnt_storage(
DOT,
dot_speed,
Rate::from_inner(1_540000000000000000),
Rate::from_inner(1_180000000000000000),
20,
);
// Change the mnt_speed parameter for KSM liquidity pool.
// Check that the indexes have been updated and block number has changed.
assert_ok!(MntToken::set_speed(admin_origin(), KSM, ksm_speed + 1_u128));
check_mnt_storage(
KSM,
ksm_speed + 1_u128,
Rate::from_inner(1_900000000000000000),
Rate::from_inner(1_000000000000000000),
20,
);
});
} | rust_cleaned_test_functions.jsonl/115708 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1639
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
717,
396,
287,
18988,
33842,
368,
341,
10217,
1779,
717,
406,
23310,
284,
760,
10285,
842,
11,
4628,
11,
17193,
3560,
11,
8149,
3560,
11,
2504,
5500,
91,
341,
197,
6948,
10714,
10297,
44,
406,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_first_group() {
let test: Vec<u8> = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
let convert = string_to_cp437("☺☻♥♦♣♠•◘○◙♂♀♪♫☼");
assert_eq!(test, convert);
} | rust_cleaned_test_functions.jsonl/1075 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 137
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12978,
6288,
368,
341,
286,
1077,
1273,
25,
11312,
34837,
23,
29,
284,
7486,
20703,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11,
220,
21,
11,
220,
22,
11,
220,
23,
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_malformed_rule() {
let store = TestStore::new();
let mut flag = store.flag("flagWithMalformedRule").unwrap().clone();
let user_a = User::with_key("no").build();
let user_b = User::with_key("yes").build();
let detail = evaluate(&store, &flag, &user_a, None);
assert_that!(detail.value).contains_value(&Bool(false));
assert_that!(detail.reason).is_equal_to(Reason::Off);
let detail = evaluate(&store, &flag, &user_b, None);
assert_that!(detail.value).contains_value(&Bool(false));
assert_that!(detail.reason).is_equal_to(Reason::Off);
flag.on = true;
let detail = evaluate(&store, &flag, &user_a, None);
assert_that!(detail.value).contains_value(&Bool(true));
assert_that!(detail.reason).is_equal_to(Reason::Fallthrough {
in_experiment: false,
});
let detail = evaluate(&store, &flag, &user_b, None);
assert_that!(detail.value).is_none();
assert_that!(detail.reason).is_equal_to(Reason::Error {
error: Error::MalformedFlag,
});
} | rust_cleaned_test_functions.jsonl/133350 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 496
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
717,
278,
10155,
21124,
368,
341,
286,
1077,
3553,
284,
3393,
6093,
486,
931,
543,
286,
1077,
5206,
5181,
284,
3553,
41230,
445,
9903,
2354,
29600,
10155,
11337,
1827,
15454,
1005,
19982,
1428,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_debug_format() {
// long vowels
let og = Orthographia::try_from_ascii("i'nfa'ns").unwrap();
assert_eq!("\"i'nfa'ns\"", format!("{:?}", og));
let og = Orthographia::try_from_ascii("Ju'ppiter").unwrap();
assert_eq!("\"Ju'ppiter\"", format!("{:?}", og));
// semivowel j
let og = Orthographia::try_from_ascii("jam").unwrap();
assert_eq!("\"jam\"", format!("{:?}", og));
// semivowel v and vowel u
let og = Orthographia::try_from_ascii("ve'rum").unwrap();
assert_eq!("\"ve'rum\"", format!("{:?}", og));
// compound word
let og = Orthographia::try_from_ascii("duo-decim").unwrap();
assert_eq!("\"duo-decim\"", format!("{:?}", og));
// stem
let og = Orthographia::try_from_ascii("magn-").unwrap();
assert_eq!("\"magn-\"", format!("{:?}", og));
// suffix
let og = Orthographia::try_from_ascii("-que").unwrap();
assert_eq!("\"-que\"", format!("{:?}", og));
} | rust_cleaned_test_functions.jsonl/80421 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 453
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15446,
8955,
368,
341,
262,
442,
1293,
78456,
198,
262,
1077,
7350,
284,
31110,
3178,
685,
486,
1539,
5673,
50238,
445,
72,
43786,
3632,
6,
4412,
1827,
15454,
543,
262,
2060,
10714,
17223,
2105,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_program_bpf_upgrade_via_cpi() {
solana_logger::setup();
let GenesisConfigInfo {
genesis_config,
mint_keypair,
..
} = create_genesis_config(50);
let mut bank = Bank::new(&genesis_config);
let (name, id, entrypoint) = solana_bpf_loader_program!();
bank.add_builtin(&name, id, entrypoint);
let (name, id, entrypoint) = solana_bpf_loader_upgradeable_program!();
bank.add_builtin(&name, id, entrypoint);
let bank_client = BankClient::new(bank);
let invoke_and_return = load_bpf_program(
&bank_client,
&bpf_loader::id(),
&mint_keypair,
"solana_bpf_rust_invoke_and_return",
);
// Deploy upgradeable program
let buffer_keypair = Keypair::new();
let program_keypair = Keypair::new();
let program_id = program_keypair.pubkey();
let authority_keypair = Keypair::new();
load_upgradeable_bpf_program(
&bank_client,
&mint_keypair,
&buffer_keypair,
&program_keypair,
&authority_keypair,
"solana_bpf_rust_upgradeable",
);
let mut instruction = Instruction::new_with_bytes(
invoke_and_return,
&[0],
vec![
AccountMeta::new(program_id, false),
AccountMeta::new(program_id, false),
AccountMeta::new(clock::id(), false),
AccountMeta::new(fees::id(), false),
],
);
// Call the upgraded program
instruction.data[0] += 1;
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction.clone());
assert_eq!(
result.unwrap_err().unwrap(),
TransactionError::InstructionError(0, InstructionError::Custom(42))
);
// Load the buffer account
let path = create_bpf_path("solana_bpf_rust_upgraded");
let mut file = File::open(&path).unwrap_or_else(|err| {
panic!("Failed to open {}: {}", path.display(), err);
});
let mut elf = Vec::new();
file.read_to_end(&mut elf).unwrap();
let buffer_keypair = Keypair::new();
load_buffer_account(
&bank_client,
&mint_keypair,
&buffer_keypair,
&authority_keypair,
&elf,
);
// Upgrade program via CPI
let mut upgrade_instruction = bpf_loader_upgradeable::upgrade(
&program_id,
&buffer_keypair.pubkey(),
&authority_keypair.pubkey(),
&mint_keypair.pubkey(),
);
upgrade_instruction.program_id = invoke_and_return;
upgrade_instruction
.accounts
.insert(0, AccountMeta::new(bpf_loader_upgradeable::id(), false));
let message = Message::new(&[upgrade_instruction], Some(&mint_keypair.pubkey()));
bank_client
.send_and_confirm_message(&[&mint_keypair, &authority_keypair], message)
.unwrap();
// Call the upgraded program
instruction.data[0] += 1;
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction.clone());
assert_eq!(
result.unwrap_err().unwrap(),
TransactionError::InstructionError(0, InstructionError::Custom(43))
);
} | rust_cleaned_test_functions.jsonl/11461 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1340
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25096,
880,
15897,
67794,
80710,
666,
2493,
368,
341,
262,
2048,
3362,
27413,
486,
15188,
1428,
262,
1077,
40788,
2648,
1731,
341,
286,
59366,
5332,
345,
286,
28337,
3097,
12670,
345,
286,
54538,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_update() {
for b in IPV4_HEADERS {
let mut buf = Vec::new();
buf.extend_from_slice(b);
let mut c = Checksum::new();
c.add_bytes(&buf);
assert_eq!(c.checksum(), 0);
// replace the destination IP with the loopback address
let old = [buf[16], buf[17], buf[18], buf[19]];
(&mut buf[16..20]).copy_from_slice(&[127, 0, 0, 1]);
let updated = Checksum::update(c.checksum(), &old, &[127, 0, 0, 1]);
let from_scratch = {
let mut c = Checksum::new();
c.add_bytes(&buf);
c.checksum()
};
assert_eq!(updated, from_scratch);
}
} | rust_cleaned_test_functions.jsonl/15732 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 483
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8882,
368,
341,
310,
369,
293,
304,
91498,
19,
79428,
341,
394,
1077,
5206,
6607,
284,
11312,
486,
931,
543,
394,
6607,
15831,
5673,
26488,
1883,
626,
394,
1077,
5206,
272,
284,
4248,
1242,
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_create_from_account_is_nonce_fail() {
let nonce = Pubkey::new_unique();
let nonce_account = AccountSharedData::new_data(
42,
&nonce::state::Versions::new_current(nonce::State::Initialized(
nonce::state::Data::default(),
)),
&system_program::id(),
)
.unwrap();
let new = Pubkey::new_unique();
let new_account = AccountSharedData::new(0, 0, &system_program::id());
process_instruction(
&bincode::serialize(&SystemInstruction::CreateAccount {
lamports: 42,
space: 0,
owner: Pubkey::new_unique(),
})
.unwrap(),
vec![(nonce, nonce_account), (new, new_account)],
vec![
AccountMeta {
pubkey: nonce,
is_signer: true,
is_writable: false,
},
AccountMeta {
pubkey: new,
is_signer: true,
is_writable: false,
},
],
Err(InstructionError::InvalidArgument),
super::process_instruction,
);
} | rust_cleaned_test_functions.jsonl/95880 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 724
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8657,
5673,
13500,
6892,
48508,
22121,
368,
341,
286,
1077,
39676,
284,
22611,
792,
486,
931,
21218,
543,
286,
1077,
39676,
13500,
284,
8615,
16997,
1043,
486,
931,
1769,
1006,
310,
220,
19,
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_delete_user() {
run_test(|url, client| {
let login =
create_and_authorize_user(url, &client, "test_delete_user@gmail.com", "Admin2193!");
let user_to_delete = create_and_authorize_user(
url,
&client,
"test_delete_user_2@gmail.com",
"Admin2193!",
);
let get_user_response = client
.get(&format!("{}/biome/users/{}", url, user_to_delete.user_id))
.header("Authorization", format!("Bearer {}", login.token))
.send()
.unwrap();
assert_eq!(get_user_response.status().as_u16(), 200);
assert_eq!(
client
.delete(&format!("{}/biome/users/{}", url, user_to_delete.user_id))
.header("Authorization", format!("Bearer {}", user_to_delete.token))
.send()
.unwrap()
.status()
.as_u16(),
200
);
assert_eq!(
client
.get(&format!("{}/biome/users/{}", url, user_to_delete.user_id))
.header("Authorization", format!("Bearer {}", login.token))
.send()
.unwrap()
.status()
.as_u16(),
404
);
})
} | rust_cleaned_test_functions.jsonl/32290 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 906
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11353,
3317,
368,
341,
286,
1598,
4452,
22428,
1085,
11,
2943,
91,
341,
310,
1077,
5858,
4035,
394,
1855,
8378,
22938,
551,
3317,
6522,
11,
609,
2972,
11,
330,
1944,
11353,
3317,
10375,
905,
497... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_permissions_net_listen_allow_deno_land() {
let (_, err) = util::run_and_collect_output(
false,
"run --allow-net=deno.land complex_permissions_test.ts netListen localhost:4545",
None,
None,
false,
);
assert!(err.contains(util::PERMISSION_DENIED_PATTERN));
} | rust_cleaned_test_functions.jsonl/5608 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 132
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
44767,
19722,
79286,
55731,
814,
11790,
60506,
368,
341,
220,
1077,
39464,
1848,
8,
284,
4094,
486,
6108,
8378,
68140,
7645,
1006,
262,
895,
345,
298,
197,
1,
6108,
1177,
7183,
66496,
28,
5183,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_protocol_from_str() {
assert!(parse_proto!("Cons").is_ok());
assert!(parse_proto!("123").is_ok());
assert!(parse_proto!("1-2-3").is_ok());
let err = Err(ProtoverError::InvalidProtocol);
assert_eq!(err, parse_proto!("a_b_c"));
assert_eq!(err, parse_proto!("a b"));
assert_eq!(err, parse_proto!("a,"));
assert_eq!(err, parse_proto!("b."));
assert_eq!(err, parse_proto!("é"));
} | rust_cleaned_test_functions.jsonl/5143 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 249
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34880,
5673,
2895,
368,
341,
286,
2060,
10297,
6400,
37689,
17223,
15220,
1827,
285,
19817,
1423,
286,
2060,
10297,
6400,
37689,
17223,
16,
17,
18,
1827,
285,
19817,
1423,
286,
2060,
10297,
6400,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_from_into_ext() {
let a = fidl::Ipv4Address { addr: [0; 4] };
assert_eq!(fidl::IpAddress::Ipv4(a), a.into_ext());
let a = fidl::Ipv6Address { addr: [0; 16] };
assert_eq!(fidl::IpAddress::Ipv6(a), a.into_ext());
let a = fidl::Ipv4SocketAddress { address: fidl::Ipv4Address { addr: [0; 4] }, port: 1 };
assert_eq!(fidl::SocketAddress::Ipv4(a), a.into_ext());
let a = fidl::Ipv6SocketAddress {
address: fidl::Ipv6Address { addr: [0; 16] },
port: 1,
zone_index: 2,
};
assert_eq!(fidl::SocketAddress::Ipv6(a), a.into_ext());
} | rust_cleaned_test_functions.jsonl/56507 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 355
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5673,
45514,
9927,
368,
341,
286,
1077,
264,
284,
32104,
75,
486,
80656,
19,
4286,
314,
10789,
25,
508,
15,
26,
220,
19,
60,
2605,
286,
2060,
10714,
10297,
32439,
75,
486,
98567,
486,
80656,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_encoding() {
assert_eq!(
Name::from_ascii("WWW.example.COM.").unwrap().to_ascii(),
"WWW.example.COM."
);
assert_eq!(
Name::from_utf8("WWW.example.COM.").unwrap().to_ascii(),
"www.example.com."
);
assert_eq!(
Name::from_ascii("WWW.example.COM.").unwrap().to_utf8(),
"WWW.example.COM."
);
} | rust_cleaned_test_functions.jsonl/38223 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 257
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
37613,
368,
341,
286,
2060,
10714,
33673,
310,
3988,
486,
1499,
50238,
445,
45508,
7724,
20851,
98401,
15454,
1005,
983,
50238,
3148,
310,
330,
45508,
7724,
20851,
10040,
286,
1439,
286,
2060,
10714... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_from_iec_i() {
new_ucmd!()
.args(&["--from=iec-i"])
.pipe_in("1.1Mi\n0.1Gi")
.run()
.stdout_is("1153434\n107374183\n");
} | rust_cleaned_test_functions.jsonl/45986 | {
"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,
5673,
62203,
66,
5318,
368,
341,
262,
501,
68887,
2277,
0,
741,
286,
659,
2116,
2099,
1183,
313,
1499,
28,
66492,
17600,
14108,
286,
659,
13768,
1243,
445,
16,
13,
16,
41887,
1699,
15,
13,
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_permissions_rw_no_prefix() {
const PERMISSION_VARIANTS: [&str; 2] = ["read", "write"];
for permission in &PERMISSION_VARIANTS {
let status = util::deno_cmd()
.current_dir(&util::tests_path())
.arg("run")
.arg(format!("--allow-{0}=tls/../", permission))
.arg("complex_permissions_test.ts")
.arg(permission)
.arg("complex_permissions_test.ts")
.spawn()
.unwrap()
.wait()
.unwrap();
assert!(status.success());
}
} | rust_cleaned_test_functions.jsonl/5598 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 234
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
44767,
49566,
6536,
13974,
368,
341,
220,
733,
96540,
2334,
16028,
37125,
25,
34336,
495,
26,
220,
17,
60,
284,
4383,
878,
497,
330,
4934,
6332,
220,
369,
7882,
304,
609,
9654,
25245,
2334,
1602... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_load_zone() {
let config = FileConfig {
zone_file_path: "../../tests/test-data/named_test_configs/example.com.zone".to_string(),
};
let authority = FileAuthority::try_from_config(
Name::from_str("example.com.").unwrap(),
ZoneType::Primary,
false,
None,
&config,
)
.expect("failed to load file");
let lookup = block_on(Authority::lookup(
&authority,
&LowerName::from_str("www.example.com.").unwrap(),
RecordType::A,
LookupOptions::default(),
))
.expect("lookup failed");
match lookup
.into_iter()
.next()
.expect("A record not found in authity")
.rdata()
{
RData::A(ip) => assert_eq!(Ipv4Addr::new(127, 0, 0, 1), *ip),
_ => panic!("wrong rdata type returned"),
}
let include_lookup = block_on(Authority::lookup(
&authority,
&LowerName::from_str("include.alias.example.com.").unwrap(),
RecordType::A,
LookupOptions::default(),
))
.expect("INCLUDE lookup failed");
match include_lookup
.into_iter()
.next()
.expect("A record not found in authity")
.rdata()
{
RData::A(ip) => assert_eq!(Ipv4Addr::new(127, 0, 0, 5), *ip),
_ => panic!("wrong rdata type returned"),
}
} | rust_cleaned_test_functions.jsonl/129328 | {
"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,
12411,
28692,
368,
341,
286,
1077,
2193,
284,
2887,
2648,
341,
310,
10143,
2458,
2638,
25,
10208,
23841,
12697,
13945,
9612,
3606,
4452,
59150,
65182,
905,
57808,
3263,
983,
3904,
3148,
286,
2605,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_ecdsa_adaptor_signature_encrypt_with_aux_rand() {
test_ecdsa_adaptor_signature_helper(|msg, sk, adaptor, rng| {
let mut aux_rand = [0; 32];
rng.fill_bytes(&mut aux_rand);
EcdsaAdaptorSignature::encrypt_with_aux_rand(&SECP256K1, msg, sk, adaptor, &aux_rand)
})
} | rust_cleaned_test_functions.jsonl/62232 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 177
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36844,
96780,
10027,
32657,
39859,
66593,
6615,
30468,
33864,
368,
341,
286,
1273,
36844,
96780,
10027,
32657,
39859,
10418,
22428,
3236,
11,
1901,
11,
91941,
11,
28422,
91,
341,
310,
1077,
5206,
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_context() {
let tests = vec![
TestItem {
name: "OXIDE_PAGER env".to_string(),
oxide_pager_env: "more".to_string(),
oxide_force_tty_env: "".to_string(),
prompt: "".to_string(),
pager: "".to_string(),
want_pager: "more".to_string(),
want_prompt: "enabled".to_string(),
want_terminal_width_override: 0,
},
TestItem {
name: "OXIDE_PAGER env override".to_string(),
oxide_pager_env: "more".to_string(),
oxide_force_tty_env: "".to_string(),
prompt: "".to_string(),
pager: "less".to_string(),
want_pager: "more".to_string(),
want_prompt: "enabled".to_string(),
want_terminal_width_override: 0,
},
TestItem {
name: "config pager".to_string(),
oxide_pager_env: "".to_string(),
oxide_force_tty_env: "".to_string(),
prompt: "".to_string(),
pager: "less".to_string(),
want_pager: "less".to_string(),
want_prompt: "enabled".to_string(),
want_terminal_width_override: 0,
},
TestItem {
name: "config prompt".to_string(),
oxide_pager_env: "".to_string(),
oxide_force_tty_env: "".to_string(),
prompt: "disabled".to_string(),
pager: "less".to_string(),
want_pager: "less".to_string(),
want_prompt: "disabled".to_string(),
want_terminal_width_override: 0,
},
TestItem {
name: "OXIDE_FORCE_TTY env".to_string(),
oxide_pager_env: "".to_string(),
oxide_force_tty_env: "120".to_string(),
prompt: "disabled".to_string(),
pager: "less".to_string(),
want_pager: "less".to_string(),
want_prompt: "disabled".to_string(),
want_terminal_width_override: 120,
},
];
for t in tests {
let mut config = crate::config::new_blank_config().unwrap();
let mut c = crate::config_from_env::EnvConfig::inherit_env(&mut config);
if !t.pager.is_empty() {
c.set("", "pager", &t.pager).unwrap();
}
if !t.prompt.is_empty() {
c.set("", "prompt", &t.prompt).unwrap();
}
if !t.oxide_pager_env.is_empty() {
std::env::set_var("OXIDE_PAGER", t.oxide_pager_env.clone());
} else {
std::env::remove_var("OXIDE_PAGER");
}
if !t.oxide_force_tty_env.is_empty() {
std::env::set_var("OXIDE_FORCE_TTY", t.oxide_force_tty_env.clone());
} else {
std::env::remove_var("OXIDE_FORCE_TTY");
}
let ctx = Context::new(&mut c);
assert_eq!(ctx.io.get_pager(), t.want_pager, "test: {}", t.name);
assert_eq!(
ctx.io.get_never_prompt(),
t.want_prompt == "disabled",
"test {}",
t.name
);
assert_eq!(ctx.config.get("", "pager").unwrap(), t.want_pager, "test: {}", t.name);
assert_eq!(ctx.config.get("", "prompt").unwrap(), t.want_prompt, "test: {}", t.name);
if t.want_terminal_width_override > 0 {
assert_eq!(
ctx.io.terminal_width(),
t.want_terminal_width_override,
"test: {}",
t.name
);
}
}
} | rust_cleaned_test_functions.jsonl/76859 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2263
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8467,
368,
341,
286,
1077,
7032,
284,
7486,
90515,
310,
3393,
1234,
341,
394,
829,
25,
330,
60155,
12146,
1088,
27650,
6105,
3263,
983,
3904,
3148,
394,
50080,
620,
1409,
15879,
25,
330,
6384,
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... | 7 |
#[test]
fn test_optimize_switch_with_labelless_break() {
test(
concat!(
"function f() {",
" switch('x') {",
" case 'x': var x = 1; break;",
" case 'y': break;",
" }",
"}",
),
"function f() { var x = 1; }",
);
test_same(concat!(
"function f() {",
" switch(x) {",
" case 'y': break;",
" default: var x = 1;",
" }",
"}",
));
test(
concat!(
"var exit;",
"switch ('a') {",
" case 'a':",
" break;",
" default:",
" exit = 21;",
" break;",
"}",
"switch(exit) {",
" case 21: throw 'x';",
" default : console.log('good');",
"}",
),
concat!(
"var exit;",
"switch(exit) {",
" case 21: throw 'x';",
" default : console.log('good');",
"}",
),
);
test(
concat!(
"let x = 1;",
"switch('x') {",
" case 'x': let x = 2; break;",
"}",
),
concat!("let x = 1;", "{let x = 2}"),
);
} | rust_cleaned_test_functions.jsonl/396 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 826
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15032,
11853,
27652,
6615,
6106,
1717,
39494,
368,
341,
262,
1273,
1006,
286,
33720,
33673,
310,
330,
1688,
282,
368,
314,
756,
310,
330,
220,
3398,
492,
87,
863,
314,
756,
310,
330,
262,
1142,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_replace_in_mem_leaf() {
let key = b"hello".test_only_hash();
let value_hash = b"world".test_only_hash();
let leaf = SubTree::new_leaf_with_value_hash(key, value_hash, 0 /* generation */);
let smt = SparseMerkleTree::new_with_root(leaf);
let new_value: StateValue = vec![1, 2, 3].into();
let root_hash = hash_leaf(key, new_value.hash());
let updated = smt
.batch_update(vec![(key, &new_value)], &ProofReader::default())
.unwrap();
assert_eq!(updated.root_hash(), root_hash);
} | rust_cleaned_test_functions.jsonl/63251 | {
"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,
10633,
1243,
12976,
38909,
368,
341,
262,
1077,
1376,
284,
293,
1,
14990,
3263,
1944,
18410,
8950,
543,
262,
1077,
897,
8950,
284,
293,
1,
14615,
3263,
1944,
18410,
8950,
543,
262,
1077,
15933,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ecdsa_update_quadruples_in_creation() {
let num_of_nodes = 4;
let subnet_id = subnet_test_id(1);
let env = CanisterThresholdSigTestEnvironment::new(num_of_nodes);
let registry_version = env.newest_registry_version;
let subnet_nodes = env.receivers().into_iter().collect::<Vec<_>>();
let algorithm = AlgorithmId::ThresholdEcdsaSecp256k1;
let mut block_reader = TestEcdsaBlockReader::new();
let key_transcript = generate_key_transcript(&env, algorithm);
let key_transcript_ref =
ecdsa::UnmaskedTranscript::try_from((Height::new(100), &key_transcript)).unwrap();
block_reader.add_transcript(*key_transcript_ref.as_ref(), key_transcript);
let mut payload = empty_ecdsa_data_payload(subnet_id);
let mut completed = BTreeMap::new();
// Start quadruple creation
let kappa_config_id = payload.next_unused_transcript_id;
let kappa_config_ref = new_random_config(
&subnet_nodes,
registry_version,
&mut payload.next_unused_transcript_id,
)
.unwrap();
let lambda_config_id = payload.next_unused_transcript_id;
let lambda_config_ref = new_random_config(
&subnet_nodes,
registry_version,
&mut payload.next_unused_transcript_id,
)
.unwrap();
let quadruple_id = ecdsa::QuadrupleId(0);
payload.quadruples_in_creation.insert(
quadruple_id,
ecdsa::QuadrupleInCreation::new(kappa_config_ref.clone(), lambda_config_ref.clone()),
);
// 1. No action case
let cur_height = Height::new(1000);
let result = update_quadruples_in_creation(
&key_transcript_ref,
&mut payload,
&mut completed,
cur_height,
no_op_logger(),
);
assert!(result.unwrap().is_empty());
let config_ids = |payload: &ecdsa::EcdsaDataPayload| {
let mut arr = payload
.iter_transcript_configs_in_creation()
.map(|x| x.transcript_id.id())
.collect::<Vec<_>>();
arr.sort_unstable();
arr
};
// check if nothing has changed
assert!(payload.available_quadruples.is_empty());
assert_eq!(payload.next_unused_transcript_id.id(), 2);
assert_eq!(payload.iter_transcript_configs_in_creation().count(), 2);
assert_eq!(config_ids(&payload), [0, 1]);
let kappa_transcript = {
let param = kappa_config_ref.as_ref();
run_idkg_and_create_transcript(
¶m.translate(&block_reader).unwrap(),
&env.crypto_components,
)
};
completed.insert(kappa_config_id, kappa_transcript);
let cur_height = Height::new(2000);
let result = update_quadruples_in_creation(
&key_transcript_ref,
&mut payload,
&mut completed,
cur_height,
no_op_logger(),
)
.unwrap();
assert_eq!(result.len(), 1);
for completed_transcript in result {
block_reader.add_transcript(
ecdsa::TranscriptRef::new(cur_height, completed_transcript.transcript_id),
completed_transcript,
);
}
// check if new config is made
assert!(payload.available_quadruples.is_empty());
let kappa_unmasked_config_id = IDkgTranscriptId::new(subnet_id, 2);
assert_eq!(payload.next_unused_transcript_id.id(), 3);
assert_eq!(config_ids(&payload), [1, 2]);
let lambda_transcript = {
let param = lambda_config_ref.as_ref();
run_idkg_and_create_transcript(
¶m.translate(&block_reader).unwrap(),
&env.crypto_components,
)
};
completed.insert(lambda_config_id, lambda_transcript);
let cur_height = Height::new(3000);
let result = update_quadruples_in_creation(
&key_transcript_ref,
&mut payload,
&mut completed,
cur_height,
no_op_logger(),
)
.unwrap();
assert_eq!(result.len(), 1);
for completed_transcript in result {
block_reader.add_transcript(
ecdsa::TranscriptRef::new(cur_height, completed_transcript.transcript_id),
completed_transcript,
);
}
// check if new config is made
assert!(payload.available_quadruples.is_empty());
assert_eq!(payload.next_unused_transcript_id.id(), 4);
let key_times_lambda_config_id = IDkgTranscriptId::new(subnet_id, 3);
assert_eq!(config_ids(&payload), [2, 3]);
// config.
let kappa_unmasked_transcript = {
let param = payload
.iter_transcript_configs_in_creation()
.find(|x| x.transcript_id == kappa_unmasked_config_id)
.unwrap()
.clone();
run_idkg_and_create_transcript(
¶m.translate(&block_reader).unwrap(),
&env.crypto_components,
)
};
completed.insert(kappa_unmasked_config_id, kappa_unmasked_transcript);
let cur_height = Height::new(4000);
let result = update_quadruples_in_creation(
&key_transcript_ref,
&mut payload,
&mut completed,
cur_height,
no_op_logger(),
)
.unwrap();
assert_eq!(result.len(), 1);
for completed_transcript in result {
block_reader.add_transcript(
ecdsa::TranscriptRef::new(cur_height, completed_transcript.transcript_id),
completed_transcript,
);
}
// check if new config is made
assert!(payload.available_quadruples.is_empty());
assert_eq!(payload.next_unused_transcript_id.id(), 5);
let kappa_times_lambda_config_id = IDkgTranscriptId::new(subnet_id, 4);
assert_eq!(config_ids(&payload), [3, 4]);
// complete.
let kappa_times_lambda_transcript = {
let param = payload
.iter_transcript_configs_in_creation()
.find(|x| x.transcript_id == kappa_times_lambda_config_id)
.unwrap()
.clone();
run_idkg_and_create_transcript(
¶m.translate(&block_reader).unwrap(),
&env.crypto_components,
)
};
completed.insert(kappa_times_lambda_config_id, kappa_times_lambda_transcript);
let key_times_lambda_transcript = {
let param = payload
.iter_transcript_configs_in_creation()
.find(|x| x.transcript_id == key_times_lambda_config_id)
.unwrap()
.clone();
run_idkg_and_create_transcript(
¶m.translate(&block_reader).unwrap(),
&env.crypto_components,
)
};
completed.insert(key_times_lambda_config_id, key_times_lambda_transcript);
let cur_height = Height::new(5000);
let result = update_quadruples_in_creation(
&key_transcript_ref,
&mut payload,
&mut completed,
cur_height,
no_op_logger(),
)
.unwrap();
assert_eq!(result.len(), 2);
// check if new config is made
assert_eq!(payload.available_quadruples.len(), 1);
assert_eq!(payload.next_unused_transcript_id.id(), 5);
assert!(config_ids(&payload).is_empty());
} | rust_cleaned_test_functions.jsonl/113084 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 3955
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36844,
96780,
8882,
11280,
14666,
28323,
1243,
46163,
368,
341,
286,
1077,
1629,
3575,
14896,
284,
220,
19,
280,
286,
1077,
51457,
842,
284,
51457,
4452,
842,
7,
16,
317,
286,
1077,
6105,
284,
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... | 4 |
#[test]
fn test_is_finalized() {
let bank = Arc::new(Bank::default_for_tests());
let ledger_path = get_tmp_ledger_path!();
let blockstore = Arc::new(Blockstore::open(&ledger_path).unwrap());
blockstore.set_roots(vec![0, 1].iter()).unwrap();
// Build BlockCommitmentCache with rooted slots
let mut cache0 = BlockCommitment::default();
cache0.increase_rooted_stake(50);
let mut cache1 = BlockCommitment::default();
cache1.increase_rooted_stake(40);
let mut cache2 = BlockCommitment::default();
cache2.increase_rooted_stake(20);
let mut block_commitment = HashMap::new();
block_commitment.entry(1).or_insert(cache0);
block_commitment.entry(2).or_insert(cache1);
block_commitment.entry(3).or_insert(cache2);
let highest_confirmed_root = 1;
let block_commitment_cache = BlockCommitmentCache::new(
block_commitment,
50,
CommitmentSlots {
slot: bank.slot(),
highest_confirmed_root,
..CommitmentSlots::default()
},
);
assert!(is_finalized(&block_commitment_cache, &bank, &blockstore, 0));
assert!(is_finalized(&block_commitment_cache, &bank, &blockstore, 1));
assert!(!is_finalized(
&block_commitment_cache,
&bank,
&blockstore,
2
));
assert!(!is_finalized(
&block_commitment_cache,
&bank,
&blockstore,
3
));
} | rust_cleaned_test_functions.jsonl/6335 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 788
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6892,
20676,
1506,
368,
341,
286,
1077,
6073,
284,
19689,
486,
931,
5349,
1180,
486,
2258,
5478,
32509,
1423,
286,
1077,
46933,
2638,
284,
633,
16125,
38367,
1389,
2638,
0,
543,
286,
1077,
2504,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_seckey_from_bytes_n() {
let mut bytes = [0; 32];
Int256::N.to_bin(&mut bytes);
let sk = SecKey::from_bytes(&bytes);
assert!(sk.is_none());
} | rust_cleaned_test_functions.jsonl/81721 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 103
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3453,
377,
1195,
5673,
12524,
1089,
368,
341,
286,
1077,
5206,
5820,
284,
508,
15,
26,
220,
18,
17,
935,
286,
1333,
17,
20,
21,
486,
45,
2389,
21816,
2099,
6984,
5820,
317,
286,
1077,
1901,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_f32() {
assert_eq!(decode_f32(0b0000_0000_0000_0000_0000_0000_0000_0000), 0f32);
assert_eq!(decode_f32(0b0111_1111_0000_0000_0000_0000_0000_0001), -1f32);
assert_eq!(decode_f32(0b1000_0000_0000_0000_0000_0000_0000_0000), 2f32);
} | rust_cleaned_test_functions.jsonl/47633 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 151
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15227,
761,
18,
17,
368,
341,
286,
2060,
10714,
10297,
18196,
761,
18,
17,
7,
15,
65,
15,
15,
15,
15,
62,
15,
15,
15,
15,
62,
15,
15,
15,
15,
62,
15,
15,
15,
15,
62,
15,
15,
15,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_wire_intersections_with_steps() {
// example 1
let w1: Wire = "R8,U5,L5,D3".parse().unwrap();
let w2: Wire = "U7,R6,D4,L4".parse().unwrap();
let steps = w1
.steps_to_intersections_with(&w2)
.min_by_key(|(steps, _)| *steps)
.unwrap();
assert_eq!(steps.0, 30);
// example 2
let w1: Wire = "R75,D30,R83,U83,L12,D49,R71,U7,L72".parse().unwrap();
let w2: Wire = "U62,R66,U55,R34,D71,R55,D58,R83".parse().unwrap();
let steps = w1
.steps_to_intersections_with(&w2)
.min_by_key(|(steps, _)| *steps)
.unwrap();
assert_eq!(steps.0, 610);
// example 3
let w1: Wire = "R98,U47,R26,D63,R33,U87,L62,D20,R33,U53,R51"
.parse()
.unwrap();
let w2: Wire = "U98,R91,D20,R16,D67,R40,U7,R15,U6,R7".parse().unwrap();
let steps = w1
.steps_to_intersections_with(&w2)
.min_by_key(|(steps, _)| *steps)
.unwrap();
assert_eq!(steps.0, 410);
} | rust_cleaned_test_functions.jsonl/106449 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 649
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
75206,
15318,
24661,
6615,
22731,
368,
341,
286,
442,
3110,
220,
16,
198,
286,
1077,
289,
16,
25,
19378,
284,
330,
49,
23,
50481,
20,
30114,
20,
27266,
18,
3263,
6400,
1005,
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... | 1 |
#[test]
fn test_read_sample_data() {
let mut i2cdev = MockI2CDevice::new();
i2cdev.write(&[0, 127, 128, 191, 129, 144, 71]).unwrap();
let mut dev = Nunchuck::new(i2cdev).unwrap();
let reading = dev.read().unwrap();
assert_eq!(reading.joystick_x, 127);
assert_eq!(reading.joystick_y, 128);
assert_eq!(reading.accel_x, 765);
assert_eq!(reading.accel_y, 516);
assert_eq!(reading.accel_z, 577);
assert_eq!(reading.c_button_pressed, false);
assert_eq!(reading.z_button_pressed, false);
} | rust_cleaned_test_functions.jsonl/100756 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 286
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
17491,
1769,
368,
341,
286,
1077,
5206,
600,
17,
66,
3583,
284,
14563,
40,
17,
34,
6985,
486,
931,
543,
286,
600,
17,
66,
3583,
3836,
2099,
58,
15,
11,
220,
16,
17,
22,
11,
220,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_empty_array() {
let data = [0xe1, 0x00, 0x01, 0x00, 0x03, 0x00, 0x04, 0x00];
assert_eq!(
parse(&data[..]).unwrap().token_tape,
vec![
BinaryToken::Token(0x00e1),
BinaryToken::Array(2),
BinaryToken::End(1),
]
);
} | rust_cleaned_test_functions.jsonl/109418 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 217
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15124,
3858,
368,
341,
286,
1077,
821,
284,
508,
15,
8371,
16,
11,
220,
15,
87,
15,
15,
11,
220,
15,
87,
15,
16,
11,
220,
15,
87,
15,
15,
11,
220,
15,
87,
15,
18,
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 |
#[test]
fn test_prepare_with_commit_message() {
let mut schema_builder = schema::Schema::builder();
let text_field = schema_builder.add_text_field("text", schema::TEXT);
let index = Index::create_in_ram(schema_builder.build());
{
// writing the segment
let mut index_writer = index.writer(12_000_000).unwrap();
// create 8 segments with 100 tiny docs
for _doc in 0..100 {
index_writer.add_document(doc!(text_field => "a"));
}
{
let mut prepared_commit = index_writer.prepare_commit().expect("commit failed");
prepared_commit.set_payload("first commit");
prepared_commit.commit().expect("commit failed");
}
{
let metas = index.load_metas().unwrap();
assert_eq!(metas.payload.unwrap(), "first commit");
}
for _doc in 0..100 {
index_writer.add_document(doc!(text_field => "a"));
}
index_writer.commit().unwrap();
{
let metas = index.load_metas().unwrap();
assert!(metas.payload.is_none());
}
}
} | rust_cleaned_test_functions.jsonl/58888 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 641
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
47460,
6615,
36346,
6462,
368,
341,
286,
1077,
5206,
10802,
28532,
284,
10802,
486,
8632,
486,
17850,
543,
286,
1077,
1467,
5013,
284,
10802,
28532,
1364,
4326,
5013,
445,
1318,
497,
10802,
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... | 3 |
#[test]
fn test_convert() {
assert_eq!(Angle::<f32>::n_pi(1.0).to_degrees().value(), 180.0f32);
assert_eq!(Angle::<f32>::degrees(90.0).to_radians().value(), std::f32::consts::PI * 0.5);
assert_eq!(Angle::<f32>::n_pi(2.0).to_degrees().value(), Angle::<f32>::n_pi(2.0).degrees_value());
assert_eq!(Angle::<f32>::degrees(180.0).to_radians().value(), Angle::<f32>::degrees(180.0).radians_value());
} | rust_cleaned_test_functions.jsonl/7221 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 224
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34910,
368,
341,
286,
2060,
10714,
10297,
15939,
27638,
69,
18,
17,
6831,
77,
47771,
7,
16,
13,
15,
568,
983,
46057,
7858,
1005,
957,
1507,
220,
16,
23,
15,
13,
15,
69,
18,
17,
317,
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_crypto_core_salsa2012_inputbytes() {
assert!(
unsafe { crypto_core_salsa2012_inputbytes() } == crypto_core_salsa2012_INPUTBYTES as usize
)
} | rust_cleaned_test_functions.jsonl/108140 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 80
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
78298,
15467,
643,
41826,
17,
15,
16,
17,
5898,
9651,
368,
341,
262,
2060,
33673,
286,
19860,
314,
19028,
15467,
643,
41826,
17,
15,
16,
17,
5898,
9651,
368,
335,
621,
19028,
15467,
643,
41826,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_serde_de_array() -> Result<(), Box<EvalAltResult>> {
let arr: Vec<INT> = vec![123, 456, 42, 999];
assert_eq!(arr, from_dynamic::<Vec<INT>>(&arr.clone().into())?);
Ok(())
} | rust_cleaned_test_functions.jsonl/97334 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 97
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
75861,
450,
2259,
3858,
368,
1464,
5714,
68843,
8261,
23835,
831,
26017,
2077,
2452,
341,
262,
1077,
2890,
25,
11312,
27,
3221,
29,
284,
7486,
20703,
16,
17,
18,
11,
220,
19,
20,
21,
11,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_draw_help_popup() {
let test_case = |expected: &Buffer| {
let mut app = TTApp::new().unwrap();
app.mode = AppMode::TaskHelpPopup;
app.task_report_next();
app.context_next();
app.update(true).unwrap();
let backend = TestBackend::new(40, 12);
let mut terminal = Terminal::new(backend).unwrap();
terminal
.draw(|f| {
app.draw_help_popup(f, 100, 100);
})
.unwrap();
assert_eq!(terminal.backend().size().unwrap(), expected.area);
terminal.backend().assert_buffer(expected);
};
let mut expected = Buffer::with_lines(vec![
"╭Help──────────────────────────────────╮",
"│Keybindings: │",
"│ │",
"│ Esc: │",
"│ │",
"│ ]: Next view │",
"│ │",
"│ [: Previous view │",
"│ │",
"│ │",
"│Keybindings for task report: │",
"╰──────────────────────────────────────╯",
]);
for i in 1..=4 {
// Calendar
expected
.get_mut(i, 0)
.set_style(Style::default().add_modifier(Modifier::BOLD));
}
test_case(&expected);
} | rust_cleaned_test_functions.jsonl/45047 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1069
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
23021,
26926,
44984,
368,
341,
286,
1077,
1273,
19096,
284,
760,
7325,
25,
609,
4095,
91,
341,
310,
1077,
5206,
906,
284,
32744,
2164,
486,
931,
1005,
15454,
1428,
310,
906,
22981,
284,
1845,
36... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_binomial() {
let expected: &[Box<[usize]>] = &[
Box::new([1, 0, 0, 0, 0, 0]),
Box::new([1, 1, 0, 0, 0, 0]),
Box::new([1, 2, 1, 0, 0, 0]),
Box::new([1, 3, 3, 1, 0, 0]),
Box::new([1, 4, 6, 4, 1, 0]),
Box::new([1, 5, 10, 10, 5, 1]),
Box::new([1, 6, 15, 20, 15, 6]),
Box::new([1, 7, 21, 35, 35, 21]),
Box::new([1, 8, 28, 56, 70, 56]),
Box::new([1, 9, 36, 84, 126, 126]),
Box::new([1, 10, 45, 120, 210, 252]),
];
assert_eq!(*make_binomial(10, 5), *expected);
} | rust_cleaned_test_functions.jsonl/116136 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 388
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21816,
20855,
368,
341,
286,
1077,
3601,
25,
44590,
1611,
66746,
51878,
25669,
60,
284,
609,
9640,
310,
8261,
486,
931,
2561,
16,
11,
220,
15,
11,
220,
15,
11,
220,
15,
11,
220,
15,
11,
220,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_remote_and_forwarded_for_when_x_forwarded_for_is_set() {
let mut request = build_test_request();
request.set_peer_addr(Some(
std::path::PathBuf::from("/dev/random").to_str().unwrap(),
));
set_x_forwarded_for(&mut request, "forwarded-host.com");
assert_eq!(request.forwarded_for(), Some("forwarded-host.com"));
assert_eq!(request.remote(), Some("forwarded-host.com"));
} | rust_cleaned_test_functions.jsonl/49022 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 206
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36425,
8378,
32121,
291,
5478,
47636,
3212,
32121,
291,
5478,
6892,
2602,
368,
341,
286,
1077,
5206,
1681,
284,
1936,
4452,
7893,
543,
286,
1681,
980,
45159,
7387,
65405,
1006,
310,
1460,
486,
234... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_from_config_classic_mode() {
let yaml_string = "classic: true\nsorting:\n dir-grouping: first";
let yaml = YamlLoader::load_from_str(yaml_string).unwrap()[0].clone();
assert_eq!(
Some(DirGrouping::None),
DirGrouping::from_config(&Config::with_yaml(yaml))
);
} | rust_cleaned_test_functions.jsonl/54320 | {
"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,
5673,
5332,
4790,
292,
7302,
368,
341,
286,
1077,
32246,
3904,
284,
330,
79709,
25,
830,
1699,
67039,
7190,
77,
220,
5419,
4351,
287,
25,
1156,
876,
286,
1077,
32246,
284,
809,
9467,
9181,
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_msgpack_serialize_body() {
let body = MessageBody::<TestTask>::new(TestTaskParams { a: 4 });
let serialized = rmp_serde::to_vec(&body).unwrap();
assert_eq!(serialized, MSGPACK);
} | rust_cleaned_test_functions.jsonl/97961 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 95
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6483,
4748,
88686,
14114,
368,
341,
262,
1077,
2487,
284,
4856,
5444,
27638,
2271,
6262,
6831,
931,
31159,
6262,
4870,
314,
264,
25,
220,
19,
1625,
262,
1077,
32916,
284,
435,
1307,
75861,
450,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_start_clients_succeeds() {
let mut exec = fuchsia_async::Executor::new().expect("failed to create an executor");
let mut test_values = test_setup(&mut exec);
// Create an empty PhyManager and IfaceManager.
let phy_manager = phy_manager::PhyManager::new(
test_values.device_service_proxy.clone(),
test_values.node,
);
let mut iface_manager = IfaceManagerService::new(
Arc::new(Mutex::new(phy_manager)),
test_values.client_update_sender,
test_values.ap_update_sender,
test_values.device_service_proxy,
test_values.saved_networks,
);
let start_fut = iface_manager.start_client_connections();
// Ensure stop_client_connections returns immediately and is successful.
pin_mut!(start_fut);
assert_variant!(exec.run_until_stalled(&mut start_fut), Poll::Ready(Ok(_)));
// Ensure an update was sent
let client_state_update = listener::ClientStateUpdate {
state: Some(fidl_fuchsia_wlan_policy::WlanClientState::ConnectionsEnabled),
networks: vec![],
};
assert_variant!(
test_values.client_update_receiver.try_next(),
Ok(Some(listener::Message::NotifyListeners(updates))) => {
assert_eq!(updates, client_state_update);
});
} | rust_cleaned_test_functions.jsonl/62707 | {
"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,
4906,
56899,
643,
29264,
82,
368,
341,
286,
1077,
5206,
3883,
284,
282,
73391,
28346,
486,
25255,
486,
931,
1005,
17119,
445,
16091,
311,
1855,
458,
31558,
797,
286,
1077,
5206,
1273,
9146,
284,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_non_equal() {
let one3: ModInt = ModInt::one();
let zero: ModInt = ModInt::zero();
assert_eq!(false, one3 == zero);
} | rust_cleaned_test_functions.jsonl/126138 | {
"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,
21637,
11478,
368,
341,
286,
1077,
825,
18,
25,
5650,
1072,
284,
5650,
1072,
486,
603,
543,
286,
1077,
7168,
25,
5650,
1072,
284,
5650,
1072,
486,
14154,
1428,
286,
2060,
10714,
10297,
3849,
11,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_valid_passports() {
let passport_json = make_json_strings(VALID);
for pp in passport_json {
let _: PassportInfo = serde_json::from_str(&pp).unwrap();
}
} | rust_cleaned_test_functions.jsonl/78543 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 104
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8337,
15464,
3394,
368,
341,
286,
1077,
25458,
9455,
284,
1281,
9455,
33500,
7,
10044,
626,
286,
369,
11823,
304,
25458,
9455,
341,
310,
1077,
58536,
66800,
1731,
284,
61570,
9455,
486,
1499,
2895... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
#[test]
fn test_double_ended_filter() {
let xs = [1, 2, 3, 4, 5, 6];
let mut it = xs.iter().filter(|&x| *x & 1 == 0);
assert_eq!(it.next_back().unwrap(), &6);
assert_eq!(it.next_back().unwrap(), &4);
assert_eq!(it.next().unwrap(), &2);
assert_eq!(it.next_back(), None);
} | rust_cleaned_test_functions.jsonl/1024 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 175
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
24598,
62,
2883,
8727,
368,
341,
286,
1077,
11943,
284,
508,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11,
220,
21,
935,
286,
1077,
5206,
432,
284,
11943,
19471,
1005,
5315,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_tx_rate_limited_event_handler() {
let mem = GuestMemory::new(&[(GuestAddress(0), 0x10000)]).unwrap();
let (mut h, _txq, _rxq) = default_test_netepollhandler(&mem, TestMutators::default());
let rl = RateLimiter::new(0, None, 0, 0, None, 0).unwrap();
h.set_tx_rate_limiter(rl);
let r = h.handle_event(TX_RATE_LIMITER_EVENT, EPOLLIN);
match r {
Err(DeviceError::RateLimited(_)) => (),
_ => panic!("invalid"),
}
} | rust_cleaned_test_functions.jsonl/84703 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 252
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17805,
9246,
907,
31511,
6748,
10183,
368,
341,
286,
1077,
1833,
284,
26215,
10642,
486,
931,
2099,
9697,
37804,
4286,
7,
15,
701,
220,
15,
87,
16,
15,
15,
15,
15,
7252,
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... | 2 |
#[test]
fn test_example() {
let input: Vec<u64> = vec![
"35", "20", "15", "25", "47", "40", "62", "55", "65", "95", "102", "117", "150",
"182", "127", "219", "299", "277", "309", "576",
]
.iter()
.map(|s| s.parse::<u64>().unwrap())
.collect();
let (lowest, highest) = find_contiguous_set_of_numbers_that_sum_up_to(&input, 127);
assert_eq!(15, lowest);
assert_eq!(47, highest);
} | rust_cleaned_test_functions.jsonl/105358 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 301
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39304,
368,
341,
310,
1077,
1946,
25,
11312,
34837,
21,
19,
29,
284,
7486,
90515,
394,
330,
18,
20,
497,
330,
17,
15,
497,
330,
16,
20,
497,
330,
17,
20,
497,
330,
19,
22,
497,
330,
19,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_message_stream_wait_context() {
let m = Arc::new(AtomicUsize::new(0));
let m2 = Arc::clone(&m);
let sys = System::new();
sys.block_on(async move {
let _addr = ContextWait::create(move |ctx| {
let (tx, rx) = unbounded_channel();
let _ = tx.send(Ping);
let _ = tx.send(Ping);
let _ = tx.send(Ping);
let actor = ContextWait { cnt: m2 };
ctx.add_message_stream(StreamRx { rx });
actor
});
});
sys.run().unwrap();
assert_eq!(m.load(Ordering::Relaxed), 1);
} | rust_cleaned_test_functions.jsonl/56897 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 306
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6462,
12673,
18760,
8467,
368,
341,
262,
1077,
296,
284,
19689,
486,
931,
7,
65857,
52,
2141,
486,
931,
7,
15,
1106,
262,
1077,
296,
17,
284,
19689,
486,
19982,
2099,
76,
626,
262,
1077,
5708,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_objects() {
test_roundtrip("({ })");
test_roundtrip(
"({
a: 1,
[x]: 1,
fn() {},
...from,
})",
);
} | rust_cleaned_test_functions.jsonl/102597 | {
"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,
24873,
368,
341,
262,
1273,
29896,
32981,
445,
2306,
6413,
797,
262,
1273,
29896,
32981,
1006,
286,
330,
2262,
310,
264,
25,
220,
16,
345,
310,
508,
87,
5669,
220,
16,
345,
310,
5168,
368,
145... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_regex() {
let reponse = "\
<h4 class=\"oden--event-card-title\"><a href=\"/about/events/1539\">Physics Discovery</a></h4>
<p class=\"oden--event-card-location\">
<h4 class=\"oden--event-card-title\"><a href=\"/about/events/1551\">Statistical Estimation</a></h4>
";
let regex = Regex::new(r"/about/events/\d*").unwrap();
for mat in regex.find_iter(reponse) {
println!("Found: {}", mat.as_str());
}
} | rust_cleaned_test_functions.jsonl/25040 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 200
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
41832,
368,
341,
262,
1077,
312,
1025,
284,
93317,
262,
366,
71,
19,
536,
4070,
54736,
313,
3087,
20466,
8816,
34681,
64,
1801,
98185,
9096,
42764,
14,
16,
20,
18,
24,
11403,
33899,
38093,
522,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_need_sync_for_qc() {
let block_tree = build_empty_tree();
let mut inserter = TreeInserter::new(block_tree.clone());
// build a tree of the following form
// genesis <- a1 <- a2 <- a3
let genesis = block_tree.root();
let a1 =
inserter.insert_block_with_qc(QuorumCert::certificate_for_genesis(), genesis.as_ref(), 1);
let a2 = inserter.insert_block(a1.as_ref(), 2);
let a3 = inserter.insert_block(a2.as_ref(), 3);
block_tree.prune_tree(a3.id());
let qc = placeholder_certificate_for_block(
vec![block_tree.signer()],
HashValue::zero(),
a3.round() + 3,
HashValue::zero(),
a3.round() + 2,
HashValue::zero(),
a3.round() + 1,
);
assert_eq!(
block_tree.need_sync_for_quorum_cert(HashValue::zero(), &qc),
true
);
let qc = placeholder_certificate_for_block(
vec![block_tree.signer()],
HashValue::zero(),
a3.round() + 2,
HashValue::zero(),
a3.round() + 1,
HashValue::zero(),
a3.round(),
);
assert_eq!(
block_tree.need_sync_for_quorum_cert(HashValue::zero(), &qc),
false,
);
assert_eq!(
block_tree.need_sync_for_quorum_cert(genesis.id(), &QuorumCert::certificate_for_genesis()),
false
);
} | rust_cleaned_test_functions.jsonl/85846 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 650
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
71506,
23008,
5478,
8976,
66,
368,
341,
262,
1077,
2504,
11663,
284,
1936,
15124,
11663,
543,
262,
1077,
5206,
47325,
465,
284,
8942,
641,
90727,
486,
931,
18682,
11663,
15997,
5231,
262,
442,
193... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_verify_account_changes_rent_epoch() {
let alice_program_id = solana_sdk::pubkey::new_rand();
assert_eq!(
Change::new(&alice_program_id, &system_program::id()).verify(),
Ok(()),
"nothing changed!"
);
assert_eq!(
Change::new(&alice_program_id, &system_program::id())
.rent_epoch(0, 1)
.verify(),
Err(InstructionError::RentEpochModified),
"no one touches rent_epoch"
);
} | rust_cleaned_test_functions.jsonl/15696 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 293
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
35638,
13500,
47526,
83127,
20682,
368,
341,
286,
1077,
70433,
25096,
842,
284,
2048,
3362,
61783,
486,
9585,
792,
486,
931,
33864,
1428,
286,
2060,
10714,
33673,
310,
10388,
486,
931,
2099,
63195,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_field_sort_key(){
let fields = DefinitionFields::new();
let account_sort_key = fields.get_field_sort_key("Account".to_string());
assert_eq!(account_sort_key,(8,1));
} | rust_cleaned_test_functions.jsonl/15172 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 93
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
5013,
18435,
3097,
3032,
414,
1077,
5043,
284,
19709,
8941,
486,
931,
543,
414,
1077,
2692,
18435,
3097,
284,
5043,
670,
5013,
18435,
3097,
445,
7365,
3263,
983,
3904,
1423,
414,
2060,
10714... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_tab_should_advance_to_next_tab_stop() {
// of the tab varies based on the leading text
new_ucmd!()
.args(&["-w8", "tab_stops.input"])
.succeeds()
.stdout_is_fixture("tab_stops_w8.expected");
} | rust_cleaned_test_functions.jsonl/23277 | {
"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,
17344,
43378,
98093,
2346,
11257,
17344,
19039,
368,
341,
1066,
262,
442,
315,
279,
5651,
34227,
3118,
389,
279,
6388,
1467,
198,
262,
501,
68887,
2277,
0,
741,
286,
659,
2116,
2099,
1183,
12,
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_injection() {
check_highlighting(
r##"
fn f(ra_fixture: &str) {}
fn main() {
f(r"
fn foo() {
foo(\$0{
92
}\$0)
}");
}
"##,
expect_file!["./test_data/injection.html"],
false,
);
} | rust_cleaned_test_functions.jsonl/5128 | {
"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,
1243,
7606,
368,
341,
262,
1779,
74546,
287,
1006,
286,
435,
565,
698,
8822,
282,
82034,
74409,
25,
609,
495,
8,
5613,
8822,
1887,
368,
341,
262,
282,
2601,
698,
8822,
15229,
368,
341,
262,
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_can_only_parse_templates() {
let mut tera = Tera::parse("examples/basic/templates/**/*").unwrap();
for tpl in tera.templates.values_mut() {
tpl.name = format!("a-theme/templates/{}", tpl.name);
if let Some(ref parent) = tpl.parent.clone() {
tpl.parent = Some(format!("a-theme/templates/{}", parent));
}
}
// Will panic here as we changed the parent and it won't be able
// to build the inheritance chain in this case
tera.build_inheritance_chains().unwrap();
} | rust_cleaned_test_functions.jsonl/87556 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 268
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
27421,
18410,
21039,
49526,
368,
341,
286,
1077,
5206,
1982,
64,
284,
350,
2416,
486,
6400,
445,
51668,
77909,
38941,
3663,
1057,
1827,
15454,
543,
286,
369,
60979,
304,
1982,
64,
76107,
10656,
29... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_edit_distance() {
dbg!(min_distance(
"intention".to_string(),
"execution".to_string()
));
dbg!(min_distance_v2(
"intention".to_string(),
"execution".to_string()
));
} | rust_cleaned_test_functions.jsonl/116171 | {
"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,
13156,
19464,
368,
341,
286,
47904,
10297,
1065,
19464,
1006,
310,
330,
396,
2939,
3263,
983,
3904,
3148,
310,
330,
52721,
3263,
983,
3904,
741,
286,
16518,
286,
47904,
10297,
1065,
19464,
2273,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_create_array_reader() {
let file = get_test_file("nulls.snappy.parquet");
let file_reader: Arc<dyn FileReader> =
Arc::new(SerializedFileReader::new(file).unwrap());
let file_metadata = file_reader.metadata().file_metadata();
let arrow_schema = parquet_to_arrow_schema(
file_metadata.schema_descr(),
file_metadata.key_value_metadata(),
)
.unwrap();
let array_reader = build_array_reader(
file_reader.metadata().file_metadata().schema_descr_ptr(),
Arc::new(arrow_schema),
vec![0usize].into_iter(),
Box::new(file_reader),
)
.unwrap();
// Create arrow types
let arrow_type = ArrowType::Struct(vec![Field::new(
"b_struct",
ArrowType::Struct(vec![Field::new("b_c_int", ArrowType::Int32, true)]),
true,
)]);
assert_eq!(array_reader.get_data_type(), &arrow_type);
} | rust_cleaned_test_functions.jsonl/10219 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 492
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8657,
3858,
22306,
368,
341,
286,
1077,
1034,
284,
633,
4452,
2458,
445,
2921,
82,
37672,
11144,
33277,
23300,
797,
286,
1077,
1034,
22306,
25,
19689,
92846,
40733,
29,
4035,
310,
19689,
486,
931,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_response_from_str() {
let raw_response = "250-me\r\n250-8BITMIME\r\n250-SIZE 42\r\n250 AUTH PLAIN CRAM-MD5\r\n";
assert_eq!(
raw_response.parse::<Response>().unwrap(),
Response {
code: Code {
severity: Severity::PositiveCompletion,
category: Category::MailSystem,
detail: Detail::Zero,
},
message: vec![
"me".to_string(),
"8BITMIME".to_string(),
"SIZE 42".to_string(),
"AUTH PLAIN CRAM-MD5".to_string(),
],
}
);
let wrong_code = "2506-me\r\n250-8BITMIME\r\n250-SIZE 42\r\n250 AUTH PLAIN CRAM-MD5\r\n";
assert!(wrong_code.parse::<Response>().is_err());
let wrong_end = "250-me\r\n250-8BITMIME\r\n250-SIZE 42\r\n250-AUTH PLAIN CRAM-MD5\r\n";
assert!(wrong_end.parse::<Response>().is_err());
} | rust_cleaned_test_functions.jsonl/10041 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 590
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9655,
5673,
2895,
368,
341,
286,
1077,
7112,
9655,
284,
330,
17,
20,
15,
33973,
12016,
1699,
17,
20,
15,
12,
23,
20917,
44,
5660,
12016,
1699,
17,
20,
15,
6222,
3282,
220,
19,
17,
12016,
169... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_named_file_content_length_headers() {
let mut srv = test::init_service(
App::new().service(Files::new("test", ".").index_file("tests/test.binary")),
);
// Valid range header
let request = TestRequest::get()
.uri("/t%65st/tests/test.binary")
.header(header::RANGE, "bytes=10-20")
.to_request();
let _response = test::call_service(&mut srv, request);
// let contentlength = response
// Invalid range header
let request = TestRequest::get()
.uri("/t%65st/tests/test.binary")
.header(header::RANGE, "bytes=10-8")
.to_request();
let response = test::call_service(&mut srv, request);
assert_eq!(response.status(), StatusCode::RANGE_NOT_SATISFIABLE);
// Without range header
let request = TestRequest::get()
.uri("/t%65st/tests/test.binary")
.to_request();
let _response = test::call_service(&mut srv, request);
// let contentlength = response
// chunked
let request = TestRequest::get()
.uri("/t%65st/tests/test.binary")
.to_request();
let mut response = test::call_service(&mut srv, request);
// with enabled compression
// let te = response
let bytes =
test::block_on(response.take_body().fold(BytesMut::new(), |mut b, c| {
b.extend(c);
Ok::<_, Error>(b)
}))
.unwrap();
let data = Bytes::from(fs::read("tests/test.binary").unwrap());
assert_eq!(bytes.freeze(), data);
} | rust_cleaned_test_functions.jsonl/35493 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 999
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
71834,
2458,
7495,
5118,
26719,
368,
341,
23459,
286,
1077,
5206,
43578,
284,
1273,
486,
2327,
12267,
1006,
310,
1845,
486,
931,
1005,
7936,
7,
10809,
486,
931,
445,
1944,
497,
22760,
568,
1252,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_mvcc_info_collector() {
use crate::storage::mvcc::Write;
use engine_test::ctor::{CFOptions, ColumnFamilyOptions, DBOptions};
use engine_traits::SyncMutable;
use txn_types::TimeStamp;
let tmp = tempfile::Builder::new()
.prefix("test_debug")
.tempdir()
.unwrap();
let path = tmp.path().to_str().unwrap();
let engine = engine_test::kv::new_engine_opt(
path,
DBOptions::new(),
vec![
CFOptions::new(CF_DEFAULT, ColumnFamilyOptions::new()),
CFOptions::new(CF_WRITE, ColumnFamilyOptions::new()),
CFOptions::new(CF_LOCK, ColumnFamilyOptions::new()),
CFOptions::new(CF_RAFT, ColumnFamilyOptions::new()),
],
)
.unwrap();
let cf_default_data = vec![
(b"k1", b"v", 5.into()),
(b"k2", b"x", 10.into()),
(b"k3", b"y", 15.into()),
];
for &(prefix, value, ts) in &cf_default_data {
let encoded_key = Key::from_raw(prefix).append_ts(ts);
let key = keys::data_key(encoded_key.as_encoded().as_slice());
engine.put(key.as_slice(), value).unwrap();
}
let cf_lock_data = vec![
(b"k1", LockType::Put, b"v", 5.into()),
(b"k4", LockType::Lock, b"x", 10.into()),
(b"k5", LockType::Delete, b"y", 15.into()),
];
for &(prefix, tp, value, version) in &cf_lock_data {
let encoded_key = Key::from_raw(prefix);
let key = keys::data_key(encoded_key.as_encoded().as_slice());
let lock = Lock::new(
tp,
value.to_vec(),
version,
0,
None,
TimeStamp::zero(),
0,
TimeStamp::zero(),
);
let value = lock.to_bytes();
engine
.put_cf(CF_LOCK, key.as_slice(), value.as_slice())
.unwrap();
}
let cf_write_data = vec![
(b"k2", WriteType::Put, 5.into(), 10.into()),
(b"k3", WriteType::Put, 15.into(), 20.into()),
(b"k6", WriteType::Lock, 25.into(), 30.into()),
(b"k7", WriteType::Rollback, 35.into(), 40.into()),
];
for &(prefix, tp, start_ts, commit_ts) in &cf_write_data {
let encoded_key = Key::from_raw(prefix).append_ts(commit_ts);
let key = keys::data_key(encoded_key.as_encoded().as_slice());
let write = Write::new(tp, start_ts, None);
let value = write.as_ref().to_bytes();
engine
.put_cf(CF_WRITE, key.as_slice(), value.as_slice())
.unwrap();
}
let scan_mvcc = |start: &[u8], end: &[u8], limit: u64| {
MvccInfoIterator::new(
|cf, opts| engine.iterator_cf_opt(cf, opts).map_err(|e| box_err!(e)),
if start.is_empty() { None } else { Some(start) },
if end.is_empty() { None } else { Some(end) },
limit as usize,
)
.unwrap()
};
let mut count = 0;
for key_and_mvcc in scan_mvcc(b"z", &[], 30) {
assert!(key_and_mvcc.is_ok());
count += 1;
}
assert_eq!(count, 7);
} | rust_cleaned_test_functions.jsonl/27337 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1911
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
73187,
638,
3109,
10211,
27669,
368,
341,
286,
990,
17717,
486,
16172,
486,
26002,
638,
486,
7985,
280,
286,
990,
4712,
4452,
486,
4904,
22964,
34,
3788,
1300,
11,
9332,
15192,
3798,
11,
5952,
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... | 7 |
#[test]
fn test_table_pool() -> Result<()> {
let pool = TablePool::new(
&ModuleLimits {
imported_functions: 0,
imported_tables: 0,
imported_memories: 0,
imported_globals: 0,
types: 0,
functions: 0,
tables: 4,
memories: 0,
globals: 0,
table_elements: 100,
memory_pages: 0,
},
&InstanceLimits { count: 7 },
)?;
let host_page_size = region::page::size();
assert_eq!(pool.table_size, host_page_size);
assert_eq!(pool.max_tables, 4);
assert_eq!(pool.max_instances, 7);
assert_eq!(pool.page_size, host_page_size);
assert_eq!(pool.max_elements, 100);
let base = pool.mapping.as_ptr() as usize;
for i in 0..7 {
let mut iter = pool.get(i);
for j in 0..4 {
assert_eq!(
iter.next().unwrap() as usize - base,
((i * 4) + j) * pool.table_size
);
}
assert_eq!(iter.next(), None);
}
Ok(())
} | rust_cleaned_test_functions.jsonl/48875 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 724
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5237,
15709,
368,
1464,
5714,
71698,
341,
286,
1077,
7314,
284,
6633,
10551,
486,
931,
1006,
310,
609,
3332,
94588,
341,
394,
24928,
31708,
25,
220,
15,
345,
394,
24928,
35632,
25,
220,
15,
345,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
#[test]
fn test_one_or_more_spaces() {
let mut reader = Reader::init(" ");
assert_eq!(
one_or_more_spaces(&mut reader),
Ok(Whitespace {
value: " ".to_string(),
source_info: SourceInfo::init(1, 1, 1, 3),
})
);
let mut reader = Reader::init("abc");
let error = one_or_more_spaces(&mut reader).err().unwrap();
assert_eq!(error.pos, Pos { line: 1, column: 1 });
} | rust_cleaned_test_functions.jsonl/119570 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 256
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11667,
8734,
36664,
67883,
368,
341,
286,
1077,
5206,
6604,
284,
25166,
486,
2327,
445,
220,
7318,
286,
2060,
10714,
33673,
310,
825,
8734,
36664,
67883,
2099,
6984,
6604,
1326,
310,
7622,
7,
7380... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_invalid_engish() {
// correct phrase:
// "letter advice cage absurd amount doctor acoustic avoid letter advice cage above"
assert_eq!(
Mnemonic::parse_normalized(
"getter advice cage absurd amount doctor acoustic avoid letter advice cage above",
),
Err(Error::UnknownWord(0))
);
assert_eq!(
Mnemonic::parse_normalized(
"letter advice cagex absurd amount doctor acoustic avoid letter advice cage above",
),
Err(Error::UnknownWord(2))
);
assert_eq!(
Mnemonic::parse_normalized(
"advice cage absurd amount doctor acoustic avoid letter advice cage above",
),
Err(Error::BadWordCount(11))
);
assert_eq!(
Mnemonic::parse_normalized(
"primary advice cage absurd amount doctor acoustic avoid letter advice cage above",
),
Err(Error::InvalidChecksum)
);
} | rust_cleaned_test_functions.jsonl/11273 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 304
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31433,
62102,
812,
368,
341,
197,
197,
322,
4396,
17133,
510,
197,
197,
322,
330,
9451,
9462,
35360,
31577,
3311,
10668,
44066,
5648,
6524,
9462,
35360,
3403,
1837,
197,
6948,
10714,
33673,
298,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_sample() {
let mut map = LruCache::with_capacity_and_sample(10, 7);
for i in 0..10 {
map.insert(i, i);
}
for i in 0..10 {
assert_eq!(map.get(&i), Some(&i));
}
for i in 10..19 {
map.insert(i, i);
}
for i in (0..7).chain(8..10) {
assert_eq!(map.get(&i), None);
}
for i in (7..8).chain(10..19) {
assert_eq!(map.get(&i), Some(&i));
}
} | rust_cleaned_test_functions.jsonl/54770 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 305
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17491,
368,
341,
286,
1077,
5206,
2415,
284,
444,
2672,
8233,
486,
4197,
35603,
8378,
17491,
7,
16,
15,
11,
220,
22,
317,
286,
369,
600,
304,
220,
15,
496,
16,
15,
341,
310,
2415,
7030,
1956... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_diff_two_inputs_one_different() {
let diff = Diff::default_refinement(&[b"a b c", b"a X c"]);
assert_eq!(
diff.hunks().collect_vec(),
vec![
DiffHunk::Matching(b"a "),
DiffHunk::Different(vec![b"b", b"X"]),
DiffHunk::Matching(b" c"),
]
);
} | rust_cleaned_test_functions.jsonl/89258 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 223
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15850,
23241,
28557,
11667,
82741,
368,
341,
286,
1077,
3638,
284,
28369,
486,
2258,
7793,
37184,
2099,
58,
65,
56693,
293,
272,
497,
293,
56693,
1599,
272,
15049,
286,
2060,
10714,
33673,
310,
36... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_extent_cluster_header_serialize_all_zeroes() {
let mut buffer = Cursor::new(Vec::new());
ExtentClusterHeader::serialize_to(0, 0, &mut buffer).unwrap();
assert!(buffer.get_ref().len() > 0);
buffer.set_position(0);
let cluster = ExtentClusterHeader::deserialize_from(&mut buffer).unwrap();
assert_eq!(cluster.magic1, EXTENT_CLUSTER_HEADER_MAGIC1);
assert_eq!(cluster.magic2, EXTENT_CLUSTER_HEADER_MAGIC2);
assert_eq!(cluster.extent_count, 0);
assert_eq!(cluster.next_cluster_offset, 0);
assert_ne!(cluster.crc32, 0);
} | rust_cleaned_test_functions.jsonl/51128 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 291
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
70102,
28441,
8757,
88686,
5705,
19359,
288,
368,
341,
286,
1077,
5206,
4147,
284,
28067,
486,
931,
49923,
486,
931,
1423,
286,
9447,
306,
28678,
4047,
486,
24166,
2346,
7,
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_verkey_from_qualified_address() {
let verkey = gen_random_base58_verkey();
let address = qualified_address_from_verkey(&verkey).unwrap();
let result = validate_address(&address);
let verkey_extracted = result.unwrap();
assert_eq!(verkey_extracted, verkey);
} | rust_cleaned_test_functions.jsonl/72541 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 136
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26042,
792,
5673,
62,
36335,
6744,
368,
341,
286,
1077,
2739,
792,
284,
4081,
22644,
7651,
20,
23,
26042,
792,
543,
286,
1077,
2621,
284,
14988,
6744,
5673,
26042,
792,
2099,
423,
792,
568,
1545... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parse_event() {
let abi = "event ValueChanged(address indexed author, string oldValue, string newValue)";
let event = HumanReadableParser::parse_event(abi).unwrap();
assert_eq!(
Event {
name: "ValueChanged".to_string(),
inputs: vec![
EventParam {
name: "author".to_string(),
kind: ParamType::Address,
indexed: true
},
EventParam {
name: "oldValue".to_string(),
kind: ParamType::String,
indexed: false
},
EventParam {
name: "newValue".to_string(),
kind: ParamType::String,
indexed: false
}
],
anonymous: false
},
event
);
} | rust_cleaned_test_functions.jsonl/77873 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 631
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
6748,
368,
341,
286,
1077,
61050,
284,
330,
3087,
5162,
5389,
15434,
30581,
3150,
11,
914,
49102,
11,
914,
24174,
24023,
286,
1077,
1538,
284,
11097,
57938,
6570,
486,
6400,
6748,
7,
25084,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_join_lines_multiline_comments_1() {
check_join_lines(
r"
fn foo() {
// Hello$0
/* world! */
}
",
r"
fn foo() {
// Hello$0 world! */
}
",
);
} | rust_cleaned_test_functions.jsonl/22502 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 128
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31017,
18323,
26290,
26560,
30359,
62,
16,
368,
341,
286,
1779,
31017,
18323,
1006,
310,
435,
698,
8822,
15229,
368,
341,
262,
442,
21927,
3,
15,
198,
262,
1391,
1879,
0,
735,
532,
756,
310,
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 |
#[test]
fn test_from_iterator() {
let s = TinyString::<[u8; 64]>::from("ศไทย中华Việt Nam");
let t = "ศไทย中华";
let u = "Việt Nam";
let a: String = s.chars().collect();
assert_eq!(s, a);
let mut b = TinyString::<[u8; 64]>::from(t);
b.extend(u.chars());
assert_eq!(s, b);
let mut c = TinyString::<[u8; 128]>::new();
c.extend(vec![t, u]);
assert_eq!(s, c);
let mut d = TinyString::<[u8; 64]>::from(t);
d.extend(vec![u]);
assert_eq!(s, d);
} | rust_cleaned_test_functions.jsonl/3640 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 249
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5673,
13491,
368,
341,
10217,
274,
284,
47974,
703,
27638,
58,
84,
23,
26,
220,
21,
19,
60,
6831,
1499,
445,
123863,
125451,
100849,
35544,
124382,
29974,
797,
10217,
259,
284,
330,
123863,
125451... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_scan_white_three() {
let result = Sequence::scan(White, Three, 0b001110, 0b110001, 6, 0);
let expected = [Sequence::new(1, 4, Some(4), None)];
assert_eq!(result, expected);
let result = Sequence::scan(White, Three, 0b010110, 0b101001, 6, 0);
let expected = [Sequence::new(1, 4, Some(3), None)];
assert_eq!(result, expected);
let result = Sequence::scan(White, Three, 0b011010, 0b100101, 6, 0);
let expected = [Sequence::new(1, 4, Some(2), None)];
assert_eq!(result, expected);
let result = Sequence::scan(White, Three, 0b011100, 0b100011, 6, 0);
let expected = [Sequence::new(1, 4, Some(1), None)];
assert_eq!(result, expected);
// two threes
let result = Sequence::scan(White, Three, 0b0011100, 0b1100011, 7, 0);
let expected = [
Sequence::new(1, 4, Some(1), None),
Sequence::new(2, 5, Some(5), None),
];
assert_eq!(result, expected);
// not three
let result = Sequence::scan(White, Three, 0b001110, 0b010001, 6, 0);
let expected = [];
assert_eq!(result, expected);
} | rust_cleaned_test_functions.jsonl/56143 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 552
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28857,
44431,
50016,
368,
341,
286,
1077,
1102,
284,
28871,
486,
16405,
7,
14075,
11,
14513,
11,
220,
15,
65,
15,
15,
16,
16,
16,
15,
11,
220,
15,
65,
16,
16,
15,
15,
15,
16,
11,
220,
21... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_generic_two_parameter() {
use test_capnp::brand_twice;
let mut message_for_brand = message::Builder::new_default();
let mut branded = message_for_brand.init_root::<brand_twice::Builder>();
{
let mut baz = branded.reborrow().init_baz_field();
baz.set_foo_field("blah").unwrap();
let mut bar = baz.init_bar_field();
bar.set_text_field("some text");
bar.set_data_field("some data".as_bytes());
}
let reader = branded.into_reader();
assert_eq!("blah", reader.get_baz_field().unwrap().get_foo_field().unwrap());
assert_eq!("some text", reader.get_baz_field().unwrap().get_bar_field().unwrap().get_text_field().unwrap());
assert_eq!("some data".as_bytes(), reader.get_baz_field().unwrap().get_bar_field().unwrap().get_data_field().unwrap());
} | rust_cleaned_test_functions.jsonl/55854 | {
"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,
41232,
23241,
24899,
368,
341,
286,
990,
1273,
16388,
6199,
486,
13473,
54178,
558,
401,
286,
1077,
5206,
1943,
5478,
54858,
284,
1943,
486,
3297,
486,
931,
9993,
543,
286,
1077,
5206,
45835,
284,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_string_literal_0() {
let s = to_chars("\"\"");
let cur = &mut 0;
expect_next_token(&s, cur, Token::StringLiteral(s.as_string()));
} | rust_cleaned_test_functions.jsonl/21016 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 93
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3904,
34100,
62,
15,
368,
341,
286,
1077,
274,
284,
311,
37418,
38915,
88385,
286,
1077,
2847,
284,
609,
6984,
220,
15,
280,
286,
1720,
11257,
6458,
2099,
82,
11,
2847,
11,
9660,
486,
703,
173... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_keywords_in_match_arm() {
check(
r#"
fn quux() -> i32 {
match () { () => <|> }
}
"#,
expect![[r#"
kw if
kw if let
kw loop
kw match
kw return
kw unsafe
kw while
"#]],
);
} | rust_cleaned_test_functions.jsonl/99575 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 258
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
51354,
1243,
10708,
34680,
368,
341,
286,
1779,
1006,
310,
435,
2,
698,
8822,
922,
2200,
368,
1464,
600,
18,
17,
341,
262,
2432,
1719,
314,
1719,
589,
82639,
29,
456,
532,
57676,
345,
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_help_long() {
let (r, sioe) = do_execute!(&["--help"]);
assert_eq!(buff!(sioe, serr), "");
assert_eq!(buff!(sioe, sout), help_msg!());
assert_eq!(r.is_ok(), true);
} | rust_cleaned_test_functions.jsonl/62174 | {
"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,
26926,
17799,
368,
341,
286,
1077,
320,
81,
11,
274,
815,
68,
8,
284,
653,
44329,
0,
2099,
1183,
313,
8653,
15049,
286,
2060,
10714,
10297,
25976,
10297,
82,
815,
68,
11,
61934,
701,
14498,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_delete_version() {
wrapper(|env| {
fn authors(conn: &Connection, crate_id: i32) -> Result<Vec<String>, Error> {
Ok(conn
.query(
"SELECT name FROM authors
INNER JOIN author_rels ON authors.id = author_rels.aid
INNER JOIN releases ON author_rels.rid = releases.id
WHERE releases.crate_id = $1",
&[&crate_id],
)?
.into_iter()
.map(|row| row.get(0))
.collect())
}
let db = env.db();
let v1 = env
.fake_release()
.name("a")
.version("1.0.0")
.author("malicious actor")
.create()?;
let v2 = env
.fake_release()
.name("a")
.version("2.0.0")
.author("Peter Rabbit")
.create()?;
assert!(release_exists(&db.conn(), v1)?);
assert!(release_exists(&db.conn(), v2)?);
let crate_id = db
.conn()
.query("SELECT crate_id FROM releases WHERE id = $1", &[&v1])?
.into_iter()
.next()
.unwrap()
.get(0);
assert_eq!(
authors(&db.conn(), crate_id)?,
vec!["malicious actor".to_string(), "Peter Rabbit".to_string()]
);
delete_version(&db.conn(), "a", "1.0.0")?;
assert!(!release_exists(&db.conn(), v1)?);
assert!(release_exists(&db.conn(), v2)?);
assert_eq!(
authors(&db.conn(), crate_id)?,
vec!["Peter Rabbit".to_string()]
);
let web = env.frontend();
assert_success("/a/2.0.0/a/", web)?;
assert_eq!(web.get("/a/1.0.0/a/").send()?.status(), 404);
Ok(())
})
} | rust_cleaned_test_functions.jsonl/125235 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1276
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11353,
9438,
368,
341,
286,
13261,
22428,
3160,
91,
341,
310,
5168,
12014,
20571,
25,
609,
4526,
11,
17717,
842,
25,
600,
18,
17,
8,
1464,
5714,
50439,
3464,
8066,
4600,
29,
341,
394,
7622,
20... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_absolute_form() {
let mut uri = "http://hyper.rs/guides".parse().unwrap();
absolute_form(&mut uri);
assert_eq!(uri.to_string(), "http://hyper.rs/guides");
let mut uri = "https://hyper.rs/guides".parse().unwrap();
absolute_form(&mut uri);
assert_eq!(uri.to_string(), "/guides");
} | rust_cleaned_test_functions.jsonl/56956 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 164
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
50874,
7915,
368,
341,
286,
1077,
5206,
13071,
284,
330,
1254,
1110,
68192,
25638,
4846,
2423,
288,
3263,
6400,
1005,
15454,
543,
286,
10740,
7915,
2099,
6984,
13071,
317,
286,
2060,
10714,
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_atom_fixed_hash_value() {
let mol = molecule::Molecule::from_smiles("c1ccccc1CN");
assert_eq!(mol.atoms[0].fixed_hash_value(), 100210060);
assert_eq!(mol.atoms[5].fixed_hash_value(), 100310060);
assert_eq!(mol.atoms[6].fixed_hash_value(), 100200060);
} | rust_cleaned_test_functions.jsonl/128005 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 150
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
42292,
37839,
8950,
3142,
368,
341,
286,
1077,
21609,
284,
41930,
486,
44,
54169,
486,
1499,
15874,
3658,
445,
66,
16,
638,
37054,
16,
28668,
797,
286,
2060,
10714,
10297,
44344,
6847,
6940,
58,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_extract_content_from_path() {
let path_buf = PathBuf::from("Cargo.toml");
let res = extract_content_from_path(&path_buf);
assert!(res.is_some());
assert!(res.unwrap().0 == "Cargo");
} | rust_cleaned_test_functions.jsonl/92734 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 116
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39123,
7495,
5673,
2638,
368,
341,
286,
1077,
1815,
10363,
284,
7933,
15064,
486,
1499,
445,
98228,
73494,
75,
797,
286,
1077,
592,
284,
8649,
7495,
5673,
2638,
2099,
2343,
10363,
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 |
#[test]
fn test_group_by() {
let slice = &[1, 1, 1, 3, 3, 2, 2, 2, 1, 0];
let mut iter = slice.group_by(|a, b| a == b);
assert_eq!(iter.next(), Some(&[1, 1, 1][..]));
assert_eq!(iter.next(), Some(&[3, 3][..]));
assert_eq!(iter.next(), Some(&[2, 2, 2][..]));
assert_eq!(iter.next(), Some(&[1][..]));
assert_eq!(iter.next(), Some(&[0][..]));
assert_eq!(iter.next(), None);
let mut iter = slice.group_by(|a, b| a == b);
assert_eq!(iter.next_back(), Some(&[0][..]));
assert_eq!(iter.next_back(), Some(&[1][..]));
assert_eq!(iter.next_back(), Some(&[2, 2, 2][..]));
assert_eq!(iter.next_back(), Some(&[3, 3][..]));
assert_eq!(iter.next_back(), Some(&[1, 1, 1][..]));
assert_eq!(iter.next_back(), None);
let mut iter = slice.group_by(|a, b| a == b);
assert_eq!(iter.next(), Some(&[1, 1, 1][..]));
assert_eq!(iter.next_back(), Some(&[0][..]));
assert_eq!(iter.next(), Some(&[3, 3][..]));
assert_eq!(iter.next_back(), Some(&[1][..]));
assert_eq!(iter.next(), Some(&[2, 2, 2][..]));
assert_eq!(iter.next_back(), None);
} | rust_cleaned_test_functions.jsonl/80836 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 527
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6288,
3710,
368,
341,
262,
1077,
15983,
284,
44590,
16,
11,
220,
16,
11,
220,
16,
11,
220,
18,
11,
220,
18,
11,
220,
17,
11,
220,
17,
11,
220,
17,
11,
220,
16,
11,
220,
15,
4821,
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_project_force_delete() {
let cli = TestCli::get();
let project = TestProject::new();
let name = project.name().to_owned();
let source_name = format!("{}/a-source", name);
cli.run(&["create", "source", &source_name]);
// Regular delete fails because of the source
let output = cli
.command()
.args(&["delete", "project", &name])
.output()
.unwrap();
assert!(!output.status.success());
assert!(
String::from_utf8_lossy(&output.stderr)
.contains("API request failed with 409 Conflict: Project contains child resources but force deletion was not requested: {\"sources\": 1}"),
"{}",
String::from_utf8_lossy(&output.stderr)
);
// The project still exists
let output = cli.run(&["get", "projects"]);
assert!(output.contains(&name));
// Force delete succeeds
cli.run(&["delete", "project", &name, "--force"]);
// The project no longer exists
let output = cli.run(&["get", "projects"]);
assert!(!output.contains(&name));
// To avoid panic on drop because the project has already been deleted.
std::mem::forget(project);
} | rust_cleaned_test_functions.jsonl/116377 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 455
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16352,
40739,
11353,
368,
341,
262,
1077,
21348,
284,
3393,
87014,
486,
455,
543,
262,
1077,
2390,
284,
3393,
7849,
486,
931,
1428,
262,
1077,
829,
284,
2390,
2644,
1005,
983,
51973,
543,
262,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_transport_cc_extmap() -> Result<()> {
// a=extmap:<value>["/"<direction>] <URI> <extensionattributes>
let uri = Some(Url::parse(
"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",
)?);
let e = ExtMap {
value: 3,
uri,
direction: Direction::Unspecified,
ext_attr: None,
};
let s = e.marshal();
if s == "3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01" {
assert!(false, "TestTransportCC failed");
} else {
assert_eq!(
s,
"extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"
)
}
Ok(())
} | rust_cleaned_test_functions.jsonl/78959 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 367
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
46398,
28955,
9927,
2186,
368,
1464,
5714,
71698,
341,
262,
442,
264,
28,
427,
2186,
31252,
957,
29,
1183,
11225,
27,
19071,
53529,
366,
10301,
29,
366,
12427,
12340,
397,
1066,
262,
1077,
13071,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_client_receive_settings_twice() {
let (mut hconn, mut peer_conn) = connect(Client);
// send the second SETTINGS frame.
let sent = peer_conn.conn.stream_send(
peer_conn.control_stream_id,
&[0x4, 0x6, 0x1, 0x40, 0x64, 0x7, 0x40, 0x64],
);
assert_eq!(sent, Ok(8));
let out = peer_conn.conn.process(None, now());
hconn.process(out.dgram(), now());
assert_closed(&hconn, Error::UnexpectedFrame);
} | rust_cleaned_test_functions.jsonl/10917 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 252
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8179,
38557,
10853,
54178,
558,
368,
341,
286,
1077,
320,
6984,
305,
5148,
11,
5206,
14397,
17241,
8,
284,
4564,
46851,
317,
286,
442,
3624,
279,
2086,
73991,
4034,
624,
286,
1077,
3208,
284,
14... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_hasher_interface_no_panic_and_same_result() {
let digest_256 = Hasher::Blake2b256.digest(b"Test").unwrap();
let digest_384 = Hasher::Blake2b384.digest(b"Test").unwrap();
let digest_512 = Hasher::Blake2b512.digest(b"Test").unwrap();
assert_eq!(digest_256, Hasher::Blake2b256.digest(b"Test").unwrap());
assert_eq!(digest_384, Hasher::Blake2b384.digest(b"Test").unwrap());
assert_eq!(digest_512, Hasher::Blake2b512.digest(b"Test").unwrap());
assert_ne!(digest_256, Hasher::Blake2b256.digest(b"Wrong").unwrap());
assert_ne!(digest_384, Hasher::Blake2b384.digest(b"Wrong").unwrap());
assert_ne!(digest_512, Hasher::Blake2b512.digest(b"Wrong").unwrap());
let _state_256 = Hasher::Blake2b256.init().unwrap();
let _state_384 = Hasher::Blake2b384.init().unwrap();
let _state_512 = Hasher::Blake2b512.init().unwrap();
} | rust_cleaned_test_functions.jsonl/56749 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 480
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8950,
261,
20546,
6536,
620,
31270,
8378,
33574,
5287,
368,
341,
310,
1077,
20882,
62,
17,
20,
21,
284,
6531,
261,
486,
91038,
17,
65,
17,
20,
21,
75577,
1883,
1,
2271,
1827,
15454,
543,
310,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_double_and_single_quote() {
assert_eq!(
eval(r#"" '''' " + " '''' ""#),
Ok(to_value(r#" '''' '''' "#))
);
} | rust_cleaned_test_functions.jsonl/28419 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 109
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
24598,
8378,
19487,
45236,
368,
341,
286,
2060,
10714,
33673,
310,
5603,
2601,
2,
3014,
3355,
4605,
330,
488,
330,
3355,
4605,
1591,
2,
1326,
310,
7622,
12186,
3142,
2601,
55543,
3355,
4605,
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 |
#[test]
fn test_iterate_into_string() {
let words = vec!["hello", " ", "world"];
let capitalized_words = words.into_iter().map(capitalize_first).collect::<Vec<String>>().join("");
assert_eq!(capitalized_words, "Hello World");
} | rust_cleaned_test_functions.jsonl/116551 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 110
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11723,
349,
45514,
3904,
368,
341,
286,
1077,
4244,
284,
7486,
0,
1183,
14990,
497,
330,
3670,
330,
14615,
6332,
286,
1077,
97321,
18981,
284,
4244,
39860,
11723,
1005,
2186,
51386,
34313,
12978,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_status_code() {
let mut cmd = process::Command::new("sh");
cmd.arg("-c").arg("exit 200");
match status(cmd) {
Err(StatusError::Code(200)) => {}
result => panic!("expected code 200 status error but got: {:?}", result),
}
} | rust_cleaned_test_functions.jsonl/74401 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 98
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4773,
4136,
368,
341,
220,
1077,
5206,
5439,
284,
1882,
486,
4062,
486,
931,
445,
927,
797,
220,
5439,
21186,
13645,
66,
1827,
858,
445,
13652,
220,
17,
15,
15,
797,
220,
2432,
2639,
14160,
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... | 2 |
#[test]
fn test_read_into_pointer() {
const INITIAL: &[u8] = b"abcdef123456";
let mut rbuf = vec![0; 4];
const EXPECT: &[u8] = b"cdef";
let mut f = tempfile().unwrap();
f.write_all(INITIAL).unwrap();
{
// Safety: ok because rbuf lives until after poll_aio
let mut aiocb = unsafe {
AioCb::from_mut_ptr( f.as_raw_fd(),
2, //offset
rbuf.as_mut_ptr() as *mut c_void,
rbuf.len(),
0, //priority
SigevNotify::SigevNone,
LioOpcode::LIO_NOP)
};
aiocb.read().unwrap();
let err = poll_aio(&mut aiocb);
assert_eq!(err, Ok(()));
assert_eq!(aiocb.aio_return().unwrap() as usize, EXPECT.len());
}
assert_eq!(rbuf, EXPECT);
} | rust_cleaned_test_functions.jsonl/90413 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 560
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
45514,
21425,
368,
341,
262,
733,
56854,
25,
44590,
84,
23,
60,
284,
293,
1,
41202,
16,
17,
18,
19,
20,
21,
876,
262,
1077,
5206,
435,
5909,
284,
7486,
20703,
15,
26,
220,
19,
935,
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_blake2s_digest() {
let tests = vec![
Test {
input: vec![
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d,
0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a,
0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81,
0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e,
0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b,
0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8,
0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5,
0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2,
0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc,
0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6,
0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe,
],
output: vec![
0x3f, 0xb7, 0x35, 0x06, 0x1a, 0xbc, 0x51, 0x9d, 0xfe, 0x97, 0x9e, 0x54, 0xc1,
0xee, 0x5b, 0xfa, 0xd0, 0xa9, 0xd8, 0x58, 0xb3, 0x31, 0x5b, 0xad, 0x34, 0xbd,
0xe9, 0x99, 0xef, 0xd7, 0x24, 0xdd,
],
key: Some(vec![
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
]),
},
];
test_hash(&tests[..]);
} | rust_cleaned_test_functions.jsonl/92931 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2098
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13141,
726,
17,
82,
52994,
368,
341,
286,
1077,
7032,
284,
7486,
90515,
3374,
310,
3393,
341,
394,
1946,
25,
7486,
90515,
503,
220,
15,
87,
15,
15,
11,
220,
15,
87,
15,
16,
11,
220,
15,
87... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_append_block_at_wrong_location() {
let mut rng: StdRng = SeedableRng::from_seed([1u8; 32]);
let mut ledger_db = create_db();
// initialize a ledger with 3 blocks.
let n_blocks = 3;
let (blocks, _) = populate_db(&mut ledger_db, n_blocks, 2);
assert_eq!(ledger_db.num_blocks().unwrap(), n_blocks);
let key_images = vec![KeyImage::from(rng.next_u64())];
let tx_out = create_test_tx_out(&mut rng);
let outputs = vec![tx_out];
let block_contents = BlockContents {
key_images,
outputs,
..Default::default()
};
// Appending a block to a previously written location should fail.
let mut new_block = Block::new(
BLOCK_VERSION,
&blocks[0].id,
1,
blocks[0].cumulative_txo_count,
&Default::default(),
&block_contents,
);
assert_eq!(
ledger_db.append_block(&new_block, &block_contents, None),
Err(Error::InvalidBlockIndex(new_block.index))
);
// Appending a non-contiguous location should fail.
new_block.index = 3 * n_blocks;
assert_eq!(
ledger_db.append_block(&new_block, &block_contents, None),
Err(Error::InvalidBlockIndex(new_block.index))
);
} | rust_cleaned_test_functions.jsonl/118280 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 674
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26041,
7113,
3752,
75198,
13126,
368,
341,
286,
1077,
5206,
28422,
25,
42517,
49,
968,
284,
35822,
480,
49,
968,
486,
1499,
33809,
2561,
16,
84,
23,
26,
220,
18,
17,
2558,
286,
1077,
5206,
469... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_substring_3_args() {
let tests = vec![
("Quadratically", 5, 6, "ratica"),
("Sakila", -5, 3, "aki"),
("Sakila", 2, 0, ""),
("Sakila", 2, -1, ""),
("Sakila", 2, 100, "akila"),
("中文a测试bb", -3, 1, "试"),
("中文a测试bb", -3, 2, "试b"),
("中文a测a试", 2, 1, "文"),
("中文a测a试", 2, 3, "文a测"),
("中文a测a试", -1, 1, "试"),
("中文a测a试", -1, 5, "试"),
("中文a测a试", -6, 20, "中文a测a试"),
("中文a测a试", -7, 5, ""),
("", 1, 1, ""),
("", -1, 1, ""),
];
for (s, pos, len, exp) in tests {
let s = Datum::Bytes(s.as_bytes().to_vec());
let pos = Datum::I64(pos);
let len = Datum::I64(len);
let got = eval_func(ScalarFuncSig::Substring3Args, &[s, pos, len]).unwrap();
assert_eq!(got, Datum::Bytes(exp.as_bytes().to_vec()));
}
let tests = vec![
(
"中文a测a试",
Datum::U64(u64::max_value()),
Datum::I64(5),
"",
),
(
"中文a测a试",
Datum::I64(2),
Datum::U64(u64::max_value()),
"文a测a试",
),
(
"中文a测a试",
Datum::I64(-2),
Datum::U64(u64::max_value()),
"a试",
),
];
for (s, pos, len, exp) in tests {
let s = Datum::Bytes(s.as_bytes().to_vec());
let got = eval_func(ScalarFuncSig::Substring3Args, &[s, pos, len]).unwrap();
assert_eq!(got, Datum::Bytes(exp.as_bytes().to_vec()));
}
} | rust_cleaned_test_functions.jsonl/9117 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1208
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5228,
917,
62,
18,
8384,
368,
341,
286,
1077,
7032,
284,
7486,
90515,
310,
3489,
2183,
14666,
7022,
497,
220,
20,
11,
220,
21,
11,
330,
81,
53297,
4461,
310,
3489,
50,
585,
10524,
497,
481,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_infinities() {
let mut summary = Summary::with_defaults();
summary.add(f64::INFINITY);
assert_eq!(summary.quantile(0.5), None);
summary.add(f64::NEG_INFINITY);
assert_eq!(summary.quantile(0.5), None);
} | rust_cleaned_test_functions.jsonl/126977 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 132
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1243,
5472,
1361,
368,
341,
286,
1077,
5206,
12126,
284,
21517,
486,
4197,
42290,
543,
286,
12126,
1364,
955,
21,
19,
486,
687,
55990,
317,
286,
2060,
10714,
10297,
1708,
77602,
457,
7,
15,
13,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_find_line_ranges_multiple_lines() {
assert_eq!(find_line_ranges(b"a\nbb\nccc\n"), vec![0..2, 2..5, 5..9]);
} | rust_cleaned_test_functions.jsonl/89234 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 79
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21814,
6528,
58748,
45233,
18323,
368,
341,
286,
2060,
10714,
10297,
3903,
6528,
58748,
1883,
56693,
1699,
6066,
1699,
37054,
1699,
3975,
7486,
20703,
15,
496,
17,
11,
220,
17,
496,
20,
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 |
#[test]
fn test_hover_through_expr_in_macro_recursive() {
check(
r#"
macro_rules! id_deep { ($($tt:tt)*) => { $($tt)* } }
macro_rules! id { ($($tt:tt)*) => { id_deep!($($tt)*) } }
fn foo(bar:u32) { let a = id!(ba$0r); }
"#,
expect![[r#"
*bar*
```rust
bar: u32
```
"#]],
);
} | rust_cleaned_test_functions.jsonl/66645 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 256
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
53445,
87399,
21915,
1243,
58810,
66242,
368,
341,
286,
1779,
1006,
310,
435,
2,
698,
32606,
21407,
0,
877,
87044,
314,
1711,
699,
5566,
25,
5566,
8,
3764,
589,
314,
93977,
5566,
4806,
335,
456,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_is_neutral() -> Result<(), PlonkError> {
test_is_neutral_helper::<FqEd354, Param254>()?;
test_is_neutral_helper::<FqEd377, Param377>()?;
test_is_neutral_helper::<FqEd381, Param381>()?;
test_is_neutral_helper::<FqEd381b, Param381b>()?;
test_is_neutral_helper::<Fq377, Param761>()
} | rust_cleaned_test_functions.jsonl/33778 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 178
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6892,
13925,
14253,
368,
1464,
5714,
68843,
1818,
263,
74,
1454,
29,
341,
286,
1273,
6892,
13925,
14253,
10418,
27638,
37,
80,
2715,
18,
20,
19,
11,
6991,
17,
20,
19,
13555,
37445,
286,
1273,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_g1_projective_group() {
let mut rng = test_rng();
let a: G1Projective = rng.gen();
let b: G1Projective = rng.gen();
group_test(a, b);
} | rust_cleaned_test_functions.jsonl/15275 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 85
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1889,
16,
16352,
533,
6288,
368,
341,
262,
1077,
5206,
28422,
284,
1273,
66849,
543,
262,
1077,
264,
25,
479,
16,
7849,
533,
284,
28422,
22822,
543,
262,
1077,
293,
25,
479,
16,
7849,
533,
284... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_sparse_sparse_to_normal() {
let builder = PassThroughHasherBuilder {};
let mut hll: HyperLogLogPlus<u64, PassThroughHasherBuilder> =
HyperLogLogPlus::new(16, builder).unwrap();
hll.add(&0x00010fffffffffff);
assert_eq!(hll.count() as u64, 1);
hll.merge_sparse();
hll.sparse_to_normal();
assert_eq!(hll.count() as u64, 1);
assert!(hll.registers.is_some());
let builder = PassThroughHasherBuilder {};
let mut hll: HyperLogLogPlus<u64, PassThroughHasherBuilder> =
HyperLogLogPlus::new(16, builder).unwrap();
hll.add(&0x00010fffffffffff);
hll.add(&0x0002ffffffffffff);
hll.add(&0x0003000000000000);
hll.add(&0x0003000000000001);
hll.add(&0xff03700000000000);
hll.add(&0xff03080000000000);
hll.merge_sparse();
hll.sparse_to_normal();
assert_eq!(hll.count() as u64, 4);
assert_eq!(hll.registers.as_ref().unwrap().get(1), 5);
assert_eq!(hll.registers.as_ref().unwrap().get(2), 1);
assert_eq!(hll.registers.as_ref().unwrap().get(3), 49);
assert_eq!(hll.registers.as_ref().unwrap().get(0xff03), 5);
} | rust_cleaned_test_functions.jsonl/8347 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 609
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
71123,
71123,
2346,
13973,
368,
341,
286,
1077,
7363,
284,
9970,
23857,
6370,
261,
3297,
20375,
286,
1077,
5206,
305,
654,
25,
32732,
2201,
2201,
21807,
34837,
21,
19,
11,
9970,
23857,
6370,
261,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_request() {
use helix::*;
let req = DeleteVideosRequest::builder()
.id(vec!["234482848".into()])
.build();
// From twitch docs
let data = br#""#.to_vec();
let http_response = http::Response::builder().status(200).body(data).unwrap();
let uri = req.get_uri().unwrap();
assert_eq!(
uri.to_string(),
"https://api.twitch.tv/helix/videos?id=234482848"
);
dbg!(DeleteVideosRequest::parse_response(Some(req), &uri, http_response).unwrap());
} | rust_cleaned_test_functions.jsonl/119719 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 232
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7893,
368,
341,
262,
990,
11338,
941,
56162,
262,
1077,
4232,
284,
10428,
55106,
1900,
486,
17850,
741,
286,
659,
307,
25592,
0,
1183,
17,
18,
19,
19,
23,
17,
23,
19,
23,
3263,
18122,
56024,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_leading_crlf() {
::init_log();
let mut body: &[u8] = b"\r\n\r\n--boundary\r\n\
asdf1234\
\r\n\r\n--boundary--";
let ref mut buf = String::new();
let mut reader = BoundaryReader::from_reader(&mut body, BOUNDARY);
debug!("Consume 1");
assert_eq!(reader.consume_boundary().unwrap(), true);
debug!("Read 1");
let _ = reader.read_to_string(buf).unwrap();
assert_eq!(buf, "asdf1234\r\n");
buf.clear();
debug!("Consume 2");
assert_eq!(reader.consume_boundary().unwrap(), false);
debug!("Read 2 (empty)");
let _ = reader.read_to_string(buf).unwrap();
assert_eq!(buf, "");
} | rust_cleaned_test_functions.jsonl/80590 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 402
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11751,
2228,
666,
2381,
69,
368,
341,
286,
3504,
2327,
5224,
1428,
286,
1077,
5206,
2487,
25,
44590,
84,
23,
60,
284,
293,
11934,
81,
1699,
12016,
1699,
313,
65180,
12016,
1699,
5661,
5108,
438,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_notarized_finalized_height() {
ic_test_utilities::artifact_pool_config::with_test_pool_config(|pool_config| {
let committee = vec![node_test_id(0)];
let interval_length = 4;
let Dependencies { mut pool, .. } = dependencies_with_subnet_params(
pool_config,
subnet_test_id(0),
vec![(
1,
SubnetRecordBuilder::from(&committee)
.with_dkg_interval_length(interval_length)
.build(),
)],
);
pool.advance_round_normal_operation_n(4);
pool.prepare_round().dont_add_catch_up_package().advance();
let block = pool.latest_notarized_blocks().next().unwrap();
pool.finalize_block(&block);
let notarization = pool.validated().notarization().get_highest().unwrap();
let catch_up_package = pool.make_catch_up_package(notarization.height());
pool.insert_validated(catch_up_package);
// remove the latest notarization
pool.remove_validated(notarization);
// remove the latest finalization
let finalization = pool.validated().finalization().get_highest().unwrap();
pool.remove_validated(finalization);
// max notarization now only exists at height 2
assert_eq!(
pool.validated()
.notarization()
.height_range()
.map(|x| x.max),
Some(Height::from(4))
);
let pool_reader = PoolReader::new(&pool);
assert_eq!(pool_reader.get_notarized_height(), Height::from(5));
assert_eq!(pool_reader.get_finalized_height(), Height::from(5));
assert_eq!(pool_reader.get_catch_up_height(), Height::from(5));
})
} | rust_cleaned_test_functions.jsonl/107789 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1003
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
7913,
277,
1506,
20676,
1506,
9561,
368,
341,
286,
17902,
4452,
94044,
486,
63722,
15709,
5332,
486,
4197,
4452,
15709,
5332,
22428,
10285,
5332,
91,
341,
310,
1077,
12801,
284,
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_with_capacity() {
let s = <InlinableString as StringExt>::with_capacity(10);
assert!(StringExt::capacity(&s) >= 10);
} | rust_cleaned_test_functions.jsonl/109712 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 72
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6615,
35603,
368,
341,
286,
1077,
274,
284,
366,
641,
3732,
480,
703,
438,
923,
6756,
6831,
4197,
35603,
7,
16,
15,
317,
286,
2060,
10297,
703,
6756,
486,
37387,
2099,
82,
8,
2604,
220,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_generate_pattern_iterators() {
let rules = create_rules(
r#"
macro_rules! generate_pattern_iterators {
{ double ended; with $(#[$common_stability_attribute:meta])*,
$forward_iterator:ident,
$reverse_iterator:ident, $iterty:ty
} => {
fn foo(){}
}
}
"#,
);
assert_expansion(MacroKind::Items, &rules, r#"generate_pattern_iterators ! ( double ended ; with # [ stable ( feature = "rust1" , since = "1.0.0" ) ] , Split , RSplit , & 'a str );"#,
"fn foo () {}");
} | rust_cleaned_test_functions.jsonl/14732 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 297
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
48851,
21260,
11723,
2973,
368,
341,
1066,
262,
1077,
5601,
284,
1855,
21407,
1006,
286,
435,
2,
698,
32606,
21407,
0,
6923,
21260,
11723,
2973,
341,
286,
314,
1990,
9482,
26,
448,
4930,
2,
3442... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_home_check_networks_toml_exists() {
let dir = tempdir().unwrap();
let home = Home::new(dir.path()).unwrap();
assert_eq!(home.ensure_networks_toml_exists().is_err(), false);
assert_eq!(home.networks_config_path.exists(), true);
} | rust_cleaned_test_functions.jsonl/39544 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 133
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21653,
7200,
20966,
82,
528,
316,
75,
9766,
368,
341,
286,
1077,
5419,
284,
2730,
3741,
1005,
15454,
543,
286,
1077,
2114,
284,
5379,
486,
931,
14161,
3875,
6011,
15454,
543,
286,
2060,
10714,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_get_values_offset() {
let three_four = FizzBuzz::new(3, 4);
let a = three_four.get_values(&2, &6);
let b = vec!["2".to_string(), "fizz".into(),
"buzz".into(), "5".into(), "fizz".into()];
assert_eq!(a, b);
} | rust_cleaned_test_functions.jsonl/74965 | {
"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,
3062,
9146,
6917,
368,
341,
286,
1077,
2326,
56142,
284,
434,
8759,
59473,
486,
931,
7,
18,
11,
220,
19,
317,
286,
1077,
264,
284,
2326,
56142,
670,
9146,
2099,
17,
11,
609,
21,
317,
286,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_vote_authorize_checked() {
let vote_pubkey = Pubkey::new_unique();
let authorized_pubkey = Pubkey::new_unique();
let new_authorized_pubkey = Pubkey::new_unique();
// Test with vanilla authorize accounts
let mut instruction = authorize_checked(
&vote_pubkey,
&authorized_pubkey,
&new_authorized_pubkey,
VoteAuthorize::Voter,
);
instruction.accounts = instruction.accounts[0..2].to_vec();
process_instruction_as_one_arg(&instruction, Err(InstructionError::NotEnoughAccountKeys));
let mut instruction = authorize_checked(
&vote_pubkey,
&authorized_pubkey,
&new_authorized_pubkey,
VoteAuthorize::Withdrawer,
);
instruction.accounts = instruction.accounts[0..2].to_vec();
process_instruction_as_one_arg(&instruction, Err(InstructionError::NotEnoughAccountKeys));
// Test with non-signing new_authorized_pubkey
let mut instruction = authorize_checked(
&vote_pubkey,
&authorized_pubkey,
&new_authorized_pubkey,
VoteAuthorize::Voter,
);
instruction.accounts[3] = AccountMeta::new_readonly(new_authorized_pubkey, false);
process_instruction_as_one_arg(
&instruction,
Err(InstructionError::MissingRequiredSignature),
);
let mut instruction = authorize_checked(
&vote_pubkey,
&authorized_pubkey,
&new_authorized_pubkey,
VoteAuthorize::Withdrawer,
);
instruction.accounts[3] = AccountMeta::new_readonly(new_authorized_pubkey, false);
process_instruction_as_one_arg(
&instruction,
Err(InstructionError::MissingRequiredSignature),
);
// Test with new_authorized_pubkey signer
let vote_account = AccountSharedData::new(100, VoteState::size_of(), &id());
let clock_address = sysvar::clock::id();
let clock_account = account::create_account_shared_data_for_test(&Clock::default());
let default_authorized_pubkey = Pubkey::default();
let authorized_account = create_default_account();
let new_authorized_account = create_default_account();
let transaction_accounts = vec![
(vote_pubkey, vote_account),
(clock_address, clock_account),
(default_authorized_pubkey, authorized_account),
(new_authorized_pubkey, new_authorized_account),
];
let instruction_accounts = vec![
AccountMeta {
pubkey: vote_pubkey,
is_signer: false,
is_writable: false,
},
AccountMeta {
pubkey: clock_address,
is_signer: false,
is_writable: false,
},
AccountMeta {
pubkey: default_authorized_pubkey,
is_signer: true,
is_writable: false,
},
AccountMeta {
pubkey: new_authorized_pubkey,
is_signer: true,
is_writable: false,
},
];
process_instruction(
&serialize(&VoteInstruction::AuthorizeChecked(VoteAuthorize::Voter)).unwrap(),
transaction_accounts.clone(),
instruction_accounts.clone(),
Ok(()),
);
process_instruction(
&serialize(&VoteInstruction::AuthorizeChecked(
VoteAuthorize::Withdrawer,
))
.unwrap(),
transaction_accounts,
instruction_accounts,
Ok(()),
);
} | rust_cleaned_test_functions.jsonl/83689 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1811
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
54360,
22938,
551,
56456,
368,
341,
286,
1077,
6910,
34014,
792,
284,
22611,
792,
486,
931,
21218,
543,
286,
1077,
18630,
34014,
792,
284,
22611,
792,
486,
931,
21218,
543,
286,
1077,
501,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.