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_disruptive_follower() {
setup_for_test();
let mut n1 = new_test_raft(1, vec![1, 2, 3], 10, 1, new_storage());
let mut n2 = new_test_raft(2, vec![1, 2, 3], 10, 1, new_storage());
let mut n3 = new_test_raft(3, vec![1, 2, 3], 10, 1, new_storage());
n1.check_quorum = true;
n2.check_quorum = true;
n3.check_quorum = true;
n1.become_follower(1, INVALID_ID);
n2.become_follower(1, INVALID_ID);
n3.become_follower(1, INVALID_ID);
let mut nt = Network::new(vec![Some(n1), Some(n2), Some(n3)]);
nt.send(vec![new_message(1, 1, MessageType::MsgHup, 0)]);
// check state
assert_eq!(nt.peers[&1].state, StateRole::Leader);
assert_eq!(nt.peers[&2].state, StateRole::Follower);
assert_eq!(nt.peers[&3].state, StateRole::Follower);
// etcd server "advanceTicksForElection" on restart;
// this is to expedite campaign trigger when given larger
// Or leader messages are being delayed while ticks elapse
let timeout = nt.peers[&3].get_election_timeout();
nt.peers
.get_mut(&3)
.unwrap()
.set_randomized_election_timeout(timeout + 2);
let timeout = nt.peers[&3].get_randomized_election_timeout();
for _ in 0..timeout - 1 {
nt.peers.get_mut(&3).unwrap().tick();
}
nt.peers.get_mut(&3).unwrap().tick();
// n1 is still leader yet
// while its heartbeat to candidate n3 is being delayed
// check state
assert_eq!(nt.peers[&1].state, StateRole::Leader);
assert_eq!(nt.peers[&2].state, StateRole::Follower);
assert_eq!(nt.peers[&3].state, StateRole::Candidate);
// check term
// n1.Term == 2
// n2.Term == 2
// n3.Term == 3
assert_eq!(nt.peers[&1].term, 2);
assert_eq!(nt.peers[&2].term, 2);
assert_eq!(nt.peers[&3].term, 3);
// leader heartbeat finally arrives at candidate n3
// heartbeat was sent with lower term than candidate's
let mut msg = new_message(1, 3, MessageType::MsgHeartbeat, 0);
msg.set_term(nt.peers[&1].term);
nt.send(vec![msg]);
// then candidate n3 responds with "pb.MsgAppResp" of higher term
// and leader steps down from a message with higher term
// with higher term can be freed with following election
// check state
assert_eq!(nt.peers[&1].state, StateRole::Follower);
assert_eq!(nt.peers[&2].state, StateRole::Follower);
assert_eq!(nt.peers[&3].state, StateRole::Candidate);
// check term
// n1.Term == 3
// n2.Term == 2
// n3.Term == 3
assert_eq!(nt.peers[&1].term, 3);
assert_eq!(nt.peers[&2].term, 2);
assert_eq!(nt.peers[&3].term, 3);
} | rust_cleaned_test_functions.jsonl/107130 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1179
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9932,
6585,
533,
761,
29034,
368,
341,
262,
6505,
5478,
4452,
543,
262,
1077,
5206,
308,
16,
284,
501,
4452,
62,
2944,
7,
16,
11,
7486,
20703,
16,
11,
220,
17,
11,
220,
18,
1125,
220,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_iter_no_id() {
let mention = "this is not <# actually a mention";
let mut iter = Id::<ChannelMarker>::iter(mention);
assert!(iter.next().is_none());
} | rust_cleaned_test_functions.jsonl/99690 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 91
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11723,
6536,
842,
368,
341,
286,
1077,
6286,
284,
330,
574,
374,
537,
366,
2,
3520,
264,
6286,
876,
286,
1077,
5206,
5367,
284,
5223,
27638,
9629,
20613,
6831,
2015,
7,
29248,
626,
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 |
#[test]
fn test_update_accounts() {
let mut accounts = [(Pubkey::default(), Account::default())];
let mut keyed_accounts = create_keyed_accounts(&mut accounts);
let lua = Lua::new();
set_accounts(&lua, "xs", &keyed_accounts).unwrap();
keyed_accounts[0].account.tokens = 42;
keyed_accounts[0].account.userdata = vec![];
update_accounts(&lua, "xs", &mut keyed_accounts).unwrap();
assert_eq!(keyed_accounts[0].account.tokens, 0);
} | rust_cleaned_test_functions.jsonl/113679 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 235
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8882,
55665,
368,
341,
286,
1077,
5206,
9618,
284,
17826,
29162,
792,
486,
2258,
1507,
8615,
486,
2258,
2140,
935,
286,
1077,
5206,
90529,
55665,
284,
1855,
3097,
291,
55665,
2099,
6984,
9618,
317... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_encodable_rng_serialization() {
let rng = EncodableRng::new();
let serialized = serde_json::to_string(&rng).unwrap();
let _: EncodableRng = serde_json::from_str(&serialized).unwrap();
} | rust_cleaned_test_functions.jsonl/129760 | {
"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,
13781,
69129,
66849,
25602,
2022,
368,
341,
286,
1077,
28422,
284,
10751,
69129,
49,
968,
486,
931,
1428,
286,
1077,
32916,
284,
61570,
9455,
486,
983,
3904,
2099,
69890,
568,
15454,
543,
286,
107... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_static_string_to_hex() {
let plaintxt = "My name is David L. Whitehurst";
let hex = static_to_hex(plaintxt);
assert_eq!("4d79206e616d65206973204461766964204c2e2057686974656875727374",
&hex);
} | rust_cleaned_test_functions.jsonl/33300 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 112
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25360,
3904,
2346,
32655,
368,
972,
262,
1077,
23372,
2252,
284,
330,
5050,
829,
374,
6798,
444,
13,
5807,
69100,
3534,
10217,
12371,
284,
1099,
2346,
32655,
7,
31297,
2252,
736,
262,
2060,
10714,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_clone() {
let str_pool : Pool<String> = Pool::with_size(2);
{
assert_eq!(2, str_pool.size());
let text = str_pool.new_from("cat");
let text_clone = text.clone();
assert_eq!(text, text_clone);
assert_eq!(0, str_pool.size());
}
assert_eq!(2, str_pool.size());
} | rust_cleaned_test_functions.jsonl/121193 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 158
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
54742,
368,
341,
262,
1077,
607,
15709,
549,
22728,
3464,
29,
284,
22728,
486,
4197,
2368,
7,
17,
317,
262,
341,
414,
2060,
10714,
10297,
17,
11,
607,
15709,
2486,
1423,
414,
1077,
1467,
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_validate_config_failures() {
let invalid = "invalid";
let valid_did = DEFAULT_DID;
let valid_ver = DEFAULT_VERKEY;
::utils::libindy::wallet::set_wallet_handle(0);
let mut config: HashMap<String, String> = HashMap::new();
assert_eq!(validate_config(&config).unwrap_err().kind(), VcxErrorKind::MissingWalletKey);
config.insert(CONFIG_WALLET_KEY.to_string(), "password".to_string());
config.insert(CONFIG_INSTITUTION_DID.to_string(), invalid.to_string());
assert_eq!(validate_config(&config).unwrap_err().kind(), VcxErrorKind::InvalidDid);
config.drain();
config.insert(CONFIG_WALLET_KEY.to_string(), "password".to_string());
config.insert(CONFIG_INSTITUTION_VERKEY.to_string(), invalid.to_string());
assert_eq!(validate_config(&config).unwrap_err().kind(), VcxErrorKind::InvalidVerkey);
config.drain();
config.insert(CONFIG_WALLET_KEY.to_string(), "password".to_string());
config.insert(CONFIG_AGENCY_DID.to_string(), invalid.to_string());
assert_eq!(validate_config(&config).unwrap_err().kind(), VcxErrorKind::InvalidDid);
config.drain();
config.insert(CONFIG_WALLET_KEY.to_string(), "password".to_string());
config.insert(CONFIG_AGENCY_VERKEY.to_string(), invalid.to_string());
assert_eq!(validate_config(&config).unwrap_err().kind(), VcxErrorKind::InvalidVerkey);
config.drain();
config.insert(CONFIG_WALLET_KEY.to_string(), "password".to_string());
config.insert(CONFIG_SDK_TO_REMOTE_DID.to_string(), invalid.to_string());
assert_eq!(validate_config(&config).unwrap_err().kind(), VcxErrorKind::InvalidDid);
config.drain();
config.insert(CONFIG_WALLET_KEY.to_string(), "password".to_string());
config.insert(CONFIG_SDK_TO_REMOTE_VERKEY.to_string(), invalid.to_string());
assert_eq!(validate_config(&config).unwrap_err().kind(), VcxErrorKind::InvalidVerkey);
config.drain();
config.insert(CONFIG_WALLET_KEY.to_string(), "password".to_string());
config.insert(CONFIG_REMOTE_TO_SDK_DID.to_string(), invalid.to_string());
assert_eq!(validate_config(&config).unwrap_err().kind(), VcxErrorKind::InvalidDid);
config.drain();
config.insert(CONFIG_WALLET_KEY.to_string(), "password".to_string());
config.insert(CONFIG_SDK_TO_REMOTE_VERKEY.to_string(), invalid.to_string());
assert_eq!(validate_config(&config).unwrap_err().kind(), VcxErrorKind::InvalidVerkey);
config.drain();
config.insert(CONFIG_WALLET_KEY.to_string(), "password".to_string());
config.insert(CONFIG_INSTITUTION_LOGO_URL.to_string(), invalid.to_string());
assert_eq!(validate_config(&config).unwrap_err().kind(), VcxErrorKind::InvalidUrl);
config.drain();
} | rust_cleaned_test_functions.jsonl/1644 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1205
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
42681,
5332,
22121,
1413,
368,
341,
286,
1077,
8318,
284,
330,
11808,
876,
286,
1077,
2697,
814,
307,
284,
11955,
1557,
915,
280,
286,
1077,
2697,
26042,
284,
11955,
14815,
4784,
401,
286,
3504,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_filter_shebang() {
assert_eq!(filter_shebang(b"".to_vec()), b"");
assert_eq!(filter_shebang(b"#".to_vec()), b"#");
assert_eq!(filter_shebang(b"#!".to_vec()), b"");
assert_eq!(filter_shebang(b"#!\n\n".to_vec()), b"\n\n");
let code = b"#!/usr/bin/env deno\nconsole.log('hello');\n".to_vec();
assert_eq!(filter_shebang(code), b"\nconsole.log('hello');\n");
} | rust_cleaned_test_functions.jsonl/75264 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 198
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8727,
643,
383,
27174,
368,
341,
262,
2060,
10714,
10297,
5315,
643,
383,
27174,
1883,
69355,
983,
13251,
11858,
293,
1,
797,
262,
2060,
10714,
10297,
5315,
643,
383,
27174,
1883,
57676,
3263,
983... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_right_encode() {
let mut buf = [0; 9];
let n = right_encode(&mut buf, 0);
assert_eq!(&buf[n..], [0, 1]);
let n = right_encode(&mut buf, 128);
assert_eq!(&buf[n..], [128, 1]);
let n = right_encode(&mut buf, 65536);
assert_eq!(&buf[n..], [1, 0, 0, 3]);
let n = right_encode(&mut buf, 4096);
assert_eq!(&buf[n..], [16, 0, 2]);
let n = right_encode(&mut buf, 18446744073709551615);
assert_eq!(&buf[n..], [255, 255, 255, 255, 255, 255, 255, 255, 8]);
let n = right_encode(&mut buf, 12345);
assert_eq!(&buf[n..], [48, 57, 2]);
} | rust_cleaned_test_functions.jsonl/43775 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 283
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10539,
11224,
368,
341,
262,
1077,
5206,
6607,
284,
508,
15,
26,
220,
24,
935,
262,
1077,
308,
284,
1290,
11224,
2099,
6984,
6607,
11,
220,
15,
317,
262,
2060,
10714,
0,
2099,
5909,
7669,
496,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_mac_to_eui() {
assert_eq!(
Mac::new([0x00, 0x1a, 0xaa, 0x12, 0x34, 0x56]).to_eui64(),
[0x02, 0x1a, 0xaa, 0xff, 0xfe, 0x12, 0x34, 0x56]
);
assert_eq!(
Mac::new([0x00, 0x1a, 0xaa, 0x12, 0x34, 0x56]).to_eui64_with_magic([0xfe, 0xfe]),
[0x02, 0x1a, 0xaa, 0xfe, 0xfe, 0x12, 0x34, 0x56]
);
} | rust_cleaned_test_functions.jsonl/19935 | {
"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,
22802,
2346,
2204,
1963,
368,
341,
286,
2060,
10714,
33673,
310,
7401,
486,
931,
2561,
15,
87,
15,
15,
11,
220,
15,
87,
16,
64,
11,
220,
15,
43300,
11,
220,
15,
87,
16,
17,
11,
220,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_serialize_delete() {
let cmd = DevopsCommand {
target_actor_selection: "/system/sharding/connection".to_string(),
headers: Default::default(),
piggyback_command: PiggybackCommand::DeleteConnection {
connection_id: "connection-id".to_string(),
},
};
assert_eq!(
serde_json::to_value(cmd).unwrap(),
json!({
"targetActorSelection": "/system/sharding/connection",
"headers": {
"aggregate": false
},
"piggybackCommand": {
"type": "connectivity.commands:deleteConnection",
"connectionId": "connection-id"
}
})
);
} | rust_cleaned_test_functions.jsonl/61458 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 414
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
88686,
11353,
368,
341,
286,
1077,
5439,
284,
6040,
3721,
4062,
341,
310,
2169,
54818,
23672,
25,
3521,
8948,
14688,
28410,
93406,
3263,
983,
3904,
3148,
310,
7102,
25,
7899,
486,
2258,
3148,
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_adjacently_b_de() {
let s = "(type:\"VariantB\",content:(foo:1,bar:2,),)";
let e = EnumStructAdjacently::VariantB {
foo: 1,
bar: 2,
};
test_de(s, e);
} | rust_cleaned_test_functions.jsonl/110480 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 112
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
42559,
580,
4402,
880,
2259,
368,
341,
262,
1077,
274,
284,
11993,
1313,
75035,
20746,
33,
16215,
1796,
3269,
7975,
25,
16,
11,
2257,
25,
17,
59564,
24023,
262,
1077,
384,
284,
14086,
9422,
5486... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_map_from_iter_panic() {
let _: SgMap<usize, usize, DEFAULT_CAPACITY> =
SgMap::from_iter((0..(DEFAULT_CAPACITY + 1)).map(|val| (val, val)));
} | rust_cleaned_test_functions.jsonl/18647 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 89
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5376,
5673,
11723,
620,
31270,
368,
341,
262,
1077,
58536,
328,
70,
2227,
90244,
11,
22301,
11,
11955,
92153,
29,
4035,
286,
328,
70,
2227,
486,
1499,
11723,
1188,
15,
496,
7,
17285,
92153,
488,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_rfc_section_5_iter() {
let mut k = BASEPOINT;
let mut u = BASEPOINT;
// 1 iter
let ret = key_agreement(&PrivateKey::from(k), &PublicKey::from(u)).unwrap();
u = k;
k = ret.value;
let mut expected = SharedKey::from([0u8; 32]);
hex::decode_to_slice(
"422c8e7a6227d7bca1350b3e2bb7279f7897b87bb6854b783c60e80311ae3079",
&mut expected.value,
)
.unwrap();
assert_eq!(k, expected.value, "Failed after 1 iter");
for _ in 0..999 {
let ret = key_agreement(&PrivateKey::from(k), &PublicKey::from(u)).unwrap();
u = k;
k = ret.value;
}
hex::decode_to_slice(
"684cf59ba83309552800ef566f2f4d3c1c3887c49360e3875f2eb94d99532c51",
&mut expected.value,
)
.unwrap();
assert_eq!(k, expected.value, "Failed after 1.000 iter");
} | rust_cleaned_test_functions.jsonl/4454 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 533
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1710,
8316,
16221,
62,
20,
11723,
368,
341,
286,
1077,
5206,
595,
284,
22194,
21531,
280,
286,
1077,
5206,
575,
284,
22194,
21531,
401,
286,
442,
220,
16,
5367,
198,
286,
1077,
2112,
284,
1376,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_jwt_unpack() {
let token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRGUiLCJpYXQiOjE1MTYyMzkwMjJ9.1bxegY2QzMgmi4VjfhxtumdUCSGl8ohztW8878wScAA";
let result = jwt_unpack(token);
println!("{:?}", result)
} | rust_cleaned_test_functions.jsonl/128610 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 197
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
95576,
54889,
368,
341,
286,
1077,
3950,
284,
330,
84609,
49039,
38,
5855,
81096,
45064,
52,
89,
40,
16,
56494,
3872,
641,
49,
20,
66,
11237,
21,
40,
48495,
55,
11287,
41,
24,
13,
84609,
48655... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_empty() -> Result<()> {
let mut s = b"<191>1 2021-03-18T20:30:00.123Z - - - - - message".to_vec();
let mut codec = test_codec();
let decoded = codec.decode(s.as_mut_slice(), 0)?.unwrap();
let expected = literal!({
"severity": "debug",
"facility": "local7",
"msg": "message",
"protocol": "RFC5424",
"protocol_version": 1,
"timestamp": 1_616_099_400_123_000_000_u64
});
assert_eq!(
tremor_script::utils::sorted_serialize(&expected)?,
tremor_script::utils::sorted_serialize(&decoded)?
);
Ok(())
} | rust_cleaned_test_functions.jsonl/89206 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 364
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15227,
15124,
368,
1464,
5714,
71698,
341,
286,
1077,
5206,
274,
284,
293,
22476,
16,
24,
16,
29,
16,
220,
17,
15,
17,
16,
12,
15,
18,
12,
16,
23,
51,
17,
15,
25,
18,
15,
25,
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... | 4 |
#[test]
fn test_only_cached_option_once() {
assert!(only_cached_option_once("z".to_string(), true).is_none());
let a = only_cached_option_once("a".to_string(), false).unwrap();
let b = only_cached_option_once("b".to_string(), false).unwrap();
assert_eq!(a, b);
sleep(Duration::new(1, 0));
let b = only_cached_option_once("b".to_string(), false).unwrap();
assert_eq!(a, b);
} | rust_cleaned_test_functions.jsonl/13141 | {
"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,
18410,
64369,
9672,
7630,
368,
341,
262,
2060,
10297,
3243,
64369,
9672,
7630,
445,
89,
3263,
983,
3904,
1507,
830,
568,
285,
31488,
1423,
262,
1077,
264,
284,
1172,
64369,
9672,
7630,
445,
64,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_redc() {
let a = u256h!("0548c135e26faa9c977fb2eda057b54b2e0baa9a77a0be7c80278f4f03462d4c");
let b = u256h!("024385f6bebc1c496e09955db534ef4b1eaff9a78e27d4093cfa8f7c8f886f6b");
let c = u256h!("012e440f0965e7029c218b64f1010006b5c4ba8b1497c4174a32fec025c197bc");
assert_eq!(redc_inline(M3, &a, &b), c);
} | rust_cleaned_test_functions.jsonl/10080 | {
"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,
26058,
66,
368,
341,
286,
1077,
264,
284,
575,
17,
20,
21,
71,
17223,
15,
20,
19,
23,
66,
16,
18,
20,
68,
17,
21,
3632,
64,
24,
66,
24,
22,
22,
10798,
17,
13830,
15,
20,
22,
65,
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... | 1 |
#[test]
fn test_uint_from_div_no_panic() {
assert_eq!(
Uint256::from(6u8).div(Uint256::from(2u8)),
Uint256::from(3u8)
);
} | rust_cleaned_test_functions.jsonl/118525 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 89
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15807,
5673,
16237,
6536,
620,
31270,
368,
341,
262,
2060,
10714,
33673,
286,
27883,
17,
20,
21,
486,
1499,
7,
21,
84,
23,
568,
611,
12317,
396,
17,
20,
21,
486,
1499,
7,
17,
84,
23,
6965,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_collect_accounts_to_store() {
let keypair0 = Keypair::new();
let keypair1 = Keypair::new();
let pubkey = solana_sdk::pubkey::new_rand();
let account0 = AccountSharedData::new(1, 0, &Pubkey::default());
let account1 = AccountSharedData::new(2, 0, &Pubkey::default());
let account2 = AccountSharedData::new(3, 0, &Pubkey::default());
let rent_collector = RentCollector::default();
let instructions = vec![CompiledInstruction::new(2, &(), vec![0, 1])];
let message = Message::new_with_compiled_instructions(
1,
0,
2,
vec![keypair0.pubkey(), pubkey, native_loader::id()],
Hash::default(),
instructions,
);
let transaction_accounts0 = vec![
(message.account_keys[0], account0),
(message.account_keys[1], account2.clone()),
];
let tx0 = new_sanitized_tx(&[&keypair0], message, Hash::default());
let instructions = vec![CompiledInstruction::new(2, &(), vec![0, 1])];
let message = Message::new_with_compiled_instructions(
1,
0,
2,
vec![keypair1.pubkey(), pubkey, native_loader::id()],
Hash::default(),
instructions,
);
let transaction_accounts1 = vec![
(message.account_keys[0], account1),
(message.account_keys[1], account2),
];
let tx1 = new_sanitized_tx(&[&keypair1], message, Hash::default());
let loaded0 = (
Ok(LoadedTransaction {
accounts: transaction_accounts0,
program_indices: vec![],
rent: 0,
rent_debits: RentDebits::default(),
estimated_execution_cost: 0,
}),
None,
);
let loaded1 = (
Ok(LoadedTransaction {
accounts: transaction_accounts1,
program_indices: vec![],
rent: 0,
rent_debits: RentDebits::default(),
estimated_execution_cost: 0,
}),
None,
);
let mut loaded = vec![loaded0, loaded1];
let accounts = Accounts::new_with_config_for_tests(
Vec::new(),
&ClusterType::Development,
AccountSecondaryIndexes::default(),
false,
AccountShrinkThreshold::default(),
);
{
accounts
.account_locks
.lock()
.unwrap()
.insert_new_readonly(&pubkey);
}
let txs = vec![tx0, tx1];
let programs = vec![(Ok(()), None), (Ok(()), None)];
let collected_accounts = accounts.collect_accounts_to_store(
&txs,
&programs,
loaded.as_mut_slice(),
&rent_collector,
&Hash::default(),
0,
true,
true, // leave_nonce_on_success
);
assert_eq!(collected_accounts.len(), 2);
assert!(collected_accounts
.iter()
.any(|(pubkey, _account)| *pubkey == &keypair0.pubkey()));
assert!(collected_accounts
.iter()
.any(|(pubkey, _account)| *pubkey == &keypair1.pubkey()));
// Ensure readonly_lock reflects lock
assert_eq!(
*accounts
.account_locks
.lock()
.unwrap()
.readonly_locks
.get(&pubkey)
.unwrap(),
1
);
} | rust_cleaned_test_functions.jsonl/49728 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1957
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
68140,
55665,
2346,
14809,
368,
341,
286,
1077,
1376,
12670,
15,
284,
6569,
1082,
1310,
486,
931,
543,
286,
1077,
1376,
12670,
16,
284,
6569,
1082,
1310,
486,
931,
543,
286,
1077,
95116,
284,
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... | 1 |
#[test]
fn test_sum_relationship_proof() {
let c1_value = 30u64;
let c2_value = 10u64;
let c1_blinding = get_random_scalar();
let c2_blinding = get_random_scalar();
let c3_blinding = get_random_scalar();
let value_basepoint = *BASEPOINT_G1;
let blinding_basepoint = *BASEPOINT_G2;
let proof = prove_sum_relationship(
c1_value,
c2_value,
&c1_blinding,
&c2_blinding,
&c3_blinding,
&value_basepoint,
&blinding_basepoint,
);
let c1_point = make_commitment_point(
c1_value,
&c1_blinding,
&value_basepoint,
&blinding_basepoint,
);
let c2_point = make_commitment_point(
c2_value,
&c2_blinding,
&value_basepoint,
&blinding_basepoint,
);
// c3 = c1 + c2
let c3_point = make_commitment_point(
c1_value + c2_value,
&c3_blinding,
&value_basepoint,
&blinding_basepoint,
);
assert_eq!(
true,
verify_sum_relationship(
&c1_point,
&c2_point,
&c3_point,
&proof,
&value_basepoint,
&blinding_basepoint
)
);
} | rust_cleaned_test_functions.jsonl/118809 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 875
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10160,
69031,
86757,
368,
341,
286,
1077,
272,
16,
3142,
284,
220,
18,
15,
84,
21,
19,
280,
286,
1077,
272,
17,
3142,
284,
220,
16,
15,
84,
21,
19,
280,
286,
1077,
272,
16,
13141,
3961,
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_syscall_sol_log_u64() {
prepare_mockup!(
invoke_context,
transaction_context,
program_id,
bpf_loader::id(),
);
let cost = invoke_context.get_compute_budget().log_64_units;
let mut syscall_sol_log_u64 = SyscallLogU64 {
invoke_context: Rc::new(RefCell::new(&mut invoke_context)),
};
syscall_sol_log_u64
.invoke_context
.borrow_mut()
.get_compute_meter()
.borrow_mut()
.mock_set_remaining(cost);
let config = Config::default();
let memory_mapping = MemoryMapping::new::<UserError>(vec![], &config).unwrap();
let mut result: Result<u64, EbpfError<BpfError>> = Ok(0);
syscall_sol_log_u64.call(1, 2, 3, 4, 5, &memory_mapping, &mut result);
result.unwrap();
assert_eq!(
syscall_sol_log_u64
.invoke_context
.borrow()
.get_log_collector()
.unwrap()
.borrow()
.get_recorded_content(),
&["Program log: 0x1, 0x2, 0x3, 0x4, 0x5".to_string()]
);
} | rust_cleaned_test_functions.jsonl/69888 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 679
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20344,
6659,
53668,
5224,
7300,
21,
19,
368,
341,
286,
10549,
34134,
454,
33673,
310,
19873,
8467,
345,
310,
7745,
8467,
345,
310,
2025,
842,
345,
310,
293,
15897,
22139,
486,
307,
3148,
286,
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_vec_truncate_drop() {
static mut drops: usize = 0;
#[derive(Clone)]
struct Elem(usize);
impl Drop for Elem {
fn drop(&mut self) {
unsafe { drops += 1; }
}
}
let mut v = Soa2::new();
v.push_all(
&[Elem(1), Elem(2), Elem(3), Elem(4), Elem(5)][..],
&[Elem(10), Elem(20), Elem(30), Elem(40), Elem(50)][..]);
assert_eq!(unsafe { drops }, 10 + 0);
v.truncate(3);
assert_eq!(unsafe { drops }, 10 + 4);
v.truncate(0);
assert_eq!(unsafe { drops }, 10 + 10);
} | rust_cleaned_test_functions.jsonl/121406 | {
"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,
13251,
3547,
26900,
29584,
368,
341,
262,
1099,
5206,
21025,
25,
22301,
284,
220,
15,
280,
262,
11506,
27098,
65297,
5563,
262,
2036,
78768,
7,
51878,
317,
262,
11605,
15733,
369,
78768,
341,
286,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_nfd_chars() {
macro_rules! t {
($input: expr, $expected: expr) => {
assert_eq!($input.nfd_chars().collect::<String>(), $expected);
}
}
t!("abc", "abc");
t!("\u{1e0b}\u{1c4}", "d\u{307}\u{1c4}");
t!("\u{2026}", "\u{2026}");
t!("\u{2126}", "\u{3a9}");
t!("\u{1e0b}\u{323}", "d\u{323}\u{307}");
t!("\u{1e0d}\u{307}", "d\u{323}\u{307}");
t!("a\u{301}", "a\u{301}");
t!("\u{301}a", "\u{301}a");
t!("\u{d4db}", "\u{1111}\u{1171}\u{11b6}");
t!("\u{ac1c}", "\u{1100}\u{1162}");
} | rust_cleaned_test_functions.jsonl/2476 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 420
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1089,
6902,
37418,
368,
341,
286,
18072,
21407,
0,
259,
341,
310,
1711,
1355,
25,
15169,
11,
400,
7325,
25,
15169,
8,
589,
341,
394,
2060,
10714,
0,
699,
1355,
1253,
6902,
37418,
1005,
17384,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_member_return_reference() {
let hdr = indoc! {"
#include <string>
class A {
public:
virtual const std::string& get_str() { return a; }
virtual ~A() {}
std::string a;
};
"};
let rs = quote! {
let mut b = ffi::A::make_unique();
b.pin_mut().get_str();
};
run_test("", hdr, rs, &["A"], &[]);
} | rust_cleaned_test_functions.jsonl/9795 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 220
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19388,
12511,
25433,
368,
341,
262,
1077,
36615,
284,
1257,
509,
0,
314,
698,
286,
671,
997,
366,
917,
397,
286,
536,
362,
341,
286,
584,
510,
310,
4108,
733,
1460,
486,
917,
5,
633,
2895,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_export_named_declaration() {
expect_printed("export { a }", "export { a };\n");
expect_printed("export { a as b }", "export { a as b };\n");
expect_printed("export { a } from \"b\"", "export { a } from \"b\";\n");
expect_printed(
"export { a as b } from \"c\"",
"export { a as b } from \"c\";\n",
);
expect_printed(
"export { default as a } from \"b\";",
"export { default as a } from \"b\";\n",
);
expect_printed("export function a() {}", "export function a() {}");
expect_printed("export function* a() {}", "export function* a() {}");
expect_printed("export const a = 1;", "export const a = 1;\n");
expect_printed("export class A {}", "export class A {}");
expect_printed("export class A extends B {}", "export class A extends B {}");
expect_printed("export class A { b() {} }", "export class A { b() {} }");
} | rust_cleaned_test_functions.jsonl/93447 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 351
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
27114,
71834,
77926,
368,
341,
262,
1720,
10064,
291,
445,
1533,
314,
264,
335,
497,
330,
1533,
314,
264,
335,
17882,
77,
797,
262,
1720,
10064,
291,
445,
1533,
314,
264,
438,
293,
335,
497,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_favicon_url_fallback() {
let base = favicon_url(
None,
"http://example.org/post/with/some/long/path?and=query&also=presents",
);
assert!(base.is_ok());
assert_eq!(base.unwrap(), "http://example.org/favicon.ico");
} | rust_cleaned_test_functions.jsonl/64940 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 154
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
761,
27921,
2903,
761,
3420,
368,
341,
286,
1077,
2331,
284,
82804,
2903,
1006,
310,
2240,
345,
310,
330,
1254,
1110,
8687,
2659,
29996,
14,
4197,
2687,
635,
14,
4825,
50976,
30,
437,
79194,
5,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_get_basic_blocks() {
let context = Context::create();
let module = context.create_module("test");
let bool_type = context.bool_type();
let fn_type = bool_type.fn_type(&[], false);
let function = module.add_function("testing", fn_type, None);
assert_eq!(function.get_name().to_str(), Ok("testing"));
assert_eq!(
fn_type
.get_return_type()
.unwrap()
.into_int_type()
.get_bit_width(),
1
);
assert!(function.get_last_basic_block().is_none());
assert_eq!(function.get_basic_blocks().len(), 0);
let basic_block = context.append_basic_block(function, "entry");
let last_basic_block = function
.get_last_basic_block()
.expect("Did not find expected basic block");
assert_eq!(last_basic_block, basic_block);
let basic_blocks = function.get_basic_blocks();
assert_eq!(basic_blocks.len(), 1);
assert_eq!(basic_blocks[0], basic_block);
} | rust_cleaned_test_functions.jsonl/125601 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 421
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
34729,
25201,
368,
341,
262,
1077,
2266,
284,
9608,
486,
3182,
543,
262,
1077,
4688,
284,
2266,
2520,
10750,
445,
1944,
3071,
262,
1077,
1807,
1819,
284,
2266,
28791,
1819,
543,
262,
1077,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_call_add_cycles_no_effect_when_perform_not_called() {
with_hypervisor(|hypervisor, tmp_path| {
let (canister, _, _, _) = execute_update(
&hypervisor,
r#"(module
(import "ic0" "call_new"
(func $ic0_call_new
(param i32 i32)
(param $method_name_src i32) (param $method_name_len i32)
(param $reply_fun i32) (param $reply_env i32)
(param $reject_fun i32) (param $reject_env i32)
))
(import "ic0" "call_cycles_add" (func $ic0_call_cycles_add (param $amount i64)))
(func $test
(call $ic0_call_new
(i32.const 100) (i32.const 10) ;; callee canister id = 777
(i32.const 0) (i32.const 18) ;; refers to "some_remote_method" on the heap
(i32.const 11) (i32.const 22) ;; fictive on_reply closure
(i32.const 33) (i32.const 44) ;; fictive on_reject closure
)
(call $ic0_call_cycles_add
(i64.const 10000000000) ;; amount of cycles used to be transferred
))
(export "canister_update test" (func $test))
(memory $memory 1)
(export "memory" (memory $memory))
(data (i32.const 0) "some_remote_method XYZ")
(data (i32.const 100) "\09\03\00\00\00\00\00\00\ff\01")
)"#,
"test",
EMPTY_PAYLOAD,
None,
tmp_path,
);
assert_eq!(canister.system_state.queues.output_queues_len(), 0);
assert_balance_equals(
INITIAL_CYCLES,
canister.system_state.cycles_balance,
BALANCE_EPSILON,
);
});
} | rust_cleaned_test_functions.jsonl/57858 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1193
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13429,
2891,
68970,
6536,
27125,
47636,
5678,
627,
7913,
27859,
368,
341,
262,
448,
1523,
1082,
31396,
22428,
78243,
31396,
11,
4174,
2638,
91,
341,
286,
1077,
320,
4814,
1571,
11,
8358,
8358,
274... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_null_equal() {
let a = NullArray::new(12);
let a = a.data();
let b = NullArray::new(12);
let b = b.data();
test_equal(&a, &b, true);
let b = NullArray::new(10);
let b = b.data();
test_equal(&a, &b, false);
// Test the case where offset != 0
let a_slice = a.slice(2, 3);
let b_slice = b.slice(1, 3);
test_equal(&a_slice, &b_slice, true);
let a_slice = a.slice(5, 4);
let b_slice = b.slice(3, 3);
test_equal(&a_slice, &b_slice, false);
} | rust_cleaned_test_functions.jsonl/24203 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 307
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15162,
11478,
368,
341,
286,
1077,
264,
284,
18084,
1857,
486,
931,
7,
16,
17,
317,
286,
1077,
264,
284,
264,
2196,
543,
286,
1077,
293,
284,
18084,
1857,
486,
931,
7,
16,
17,
317,
286,
1077... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_null_buffer_ref() {
let mut bit_v: [u8; 2] = [0; 2];
bit_util::set_bit(&mut bit_v, 0);
bit_util::set_bit(&mut bit_v, 3);
bit_util::set_bit(&mut bit_v, 10);
let arr_data = ArrayData::builder(DataType::Int32)
.len(16)
.null_bit_buffer(Buffer::from(bit_v))
.build();
assert!(arr_data.null_buffer().is_some());
assert_eq!(&bit_v, arr_data.null_buffer().unwrap().as_slice());
} | rust_cleaned_test_functions.jsonl/133940 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 259
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15162,
7776,
7793,
368,
341,
286,
1077,
5206,
2699,
2273,
25,
508,
84,
23,
26,
220,
17,
60,
284,
508,
15,
26,
220,
17,
935,
286,
2699,
18974,
486,
746,
13996,
2099,
6984,
2699,
2273,
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_method_eq() {
assert_eq!(Method::GET, Method::GET);
assert_eq!(Method::GET, "GET");
assert_eq!(&Method::GET, "GET");
assert_eq!("GET", Method::GET);
assert_eq!("GET", &Method::GET);
assert_eq!(&Method::GET, Method::GET);
assert_eq!(Method::GET, &Method::GET);
} | rust_cleaned_test_functions.jsonl/67359 | {
"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,
9032,
10714,
368,
341,
262,
2060,
10714,
10297,
3523,
486,
3806,
11,
6730,
486,
3806,
317,
262,
2060,
10714,
10297,
3523,
486,
3806,
11,
330,
3806,
797,
262,
2060,
10714,
0,
2099,
3523,
486,
380... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_highest_value_achieved() {
let inputs = to_string_vector("test_inputs/day_8_part_1.txt").unwrap();
let mut test_registers = Registers::new(&inputs);
assert_eq!(test_registers.highest_register_value_achieved, 0);
test_registers.run_instructions();
assert_eq!(test_registers.highest_register_value_achieved, 10);
} | rust_cleaned_test_functions.jsonl/113415 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 162
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1523,
7504,
3142,
62,
610,
30977,
368,
341,
286,
1077,
11127,
284,
311,
3904,
12247,
445,
1944,
28557,
44739,
62,
23,
10495,
62,
16,
3909,
1827,
15454,
543,
286,
1077,
5206,
1273,
78360,
284,
54... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_full() {
let engine = TestEngineBuilder::new().build().unwrap();
let engine_lock = Arc::new(Mutex::new(engine.clone()));
let read_pool = readpool::Builder::from_config(&readpool::Config {
normal_concurrency: 1,
max_tasks_per_worker_normal: 2,
..readpool::Config::default_for_test()
})
.name_prefix("cop-test-full")
.after_start(move || set_tls_engine(engine_lock.lock().unwrap().clone()))
.before_stop(|| destroy_tls_engine::<RocksEngine>())
.build();
let cop = Endpoint::<RocksEngine>::new(&Config::default(), read_pool);
let (tx, rx) = mpsc::channel();
// first 2 requests are processed as normal and laters are returned as errors
for i in 0..5 {
let mut response = coppb::Response::default();
response.set_data(vec![1, 2, i]);
let mut context = kvrpcpb::Context::default();
context.set_priority(kvrpcpb::CommandPri::Normal);
let handler_builder = Box::new(|_, _: &_| {
Ok(UnaryFixture::new_with_duration(Ok(response), 1000).into_boxed())
});
let result_of_future =
cop.handle_unary_request(ReqContext::default_for_test(), handler_builder);
match result_of_future {
Err(full_error) => {
tx.send(Err(full_error)).unwrap();
}
Ok(future) => {
let tx = tx.clone();
thread::spawn(move || {
tx.send(future.wait()).unwrap();
});
}
}
thread::sleep(Duration::from_millis(100));
}
// verify
for _ in 2..5 {
assert!(rx.recv().unwrap().is_err());
}
for i in 0..2 {
let resp = rx.recv().unwrap().unwrap();
assert_eq!(resp.get_data(), [1, 2, i]);
assert!(!resp.has_region_error());
}
} | rust_cleaned_test_functions.jsonl/40859 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1059
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16372,
368,
341,
286,
1077,
4712,
284,
3393,
4571,
3297,
486,
931,
1005,
5834,
1005,
15454,
1428,
286,
1077,
4712,
9818,
284,
19689,
486,
931,
3189,
9371,
486,
931,
48974,
15997,
7392,
286,
1077,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
#[test]
fn test_chunks() {
// Set 1 Challenge 6
let input = &[1, 2, 3, 4, 5, 6];
let expected = vec![vec![1, 4], vec![2, 5], vec![3, 6]];
assert_eq!(chunks(input, 3), expected);
} | rust_cleaned_test_functions.jsonl/74994 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 119
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
65470,
368,
341,
286,
442,
2573,
220,
16,
25257,
220,
21,
198,
286,
1077,
1946,
284,
44590,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11,
220,
21,
935,
286,
1077,
3601,
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_setlint() {
let hv = hypervisor::new().unwrap();
let vm = hv.create_vm().expect("new VM fd creation failed");
assert!(hv.check_required_extensions().is_ok());
// Calling get_lapic will fail if there is no irqchip before hand.
assert!(vm.create_irq_chip().is_ok());
let vcpu = vm.create_vcpu(0, None).unwrap();
let klapic_before: LapicState = vcpu.get_lapic().unwrap();
// Compute the value that is expected to represent LVT0 and LVT1.
let lint0 = get_klapic_reg(&klapic_before, APIC_LVT0);
let lint1 = get_klapic_reg(&klapic_before, APIC_LVT1);
let lint0_mode_expected = set_apic_delivery_mode(lint0, APIC_MODE_EXTINT);
let lint1_mode_expected = set_apic_delivery_mode(lint1, APIC_MODE_NMI);
set_lint(&vcpu).unwrap();
// Compute the value that represents LVT0 and LVT1 after set_lint.
let klapic_actual: LapicState = vcpu.get_lapic().unwrap();
let lint0_mode_actual = get_klapic_reg(&klapic_actual, APIC_LVT0);
let lint1_mode_actual = get_klapic_reg(&klapic_actual, APIC_LVT1);
assert_eq!(lint0_mode_expected, lint0_mode_actual);
assert_eq!(lint1_mode_expected, lint1_mode_actual);
} | rust_cleaned_test_functions.jsonl/38423 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 586
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2602,
14957,
368,
341,
286,
1077,
22747,
284,
9751,
31396,
486,
931,
1005,
15454,
543,
286,
1077,
10995,
284,
22747,
2520,
39008,
1005,
17119,
445,
931,
17792,
12414,
9688,
4641,
797,
286,
2060,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_decode_valid() {
let converter = Base64Converter::new();
let options = Options {
input_type: String::from("all"),
verbose: false,
reverse: false,
converter_specific: HashMap::new(),
};
assert_eq!(
converter.prettify(&String::from("aGVsbG8gd29ybGQh"), &options),
Ok(String::from("hello world!"))
);
assert_eq!(
converter.prettify(&String::from("SGkkQA=="), &options),
Ok(String::from("Hi$@"))
);
} | rust_cleaned_test_functions.jsonl/83344 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 300
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15227,
8337,
368,
341,
286,
1077,
27058,
284,
5351,
21,
19,
14920,
486,
931,
543,
286,
1077,
2606,
284,
14566,
341,
310,
1946,
1819,
25,
923,
486,
1499,
445,
541,
4461,
310,
13694,
25,
895,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_third_order_problem_rkf45_adaptive() -> Result<(), Error> {
let alpha = 0.1;
let square = |x: f64| -> f64 { x * x };
let dydt = |t: f64, y: &[f64]| -> Vec<f64> {
vec![y[1], y[2], -12.0 * square(alpha) * t * y[0] - 4.0 * square(alpha * t) * y[1]]
};
let y_true = |t: f64| -> f64 { f64::cos(alpha * square(t)) };
let options = AdaptiveOdeSolverOptions {
t_initial: 0.0,
t_final: 4.0,
dt_initial: 0.25,
error_control: ErrorControlOptions::simple(1e-6),
};
let mut y = [1.0, 0.0, 0.0];
rkf45_adaptive(&mut y, &dydt, &options)?;
let actual_error = (y_true(options.t_final) - y[0]).abs();
assert_lt!(actual_error, 1e-4);
assert_gt!(actual_error, 1e-7);
Ok(())
} | rust_cleaned_test_functions.jsonl/23085 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 477
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
79519,
7869,
60139,
1710,
81869,
19,
20,
10027,
27781,
368,
1464,
5714,
68843,
4600,
29,
341,
286,
1077,
8287,
284,
220,
15,
13,
16,
280,
286,
1077,
9334,
284,
760,
87,
25,
282,
21,
19,
91,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_possible_intersection() {
let (s, c) = fixture_shapes("two_shapes.geojson");
let mut q: BinaryHeap<Rc<SweepEvent<f64>>> = BinaryHeap::new();
let (se1, _other1) = make_simple(s.exterior().0[3], s.exterior().0[2], true);
let (se2, _other2) = make_simple(c.exterior().0[0], c.exterior().0[1], false);
assert_eq!(possible_intersection(&se1, &se2, &mut q), 1);
assert_eq!(q.len(), 4);
let mut e = q.pop().unwrap();
assert_eq!(
e.point,
Coordinate {
x: 100.79403384562251,
y: 233.41363754101192
}
);
assert_eq!(e.get_other_event().unwrap().point, Coordinate { x: 56.0, y: 181.0 });
e = q.pop().unwrap();
assert_eq!(
e.point,
Coordinate {
x: 100.79403384562251,
y: 233.41363754101192
}
);
assert_eq!(e.get_other_event().unwrap().point, Coordinate { x: 16.0, y: 282.0 });
e = q.pop().unwrap();
assert_eq!(
e.point,
Coordinate {
x: 100.79403384562251,
y: 233.41363754101192
}
);
assert_eq!(e.get_other_event().unwrap().point, Coordinate { x: 153.0, y: 203.5 });
e = q.pop().unwrap();
assert_eq!(
e.point,
Coordinate {
x: 100.79403384562251,
y: 233.41363754101192
}
);
assert_eq!(e.get_other_event().unwrap().point, Coordinate { x: 153.0, y: 294.5 });
} | rust_cleaned_test_functions.jsonl/130746 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 762
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
71244,
82558,
368,
341,
262,
1077,
320,
82,
11,
272,
8,
284,
12507,
71315,
445,
19789,
71315,
61188,
2236,
797,
262,
1077,
5206,
2804,
25,
17718,
27909,
23370,
66,
18858,
48542,
1556,
63895,
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_process_message_readonly_handling() {
#[derive(Serialize, Deserialize)]
enum MockSystemInstruction {
Correct,
AttemptCredit { lamports: u64 },
AttemptDataChange { data: u8 },
}
fn mock_system_process_instruction(
_program_id: &Pubkey,
keyed_accounts: &[KeyedAccount],
data: &[u8],
) -> Result<(), InstructionError> {
if let Ok(instruction) = bincode::deserialize(data) {
match instruction {
MockSystemInstruction::Correct => Ok(()),
MockSystemInstruction::AttemptCredit { lamports } => {
keyed_accounts[0].account.borrow_mut().lamports -= lamports;
keyed_accounts[1].account.borrow_mut().lamports += lamports;
Ok(())
}
// Change data in a read-only account
MockSystemInstruction::AttemptDataChange { data } => {
keyed_accounts[1].account.borrow_mut().data = vec![data];
Ok(())
}
}
} else {
Err(InstructionError::InvalidInstructionData)
}
}
let mock_system_program_id = Pubkey::new(&[2u8; 32]);
let rent_collector = RentCollector::default();
let mut message_processor = MessageProcessor::default();
message_processor
.add_instruction_processor(mock_system_program_id, mock_system_process_instruction);
let mut accounts: Vec<Rc<RefCell<Account>>> = Vec::new();
let account = Account::new_ref(100, 1, &mock_system_program_id);
accounts.push(account);
let account = Account::new_ref(0, 1, &mock_system_program_id);
accounts.push(account);
let mut loaders: Vec<Vec<(Pubkey, RefCell<Account>)>> = Vec::new();
let account = RefCell::new(create_loadable_account("mock_system_program"));
loaders.push(vec![(mock_system_program_id, account)]);
let from_pubkey = Pubkey::new_rand();
let to_pubkey = Pubkey::new_rand();
let account_metas = vec![
AccountMeta::new(from_pubkey, true),
AccountMeta::new_readonly(to_pubkey, false),
];
let message = Message::new(&[Instruction::new(
mock_system_program_id,
&MockSystemInstruction::Correct,
account_metas.clone(),
)]);
let result =
message_processor.process_message(&message, &loaders, &accounts, &rent_collector);
assert_eq!(result, Ok(()));
assert_eq!(accounts[0].borrow().lamports, 100);
assert_eq!(accounts[1].borrow().lamports, 0);
let message = Message::new(&[Instruction::new(
mock_system_program_id,
&MockSystemInstruction::AttemptCredit { lamports: 50 },
account_metas.clone(),
)]);
let result =
message_processor.process_message(&message, &loaders, &accounts, &rent_collector);
assert_eq!(
result,
Err(TransactionError::InstructionError(
0,
InstructionError::ReadonlyLamportChange
))
);
let message = Message::new(&[Instruction::new(
mock_system_program_id,
&MockSystemInstruction::AttemptDataChange { data: 50 },
account_metas,
)]);
let result =
message_processor.process_message(&message, &loaders, &accounts, &rent_collector);
assert_eq!(
result,
Err(TransactionError::InstructionError(
0,
InstructionError::ReadonlyDataModified
))
);
} | rust_cleaned_test_functions.jsonl/71239 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1884
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11305,
6462,
6443,
3243,
75642,
368,
341,
286,
11506,
27098,
3759,
9050,
11,
48440,
5563,
286,
7618,
14563,
2320,
16664,
341,
310,
39970,
345,
310,
43517,
33493,
314,
31603,
3394,
25,
575,
21,
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... | 3 |
#[test]
fn test_truncate() {
let mut x = BitVec::with_capacity(0);
x.push(true);
x.push(false);
x.push(true);
x.push(false);
x.push(true);
x.push(false);
x.push(true);
x.truncate(4);
assert_eq!(x.len(), 4);
x.truncate(100);
assert_eq!(x.len(), 4);
x.truncate(0);
assert_eq!(x.len(), 0);
} | rust_cleaned_test_functions.jsonl/59462 | {
"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,
3547,
26900,
368,
341,
286,
1077,
5206,
856,
284,
6495,
10050,
486,
4197,
35603,
7,
15,
317,
286,
856,
2552,
3715,
317,
286,
856,
2552,
3576,
317,
286,
856,
2552,
3715,
317,
286,
856,
2552,
35... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_display_quote() {
let as_string = "form-data; name=upload; filename=\"Quote\\\"here.png\"";
as_string
.find(['\\', '\"'].iter().collect::<String>().as_str())
.unwrap(); // ensure `\"` is there
let a = HeaderValue::from_static(as_string);
let a: ContentDisposition = ContentDisposition::from_raw(&a).unwrap();
let display_rendered = format!("{}", a);
assert_eq!(as_string, display_rendered);
} | rust_cleaned_test_functions.jsonl/129592 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 216
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14825,
45236,
368,
341,
286,
1077,
438,
3904,
284,
330,
627,
13945,
26,
829,
28,
6120,
26,
3899,
4070,
19466,
3422,
2105,
6739,
3508,
95349,
286,
438,
3904,
198,
310,
659,
3903,
6425,
3422,
516,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parse_macos_conf() {
let mut config = resolv_conf::Config::new();
config.set_domain(String::from("example.com."));
config.set_search(vec!["example.com.".into(), "sub.example.com.".into()]);
config.nameservers = vec![
ScopedIp::V6(
Ipv6Addr::new(0x2001, 0x4860, 0x4860, 0, 0, 0, 0, 0x8888),
None,
),
ScopedIp::V6(
Ipv6Addr::new(0x2001, 0x4860, 0x4860, 0, 0, 0, 0, 0x8844),
None,
),
ScopedIp::V4(Ipv4Addr::new(8, 8, 8, 8)),
ScopedIp::V4(Ipv4Addr::new(8, 8, 4, 4)),
];
config.ndots = 8;
config.timeout = 8;
config.attempts = 8;
assert_eq!(config, parse_file("tests/resolv.conf-macos"));
} | rust_cleaned_test_functions.jsonl/121164 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 410
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
22802,
436,
16059,
368,
341,
262,
1077,
5206,
2193,
284,
592,
35315,
16059,
486,
2648,
486,
931,
543,
262,
2193,
980,
20111,
2242,
486,
1499,
445,
8687,
905,
54136,
262,
2193,
980,
10716,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_simple_opaque_struct() {
test_file! {
#[diplomat::bridge]
mod ffi {
#[diplomat::opaque]
struct MyStruct(UnknownType);
impl MyStruct {
pub fn new(a: u8, b: u8) -> Box<MyStruct> {
unimplemented!()
}
pub fn get_a(&self) -> u8 {
unimplemented!()
}
pub fn set_b(&mut self, b: u8) {
unimplemented!()
}
}
}
}
} | rust_cleaned_test_functions.jsonl/42850 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 441
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
30015,
10287,
19659,
15126,
368,
341,
286,
1273,
2458,
0,
341,
310,
11506,
8579,
500,
80768,
486,
13709,
921,
310,
1463,
76956,
341,
394,
11506,
8579,
500,
80768,
486,
95480,
921,
394,
2036,
3017,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_variant_to_str() {
let ident = token::str_to_ident("principal_skinner");
let var = codemap::respan(codemap::DUMMY_SP, ast::Variant_ {
name: ident,
attrs: Vec::new(),
kind: ast::TupleVariantKind(Vec::new()),
id: 0,
disr_expr: None,
vis: ast::Public,
});
let varstr = variant_to_str(&var);
assert_eq!(&varstr,&"pub principal_skinner".to_owned());
} | rust_cleaned_test_functions.jsonl/2693 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 273
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
46112,
2346,
2895,
368,
341,
286,
1077,
3524,
284,
3950,
486,
495,
2346,
38399,
445,
66450,
33811,
4382,
3071,
286,
1077,
762,
284,
20329,
42040,
486,
416,
848,
1337,
347,
42040,
486,
35,
58673,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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() {
let specifier =
ModuleSpecifier::parse("file:///a/test.ts").expect("bad specifier");
let source = Arc::new(
r#"import {
A,
B,
C,
D,
} from "https://deno.land/x/example@v1.0.0/mod.ts";
export * from "./mod.ts";
import type { Component } from "https://esm.sh/preact";
import { h, Fragment } from "https://esm.sh/preact";
// @deno-types="https://deno.land/x/types/react/index.d.ts";
import React from "https://cdn.skypack.dev/react";
const a = await import("./a.ts");
"#
.to_string(),
);
let parser = DefaultSourceParser::new();
let result = parser.parse_module(&specifier, source, MediaType::TypeScript);
assert!(result.is_ok());
let parsed_source = result.unwrap();
assert_eq!(analyze_dependencies(&parsed_source).len(), 6);
assert_eq!(analyze_ts_references(&parsed_source).len(), 0);
} | rust_cleaned_test_functions.jsonl/18982 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 396
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
368,
341,
262,
1077,
97616,
4035,
414,
13711,
87297,
486,
6400,
445,
1192,
60896,
64,
12697,
21288,
1827,
17119,
445,
13855,
97616,
797,
262,
1077,
2530,
284,
19689,
486,
931,
1006,
414,
43... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_compact_raft_group() {
let dir = tempfile::Builder::new()
.prefix("test_compact_raft_group")
.tempdir()
.unwrap();
let cfg = Config {
dir: dir.path().to_str().unwrap().to_owned(),
target_file_size: ReadableSize(1),
..Default::default()
};
let engine = RaftLogEngine::open(cfg).unwrap();
let data = vec![b'x'; 1024];
let mut rid = 7;
engine.append(rid, 1, 10, Some(&data));
// Files are not purged.
engine
.purge_manager
.must_rewrite_append_queue(None, Some(2));
let mut compact_log = LogBatch::default();
compact_log.add_command(rid, Command::Compact { index: 5 });
engine.write(&mut compact_log, true).unwrap();
let engine = engine.reopen();
engine.scan(rid, 5, 10, |_, q, d| {
assert_eq!(q, LogQueue::Append);
assert_eq!(d, &data);
});
rid += 1;
engine.append(rid, 5, 15, Some(&data));
let mut compact_log = LogBatch::default();
compact_log.add_command(rid, Command::Compact { index: 10 });
engine.write(&mut compact_log, true).unwrap();
engine.append(rid, 15, 25, Some(&data));
// Files are not purged.
engine
.purge_manager
.must_rewrite_append_queue(None, Some(2));
// Simulate loss of buffered write.
let mut compact_log = LogBatch::default();
compact_log.add_command(rid, Command::Compact { index: 20 });
engine
.memtables
.apply(compact_log.drain(), LogQueue::Append);
engine.purge_manager.must_rewrite_rewrite_queue();
let engine = engine.reopen();
engine.scan(rid, 10, 25, |_, q, d| {
assert_eq!(q, LogQueue::Append);
assert_eq!(d, &data);
});
engine
.purge_manager
.must_rewrite_append_queue(None, Some(2));
let engine = engine.reopen();
engine.scan(rid, 10, 25, |_, q, d| {
assert_eq!(q, LogQueue::Append);
assert_eq!(d, &data);
});
rid += 1;
engine.append(rid, 5, 15, Some(&data));
let mut compact_log = LogBatch::default();
compact_log.add_command(rid, Command::Compact { index: 10 });
engine.write(&mut compact_log, true).unwrap();
engine.purge_manager.must_rewrite_append_queue(None, None);
engine.append(rid, 15, 25, Some(&data));
engine
.purge_manager
.must_rewrite_append_queue(None, Some(2));
let mut compact_log = LogBatch::default();
compact_log.add_command(rid, Command::Compact { index: 20 });
engine.write(&mut compact_log, true).unwrap();
let engine = engine.reopen();
engine.scan(rid, 20, 25, |_, q, d| {
assert_eq!(q, LogQueue::Append);
assert_eq!(d, &data);
});
rid += 1;
engine.append(rid, 1, 5, Some(&data));
engine.purge_manager.must_rewrite_append_queue(None, None);
engine.append(rid, 5, 15, Some(&data));
let mut compact_log = LogBatch::default();
compact_log.add_command(rid, Command::Compact { index: 10 });
engine.write(&mut compact_log, true).unwrap();
// Files are not purged.
engine
.purge_manager
.must_rewrite_append_queue(None, Some(2));
let engine = engine.reopen();
engine.scan(rid, 10, 15, |_, q, d| {
assert_eq!(q, LogQueue::Append);
assert_eq!(d, &data);
});
} | rust_cleaned_test_functions.jsonl/91524 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1880
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18177,
531,
62,
2944,
6288,
368,
341,
286,
1077,
5419,
284,
54819,
486,
3297,
486,
931,
741,
310,
659,
11849,
445,
1944,
18177,
531,
62,
2944,
6288,
1138,
310,
659,
3888,
3741,
741,
310,
659,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_cast_decimal_as_time() {
let cases = vec![
("2019-09-16 10:11:12", "20190916101112", 0),
("2019-09-16 10:11:12", "190916101112", 0),
("1909-12-10 00:00:00", "19091210", 0),
("2020-02-29 10:00:00", "20200229100000", 0),
("2019-09-16 00:00:00", "190916", 0),
("2019-09-16 10:11:12.111", "190916101112.111", 3),
("2019-09-16 10:11:12.111", "20190916101112.111", 3),
("2019-09-16 10:11:12.67", "20190916101112.666", 2),
("2019-09-16 10:11:13.0", "20190916101112.999", 1),
("2001-11-11 00:00:00.0000", "11111.1111", 4),
("0102-11-21 14:11:05.4324", "1021121141105.4324", 4),
("2002-11-21 14:11:05.101", "21121141105.101", 3),
("2000-11-21 14:11:05.799055", "1121141105.799055", 6),
("2000-01-21 14:11:05.123", "121141105.123", 3),
("0114-11-05 00:00:00", "1141105", 0),
("2004-11-05 00:00:00.00", "41105.11", 2),
("2000-11-05 00:00:00.0", "1105.3", 1),
("2000-01-05 00:00:00", "105", 0),
];
for (expected, decimal, fsp) in cases {
let decimal: Decimal = decimal.parse().unwrap();
let actual: Time = RpnFnScalarEvaluator::new()
.push_param(decimal)
.return_field_type(
FieldTypeBuilder::new()
.tp(FieldTypeTp::DateTime)
.decimal(fsp)
.build(),
)
.evaluate(ScalarFuncSig::CastDecimalAsTime)
// `Result<Option<_>>`
.unwrap()
.unwrap();
assert_eq!(actual.to_string(), expected);
}
let should_fail = vec![
"19091610111",
"1909161011",
"190916101",
"1909161",
"19091",
"201705051315111.22",
"2011110859.1111",
"2011110859.1111",
"191203081.1111",
"43128.121105",
];
for case in should_fail {
let case: Decimal = case.parse().unwrap();
let actual = RpnFnScalarEvaluator::new()
.push_param(case)
.return_field_type(FieldTypeBuilder::new().tp(FieldTypeTp::DateTime).build())
.evaluate::<Time>(ScalarFuncSig::CastDecimalAsTime)
.unwrap();
assert!(actual.is_none());
}
} | rust_cleaned_test_functions.jsonl/1953 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1505
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5303,
74429,
11898,
3009,
368,
341,
286,
1077,
5048,
284,
7486,
90515,
310,
3489,
17,
15,
16,
24,
12,
15,
24,
12,
16,
21,
220,
16,
15,
25,
16,
16,
25,
16,
17,
497,
330,
17,
15,
16,
24,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_boxed_anyhow() {
let error = anyhow!("oh no!").context("it failed");
let error = anyhow!(error);
assert_eq!("oh no!", error.source().unwrap().to_string());
} | rust_cleaned_test_functions.jsonl/91395 | {
"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,
10194,
291,
37248,
5158,
368,
341,
262,
1077,
1465,
284,
88964,
17223,
2267,
902,
0,
1827,
2147,
445,
275,
4641,
797,
262,
1077,
1465,
284,
88964,
10297,
841,
317,
262,
2060,
10714,
17223,
2267,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_filter_program_errors_and_collect_fee() {
let leader = solana_sdk::pubkey::new_rand();
let GenesisConfigInfo {
mut genesis_config,
mint_keypair,
..
} = create_genesis_config_with_leader(100, &leader, 3);
genesis_config.fee_rate_governor = FeeRateGovernor::new(2, 0);
let bank = Bank::new(&genesis_config);
let key = Keypair::new();
let tx1 =
system_transaction::transfer(&mint_keypair, &key.pubkey(), 2, genesis_config.hash());
let tx2 =
system_transaction::transfer(&mint_keypair, &key.pubkey(), 5, genesis_config.hash());
let results = vec![
(Ok(()), None),
(
Err(TransactionError::InstructionError(
1,
SystemError::ResultWithNegativeLamports.into(),
)),
None,
),
];
let initial_balance = bank.get_balance(&leader);
let results = bank.filter_program_errors_and_collect_fee([tx1, tx2].iter(), &results);
bank.freeze();
assert_eq!(
bank.get_balance(&leader),
initial_balance
+ bank
.fee_rate_governor
.burn(bank.fee_calculator.lamports_per_signature * 2)
.0
);
assert_eq!(results[0], Ok(()));
assert_eq!(results[1], Ok(()));
} | rust_cleaned_test_functions.jsonl/2569 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 771
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8727,
25096,
20196,
8378,
68140,
34305,
368,
341,
286,
1077,
7653,
284,
2048,
3362,
61783,
486,
9585,
792,
486,
931,
33864,
543,
286,
1077,
40788,
2648,
1731,
341,
310,
5206,
59366,
5332,
345,
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_tokenize() {
let test_input: String = "(a b c)".to_string();
assert_eq!(tokenize(test_input),
vec!("(","a","b","c", ")"));
} | rust_cleaned_test_functions.jsonl/119322 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 89
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
86508,
368,
341,
262,
1077,
1273,
5898,
25,
923,
220,
284,
11993,
64,
293,
272,
94010,
983,
3904,
543,
262,
2060,
10714,
10297,
5839,
551,
8623,
5898,
701,
715,
2290,
7486,
17223,
47503,
64,
219... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_version_parse() {
let error = Err(crate::InstanceError);
assert_eq!(Adapter::parse_version("1"), error);
assert_eq!(Adapter::parse_version("1."), error);
assert_eq!(Adapter::parse_version("1 h3l1o. W0rld"), error);
assert_eq!(Adapter::parse_version("1. h3l1o. W0rld"), error);
assert_eq!(Adapter::parse_version("1.2.3"), error);
assert_eq!(Adapter::parse_version("OpenGL ES 3.1"), Ok((3, 1)));
assert_eq!(
Adapter::parse_version("OpenGL ES 2.0 Google Nexus"),
Ok((2, 0))
);
assert_eq!(Adapter::parse_version("GLSL ES 1.1"), Ok((1, 1)));
assert_eq!(Adapter::parse_version("OpenGL ES GLSL ES 3.20"), Ok((3, 2)));
assert_eq!(
Adapter::parse_version("WebGL 2.0 (OpenGL ES 3.0 Chromium)"),
Ok((3, 0))
);
assert_eq!(
Adapter::parse_version("WebGL GLSL ES 3.00 (OpenGL ES GLSL ES 3.0 Chromium)"),
Ok((3, 0))
);
} | rust_cleaned_test_functions.jsonl/65290 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 524
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9438,
21039,
368,
341,
286,
1077,
1465,
284,
15495,
54907,
486,
2523,
1454,
317,
286,
2060,
10714,
10297,
5940,
486,
6400,
9438,
445,
16,
3975,
1465,
317,
286,
2060,
10714,
10297,
5940,
486,
6400,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_hash_map_insert() {
let mut map = HashMap::<(Currency, Currency), i32>::new();
map.insert(("CHF", "USD"), 2);
assert_eq!(Some(2), map.get(&("CHF", "USD")).cloned());
map.insert(("CHF", "USD"), 3);
assert_eq!(Some(3), map.get(&("CHF", "USD")).cloned());
} | rust_cleaned_test_functions.jsonl/133369 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 160
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8950,
5376,
17678,
368,
341,
286,
1077,
5206,
2415,
284,
10528,
27638,
7,
26321,
11,
28453,
701,
600,
18,
17,
6831,
931,
543,
286,
2415,
7030,
30873,
2149,
37,
497,
330,
26749,
3975,
220,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_send_with_request_builder() {
let domain = "sandbox0123456789abcdef0123456789abcdef.mailgun.org";
let key = "0123456789abcdef0123456789abcdef-01234567-89abcdef";
let recipient = "user@example.com";
let creds = Credentials::new(&key, &domain);
let recipient = EmailAddress::address(&recipient);
let message = Message {
to: vec![recipient],
subject: "Test email".to_string(),
body: MessageBody::Text(String::from(
"This email is from an mailgun_v3 automated test",
)),
..Default::default()
};
let sender = EmailAddress::name_address("Nick Testla", &format!("mailgun_v3@{}", &domain));
let domain = &mockito::server_url();
let uri = format!("/{}/{}", creds.domain, MESSAGES_ENDPOINT);
let response = json!({
"id": "<0123456789abcdef.0123456789abcdef@sandbox0123456789abcdef0123456789abcdef.mailgun.org>",
"message": "Queued. Thank you."
});
let _m = mockito::mock("POST", uri.as_str())
.with_status(200)
.with_header("content-type", "application/json")
.with_body(response.to_string())
.create();
let url = format!("{}{}", domain, uri);
let client = reqwest::blocking::Client::new();
let request_builder = client.post(&url);
let res = send_with_request_builder(request_builder, &creds, &sender, message);
assert!(res.is_ok(), format!("{:?}", &res));
} | rust_cleaned_test_functions.jsonl/56134 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 735
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13565,
6615,
7893,
28532,
368,
341,
286,
1077,
7947,
284,
330,
76756,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
41202,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
41202,
33156,
13259,
2659,
876,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_complex() {
let res = parse_cfg::<(_, nom::error::ErrorKind)>(
"cfg(all(not(target_os = \"macos\"), not(windows), not(target_os = \"ios\")))",
);
println!("res = {:?}", res);
assert_eq!(
res,
Ok((
"",
All(vec!(
Not(Box::new(Value {
key: "target_os",
value: "macos"
})),
Not(Box::new(Windows)),
Not(Box::new(Value {
key: "target_os",
value: "ios"
}))
))
))
)
} | rust_cleaned_test_functions.jsonl/50604 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 575
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
41522,
368,
341,
310,
1077,
592,
284,
4715,
18343,
27638,
41117,
9662,
486,
841,
486,
1454,
10629,
16018,
1006,
394,
330,
14072,
20388,
24772,
8637,
29387,
284,
7245,
11948,
436,
2105,
701,
537,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_too_many_args() {
const EXPECTED: &str =
"error: The value 'u' was provided to '<FILE>...', but it wasn't expecting any more values";
let args = ["am", "i", "u"];
new_ucmd!().args(&args).fails().stderr_contains(EXPECTED);
} | rust_cleaned_test_functions.jsonl/79399 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 114
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2346,
78,
22101,
8384,
368,
341,
262,
733,
8921,
1479,
25,
609,
495,
4035,
286,
330,
841,
25,
576,
897,
364,
84,
6,
572,
3897,
311,
3857,
6041,
29,
68386,
714,
432,
5710,
944,
22331,
894,
80... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_commit_callback() {
// consensus commit callback should unlock txns in parking lot
let mut pool = setup_mempool().0;
let txns = add_txns_to_mempool(&mut pool, vec![TestTransaction::new(1, 6, 1)]);
// check that pool is empty
assert!(pool.get_block(1, HashSet::new()).is_empty());
// transaction 5 got back from consensus
pool.remove_transaction(&TestTransaction::get_address(1), 5, false);
// verify that we can execute transaction 6
assert_eq!(pool.get_block(1, HashSet::new())[0], txns[0]);
} | rust_cleaned_test_functions.jsonl/1801 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 204
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36346,
12519,
368,
341,
262,
442,
23869,
5266,
4822,
1265,
15055,
9854,
4412,
304,
12921,
2696,
198,
262,
1077,
5206,
7314,
284,
6505,
717,
3262,
1749,
1005,
15,
280,
1066,
262,
1077,
9854,
4412,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_request_envelope() {
let bytes = Bytes::from("{\"event_id\":\"9ec79c33ec9942ab8353589fcb2e04dc\"}");
let envelope = Envelope::parse_request(bytes, request_meta()).unwrap();
let meta = envelope.meta();
// This test asserts that all information from the envelope is overwritten with request
// information matches the DSN.
let dsn = "https://e12d836b15bb49d7bbf99e64295d995b:@sentry.io/42"
.parse()
.unwrap();
assert_eq!(*meta.dsn(), dsn);
assert_eq!(meta.project_id(), ProjectId::new(42));
assert_eq!(meta.public_key(), "e12d836b15bb49d7bbf99e64295d995b");
assert_eq!(meta.client(), Some("sentry/client"));
assert_eq!(meta.version(), 7);
assert_eq!(meta.origin(), Some(&"http://origin/".parse().unwrap()));
assert_eq!(meta.remote_addr(), Some("192.168.0.1".parse().unwrap()));
assert_eq!(meta.forwarded_for(), "");
assert_eq!(meta.user_agent(), Some("sentry/agent"));
} | rust_cleaned_test_functions.jsonl/103613 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 486
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
7893,
6205,
18853,
368,
341,
286,
1077,
5820,
284,
30024,
486,
1499,
99141,
3087,
842,
23488,
24,
757,
22,
24,
66,
18,
18,
757,
24,
24,
19,
17,
370,
23,
18,
20,
18,
20,
23,
24,
69,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_return_impl_traits_has_goto_type_action() {
check_actions(
r#"
trait Foo {}
trait Bar {}
fn foo() -> impl Foo + Bar {}
fn main() { let s<|>t = foo(); }
"#,
expect![[r#"
[
GoToType(
[
HoverGotoTypeData {
mod_path: "test::Foo",
nav: NavigationTarget {
file_id: FileId(
0,
),
full_range: 0..12,
focus_range: Some(
6..9,
),
name: "Foo",
kind: TRAIT,
container_name: None,
description: Some(
"trait Foo",
),
docs: None,
},
},
HoverGotoTypeData {
mod_path: "test::Bar",
nav: NavigationTarget {
file_id: FileId(
0,
),
full_range: 13..25,
focus_range: Some(
19..22,
),
name: "Bar",
kind: TRAIT,
container_name: None,
description: Some(
"trait Bar",
),
docs: None,
},
},
],
),
]
"#]],
);
} | rust_cleaned_test_functions.jsonl/66168 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1786
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
53445,
12511,
21007,
39693,
21778,
97732,
1819,
7931,
368,
341,
286,
1779,
25368,
1006,
310,
435,
2,
698,
29432,
33428,
5613,
29432,
4716,
5613,
8822,
15229,
368,
1464,
11605,
33428,
488,
4716,
1008... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_result() {
assert_eq! {
rune! { i64 =>
pub fn main() { match Err("err") { Err("err") => 1, _ => 2 } }
},
1,
};
assert_eq! {
rune! { i64 =>
pub fn main() { match Err("err") { Ok("ok") => 1, _ => 2 } }
},
2,
};
assert_eq! {
rune! { i64 =>
pub fn main() { match Ok("ok") { Ok("ok") => 1, _ => 2 } }
},
1,
};
} | rust_cleaned_test_functions.jsonl/50508 | {
"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,
5287,
368,
341,
262,
2060,
10714,
0,
341,
286,
63499,
0,
314,
600,
21,
19,
6274,
310,
6675,
5168,
1887,
368,
314,
2432,
15495,
445,
615,
899,
314,
15495,
445,
615,
899,
589,
220,
16,
11,
220... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_extra_fields() {
let json = r#"{
".tag": "deleted",
"name": "f",
"some extra field": "whatever",
"some more": {"some": "complex", "other": "stuff"},
"parent_shared_folder_id": "spaghetti",
"one more extra": "~~~~"
}"#;
let x = serde_json::from_str::<dropbox_sdk::files::Metadata>(json).unwrap();
if let dropbox_sdk::files::Metadata::Deleted(d) = x {
assert_eq!("f", &d.name);
assert_eq!(Some("spaghetti"), d.parent_shared_folder_id.as_deref());
} else {
panic!("wrong variant");
}
} | rust_cleaned_test_functions.jsonl/12416 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 284
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31858,
12132,
368,
341,
262,
1077,
2951,
284,
435,
55543,
515,
286,
5933,
4578,
788,
330,
26521,
756,
286,
330,
606,
788,
330,
69,
756,
286,
330,
14689,
4960,
2070,
788,
330,
68286,
756,
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_parsing_with_a_newly_included_range() {
let source_code = "<div><%= foo() %></div><div><%= bar() %>";
let first_code_start_index = source_code.find(" foo").unwrap();
let first_code_end_index = first_code_start_index + 7;
let second_code_start_index = source_code.find(" bar").unwrap();
let second_code_end_index = second_code_start_index + 7;
let ranges = [
Range {
start_byte: first_code_start_index,
end_byte: first_code_end_index,
start_point: Point::new(0, first_code_start_index),
end_point: Point::new(0, first_code_end_index),
},
Range {
start_byte: second_code_start_index,
end_byte: second_code_end_index,
start_point: Point::new(0, second_code_start_index),
end_point: Point::new(0, second_code_end_index),
},
];
// Parse only the first code directive as JavaScript
let mut parser = Parser::new();
parser.set_language(get_language("javascript")).unwrap();
parser.set_included_ranges(&ranges[0..1]);
let first_tree = parser.parse(source_code, None).unwrap();
assert_eq!(
first_tree.root_node().to_sexp(),
concat!(
"(program",
" (expression_statement (call_expression (identifier) (arguments))))",
)
);
parser.set_included_ranges(&ranges);
let tree = parser.parse(&source_code, Some(&first_tree)).unwrap();
assert_eq!(
tree.root_node().to_sexp(),
concat!(
"(program",
" (expression_statement (call_expression (identifier) (arguments)))",
" (expression_statement (call_expression (identifier) (arguments))))",
)
);
assert_eq!(
tree.changed_ranges(&first_tree),
vec![Range {
start_byte: first_code_end_index + 1,
end_byte: second_code_end_index + 1,
start_point: Point::new(0, first_code_end_index + 1),
end_point: Point::new(0, second_code_end_index + 1),
}]
);
} | rust_cleaned_test_functions.jsonl/7396 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 961
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
28598,
6615,
4306,
5921,
398,
1243,
10181,
9698,
368,
341,
262,
1077,
2530,
4136,
284,
4055,
611,
1784,
35205,
15229,
368,
1018,
1472,
611,
1784,
611,
1784,
35205,
3619,
368,
1018,
6734,
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_overflow_behaviour() {
let mut incrementing: Incrementing<u8> = Incrementing {
count: 0,
step: 1,
overflowed: false
};
let mut rng = OsRng::default();
for i in 0..255 {
assert_eq!(i, incrementing.next(&mut rng).into_yielded().unwrap())
}
assert!(incrementing.next(&mut rng).into_complete().is_err())
} | rust_cleaned_test_functions.jsonl/104780 | {
"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,
79073,
43241,
8897,
368,
341,
286,
1077,
5206,
16252,
287,
25,
52835,
287,
34837,
23,
29,
284,
52835,
287,
341,
310,
1760,
25,
220,
15,
345,
310,
3019,
25,
220,
16,
345,
310,
16484,
291,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_build_manifest_not_exist() -> Result<()> {
let cmd = BuildCommand {
build_manifest_path: PathBuf::from("invalid path"),
package_manifest_path: Some(PathBuf::from("./package_manifest.json")),
out: PathBuf::from("./out"),
published_name: String::from("package"),
};
assert!(cmd_package_build(cmd).is_err());
Ok(())
} | rust_cleaned_test_functions.jsonl/104040 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 203
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20801,
74269,
7913,
35906,
368,
1464,
5714,
71698,
341,
286,
1077,
5439,
284,
7854,
4062,
341,
310,
1936,
74269,
2638,
25,
7933,
15064,
486,
1499,
445,
11808,
1815,
4461,
310,
6328,
74269,
2638,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_random_access_zip() {
let xs = [1, 2, 3, 4, 5];
let ys = [7, 9, 11];
check_randacc_iter(xs.iter().zip(ys.iter()), cmp::min(xs.len(), ys.len()));
} | rust_cleaned_test_functions.jsonl/1028 | {
"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,
22644,
12759,
42131,
368,
341,
286,
1077,
11943,
284,
508,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
935,
286,
1077,
31810,
284,
508,
22,
11,
220,
24,
11,
220,
16,
16,
935,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_coil_booleanness() {
let a: Coil = true.into();
assert_ne!(a, !a);
assert_eq!(a, !!a);
let b: Coil = false.into();
assert_eq!(a, !b);
} | rust_cleaned_test_functions.jsonl/86708 | {
"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,
11393,
321,
56013,
1263,
82033,
368,
341,
286,
1077,
264,
25,
67665,
284,
830,
39860,
543,
286,
2060,
13925,
10297,
64,
11,
753,
64,
317,
286,
2060,
10714,
10297,
64,
11,
11015,
64,
317,
286,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_ordered_sub_contiguous() {
macro_rules! test {
($ordered:expr, $a:expr, $b:expr, $expected:expr) => {
assert_eq!(
OrderedIntegerSet::from_slice($ordered)
- ContiguousIntegerSet::new($a, $b),
OrderedIntegerSet::from_slice($expected)
);
};
}
test!(&[], 2, 3, &[]);
test!(&[[4, 10]], 2, 3, &[[4, 10]]);
test!(&[[4, 10]], -2, 3, &[[4, 10]]);
test!(&[[4, 10]], 12, 13, &[[4, 10]]);
test!(&[[4, 10]], 3, 4, &[[5, 10]]);
test!(&[[4, 10]], 4, 4, &[[5, 10]]);
test!(&[[4, 10]], 10, 10, &[[4, 9]]);
test!(&[[4, 10]], 10, 12, &[[4, 9]]);
test!(&[[0, 10]], 3, 5, &[[0, 2], [6, 10]]);
test!(&[[0, 10]], 0, 10, &[]);
test!(&[[0, 10]], -1, 11, &[]);
test!(&[[0, 3], [6, 10]], 0, 11, &[]);
test!(&[[0, 3], [6, 10]], 0, 2, &[[3, 3], [6, 10]]);
test!(&[[0, 3], [6, 10]], 0, 3, &[[6, 10]]);
test!(&[[0, 3], [6, 10]], 0, 5, &[[6, 10]]);
test!(&[[0, 3], [6, 10]], 0, 6, &[[7, 10]]);
test!(&[[0, 3], [6, 10]], 0, 9, &[[10, 10]]);
test!(&[[0, 3], [6, 10]], 1, 1, &[[0, 0], [2, 3], [6, 10]]);
test!(&[[0, 3], [6, 10]], 1, 2, &[[0, 0], [3, 3], [6, 10]]);
test!(&[[0, 3], [6, 10]], 2, 3, &[[0, 1], [6, 10]]);
test!(&[[0, 3], [6, 10]], 2, 6, &[[0, 1], [7, 10]]);
test!(&[[0, 3], [6, 10]], 2, 9, &[[0, 1], [10, 10]]);
test!(&[[0, 3], [6, 10]], 3, 9, &[[0, 2], [10, 10]]);
test!(&[[0, 3], [6, 10]], 5, 9, &[[0, 3], [10, 10]]);
test!(&[[0, 3], [6, 10]], 8, 8, &[[0, 3], [6, 7], [9, 10]]);
test!(&[[0, 3], [6, 9], [12, 15]], 0, 14, &[[15, 15]]);
test!(&[[0, 3], [6, 9], [12, 15]], 0, 15, &[]);
test!(&[[0, 3], [6, 9], [12, 15]], 2, 7, &[[0, 1], [8, 9], [
12, 15
]]);
test!(&[[0, 3], [6, 9], [12, 15]], 3, 12, &[[0, 2], [13, 15]]);
test!(&[[0, 3], [6, 9], [12, 15]], 3, 15, &[[0, 2]]);
test!(&[[0, 3], [6, 9], [12, 15]], 9, 12, &[[0, 3], [6, 8], [
13, 15
]]);
} | rust_cleaned_test_functions.jsonl/21306 | {
"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,
75272,
5228,
10260,
27029,
368,
341,
286,
18072,
21407,
0,
1273,
341,
310,
1711,
10544,
96011,
11,
400,
64,
96011,
11,
400,
65,
96011,
11,
400,
7325,
96011,
8,
589,
341,
394,
2060,
10714,
33673,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_invert() {
assert_ulps_eq!(Deg(0.0).invert(), Deg(180.0));
assert_ulps_eq!(Deg(180.0).invert().normalize(), Deg(0.0));
assert_ulps_eq!(Deg(80.0).invert(), Deg(260.0));
} | rust_cleaned_test_functions.jsonl/58809 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 122
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1243,
1621,
368,
341,
286,
2060,
61039,
1690,
10714,
10297,
45657,
7,
15,
13,
15,
568,
83729,
1507,
57237,
7,
16,
23,
15,
13,
15,
1106,
286,
2060,
61039,
1690,
10714,
10297,
45657,
7,
16,
23,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_select() {
let bits: BitVec<u8> = bit_vec![true, false];
let rs = RankSelect::new(bits, 1);
assert_eq!(rs.select_0(0), Some(0));
assert_eq!(rs.select_1(0), None);
assert_eq!(rs.select_0(1), Some(1));
assert_eq!(rs.select_1(1), Some(0));
assert_eq!(rs.select_0(2), None);
assert_eq!(rs.select_1(2), None);
} | rust_cleaned_test_functions.jsonl/110833 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 214
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13051,
368,
341,
286,
1077,
9472,
25,
6495,
10050,
34837,
23,
29,
284,
2699,
13251,
20703,
1866,
11,
895,
935,
286,
1077,
10036,
284,
19298,
3379,
486,
931,
68901,
11,
220,
16,
626,
286,
2060,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_quoted_name() -> Result<()> {
let name = SqlName::new("some 'awesome' name").quoted();
assert_eq!(&name, "'some ''awesome'' name'");
let name = SqlName::new("some 'awesome' name")
.alias("awesome name")
.quoted();
assert_eq!(&name, "'some ''awesome'' name' AS `awesome name`");
let name = SqlName::new("some 'awesome' name")
.add("sub")
.alias("awesome name")
.quoted();
assert_eq!(&name, "'some ''awesome'' name'.'sub' AS `awesome name`");
let name = qname!("some 'awesome' name");
assert_eq!(&name, "'some ''awesome'' name'");
let name = qname!("some 'awesome' name"; "awesome name");
assert_eq!(&name, "'some ''awesome'' name' AS `awesome name`");
let name = qname!("some 'awesome' name", "sub"; "awesome name");
assert_eq!(&name, "'some ''awesome'' name'.'sub' AS `awesome name`");
Ok(())
} | rust_cleaned_test_functions.jsonl/74807 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 456
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11280,
9253,
1269,
368,
1464,
5714,
71698,
341,
286,
1077,
829,
284,
7224,
675,
486,
931,
445,
14689,
364,
16875,
6,
829,
1827,
63725,
543,
286,
2060,
10714,
0,
2099,
606,
11,
7178,
14689,
3355,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_bank_parent_account_spend() {
let (genesis_block, mint_keypair) = GenesisBlock::new(2);
let key1 = Keypair::new();
let key2 = Keypair::new();
let parent = Arc::new(Bank::new(&genesis_block));
let tx =
system_transaction::transfer(&mint_keypair, &key1.pubkey(), 1, genesis_block.hash(), 0);
assert_eq!(parent.process_transaction(&tx), Ok(()));
let bank = new_from_parent(&parent);
let tx = system_transaction::transfer(&key1, &key2.pubkey(), 1, genesis_block.hash(), 0);
assert_eq!(bank.process_transaction(&tx), Ok(()));
assert_eq!(parent.get_signature_status(&tx.signatures[0]), None);
} | rust_cleaned_test_functions.jsonl/41899 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 307
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
35733,
15960,
13500,
643,
3740,
368,
341,
286,
1077,
320,
77894,
7113,
11,
28337,
3097,
12670,
8,
284,
40788,
4713,
486,
931,
7,
17,
317,
286,
1077,
1376,
16,
284,
6569,
1082,
1310,
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_rot13() {
let plain = "hello";
let encrypted = encrypt_rot13(plain);
assert_eq!(encrypted, "uryyb");
let decrypted = decrypt_rot13(&encrypted);
assert_eq!(plain, decrypted);
} | rust_cleaned_test_functions.jsonl/8402 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 112
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
38256,
16,
18,
368,
341,
286,
1077,
14396,
284,
330,
14990,
876,
286,
1077,
24455,
284,
29625,
38256,
16,
18,
7,
20772,
626,
286,
2060,
10714,
10297,
36444,
11,
330,
3350,
84307,
3071,
286,
1077... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_graph_store_update() {
let root_dir = "data/small_data";
let mut graphdb: MutableGraphDB<DefaultId, InternalId> =
GraphDBConfig::default().root_dir(root_dir).number_vertex_labels(20).new();
assert!(graphdb.add_vertex(PIDS[0], [1, INVALID_LABEL_ID]));
// Cannot re-add a vertex
assert!(!graphdb.add_vertex(PIDS[0], [1, INVALID_LABEL_ID]));
assert!(graphdb.add_vertex(PIDS[2], [1, INVALID_LABEL_ID]));
assert!(graphdb.add_corner_vertex(PIDS[5], 1));
let prop = Row::from(vec![object!(15), object!("John")]);
let new_prop = Row::from(vec![object!(16), object!("Steve")]);
// Update the vertex's properties
assert!(graphdb.add_or_update_vertex_properties(PIDS[0], prop.clone()).unwrap().is_none());
assert!(graphdb.add_or_update_vertex_properties(PIDS[1], prop.clone()).is_err());
// Add vertex PIDS[1]
assert!(graphdb
.add_vertex_with_properties(PIDS[1], [1, INVALID_LABEL_ID], prop.clone())
.unwrap()
.is_none());
assert_eq!(
Some(prop.clone()),
graphdb
.add_vertex_with_properties(PIDS[1], [1, INVALID_LABEL_ID], new_prop.clone())
.unwrap()
);
assert!(graphdb.add_edge(PIDS[0], PIDS[1], 13));
// add an edge from a corner vertex
assert!(graphdb.add_edge(PIDS[5], PIDS[0], 12));
assert!(!graphdb.add_edge(PIDS[0], PIDS[3], 12));
assert!(!graphdb.add_edge(PIDS[3], PIDS[0], 12));
let edge_prop = Row::from(20200202_i64);
// add duplicate edge to the db
assert!(graphdb
.add_edge_with_properties(PIDS[0], PIDS[1], 12, edge_prop.clone())
.unwrap()
.is_none());
assert!(graphdb.add_edge_with_properties(PIDS[0], PIDS[3], 12, edge_prop.clone()).is_err());
let schema =
LDBCGraphSchema::from_json_file("data/schema.json").expect("Get Schema error!");
let graph = graphdb.into_graph(schema);
assert_eq!(
vec![prop.clone().get(0), prop.clone().get(1)],
vec![
graph.get_vertex(PIDS[0]).unwrap().get_property(ID_FIELD),
graph.get_vertex(PIDS[0]).unwrap().get_property("firstName"),
]
);
assert_eq!(
vec![new_prop.clone().get(0), new_prop.clone().get(1)],
vec![
graph.get_vertex(PIDS[1]).unwrap().get_property(ID_FIELD),
graph.get_vertex(PIDS[1]).unwrap().get_property("firstName"),
]
);
assert_eq!(3, graph.count_all_vertices(None));
assert_eq!(2, graph.count_all_edges(None));
// one edge of label 12
assert_eq!(1, graph.count_all_edges(Some(&vec![12])));
// one edge of label 13
assert_eq!(1, graph.count_all_edges(Some(&vec![13])));
} | rust_cleaned_test_functions.jsonl/22814 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1543
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14738,
14809,
8882,
368,
341,
286,
1077,
3704,
4334,
284,
330,
691,
96816,
1769,
876,
286,
1077,
5206,
4771,
1999,
25,
31143,
11212,
3506,
27,
3675,
764,
11,
15412,
764,
29,
4035,
310,
12165,
35... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_simple_inversion2() {
let a: Secp256r1Scalar = ECScalar::from(&BigInt::from(2));
let a_inv = a.invert();
let a_inv_int = a_inv.to_big_int();
assert_eq!(
a_inv_int,
BigInt::from_hex("7fffffff800000007fffffffffffffffde737d56d38bcf4279dce5617e3192a9")
.unwrap(),
);
} | rust_cleaned_test_functions.jsonl/12363 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 213
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
30015,
1243,
4366,
17,
368,
341,
286,
1077,
264,
25,
4520,
79,
17,
20,
21,
81,
16,
20639,
284,
20633,
20639,
486,
1499,
2099,
87474,
486,
1499,
7,
17,
1106,
286,
1077,
264,
19996,
284,
264,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_ascii_filenames() {
let tmp_dir = TempDir::new().expect("failed to make tempdir");
Exporter::new(
PathBuf::from("tests/testdata/input/non-ascii/"),
tmp_dir.path().to_path_buf(),
)
.run()
.expect("exporter returned error");
let walker = WalkDir::new("tests/testdata/expected/non-ascii/")
// unpredictable order.
.sort_by(|a, b| a.file_name().cmp(b.file_name()))
.into_iter();
for entry in walker {
let entry = entry.unwrap();
if entry.metadata().unwrap().is_dir() {
continue;
};
let filename = entry.file_name().to_string_lossy().into_owned();
let expected = read_to_string(entry.path()).expect(&format!(
"failed to read {} from testdata/expected/non-ascii/",
entry.path().display()
));
let actual = read_to_string(tmp_dir.path().clone().join(PathBuf::from(&filename))).expect(
&format!("failed to read {} from temporary exportdir", filename),
);
assert_eq!(
expected, actual,
"{} does not have expected content",
filename
);
}
} | rust_cleaned_test_functions.jsonl/116604 | {
"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,
21637,
50238,
80632,
368,
341,
262,
1077,
4174,
4334,
284,
19944,
6184,
486,
931,
1005,
17119,
445,
16091,
311,
1281,
2730,
3741,
3071,
262,
22191,
261,
486,
931,
1006,
286,
7933,
15064,
486,
1499... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_debug() {
let fb = FooBar(1_234_567_890);
let expected = "FooBar { .0: 1234567890, foo1: 0, foo2: 0, foo3: 2, foo3: 2, foo4: 4, foo5: [0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0], foo6: [2, 3, 1], getter_only: 1, getter_only_array: [2, 3, 1], all_bits: 1234567890, single_bit: false, into_foo1: Foo(0), into_foo2: Foo(0), from_foo1: Foo(0), into_foo3: Foo(0), into_foo4: Foo(0), into_foo6: [Foo(0), Foo(1), Foo(0)], from_foo3: Foo(0), from_foo5: [Foo(0), Foo(1), Foo(0)], from_foo6: Foo(0), signed_single_bit: 0, signed_two_bits: -2, signed_eight_bits: -46, signed_eight_bits_unaligned: 105, u128_getter: 105, i128_getter: 105 }";
assert_eq!(expected, format!("{:?}", fb))
} | rust_cleaned_test_functions.jsonl/2275 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 378
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15446,
368,
341,
262,
1077,
25469,
284,
33428,
3428,
7,
16,
62,
17,
18,
19,
62,
20,
21,
22,
62,
23,
24,
15,
317,
262,
1077,
3601,
284,
330,
40923,
3428,
314,
659,
15,
25,
220,
16,
17,
18... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_merge_bu_empty() {
let mut vector_in:Vec<i32> = vec![];
merge_bottom_up_sort(&mut vector_in);
debug_assert_eq!(vector_in, &[]);
} | rust_cleaned_test_functions.jsonl/25084 | {
"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,
20888,
880,
84,
15124,
368,
341,
286,
1077,
5206,
4621,
1243,
25,
10050,
21897,
18,
17,
29,
284,
7486,
0,
15078,
286,
10880,
25473,
8237,
18435,
2099,
6984,
4621,
1243,
317,
286,
7390,
16553,
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 |
#[test]
fn test_parse_expectations_latency() {
assert_expectation(
indoc!(
"
mysql:
expectation:
- type: LATENCY
threshold: 10
"
),
Some(Expectation::Latency(10)),
);
} | rust_cleaned_test_functions.jsonl/74663 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 156
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
68918,
804,
74832,
368,
341,
286,
2060,
68918,
367,
1006,
310,
1257,
509,
33673,
394,
6228,
12272,
510,
220,
30193,
510,
262,
481,
943,
25,
53187,
42458,
198,
414,
12171,
25,
220,
16,
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 |
#[test]
fn test_merge_compatible_schema() {
let schema1 = SchemaBuilder::new()
.tag("the_tag")
.influx_field("int_field", Integer)
.build()
.unwrap();
let schema2 = SchemaBuilder::new()
.measurement("my_measurement")
.tag("the_other_tag")
.influx_field("int_field", Integer)
.influx_field("another_field", Integer)
.build()
.unwrap();
let merged_schema = schema1.try_merge(schema2).unwrap();
let expected_schema = SchemaBuilder::new()
.measurement("my_measurement")
.tag("the_tag")
.influx_field("int_field", Integer)
.tag("the_other_tag")
.influx_field("another_field", Integer)
.build()
.unwrap();
assert_eq!(
expected_schema, merged_schema,
"\nExpected:\n{:#?}\nActual:\n{:#?}",
expected_schema, merged_schema
);
} | rust_cleaned_test_functions.jsonl/44074 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 558
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20888,
2965,
37079,
25371,
368,
341,
286,
1077,
10802,
16,
284,
12539,
3297,
486,
931,
741,
310,
659,
4578,
445,
1782,
9372,
1138,
310,
659,
258,
36706,
5013,
445,
396,
5013,
497,
4440,
340,
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_mimc_groth16() {
// We're going to use the Groth-Maller17 proving system.
use ark_groth16::{
create_random_proof, generate_random_parameters, prepare_verifying_key,
verify_proof as raw_verify_proof,
};
use ark_std::test_rng;
let rng = &mut test_rng();
// Generate the MiMC round constants
let constants = (0..MIMC_ROUNDS).map(|_| rng.gen()).collect::<Vec<_>>();
println!("Creating parameters...");
// Create parameters for our circuit
let params = {
let c = MiMCDemo::<Fr> {
xl: None,
xr: None,
constants: &constants,
};
generate_random_parameters::<Bn254, _, _>(c, rng).unwrap()
};
let pvk = prepare_verifying_key(¶ms.vk);
println!("Creating proofs...");
// Let's benchmark stuff!
// const SAMPLES: u32 = 50;
// benchmark deserialization.
// let mut proof_vec = vec![];
// Generate a random preimage and compute the image
let xl: Fr = rng.gen();
let xr: Fr = rng.gen();
let image = mimc(xl, xr, &constants);
let input_vec = vec![image.clone()];
{
// Create an instance of our circuit (with the
// witness)
let c = MiMCDemo {
xl: Some(xl),
xr: Some(xr),
constants: &constants,
};
// Create a groth16 proof with our parameters.
let proof = create_random_proof(c, ¶ms, rng).unwrap();
// proof encode
let mut proof_encode = Vec::new();
proof.write(&mut proof_encode).unwrap();
println!("proof:{}", hex::encode(&proof_encode));
// vk encode
let mut vk_encode = Vec::new();
params.vk.gamma_g2.write(&mut vk_encode).unwrap();
params.vk.delta_g2.write(&mut vk_encode).unwrap();
params.vk.alpha_g1.write(&mut vk_encode).unwrap();
params.vk.beta_g2.write(&mut vk_encode).unwrap();
println!("vk:{}", hex::encode(&vk_encode));
// vk_ic encode
let vk_ic = params
.vk
.gamma_abc_g1
.iter()
.map(|ic| {
let mut ic_vector = Vec::new();
ic.write(&mut ic_vector).unwrap();
ic_vector
})
.collect::<Vec<Vec<u8>>>();
let mut vk_ic_slice = Vec::new();
vk_ic.iter().for_each(|ic| vk_ic_slice.push(ic.to_vec()));
println!("vk_ic:{}", hex::encode(&vk_ic_slice[0]));
println!("vk_ic2:{}", hex::encode(&vk_ic_slice[1]));
let mut input = vec![Vec::new(); 1];
input_vec.iter().enumerate().for_each(|(i, scalar)| {
scalar.write(&mut input[i]).unwrap();
});
let public_input = input.iter().map(|x| x.to_vec()).collect::<Vec<_>>();
println!("public_input:{}", hex::encode(&public_input[0]));
assert!(
verify_proof::<Bn254>(vk_ic_slice, vk_encode, proof_encode, public_input,)
.expect("verify proof fail ")
);
}
} | rust_cleaned_test_functions.jsonl/64266 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1531
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
717,
318,
66,
1889,
299,
339,
16,
21,
368,
341,
262,
442,
1205,
2299,
2087,
311,
990,
279,
17888,
339,
5251,
13956,
16,
22,
38758,
1849,
624,
262,
990,
55217,
1889,
299,
339,
16,
21,
74843,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_check_if_board_is_won() {
let (boards, _input_numbers) = parse_puzzle::input(SAMPLE_INPUT);
let boards = boards.to_owned();
let mut chosen_board = boards[0].clone();
let is_won_before_played = check_if_board_is_won(&chosen_board);
assert_eq!(is_won_before_played, false);
for row_of_entries in chosen_board.entries.iter_mut(){
for entry in row_of_entries {
entry.marked = true;
}
}
let is_won_after_played = check_if_board_is_won(&chosen_board);
assert_eq!(is_won_after_played, true);
} | rust_cleaned_test_functions.jsonl/55616 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 302
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7200,
11119,
23919,
6892,
1670,
263,
368,
341,
286,
1077,
320,
19270,
11,
716,
1355,
32964,
8,
284,
4715,
620,
14945,
486,
1355,
3759,
18918,
21022,
317,
286,
1077,
20490,
284,
20490,
2389,
51973,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_feature_set_activate_deactivate() {
let mut feature_set = FeatureSet::default();
let feature = Pubkey::new_unique();
assert!(!feature_set.is_active(&feature));
feature_set.activate(&feature, 0);
assert!(feature_set.is_active(&feature));
feature_set.deactivate(&feature);
assert!(!feature_set.is_active(&feature));
} | rust_cleaned_test_functions.jsonl/38677 | {
"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,
17069,
2602,
67894,
2259,
16856,
368,
341,
286,
1077,
5206,
4565,
2602,
284,
19998,
1649,
486,
2258,
1428,
286,
1077,
4565,
284,
22611,
792,
486,
931,
21218,
543,
286,
2060,
0,
3471,
12753,
2602,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_sigils() {
assert_eq!(&["#"], ChannelId::SIGILS);
assert_eq!(&[":"], EmojiId::SIGILS);
assert_eq!(&["#", ":", "@&", "@!", "@", "t:"], MentionType::SIGILS);
assert_eq!(&["@&"], RoleId::SIGILS);
assert_eq!(&["@!", "@"], UserId::SIGILS);
} | rust_cleaned_test_functions.jsonl/3587 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 158
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
29252,
8669,
368,
341,
286,
2060,
10714,
0,
2099,
1183,
2,
7914,
13434,
764,
486,
50631,
1715,
50,
317,
286,
2060,
10714,
0,
2099,
58,
3252,
1125,
82367,
764,
486,
50631,
1715,
50,
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_topological_sort() -> Result<(), Error> {
let ns: Vec<StackString> = (0..8).map(|i| format!("n{}", i).into()).collect();
let dependencies = hashmap! {
"n0".into() => btreeset!["n1".into(), "n2".into(), "n3".into()],
"n1".into() => btreeset!["n4".into(), "n6".into()],
"n2".into() => btreeset!["n4".into()],
"n3".into() => btreeset!["n5".into(), "n6".into()],
"n4".into() => BTreeSet::new(),
"n5".into() => BTreeSet::new(),
"n6".into() => btreeset!["n7".into()],
"n7".into() => btreeset!["n4".into()],
};
let expected: Vec<&StackString> = vec![
&ns[0], &ns[3], &ns[5], &ns[2], &ns[1], &ns[6], &ns[7], &ns[4],
];
let result = topological_sort(&dependencies)?;
assert_eq!(result, expected);
Ok(())
} | rust_cleaned_test_functions.jsonl/25439 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 486
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10426,
5729,
18435,
368,
1464,
5714,
68843,
4600,
29,
341,
286,
1077,
12268,
25,
11312,
27,
4336,
703,
29,
284,
320,
15,
496,
23,
568,
2186,
22428,
72,
91,
3561,
17223,
77,
42351,
600,
568,
18... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_query_stats_inspect_error_counters() {
let mut exec = fasync::TestExecutor::new_with_fake_time().unwrap();
const START_NANOS: i64 = 1_234_567;
let () = exec.set_fake_time(fasync::Time::from_nanos(START_NANOS));
let env = TestEnvironment::new();
let inspector = fuchsia_inspect::Inspector::new();
let _query_stats_inspect_node =
add_query_stats_inspect(inspector.root(), env.stats.clone());
const FAILED_QUERY_COUNT: u64 = 10;
const FAILED_QUERY_DURATION: fuchsia_zircon::Duration =
fuchsia_zircon::Duration::from_millis(500);
for _ in 0..FAILED_QUERY_COUNT {
let () = run_fake_lookup(
&mut exec,
env.stats.clone(),
Some(ResolveErrorKind::Timeout),
FAILED_QUERY_DURATION,
);
}
assert_data_tree!(inspector, root:{
query_stats: {
"window 1": {
start_time_nanos: u64::try_from(
START_NANOS + FAILED_QUERY_DURATION.into_nanos()
).unwrap(),
successful_queries: 0u64,
failed_queries: FAILED_QUERY_COUNT,
average_failure_duration_micros: u64::try_from(
FAILED_QUERY_DURATION.into_micros()
).unwrap(),
errors: {
Message: 0u64,
NoRecordsFound: 0u64,
Io: 0u64,
Proto: 0u64,
Timeout: FAILED_QUERY_COUNT,
},
},
}
});
} | rust_cleaned_test_functions.jsonl/101207 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1032
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5738,
15381,
34386,
987,
4096,
85632,
368,
341,
286,
1077,
5206,
3883,
284,
282,
7692,
486,
2271,
25255,
486,
931,
6615,
56881,
3009,
1005,
15454,
543,
286,
733,
20998,
1604,
1093,
3126,
25,
600,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_vcx_endorse_cred_def() {
let _setup = SetupLibraryWalletPoolZeroFees::init();
let (_, schema_id, did, revocation_details) = prepare_create_cred_def_data(false);
let (endorser_did, _) = add_new_did(Some("ENDORSER"));
let (handle, cred_def_request, rev_reg_def_req, rev_reg_entry_req) = prepare_credentialdef_for_endorser("test_vcx_endorse_cred_def".to_string(), "Test Credential Def".to_string(), did, schema_id, "tag".to_string(), revocation_details.to_string(), endorser_did.clone()).unwrap();
assert_eq!(0, get_state(handle).unwrap());
assert_eq!(0, update_state(handle).unwrap());
assert!(rev_reg_def_req.is_none());
assert!(rev_reg_entry_req.is_none());
settings::set_config_value(settings::CONFIG_INSTITUTION_DID, &endorser_did);
ledger::endorse_transaction(&cred_def_request).unwrap();
::std::thread::sleep(::std::time::Duration::from_millis(1000));
assert_eq!(1, update_state(handle).unwrap());
assert_eq!(1, get_state(handle).unwrap());
} | rust_cleaned_test_functions.jsonl/96773 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 460
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2273,
25844,
6213,
10836,
73475,
7844,
368,
341,
286,
1077,
716,
15188,
284,
18626,
16915,
38259,
10551,
17999,
37,
5516,
486,
2327,
1428,
286,
1077,
39464,
10802,
842,
11,
1521,
11,
5772,
2276,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_type_for_char() {
assert_eq!(char::from(Type::Char), 'A');
assert_eq!(char::from(Type::Int8), 'c');
assert_eq!(char::from(Type::UInt8), 'C');
assert_eq!(char::from(Type::Int16), 's');
assert_eq!(char::from(Type::UInt16), 'S');
assert_eq!(char::from(Type::Int32), 'i');
assert_eq!(char::from(Type::UInt32), 'I');
assert_eq!(char::from(Type::Float), 'f');
assert_eq!(char::from(Type::String), 'Z');
assert_eq!(char::from(Type::Hex), 'H');
assert_eq!(char::from(Type::Array), 'B');
} | rust_cleaned_test_functions.jsonl/23141 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 302
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5673,
1819,
5478,
9232,
368,
341,
286,
2060,
10714,
10297,
1762,
486,
1499,
22498,
486,
4768,
701,
364,
32,
1157,
286,
2060,
10714,
10297,
1762,
486,
1499,
22498,
486,
1072,
23,
701,
364,
66,
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_fixed_strings() {
let dirs = &["test1", "test2"];
let files = &["test1/a.foo", "test1/a_foo", "test2/Download (1).tar.gz"];
let te = TestEnv::new(dirs, files);
te.assert_output(
&["a.foo"],
"test1/a.foo
test1/a_foo",
);
te.assert_output(&["--fixed-strings", "a.foo"], "test1/a.foo");
te.assert_output(&["download (1)"], "");
te.assert_output(
&["--fixed-strings", "download (1)"],
"test2/Download (1).tar.gz",
);
// Combine with --case-sensitive
te.assert_output(&["--fixed-strings", "--case-sensitive", "download (1)"], "");
} | rust_cleaned_test_functions.jsonl/10892 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 318
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
37839,
33500,
368,
341,
262,
1077,
42248,
284,
609,
1183,
1944,
16,
497,
330,
1944,
17,
6332,
262,
1077,
3542,
284,
609,
1183,
1944,
16,
14186,
58432,
497,
330,
1944,
16,
14186,
761,
2624,
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_shift_right_3() {
let original: Vec<u8> = vec![0xE6, 0x38, 0x6D, 0x84];
let expected: Vec<u8> = vec![0x0E, 0x63, 0x86, 0xD8, 0x40];
assert_array_eq(expected.clone(), common::shift_right(&original.clone(), 12));
assert_array_eq(expected.clone(), common::shift_left(&original.clone(), -12));
} | rust_cleaned_test_functions.jsonl/57142 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 148
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
22230,
10539,
62,
18,
368,
341,
262,
1077,
4024,
25,
11312,
34837,
23,
29,
284,
7486,
20703,
15,
12606,
21,
11,
220,
15,
87,
18,
23,
11,
220,
15,
87,
21,
35,
11,
220,
15,
87,
23,
19,
935... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_issue486() {
let hdr = indoc! {"
namespace a {
namespace spanner {
class Key;
}
} // namespace a
namespace spanner {
class Key {
public:
bool b(a::spanner::Key &);
};
} // namespace spanner
"};
let rs = quote! {};
run_test("", hdr, rs, &["spanner::Key"], &[]);
} | rust_cleaned_test_functions.jsonl/9928 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 246
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
53340,
19,
23,
21,
368,
341,
262,
1077,
36615,
284,
1257,
509,
0,
314,
698,
286,
4473,
264,
341,
310,
4473,
9390,
1194,
341,
394,
536,
5309,
280,
310,
456,
286,
335,
442,
4473,
264,
198,
286... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_graph_construction_1() {
let w1 = vec![
None, Some(-1.0f64),
Some(4.0f64), None
];
let mut g = super::Digraph::from_vec(&w1);
let edges1 = vec![
g.get_edge((0, 0)), g.get_edge((0, 1)),
g.get_edge((1, 0)), g.get_edge((1, 1))
];
let set_0: Vec<usize> = vec![0];
let set_1: Vec<usize> = vec![1];
assert_eq!(edges1, w1);
assert_eq!(g.size(), 2);
assert_eq!(g.is_loopfree(), true);
assert_eq!(g.is_nonnegative(), false);
assert_eq!(g.is_complete(), true);
assert_eq!(g.is_symmetric(), false);
assert_eq!(g.predecessors(0), set_1);
assert_eq!(g.predecessors(1), set_0);
assert_eq!(g.successors(0), set_1);
assert_eq!(g.successors(1), set_0);
let w2 = vec![
Some(1.0f64), Some(2.0f64),
Some(3.0f64), Some(4.0f64),
];
g.set_edge((0, 0), w2[0]);
g.set_edge((0, 1), w2[1]);
g.set_edge((1, 0), w2[2]);
g.set_edge((1, 1), w2[3]);
let edges2 = vec![
g.get_edge((0, 0)), g.get_edge((0, 1)),
g.get_edge((1, 0)), g.get_edge((1, 1))
];
let set_01: Vec<usize> = vec![0, 1];
assert_eq!(edges2, w2);
assert_eq!(g.size(), 2);
assert_eq!(g.is_loopfree(), false);
assert_eq!(g.is_nonnegative(), true);
assert_eq!(g.is_complete(), true);
assert_eq!(g.is_symmetric(), false);
assert_eq!(g.predecessors(0), set_01);
assert_eq!(g.predecessors(1), set_01);
assert_eq!(g.successors(0), set_01);
assert_eq!(g.successors(1), set_01);
g.set_edge((0, 1), w2[2]);
assert_eq!(g.is_symmetric(), true);
} | rust_cleaned_test_functions.jsonl/42288 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1032
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14738,
3382,
3024,
62,
16,
368,
341,
286,
1077,
289,
16,
284,
7486,
90515,
310,
2240,
11,
4329,
4080,
16,
13,
15,
69,
21,
19,
1326,
310,
4329,
7,
19,
13,
15,
69,
21,
19,
701,
2240,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_append() {
let mut a = SortedVecSet::new();
a.insert(1);
a.insert(2);
a.insert(3);
let mut b = SortedVecSet::new();
b.insert(3);
b.insert(4);
b.insert(5);
a.append(&mut b);
assert_eq!(a.len(), 5);
assert_eq!(b.len(), 0);
assert_eq!(a.contains(&1), true);
assert_eq!(a.contains(&2), true);
assert_eq!(a.contains(&3), true);
assert_eq!(a.contains(&4), true);
assert_eq!(a.contains(&5), true);
} | rust_cleaned_test_functions.jsonl/110160 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 309
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26041,
368,
341,
286,
1077,
5206,
264,
284,
52688,
10050,
1649,
486,
931,
543,
286,
264,
7030,
7,
16,
317,
286,
264,
7030,
7,
17,
317,
286,
264,
7030,
7,
18,
626,
286,
1077,
5206,
293,
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_join_for_different_lengths() {
let empty: &[&str] = &[];
test_join!("", empty, "-");
test_join!("a", ["a"], "-");
test_join!("a-b", ["a", "b"], "-");
test_join!("-a-bc", ["", "a", "bc"], "-");
} | rust_cleaned_test_functions.jsonl/17590 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 117
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31017,
5478,
82741,
54416,
368,
341,
262,
1077,
4287,
25,
44590,
5,
495,
60,
284,
609,
15078,
262,
1273,
31017,
17223,
497,
4287,
11,
6523,
797,
262,
1273,
31017,
17223,
64,
497,
4383,
64,
7914,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ns_constructor() {
let cxx = indoc! {"
A::Bob::Bob() {}
"};
let hdr = indoc! {"
#include <cstdint>
#include <memory>
namespace A {
struct Bob {
Bob();
uint32_t a;
uint32_t b;
};
}
"};
let rs = quote! {
ffi::A::Bob::make_unique();
};
run_test(cxx, hdr, rs, &["A::Bob"], &[]);
} | rust_cleaned_test_functions.jsonl/9790 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 270
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34728,
66210,
368,
341,
262,
1077,
272,
4146,
284,
1257,
509,
0,
314,
698,
286,
362,
486,
32388,
486,
32388,
368,
5613,
262,
330,
2440,
262,
1077,
36615,
284,
1257,
509,
0,
314,
698,
286,
671,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_after_if() {
check(
r#"fn quux() { if true { () } <|> }"#,
expect![[r#"
kw const
kw else
kw else if
kw extern
kw fn
kw if
kw if let
kw impl
kw let
kw loop
kw match
kw mod
kw return
kw static
kw trait
kw type
kw unsafe
kw use
kw while
"#]],
);
check_edit(
"else",
r#"fn quux() { if true { () } <|> }"#,
r#"fn quux() { if true { () } else {$0} }"#,
);
} | rust_cleaned_test_functions.jsonl/99574 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 577
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
51354,
19844,
11119,
368,
341,
286,
1779,
1006,
310,
435,
55543,
8822,
922,
2200,
368,
314,
421,
830,
314,
1719,
335,
82639,
29,
335,
57676,
345,
310,
1720,
0,
15505,
81,
2,
698,
394,
29525,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_contract_sig_validation() {
// First create a funding transaction
let secp = Secp256k1::new();
let priv_1 =
PrivateKey::from_wif("cVt4o7BGAig1UXywgGSmARhxMdzP5qvQsxKkSsc1XEkw3tDTQFpy").unwrap();
let priv_2 =
PrivateKey::from_wif("5JYkZjmN7PVMjJUfJWfRFwtuXTGB439XV6faajeHPAM9Z2PT2R3").unwrap();
let pub1 = priv_1.public_key(&secp);
let pub2 = priv_2.public_key(&secp);
let funding_outpoint_script =
crate::wallet_sync::create_multisig_redeemscript(&pub1, &pub2);
let funding_spk = Address::p2sh(&funding_outpoint_script, NETWORK).script_pubkey();
let funding_tx = Transaction {
input: vec![TxIn {
// random outpoint
previous_output: OutPoint::from_str(
"5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456:42",
)
.unwrap(),
sequence: 0,
witness: Vec::new(),
script_sig: Script::new(),
}],
output: vec![TxOut {
script_pubkey: funding_spk,
value: 2000,
}],
lock_time: 0,
version: 2,
};
// Create the contract transaction spending the funding outpoint
let funding_outpoint = OutPoint::new(funding_tx.txid(), 0);
let contract_script = Script::from(Vec::from_hex("827ca914cdccf6695323f22d061a58c398deba38bba47148876321032e58afe51f9ed8ad3cc7897f634d881fdbe49a81564629ded8156bebd2ffd1af0120516721039b6347398505f5ec93826dc61c19f47c66c0283ee9be980e29ce325a0f4679ef000812dabb690fe0fd3768b2757b88ac").unwrap());
let contract_tx = create_receivers_contract_tx(
funding_outpoint,
funding_tx.output[0].value,
&contract_script,
);
// priv1 signs the contract and verify
let sig1 = sign_contract_tx(
&contract_tx,
&funding_outpoint_script,
funding_tx.output[0].value,
&priv_1.key,
)
.unwrap();
assert_eq!(
verify_contract_tx_sig(
&contract_tx,
&funding_outpoint_script,
funding_tx.output[0].value,
&pub1,
&sig1
),
true
);
// priv2 signs the contract and verify
let sig2 = sign_contract_tx(
&contract_tx,
&funding_outpoint_script,
funding_tx.output[0].value,
&priv_2.key,
)
.unwrap();
assert!(verify_contract_tx_sig(
&contract_tx,
&funding_outpoint_script,
funding_tx.output[0].value,
&pub2,
&sig2
));
} | rust_cleaned_test_functions.jsonl/112482 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1591
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
51499,
29252,
19416,
368,
341,
286,
442,
5512,
1855,
264,
10773,
7745,
198,
286,
1077,
511,
4672,
284,
4520,
79,
17,
20,
21,
74,
16,
486,
931,
543,
286,
1077,
6095,
62,
16,
4035,
310,
9679,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_draw_prediction() {
init(
DATA_GEN_RADIUS,
SPIN_SPAN,
DATA_NUM,
NUM_CLASSES,
DATA_GEN_RAND_MAX,
NETWORK_GEN_RAND_MAX,
FC_SIZE,
DESCENT_RATE,
REGULAR_RATE,
);
let width = 100;
let height = 100;
let buffer = alloc(width * height * 4);
draw_prediction(buffer, width, height, 2f32);
free(buffer, width * height * 4);
} | rust_cleaned_test_functions.jsonl/48786 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 296
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
23021,
51446,
368,
341,
286,
2930,
1006,
310,
14112,
42362,
60226,
345,
310,
9256,
687,
17747,
1093,
345,
310,
14112,
9631,
345,
310,
15943,
69164,
345,
310,
14112,
42362,
2568,
3976,
6806,
345,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_replace_missing_arg() {
let mut args = HashMap::new();
args.insert("from".to_string(), to_value(&"Hello").unwrap());
let result = replace(to_value(&"Hello world!").unwrap(), args);
assert!(result.is_err());
assert_eq!(
result.err().unwrap().description(),
"Filter `replace` expected an arg called `to`"
);
} | rust_cleaned_test_functions.jsonl/49418 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 183
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10633,
40447,
6057,
368,
341,
286,
1077,
5206,
2827,
284,
10528,
486,
931,
543,
286,
2827,
7030,
445,
1499,
3263,
983,
3904,
1507,
311,
3142,
2099,
1,
9707,
1827,
15454,
1423,
286,
1077,
1102,
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_builder_should_return_zero_number_of_game_playable_with_one_player() {
let t = TournamentBuilder::new()
.add("sylvain")
.finalize();
let ng = t.number_of_games_playable();
let np = t.number_of_player();
assert_eq!(0, ng);
assert_eq!(1, np);
} | rust_cleaned_test_functions.jsonl/109239 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 168
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28532,
43378,
12511,
19359,
5500,
3575,
18547,
22144,
480,
6615,
11667,
15524,
368,
341,
286,
1077,
259,
284,
18371,
3297,
486,
931,
741,
310,
659,
718,
445,
82,
14753,
466,
1138,
310,
659,
94405,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_resolve_url() -> Result<(), ParseError> {
let resolved_url = resolve_url("https://www.kernel.org", "../category/signatures.html")?;
assert_eq!(
resolved_url.as_str(),
"https://www.kernel.org/../category/signatures.html"
);
let resolved_url = resolve_url("https://www.kernel.org", "category/signatures.html")?;
assert_eq!(
resolved_url.as_str(),
"https://www.kernel.org/category/signatures.html"
);
let resolved_url = resolve_url(
"saved_page.htm",
"https://www.kernel.org/category/signatures.html",
)?;
assert_eq!(
resolved_url.as_str(),
"https://www.kernel.org/category/signatures.html"
);
let resolved_url = resolve_url(
"https://www.kernel.org",
"//www.kernel.org/theme/images/logos/tux.png",
)?;
assert_eq!(
resolved_url.as_str(),
"https://www.kernel.org/theme/images/logos/tux.png"
);
let resolved_url = resolve_url(
"https://www.kernel.org/category/signatures.html",
"/theme/images/logos/tux.png",
)?;
assert_eq!(
resolved_url.as_str(),
"https://www.kernel.org/theme/images/logos/tux.png"
);
Ok(())
} | rust_cleaned_test_functions.jsonl/41748 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 714
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
77291,
2903,
368,
1464,
5714,
68843,
14775,
1454,
29,
341,
286,
1077,
19673,
2903,
284,
8830,
2903,
445,
2428,
1110,
2136,
31226,
2659,
497,
7005,
5471,
35763,
2789,
2564,
899,
37445,
286,
2060,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.