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_return_pod_by_ref_and_ptr() {
let hdr = indoc! {"
#include <cstdint>
struct B {
uint32_t a;
};
struct A {
B b;
};
inline const B& return_b_ref(const A& a) {
return a.b;
}
inline const B* return_b_ptr(const A& a) {
return &a.b;
}
"};
let rs = quote! {
let a = ffi::A { b: ffi::B { a: 3 } };
assert_eq!(ffi::return_b_ref(&a).a, 3);
let b_ptr = ffi::return_b_ptr(&a);
assert_eq!(unsafe { b_ptr.as_ref() }.unwrap().a, 3);
};
run_test("", hdr, rs, &["return_b_ref", "return_b_ptr"], &["A", "B"]);
} | rust_cleaned_test_functions.jsonl/9737 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 401
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12511,
85337,
3710,
7793,
8378,
4348,
368,
341,
262,
1077,
36615,
284,
1257,
509,
0,
314,
698,
286,
671,
997,
366,
96975,
397,
286,
2036,
425,
341,
310,
2622,
18,
17,
528,
264,
280,
286,
2605,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_set_controller() {
local_test_e(|runtime| async move {
let universal_canister = set_up_universal_canister(&runtime).await;
universal_canister
.set_controller(universal_canister.canister_id().get())
.await
.unwrap();
// Can't use "query_": we get "IC0301: Could not find subnet for canister
// aaaaa-aa"
// The anonymous user is not allowed to do a "canister_status"
let res: Result<CanisterStatusResult, String> = runtime
.get_management_canister()
.update_(
ic00::Method::CanisterStatus.to_string(),
dfn_candid::candid,
(CanisterIdRecord::from(universal_canister.canister_id()),),
)
.await;
assert_matches!(res, Err(msg) if msg.contains(&ErrorCode::CanisterInvalidController.to_string()));
// Now call canister_status from the controller
let arg = universal_canister_argument_builder()
.call_simple(
IC_00,
ic00::Method::CanisterStatus.to_string(),
CallArgs::default().other_side(
Encode!(&CanisterIdRecord::from(universal_canister.canister_id())).unwrap(),
),
)
.build();
let status_bytes: Vec<u8> = universal_canister
.update_("update", bytes, arg)
.await
.unwrap();
let status = Decode!(&status_bytes, CanisterStatusResult).unwrap();
assert_eq!(status.controller(), universal_canister.canister_id().get());
Ok(())
})
} | rust_cleaned_test_functions.jsonl/39207 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 797
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2602,
21600,
368,
341,
262,
2205,
4452,
2204,
22428,
22255,
91,
3312,
3271,
341,
286,
1077,
20178,
27421,
1571,
284,
738,
8237,
4907,
33952,
27421,
1571,
2099,
22255,
568,
11421,
401,
286,
20178,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_outer_join() {
let (temp, rain) = create_frames();
let joined = temp.outer_join(&rain, "days", "days").unwrap();
println!("{:?}", &joined);
assert_eq!(joined.height(), 5);
assert_eq!(joined.column("days").unwrap().sum::<i32>(), Some(7));
} | rust_cleaned_test_functions.jsonl/4174 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 142
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
67258,
31017,
368,
341,
286,
1077,
320,
3888,
11,
11174,
8,
284,
1855,
29319,
543,
286,
1077,
10859,
284,
2730,
53719,
31017,
2099,
29093,
11,
330,
13778,
497,
330,
13778,
1827,
15454,
543,
286,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_bpf_to_bpf_scratch_registers() {
test_interpreter_and_jit_elf!(
"tests/elfs/scratch_registers.so",
[1],
(
b"log_64" => syscalls::BpfSyscallU64::call; syscalls::BpfSyscallU64 {},
),
{ |_vm, res: Result| { res.unwrap() == 112 } },
41
);
} | rust_cleaned_test_functions.jsonl/59035 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 186
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
880,
15897,
2346,
880,
15897,
59728,
754,
78360,
368,
341,
262,
1273,
15318,
28637,
8378,
5374,
275,
62,
490,
33673,
286,
330,
23841,
14,
490,
82,
14,
54055,
78360,
26476,
756,
286,
508,
16,
125... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_100099() {
assert_eq!(
get_final_state(parse_opcodes(&String::from("1,0,0,0,99"))),
vec![2, 0, 0, 0, 99]
);
} | rust_cleaned_test_functions.jsonl/105028 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 108
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
16,
15,
15,
15,
24,
24,
368,
341,
286,
2060,
10714,
33673,
310,
633,
20676,
4387,
27762,
10287,
25814,
2099,
703,
486,
1499,
445,
16,
11,
15,
11,
15,
11,
15,
11,
24,
24,
2761,
1326,
31... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_date_set_permissions_error() {
if !(get_effective_uid() == 0 || is_wsl()) {
let (_, mut ucmd) = at_and_ucmd!();
let result = ucmd.arg("--set").arg("2020-03-11 21:45:00+08:00").fails();
let result = result.no_stdout();
assert!(result.stderr.starts_with("date: cannot set date: "));
}
} | rust_cleaned_test_functions.jsonl/77626 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 164
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4164,
2602,
44767,
4096,
368,
341,
262,
421,
18208,
455,
27125,
533,
25396,
368,
621,
220,
15,
1369,
374,
1670,
3226,
2140,
341,
286,
1077,
39464,
5206,
575,
8710,
8,
284,
518,
8378,
68887,
2277... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_block() {
let keys = KeyPair::random();
let ts = Utc::now();
let txs = [2];
let tx_count = txs.len() as u32;
let content = Block {
height: Height(500),
tx_count,
prev_hash: crypto::hash(&[1]),
tx_hash: crypto::hash(&txs),
state_hash: crypto::hash(&[3]),
error_hash: crypto::hash(&[4]),
additional_headers: AdditionalHeaders::new(),
};
let precommits = vec![
Verified::from_value(
Precommit::new(
ValidatorId(123),
Height(15),
Round(25),
crypto::hash(&[1, 2, 3]),
crypto::hash(&[3, 2, 1]),
ts,
),
keys.public_key(),
keys.secret_key(),
),
Verified::from_value(
Precommit::new(
ValidatorId(13),
Height(25),
Round(35),
crypto::hash(&[4, 2, 3]),
crypto::hash(&[3, 3, 1]),
ts,
),
keys.public_key(),
keys.secret_key(),
),
Verified::from_value(
Precommit::new(
ValidatorId(323),
Height(15),
Round(25),
crypto::hash(&[1, 1, 3]),
crypto::hash(&[5, 2, 1]),
ts,
),
keys.public_key(),
keys.secret_key(),
),
];
let transactions = [
Verified::from_value(
Status::new(Height(2), Height(2), crypto::hash(&[]), 0),
keys.public_key(),
keys.secret_key(),
),
Verified::from_value(
Status::new(Height(4), Height(4), crypto::hash(&[2]), 0),
keys.public_key(),
keys.secret_key(),
),
Verified::from_value(
Status::new(Height(7), Height(7), crypto::hash(&[3]), 0),
keys.public_key(),
keys.secret_key(),
),
]
.iter()
.map(ObjectHash::object_hash)
.collect::<Vec<_>>();
let precommits_buf: Vec<_> = precommits.iter().map(BinaryValue::to_bytes).collect();
let block = Verified::from_value(
BlockResponse::new(
keys.public_key(),
content.clone(),
precommits_buf.clone(),
transactions.iter().cloned(),
),
keys.public_key(),
keys.secret_key(),
);
assert_eq!(block.author(), keys.public_key());
assert_eq!(block.payload().to, keys.public_key());
assert_eq!(block.payload().block, content);
assert_eq!(block.payload().precommits, precommits_buf);
assert_eq!(block.payload().transactions, transactions);
let block2: Verified<BlockResponse> = SignedMessage::from_bytes(block.to_bytes().into())
.unwrap()
.into_verified()
.unwrap();
assert_eq!(block2.author(), keys.public_key());
assert_eq!(block2.payload().to, keys.public_key());
assert_eq!(block2.payload().block, content);
assert_eq!(block2.payload().precommits, precommits_buf);
assert_eq!(block2.payload().transactions, transactions);
let block_proof = BlockProof::new(content, precommits);
let json_str = serde_json::to_string(&block_proof).unwrap();
let block_proof_1: BlockProof = serde_json::from_str(&json_str).unwrap();
assert_eq!(block_proof, block_proof_1);
} | rust_cleaned_test_functions.jsonl/43027 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2170
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7113,
368,
341,
286,
1077,
6894,
284,
5309,
12443,
486,
11463,
543,
286,
1077,
10591,
284,
547,
10413,
486,
3328,
543,
286,
1077,
9854,
82,
284,
508,
17,
935,
286,
1077,
9854,
3180,
284,
9854,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_segments_of_arrays() {
let mut buf = vec![255; 64];
let v1 = [1u8, 2, 3];
let v2 = [1u8, 3];
let v3 = [2u8, 5, 2, 3, 56, 3];
let dat = vec![v1.as_ref(), v2.as_ref(), v3.as_ref()];
Field::write(&dat, &mut buf, 48, 56);
<Vec<&[u8]> as Field>::check(&buf, 48.into(), 56.into(), 64.into()).unwrap();
let buf2 = buf.clone();
<Vec<&[u8]> as Field>::check(&buf2, 48.into(), 56.into(), 64.into()).unwrap();
let dat2: Vec<&[u8]> = unsafe { Field::read(&buf2, 48, 56) };
assert_eq!(dat2, dat);
//48 spaces + 8 segment of vec + 8 spaces = 64 +
// + v1_segment + v2_segment + v3_segment +
// + v1_body + v2_body + v3_body
assert_eq!(buf.len(), 64 + v1.len() + v2.len() + v3.len() + 3 * 8);
} | rust_cleaned_test_functions.jsonl/118849 | {
"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,
55735,
3575,
68983,
368,
341,
262,
1077,
5206,
6607,
284,
7486,
20703,
17,
20,
20,
26,
220,
21,
19,
935,
262,
1077,
348,
16,
284,
508,
16,
84,
23,
11,
220,
17,
11,
220,
18,
935,
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_invalid_icmpv4_in_ipv6() {
let ip_config = Ipv6::DUMMY_CONFIG;
let mut ctx = DummyEventDispatcherBuilder::from_config(ip_config.clone())
.build::<DummyEventDispatcher>();
let device = DeviceId::new_ethernet(1);
let frame_dst = FrameDestination::Unicast;
let ic_config = Ipv4::DUMMY_CONFIG;
let icmp_builder = IcmpPacketBuilder::<Ipv4, &[u8], _>::new(
ic_config.remote_ip,
ic_config.local_ip,
IcmpUnusedCode,
IcmpEchoRequest::new(0, 0),
);
let ip_builder = Ipv6PacketBuilder::new(
ip_config.remote_ip,
ip_config.local_ip,
64,
Ipv6Proto::Other(Ipv4Proto::Icmp.into()),
);
let buf = Buf::new(Vec::new(), ..)
.encapsulate(icmp_builder)
.encapsulate(ip_builder)
.serialize_vec_outer()
.unwrap();
receive_ipv6_packet(&mut ctx, device, frame_dst, buf);
// Should not have dispatched the packet.
assert_eq!(get_counter_val(&mut ctx, "dispatch_receive_ipv6_packet"), 0);
// but the netstack chooses to just drop the packet since we are not
// required to send the ICMP response.
assert_empty(ctx.dispatcher.frames_sent().iter());
} | rust_cleaned_test_functions.jsonl/122985 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 699
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31433,
32747,
1307,
85,
19,
1243,
49378,
21,
368,
341,
286,
1077,
5997,
5332,
284,
358,
30168,
21,
486,
35,
58673,
12568,
280,
286,
1077,
5206,
5635,
284,
50567,
1556,
21839,
3297,
486,
1499,
53... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_match_char_with_surrounding_properties() {
let o = CellGrid::o();
let q = CellGrid::q();
let u = CellGrid::u();
let unit4 = Cell::unit(4);
// Expecting to match .
let fragments = vec![arc(o, q, unit4), line(q, u)];
let top_left = &Property::empty();
let top = &Property::empty();
let top_right = &Property::empty();
let left = &Property::empty();
let right = Property::from_char('-').expect("must have a property");
let bottom_left = Property::from_char('/').unwrap();
let bottom = &Property::empty();
let bottom_right = &Property::empty();
let ch = PropertyBuffer::match_char_with_surrounding_properties(
&Settings::default(),
&fragments,
top_left,
top,
top_right,
left,
right,
bottom_left,
bottom,
bottom_right,
);
println!("ch: {:?}", ch);
assert_eq!(ch, Some(','));
} | rust_cleaned_test_functions.jsonl/33914 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 623
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10708,
9232,
6615,
49946,
1049,
287,
25158,
368,
341,
286,
1077,
297,
284,
13972,
3543,
486,
78,
543,
286,
1077,
2804,
284,
13972,
3543,
486,
80,
543,
286,
1077,
575,
284,
13972,
3543,
486,
84,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_formats() {
let rocket = rocket::ignite()
.mount("/", routes![json, xml, json_long, msgpack_long, msgpack,
plain, binary, other]);
let client = Client::tracked(rocket).unwrap();
let response = client.post("/").header(ContentType::JSON).dispatch();
assert_eq!(response.into_string().unwrap(), "json");
let response = client.post("/").header(ContentType::MsgPack).dispatch();
assert_eq!(response.into_string().unwrap(), "msgpack_long");
let response = client.post("/").header(ContentType::XML).dispatch();
assert_eq!(response.into_string().unwrap(), "xml");
let response = client.get("/").header(Accept::Plain).dispatch();
assert_eq!(response.into_string().unwrap(), "plain");
let response = client.get("/").header(Accept::Binary).dispatch();
assert_eq!(response.into_string().unwrap(), "binary");
let response = client.get("/").header(ContentType::JSON).dispatch();
assert_eq!(response.into_string().unwrap(), "plain");
let response = client.get("/").dispatch();
assert_eq!(response.into_string().unwrap(), "plain");
let response = client.put("/").header(ContentType::HTML).dispatch();
assert_eq!(response.status(), Status::NotFound);
} | rust_cleaned_test_functions.jsonl/34696 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 449
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
68351,
368,
341,
262,
1077,
24306,
284,
24306,
486,
95408,
741,
286,
659,
16557,
35460,
11291,
20703,
2236,
11,
8396,
11,
2951,
17799,
11,
3750,
4748,
17799,
11,
3750,
4748,
345,
2290,
14396,
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_preserve_root() {
for d in [
"/",
"/////dev///../../../../",
"../../../../../../../../../../../../../../",
"./../../../../../../../../../../../../../../",
] {
new_ucmd!()
.arg("--preserve-root")
.arg("-R")
.arg("bin").arg(d)
.fails()
.stderr_is("chgrp: it is dangerous to operate recursively on '/'\nchgrp: use --no-preserve-root to override this failsafe");
}
} | rust_cleaned_test_functions.jsonl/49269 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 267
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
32116,
5852,
12993,
368,
341,
1066,
262,
369,
294,
304,
2278,
286,
3521,
756,
286,
330,
97656,
3583,
2575,
84257,
756,
286,
63392,
84257,
84257,
2748,
756,
286,
5924,
84257,
84257,
84257,
2748,
75... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_ascii_boundary_below() -> io::Result<()> {
test_truncate_length("1337_hello_world", 15, "1337_hello_worl", "…")
} | rust_cleaned_test_functions.jsonl/106751 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 66
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
50238,
54004,
82750,
368,
1464,
6399,
486,
2077,
71698,
341,
262,
1273,
3547,
26900,
5118,
445,
16,
18,
18,
22,
96724,
31792,
497,
220,
16,
20,
11,
330,
16,
18,
18,
22,
96724,
1670,
269,
75,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_iter() {
let mut p = make_parser();
assert_eq!(p.next().and_then(|n| Some(n.typ)), Some(ItemType::ItemText));
assert_eq!(p.collect::<Vec<_>>().len(), 12);
} | rust_cleaned_test_functions.jsonl/8624 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 104
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11723,
368,
341,
286,
1077,
5206,
281,
284,
1281,
18517,
543,
286,
2060,
10714,
10297,
79,
4529,
1005,
437,
68367,
22428,
77,
91,
4329,
1445,
49286,
5731,
4329,
29771,
929,
486,
1234,
1178,
1106,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_distinct() {
let expected_sql = "SELECT DISTINCT \"bar\" FROM \"test\"";
let query = Select::from_table("test").column(Column::new("bar")).distinct();
let (sql, _) = Postgres::build(query).unwrap();
assert_eq!(expected_sql, sql);
} | rust_cleaned_test_functions.jsonl/6448 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 125
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16031,
7800,
368,
341,
286,
1077,
3601,
18063,
284,
330,
4858,
59086,
7245,
2257,
2105,
4295,
7245,
1944,
95349,
286,
1077,
3239,
284,
8427,
486,
1499,
5237,
445,
1944,
1827,
6229,
95105,
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_shr_reg_reg() {
assert_emit!(0xD3, 0xE8; emit_shr_reg_cl(0, RAX));
assert_emit!(0x41, 0xD3, 0xE9; emit_shr_reg_cl(0, R9));
assert_emit!(0x48, 0xD3, 0xE8; emit_shr_reg_cl(1, RAX));
assert_emit!(0x49, 0xD3, 0xE9; emit_shr_reg_cl(1, R9));
} | rust_cleaned_test_functions.jsonl/85466 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 186
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3712,
81,
4920,
4920,
368,
341,
286,
2060,
69082,
10297,
15,
15764,
18,
11,
220,
15,
12606,
23,
26,
16691,
3712,
81,
4920,
6794,
7,
15,
11,
431,
2954,
1106,
286,
2060,
69082,
10297,
15,
87,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_storage_stage_process_account_proofs() {
solana_logger::setup();
let keypair = Arc::new(Keypair::new());
let storage_keypair = Arc::new(Keypair::new());
let archiver_keypair = Arc::new(Keypair::new());
let exit = Arc::new(AtomicBool::new(false));
let GenesisConfigInfo {
mut genesis_config,
mint_keypair,
..
} = create_genesis_config(1000);
genesis_config
.native_instruction_processors
.push(solana_storage_program::solana_storage_program!());
let (ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_config);
let blocktree = Arc::new(Blocktree::open(&ledger_path).unwrap());
let bank = Bank::new(&genesis_config);
let bank = Arc::new(bank);
let bank_forks = Arc::new(RwLock::new(BankForks::new_from_banks(
&[bank.clone()],
vec![0],
)));
let cluster_info = test_cluster_info(&keypair.pubkey());
let (bank_sender, bank_receiver) = channel();
let storage_state = StorageState::new(
&bank.last_blockhash(),
SLOTS_PER_TURN_TEST,
bank.slots_per_segment(),
);
let storage_stage = StorageStage::new(
&storage_state,
bank_receiver,
Some(blocktree.clone()),
&keypair,
&storage_keypair,
&exit.clone(),
&bank_forks,
&cluster_info,
);
bank_sender.send(vec![bank.clone()]).unwrap();
// create accounts
let bank = Arc::new(Bank::new_from_parent(&bank, &keypair.pubkey(), 1));
let account_ix = storage_instruction::create_storage_account(
&mint_keypair.pubkey(),
&Pubkey::new_rand(),
&archiver_keypair.pubkey(),
1,
StorageAccountType::Archiver,
);
let account_tx = Transaction::new_signed_instructions(
&[&mint_keypair, &archiver_keypair],
account_ix,
bank.last_blockhash(),
);
bank.process_transaction(&account_tx).expect("create");
bank_sender.send(vec![bank.clone()]).unwrap();
let mut reference_keys;
{
let keys = &storage_state.state.read().unwrap().storage_keys;
reference_keys = vec![0; keys.len()];
reference_keys.copy_from_slice(keys);
}
let keypair = Keypair::new();
let mining_proof_ix = storage_instruction::mining_proof(
&archiver_keypair.pubkey(),
Hash::default(),
0,
keypair.sign_message(b"test"),
bank.last_blockhash(),
);
let next_bank = Arc::new(Bank::new_from_parent(&bank, &keypair.pubkey(), 2));
//register ticks so the program reports a different segment
blocktree_processor::process_entries(
&next_bank,
&entry::create_ticks(
DEFAULT_TICKS_PER_SLOT * next_bank.slots_per_segment() + 1,
0,
bank.last_blockhash(),
),
true,
)
.unwrap();
let message = Message::new_with_payer(vec![mining_proof_ix], Some(&mint_keypair.pubkey()));
let mining_proof_tx = Transaction::new(
&[&mint_keypair, archiver_keypair.as_ref()],
message,
next_bank.last_blockhash(),
);
next_bank
.process_transaction(&mining_proof_tx)
.expect("process txs");
bank_sender.send(vec![next_bank]).unwrap();
for _ in 0..5 {
{
let keys = &storage_state.state.read().unwrap().storage_keys;
if keys[..] != *reference_keys.as_slice() {
break;
}
}
sleep(Duration::new(1, 0));
}
debug!("joining..?");
exit.store(true, Ordering::Relaxed);
storage_stage.join().unwrap();
{
let keys = &storage_state.state.read().unwrap().storage_keys;
assert_ne!(keys[..], *reference_keys);
}
remove_dir_all(ledger_path).unwrap();
} | rust_cleaned_test_functions.jsonl/82499 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2152
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
23310,
35238,
11305,
13500,
2540,
36081,
368,
341,
286,
2048,
3362,
27413,
486,
15188,
543,
286,
1077,
1376,
12670,
284,
19689,
486,
931,
7,
6608,
1082,
1310,
486,
931,
1423,
286,
1077,
5819,
3097... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_get_colors_error() {
let status = Command::new(get_path())
.arg("--base-colors=#FFFFFF,#001488")
.arg("--target-colors=000000")
.stderr(Stdio::null())
.status()
.expect("failed to start color_bruteforcer");
match status.code() {
Some(code) => assert_eq!(1, code),
None => assert!(false, "Process terminated by signal"),
}
} | rust_cleaned_test_functions.jsonl/4295 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 237
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
33670,
4096,
368,
341,
286,
1077,
2639,
284,
7348,
486,
931,
5433,
2638,
2398,
310,
659,
858,
21549,
3152,
7889,
82,
45131,
28321,
38898,
15,
15,
16,
19,
23,
23,
1138,
310,
659,
858,
215... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_pool_ray_srm() {
pool_actions::run_test(
"RDM.RAY-SRM-V4",
vec![
utils::Swap {
protocol: "RDM",
from_token: "SOL",
to_token: "RAY",
amount: 0.111,
},
utils::Swap {
protocol: "RDM",
from_token: "SOL",
to_token: "SRM",
amount: 0.111,
},
],
vec![],
false,
);
} | rust_cleaned_test_functions.jsonl/120672 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 348
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15709,
72690,
643,
8719,
368,
341,
262,
7314,
25368,
486,
6108,
4452,
1006,
286,
330,
49,
8395,
2013,
3022,
6222,
23652,
19625,
19,
756,
286,
7486,
90515,
310,
12439,
486,
46179,
341,
394,
11507,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_stop_sending_other_error_with_reset() {
let (mut client, mut server, request_stream_id) = connect_and_send_request(false);
// Stop sending with RequestRejected.
assert_eq!(
Ok(()),
server
.conn
.stream_stop_sending(request_stream_id, Error::HttpRequestRejected.code())
);
// also reset with RequestRejected.
assert_eq!(
Ok(()),
server
.conn
.stream_reset_send(request_stream_id, Error::HttpRequestRejected.code())
);
let out = server.conn.process(None, now());
client.process(out.dgram(), now());
let mut reset = false;
let mut stop_sending = false;
while let Some(e) = client.next_event() {
match e {
Http3ClientEvent::StopSending { stream_id, error } => {
assert_eq!(stream_id, request_stream_id);
assert_eq!(error, Error::HttpRequestRejected.code());
stop_sending = true;
}
Http3ClientEvent::Reset {
stream_id,
error,
local,
} => {
assert_eq!(stream_id, request_stream_id);
assert_eq!(error, Error::HttpRequestRejected.code());
assert!(!local);
reset = true;
}
Http3ClientEvent::HeaderReady { .. } | Http3ClientEvent::DataReadable { .. } => {
panic!("We should not get any headers or data");
}
_ => {}
}
}
assert!(reset);
assert!(stop_sending);
// after this stream will be removed from client. We will check this by trying to read
// from the stream and that should fail.
let mut buf = [0_u8; 100];
let res = client.read_response_data(now(), request_stream_id, &mut buf);
assert!(res.is_err());
assert_eq!(res.unwrap_err(), Error::InvalidStreamId);
client.close(now(), 0, "");
} | rust_cleaned_test_functions.jsonl/101903 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1145
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19039,
643,
2459,
30456,
4096,
6615,
18983,
368,
341,
1789,
286,
1077,
320,
6984,
2943,
11,
5206,
3538,
11,
1681,
12673,
842,
8,
284,
4564,
8378,
13565,
7893,
3576,
626,
286,
442,
14215,
11628,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_rm_force() {
let (at, mut ucmd) = testing(UTIL_NAME);
let file_a = "test_rm_force_a";
let file_b = "test_rm_force_b";
let result = ucmd.arg("-f")
.arg(file_a)
.arg(file_b)
.run();
assert_empty_stderr!(result);
assert!(result.success);
assert!(!at.file_exists(file_a));
assert!(!at.file_exists(file_b));
} | rust_cleaned_test_functions.jsonl/61414 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 236
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
58537,
40739,
368,
341,
262,
1077,
320,
266,
11,
5206,
575,
8710,
8,
284,
7497,
7,
36969,
4708,
317,
262,
1077,
1034,
4306,
284,
330,
1944,
58537,
40739,
4306,
876,
262,
1077,
1034,
880,
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_escaped_char() {
assert_eq!(
apply(
r#"
'\'' +
"#
.trim()
),
Ok(vec![
Token::Char(span(1, 1, "'\\''")),
Token::Symbol(span(1, 6, "+"))
])
)
} | rust_cleaned_test_functions.jsonl/27569 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 215
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
65826,
9232,
368,
341,
286,
2060,
10714,
33673,
310,
3796,
1006,
394,
435,
2,
698,
15777,
4605,
3610,
1,
4956,
503,
659,
10666,
741,
310,
2837,
310,
7622,
25592,
90515,
394,
9660,
486,
4768,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_std() {
::init().unwrap();
let mut it = Iterator::from_vec(vec![1i32, 2, 3]).into_iter();
assert_eq!(it.next(), Some(Ok(1)));
assert_eq!(it.next(), Some(Ok(2)));
assert_eq!(it.next(), Some(Ok(3)));
assert_eq!(it.next(), None);
} | rust_cleaned_test_functions.jsonl/50298 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 161
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15656,
368,
341,
286,
3504,
2327,
1005,
15454,
1428,
286,
1077,
5206,
432,
284,
23023,
486,
1499,
13251,
25592,
20703,
16,
72,
18,
17,
11,
220,
17,
11,
220,
18,
10697,
18122,
11723,
543,
286,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_index_debug() {
let mut list = VecList::new();
let index = list.push_back(5);
assert_eq!(
format!("{:?}", index),
format!("Index(0, {})", index.generation)
);
} | rust_cleaned_test_functions.jsonl/11490 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 129
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3560,
15446,
368,
341,
286,
1077,
5206,
1140,
284,
11312,
852,
486,
931,
543,
286,
1077,
1922,
284,
1140,
2552,
3895,
7,
20,
626,
286,
2060,
10714,
33673,
310,
3561,
88928,
25,
52652,
1922,
1326... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_is_current() {
let now = Instant::now();
let not_the_future = now + Duration::from_secs(4);
let future = now + Duration::from_secs(5);
let past_the_future = now + Duration::from_secs(6);
let value = LruValue {
lookup: Err(ResolveErrorKind::Message("test error").into()),
valid_until: future,
};
assert!(value.is_current(now));
assert!(value.is_current(not_the_future));
assert!(value.is_current(future));
assert!(!value.is_current(past_the_future));
} | rust_cleaned_test_functions.jsonl/2126 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 269
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6892,
11080,
368,
341,
286,
1077,
1431,
284,
18058,
486,
3328,
543,
286,
1077,
537,
16068,
59740,
284,
1431,
488,
21045,
486,
1499,
68718,
7,
19,
317,
286,
1077,
3853,
284,
1431,
488,
21045,
486... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_yield_rate_period() {
let expected = 0.005_f32;
let invest = Investment::new(10000, 12, 0.06, 0);
assert!(
&expected.approx_eq(&invest.yield_rate_period(), 2.0 * ::std::f32::EPSILON, 2),
"expected: {}, actual: {}",
expected,
invest.yield_rate_period()
);
} | rust_cleaned_test_functions.jsonl/126190 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 192
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
83709,
9246,
20818,
368,
341,
286,
1077,
3601,
284,
220,
15,
13,
15,
15,
20,
761,
18,
17,
280,
286,
1077,
2725,
284,
32250,
486,
931,
7,
16,
15,
15,
15,
15,
11,
220,
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_new_run_classical_register() {
pyo3::prepare_freethreaded_python();
Python::with_gil(|py| -> () {
let mut circs: Vec<CircuitWrapper> = Vec::new();
circs.push(CircuitWrapper::new());
let mut circ1 = CircuitWrapper::new();
circ1.internal += RotateX::new(0, 0.0.into());
circs.push(circ1.clone());
let br_type = py.get_type::<ClassicalRegisterWrapper>();
let input = br_type
.call1((Some(CircuitWrapper::new()), circs.clone()))
.unwrap()
.cast_as::<PyCell<ClassicalRegisterWrapper>>()
.unwrap();
let program_type = py.get_type::<QuantumProgramWrapper>();
let program = program_type
.call1((input, vec!["test".to_string()]))
.unwrap()
.cast_as::<PyCell<QuantumProgramWrapper>>()
.unwrap();
let program_wrapper = program.extract::<QuantumProgramWrapper>().unwrap();
let cr = ClassicalRegister {
constant_circuit: Some(Circuit::new()),
circuits: vec![Circuit::new(), circ1.internal],
};
assert_eq!(
program_wrapper,
QuantumProgramWrapper {
internal: QuantumProgram::ClassicalRegister {
measurement: cr.clone(),
input_parameter_names: vec!["test".to_string()]
}
}
);
let measurement = ClassicalRegisterWrapper::extract(
program
.call_method1("run_registers", (TestBackend, Some(vec![0.0])))
.unwrap(),
)
.unwrap();
assert_eq!(measurement.internal, cr);
let error = program.call_method1("run", (TestBackend, Some(vec![0.0])));
assert!(error.is_err());
})
} | rust_cleaned_test_functions.jsonl/8604 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 903
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5921,
14007,
4790,
938,
14000,
368,
341,
262,
4510,
78,
18,
486,
13609,
74179,
769,
878,
291,
55869,
543,
262,
13027,
486,
4197,
1889,
321,
22428,
3288,
91,
1464,
1719,
341,
286,
1077,
5206,
422... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_extend() {
let cmd = RelayCmd::EXTEND;
assert_eq!(Into::<u8>::into(cmd), 6_u8);
let body = "7F000001 138C
71510FC729E1DBE35586F0031D69A38FC684B26D657821EE640C299BA9F8FD38D3A3376F2DD3A79A0B73836AB4B42E5FB3BEE1383F3184A852B292626DCC64AF672A8FAEFC263C38370768EF9EA6C244BA079142D3E23835F6914DE0C7F468316C4265E109F5312987275D61E1DC831A3323195DDE70841CEE2DC30F6DCDBDABA40A75FDFB714431FC5EB8F84D4150EE2C2478A79018F18D7F30F6BB677516CF03390F5180B371DEAEBB89175798864D2130B13ED1D20B254F07
CF555174CBE8AD62A7E764A8F3D85D40C5145ABB";
let addr = "127.0.0.1".parse::<Ipv4Addr>().unwrap();
let handshake = hex::decode("71510FC729E1DBE35586F0031D69A38FC684B26D657821EE640C299BA9F8FD38D3A3376F2DD3A79A0B73836AB4B42E5FB3BEE1383F3184A852B292626DCC64AF672A8FAEFC263C38370768EF9EA6C244BA079142D3E23835F6914DE0C7F468316C4265E109F5312987275D61E1DC831A3323195DDE70841CEE2DC30F6DCDBDABA40A75FDFB714431FC5EB8F84D4150EE2C2478A79018F18D7F30F6BB677516CF03390F5180B371DEAEBB89175798864D2130B13ED1D20B254F07").unwrap();
let rsa =
RsaIdentity::from_bytes(&hex::decode("CF555174CBE8AD62A7E764A8F3D85D40C5145ABB").unwrap())
.unwrap();
msg(
cmd,
body,
&msg::Extend::new(addr, 5004, handshake, rsa).into(),
);
} | rust_cleaned_test_functions.jsonl/66344 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 752
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
70265,
368,
341,
262,
1077,
5439,
284,
46172,
15613,
486,
5722,
4689,
280,
262,
2060,
10714,
10297,
26591,
27638,
84,
23,
6831,
18122,
14160,
701,
220,
21,
7300,
23,
626,
262,
1077,
2487,
284,
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_star_network_pull_50() {
let mut network = star_network_create(50);
let thread_pool = build_gossip_thread_pool();
network_simulator_pull_only(&thread_pool, &mut network);
} | rust_cleaned_test_functions.jsonl/2395 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 80
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31681,
20966,
65693,
62,
20,
15,
368,
341,
262,
1077,
5206,
3922,
284,
6774,
20966,
8657,
7,
20,
15,
317,
262,
1077,
4516,
15709,
284,
1936,
1889,
41473,
10814,
15709,
543,
262,
3922,
18314,
105... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_aes_siv_cmac256_enc() {
let key = hex::decode("fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0\
f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff").unwrap();
let aad = hex::decode("101112131415161718191a1b1c1d1e1f\
2021222324252627").unwrap();
let plaintext = hex::decode("112233445566778899aabbccddee").unwrap();
// NOTE: Layout = IV || C
let mut ciphertext_and_tag = plaintext.clone();
for _ in 0..AesSivCmac256::TAG_LEN {
ciphertext_and_tag.insert(0, 0);
}
let cipher = AesSivCmac256::new(&key);
cipher.encrypt_slice(&[&aad], &mut ciphertext_and_tag);
assert_eq!(&ciphertext_and_tag[..],
&hex::decode("85632d07c6e8f37f950acd320a2ecc93\
40c02b9690c4dc04daef7f6afe5c").unwrap()[..]);
let key = hex::decode("7f7e7d7c7b7a79787776757473727170\
404142434445464748494a4b4c4d4e4f").unwrap();
let ad1 = hex::decode("\
00112233445566778899aabbccddeeff\
deaddadadeaddadaffeeddccbbaa9988\
7766554433221100").unwrap();
let ad2 = hex::decode("102030405060708090a0").unwrap();
let nonce = hex::decode("09f911029d74e35bd84156c5635688c0").unwrap();
let plaintext = hex::decode("7468697320697320736f6d6520706c61\
696e7465787420746f20656e63727970\
74207573696e67205349562d414553").unwrap();
// NOTE: Layout = IV || C
let mut ciphertext_and_tag = plaintext.clone();
for _ in 0..AesSivCmac256::TAG_LEN {
ciphertext_and_tag.insert(0, 0);
}
let cipher = AesSivCmac256::new(&key);
cipher.encrypt_slice(&[&ad1, &ad2, &nonce], &mut ciphertext_and_tag);
assert_eq!(&ciphertext_and_tag[..], &hex::decode("7bdb6e3b432667eb06f4d14bff2fbd0f\
cb900f2fddbe404326601965c889bf17\
dba77ceb094fa663b7a3f748ba8af829\
ea64ad544a272e9c485b62a3fd5c0d").unwrap()[..]);
} | rust_cleaned_test_functions.jsonl/78463 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 931
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
90958,
643,
344,
666,
11948,
17,
20,
21,
13781,
368,
341,
9401,
262,
1077,
1376,
981,
284,
12371,
486,
18196,
445,
14092,
823,
2940,
9792,
13233,
2577,
24,
69,
23,
69,
22,
69,
21,
69,
20,
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... | 3 |
#[test]
fn test_is_votable() {
let (genesis_block, mint_keypair) = GenesisBlock::new(500);
let bank = Arc::new(Bank::new(&genesis_block));
let key1 = Keypair::new();
assert_eq!(bank.is_votable(), false);
// Set is_delta to true
let tx_transfer_mint_to_1 =
system_transaction::transfer(&mint_keypair, &key1.pubkey(), 1, genesis_block.hash(), 0);
assert_eq!(bank.process_transaction(&tx_transfer_mint_to_1), Ok(()));
assert_eq!(bank.is_votable(), false);
// Register enough ticks to hit max tick height
for i in 0..genesis_block.ticks_per_slot - 1 {
bank.register_tick(&hash::hash(format!("hello world {}", i).as_bytes()));
}
assert_eq!(bank.is_votable(), true);
} | rust_cleaned_test_functions.jsonl/41910 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 363
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6892,
2273,
354,
480,
368,
341,
286,
1077,
320,
77894,
7113,
11,
28337,
3097,
12670,
8,
284,
40788,
4713,
486,
931,
7,
20,
15,
15,
317,
286,
1077,
6073,
284,
19689,
486,
931,
5349,
1180,
486,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_set_time_warp() {
let mut environment = CanisterEnv::new();
let start = environment.now();
environment.set_time_warp(TimeWarp { delta_s: 1_000 });
let delta_s = environment.now() - start;
assert!(delta_s >= 1000, "delta_s = {}", delta_s);
assert!(delta_s < 1005, "delta_s = {}", delta_s);
} | rust_cleaned_test_functions.jsonl/57026 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 144
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2602,
3009,
1670,
7876,
368,
341,
262,
1077,
5206,
4573,
284,
2980,
1571,
14359,
486,
931,
1428,
262,
1077,
1191,
284,
4573,
10700,
543,
262,
4573,
980,
3009,
1670,
7876,
36968,
54,
7876,
314,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_decode_and() {
match decode_16(0x401a) {
Instruction::AND_reg { params, thumb32 } => {
assert_eq!(params.rd, Reg::R2);
assert_eq!(params.rn, Reg::R2);
assert_eq!(params.rm, Reg::R3);
assert_eq!(thumb32, false);
assert_eq!(params.shift_t, SRType::LSL);
assert_eq!(params.shift_n, 0);
assert!(params.setflags == SetFlags::NotInITBlock);
}
_ => {
assert!(false);
}
}
} | rust_cleaned_test_functions.jsonl/64776 | {
"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,
15227,
8378,
368,
341,
1066,
262,
2432,
16895,
62,
16,
21,
7,
15,
87,
19,
15,
16,
64,
8,
341,
286,
29051,
486,
3976,
4920,
314,
3628,
11,
24050,
18,
17,
335,
589,
341,
310,
2060,
10714,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_should_panic_non_string_message_type() {
use crate::tests::TrFailedMsg;
use std::any::TypeId;
fn f() {
std::panic::panic_any(1i32);
}
let expected = "foobar";
let failed_msg = format!(
r#"expected panic with string value,
found non-string value: `{:?}`
expected substring: `"foobar"`"#,
TypeId::of::<i32>()
);
let desc = TestDescAndFn {
desc: TestDesc {
name: StaticTestName("whatever"),
ignore: false,
should_panic: ShouldPanic::YesWithMessage(expected),
allow_fail: false,
compile_fail: false,
no_run: false,
test_type: TestType::Unknown,
},
testfn: DynTestFn(Box::new(f)),
};
let (tx, rx) = channel();
run_test(&TestOpts::new(), false, TestId(0), desc, RunStrategy::InProcess, tx, Concurrent::No);
let result = rx.recv().unwrap().result;
assert_eq!(result, TrFailedMsg(failed_msg));
} | rust_cleaned_test_functions.jsonl/7705 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 470
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
43378,
620,
31270,
21637,
3904,
6462,
1819,
368,
341,
262,
990,
17717,
486,
23841,
486,
1282,
9408,
6611,
280,
262,
990,
1460,
486,
3767,
486,
31934,
280,
262,
5168,
282,
368,
341,
286,
1460,
48... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_can_validate_option_fields_without_lifetime() {
let instance = ParentWithOptionalChild { child: Some(Child { value: String::new() }) };
let res = instance.validate();
assert!(res.is_err());
let err = res.unwrap_err();
let errs = err.errors();
assert_eq!(errs.len(), 1);
assert!(errs.contains_key("child"));
if let ValidationErrorsKind::Struct(ref errs) = errs["child"] {
unwrap_map(errs, |errs| {
assert_eq!(errs.len(), 1);
assert!(errs.contains_key("value"));
if let ValidationErrorsKind::Field(ref errs) = errs["value"] {
assert_eq!(errs.len(), 1);
assert_eq!(errs[0].code, "length");
} else {
panic!("Expected field validation errors");
}
});
} else {
panic!("Expected struct validation errors");
}
} | rust_cleaned_test_functions.jsonl/779 | {
"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,
27421,
42681,
9672,
12132,
39904,
98827,
368,
341,
262,
1077,
2867,
284,
17022,
2354,
15309,
3652,
314,
1682,
25,
4329,
7,
3652,
314,
897,
25,
923,
486,
931,
368,
6413,
3634,
262,
1077,
592,
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... | 3 |
#[test]
fn test_read_holding_registers() {
let (_s, cfg) = start_dummy_server_with_cfg();
let mut trans = Transport::new_with_cfg("127.0.0.1", cfg).unwrap();
assert_eq!(trans.read_holding_registers(0, 5).unwrap().len(), 5);
assert!(trans.read_holding_registers(0, 5).unwrap().iter().all(|c| *c == 0));
} | rust_cleaned_test_functions.jsonl/46834 | {
"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,
6443,
1523,
14995,
78360,
368,
341,
286,
1077,
5453,
82,
11,
13286,
8,
284,
1191,
60321,
12015,
6615,
18343,
543,
286,
1077,
5206,
1356,
284,
16742,
486,
931,
6615,
18343,
445,
16,
17,
22,
13,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_empty_statement() {
let src = r#"
;;;let a = 10;;
if(a) ;
a
"#;
assert_eq!(&exec(src), "10");
} | rust_cleaned_test_functions.jsonl/39568 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 90
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15124,
37404,
368,
341,
262,
1077,
2286,
284,
435,
2,
698,
286,
2587,
6768,
1149,
264,
284,
220,
16,
15,
28207,
286,
421,
2877,
8,
4386,
286,
264,
198,
262,
5869,
280,
262,
2060,
10714,
0,
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 |
#[test]
fn test_state_info_update() {
fn update_delta(port: Delta<StateEvent>, system: Delta<SystemState>) -> StateDelta {
StateDelta {
port: IpVersions { ipv4: port.clone(), ipv6: port },
system: IpVersions { ipv4: system.clone(), ipv6: system },
}
}
let if1_local_event = StateEvent::construct(State::Local);
let if1_local = IpVersions::<StateEvent>::construct(if1_local_event);
// Post-update the system state should be Local due to interface 1.
let mut state = StateInfo::default();
let want = update_delta(
Delta { previous: None, current: if1_local_event },
Delta { previous: None, current: SystemState { id: ID1, state: if1_local_event } },
);
assert_eq!(state.update(ID1, if1_local.clone()), want);
let want_state = StateInfo {
per_interface: std::iter::once((ID1, if1_local.clone())).collect::<HashMap<_, _>>(),
system: IpVersions { ipv4: Some(ID1), ipv6: Some(ID1) },
};
assert_eq!(state, want_state);
let if2_gateway_event = StateEvent::construct(State::Gateway);
let if2_gateway = IpVersions::<StateEvent>::construct(if2_gateway_event);
// will be Gateway due to interface 2.
let want = update_delta(
Delta { previous: None, current: if2_gateway_event },
Delta {
previous: Some(SystemState { id: ID1, state: if1_local_event }),
current: SystemState { id: ID2, state: if2_gateway_event },
},
);
assert_eq!(state.update(ID2, if2_gateway.clone()), want);
let want_state = StateInfo {
per_interface: [(ID1, if1_local.clone()), (ID2, if2_gateway.clone())]
.iter()
.cloned()
.collect::<HashMap<_, _>>(),
system: IpVersions { ipv4: Some(ID2), ipv6: Some(ID2) },
};
assert_eq!(state, want_state);
let if2_removed_event = StateEvent::construct(State::Removed);
let if2_removed = IpVersions::<StateEvent>::construct(if2_removed_event);
// will be Local due to interface 1.
let want = update_delta(
Delta { previous: Some(if2_gateway_event), current: if2_removed_event },
Delta {
previous: Some(SystemState { id: ID2, state: if2_gateway_event }),
current: SystemState { id: ID1, state: if1_local_event },
},
);
assert_eq!(state.update(ID2, if2_removed.clone()), want);
let want_state = StateInfo {
per_interface: [(ID1, if1_local.clone()), (ID2, if2_removed.clone())]
.iter()
.cloned()
.collect::<HashMap<_, _>>(),
system: IpVersions { ipv4: Some(ID1), ipv6: Some(ID1) },
};
assert_eq!(state, want_state);
} | rust_cleaned_test_functions.jsonl/64394 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1438
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4387,
3109,
8882,
368,
341,
286,
5168,
2647,
26710,
21230,
25,
24957,
62201,
1556,
8066,
1849,
25,
24957,
30721,
1397,
9231,
1464,
3234,
20277,
341,
310,
3234,
20277,
341,
394,
2635,
25,
35033,
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_mm_anon() {
let siz = 1024 * 1024;
let addr = mm_anon(siz).unwrap();
unsafe {
assert_eq!(*(addr.offset((siz - 1) as isize) as *const u8), 0u8);
}
} | rust_cleaned_test_functions.jsonl/91343 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 121
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
35599,
12008,
263,
368,
341,
286,
1077,
64896,
284,
220,
16,
15,
17,
19,
353,
220,
16,
15,
17,
19,
280,
286,
1077,
10789,
284,
9465,
12008,
263,
1141,
449,
568,
15454,
543,
286,
19860,
341,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_lif_manager_add_same_name() {
let mut lm = LIFManager::new();
let l = LIF::new(3, LIFType::LAN, "lan1", PortId::from(0), vec![PortId::from(1)], 0, None)
.unwrap();
lm.add_lif(&l).unwrap();
let l = LIF::new(4, LIFType::LAN, "lan1", PortId::from(0), vec![PortId::from(2)], 0, None)
.unwrap();
assert!(lm.add_lif(&l).is_err());
assert_eq!(lm.lifs.len(), 1);
} | rust_cleaned_test_functions.jsonl/81914 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 248
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
907,
333,
12144,
2891,
33574,
1269,
368,
341,
286,
1077,
5206,
40238,
284,
444,
2773,
2043,
486,
931,
543,
286,
1077,
326,
284,
444,
2773,
486,
931,
7,
18,
11,
444,
2773,
929,
486,
23408,
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_rfc6979_sample() {
let msg = "sample";
let k = "A6E3C57DD01ABE90086538398355DD4C3B17AA873382B0F24D6129493D8AAD60";
let r = "EFD48B2AACB6A8FD1140DD9CD45E81D69D2C877B56AAF991C34D0EA84EAF3716";
let s = "F7CB1C942D657C41D436C7A1B6E29F65F3E900DBB9AFF4064DC4AB2F843ACDA8";
test_rfc6979(msg, k, r, s);
} | rust_cleaned_test_functions.jsonl/81724 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 227
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1710,
8316,
21,
24,
22,
24,
17491,
368,
341,
286,
1077,
3750,
284,
330,
13611,
876,
286,
1077,
595,
284,
330,
32,
21,
36,
18,
34,
20,
22,
4103,
15,
16,
1867,
36,
24,
15,
15,
23,
21,
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_find_saves_node() {
let node_table = DummyNodeTable { node: None };
let mut svc: Service<TestsIdType, net::SocketAddr, DummyNodeTable, String> =
Service::new(node_table);
let node = test::new_node(test::make_id(43));
assert!(svc.handler.on_find_node(&node, &node.id).is_empty());
let result = svc.handler.on_find_node(&node, &node.id);
assert_eq!(1, result.len());
assert_eq!(test::make_id(43), result.get(0).unwrap().id)
} | rust_cleaned_test_functions.jsonl/110956 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 241
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21814,
643,
4693,
5084,
368,
341,
286,
1077,
2436,
5237,
284,
50567,
1955,
2556,
314,
2436,
25,
2240,
2605,
286,
1077,
5206,
46154,
25,
5362,
27,
18200,
764,
929,
11,
4179,
486,
10286,
13986,
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_insert_all() {
let mut map = MultiMap::new();
map.insert("a", "b");
map.insert_all("a", vec!["c"], false);
map.insert_all("a", vec!["d"], false);
assert_eq!(*map.get("a").unwrap(), vec!["b", "c", "d"]);
let replace = map.insert_all("a", vec!["e"], true);
assert_eq!(replace, Some(vec!["b", "c", "d"]));
let vec = &map["a"];
assert_eq!(vec, &vec!["e"]);
} | rust_cleaned_test_functions.jsonl/134333 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 193
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17678,
5705,
368,
341,
262,
1077,
5206,
2415,
284,
17439,
2227,
486,
931,
1428,
262,
2415,
7030,
445,
64,
497,
330,
65,
3071,
262,
2415,
7030,
5705,
445,
64,
497,
7486,
0,
1183,
66,
7914,
895,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_count() {
use rand::thread_rng;
use rand::Rng;
use rand::seq::SliceRandom;
use std::collections::HashMap;
TIMER.run();
let mut rng = thread_rng();
let count = Arc::new(AtomicUsize::new(0));
let mut timer_refs = vec![];
let mut timer_map = HashMap::new();
let total = 100000;
for _i in 1..total + 1 {
let count = count.clone();
let t = rng.gen_range(10, 5000);
let timer_ref =TIMER.set_timeout(FuncRuner::new(Box::new(move || {
count.fetch_add(1, Ordering::SeqCst);
})), t);
timer_refs.push(timer_ref);
timer_map.insert(timer_ref, true);
}
let cancel: Vec<usize> = timer_refs.choose_multiple(&mut rng, 50).cloned().collect();
println!("shuffled timer_refs = {:?}", cancel);
let mut cancel_success = Vec::new();
let mut cancel_fail = Vec::new();
for c in cancel {
if let Some(_) = TIMER.cancel(c) {
cancel_success.push(c);
} else {
cancel_fail.push(c);
}
thread::sleep(Duration::from_millis(rng.gen_range(10, 100)));
}
thread::sleep(Duration::from_millis(5100));
println!("run: {:?}, total: {:?}, cancel_success: {}, cancel_fail:{}", count, total, cancel_success.len(), cancel_fail.len());
} | rust_cleaned_test_functions.jsonl/507 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 604
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3180,
368,
972,
262,
990,
10382,
486,
4528,
66849,
463,
262,
990,
10382,
486,
49,
968,
463,
41819,
10382,
486,
13262,
486,
33236,
13999,
463,
41819,
1460,
486,
51137,
486,
18497,
1926,
262,
49931,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
#[test]
fn test_benchmarks() {
ExtBuilder::build_with(|storage| {
pallet_balances::GenesisConfig::<Test, pallet_balances::Instance1> {
balances: vec![
(account("Origin", 0, 0), 1 << 32),
(account("Vault", 0, 0), 1 << 32),
],
}
.assimilate_storage(storage)
.unwrap();
sla::GenesisConfig::<Test> {
vault_target_sla: FixedI128::from(100),
vault_redeem_failure_sla_change: FixedI128::from(0),
vault_executed_issue_max_sla_change: FixedI128::from(0),
vault_submitted_issue_proof: FixedI128::from(0),
vault_refunded: FixedI128::from(1),
relayer_target_sla: FixedI128::from(100),
relayer_block_submission: FixedI128::from(1),
relayer_correct_no_data_vote_or_report: FixedI128::from(1),
relayer_correct_invalid_vote_or_report: FixedI128::from(10),
relayer_correct_liquidation_report: FixedI128::from(1),
relayer_correct_theft_report: FixedI128::from(1),
relayer_correct_oracle_offline_report: FixedI128::from(1),
relayer_false_no_data_vote_or_report: FixedI128::from(-10),
relayer_false_invalid_vote_or_report: FixedI128::from(-100),
relayer_ignored_vote: FixedI128::from(-10),
}
.assimilate_storage(storage)
.unwrap();
GenesisConfig::<Test> {
gov_id: account("Origin", 0, 0),
maturity_period: 10,
}
.assimilate_storage(storage)
.unwrap();
})
.execute_with(|| {
assert_ok!(test_benchmark_register_staked_relayer::<Test>());
assert_ok!(test_benchmark_deregister_staked_relayer::<Test>());
assert_ok!(test_benchmark_suggest_status_update::<Test>());
assert_ok!(test_benchmark_vote_on_status_update::<Test>());
assert_ok!(test_benchmark_force_status_update::<Test>());
assert_ok!(test_benchmark_slash_staked_relayer::<Test>());
assert_ok!(test_benchmark_report_vault_theft::<Test>());
assert_ok!(test_benchmark_report_vault_under_liquidation_threshold::<
Test,
>());
assert_ok!(test_benchmark_remove_active_status_update::<Test>());
assert_ok!(test_benchmark_remove_inactive_status_update::<Test>());
});
} | rust_cleaned_test_functions.jsonl/43779 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1370
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
880,
19762,
15544,
368,
341,
286,
9447,
3297,
486,
5834,
6615,
22428,
16172,
91,
341,
310,
58803,
56441,
3020,
486,
84652,
2648,
27638,
2271,
11,
58803,
56441,
3020,
486,
2523,
16,
29,
341,
394,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_neuron_spawn() {
let from = *TEST_NEURON_1_OWNER_PRINCIPAL;
// Compute the subaccount to which the transfer would have been made
let nonce = 1234u64;
let block_height = 543212234;
let dissolve_delay_seconds = MIN_DISSOLVE_DELAY_FOR_VOTE_ELIGIBILITY_SECONDS;
let neuron_stake_e8s = 1_000_000_000;
let (mut driver, mut gov, id, _) = governance_with_staked_neuron(
dissolve_delay_seconds,
neuron_stake_e8s,
block_height,
from,
nonce,
);
let neuron = gov.get_neuron_mut(&id).expect("Neuron did not exist");
assert_eq!(
neuron.get_neuron_info(driver.now()).state(),
NeuronState::NotDissolving
);
// Starts with too little maturity
neuron.maturity_e8s_equivalent = 187;
assert!(
neuron.maturity_e8s_equivalent
< NetworkEconomics::with_default_values().neuron_minimum_stake_e8s
);
let child_controller = *TEST_NEURON_2_OWNER_PRINCIPAL;
// An attempt to spawn a neuron should simply return an error and
// change nothing.
let neuron_before = neuron.clone();
let spawn_res = gov
.spawn_neuron(
&id,
&from,
&Spawn {
new_controller: Some(child_controller),
},
)
.now_or_never()
.unwrap();
assert_matches!(
spawn_res,
Err(GovernanceError{error_type: code, error_message: msg})
if code == InsufficientFunds as i32 && msg.to_lowercase().contains("maturity"));
assert_eq!(*gov.get_neuron(&id).unwrap(), neuron_before);
// Artificially set the neuron's maturity to sufficient value
let neuron = gov.get_neuron_mut(&id).expect("Neuron did not exist");
let parent_maturity_e8s_equivalent: u64 = 123_456_789;
assert!(
parent_maturity_e8s_equivalent
> NetworkEconomics::with_default_values().neuron_minimum_stake_e8s
);
neuron.maturity_e8s_equivalent = parent_maturity_e8s_equivalent;
// Advance the time so that we can check that the spawned neuron has the age
// and the right creation timestamp
driver.advance_time_by(1);
let child_nid = gov
.spawn_neuron(
&id,
&from,
&Spawn {
new_controller: Some(child_controller),
},
)
.now_or_never()
.unwrap()
.unwrap();
// We should now have 2 neurons.
assert_eq!(gov.proto.neurons.len(), 2);
// And we should have two ledger accounts.
driver.assert_num_neuron_accounts_exist(2);
let child_neuron = gov
.get_neuron(&child_nid)
.expect("The child neuron is missing");
let parent_neuron = gov.get_neuron(&id).expect("The parent neuron is missing");
let child_subaccount = child_neuron.account.clone();
// Maturity on the parent neuron should be reset.
assert_eq!(parent_neuron.maturity_e8s_equivalent, 0);
assert_eq!(
child_neuron,
&Neuron {
id: Some(child_nid.clone()),
account: child_subaccount,
controller: Some(child_controller),
cached_neuron_stake_e8s: parent_maturity_e8s_equivalent,
created_timestamp_seconds: driver.now(),
aging_since_timestamp_seconds: driver.now(),
dissolve_state: Some(DissolveState::DissolveDelaySeconds(
gov.proto
.economics
.as_ref()
.unwrap()
.neuron_spawn_dissolve_delay_seconds
)),
kyc_verified: true,
..Default::default()
}
);
} | rust_cleaned_test_functions.jsonl/1161 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1716
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13925,
36090,
76026,
368,
341,
262,
1077,
504,
284,
353,
10033,
14039,
1511,
711,
62,
16,
74323,
10571,
38439,
3298,
969,
280,
262,
442,
22603,
279,
1186,
4608,
311,
892,
279,
8317,
1035,
614,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_start_training_selected_participant() {
let mut protocol = Protocol::new(get_default_fl_settings());
let resp = protocol.start_training(ClientState::Selected);
assert_eq!(StartTrainingResponse::Accept, resp);
assert!(protocol.next_event().is_none());
} | rust_cleaned_test_functions.jsonl/97780 | {
"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,
4906,
32891,
23755,
10495,
21757,
368,
341,
286,
1077,
5206,
11507,
284,
24572,
486,
931,
5433,
9993,
5081,
10853,
5231,
286,
1077,
9039,
284,
11507,
4962,
32891,
46851,
1397,
486,
6316,
626,
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 |
#[test]
fn test_issue_203() {
struct Bar(RwLock<()>);
impl Drop for Bar {
fn drop(&mut self) {
let _n = self.0.write();
}
}
thread_local! {
static B: Bar = Bar(RwLock::new(()));
}
thread::spawn(|| {
B.with(|_| ());
let a = RwLock::new(());
let _a = a.read();
})
.join()
.unwrap();
} | rust_cleaned_test_functions.jsonl/15765 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 278
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
53340,
62,
17,
15,
18,
368,
341,
286,
2036,
4716,
2785,
86,
11989,
71698,
626,
286,
11605,
15733,
369,
4716,
341,
310,
5168,
5943,
2099,
6984,
656,
8,
341,
394,
1077,
716,
77,
284,
656,
13,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_cipher_filter() {
let ecdhe_ciphers: Vec<&TlsCipherSuite> = CIPHERS
.values()
.filter(|c| c.kx == TlsCipherKx::Ecdhe)
.collect();
assert!(ecdhe_ciphers.len() > 20);
} | rust_cleaned_test_functions.jsonl/37915 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 144
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
76692,
8727,
368,
341,
286,
1077,
384,
4385,
383,
666,
82077,
25,
11312,
52244,
51,
4730,
79460,
28000,
29,
284,
356,
58088,
50,
198,
310,
659,
3661,
741,
310,
659,
5315,
22428,
66,
91,
272,
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_url_1() {
test_url("/npoplayer.html?tx_eonpo_npoplayer%5Bmid%5D=WO_EO_16582885&tx_eonpo_npoplayer%5Bhash%5D=45a69ca57ac8eee5025d45f06f9910f85fd9a0db814c590fg560293d<549880f&tx_eonpo_npoplayer%5Boverlay%5D=https%3A%2F%2Fblauwbloed.eo.nl%2Ffileadmin%2Fbestanden-2016%2Fuser_upload%2F2021-07%2FKoninklijk_gezin_fotosessie_zomer_2021.jpg&tx_eonpo_npoplayer%5Bhasadconsent%5D=0&tx_eonpo_npoplayer%5Breferralurl%5D=https%3A%2F%2Fblauwbloed.eo.nl%2Fartikel%2F2021%2F07%2Fkijk-de-eerste-foto-van-de-fotosessie-van-de-oranjes&tx_eonpo_npoplayer%5BsterSiteId%5D=blauwbloed&tx_eonpo_npoplayer%5BsterIdentifier%5D=blauwbloed-ios-smartphone&tx_eonpo_npoplayer%5BatinternetSiteId%5D=25&tx_eonpo_npoplayer%5BatinternetUserId%5D=287dbe14-d677-4b9b-8eeb-ecb389349db1&tx_eonpo_npoplayer%5BatinternetUserIdCookieDuration%5D=394");
} | rust_cleaned_test_functions.jsonl/23709 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 464
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2903,
62,
16,
368,
341,
286,
1273,
2903,
4283,
6199,
93108,
2564,
30,
3998,
2204,
263,
5368,
1089,
8374,
10333,
4,
20,
33,
16106,
4,
20,
35,
28,
22681,
2089,
46,
62,
16,
21,
20,
23,
17,
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_hover_return_impl_traits_has_goto_type_action() {
check_actions(
r#"
trait Foo {}
trait Bar {}
fn foo() -> impl Foo + Bar {}
fn main() { let s$0t = foo(); }
"#,
expect![[r#"
[
GoToType(
[
HoverGotoTypeData {
mod_path: "test::Foo",
nav: NavigationTarget {
file_id: FileId(
0,
),
full_range: 0..12,
focus_range: 6..9,
name: "Foo",
kind: Trait,
description: "trait Foo",
},
},
HoverGotoTypeData {
mod_path: "test::Bar",
nav: NavigationTarget {
file_id: FileId(
0,
),
full_range: 13..25,
focus_range: 19..22,
name: "Bar",
kind: Trait,
description: "trait Bar",
},
},
],
),
]
"#]],
);
} | rust_cleaned_test_functions.jsonl/66676 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1295
} | [
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_open_subkey_with_flags_query_info() {
let hklm = RegKey::predef(HKEY_LOCAL_MACHINE);
let win = hklm
.open_subkey_with_flags("Software\\Microsoft\\Windows", KEY_READ)
.unwrap();
let info = win.query_info().unwrap();
info.get_last_write_time_system();
#[cfg(feature = "chrono")]
info.get_last_write_time_chrono();
assert!(win
.open_subkey_with_flags("CurrentVersion\\", KEY_READ)
.is_ok());
assert!(hklm
.open_subkey_with_flags("i\\just\\hope\\nobody\\created\\that\\key", KEY_READ)
.is_err());
} | rust_cleaned_test_functions.jsonl/128082 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 277
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11311,
5228,
792,
6615,
14130,
5738,
3109,
368,
341,
262,
1077,
305,
10561,
76,
284,
3184,
1592,
486,
1726,
750,
10896,
4784,
28399,
66702,
317,
262,
1077,
3164,
284,
305,
10561,
76,
198,
286,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_utf_16le_decode_near_end() {
let mut output = [0u8; 4];
let mut decoder = UTF_16LE.new_decoder();
{
let (result, read, written, had_errors) =
decoder.decode_to_utf8(&[0x03], &mut output[..], false);
assert_eq!(result, CoderResult::InputEmpty);
assert_eq!(read, 1);
assert_eq!(written, 0);
assert!(!had_errors);
assert_eq!(output[0], 0x0);
}
{
let (result, read, written, had_errors) =
decoder.decode_to_utf8(&[0x26, 0x03, 0x26], &mut output[..], false);
assert_eq!(result, CoderResult::OutputFull);
assert_eq!(read, 1);
assert_eq!(written, 3);
assert!(!had_errors);
assert_eq!(output[0], 0xE2);
assert_eq!(output[1], 0x98);
assert_eq!(output[2], 0x83);
assert_eq!(output[3], 0x00);
}
} | rust_cleaned_test_functions.jsonl/86902 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 550
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39453,
62,
16,
21,
273,
15227,
76340,
6213,
368,
341,
286,
1077,
5206,
2550,
284,
508,
15,
84,
23,
26,
220,
19,
935,
286,
1077,
5206,
24551,
284,
20076,
62,
16,
21,
867,
4618,
49843,
543,
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_serialize_combo_option() {
let m = UciMessage::Option(UciOptionConfig::Combo {
name: "Style".to_string(),
default: Some(String::from("Normal")),
var: vec![String::from("Solid"), String::from("Normal"), String::from("Risky")],
});
assert_eq!(m.serialize(), "option name Style type combo default Normal var Solid var Normal var Risky");
} | rust_cleaned_test_functions.jsonl/19052 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 177
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
88686,
54781,
9672,
368,
341,
286,
1077,
296,
284,
547,
5855,
2052,
486,
5341,
12317,
5855,
5341,
2648,
486,
56893,
341,
310,
829,
25,
330,
2323,
3263,
983,
3904,
3148,
310,
1638,
25,
4329,
2242... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_specfile() {
let specfile = super::test_utils::file("logspec.toml");
std::fs::remove_file(&specfile).ok();
assert!(!specfile.exists());
let logger = Logger::try_with_str("info")
.unwrap()
.log_to_file(
FileSpec::default()
.directory(super::test_utils::dir())
.suppress_timestamp(),
)
.format(detailed_format)
.start_with_specfile(&specfile)
.unwrap_or_else(|e| panic!("Logger initialization failed because: {}", e));
error!("This is an error-0");
warn!("This is a warning-0");
info!("This is an info-0");
debug!("This is a debug-0");
trace!("This is a trace-0");
eprintln!(
"[{}] ===== behave like many editors: rename and recreate, as warn",
chrono::Local::now()
);
{
let mut old_name = specfile.clone();
old_name.set_file_name("old_logspec.toml");
std::fs::rename(&specfile, old_name).unwrap();
let mut file = std::fs::OpenOptions::new()
.create(true)
.write(true)
.open(&specfile)
.unwrap();
file.write_all(
b"
global_level = 'warn'
[modules]
",
)
.unwrap();
}
std::thread::sleep(std::time::Duration::from_millis(WAIT_MILLIS));
error!("This is an error-1");
warn!("This is a warning-1");
info!("This is an info-1");
debug!("This is a debug-1");
trace!("This is a trace-1");
eprintln!(
"[{}] ===== truncate and rewrite, update to error",
chrono::Local::now()
);
{
let mut file = std::fs::OpenOptions::new()
.truncate(true)
.write(true)
.open(&specfile)
.unwrap();
file.write_all(
b"
global_level = 'error'
[modules]
",
)
.unwrap();
}
std::thread::sleep(std::time::Duration::from_millis(WAIT_MILLIS));
error!("This is an error-2");
warn!("This is a warning-2");
info!("This is an info-2");
debug!("This is a debug-2");
trace!("This is a trace-2");
if cfg!(feature = "specfile") {
eprintln!("feature is: specfile!");
logger.validate_logs(&[
("ERROR", "test_specfile::a", "error-0"),
("WARN", "test_specfile::a", "warning-0"),
("INFO", "test_specfile::a", "info-0"),
("ERROR", "test_specfile::a", "error-1"),
("WARN", "test_specfile::a", "warning-1"),
("ERROR", "test_specfile::a", "error-2"),
]);
} else {
eprintln!("feature is: specfile_without_notification!");
logger.validate_logs(&[
("ERROR", "test_specfile::a", "error-0"),
("WARN", "test_specfile::a", "warning-0"),
("INFO", "test_specfile::a", "info-0"),
("ERROR", "test_specfile::a", "error-1"),
("WARN", "test_specfile::a", "warning-1"),
("INFO", "test_specfile::a", "info-1"),
("ERROR", "test_specfile::a", "error-2"),
("WARN", "test_specfile::a", "warning-2"),
("INFO", "test_specfile::a", "info-2"),
]);
}
} | rust_cleaned_test_functions.jsonl/125196 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2012
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13594,
1192,
368,
341,
286,
1077,
1398,
1192,
284,
2256,
486,
1944,
17309,
486,
1192,
445,
839,
9535,
73494,
75,
3071,
286,
1460,
486,
3848,
486,
5399,
2458,
2099,
9535,
1192,
568,
562,
543,
286... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_guide_library_positive() {
let g1 = Guide::new(0, "foo-1", "ACGTCAGCATGCATGACGTT", "FOO", GuideType::Other);
let g2 = Guide::new(1, "foo-2", "GCTAGACTGGACTCTAATGC", "FOO", GuideType::Other);
let l1 = GuideLibrary::new(vec![]).unwrap();
assert_eq!(l1.len(), 0);
assert!(l1.is_empty());
let l2 = GuideLibrary::new(vec![g1.clone(), g2.clone()]).unwrap();
assert_eq!(l2.len(), 2);
assert_eq!(l2.guides, vec![g1, g2]);
assert_eq!(l2.guide_length, 20);
} | rust_cleaned_test_functions.jsonl/48767 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 282
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
80407,
39461,
54160,
368,
341,
286,
1077,
342,
16,
284,
12712,
486,
931,
7,
15,
11,
330,
7975,
12,
16,
497,
330,
1706,
38,
7749,
1890,
28196,
22863,
828,
38,
1706,
38,
14903,
497,
330,
3788,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_many_categorys() {
let enc = build_fake_str_enc();
let cat_it = ["dog", "cat", "fish", "background"].iter().cloned();
let res: Vec<Option<Vec<f64>>> = cat_it.map(|v| enc.get_one_hot(&v)).collect();
let v = vec![
Some(vec![0.0, 1.0, 0.0]),
Some(vec![0.0, 0.0, 1.0]),
None,
Some(vec![1.0, 0.0, 0.0]),
];
assert_eq!(res, v)
} | rust_cleaned_test_functions.jsonl/109963 | {
"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,
22101,
11847,
82,
368,
341,
286,
1077,
3209,
284,
1936,
56881,
2895,
13781,
543,
286,
1077,
8251,
14631,
284,
4383,
18457,
497,
330,
4616,
497,
330,
18170,
497,
330,
6742,
5521,
2015,
1005,
564,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_catchable() {
#[derive(Debug, Display, Clone)]
enum MainErrorKind {
A1,
#[allow(dead_code)]
A2,
}
impl Error for MainErrorKind {};
impl From<MainErrorKind> for CommonError {
fn from(error: MainErrorKind) -> Self {
CommonError::new(CommonErrorKind::Main, Box::new(error))
}
}
#[derive(Debug, Display, Clone)]
enum ServiceErrorKind {
B1,
B2,
}
impl Error for ServiceErrorKind {};
impl From<ServiceErrorKind> for CommonError {
fn from(error: ServiceErrorKind) -> Self {
CommonError::new(CommonErrorKind::Service, Box::new(error))
}
}
fn call_service_b1() -> CommonResult<()> {
Err(ServiceErrorKind::B1.into())
}
fn call_service_b2() -> CommonResult<()> {
Err(ServiceErrorKind::B2.into())
}
// will catch b1
fn call_main_a1() -> CommonResult<()> {
let _result = call_service_b1().or_else_catch::<ServiceErrorKind, _>(|e| match e {
ServiceErrorKind::B1 => Some(Err(MainErrorKind::A1.into())),
_ => None,
})?;
Ok(())
}
// will catch b1 and ignore the error
fn call_main_a1_2() -> CommonResult<()> {
let _result = call_service_b1().or_else_catch::<ServiceErrorKind, _>(|e| match e {
ServiceErrorKind::B1 => Some(Ok(())),
_ => None,
})?;
Ok(())
}
// will not catch b2
fn call_main_a2() -> CommonResult<()> {
let _result = call_service_b2()?;
Ok(())
}
assert_eq!(format!("{}", call_main_a1().unwrap_err()), "Main Error: A1");
assert!(call_main_a1_2().is_ok());
assert_eq!(
format!("{}", call_main_a2().unwrap_err()),
"Service Error: B2"
);
} | rust_cleaned_test_functions.jsonl/103847 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 712
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
666,
754,
480,
368,
341,
197,
197,
13353,
27098,
42618,
11,
10623,
11,
27913,
5563,
197,
37777,
4697,
1454,
10629,
341,
298,
22985,
16,
345,
298,
197,
13353,
7183,
83207,
4136,
5563,
298,
22985,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_code_with_spaces() {
let mut reader = Lexer::from_str("1 2 3");
assert_tok(
&mut reader,
TokenKind::LitInt("1".into(), IntBase::Dec, IntSuffix::Int),
1,
1,
);
assert_tok(
&mut reader,
TokenKind::LitInt("2".into(), IntBase::Dec, IntSuffix::Int),
1,
3,
);
assert_tok(
&mut reader,
TokenKind::LitInt("3".into(), IntBase::Dec, IntSuffix::Int),
1,
5,
);
assert_end(&mut reader, 1, 6);
} | rust_cleaned_test_functions.jsonl/101124 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 372
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4136,
6615,
67883,
368,
341,
286,
1077,
5206,
6604,
284,
85082,
486,
1499,
2895,
445,
16,
220,
17,
220,
18,
797,
286,
2060,
76162,
1006,
310,
609,
6984,
6604,
345,
310,
9660,
10629,
486,
68954,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_passfile() -> Result<()> {
let user = "user";
let pass = "pass";
let path = create_passfile(&UserConfig::new(user.into(), pass.into()))?;
let buf = read(&path)?;
let s = String::from_utf8(buf)?;
assert_eq!(s, format!("{}+plc\n{}\n", user, pass));
let output = Command::new("/usr/bin/cat").arg(&path).output()?;
assert!(output.status.success());
Ok(())
} | rust_cleaned_test_functions.jsonl/102213 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 169
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15464,
1192,
368,
1464,
5714,
71698,
341,
197,
10217,
1196,
284,
330,
872,
876,
197,
10217,
1494,
284,
330,
6385,
876,
197,
10217,
1815,
284,
1855,
15464,
1192,
2099,
1474,
2648,
486,
931,
4277,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
#[test]
fn test_optopt() {
let long_args = vec!("--test=20".to_string());
let opts = vec!(optopt("t", "test", "testing", "TEST"));
let rs = getopts(long_args.as_slice(), opts.as_slice());
match rs {
Ok(ref m) => {
assert!(m.opt_present("test"));
assert_eq!(m.opt_str("test").unwrap(), "20");
assert!((m.opt_present("t")));
assert_eq!(m.opt_str("t").unwrap(), "20");
}
_ => panic!()
}
let short_args = vec!("-t".to_string(), "20".to_string());
match getopts(short_args.as_slice(), opts.as_slice()) {
Ok(ref m) => {
assert!((m.opt_present("test")));
assert_eq!(m.opt_str("test").unwrap(), "20");
assert!((m.opt_present("t")));
assert_eq!(m.opt_str("t").unwrap(), "20");
}
_ => panic!()
}
} | rust_cleaned_test_functions.jsonl/11179 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 505
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15032,
2912,
368,
341,
286,
1077,
1293,
8384,
284,
7486,
17223,
313,
1944,
28,
17,
15,
3263,
983,
3904,
1423,
286,
1077,
12185,
284,
7486,
10297,
2912,
2912,
445,
83,
497,
330,
1944,
497,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_parsing_after_editing_end_of_code() {
let mut parser = Parser::new();
parser.set_language(get_language("javascript")).unwrap();
let mut code = b"x * (100 + abc);".to_vec();
let mut tree = parser.parse(&code, None).unwrap();
assert_eq!(
tree.root_node().to_sexp(),
concat!(
"(program (expression_statement (binary_expression ",
"left: (identifier) ",
"right: (parenthesized_expression (binary_expression left: (number) right: (identifier))))))",
)
);
let position = code.len() - 2;
perform_edit(
&mut tree,
&mut code,
&Edit {
position,
deleted_length: 0,
inserted_text: b".d".to_vec(),
},
);
let mut recorder = ReadRecorder::new(&code);
let tree = parser
.parse_with(&mut |i, _| recorder.read(i), Some(&tree))
.unwrap();
assert_eq!(
tree.root_node().to_sexp(),
concat!(
"(program (expression_statement (binary_expression ",
"left: (identifier) ",
"right: (parenthesized_expression (binary_expression ",
"left: (number) ",
"right: (member_expression ",
"object: (identifier) ",
"property: (property_identifier)))))))"
)
);
assert_eq!(recorder.strings_read(), vec![" * ", "abc.d)",]);
} | rust_cleaned_test_functions.jsonl/15867 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 666
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
28598,
19844,
13156,
287,
6213,
3575,
4136,
368,
341,
262,
1077,
5206,
6729,
284,
21102,
486,
931,
543,
262,
6729,
980,
29021,
5433,
29021,
445,
14073,
15197,
15454,
1428,
262,
1077,
5206,
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_grounding_not_3() -> TestResult {
test_grounding(
r#"
f(x) if x > 0 and not (x >= 1 and x = 1);
"#,
term!(call!("f", [sym!("x")])),
&[|r: Bindings| {
assert_partial_expression!(r, "x", "_this > 0 and _this != 1");
Ok(())
}],
)
} | rust_cleaned_test_functions.jsonl/63052 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 262
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
72492,
287,
7913,
62,
18,
368,
1464,
3393,
2077,
341,
286,
1273,
72492,
287,
1006,
310,
435,
2,
698,
310,
282,
2075,
8,
421,
856,
861,
220,
15,
323,
537,
320,
87,
2604,
220,
16,
323,
856,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_args_lr_update_rate() {
let mut args = Args::new();
assert_eq!(100, args.lr_update_rate());
args.set_lr_update_rate(50);
assert_eq!(50, args.lr_update_rate());
} | rust_cleaned_test_functions.jsonl/118612 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 111
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8384,
46086,
8882,
9246,
368,
341,
286,
1077,
5206,
2827,
284,
17693,
486,
931,
543,
286,
2060,
10714,
10297,
16,
15,
15,
11,
2827,
63349,
8882,
9246,
5231,
286,
2827,
980,
46086,
8882,
9246,
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 |
#[test]
fn test_memory_transport_server_only_auth() {
test_transport_success(
memory::MemoryTransport,
Auth::ServerOnly,
"/memory/0",
expect_memory_noise_addr,
);
} | rust_cleaned_test_functions.jsonl/14345 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 128
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19195,
46398,
12015,
18410,
14014,
368,
341,
286,
1273,
46398,
18632,
1006,
310,
4938,
486,
10642,
27560,
345,
310,
7366,
486,
5475,
7308,
345,
310,
3521,
17269,
14,
15,
756,
310,
1720,
19195,
403... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_range_of_line_at_position_b() {
let code: Vec<char> = "text\ntext".to_string().chars().collect();
assert_eq!(range_of_line_at_position(&code, 5), 5..9);
let code: Vec<char> = "text\ntext".to_string().chars().collect();
assert_eq!(range_of_line_at_position(&code, 7), 5..9);
let code: Vec<char> = "text\ntext".to_string().chars().collect();
assert_eq!(range_of_line_at_position(&code, 8), 5..9);
} | rust_cleaned_test_functions.jsonl/126884 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 218
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9698,
3575,
6528,
3752,
9661,
880,
368,
341,
286,
1077,
2038,
25,
11312,
21919,
29,
284,
330,
1318,
59,
406,
427,
3263,
983,
3904,
1005,
19255,
1005,
17384,
543,
286,
2060,
10714,
10297,
9669,
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_integration() {
let expr = ExprDefBuilder::aggr_func(ExprType::Sum, FieldTypeTp::Double)
.push_child(ExprDefBuilder::column_ref(0, FieldTypeTp::VarString))
.build();
AggrFnDefinitionParserSum.check_supported(&expr).unwrap();
let src_schema = [FieldTypeTp::VarString.into()];
let mut columns = LazyBatchColumnVec::from(vec![{
let mut col = LazyBatchColumn::decoded_with_capacity_and_tp(0, EvalType::Bytes);
col.mut_decoded().push_bytes(Some(b"12.5".to_vec()));
col.mut_decoded().push_bytes(None);
col.mut_decoded().push_bytes(Some(b"10000.0".to_vec()));
col.mut_decoded().push_bytes(Some(b"42.0".to_vec()));
col.mut_decoded().push_bytes(None);
col
}]);
let logical_rows = vec![0, 1, 3, 4];
let mut schema = vec![];
let mut exp = vec![];
let aggr_fn = AggrFnDefinitionParserSum
.parse(expr, &Tz::utc(), &src_schema, &mut schema, &mut exp)
.unwrap();
assert_eq!(schema.len(), 1);
assert_eq!(schema[0].tp(), FieldTypeTp::Double);
assert_eq!(exp.len(), 1);
let mut state = aggr_fn.create_state();
let mut ctx = EvalContext::default();
let exp_result = exp[0]
.eval(&mut ctx, &src_schema, &mut columns, &logical_rows, 4)
.unwrap();
let exp_result = exp_result.vector_value().unwrap();
let slice: &[Option<Real>] = exp_result.as_ref().as_ref();
state
.update_vector(&mut ctx, slice, exp_result.logical_rows())
.unwrap();
let mut aggr_result = [VectorValue::with_capacity(0, EvalType::Real)];
state.push_result(&mut ctx, &mut aggr_result).unwrap();
assert_eq!(aggr_result[0].as_real_slice(), &[Real::new(54.5).ok()]);
} | rust_cleaned_test_functions.jsonl/110901 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 921
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
90250,
368,
341,
286,
1077,
15169,
284,
28819,
2620,
3297,
486,
351,
901,
9596,
7,
16041,
929,
486,
9190,
11,
84614,
62241,
486,
7378,
340,
310,
659,
9077,
17268,
7,
16041,
2620,
3297,
486,
6229... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_struct() {
ok("struct Foo {}");
err(
"struct Foo {} struct Foo {}",
pos(1, 15),
Msg::ShadowStruct("Foo".into()),
);
err(
"struct Foo {} class Foo {}",
pos(1, 15),
Msg::ShadowStruct("Foo".into()),
);
err(
"struct Foo {} fun Foo() {}",
pos(1, 15),
Msg::ShadowStruct("Foo".into()),
);
} | rust_cleaned_test_functions.jsonl/45236 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 280
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15126,
368,
341,
286,
5394,
445,
1235,
33428,
4687,
797,
286,
1848,
1006,
310,
330,
1235,
33428,
4687,
2036,
33428,
4687,
756,
310,
1133,
7,
16,
11,
220,
16,
20,
1326,
310,
24205,
486,
23667,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_hand_evaluation() {
let g = test_helpers::create_test_bid_phase();
// User: ♣2 ♣6 ♣9 ♣10 ♣A ♥6 ♥9 ♥10 ♥A ♠2 ♠7 ♠8 ♠K
assert_eq!(
hand_evaluation(hand_score(g.hand(Position::User)), Some(Suit::Clubs)),
BidResponse::HandEvaluation(HandRating::Excellent, Some(Suit::Clubs))
);
assert_eq!(
hand_evaluation(hand_score(g.hand(Position::User)), Some(Suit::Diamonds)),
BidResponse::HandEvaluation(HandRating::Fair, Some(Suit::Diamonds))
);
// Dummy: ♦6 ♦7 ♦8 ♦K ♣5 ♣K ♥4 ♥7 ♥J ♥Q ♠4 ♠5 ♠10
assert_eq!(
hand_evaluation(hand_score(g.hand(Position::Dummy)), Some(Suit::Clubs)),
BidResponse::HandEvaluation(HandRating::Poor, Some(Suit::Clubs))
);
assert_eq!(
hand_evaluation(hand_score(g.hand(Position::Dummy)), Some(Suit::Diamonds)),
BidResponse::HandEvaluation(HandRating::Fair, Some(Suit::Diamonds))
);
} | rust_cleaned_test_functions.jsonl/83222 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 521
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
23194,
86505,
368,
341,
286,
1077,
342,
284,
1273,
54473,
486,
3182,
4452,
62509,
37593,
543,
286,
442,
2657,
25,
220,
35358,
96,
17,
35358,
96,
21,
35358,
96,
24,
35358,
96,
16,
15,
35358,
96... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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() {
let a = Bump::new();
assert_eq!(Map::<i64, i64>::from(&a, Vec::new()), map![]);
assert_eq!(
Map::<i64, i64>::from(&a, vec![(6, 7), (8, 9)]),
map![&a; 8 => 9, 6 => 7]
);
} | rust_cleaned_test_functions.jsonl/118072 | {
"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,
5673,
368,
341,
286,
1077,
264,
284,
425,
1510,
486,
931,
543,
286,
2060,
10714,
10297,
2227,
27638,
72,
21,
19,
11,
600,
21,
19,
6831,
1499,
2099,
64,
11,
11312,
486,
931,
11858,
2415,
0,
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_query_directed_bounds() {
// if shift and expand operation have reached the end of the vecs an error should be returned
let mut lsh = hi8::LshMem::new(2, 1, 1).multi_probe(1000).l2(4.).unwrap();
lsh.store_vec(&[1.]).unwrap();
assert!(lsh.query_bucket_ids(&[1.]).is_err())
} | rust_cleaned_test_functions.jsonl/107651 | {
"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,
5738,
32871,
291,
36878,
368,
341,
286,
442,
421,
6407,
323,
9225,
5666,
614,
8643,
279,
835,
315,
279,
7486,
82,
458,
1465,
1265,
387,
5927,
198,
286,
1077,
5206,
326,
927,
284,
15588,
23,
48... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_generated() {
let mut rng = StdRng::seed_from_u64(0);
let mut n_pixels = 0;
while n_pixels < 20_000_000 {
let min_len = rng.gen_range(1..=5000);
let channels = rng.gen_range(3..=4);
let gen = ImageGen::new_random(&mut rng);
let img = gen.generate(&mut rng, channels, min_len);
let encode = |data: &[u8], size| encode_to_vec(data, size, 1);
let decode = |data: &[u8]| decode_to_vec(data).map(|r| r.1);
let encode_c = |data: &[u8], size| qoi_encode(data, size, 1, channels as _);
let decode_c = |data: &[u8]| qoi_decode(data, channels as _).map(|r| r.1);
check_roundtrip("qoi-rust -> qoi-rust", &img, channels as _, encode, decode);
check_roundtrip("qoi-rust -> qoi.h", &img, channels as _, encode, decode_c);
check_roundtrip("qoi.h -> qoi-rust", &img, channels as _, encode_c, decode);
let size = (img.len() / channels) as u32;
let encoded = encode(&img, size).unwrap();
let encoded_c = encode_c(&img, size).unwrap();
cfg_if! {
if #[cfg(feature = "reference")] {
let eq = encoded.as_slice() == encoded_c.as_ref();
assert!(eq, "qoi-rust [reference mode] doesn't match qoi.h");
} else {
let eq = encoded.len() == encoded_c.len();
assert!(eq, "qoi-rust [non-reference mode] length doesn't match qoi.h");
}
}
n_pixels += size;
}
} | rust_cleaned_test_functions.jsonl/27216 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 730
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
67313,
368,
341,
262,
1077,
5206,
28422,
284,
42517,
49,
968,
486,
22602,
5673,
7300,
21,
19,
7,
15,
626,
262,
1077,
5206,
308,
49745,
284,
220,
15,
280,
262,
1393,
308,
49745,
366,
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... | 3 |
#[test]
fn test_to_vec() {
Python::with_gil(|py| {
let src = b"Hello Python";
let bytearray = PyByteArray::new(py, src);
let vec = bytearray.to_vec();
assert_eq!(src, vec.as_slice());
});
} | rust_cleaned_test_functions.jsonl/47842 | {
"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,
2346,
13251,
368,
341,
286,
13027,
486,
4197,
1889,
321,
22428,
3288,
91,
341,
310,
1077,
2286,
284,
293,
1,
9707,
13027,
876,
310,
1077,
95603,
284,
5355,
18394,
486,
931,
46827,
11,
2286,
626,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_doesnt_accept_wrong_proto() {
#[cfg(feature = "proto-ipv4")]
{
let socket = RawSocket::new(
IpVersion::Ipv4,
IpProtocol::Unknown(ipv4_locals::IP_PROTO + 1),
buffer(1),
buffer(1),
);
assert!(!socket.accepts(&ipv4_locals::HEADER_REPR));
#[cfg(feature = "proto-ipv6")]
assert!(!socket.accepts(&ipv6_locals::HEADER_REPR));
}
#[cfg(feature = "proto-ipv6")]
{
let socket = RawSocket::new(
IpVersion::Ipv6,
IpProtocol::Unknown(ipv6_locals::IP_PROTO + 1),
buffer(1),
buffer(1),
);
assert!(!socket.accepts(&ipv6_locals::HEADER_REPR));
#[cfg(feature = "proto-ipv4")]
assert!(!socket.accepts(&ipv4_locals::HEADER_REPR));
}
} | rust_cleaned_test_functions.jsonl/7287 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 572
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
96374,
406,
35728,
75198,
37689,
368,
341,
286,
11506,
14072,
27062,
284,
330,
15110,
12,
42676,
19,
5422,
286,
341,
310,
1077,
7575,
284,
23022,
10286,
486,
931,
1006,
394,
35033,
5637,
486,
8065... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_slice_range() {
let data = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
assert_eq!(get_slice_range(data, 0..6).unwrap(), &[0, 1, 2, 3, 4, 5]);
assert_eq!(get_slice_range(data, 7..10).unwrap(), &[7, 8, 9]);
get_slice_range(data, 5..15).unwrap_err();
get_slice_range(data, 20..25).unwrap_err();
} | rust_cleaned_test_functions.jsonl/100520 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 187
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
26488,
9698,
368,
341,
286,
1077,
821,
284,
44590,
15,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11,
220,
21,
11,
220,
22,
11,
220,
23,
11,
220,
24,
935,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_straight_flush_ranks() {
test(&["4H 6H 7H 8H 5H", "5S 7S 8S 9S 6S"], &["5S 7S 8S 9S 6S"])
} | rust_cleaned_test_functions.jsonl/49921 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 73
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2895,
7386,
39213,
1710,
4039,
368,
341,
1066,
262,
1273,
2099,
1183,
19,
39,
220,
21,
39,
220,
22,
39,
220,
23,
39,
220,
20,
39,
497,
330,
20,
50,
220,
22,
50,
220,
23,
50,
220,
24,
50,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_read_client_state_failed_by_supply_error_client_id() {
let gp_client_id = ClientId::new(ClientType::Grandpa, 0).unwrap();
let gp_client_id_failed = ClientId::new(ClientType::Grandpa, 1).unwrap();
let gp_client_state = GPClientState::new(
ChainId::new("ibc".to_string(), 0),
Height::default(),
Height::default(),
)
.unwrap();
let gp_client_state = AnyClientState::Grandpa(gp_client_state);
let mut context: Context<Test> = Context::new();
new_test_ext().execute_with(|| {
assert_eq!(
context
.store_client_state(gp_client_id.clone(), gp_client_state.clone())
.is_ok(),
true
);
let ret = ClientReader::client_state(&context, &gp_client_id_failed)
.unwrap_err()
.to_string();
assert_eq!(ret, ICS02Error::client_not_found(gp_client_id_failed).to_string());
})
} | rust_cleaned_test_functions.jsonl/60059 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 333
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
8179,
4387,
35060,
3710,
65630,
4096,
8179,
842,
368,
341,
10217,
28705,
8179,
842,
284,
8423,
764,
486,
931,
46851,
929,
486,
40151,
6595,
11,
220,
15,
568,
15454,
543,
10217,
28705,
8179,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_try_map() {
// One - OK
let one: OneOrSet<MockKeyU8> = OneOrSet::new_one(MockKeyU8(1));
let one_add: OneOrSet<MockKeyU8> = one
.try_map(|item| {
if item.key() == &1 {
Ok(MockKeyU8(item.0 + 1))
} else {
Err(Error::OneOrSetEmpty)
}
})
.unwrap();
assert_eq!(one_add, OneOrSet::new_one(MockKeyU8(2)));
// One - ERROR
let one_err: OneOrSet<MockKeyU8> = OneOrSet::new_one(MockKeyU8(1));
let result_one: Result<OneOrSet<MockKeyBool>> = one_err.try_map(|item| {
if item.key() == &1 {
Err(Error::OneOrSetEmpty)
} else {
Ok(MockKeyBool(false))
}
});
assert!(matches!(result_one, Err(Error::OneOrSetEmpty)));
// Set - OK
let set: OneOrSet<MockKeyU8> = OneOrSet::new_set((1..=3).map(MockKeyU8).collect()).unwrap();
let set_add: OneOrSet<MockKeyU8> = set
.try_map(|item| {
if item.key() < &4 {
Ok(MockKeyU8(item.0 + 10))
} else {
Err(Error::OneOrSetEmpty)
}
})
.unwrap();
assert_eq!(set_add, OneOrSet::new_set((11..=13).map(MockKeyU8).collect()).unwrap());
// Set - ERROR
let set_err: OneOrSet<MockKeyU8> = OneOrSet::new_set((1..=3).map(MockKeyU8).collect()).unwrap();
let result_set: Result<OneOrSet<MockKeyU8>> = set_err.try_map(|item| {
if item.key() < &4 {
Err(Error::OneOrSetEmpty)
} else {
Ok(MockKeyU8(item.0))
}
});
assert!(matches!(result_set, Err(Error::OneOrSetEmpty)));
// Set reduced to one - OK
let set_many: OneOrSet<MockKeyU8> = OneOrSet::new_set([2, 4, 6, 8].into_iter().map(MockKeyU8).collect()).unwrap();
assert_eq!(set_many.len(), 4);
let set_bool: OneOrSet<MockKeyBool> = set_many
.try_map(|item| {
if item.key() % 2 == 0 {
Ok(MockKeyBool(item.0 % 2 == 0))
} else {
Err(Error::OneOrSetEmpty)
}
})
.unwrap();
assert_eq!(set_bool, OneOrSet::new_one(MockKeyBool(true)));
assert_eq!(set_bool.0, OneOrSetInner::One(MockKeyBool(true)));
assert_eq!(set_bool.len(), 1);
} | rust_cleaned_test_functions.jsonl/5924 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1113
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
53283,
5376,
368,
341,
262,
442,
3776,
481,
10402,
198,
262,
1077,
825,
25,
3776,
2195,
1649,
27,
11571,
1592,
52,
23,
29,
284,
3776,
2195,
1649,
486,
931,
11667,
66436,
1592,
52,
23,
7,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
#[test]
fn test_position() {
let b = [1, 2, 3, 5, 5];
assert_eq!(b.iter().position(|&v| v == 9), None);
assert_eq!(b.iter().position(|&v| v == 5), Some(3));
assert_eq!(b.iter().position(|&v| v == 3), Some(2));
assert_eq!(b.iter().position(|&v| v == 0), None);
} | rust_cleaned_test_functions.jsonl/9607 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 141
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9661,
368,
341,
262,
1077,
293,
284,
508,
16,
11,
220,
17,
11,
220,
18,
11,
220,
20,
11,
220,
20,
935,
262,
2060,
10714,
10297,
65,
19471,
1005,
3487,
22428,
5,
85,
91,
348,
621,
220,
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... | 1 |
#[test]
fn test_security_feature_from_str() {
assert_eq!(SecurityFeature::from_str("nat").unwrap(), SecurityFeature::NAT);
assert_eq!(SecurityFeature::from_str("NAT").unwrap(), SecurityFeature::NAT);
assert_eq!(SecurityFeature::from_str("NaT").unwrap(), SecurityFeature::NAT);
assert_eq!(
SecurityFeature::from_str("nnat").unwrap_err().to_string(),
format!("Invalid security feature: 'nnat'")
);
} | rust_cleaned_test_functions.jsonl/112937 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 196
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
48726,
17069,
5673,
2895,
368,
341,
286,
2060,
10714,
10297,
15352,
13859,
486,
1499,
2895,
445,
33297,
1827,
15454,
1507,
8234,
13859,
486,
45,
828,
317,
286,
2060,
10714,
10297,
15352,
13859,
486,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_g1_generator() {
let generator = G1Affine::prime_subgroup_generator();
assert!(generator.is_on_curve());
assert!(generator.is_in_correct_subgroup_assuming_on_curve());
} | rust_cleaned_test_functions.jsonl/15276 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 86
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1889,
16,
25813,
368,
341,
262,
1077,
13823,
284,
479,
16,
25841,
482,
486,
32338,
5228,
4074,
25813,
543,
262,
2060,
10297,
35851,
2079,
4470,
43407,
1423,
262,
2060,
10297,
35851,
2079,
1243,
31... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_if_not_endif() {
let text = "{{ if not foo }}Hello!{{ endif }}";
let instructions = compile(text).unwrap();
assert_eq!(2, instructions.len());
assert_eq!(&Branch(vec!["foo"], false, 2), &instructions[0]);
assert_eq!(&Literal("Hello!"), &instructions[1]);
} | rust_cleaned_test_functions.jsonl/131990 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 151
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11119,
7913,
62,
2330,
368,
972,
286,
1077,
1467,
284,
47219,
421,
537,
15229,
3869,
9707,
0,
2979,
12330,
3869,
3534,
286,
1077,
11221,
284,
19192,
7235,
568,
15454,
1647,
286,
2060,
10714,
10297... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_mut_chunks_exact_0() {
let mut v = [1, 2, 3, 4];
let _it = v.chunks_exact_mut(0);
} | rust_cleaned_test_functions.jsonl/12927 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 64
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
29523,
65470,
71084,
62,
15,
368,
341,
262,
1077,
5206,
348,
284,
508,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
935,
262,
1077,
716,
275,
284,
348,
5329,
15296,
71084,
29523,
7,
15,
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 |
#[test]
fn test_truncate() {
let mut v: Vec<Box<_>> = vec![Box::new(6), Box::new(5), Box::new(4)];
v.truncate(1);
let v = v;
assert_eq!(v.len(), 1);
assert_eq!(*(v[0]), 6);
} | rust_cleaned_test_functions.jsonl/80755 | {
"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,
3547,
26900,
368,
341,
262,
1077,
5206,
348,
25,
11312,
79852,
32399,
2452,
284,
7486,
20703,
1611,
486,
931,
7,
21,
701,
8261,
486,
931,
7,
20,
701,
8261,
486,
931,
7,
19,
12587,
262,
348,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_serde_deserialize() {
use self::serde_json::from_str;
use Month::*;
let cases: Vec<(&str, Month)> = vec![
("\"january\"", January),
("\"jan\"", January),
("\"FeB\"", February),
("\"MAR\"", March),
("\"mar\"", March),
("\"april\"", April),
("\"may\"", May),
("\"june\"", June),
("\"JULY\"", July),
("\"august\"", August),
("\"september\"", September),
("\"October\"", October),
("\"November\"", November),
("\"DECEmbEr\"", December),
];
for (string, expected_month) in cases {
let month = from_str::<Month>(string).unwrap();
assert_eq!(month, expected_month);
}
let errors: Vec<&str> =
vec!["\"not a month\"", "\"ja\"", "\"Dece\"", "Dec", "\"Augustin\""];
for string in errors {
from_str::<Month>(string).unwrap_err();
}
} | rust_cleaned_test_functions.jsonl/92414 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 554
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
75861,
450,
15768,
9050,
368,
341,
286,
990,
656,
486,
47024,
9455,
486,
1499,
2895,
280,
286,
990,
19397,
79304,
286,
1077,
5048,
25,
11312,
27,
2099,
495,
11,
19397,
16018,
284,
7486,
90515,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_hash_sha2_256() {
let mut output = [0x00_u8; 32];
sha2_256(TEST_INPUT, &mut output);
assert_eq!(
output,
[
136, 15, 25, 218, 88, 54, 49, 152, 115, 168, 147, 189, 207, 171, 243,
129, 161, 76, 15, 141, 197, 106, 111, 213, 19, 197, 133, 219, 181, 233,
195, 120
]
);
} | rust_cleaned_test_functions.jsonl/37532 | {
"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,
8950,
48836,
17,
62,
17,
20,
21,
368,
341,
286,
1077,
5206,
2550,
284,
508,
15,
87,
15,
15,
7300,
23,
26,
220,
18,
17,
935,
286,
15870,
17,
62,
17,
20,
21,
50320,
21022,
11,
609,
6984,
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_get_coefficients() {
let x = DMatrix::from_vec(5, 1, vec![2_f64, 1., 3., 4., 5.]);
let y = DMatrix::from_vec(5, 1, vec![1_f64, 2., 3., 4., 5.]);
let result = get_coefficients(&x, &y);
assert_approx_eq!(result[(0)], 0.9818181818181818);
let x = DMatrix::from_vec(3, 2, vec![1_f64, 2., 1., 1., 1., 2.]);
let y = DMatrix::from_vec(3, 1, vec![3_f64, 4., 5.]);
let result = get_coefficients(&x, &y);
assert_approx_eq!(result[(0)], 1.);
assert_approx_eq!(result[(1)], 2.);
} | rust_cleaned_test_functions.jsonl/6779 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 308
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
31990,
28142,
368,
341,
286,
1077,
856,
284,
422,
6689,
486,
1499,
13251,
7,
20,
11,
220,
16,
11,
7486,
20703,
17,
761,
21,
19,
11,
220,
16,
2572,
220,
18,
2572,
220,
19,
2572,
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_sum_two_longs() {
assert_eq!(sum_two_longs(-600000, 700000), 100000);
} | rust_cleaned_test_functions.jsonl/123613 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 58
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10160,
23241,
907,
13181,
368,
972,
286,
2060,
10714,
10297,
1242,
23241,
907,
13181,
4080,
21,
15,
15,
15,
15,
15,
11,
220,
22,
15,
15,
15,
15,
15,
701,
220,
16,
15,
15,
15,
15,
15,
736,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_buffer_wraparound_tx() {
let mut s = socket_established();
s.tx_buffer = SocketBuffer::new(vec![b'.'; 9]);
assert_eq!(s.send_slice(b"xxxyyy"), Ok(6));
assert_eq!(s.tx_buffer.dequeue_many(3), &b"xxx"[..]);
assert_eq!(s.tx_buffer.len(), 3);
// "abcdef" not contiguous in tx buffer
assert_eq!(s.send_slice(b"abcdef"), Ok(6));
recv!(s, Ok(TcpRepr {
seq_number: LOCAL_SEQ + 1,
ack_number: Some(REMOTE_SEQ + 1),
payload: &b"yyyabc"[..],
..RECV_TEMPL
}));
recv!(s, Ok(TcpRepr {
seq_number: LOCAL_SEQ + 1 + 6,
ack_number: Some(REMOTE_SEQ + 1),
payload: &b"def"[..],
..RECV_TEMPL
}));
} | rust_cleaned_test_functions.jsonl/91918 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 457
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7776,
38550,
19454,
17805,
368,
341,
286,
1077,
5206,
274,
284,
7575,
18583,
5102,
291,
543,
286,
274,
33807,
7776,
284,
20954,
4095,
486,
931,
25592,
20703,
65,
6,
3159,
26,
220,
24,
2558,
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_buffered_reader_seek_relative() {
let inner: &[u8] = &[5, 6, 7, 0, 1, 2, 3, 4];
let mut reader = BufReader::with_capacity(2, io::Cursor::new(inner));
assert!(reader.seek_relative(3).is_ok());
assert_eq!(reader.fill_buf().ok(), Some(&[0, 1][..]));
assert!(reader.seek_relative(0).is_ok());
assert_eq!(reader.fill_buf().ok(), Some(&[0, 1][..]));
assert!(reader.seek_relative(1).is_ok());
assert_eq!(reader.fill_buf().ok(), Some(&[1][..]));
assert!(reader.seek_relative(-1).is_ok());
assert_eq!(reader.fill_buf().ok(), Some(&[0, 1][..]));
assert!(reader.seek_relative(2).is_ok());
assert_eq!(reader.fill_buf().ok(), Some(&[2, 3][..]));
} | rust_cleaned_test_functions.jsonl/17434 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 363
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7776,
291,
22306,
74473,
29286,
368,
341,
286,
1077,
9179,
25,
44590,
84,
23,
60,
284,
44590,
20,
11,
220,
21,
11,
220,
22,
11,
220,
15,
11,
220,
16,
11,
220,
17,
11,
220,
18,
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... | 1 |
#[test]
fn test_prewrite_committed_encounter_newer_lock() {
let engine = TestEngineBuilder::new().build().unwrap();
let mut statistics = Statistics::default();
let k1 = b"k1";
let v1 = b"v1";
let v2 = b"v2";
must_prewrite_put_async_commit(&engine, k1, v1, k1, &Some(vec![]), 5, 10);
// This commit may actually come from a ResolveLock command
must_commit(&engine, k1, 5, 15);
// Another transaction prewrites
must_prewrite_put(&engine, k1, v2, k1, 20);
// A retried prewrite of the first transaction should be idempotent.
let prewrite_cmd = Prewrite::new(
vec![Mutation::make_put(Key::from_raw(k1), v1.to_vec())],
k1.to_vec(),
5.into(),
2000,
false,
1,
5.into(),
1000.into(),
Some(vec![]),
false,
AssertionLevel::Off,
Context::default(),
);
let context = WriteContext {
lock_mgr: &DummyLockManager {},
concurrency_manager: ConcurrencyManager::new(20.into()),
extra_op: ExtraOp::Noop,
statistics: &mut statistics,
async_apply_prewrite: false,
};
let snap = engine.snapshot(Default::default()).unwrap();
let res = prewrite_cmd.cmd.process_write(snap, context).unwrap();
match res.pr {
ProcessResult::PrewriteResult { result } => {
assert!(result.locks.is_empty(), "{:?}", result);
assert_eq!(result.min_commit_ts, 15.into(), "{:?}", result);
}
_ => panic!("unexpected result {:?}", res.pr),
}
} | rust_cleaned_test_functions.jsonl/31436 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 871
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
52473,
2965,
5483,
13781,
39914,
5921,
261,
9818,
368,
341,
286,
1077,
4712,
284,
3393,
4571,
3297,
486,
931,
1005,
5834,
1005,
15454,
543,
286,
1077,
5206,
13142,
284,
24624,
486,
2258,
1428... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_overlap() {
let cube_a = Cuboid {
lower: [1, 1, 1],
upper: [4, 4, 4],
};
let cube_b = Cuboid {
lower: [2, 2, 2],
upper: [3, 3, 3],
};
let mut new_cubes = Vec::new();
// B is fully inside A so it should overlap and the result should be empty
assert!(!cube_b.retain_nonoverlapping(&cube_a, &mut new_cubes));
assert_eq!(new_cubes, Vec::new());
assert!(!cube_a.retain_nonoverlapping(&cube_b, &mut new_cubes));
assert_eq!(new_cubes.len(), 6);
} | rust_cleaned_test_functions.jsonl/93684 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 323
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
65794,
368,
341,
286,
1077,
23739,
4306,
284,
18030,
588,
341,
310,
4722,
25,
508,
16,
11,
220,
16,
11,
220,
16,
1259,
310,
8416,
25,
508,
19,
11,
220,
19,
11,
220,
19,
1259,
286,
3634,
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_into() {
let v = QUATERNION;
{
let v: [f32; 4] = v.into();
assert_eq!(v, [1.0, 2.0, 3.0, 4.0]);
}
{
let v: (f32, f32, f32, f32) = v.into();
assert_eq!(v, (1.0, 2.0, 3.0, 4.0));
}
} | rust_cleaned_test_functions.jsonl/15342 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 205
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
45514,
368,
341,
286,
1077,
348,
284,
25999,
828,
13660,
1271,
280,
286,
341,
310,
1077,
348,
25,
508,
69,
18,
17,
26,
220,
19,
60,
284,
348,
39860,
543,
310,
2060,
10714,
10297,
85,
11,
508... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_qmp_event_msg() {
let event_json =
r#"{"event":"STOP","data":{},"timestamp":{"seconds":1575531524,"microseconds":91519}}"#;
let qmp_event: schema::QmpEvent = serde_json::from_str(&event_json).unwrap();
match qmp_event {
schema::QmpEvent::STOP {
data: _,
timestamp: _,
} => {
assert!(true);
}
_ => assert!(false),
}
} | rust_cleaned_test_functions.jsonl/66356 | {
"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,
8976,
1307,
6748,
6483,
368,
341,
286,
1077,
1538,
9455,
4035,
310,
435,
55543,
4913,
3087,
3252,
50669,
2198,
691,
788,
6257,
1335,
13035,
22317,
17403,
788,
16,
20,
22,
20,
20,
18,
16,
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... | 2 |
#[test]
fn test_pop_sequence_recurrence() {
assert!(!cdll::LinkedList::is_valid_pop_sequence_recurrence(
0,
&[2, 0, 1]
));
assert!(cdll::LinkedList::is_valid_pop_sequence_recurrence(
0,
&[0, 1, 2]
));
assert!(cdll::LinkedList::is_valid_pop_sequence_recurrence(
0,
&[0, 2, 1]
));
assert!(cdll::LinkedList::is_valid_pop_sequence_recurrence(
0,
&[1, 0, 2]
));
assert!(cdll::LinkedList::is_valid_pop_sequence_recurrence(
0,
&[1, 2, 0]
));
assert!(cdll::LinkedList::is_valid_pop_sequence_recurrence(
0,
&[2, 1, 0]
));
} | rust_cleaned_test_functions.jsonl/23387 | {
"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,
17061,
23735,
7080,
20559,
368,
341,
286,
2060,
0,
3471,
4385,
654,
486,
33915,
486,
285,
8337,
17061,
23735,
7080,
20559,
1006,
310,
220,
15,
345,
310,
44590,
17,
11,
220,
15,
11,
220,
16,
92... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_init_all_passes_for_module() {
let context = Context::create();
let module = context.create_module("my_module");
let pass_manager = PassManager::create(());
pass_manager.add_argument_promotion_pass();
pass_manager.add_constant_merge_pass();
pass_manager.add_dead_arg_elimination_pass();
pass_manager.add_function_attrs_pass();
pass_manager.add_function_inlining_pass();
pass_manager.add_always_inliner_pass();
pass_manager.add_global_dce_pass();
pass_manager.add_global_optimizer_pass();
pass_manager.add_ip_constant_propagation_pass();
pass_manager.add_prune_eh_pass();
pass_manager.add_ipsccp_pass();
pass_manager.add_internalize_pass(true);
pass_manager.add_strip_dead_prototypes_pass();
pass_manager.add_strip_symbol_pass();
#[cfg(any(feature = "llvm3-6", feature = "llvm3-7", feature = "llvm3-8", feature = "llvm3-9", feature = "llvm4-0"))]
pass_manager.add_bb_vectorize_pass();
pass_manager.add_loop_vectorize_pass();
pass_manager.add_slp_vectorize_pass();
pass_manager.add_aggressive_dce_pass();
#[cfg(not(feature = "llvm3-6"))]
pass_manager.add_bit_tracking_dce_pass();
pass_manager.add_alignment_from_assumptions_pass();
pass_manager.add_cfg_simplification_pass();
pass_manager.add_dead_store_elimination_pass();
pass_manager.add_scalarizer_pass();
pass_manager.add_merged_load_store_motion_pass();
pass_manager.add_gvn_pass();
pass_manager.add_ind_var_simplify_pass();
pass_manager.add_instruction_combining_pass();
pass_manager.add_jump_threading_pass();
pass_manager.add_licm_pass();
pass_manager.add_loop_deletion_pass();
pass_manager.add_loop_idiom_pass();
pass_manager.add_loop_rotate_pass();
pass_manager.add_loop_reroll_pass();
pass_manager.add_loop_unroll_pass();
pass_manager.add_loop_unswitch_pass();
pass_manager.add_memcpy_optimize_pass();
pass_manager.add_partially_inline_lib_calls_pass();
pass_manager.add_lower_switch_pass();
pass_manager.add_promote_memory_to_register_pass();
pass_manager.add_reassociate_pass();
pass_manager.add_sccp_pass();
pass_manager.add_scalar_repl_aggregates_pass();
pass_manager.add_scalar_repl_aggregates_pass_ssa();
pass_manager.add_scalar_repl_aggregates_pass_with_threshold(1);
pass_manager.add_simplify_lib_calls_pass();
pass_manager.add_tail_call_elimination_pass();
pass_manager.add_constant_propagation_pass();
pass_manager.add_demote_memory_to_register_pass();
pass_manager.add_verifier_pass();
pass_manager.add_correlated_value_propagation_pass();
pass_manager.add_early_cse_pass();
pass_manager.add_lower_expect_intrinsic_pass();
pass_manager.add_type_based_alias_analysis_pass();
pass_manager.add_scoped_no_alias_aa_pass();
pass_manager.add_basic_alias_analysis_pass();
#[cfg(not(any(feature = "llvm3-6", feature = "llvm3-7", feature = "llvm3-8", feature = "llvm3-9")))]
{
pass_manager.add_early_cse_mem_ssa_pass();
pass_manager.add_new_gvn_pass();
}
#[cfg(not(any(feature = "llvm3-6", feature = "llvm3-7", feature = "llvm3-8", feature = "llvm3-9",
feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0")))]
{
pass_manager.add_aggressive_inst_combiner_pass();
pass_manager.add_loop_unroll_and_jam_pass();
}
#[cfg(not(any(feature = "llvm3-6", feature = "llvm3-7", feature = "llvm3-8", feature = "llvm3-9",
feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0", feature = "llvm7-0")))]
{
pass_manager.add_coroutine_early_pass();
pass_manager.add_coroutine_split_pass();
pass_manager.add_coroutine_elide_pass();
pass_manager.add_coroutine_cleanup_pass();
}
pass_manager.run_on(&module);
} | rust_cleaned_test_functions.jsonl/42667 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1641
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6137,
5705,
15464,
288,
5478,
10750,
368,
341,
262,
1077,
2266,
284,
9608,
486,
3182,
543,
262,
1077,
4688,
284,
2266,
2520,
10750,
445,
2408,
10750,
797,
262,
1077,
1494,
12144,
284,
9970,
2043,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_established_retransmit_reset_after_ack() {
let mut s = socket_established();
s.remote_win_len = 6;
s.send_slice(b"abcdef").unwrap();
s.send_slice(b"123456").unwrap();
s.send_slice(b"ABCDEF").unwrap();
recv!(s, time 1000, Ok(TcpRepr {
seq_number: LOCAL_SEQ + 1,
ack_number: Some(REMOTE_SEQ + 1),
payload: &b"abcdef"[..],
..RECV_TEMPL
}));
send!(s, time 1005, TcpRepr {
seq_number: REMOTE_SEQ + 1,
ack_number: Some(LOCAL_SEQ + 1 + 6),
window_len: 6,
..SEND_TEMPL
});
recv!(s, time 1010, Ok(TcpRepr {
seq_number: LOCAL_SEQ + 1 + 6,
ack_number: Some(REMOTE_SEQ + 1),
payload: &b"123456"[..],
..RECV_TEMPL
}));
send!(s, time 1015, TcpRepr {
seq_number: REMOTE_SEQ + 1,
ack_number: Some(LOCAL_SEQ + 1 + 6 + 6),
window_len: 6,
..SEND_TEMPL
});
recv!(s, time 1020, Ok(TcpRepr {
seq_number: LOCAL_SEQ + 1 + 6 + 6,
ack_number: Some(REMOTE_SEQ + 1),
payload: &b"ABCDEF"[..],
..RECV_TEMPL
}));
} | rust_cleaned_test_functions.jsonl/1766 | {
"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,
18583,
5102,
291,
1288,
1458,
1763,
18983,
19844,
48447,
368,
341,
286,
1077,
5206,
274,
284,
7575,
18583,
5102,
291,
543,
286,
274,
34093,
25672,
6043,
284,
220,
21,
280,
286,
274,
5219,
26488,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_encrypt_decrypt() {
let _ = simple_logger::SimpleLogger::new()
.with_level(log::Level::Info.to_level_filter())
.init();
let plaintext = b"Hello world!Hello world!";
let current_plaintext = *plaintext;
let oracle = PaddingOracle::new(16, 1, oracle_fn);
let iv: Vec<u8> = [].to_vec();
let ciphertext = oracle.encrypt(&plaintext.to_vec(), &iv).unwrap();
let plaintext = oracle.decrypt(&ciphertext, &iv).unwrap();
assert_eq!(
current_plaintext.to_vec(),
unpad(plaintext[32..].to_vec(), 16).unwrap()
);
} | rust_cleaned_test_functions.jsonl/78891 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 313
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
66593,
80764,
368,
341,
286,
1077,
716,
284,
4285,
27413,
486,
16374,
7395,
486,
931,
741,
310,
659,
4197,
8274,
12531,
486,
4449,
486,
1731,
2389,
8274,
8727,
2398,
310,
659,
2327,
1428,
286,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_true() {
assert_eq!(
crate::rsass(
"a {b: join(c, d, $bracketed: true)}\
\n"
)
.unwrap(),
"a {\
\n b: [c d];\
\n}\
\n"
);
} | rust_cleaned_test_functions.jsonl/71426 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 195
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16082,
368,
341,
286,
2060,
10714,
33673,
310,
17717,
486,
5428,
395,
1006,
394,
330,
64,
314,
65,
25,
5138,
1337,
11,
294,
11,
400,
1323,
5709,
291,
25,
830,
9139,
5661,
310,
1124,
77,
698,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_normalize() {
fn t(wp: &PosixPath, s: &str) {
let ss = wp.to_str();
let sss = s.to_owned();
if (ss != sss) {
debug!("got %s", ss);
debug!("expected %s", sss);
assert_eq!(ss, sss);
}
}
t(&(PosixPath("hi/there.txt")
.with_dirname(".").normalize()), "there.txt");
t(&(PosixPath("a/b/../c/././/../foo.txt/").normalize()),
"a/foo.txt");
t(&(PosixPath("a/b/c")
.push("..").normalize()), "a/b");
} | rust_cleaned_test_functions.jsonl/45744 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 358
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
80807,
368,
341,
286,
5168,
259,
88117,
25,
609,
4859,
941,
1820,
11,
274,
25,
609,
495,
8,
341,
310,
1077,
10870,
284,
12609,
2389,
2895,
543,
310,
1077,
274,
778,
284,
274,
2389,
51973,
543,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.