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_malformed_array_type() {
let parser = Parser::new();
let source = "byte[7[]uint][]";
assert_eq!(parser.parse_type(source).is_err(), true)
} | rust_cleaned_test_functions.jsonl/85364 | {
"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,
717,
278,
10155,
3858,
1819,
368,
341,
197,
10217,
6729,
284,
21102,
486,
931,
543,
197,
10217,
2530,
284,
330,
3782,
58,
22,
1294,
2496,
45725,
876,
197,
6948,
10714,
10297,
9657,
4632,
1819,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_epoch() {
let base = Epoch::new(10);
assert_eq!(RelativeEpoch::Current.into_epoch(base), base);
assert_eq!(RelativeEpoch::Previous.into_epoch(base), base - 1);
assert_eq!(RelativeEpoch::Next.into_epoch(base), base + 1);
} | rust_cleaned_test_functions.jsonl/88414 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 134
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
45514,
20682,
368,
341,
286,
1077,
2331,
284,
87379,
486,
931,
7,
16,
15,
626,
286,
2060,
10714,
10297,
28442,
44338,
486,
5405,
39860,
20682,
12663,
701,
2331,
317,
286,
2060,
10714,
10297,
28442... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_on_block_end() {
let mut storage = Contract::new_storage();
let code_hash = storage
.upload_code(
ALICE.clone(),
include_bytes!("./fixtures/hooks_test/hooks_test.wasm").to_vec(),
)
.unwrap();
let (mut contract, effects) = Contract::new_with_selector(
&mut storage,
ALICE.clone(),
code_hash,
hex!("ed4b9d1b"), // init_value
(),
vec![],
vec![],
1,
0,
)
.unwrap();
insta::assert_debug_snapshot!(contract);
insta::assert_debug_snapshot!(effects);
for (account, event) in effects.pink_events {
if let PinkEvent::OnBlockEndSelector(selector) = event {
if account == contract.address {
contract.set_on_block_end_selector(selector);
}
}
}
let effects = contract.on_block_end(&mut storage, 1, 1).unwrap();
insta::assert_debug_snapshot!(effects);
} | rust_cleaned_test_functions.jsonl/122570 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 481
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4470,
7113,
6213,
368,
341,
262,
1077,
5206,
5819,
284,
19185,
486,
931,
23310,
543,
262,
1077,
2038,
8950,
284,
5819,
198,
286,
659,
6120,
4136,
1006,
310,
8753,
5487,
15997,
3148,
310,
2924,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
#[test]
fn test_vec() {
assert_eq!(Body::from(Vec::from("test")).size(), BodySize::Sized(4));
assert_eq!(Body::from(Vec::from("test")).get_ref(), b"test");
assert_eq!(Vec::from("test").size(), BodySize::Sized(4));
assert_eq!(
block_on(poll_fn(|cx| Vec::from("test").poll_next(cx)))
.unwrap()
.ok(),
Some(Bytes::from("test"))
);
} | rust_cleaned_test_functions.jsonl/82687 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 238
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13251,
368,
341,
286,
2060,
10714,
10297,
5444,
486,
1499,
49923,
486,
1499,
445,
1944,
15197,
2141,
1507,
13958,
1695,
486,
50,
1506,
7,
19,
1106,
286,
2060,
10714,
10297,
5444,
486,
1499,
49923,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_overflow() {
assert_eq!(
Number::from_parts(i128::MAX, 0) + Number::from_parts(1, 0),
Number::Infinity
);
} | rust_cleaned_test_functions.jsonl/71160 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 97
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
79073,
368,
341,
286,
2060,
10714,
33673,
310,
5624,
486,
1499,
33217,
1956,
16,
17,
23,
486,
10586,
11,
220,
15,
8,
488,
5624,
486,
1499,
33217,
7,
16,
11,
220,
15,
1326,
310,
5624,
486,
45... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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() {
let (rx, rp) = crate::test::create_client();
rp.digital
.set_direction(crate::digital::Gpio::DIO0_N, crate::digital::Direction::OUT);
assert_eq!("DIG:PIN:DIR OUT,DIO0_N\r\n", rx.recv().unwrap());
rp.digital
.set_state(crate::digital::Gpio::DIO0_N, crate::digital::State::HIGH);
assert_eq!("DIG:PIN DIO0_N,1\r\n", rx.recv().unwrap());
assert_eq!(
rp.digital.get_state(crate::digital::Gpio::DIO0_N),
Ok(crate::digital::State::HIGH)
);
} | rust_cleaned_test_functions.jsonl/15583 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 312
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4387,
368,
341,
286,
1077,
320,
12651,
11,
33109,
8,
284,
17717,
486,
1944,
486,
3182,
8179,
1428,
286,
33109,
87446,
198,
310,
659,
746,
25438,
54907,
486,
57269,
486,
38,
11917,
486,
35,
3810,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_source_code_5() {
let http_server_guard = crate::test_util::http_server();
let (_temp_dir, fetcher) = test_setup();
let double_redirect_url =
Url::parse("http://localhost:4548/tests/subdir/redirects/redirect1.js")
.unwrap();
let redirect_url =
Url::parse("http://localhost:4546/tests/subdir/redirects/redirect1.js")
.unwrap();
let target_path = fetcher
.deps_cache
.location
.join("http/localhost_PORT4545/tests/subdir/redirects/redirect1.js");
let target_path_ = target_path.clone();
// Test that redirect target is not downloaded twice for different redirect source.
let fut = fetcher
.get_source_file_async(&double_redirect_url, true, false, false)
.then(move |result| {
assert!(result.is_ok());
let result = fs::File::open(&target_path);
assert!(result.is_ok());
let file = result.unwrap();
// save modified timestamp for headers file of redirect target
let file_metadata = file.metadata().unwrap();
let file_modified = file_metadata.modified().unwrap();
// shouldn't be downloaded again. It can be verified using source header file creation
fetcher
.get_source_file_async(&redirect_url, true, false, false)
.map(move |r| (r, file_modified))
})
.map(move |(result, file_modified)| {
assert!(result.is_ok());
let result = fs::File::open(&target_path_);
assert!(result.is_ok());
let file_2 = result.unwrap();
// save modified timestamp for headers file
let file_metadata_2 = file_2.metadata().unwrap();
let file_modified_2 = file_metadata_2.modified().unwrap();
assert_eq!(file_modified, file_modified_2);
});
tokio_util::run(fut);
drop(http_server_guard);
} | rust_cleaned_test_functions.jsonl/16756 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 784
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
10347,
4136,
62,
20,
368,
341,
262,
1077,
1758,
12015,
36796,
284,
17717,
486,
1944,
18974,
486,
1254,
12015,
543,
262,
1077,
5453,
3888,
4334,
11,
7807,
261,
8,
284,
1273,
21363,
1428,
26... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_base58_decode() {
// Basics
assert_eq!(from("1").ok(), Some(vec![0u8]));
assert_eq!(from("2").ok(), Some(vec![1u8]));
assert_eq!(from("21").ok(), Some(vec![58u8]));
assert_eq!(from("211").ok(), Some(vec![13u8, 36]));
// Leading zeroes
assert_eq!(from("1211").ok(), Some(vec![0u8, 13, 36]));
assert_eq!(from("111211").ok(), Some(vec![0u8, 0, 0, 13, 36]));
// Addresses
assert_eq!(
from_check("1PfJpZsjreyVrqeoAfabrRwwjQyoSQMmHH").ok(),
Some(from_hex("00f8917303bfa8ef24f292e8fa1419b20460ba064d").unwrap())
)
} | rust_cleaned_test_functions.jsonl/42586 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 292
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7651,
20,
23,
15227,
368,
341,
197,
197,
322,
67176,
198,
197,
6948,
10714,
10297,
1499,
445,
16,
1827,
562,
1507,
4329,
25592,
20703,
15,
84,
23,
14382,
197,
6948,
10714,
10297,
1499,
445,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_201() {
let s = "..#.#..#####.#.#.#.###.##.....###.##.#..###.####..#####..#....#..#..##..##\
#..######.###...####..#..#####..##..#.#####...##.#.#..#.##..#.#......#.###\
.######.###.####...#.##.##..#..#..#####.....#.#....###..#.##......#.....#.\
.#..#..##..#...##.######.####.####.#.#...#.......#..#.#.#...####.##.#.....\
.#..#...##.#.##..#...##.#.##..###.#......#.#.......#.#.#.####.###.##...#..\
...####.#..#..#.##.#....##..#.####....##...##..#...#......#.#.......#.....\
..##..####..#...#.#.#...##..#.#..###..#####........#..####......#..#
#..#.
#....
##..#
..#..
..###";
let s = fs::read_to_string("src/input20").expect("cannot read file");
let xs = s.trim().split("\n\n").collect::<Vec<&str>>();
let r = part1(xs, 2);
assert_eq!(r, 5097);
} | rust_cleaned_test_functions.jsonl/57437 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 397
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
17,
15,
16,
368,
341,
286,
1077,
274,
284,
32213,
2,
43326,
496,
67331,
43326,
43326,
43326,
13,
14374,
13,
565,
18083,
14374,
13,
565,
43326,
496,
14374,
13,
820,
496,
67331,
496,
2,
1934... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_push_value_failure() {
let size = 1;
let mut stack = super::Stack::init(size);
stack.push(String::from("a"));
assert_eq!(stack.push(String::from("b")), false);
} | rust_cleaned_test_functions.jsonl/70594 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 87
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14218,
3142,
43618,
368,
341,
262,
1077,
1379,
284,
220,
16,
280,
262,
1077,
5206,
5611,
284,
2256,
486,
4336,
486,
2327,
6856,
317,
262,
5611,
2552,
2242,
486,
1499,
445,
64,
4010,
262,
2060,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_highlight_text() {
assert_eq!(
highlight_text(
"mein treffer",
&vec!["treffer"].iter().map(|el| el.to_string()).collect(),
&DEFAULT_SNIPPETINFO,
Some(&get_test_tokenizer())
)
.unwrap(),
"mein <b>treffer</b>"
);
assert_eq!(
highlight_text(
"mein treffer treffers",
&vec!["treffers", "treffer"].iter().map(|el| el.to_string()).collect(),
&DEFAULT_SNIPPETINFO,
Some(&get_test_tokenizer())
)
.unwrap(),
"mein <b>treffer</b> <b>treffers</b>"
);
assert_eq!(
highlight_text(
"Schön-Hans",
&vec!["Hans"].iter().map(|el| el.to_string()).collect(),
&DEFAULT_SNIPPETINFO,
Some(&get_test_tokenizer())
)
.unwrap(),
"Schön-<b>Hans</b>"
);
assert_eq!(
highlight_text(
"Schön-Hans",
&vec!["Haus"].iter().map(|el| el.to_string()).collect(),
&DEFAULT_SNIPPETINFO,
Some(&get_test_tokenizer())
),
None
);
} | rust_cleaned_test_functions.jsonl/53288 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 827
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
74546,
4326,
368,
341,
286,
2060,
10714,
33673,
310,
11167,
4326,
1006,
394,
330,
2660,
258,
4258,
2945,
756,
394,
609,
4083,
0,
1183,
10157,
2945,
5521,
2015,
1005,
2186,
22428,
301,
91,
655,
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_empty_nested() {
let value = Annotated::from(Test {
answer: Annotated::empty(),
});
assert_eq_str!(serialize(&value).unwrap(), "{}")
} | rust_cleaned_test_functions.jsonl/126376 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 99
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15124,
66279,
368,
341,
286,
1077,
897,
284,
1527,
87029,
486,
1499,
31159,
341,
310,
4226,
25,
1527,
87029,
486,
3194,
3148,
286,
3011,
286,
2060,
10714,
2895,
10297,
24166,
2099,
957,
568,
15454... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_load_opcode() {
let mut test_vm = VM::new();
test_vm.program = vec![1, 0, 1, 244]; // this is how we represent 500 using two u8s in little endian format
test_vm.run();
assert_eq!(test_vm.registers[0].content, 500);
} | rust_cleaned_test_functions.jsonl/60340 | {
"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,
12411,
71319,
368,
341,
286,
1077,
5206,
1273,
39008,
284,
17792,
486,
931,
543,
286,
1273,
39008,
45082,
284,
7486,
20703,
16,
11,
220,
15,
11,
220,
16,
11,
220,
17,
19,
19,
5265,
442,
419,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_var_uint_overflow_detection() {
let _var_uint = VarUInt::read(&mut Cursor::new(&[
0b0111_1111,
0b0111_1111,
0b0111_1111,
0b0111_1111,
0b0111_1111,
0b0111_1111,
0b0111_1111,
0b0111_1111,
0b0111_1111,
0b1111_1111,
]))
.expect_err("This should have failed due to overflow.");
} | rust_cleaned_test_functions.jsonl/116131 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 281
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
4612,
15807,
79073,
57505,
368,
341,
286,
1077,
716,
947,
15807,
284,
8735,
18777,
486,
878,
2099,
6984,
28067,
486,
931,
2099,
9640,
310,
220,
15,
65,
15,
16,
16,
16,
62,
16,
16,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_type() {
assert_eq!(
crate::rsass(
"@use \'sass:color\';\
\na {b: color.hwb(\"foo\", 30%, 40%, 0.5)}\
\n"
)
.unwrap_err(),
"Error: $hue: \"foo\" is not a number.\
\n ,\
\n2 | a {b: color.hwb(\"foo\", 30%, 40%, 0.5)}\
\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\
\n \'\
\n input.scss 2:7 root stylesheet",
);
} | rust_cleaned_test_functions.jsonl/33220 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 312
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1819,
368,
341,
286,
2060,
10714,
33673,
310,
17717,
486,
5428,
395,
1006,
394,
8428,
810,
27152,
60326,
25,
3423,
59,
6967,
5661,
1797,
1124,
3376,
314,
65,
25,
1894,
860,
20211,
36014,
7975,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_bit() {
let n = 100;
let mut rng: StdRng = SeedableRng::from_seed([0; 32]);
for _ in 0..n {
let bits: u64 = rng.gen();
let k = bits.count_ones() as u8;
for p in 0..64 {
let ans = (bits >> p) & 1 == 1;
assert_eq!(
decode_bit(encode(bits, k).0, k, p),
ans,
"the {}-th bit of {:064b} is {}",
p,
bits,
ans as u8,
);
}
}
} | rust_cleaned_test_functions.jsonl/50479 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 403
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15227,
13996,
368,
341,
286,
1077,
308,
284,
220,
16,
15,
15,
280,
286,
1077,
5206,
28422,
25,
42517,
49,
968,
284,
35822,
480,
49,
968,
486,
1499,
33809,
2561,
15,
26,
220,
18,
17,
2558,
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... | 3 |
#[test]
fn test_discrete_forward_equals_backward_toy_example() {
// Same toy example as above.
let transition = array![[0.5, 0.5], [0.4, 0.6]];
let observation = array![[0.2, 0.3, 0.3, 0.2], [0.3, 0.2, 0.2, 0.3]];
let initial = array![0.5, 0.5];
let hmm = DiscreteEmissionHMM::with_float(&transition, &observation, &initial)
.expect("Dimensions should be consistent");
for len in 1..10 {
let mut seq: Vec<usize> = vec![0; len];
while seq.iter().sum::<usize>() != len {
for i in 0..len {
if seq[i] == 0 {
seq[i] = 1;
break;
} else {
seq[i] = 0;
}
}
let prob_fwd = *Prob::from(forward(&hmm, &seq).1);
let prob_bck = *Prob::from(backward(&hmm, &seq).1);
assert_relative_eq!(prob_fwd, prob_bck, epsilon = 0.00001);
}
}
} | rust_cleaned_test_functions.jsonl/13087 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 622
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9932,
9353,
32121,
61664,
70477,
528,
2253,
39304,
368,
341,
286,
442,
25739,
21357,
3110,
438,
3403,
624,
286,
1077,
9142,
284,
1334,
0,
15505,
15,
13,
20,
11,
220,
15,
13,
20,
1125,
508,
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... | 5 |
#[test]
fn test_expect_timestamp_or_null() {
assert_eq!(
Ok(None),
expect_timestamp_or_null(value_null(0), Format::HttpDate)
);
assert_eq!(
Ok(Some(Instant::from_f64(2048.0))),
expect_timestamp_or_null(value_number(0, Number::Float(2048.0)), Format::EpochSeconds)
);
assert_eq!(
Ok(Some(Instant::from_f64(1445412480.0))),
expect_timestamp_or_null(
value_string(0, "Wed, 21 Oct 2015 07:28:00 GMT"),
Format::HttpDate
)
);
assert_eq!(
Ok(Some(Instant::from_f64(1445412480.0))),
expect_timestamp_or_null(value_string(0, "2015-10-21T07:28:00Z"), Format::DateTime)
);
assert_eq!(
Err(Error::custom("expected ValueNumber or ValueNull")),
expect_timestamp_or_null(value_string(0, "wrong"), Format::EpochSeconds)
);
assert_eq!(
Err(Error::custom("expected ValueString or ValueNull")),
expect_timestamp_or_null(value_number(0, Number::Float(0.0)), Format::DateTime)
);
} | rust_cleaned_test_functions.jsonl/65150 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 608
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
68918,
23073,
8734,
15162,
368,
341,
286,
2060,
10714,
33673,
310,
7622,
26717,
1326,
310,
1720,
23073,
8734,
15162,
3679,
15162,
7,
15,
701,
15042,
486,
2905,
1916,
340,
286,
1439,
286,
2060,
107... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_describe() {
let body: String = String::from("{ \"foo\": \"bar\" }");
let msj = describe(&Method::Get, &String::from("/foo/bar"), &body);
assert_eq!(
msj,
"synchronous Get request \"/foo/bar\" with body \"{ \\\"foo\\\": \\\"bar\\\" }\""
);
let msj = describe(&Method::Put, &String::from("/foo/bar"), &body);
assert_eq!(
msj,
"synchronous Put request \"/foo/bar\" with body \"{ \\\"foo\\\": \\\"bar\\\" }\""
);
} | rust_cleaned_test_functions.jsonl/14377 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 271
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15768,
3114,
368,
341,
286,
1077,
2487,
25,
923,
284,
923,
486,
1499,
13976,
7245,
7975,
11693,
7245,
2257,
2105,
335,
797,
286,
1077,
9829,
73,
284,
7512,
2099,
3523,
486,
1949,
11,
609,
703,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_statistics() {
let stats: Statistics = serde_json::from_str(EXAMPLE).unwrap();
assert_eq!(stats.name, "rdkafka#producer-1");
assert_eq!(stats.client_type, "producer");
assert_eq!(stats.ts, 1163982743268);
assert_eq!(stats.time, 1589652530);
assert_eq!(stats.replyq, 0);
assert_eq!(stats.msg_cnt, 320);
assert_eq!(stats.msg_size, 9920);
assert_eq!(stats.msg_max, 500000);
assert_eq!(stats.msg_size_max, 1073741824);
assert_eq!(stats.simple_cnt, 0);
assert_eq!(stats.brokers.len(), 1);
assert_eq!(stats.topics.len(), 1);
} | rust_cleaned_test_functions.jsonl/25884 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 327
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
49569,
368,
341,
286,
1077,
10472,
25,
24624,
284,
61570,
9455,
486,
1499,
2895,
25409,
18918,
568,
15454,
1428,
286,
2060,
10714,
10297,
16260,
2644,
11,
330,
6498,
74,
21883,
2,
58912,
12,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_nf() {
use self::Subst::*;
use self::Type::*;
assert_eq!(Var(0).nf(Id), Var(0));
assert_eq!(Var(20).nf(Id), Var(20));
assert_eq!(Var(0).nf(Shift), Var(1));
assert_eq!(Var(1).nf(Shift), Var(2));
assert_eq!(
Var(0).nf(Subst::cons(Type::closure(Var(0), Id), Shift)),
Var(0)
);
assert_eq!(
Var(0).nf(Subst::cons(Type::closure(Var(1), Id), Shift)),
Var(1)
);
assert_eq!(
Var(0).nf(Subst::cons(Type::closure(Var(21), Id), Shift)),
Var(21)
);
assert_eq!(
Var(1).nf(Subst::cons(Type::closure(Var(21), Id), Shift)),
Var(1)
);
assert_eq!(
Var(1).nf(Subst::cons(Type::closure(Var(21), Id), Id)),
Var(0)
);
assert_eq!(Var(0).nf(Subst::comp(Id, Id)), Var(0));
assert_eq!(Var(0).nf(Subst::comp(Id, Shift)), Var(1));
assert_eq!(Var(0).nf(Subst::comp(Shift, Id)), Var(1));
assert_eq!(Var(0).nf(Subst::comp(Shift, Shift)), Var(2));
assert_eq!(Type::arr(Var(0), Var(0)).nf(Id), Type::arr(Var(0), Var(0)));
assert_eq!(
Type::arr(Var(0), Var(0)).nf(Shift),
Type::arr(Var(1), Var(1))
);
assert_eq!(Type::forall(Var(0)).nf(Id), Type::forall(Var(0)));
assert_eq!(Type::forall(Var(0)).nf(Shift), Type::forall(Var(0)));
assert_eq!(Type::forall(Var(1)).nf(Shift), Type::forall(Var(2)));
assert_eq!(
Type::forall(Var(0)).nf(Subst::cons(Type::closure(Var(77), Id), Id)),
Type::forall(Var(0))
);
assert_eq!(
Type::forall(Var(1)).nf(Subst::cons(Type::closure(Var(77), Id), Id)),
Type::forall(Var(78))
);
assert_eq!(
Type::forall(Type::forall(Var(2))).nf(Subst::cons(Type::closure(Var(0), Id), Shift)),
Type::forall(Type::forall(Var(2)))
);
assert_eq!(
Type::forall(Type::forall(Var(2))).nf(Subst::cons(Type::closure(Var(0), Id), Id)),
Type::forall(Type::forall(Var(2)))
);
} | rust_cleaned_test_functions.jsonl/35849 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1247
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
78225,
368,
341,
286,
990,
656,
486,
3136,
267,
56162,
286,
990,
656,
486,
929,
79304,
286,
2060,
10714,
10297,
3962,
7,
15,
568,
31737,
55924,
701,
8735,
7,
15,
1106,
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_encryption_decryption_combined() -> anyhow::Result<()> {
let mut cs_rng = CsRng::default();
let key = cs_rng.generate_key();
let bytes = cs_rng.generate_random_bytes(8192);
let iv = cs_rng.generate_nonce();
// no additional data
let encrypted_result = encrypt_combined(&key, &bytes, &iv, None)?;
assert_ne!(encrypted_result, bytes);
assert_eq!(bytes.len() + MAC_LENGTH, encrypted_result.len());
let recovered = decrypt_combined(&key, encrypted_result.as_slice(), &iv, None)?;
assert_eq!(bytes, recovered);
// additional data
let ad = cs_rng.generate_random_bytes(42);
let encrypted_result = encrypt_combined(&key, &bytes, &iv, Some(&ad))?;
assert_ne!(encrypted_result, bytes);
assert_eq!(bytes.len() + MAC_LENGTH, encrypted_result.len());
let recovered = decrypt_combined(&key, encrypted_result.as_slice(), &iv, Some(&ad))?;
assert_eq!(bytes, recovered);
Ok(())
} | rust_cleaned_test_functions.jsonl/132751 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 445
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13781,
15597,
13783,
15597,
89945,
368,
1464,
88964,
486,
2077,
71698,
341,
286,
1077,
5206,
10532,
66849,
284,
67332,
49,
968,
486,
2258,
543,
286,
1077,
1376,
284,
10532,
66849,
22019,
3097,
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... | 5 |
#[test]
fn test_try_expr() {
check_assist(
inline_local_variable,
"
fn foo() -> Option<usize> {
let bar = Some(1);
let a<|> = bar?;
let b = a * 10;
let c = a as usize;
None
}",
"
fn foo() -> Option<usize> {
let bar = Some(1);
<|>let b = bar? * 10;
let c = bar? as usize;
None
}",
);
} | rust_cleaned_test_functions.jsonl/60322 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 214
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
53283,
21915,
368,
341,
286,
1779,
12083,
380,
1006,
310,
7381,
13564,
14635,
345,
310,
6228,
8822,
15229,
368,
1464,
6959,
90244,
29,
341,
262,
1077,
3619,
284,
4329,
7,
16,
317,
262,
1077,
264... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_test() {
assert_eq!(
parse_test("test x = 3\n"),
Ok((
"\n",
Instruction::Test(
Target::Register(String::from("x")),
Comparator::Equal,
Target::Literal(3)
)
)),
);
assert_eq!(
parse_test("test x > t\n"),
Ok((
"\n",
Instruction::Test(
Target::Register(String::from("x")),
Comparator::GreaterThan,
Target::Register(String::from("t")),
)
)),
);
assert_eq!(
parse_test("test x < #nrv\n"),
Ok((
"\n",
Instruction::Test(
Target::Register(String::from("x")),
Comparator::LessThan,
Target::Register(String::from("#nrv")),
)
)),
);
} | rust_cleaned_test_functions.jsonl/993 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 677
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4452,
368,
341,
286,
2060,
10714,
33673,
310,
4715,
4452,
445,
1944,
856,
284,
220,
18,
1699,
4461,
310,
7622,
94702,
394,
2917,
77,
756,
394,
29051,
486,
2271,
1006,
503,
13483,
486,
8690,
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_label_values_do_not_change() {
type StaticStr = &'static str;
assert_eq!(StaticStr::from(ApiReqType::Call), "call");
assert_eq!(StaticStr::from(ApiReqType::Query), "query");
assert_eq!(StaticStr::from(ApiReqType::ReadState), "read_state");
assert_eq!(StaticStr::from(ApiReqType::Status), "status");
assert_eq!(
StaticStr::from(ApiReqType::CatchUpPackage),
"catch_up_package"
);
assert_eq!(StaticStr::from(ApiReqType::Options), "options");
assert_eq!(StaticStr::from(ApiReqType::Dashboard), "dashboard");
assert_eq!(
StaticStr::from(ApiReqType::RedirectToDashboard),
"redirect_to_dashboard"
);
assert_eq!(
StaticStr::from(ApiReqType::InvalidArgument),
"invalid_argument"
);
assert_eq!(StaticStr::from(ApiReqType::PprofHome), "pprof_home");
assert_eq!(StaticStr::from(ApiReqType::PprofProfile), "pprof_profile");
assert_eq!(
StaticStr::from(ApiReqType::PprofFlamegraph),
"pprof_flamegraph"
);
assert_eq!(to_legacy_request_type(ApiReqType::Call), "submit");
assert_eq!(StaticStr::from(AppLayer::Http), "http");
assert_eq!(StaticStr::from(AppLayer::Https), "https");
assert_eq!(
StaticStr::from(ConnectionError::TlsHandshake),
"tls_handshake"
);
assert_eq!(
StaticStr::from(ConnectionError::ServingHttpConnection),
"serving_http_connection"
);
assert_eq!(
StaticStr::from(ConnectionError::ServingHttpsConnection),
"serving_https_connection"
);
assert_eq!(StaticStr::from(ConnectionError::Accept), "accept");
assert_eq!(StaticStr::from(ConnectionError::Peek), "peek");
assert_eq!(
StaticStr::from(ConnectionError::PeekTimeout),
"peek_timeout"
);
} | rust_cleaned_test_functions.jsonl/94996 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 980
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6106,
9146,
26309,
7913,
15947,
368,
341,
286,
943,
23105,
2580,
284,
30136,
1978,
607,
280,
286,
2060,
10714,
10297,
11690,
2580,
486,
1499,
65830,
27234,
929,
486,
7220,
701,
330,
6659,
797,
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_straight_cascade() {
test(&["4S 6C 7S 8D 5H", "5S 7H 8S 9D 6H"], &["5S 7H 8S 9D 6H"])
} | rust_cleaned_test_functions.jsonl/49910 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 71
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2895,
7386,
666,
19977,
368,
341,
1066,
262,
1273,
2099,
1183,
19,
50,
220,
21,
34,
220,
22,
50,
220,
23,
35,
220,
20,
39,
497,
330,
20,
50,
220,
22,
39,
220,
23,
50,
220,
24,
35,
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_account_grow_many() {
let (_accounts_dir, paths) = get_temp_accounts_paths(2).unwrap();
let size = 4096;
let accounts = AccountsDB::new_sized(Some(paths), size);
let mut keys = vec![];
for i in 0..9 {
let key = Pubkey::new_rand();
let account = Account::new(i + 1, size as usize / 4, &key);
accounts.store(0, &hashmap!(&key => &account));
keys.push(key);
}
for (i, key) in keys.iter().enumerate() {
let ancestors = vec![(0, 0)].into_iter().collect();
assert_eq!(
accounts.load_slow(&ancestors, &key).unwrap().0.lamports,
(i as u64) + 1
);
}
let mut append_vec_histogram = HashMap::new();
for storage in accounts
.storage
.read()
.unwrap()
.0
.values()
.flat_map(|x| x.values())
{
*append_vec_histogram.entry(storage.fork_id).or_insert(0) += 1;
}
for count in append_vec_histogram.values() {
assert!(*count >= 2);
}
} | rust_cleaned_test_functions.jsonl/58297 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 627
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13500,
1889,
651,
22101,
368,
341,
286,
1077,
5453,
26206,
4334,
11,
12716,
8,
284,
633,
11771,
55665,
24152,
7,
17,
568,
15454,
543,
286,
1077,
1379,
284,
220,
19,
15,
24,
21,
280,
286,
1077,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
#[test]
fn test_cached_smartstring_from_str() {
smartstring::validate();
assert!(cached_smartstring_from_str("true"));
{
let cache = CACHED_SMARTSTRING_FROM_STR.lock().unwrap();
assert_eq!(cache.cache_hits(), Some(0));
assert_eq!(cache.cache_misses(), Some(1));
}
assert!(cached_smartstring_from_str("true"));
{
let cache = CACHED_SMARTSTRING_FROM_STR.lock().unwrap();
assert_eq!(cache.cache_hits(), Some(1));
assert_eq!(cache.cache_misses(), Some(1));
}
assert!(!cached_smartstring_from_str("false"));
{
let cache = CACHED_SMARTSTRING_FROM_STR.lock().unwrap();
assert_eq!(cache.cache_hits(), Some(1));
assert_eq!(cache.cache_misses(), Some(2));
}
} | rust_cleaned_test_functions.jsonl/13145 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 362
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
64369,
88825,
917,
5673,
2895,
368,
341,
262,
7785,
917,
486,
7067,
1428,
262,
2060,
10297,
32918,
88825,
917,
5673,
2895,
445,
1866,
4010,
262,
341,
286,
1077,
6500,
284,
356,
52645,
28845,
2992,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_put_get_simple() {
let ledger_path = get_tmp_ledger_path_auto_delete!();
let blockstore = Blockstore::open(ledger_path.path()).unwrap();
// Test meta column family
let meta = SlotMeta::new(0, 1);
blockstore.meta_cf.put(0, &meta).unwrap();
let result = blockstore
.meta_cf
.get(0)
.unwrap()
.expect("Expected meta object to exist");
assert_eq!(result, meta);
// Test erasure column family
let erasure = vec![1u8; 16];
let erasure_key = (0, 0);
blockstore
.code_shred_cf
.put_bytes(erasure_key, &erasure)
.unwrap();
let result = blockstore
.code_shred_cf
.get_bytes(erasure_key)
.unwrap()
.expect("Expected erasure object to exist");
assert_eq!(result, erasure);
// Test data column family
let data = vec![2u8; 16];
let data_key = (0, 0);
blockstore.data_shred_cf.put_bytes(data_key, &data).unwrap();
let result = blockstore
.data_shred_cf
.get_bytes(data_key)
.unwrap()
.expect("Expected data object to exist");
assert_eq!(result, data);
} | rust_cleaned_test_functions.jsonl/9537 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 670
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15557,
3062,
30015,
368,
341,
286,
1077,
46933,
2638,
284,
633,
16125,
38367,
1389,
2638,
27740,
11353,
0,
543,
286,
1077,
2504,
4314,
284,
8362,
4314,
486,
2508,
7,
50704,
2638,
3875,
6011,
15454... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_another_configuration_change_proposal() {
let mut testkit = testkit_with_supervisor_and_service(4);
let initiator_id = testkit.network().us().validator_id().unwrap();
let params = "I am a new parameter".to_owned();
let cfg_change_height = Height(4);
let propose = ConfigProposeBuilder::new(cfg_change_height)
.configuration_number(0)
.extend_service_config_propose(params.clone())
.build();
let proposal_hash = propose.object_hash();
testkit
.create_block_with_transaction(sign_config_propose_transaction(
&testkit,
propose,
initiator_id,
))
.transactions[0]
.status()
.expect("Transaction with change propose discarded.");
// Try to commit second config change propose.
let second_propose = ConfigProposeBuilder::new(cfg_change_height)
.configuration_number(1)
.extend_service_config_propose("I am an overridden parameter".to_string())
.build();
let signed_proposal = sign_config_propose_transaction(&testkit, second_propose, initiator_id);
let block = testkit.create_block_with_transaction(signed_proposal);
let err = block.transactions[0].status().unwrap_err();
assert_eq!(
*err,
ErrorMatch::from_fail(&ConfigurationError::ConfigProposeExists)
.for_service(SUPERVISOR_INSTANCE_ID)
);
let signed_txs = build_confirmation_transactions(&testkit, proposal_hash, initiator_id);
testkit
.create_block_with_transactions(signed_txs)
.transactions[0]
.status()
.expect("Transaction with confirmations discarded.");
testkit.create_blocks_until(cfg_change_height);
assert_eq!(config_propose_entry(&testkit), None);
check_service_actual_param(&testkit, Some(params));
} | rust_cleaned_test_functions.jsonl/93841 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 737
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12008,
1575,
35726,
15947,
21663,
32556,
368,
341,
262,
1077,
5206,
1273,
8226,
284,
1273,
8226,
6615,
23723,
31396,
8378,
12267,
7,
19,
317,
262,
1077,
98040,
842,
284,
1273,
8226,
20573,
1005,
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_simple() {
let regex = r"^(?P<foo>\d*),(?P<bar>-?\d*)$";
let input = "1,-2";
let output: Test = from_str(input, regex).unwrap();
assert_eq!(output, Test { foo: 1, bar: -2 });
} | rust_cleaned_test_functions.jsonl/133414 | {
"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,
30015,
368,
341,
286,
1077,
20180,
284,
435,
1,
13268,
30,
47,
27,
7975,
8449,
67,
9,
23547,
30,
47,
27,
2257,
38643,
32620,
67,
3764,
3,
876,
286,
1077,
1946,
284,
330,
16,
4999,
17,
876,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_add_fails_on_nan_t_ref() {
let a = not_nan(std::f32::INFINITY);
let b = std::f32::NEG_INFINITY;
let _c = a + &b;
} | rust_cleaned_test_functions.jsonl/80091 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 82
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
761,
6209,
4470,
73936,
528,
7793,
368,
341,
262,
1077,
264,
284,
537,
73936,
5194,
486,
69,
18,
17,
486,
687,
55990,
317,
262,
1077,
293,
284,
1460,
486,
69,
18,
17,
486,
97127,
91110,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_perspective_camera_should_map_points_inside_frustum_inside_canonical_view_volume() {
let near = 0.1;
let far = 100.0;
let fovy = 67.0; // degrees
let aspect = 720.0 / 480.0;
let frustum_fov = FrustumFov::new(near, far, fovy, aspect);
let origin = cgmath::vec3((0.0, 0.0, 5.0));
let forward = cgmath::vec4((0.0, 0.0, -1.0, 0.0));
let right = cgmath::vec4((1.0, 0.0, 0.0, 0.0));
let up = cgmath::vec4((0.0, 1.0, 0.0, 0.0));
let rotation_axis = cgmath::vec3((0.0, 0.0, -1.0));
let attitude = CameraAttitude::new(origin, forward, right, up, rotation_axis);
let camera = PerspectiveFovCamera::new(frustum_fov, attitude);
let p_cam = cgmath::vec4((1.0, 1.0, 1.0, 1.0));
let p_cvv = camera.proj_mat * p_cam;
let p_cvv = cgmath::vec3((p_cvv.x, p_cvv.y, p_cvv.z));
let cvv = AxisAlignedBoundingBox::unit_aabb();
assert!(cvv.contains(p_cvv), "p_cam = {}; p_cvv = {}", p_cam, p_cvv);
} | rust_cleaned_test_functions.jsonl/59094 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 469
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
85091,
29843,
43378,
5376,
12928,
72860,
761,
35788,
372,
72860,
27421,
22391,
7122,
26941,
368,
341,
262,
1077,
3143,
284,
220,
15,
13,
16,
280,
262,
1077,
3041,
284,
220,
16,
15,
15,
13,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_batch_tso_provider_on_failure() {
let pd_cli = Arc::new(TestPdClient::new(1, false));
pd_cli.set_tso(1000.into());
{
pd_cli.trigger_tso_failure();
assert!(
block_on(BatchTsoProvider::new_opt(
pd_cli.clone(),
Duration::ZERO,
100
))
.is_err()
);
}
let provider = block_on(BatchTsoProvider::new_opt(
pd_cli.clone(),
Duration::ZERO,
100,
))
.unwrap();
assert_eq!(provider.batch_size(), 100);
for ts in 1001..=1010u64 {
assert_eq!(TimeStamp::from(ts), provider.get_ts().unwrap())
}
pd_cli.trigger_tso_failure();
for ts in 1011..=1020u64 {
assert_eq!(TimeStamp::from(ts), provider.get_ts().unwrap())
}
assert!(provider.flush().is_err());
for ts in 1101..=1300u64 {
assert_eq!(TimeStamp::from(ts), provider.get_ts().unwrap())
}
pd_cli.trigger_tso_failure();
assert!(provider.get_ts().is_err()); // renew fail on used-up
pd_cli.trigger_tso_failure();
assert!(provider.flush().is_err());
provider.flush().unwrap();
pd_cli.trigger_tso_failure(); // make renew fail to verify used-up
for ts in 1301..=1700u64 {
assert_eq!(TimeStamp::from(ts), provider.get_ts().unwrap())
}
assert!(provider.get_ts().is_err());
} | rust_cleaned_test_functions.jsonl/45248 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 897
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14534,
528,
704,
29518,
4470,
43618,
368,
341,
286,
1077,
7744,
47147,
284,
19689,
486,
931,
31159,
47,
67,
2959,
486,
931,
7,
16,
11,
895,
1106,
286,
7744,
47147,
980,
528,
704,
7,
16,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
#[test]
fn test_tg_mnemonic() {
let client = TestClient::new();
let crc16 = client.request_json("crypto.ton_crc16", json!({
"hex": "0123456789abcdef"
})).unwrap();
assert_eq!(crc16, 43349);
let keys = client.request_map(
"crypto.mnemonic.derive.sign.keys",
json!({
"phrase": "owner stock veteran sort resource round smart plug tent picture ozone fury",
}),
);
assert_eq!(TestClient::get_map_string(&keys, "public"), "36cf573461971289477d65ebc67664805207d07d1cfb337bc28ff86a3f4fa8c7");
let keys = TestClient::parse_object(client.request(
"crypto.mnemonic.derive.sign.keys",
json!({
"phrase": "unit follow zone decline glare flower crisp vocal adapt magic much mesh cherry teach mechanic rain float vicious solution assume hedgehog rail sort chuckle",
"dictionary": 0,
"wordCount": 24,
}),
));
let ton_public = TestClient::parse_string(client.request(
"crypto.ton_public_key_string",
Value::String(TestClient::get_map_string(&keys, "public")),
));
assert_eq!(ton_public, "PubDdJkMyss2qHywFuVP1vzww0TpsLxnRNnbifTCcu-XEgW0");
let words = TestClient::parse_string(client.request("crypto.mnemonic.words", json!({
})));
assert_eq!(words.split(" ").count(), 2048);
let phrase = TestClient::parse_string(client.request("crypto.mnemonic.from.random", json!({
})));
assert_eq!(phrase.split(" ").count(), 12);
let phrase = TestClient::parse_string(client.request("crypto.mnemonic.from.random", json!({
"dictionary": 1,
"wordCount": 24,
})));
assert_eq!(phrase.split(" ").count(), 24);
let entropy = "2199ebe996f14d9e4e2595113ad1e6276bd05e2e147e16c8ab8ad5d47d13b44fcf";
let mnemonic = TestClient::parse_string(client.request("crypto.mnemonic.from.entropy", json!({
"dictionary": 0,
"wordCount": 24,
"entropy": json!({
"hex": entropy,
}),
})));
let public = TestClient::get_map_string(&TestClient::parse_object(client.request(
"crypto.mnemonic.derive.sign.keys",
json!({
"phrase": mnemonic,
"dictionary": 0,
"wordCount": 24
}),
)), "public");
let ton_public = TestClient::parse_string(client.request(
"crypto.ton_public_key_string",
Value::String(public),
));
assert_eq!(ton_public, "PuYGEX9Zreg-CX4Psz5dKehzW9qCs794oBVUKqqFO7aWAOTD");
// let ton_phrase = "shove often foil innocent soft slim pioneer day uncle drop nephew soccer worry renew public hand word nut again dry first delay first maple";
let is_valid = client.request_json(
"crypto.mnemonic.verify",
json!({
"phrase": "unit follow zone decline glare flower crisp vocal adapt magic much mesh cherry teach mechanic rain float vicious solution assume hedgehog rail sort chuckle",
"dictionary": 0,
"wordCount": 24,
}),
).unwrap();
assert_eq!(is_valid, Value::Bool(true));
let is_valid = client.request_json(
"crypto.mnemonic.verify",
json!({
"phrase": "unit follow"
}),
).unwrap();
assert_eq!(is_valid, Value::Bool(false));
let is_valid = client.request_json(
"crypto.mnemonic.verify",
json!({
"phrase": "unit unit unit unit unit unit unit unit unit unit unit unit unit unit unit unit unit unit unit unit unit unit unit unit"
}),
).unwrap();
assert_eq!(is_valid, Value::Bool(false));
let invalid_phrase = "invalid phrase for TON dictionary";
let result = client.request_json(
"crypto.mnemonic.derive.sign.keys",
json!({
"phrase": invalid_phrase
}),
);
let expected_error = ClientError::crypto_bip39_invalid_phrase(invalid_phrase);
assert_eq!(result.unwrap_err().code, expected_error.code);
} | rust_cleaned_test_functions.jsonl/69933 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1693
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
528,
70,
717,
70775,
368,
341,
262,
1077,
2943,
284,
3393,
2959,
486,
931,
543,
262,
1077,
37180,
16,
21,
284,
2943,
8223,
9455,
445,
35772,
734,
263,
59084,
16,
21,
497,
2951,
0,
2262,
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_groestl256_hash_password() {
let password = "password";
let hash = Groestl256Hasher.hash_str((), password).unwrap();
assert_eq!(
"5fc07d8c8d9d54bf2733c8f3d4d2aa8b3f1603970001fc987f1cdecde18f520f",
hash.as_hex()
);
} | rust_cleaned_test_functions.jsonl/56169 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 167
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1889,
299,
477,
75,
17,
20,
21,
8950,
10122,
368,
341,
286,
1077,
3552,
284,
330,
3833,
3302,
286,
1077,
5175,
284,
17888,
477,
75,
17,
20,
21,
6370,
261,
15101,
2895,
7,
1507,
3552,
568,
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_size() {
assert_eq!(<G1Affine as CurveAffine>::Compressed::size(), PK_SIZE);
assert_eq!(<G2Affine as CurveAffine>::Compressed::size(), SIG_SIZE);
} | rust_cleaned_test_functions.jsonl/30574 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 88
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2368,
368,
341,
286,
2060,
10714,
10297,
27,
38,
16,
25841,
482,
438,
53677,
25841,
482,
6831,
1092,
14318,
486,
2141,
1507,
24826,
4098,
317,
286,
2060,
10714,
10297,
27,
38,
17,
25841,
482,
43... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_trim_1_arg() {
let test_cases = vec![
(None, None),
(Some(" bar "), Some("bar")),
(Some(" b "), Some("b")),
(Some(" b ar "), Some("b ar")),
(Some("bar"), Some("bar")),
(Some(" "), Some("")),
(Some(" \tbar\t "), Some("\tbar\t")),
(Some(" \rbar\r "), Some("\rbar\r")),
(Some(" \nbar\n "), Some("\nbar\n")),
(Some(""), Some("")),
(Some(" 你好"), Some("你好")),
(Some(" 你 好 "), Some("你 好")),
(Some(" 분산 데이터베이스 "), Some("분산 데이터베이스")),
(
Some(" あなたのことが好きです "),
Some("あなたのことが好きです"),
),
];
for (arg, expect_output) in test_cases {
let output = RpnFnScalarEvaluator::new()
.push_param(arg.map(|s| s.as_bytes().to_vec()))
.evaluate(ScalarFuncSig::Trim1Arg)
.unwrap();
assert_eq!(output, expect_output.map(|s| s.as_bytes().to_vec()));
}
let invalid_utf8_output = RpnFnScalarEvaluator::new()
.push_param(Some(b" \xF0 Hello \x90 World \x80 ".to_vec()))
.evaluate(ScalarFuncSig::Trim1Arg)
.unwrap();
assert_eq!(
invalid_utf8_output,
Some(b"\xF0 Hello \x90 World \x80".to_vec())
);
} | rust_cleaned_test_functions.jsonl/10184 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 930
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
70025,
62,
16,
6057,
368,
341,
286,
1077,
1273,
41427,
284,
7486,
90515,
310,
320,
4064,
11,
2240,
1326,
310,
320,
8373,
445,
256,
3619,
256,
59312,
4329,
445,
2257,
30154,
310,
320,
8373,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_stashes() -> Result<()> {
let (_td, repo) = repo_init().unwrap();
let root = repo.path().parent().unwrap();
let repo_path = root.as_os_str().to_str().unwrap();
File::create(&root.join("foo.txt"))?
.write_all(b"test\nfoo")?;
stash_save(repo_path, Some("foo"), true, false)?;
let res = get_stashes(repo_path)?;
assert_eq!(res.len(), 1);
let infos =
get_commits_info(repo_path, &[res[0]], 100).unwrap();
assert_eq!(infos[0].message, "On master: foo");
Ok(())
} | rust_cleaned_test_functions.jsonl/20966 | {
"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,
1261,
14051,
368,
1464,
5714,
71698,
341,
286,
1077,
5453,
1296,
11,
15867,
8,
284,
15867,
6137,
1005,
15454,
543,
286,
1077,
3704,
284,
15867,
3875,
1005,
3765,
1005,
15454,
543,
286,
1077,
15867... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_write_then_read_replaces_lf_to_crlf_over_multiple_writes() {
let mut stream = OutputStream::new();
let (read, read_buff) = Runtime::new().unwrap().block_on(async {
stream.write(&[LF]).unwrap();
stream.write(&[1, 2, 3]).unwrap();
stream.write(&[LF, 4, 5, 6, CR]).unwrap();
stream.write(&[LF, 7, 8, 9]).unwrap();
let mut read_buff = [0u8; 1024];
let read = stream.read(&mut read_buff).await.unwrap();
(read, read_buff)
});
assert_eq!(
&read_buff[..read],
&[CR, LF, 1, 2, 3, CR, LF, 4, 5, 6, CR, LF, 7, 8, 9]
);
} | rust_cleaned_test_functions.jsonl/124338 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 369
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9165,
68367,
6443,
1288,
26078,
907,
69,
2346,
666,
2381,
69,
15431,
45233,
1670,
23262,
368,
341,
286,
1077,
5206,
4269,
284,
52058,
486,
931,
1428,
286,
1077,
320,
878,
11,
1349,
29328,
8,
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_credential_presentation() {
let schema = get_test_issuance_schema();
let issuer = CredentialIssuer::new();
let holder = CredentialHolder::new();
let cred = issuer
.sign_credential(
&schema,
&[
CredentialAttribute::Blob(holder.id.to_bytes_compressed_form()),
CredentialAttribute::String(String::from("local-test")),
CredentialAttribute::String(String::from("ockam.io")),
CredentialAttribute::Numeric(
std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap()
.as_secs() as i64,
),
],
)
.unwrap();
let mut manifest = PresentationManifest {
credential_schema: schema,
public_key: issuer.get_public_key(),
revealed: [0, 1].to_vec(),
};
let pr_id = CredentialVerifier::create_proof_request_id();
let res = holder.present_credentials(&[cred.clone()], &[manifest.clone()], pr_id);
assert!(res.is_err());
manifest.revealed = [1].to_vec();
let res = holder.present_credentials(&[cred.clone()], &[manifest.clone()], pr_id);
assert!(res.is_ok());
let prez = res.unwrap();
let res = CredentialVerifier::verify_credential_presentations(
prez.as_slice(),
&[manifest],
pr_id,
);
assert!(res.is_ok());
} | rust_cleaned_test_functions.jsonl/32384 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 884
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
666,
30320,
620,
13584,
368,
341,
286,
1077,
10802,
284,
633,
4452,
62,
1038,
84,
681,
25371,
543,
286,
1077,
54835,
284,
93379,
98902,
486,
931,
543,
286,
1077,
11839,
284,
93379,
8589,
486,
93... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_flatten() {
use parser::Parser;
let input = String::from("(+ 12 (+ 13 14))");
let parser = Parser::new(&input);
let toplevel : Vec<_> = parser.collect();
assert_eq!(
flatten(&Ast::Prog(vec![], Box::new(toplevel[0].clone()))),
FlatResult::Prog(vec![],
vec![Flat::Assign(Rc::new("tmp1".to_string()), Box::new(Flat::Prim(Rc::new("+".to_string()),
vec![Flat::Number(13), Flat::Number(14)]))),
Flat::Assign(Rc::new("tmp2".to_string()),
Box::new(Flat::Prim(Rc::new("+".to_string()),
vec![Flat::Number(12),
Flat::Symbol(Rc::new("tmp1".to_string()))]))),
Flat::Return(Box::new(Flat::Symbol(Rc::new("tmp2".to_string()))))],
vec![Rc::new("tmp1".to_string()),
Rc::new("tmp2".to_string())])
);
// independent.
assert_eq!(
flatten(&Ast::Define(Rc::new("foo".to_string()),
vec![Rc::new("x".to_string()),
Rc::new("y".to_string()),
Rc::new("z".to_string())],
box (Ast::App(box (Ast::Symbol(Rc::new("+".to_string()))),
vec![Ast::Symbol(Rc::new("x".to_string())),
Ast::Number(10)])))),
FlatResult::Define(Rc::new("foo".to_string()),
vec![Rc::new("x".to_string()),
Rc::new("y".to_string()),
Rc::new("z".to_string())],
vec![Flat::Assign(Rc::new("tmp3".to_string()),
Box::new(Flat::Prim(Rc::new("+".to_string()),
vec![Flat::Symbol(Rc::new("x".to_string())), Flat::Number(10)]))),
Flat::Return(Box::new(Flat::Symbol(Rc::new("tmp3".to_string()))))],
vec![Rc::new("tmp3".to_string())])
);
} | rust_cleaned_test_functions.jsonl/80136 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1562
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5081,
14456,
368,
341,
262,
990,
6729,
486,
6570,
401,
262,
1077,
1946,
284,
923,
486,
1499,
31732,
10,
220,
16,
17,
17973,
220,
16,
18,
220,
16,
19,
593,
797,
262,
1077,
6729,
284,
21102,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_pathops_concat() {
let actual = Path::new("foo")
.concat(Path::new("bar"))
.expect("Could not concat paths?");
let expected = PathBuf::from("foo/bar");
assert_eq!(actual, expected);
let actual = Path::new("foo")
.concat(Path::new("bar/../baz"))
.expect("Could not concat path with ..?");
let expected = PathBuf::from("foo/baz");
assert_eq!(actual, expected);
let actual = Path::new("foo")
.concat("..")
.expect("Could not cancel path with ..?");
let expected = PathBuf::from(r"");
assert_eq!(actual, expected);
let actual = Path::new("foo")
.concat("../..")
.expect("Could not prefix with ..?");
let expected = PathBuf::from(r"../");
assert_eq!(actual, expected);
let actual = Path::new("/foo")
.concat("../..")
.expect_err("Could escape root with ..?");
assert_eq!(actual.io_error().kind(), io::ErrorKind::NotFound);
assert_eq!(actual.action(), "truncating to parent");
assert_eq!(actual.path(), Path::new("/"));
let actual = Path::new("foo")
.concat(Path::new("/etc/passwd"))
.expect("Could not concat RootDir to path?");
let expected: PathBuf = PathBuf::from("foo/etc/passwd");
assert_eq!(actual, expected);
} | rust_cleaned_test_functions.jsonl/14051 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 807
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2638,
3721,
57478,
368,
341,
310,
1077,
5042,
284,
7933,
486,
931,
445,
7975,
1138,
394,
659,
20164,
33030,
486,
931,
445,
2257,
5455,
394,
659,
17119,
445,
12895,
537,
33720,
12716,
46091,
310,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_movsd() {
assert_emit!(0xf2, 0x0f, 0x10, 0xc1; movsd(XMM0, XMM1));
assert_emit!(0xf2, 0x41, 0x0f, 0x10, 0xdf; movsd(XMM3, XMM15));
assert_emit!(0xf2, 0x44, 0x0f, 0x10, 0xc4; movsd(XMM8, XMM4));
} | rust_cleaned_test_functions.jsonl/85495 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 158
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
55798,
13446,
368,
341,
286,
2060,
69082,
10297,
15,
5848,
17,
11,
220,
15,
87,
15,
69,
11,
220,
15,
87,
16,
15,
11,
220,
15,
8148,
16,
26,
1974,
13446,
7644,
8035,
15,
11,
1599,
8035,
16,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_conditional_selection() {
let a = Fp([1, 2, 3, 4, 5, 6]);
let b = Fp([7, 8, 9, 10, 11, 12]);
assert_eq!(
ConditionallySelectable::conditional_select(&a, &b, Choice::from(0u8)),
a
);
assert_eq!(
ConditionallySelectable::conditional_select(&a, &b, Choice::from(1u8)),
b
);
} | rust_cleaned_test_functions.jsonl/23226 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 174
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
24433,
3005,
23672,
368,
341,
262,
1077,
264,
284,
434,
79,
2561,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11,
220,
21,
2558,
262,
1077,
293,
284,
434,
79,
2561,
22,
11,
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_segment_tree() {
let mut tree = SegmentMap::default();
assert!(tree.add((1, 4)));
assert!(tree.add((4, 8)));
assert!(tree.add((42, 46)));
assert!(!tree.add((3, 8)));
assert!(tree.insert((47, 88), "hello".to_owned()));
assert_eq!(
tree.get_value_by_point(&49).map(String::as_str),
Some("hello")
);
assert_eq!(tree.get_interval_by_point(&3), Some((&1, &4)));
assert_eq!(tree.get_interval_by_point(&7), Some((&4, &8)));
assert_eq!(tree.get_interval_by_point(&90), None);
assert!(tree.is_overlapping((&1, &3)));
assert!(tree.is_overlapping((&7, &9)));
assert!(!tree.is_overlapping((&8, &42)));
assert!(!tree.is_overlapping((&9, &10)));
assert!(tree.is_overlapping((&2, &10)));
assert!(tree.is_overlapping((&0, &9999999)));
} | rust_cleaned_test_functions.jsonl/33981 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 478
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28061,
11663,
368,
341,
286,
1077,
5206,
4916,
284,
37103,
2227,
486,
2258,
543,
286,
2060,
10297,
9344,
1364,
1188,
16,
11,
220,
19,
4945,
286,
2060,
10297,
9344,
1364,
1188,
19,
11,
220,
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_bank_process_and_record_transactions_account_in_use() {
solana_logger::setup();
let GenesisConfigInfo {
genesis_config,
mint_keypair,
..
} = create_slow_genesis_config(10_000);
let bank = Arc::new(Bank::new_no_wallclock_throttle_for_tests(&genesis_config));
let pubkey = solana_sdk::pubkey::new_rand();
let pubkey1 = solana_sdk::pubkey::new_rand();
let transactions = sanitize_transactions(vec![
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_config.hash()),
system_transaction::transfer(&mint_keypair, &pubkey1, 1, genesis_config.hash()),
]);
let ledger_path = get_tmp_ledger_path_auto_delete!();
{
let blockstore = Blockstore::open(ledger_path.path())
.expect("Expected to be able to open database ledger");
let (poh_recorder, _entry_receiver, record_receiver) = PohRecorder::new(
bank.tick_height(),
bank.last_blockhash(),
bank.clone(),
Some((4, 4)),
bank.ticks_per_slot(),
&pubkey,
&Arc::new(blockstore),
&Arc::new(LeaderScheduleCache::new_from_bank(&bank)),
&Arc::new(PohConfig::default()),
Arc::new(AtomicBool::default()),
);
let recorder = poh_recorder.recorder();
let poh_recorder = Arc::new(Mutex::new(poh_recorder));
poh_recorder.lock().unwrap().set_bank(&bank);
let poh_simulator = simulate_poh(record_receiver, &poh_recorder);
let (gossip_vote_sender, _gossip_vote_receiver) = unbounded();
let process_transactions_batch_output = BankingStage::process_and_record_transactions(
&bank,
&transactions,
&recorder,
0,
None,
&gossip_vote_sender,
&QosService::new(Arc::new(RwLock::new(CostModel::default())), 1),
);
poh_recorder
.lock()
.unwrap()
.is_exited
.store(true, Ordering::Relaxed);
let _ = poh_simulator.join();
let ExecuteAndCommitTransactionsOutput {
transactions_attempted_execution_count,
executed_transactions_count,
retryable_transaction_indexes,
commit_transactions_result,
..
} = process_transactions_batch_output.execute_and_commit_transactions_output;
assert_eq!(transactions_attempted_execution_count, 2);
assert_eq!(executed_transactions_count, 1);
assert_eq!(retryable_transaction_indexes, vec![1],);
assert!(commit_transactions_result.is_ok());
}
Blockstore::destroy(ledger_path.path()).unwrap();
} | rust_cleaned_test_functions.jsonl/15489 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1536
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
35733,
11305,
8378,
14192,
68182,
13500,
1243,
15951,
368,
341,
286,
2048,
3362,
27413,
486,
15188,
543,
286,
1077,
40788,
2648,
1731,
341,
310,
59366,
5332,
345,
310,
28337,
3097,
12670,
345,
310,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_mono_to_stereo_handles_mono_input() {
let mut mono = MonoToStereoProcessor::new(1);
let mut samples = [1., 0.1, 1., 0.1, 1., 0.1, 1., 0.1, 1., 0.1, 1., 0.1];
let mut input = InterleavedAudioBuffer::new(2, &mut samples);
mono.process(&mut input);
for sample_index in 0..input.num_samples() {
for channel_index in 0..input.num_channels() {
let sample = *input.get(channel_index, sample_index);
assert_f_eq!(sample, 0.1);
}
}
} | rust_cleaned_test_functions.jsonl/11994 | {
"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,
60080,
2346,
1261,
64853,
68017,
60080,
5898,
368,
341,
286,
1077,
5206,
39674,
284,
12691,
1249,
80350,
24612,
22946,
486,
931,
7,
16,
317,
286,
1077,
5206,
10469,
284,
508,
16,
2572,
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... | 3 |
#[test]
fn test_read_endian_u32() {
let data = vec![0x01, 0x02, 0x03, 0x04];
let expected_be_u32 = 0x01020304;
let expected_le_u32 = 0x04030201;
let actual_le_u32 =
crate::gpio::read_endian_u32(&data, crate::gpio::Endianness::LittleEndian);
let actual_be_u32 = crate::gpio::read_endian_u32(&data, crate::gpio::Endianness::BigEndian);
assert!(actual_be_u32.is_some());
assert_eq!(expected_be_u32, actual_be_u32.unwrap());
assert!(actual_le_u32.is_some());
assert_eq!(expected_le_u32, actual_le_u32.unwrap());
} | rust_cleaned_test_functions.jsonl/97888 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 306
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
87193,
7300,
18,
17,
368,
341,
286,
1077,
821,
284,
7486,
20703,
15,
87,
15,
16,
11,
220,
15,
87,
15,
17,
11,
220,
15,
87,
15,
18,
11,
220,
15,
87,
15,
19,
4821,
286,
1077,
3601,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_crc_for_bigger_than_32_bytes() {
let (_, mut ucmd) = at_and_ucmd!();
let result = ucmd.arg("chars.txt").run();
let mut stdout_splitted = result.stdout.split(" ");
let cksum: i64 = stdout_splitted.next().unwrap().parse().unwrap();
let bytes_cnt: i64 = stdout_splitted.next().unwrap().parse().unwrap();
assert!(result.success);
assert_eq!(cksum, 586047089);
assert_eq!(bytes_cnt, 16);
} | rust_cleaned_test_functions.jsonl/69426 | {
"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,
59084,
5478,
880,
4500,
51613,
62,
18,
17,
12524,
368,
341,
262,
1077,
39464,
5206,
575,
8710,
8,
284,
518,
8378,
68887,
2277,
0,
1428,
262,
1077,
1102,
284,
575,
8710,
21186,
445,
19255,
3909,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_cast_utf8_to_i32() {
let a = StringArray::from(vec!["5", "6", "seven", "8", "9.1"]);
let array = Arc::new(a) as ArrayRef;
let b = cast(&array, &DataType::Int32).unwrap();
let c = b.as_any().downcast_ref::<Int32Array>().unwrap();
assert_eq!(5, c.value(0));
assert_eq!(6, c.value(1));
assert_eq!(false, c.is_valid(2));
assert_eq!(8, c.value(3));
assert_eq!(false, c.is_valid(2));
} | rust_cleaned_test_functions.jsonl/29606 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 252
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5303,
39453,
23,
2346,
5318,
18,
17,
368,
341,
286,
1077,
264,
284,
923,
1857,
486,
1499,
25592,
0,
1183,
20,
497,
330,
21,
497,
330,
80185,
497,
330,
23,
497,
330,
24,
13,
16,
15049,
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_object_async_result() {
use glib::subclass::prelude::*;
pub struct MySimpleObjectPrivate {
pub size: std::cell::RefCell<Option<i64>>,
}
#[glib::object_subclass]
impl ObjectSubclass for MySimpleObjectPrivate {
const NAME: &'static str = "MySimpleObjectPrivate";
type Type = MySimpleObject;
fn new() -> Self {
Self {
size: std::cell::RefCell::new(Some(100)),
}
}
}
impl ObjectImpl for MySimpleObjectPrivate {}
glib::wrapper! {
pub struct MySimpleObject(ObjectSubclass<MySimpleObjectPrivate>);
}
impl MySimpleObject {
pub fn new() -> Self {
glib::Object::new(&[]).expect("Failed to create MySimpleObject")
}
#[doc(alias = "get_size")]
pub fn size(&self) -> Option<i64> {
*self.imp().size.borrow()
}
pub fn set_size(&self, size: i64) {
self.imp().size.borrow_mut().replace(size);
}
}
impl Default for MySimpleObject {
fn default() -> Self {
Self::new()
}
}
match run_async_local(|tx, l| {
let cancellable = crate::Cancellable::new();
let task = unsafe {
crate::LocalTask::new(
None,
Some(&cancellable),
move |t: LocalTask<glib::Object>, _b: Option<&glib::Object>| {
tx.send(t.propagate()).unwrap();
l.quit();
},
)
};
let my_object = MySimpleObject::new();
my_object.set_size(100);
task.return_result(Ok(my_object.upcast::<glib::Object>()));
}) {
Err(_) => panic!(),
Ok(o) => {
let o = o.downcast::<MySimpleObject>().unwrap();
assert_eq!(o.size(), Some(100));
}
}
} | rust_cleaned_test_functions.jsonl/124324 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1190
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5314,
28346,
5287,
368,
341,
286,
990,
342,
2740,
486,
99117,
486,
1726,
52538,
56162,
286,
6675,
2036,
3017,
16374,
1190,
16787,
341,
310,
6675,
1379,
25,
1460,
486,
5873,
486,
3945,
3599,
94150,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_display() {
assert_eq!("42".to_string(), format!("{}", Value::UInt8(42)));
assert_eq!("42".to_string(), format!("{}", Value::UInt16(42)));
assert_eq!("42".to_string(), format!("{}", Value::UInt32(42)));
assert_eq!("42".to_string(), format!("{}", Value::UInt64(42)));
assert_eq!("42".to_string(), format!("{}", Value::Int8(42)));
assert_eq!("42".to_string(), format!("{}", Value::Int16(42)));
assert_eq!("42".to_string(), format!("{}", Value::Int32(42)));
assert_eq!("42".to_string(), format!("{}", Value::Int64(42)));
assert_eq!(
"text".to_string(),
format!("{}", Value::String(Arc::new(b"text".to_vec())))
);
assert_eq!(
"\u{1}\u{2}\u{3}".to_string(),
format!("{}", Value::String(Arc::new(vec![1, 2, 3])))
);
assert_eq!(
"NULL".to_string(),
format!("{}", Value::Nullable(Either::Left(SqlType::UInt8.into())))
);
assert_eq!(
"42".to_string(),
format!(
"{}",
Value::Nullable(Either::Right(Box::new(Value::UInt8(42))))
)
);
assert_eq!(
"[1, 2, 3]".to_string(),
format!(
"{}",
Value::Array(
SqlType::Int32.into(),
Arc::new(vec![Value::Int32(1), Value::Int32(2), Value::Int32(3)])
)
)
);
} | rust_cleaned_test_functions.jsonl/114573 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 866
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14825,
368,
341,
286,
2060,
10714,
17223,
19,
17,
3263,
983,
3904,
1507,
3561,
79878,
5162,
486,
18777,
23,
7,
19,
17,
4945,
286,
2060,
10714,
17223,
19,
17,
3263,
983,
3904,
1507,
3561,
79878,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_bootstrap_empty_storage_with_second_block_with_first_predecessor_should_fail_unknown_predecessor_context(
) {
init_test_runtime();
// init empty context for test
let (chain_id, ..) = init_test_protocol_context("bootstrap_test_storage_02");
// apply second block - level 2
let apply_block_result = client::apply_block(ApplyBlockRequest {
chain_id,
block_header: BlockHeader::from_bytes(
hex::decode(test_data::BLOCK_HEADER_LEVEL_2).unwrap(),
)
.unwrap(),
pred_header: BlockHeader::from_bytes(hex::decode(test_data::BLOCK_HEADER_LEVEL_1).unwrap())
.unwrap(),
operations: ApplyBlockRequest::convert_operations(test_data::block_operations_from_hex(
test_data::BLOCK_HEADER_HASH_LEVEL_2,
test_data::block_header_level2_operations(),
)),
max_operations_ttl: 0,
predecessor_block_metadata_hash: None,
predecessor_ops_metadata_hash: None,
});
assert!(apply_block_result.is_err());
assert!(match apply_block_result.unwrap_err() {
ApplyBlockError::UnknownPredecessorContext { .. } => true,
e => {
println!("expected UnknownPredecessorContext, but was {:?}", e);
false
}
});
} | rust_cleaned_test_functions.jsonl/21212 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 566
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
88424,
15124,
23310,
6615,
29644,
7113,
6615,
12978,
10442,
26911,
269,
43378,
22121,
57507,
10442,
26911,
269,
8467,
1006,
8,
341,
262,
2930,
4452,
33232,
1428,
262,
442,
2930,
4287,
2266,
369,
127... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_get_values_by_key_prefix() {
let tmp_dir = TempPath::new();
let db = AptosDB::new_for_test(&tmp_dir);
let store = &db.state_store;
let address = AccountAddress::new([12u8; AccountAddress::LENGTH]);
let key1 = StateKey::AccessPath(AccessPath::new(address, b"state_key1".to_vec()));
let key2 = StateKey::AccessPath(AccessPath::new(address, b"state_key2".to_vec()));
let value1_v0 = StateValue::from(String::from("value1_v0").into_bytes());
let value2_v0 = StateValue::from(String::from("value2_v0").into_bytes());
let account_key_prefx = StateKeyPrefix::new(StateKeyTag::AccessPath, address.to_vec());
put_value_set(
store,
vec![
(key1.clone(), value1_v0.clone()),
(key2.clone(), value2_v0.clone()),
],
0,
);
let key_value_map = store
.get_values_by_key_prefix(&account_key_prefx, 0)
.unwrap();
assert_eq!(key_value_map.len(), 2);
assert_eq!(*key_value_map.get(&key1).unwrap(), value1_v0);
assert_eq!(*key_value_map.get(&key2).unwrap(), value2_v0);
let key4 = StateKey::AccessPath(AccessPath::new(address, b"state_key4".to_vec()));
let value2_v1 = StateValue::from(String::from("value2_v1").into_bytes());
let value4_v1 = StateValue::from(String::from("value4_v1").into_bytes());
put_value_set(
store,
vec![
(key2.clone(), value2_v1.clone()),
(key4.clone(), value4_v1.clone()),
],
1,
);
// Ensure that we still get only values for key1 and key2 for version 0 after the update
let key_value_map = store
.get_values_by_key_prefix(&account_key_prefx, 0)
.unwrap();
assert_eq!(key_value_map.len(), 2);
assert_eq!(*key_value_map.get(&key1).unwrap(), value1_v0);
assert_eq!(*key_value_map.get(&key2).unwrap(), value2_v0);
// Ensure that key value map for version 1 returns value for key1 at version 0.
let key_value_map = store
.get_values_by_key_prefix(&account_key_prefx, 1)
.unwrap();
assert_eq!(key_value_map.len(), 3);
assert_eq!(*key_value_map.get(&key1).unwrap(), value1_v0);
assert_eq!(*key_value_map.get(&key2).unwrap(), value2_v1);
assert_eq!(*key_value_map.get(&key4).unwrap(), value4_v1);
// Add values for one more account and verify the state
let address1 = AccountAddress::new([22u8; AccountAddress::LENGTH]);
let key5 = StateKey::AccessPath(AccessPath::new(address1, b"state_key5".to_vec()));
let value5_v2 = StateValue::from(String::from("value5_v2").into_bytes());
let account1_key_prefx = StateKeyPrefix::new(StateKeyTag::AccessPath, address1.to_vec());
put_value_set(store, vec![(key5.clone(), value5_v2.clone())], 2);
// address1 did not exist in version 0 and 1.
let key_value_map = store
.get_values_by_key_prefix(&account1_key_prefx, 0)
.unwrap();
assert_eq!(key_value_map.len(), 0);
let key_value_map = store
.get_values_by_key_prefix(&account1_key_prefx, 1)
.unwrap();
assert_eq!(key_value_map.len(), 0);
let key_value_map = store
.get_values_by_key_prefix(&account1_key_prefx, 2)
.unwrap();
assert_eq!(key_value_map.len(), 1);
assert_eq!(*key_value_map.get(&key5).unwrap(), value5_v2);
} | rust_cleaned_test_functions.jsonl/60443 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1459
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
9146,
3710,
3097,
13974,
368,
341,
262,
1077,
4174,
4334,
284,
19944,
1820,
486,
931,
543,
262,
1077,
2927,
284,
96987,
436,
3506,
486,
931,
5478,
4452,
2099,
5173,
4334,
317,
262,
1077,
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_iv_constants() {
assert_eq!(0x61707865, LittleEndian::read_u32(&IV[0..][..4]));
assert_eq!(0x3320646e, LittleEndian::read_u32(&IV[4..][..4]));
assert_eq!(0x79622d32, LittleEndian::read_u32(&IV[8..][..4]));
assert_eq!(0x6b206574, LittleEndian::read_u32(&IV[12..][..4]));
} | rust_cleaned_test_functions.jsonl/49284 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 178
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
51411,
55642,
368,
341,
286,
2060,
10714,
10297,
15,
87,
21,
16,
22,
15,
22,
23,
21,
20,
11,
14671,
43231,
486,
878,
7300,
18,
17,
2099,
3090,
58,
15,
496,
1457,
496,
19,
14382,
286,
2060,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_decode_orr_reg_w() {
assert_eq!(
decode_32(0xea4404c8),
Instruction::ORR_reg {
params: Reg3ShiftParams {
rd: Reg::R4,
rn: Reg::R4,
rm: Reg::R8,
setflags: SetFlags::False,
shift_t: SRType::LSL,
shift_n: 3,
},
thumb32: true,
}
);
} | rust_cleaned_test_functions.jsonl/64813 | {
"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,
15227,
8734,
81,
4920,
1670,
368,
341,
1066,
262,
2060,
10714,
33673,
286,
16895,
62,
18,
17,
7,
15,
56570,
19,
19,
15,
19,
66,
23,
1326,
286,
29051,
486,
868,
49,
4920,
341,
310,
3628,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_is_valid_no_chips() {
let floors: Vec<BTreeSet<ScienceThing>> = vec![
[
gen("thulium"), gen("plutonium")
].iter().cloned().collect(),
];
assert_eq!(true, is_valid(&floors));
} | rust_cleaned_test_functions.jsonl/55907 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 94
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6892,
8337,
6536,
4138,
3077,
368,
341,
10217,
25945,
25,
11312,
32519,
6533,
1649,
27,
35400,
52940,
2452,
284,
7486,
90515,
197,
197,
9640,
298,
82281,
445,
339,
360,
2356,
3975,
4081,
445,
500,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_symlink_backup_numbering() {
let (at, mut ucmd) = at_and_ucmd!();
let file = "test_symlink_backup_numbering";
let link = "test_symlink_backup_numbering_link";
at.touch(file);
at.symlink_file(file, link);
assert!(at.file_exists(file));
assert!(at.is_symlink(link));
assert_eq!(at.resolve_link(link), file);
ucmd.args(&["-s", "--backup=t", file, link])
.succeeds()
.no_stderr();
assert!(at.file_exists(file));
assert!(at.is_symlink(link));
assert_eq!(at.resolve_link(link), file);
let backup = &format!("{}.~1~", link);
assert!(at.is_symlink(backup));
assert_eq!(at.resolve_link(backup), file);
} | rust_cleaned_test_functions.jsonl/4887 | {
"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,
58530,
44243,
44710,
5500,
287,
368,
341,
262,
1077,
320,
266,
11,
5206,
575,
8710,
8,
284,
518,
8378,
68887,
2277,
0,
543,
262,
1077,
1034,
284,
330,
1944,
58530,
44243,
44710,
5500,
287,
876,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_jump_if_backward() {
let mut masm = MacroAssembler::new();
let lbl = masm.create_label();
masm.bind_label(lbl);
masm.jump_if(CondCode::Less, lbl);
assert_emit!(0x5400000B; masm);
} | rust_cleaned_test_functions.jsonl/20609 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 130
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
65436,
11119,
70477,
368,
341,
286,
1077,
5206,
9243,
76,
284,
53317,
77858,
486,
931,
543,
286,
1077,
16421,
284,
9243,
76,
2520,
6106,
543,
286,
9243,
76,
6090,
6106,
70491,
317,
286,
9243,
76... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_cast_to_real() {
let test_cases = vec![
("{}", 0f64),
("[]", 0f64),
("3", 3f64),
("-3", -3f64),
("4.5", 4.5),
("true", 1f64),
("false", 0f64),
("null", 0f64),
(r#""hello""#, 0f64),
(r#""1234""#, 1234f64),
];
let mut ctx = EvalContext::new(Arc::new(EvalConfig::default_for_test()));
for (jstr, exp) in test_cases {
let json: Json = jstr.parse().unwrap();
let get = json.cast_to_real(&mut ctx).unwrap();
assert!(
(get - exp).abs() < f64::EPSILON,
"json.as_f64 get: {}, exp: {}",
get,
exp
);
}
} | rust_cleaned_test_functions.jsonl/47554 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 502
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5303,
2346,
15266,
368,
341,
286,
1077,
1273,
41427,
284,
7486,
90515,
310,
3489,
42351,
220,
15,
69,
21,
19,
1326,
310,
3489,
1294,
497,
220,
15,
69,
21,
19,
1326,
310,
3489,
18,
497,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_fmt() {
test! {
let fmt = AST::StringLiteral(StringLiteral::new_wrapped("{x} {y}".to_string(), false));
let sym_a = AST::SimpleIdentifier(SimpleIdentifier::new_wrapped("a".to_string()));
let sym_b = AST::SimpleIdentifier(SimpleIdentifier::new_wrapped("b".to_string()));
let mut map = linked_hash_map::LinkedHashMap::new();
map.insert("x".to_string(), sym_a);
map.insert("y".to_string(), sym_b);
let dict = AST::Formatted(crate::python::Formatted::new_wrapped(fmt, map));
let r_node = dict.to_r_ast_node(0);
assert_eq!(r_node, eval_string("call('call', name='glue', fmt='{x} {y}', x=rlang::sym('a'), y=rlang::sym('b'))").unwrap());
}
} | rust_cleaned_test_functions.jsonl/75449 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 380
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
38128,
368,
341,
286,
1273,
0,
341,
310,
1077,
8879,
284,
22465,
486,
703,
17350,
2242,
17350,
486,
931,
44074,
5677,
13976,
87,
92,
314,
88,
21901,
983,
3904,
1507,
895,
1106,
310,
1077,
7886,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_fold_import_and_groups() {
let text = r#"
<fold>use std::str;
use std::vec;
use std::io as iop;</fold>
<fold>use std::mem;
use std::f64;</fold>
<fold>use std::collections::<fold>{
HashMap,
VecDeque,
}</fold>;</fold>
// Some random comment
fn main() <fold>{
}</fold>"#;
let folds = &[
FoldKind::Imports,
FoldKind::Imports,
FoldKind::Imports,
FoldKind::Block,
FoldKind::Block,
];
do_check(text, folds);
} | rust_cleaned_test_functions.jsonl/12686 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 275
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
61187,
18434,
8378,
21148,
368,
341,
286,
1077,
1467,
284,
435,
2,
698,
27,
19961,
29,
810,
1460,
486,
495,
280,
810,
1460,
486,
4083,
280,
810,
1460,
486,
815,
438,
600,
453,
11347,
19961,
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_blank_hash() {
let mut cs = TestConstraintSystem::<Bls12>::new();
let input_bits = vec![];
let out = blake2s(&mut cs, &input_bits, b"12345678").unwrap();
assert!(cs.is_satisfied());
assert_eq!(cs.num_constraints(), 0);
// >>> import blake2s from hashlib
let expected = hex!("c59f682376d137f3f255e671e207d1f2374ebe504e9314208a52d9f88d69e8c8");
let mut out = out.into_iter();
for b in expected.iter() {
for i in 0..8 {
let c = out.next().unwrap().get_value().unwrap();
assert_eq!(c, (b >> i) & 1u8 == 1u8);
}
}
} | rust_cleaned_test_functions.jsonl/11166 | {
"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,
56103,
8950,
368,
341,
286,
1077,
5206,
10532,
284,
3393,
17890,
2320,
27638,
33,
4730,
16,
17,
6831,
931,
543,
286,
1077,
1946,
20034,
284,
7486,
0,
15078,
286,
1077,
700,
284,
1501,
726,
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_profile() -> Result<()> {
lazy_static! {
static ref PROFILED: Mutex<Vec<(String, Duration)>> = Mutex::new(Vec::new());
}
fn profiler(s: &str, d: Duration) {
let mut profiled = PROFILED.lock().unwrap();
profiled.push((s.to_owned(), d));
}
let mut db = Connection::open_in_memory()?;
db.profile(Some(profiler));
db.execute_batch("PRAGMA application_id = 1")?;
db.profile(None);
db.execute_batch("PRAGMA application_id = 2")?;
let profiled = PROFILED.lock().unwrap();
assert_eq!(profiled.len(), 1);
assert_eq!(profiled[0].0, "PRAGMA application_id = 1");
Ok(())
} | rust_cleaned_test_functions.jsonl/69783 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 360
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13789,
368,
1464,
5714,
71698,
341,
286,
15678,
25360,
0,
341,
310,
1099,
2053,
70950,
35,
25,
66215,
50439,
28706,
703,
11,
21045,
54229,
284,
66215,
486,
931,
49923,
486,
931,
1423,
286,
456,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_verify_tampered_sig_len() {
let mut tx = test_tx();
tx.signatures.pop();
let packet = sigverify::make_packet_from_transaction(tx);
let mut batches = generate_packet_batches(&packet, 1, 1);
// verify packets
ed25519_verify(&mut batches);
assert!(batches
.iter()
.flat_map(|batch| &batch.packets)
.all(|p| p.meta.discard()));
} | rust_cleaned_test_functions.jsonl/22084 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 235
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
35638,
528,
309,
42768,
29252,
6043,
368,
341,
286,
1077,
5206,
9854,
284,
1273,
17805,
543,
1789,
286,
9854,
15499,
2789,
8288,
543,
286,
1077,
10151,
284,
8366,
12446,
486,
6927,
21078,
5673,
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_nearby_entities() {
let (mut w, mut d) = t::init_world();
t::populate_with_air(&mut w); // Prevents entities from getting despawned for being outside loaded chunks
let e1 = test::create(&mut w, position!(0.0, 0.0, 0.0)).build();
let e2 = test::create(&mut w, position!(-100.0, 0.0, 50.0)).build();
let e3 = test::create(&mut w, position!(100.0, 50.0, 50.0)).build();
let e4 = test::create(&mut w, position!(100.0, 1.0, -50.0)).build();
d.dispatch(&w);
w.maintain();
let entities = nearby_entities(
&w.fetch(),
&w.read_component(),
position!(0.0, 0.0, 0.0),
vec3(100.0, 1.0, 50.0),
)
.into_iter()
.collect::<HashSet<_>>();
assert_eq!(entities.len(), 3);
assert!(entities.contains(&e1));
assert!(entities.contains(&e2));
assert!(!entities.contains(&e3));
assert!(entities.contains(&e4));
} | rust_cleaned_test_functions.jsonl/130413 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 504
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
76340,
1694,
47377,
368,
341,
286,
1077,
320,
6984,
289,
11,
5206,
294,
8,
284,
259,
486,
2327,
31792,
1428,
286,
259,
486,
47721,
6615,
50827,
2099,
6984,
289,
1215,
442,
38068,
82,
14744,
504,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_restore() {
let l = default_logger();
// magic number
let s = new_snapshot(11, 11, vec![1, 2, 3]);
let mut sm = new_test_raft(1, vec![1, 2], 10, 1, new_storage(), &l);
assert!(sm.restore(s.clone()));
assert_eq!(sm.raft_log.last_index(), s.get_metadata().index);
assert_eq!(
sm.raft_log.term(s.get_metadata().index).unwrap(),
s.get_metadata().term
);
assert_eq!(
sm.prs().voter_ids(),
s.get_metadata()
.get_conf_state()
.voters
.iter()
.cloned()
.collect::<HashSet<_>>(),
);
assert!(!sm.restore(s));
} | rust_cleaned_test_functions.jsonl/30298 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 346
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62677,
368,
341,
262,
1077,
326,
284,
1638,
27413,
543,
262,
442,
10963,
1372,
198,
262,
1077,
274,
284,
501,
53265,
7,
16,
16,
11,
220,
16,
16,
11,
7486,
20703,
16,
11,
220,
17,
11,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_lehmer_double() {
assert_eq!(lehmer_double(U256::ZERO, U256::ZERO), Matrix::IDENTITY);
assert_eq!(
// Aggegrates the first 34 quotients
lehmer_double(
u256h!("518a5cc4c55ac5b050a0831b65e827e5e39fd4515e4e094961c61509e7870814"),
u256h!("018a5cc4c55ac5b050a0831b65e827e5e39fd4515e4e094961c61509e7870814")
),
Matrix(
2927556694930003,
154961230633081597,
3017020641586254,
159696730135159213,
true
)
);
} | rust_cleaned_test_functions.jsonl/13591 | {
"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,
11751,
71,
1174,
24598,
368,
341,
286,
2060,
10714,
10297,
73790,
1174,
24598,
12317,
17,
20,
21,
486,
73956,
11,
547,
17,
20,
21,
486,
73956,
701,
11631,
486,
19811,
3333,
317,
286,
2060,
10714... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_long() {
assert_eq!(
Variant::VSingle(5.1).minus(Variant::VLong(2)).unwrap(),
Variant::VSingle(3.1)
);
} | rust_cleaned_test_functions.jsonl/84557 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 139
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17799,
368,
341,
394,
2060,
10714,
33673,
503,
39292,
486,
53,
10888,
7,
20,
13,
16,
568,
38365,
12410,
15341,
486,
53,
6583,
7,
17,
4579,
15454,
3148,
503,
39292,
486,
53,
10888,
7,
18,
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 |
#[test]
fn test_validate_max_gas_units_above_max() {
let (config, keypair) = get_test_config();
let vm_validator = TestValidator::new(&config);
let address = account_config::association_address();
let txn = transaction_test_helpers::get_test_signed_transaction(
address,
0,
keypair.private_key().clone(),
keypair.public_key(),
None,
0,
0, /* max gas price */
Some(u64::MAX), // Max gas units
);
let ret = vm_validator
.validate_transaction(SignedTransaction::from_proto(txn).unwrap())
.wait()
.unwrap();
assert_matches!(
ret,
Some(VMStatus::Validation(VMValidationStatus::MaxGasUnitsExceedsMaxGasUnitsBound(_)))
);
} | rust_cleaned_test_functions.jsonl/90960 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 354
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
42681,
6345,
82116,
28345,
77315,
6345,
368,
341,
262,
1077,
320,
1676,
11,
1376,
12670,
8,
284,
633,
4452,
5332,
543,
262,
1077,
10995,
64959,
284,
3393,
14256,
486,
931,
2099,
1676,
626,
262,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_reader_unlock() {
let lock = RwLock::<usize>::default();
{
let mut _guard = lock.read(0);
assert_eq!(lock.rlock[0].load(Ordering::Relaxed), 1);
}
assert_eq!(lock.rlock[0].load(Ordering::Relaxed), 0);
} | rust_cleaned_test_functions.jsonl/77525 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 153
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
22306,
19465,
368,
341,
286,
1077,
5296,
284,
55294,
11989,
27638,
51878,
6831,
2258,
1428,
286,
341,
310,
1077,
5206,
716,
26098,
284,
5296,
4125,
7,
15,
317,
310,
2060,
10714,
10297,
1023,
1746,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_utf16_latin1_success() {
let mut src: Vec<u16> = Vec::with_capacity(256);
src.resize(256, 0);
for i in 0..src.len() {
src[i] = i as u16;
}
for i in 0..src.len() {
assert!(is_utf16_latin1(&src[i..]));
assert_eq!(
check_utf16_for_latin1_and_bidi(&src[i..]),
Latin1Bidi::Latin1
);
}
} | rust_cleaned_test_functions.jsonl/27300 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 270
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6892,
39453,
16,
21,
907,
14768,
16,
18632,
368,
341,
286,
1077,
5206,
2286,
25,
11312,
34837,
16,
21,
29,
284,
11312,
486,
4197,
35603,
7,
17,
20,
21,
317,
286,
2286,
17382,
7,
17,
20,
21,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_packages() -> Result<(), Box<EvalAltResult>> {
let engine = Engine::new();
let ast = engine.compile("x")?;
let std_pkg = StandardPackage::new();
let make_call = |x: INT| -> Result<INT, Box<EvalAltResult>> {
// Create a raw Engine - extremely cheap.
let mut engine = Engine::new_raw();
// Register packages - cheap.
engine.register_global_module(std_pkg.as_shared_module());
// Create custom scope - cheap.
let mut scope = Scope::new();
// Push variable into scope - relatively cheap.
scope.push("x", x);
// Evaluate script.
engine.eval_ast_with_scope::<INT>(&mut scope, &ast)
};
assert_eq!(make_call(42)?, 42);
Ok(())
} | rust_cleaned_test_functions.jsonl/19793 | {
"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,
41874,
368,
1464,
5714,
68843,
8261,
23835,
831,
26017,
2077,
2452,
341,
262,
1077,
4712,
284,
8200,
486,
931,
543,
262,
1077,
11763,
284,
4712,
18922,
445,
87,
899,
37445,
262,
1077,
1460,
64739,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_flip_cond() {
let info = EmitInfo::new(settings::Flags::new(settings::builder()));
let mut buf = MachBuffer::new();
let mut state = Default::default();
buf.reserve_labels_for_blocks(4);
buf.bind_label(label(0));
let inst = Inst::CondBr {
kind: CondBrKind::NotZero(xreg(0)),
taken: target(1),
not_taken: target(2),
};
inst.emit(&mut buf, &info, &mut state);
buf.bind_label(label(1));
let inst = Inst::Udf {
trap_code: TrapCode::Interrupt,
};
inst.emit(&mut buf, &info, &mut state);
buf.bind_label(label(2));
let inst = Inst::Nop4;
inst.emit(&mut buf, &info, &mut state);
buf.bind_label(label(3));
let buf = buf.finish();
let mut buf2 = MachBuffer::new();
let mut state = Default::default();
let inst = Inst::TrapIf {
kind: CondBrKind::NotZero(xreg(0)),
trap_code: TrapCode::Interrupt,
};
inst.emit(&mut buf2, &info, &mut state);
let inst = Inst::Nop4;
inst.emit(&mut buf2, &info, &mut state);
let buf2 = buf2.finish();
assert_eq!(buf.data, buf2.data);
} | rust_cleaned_test_functions.jsonl/17887 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 632
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
56012,
24433,
368,
341,
286,
1077,
3546,
284,
61537,
1731,
486,
931,
23369,
486,
9195,
486,
931,
23369,
486,
17850,
7392,
286,
1077,
5206,
6607,
284,
18294,
4095,
486,
931,
543,
286,
1077,
5206,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parse_timestamptz() {
#[rustfmt::skip]
let test_cases = [("1999-01-01 01:23:34.555", 1999, 1, 1, 1, 23, 34, 555_000_000, 0),
("1999-01-01 01:23:34.555+0:00", 1999, 1, 1, 1, 23, 34, 555_000_000, 0),
("1999-01-01 01:23:34.555+0", 1999, 1, 1, 1, 23, 34, 555_000_000, 0),
("1999-01-01 01:23:34.555z", 1999, 1, 1, 1, 23, 34, 555_000_000, 0),
("1999-01-01 01:23:34.555Z", 1999, 1, 1, 1, 23, 34, 555_000_000, 0),
("1999-01-01 01:23:34.555 z", 1999, 1, 1, 1, 23, 34, 555_000_000, 0),
("1999-01-01 01:23:34.555 Z", 1999, 1, 1, 1, 23, 34, 555_000_000, 0),
("1999-01-01 01:23:34.555+4:00", 1999, 1, 1, 1, 23, 34, 555_000_000, 14400),
("1999-01-01 01:23:34.555-4:00", 1999, 1, 1, 1, 23, 34, 555_000_000, -14400),
("1999-01-01 01:23:34.555+400", 1999, 1, 1, 1, 23, 34, 555_000_000, 14400),
("1999-01-01 01:23:34.555+4", 1999, 1, 1, 1, 23, 34, 555_000_000, 14400),
("1999-01-01 01:23:34.555+4:30", 1999, 1, 1, 1, 23, 34, 555_000_000, 16200),
("1999-01-01 01:23:34.555+430", 1999, 1, 1, 1, 23, 34, 555_000_000, 16200),
("1999-01-01 01:23:34.555+4:45", 1999, 1, 1, 1, 23, 34, 555_000_000, 17100),
("1999-01-01 01:23:34.555+445", 1999, 1, 1, 1, 23, 34, 555_000_000, 17100),
("1999-01-01 01:23:34.555+14:45", 1999, 1, 1, 1, 23, 34, 555_000_000, 53100),
("1999-01-01 01:23:34.555-14:45", 1999, 1, 1, 1, 23, 34, 555_000_000, -53100),
("1999-01-01 01:23:34.555+1445", 1999, 1, 1, 1, 23, 34, 555_000_000, 53100),
("1999-01-01 01:23:34.555-1445", 1999, 1, 1, 1, 23, 34, 555_000_000, -53100),
("1999-01-01 01:23:34.555 +14:45", 1999, 1, 1, 1, 23, 34, 555_000_000, 53100),
("1999-01-01 01:23:34.555 -14:45", 1999, 1, 1, 1, 23, 34, 555_000_000, -53100),
("1999-01-01 01:23:34.555 +1445", 1999, 1, 1, 1, 23, 34, 555_000_000, 53100),
("1999-01-01 01:23:34.555 -1445", 1999, 1, 1, 1, 23, 34, 555_000_000, -53100),
];
for test in test_cases.iter() {
let actual = strconv::parse_timestamptz(test.0).unwrap();
let expected = NaiveDate::from_ymd(test.1, test.2, test.3)
.and_hms_nano(test.4, test.5, test.6, test.7);
let offset = FixedOffset::east(test.8);
let dt_fixed_offset = offset.from_local_datetime(&expected).earliest().unwrap();
let expected = DateTime::<Utc>::from_utc(dt_fixed_offset.naive_utc(), Utc);
assert_eq!(actual, expected);
}
} | rust_cleaned_test_functions.jsonl/55840 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1319
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
528,
4255,
309,
417,
89,
368,
341,
262,
11506,
35788,
12501,
486,
20599,
921,
262,
1077,
1273,
41427,
284,
84019,
16,
24,
24,
24,
12,
15,
16,
12,
15,
16,
220,
15,
16,
25,
17,
18,
25... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_list_services() {
let mut io_loop = Runtime::new().unwrap();
let (resolver, bg) = AsyncResolver::new(
ResolverConfig::default(),
ResolverOpts {
ip_strategy: LookupIpStrategy::Ipv6thenIpv4,
..ResolverOpts::default()
},
);
io_loop.spawn(bg);
let response = io_loop
.block_on(resolver.list_services("_http._tcp.local."))
.expect("failed to run lookup");
for name in response.iter() {
println!("service: {}", name);
let srvs = io_loop
.block_on(resolver.lookup_srv(name))
.expect("failed to lookup name");
for srv in srvs.iter() {
println!("service: {:#?}", srv);
let info = io_loop
.block_on(resolver.service_info(name))
.expect("info failed");
let info = info.to_map();
println!("info: {:#?}", info);
}
for ip in srvs.ip_iter() {
println!("ip: {}", ip);
}
}
} | rust_cleaned_test_functions.jsonl/99470 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 655
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2019,
39846,
368,
341,
286,
1077,
5206,
6399,
17198,
284,
10954,
486,
931,
1005,
15454,
543,
286,
1077,
320,
48943,
11,
8951,
8,
284,
21433,
18190,
486,
931,
1006,
310,
81854,
2648,
486,
2258,
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... | 4 |
#[test]
fn test_proposal_generation_parent() {
let block_store = build_empty_tree();
let mut inserter = TreeInserter::new(block_store.clone());
let proposal_generator = ProposalGenerator::new(
block_store.clone(),
Arc::new(MockTransactionManager::new()),
Arc::new(SimulatedTimeService::new()),
1,
true,
);
let genesis = block_store.root();
let a1 = inserter.insert_block(genesis.as_ref(), 1);
let b1 = inserter.insert_block(genesis.as_ref(), 2);
// With no certifications the parent is genesis
// generate proposals for an empty tree.
assert_eq!(
block_on(proposal_generator.generate_proposal(10, minute_from_now()))
.unwrap()
.parent_id(),
genesis.id()
);
let vote_msg_a1 = VoteMsg::new(
VoteData::new(
a1.id(),
block_store
.get_compute_result(a1.id())
.unwrap()
.executed_state
.state_id,
a1.round(),
a1.quorum_cert().parent_block_id(),
a1.quorum_cert().parent_block_round(),
a1.quorum_cert().grandparent_block_id(),
a1.quorum_cert().grandparent_block_round(),
),
block_store.signer().author(),
placeholder_ledger_info(),
block_store.signer(),
);
block_store.insert_vote_and_qc(vote_msg_a1, 1);
let a1_child_res =
block_on(proposal_generator.generate_proposal(11, minute_from_now())).unwrap();
assert_eq!(a1_child_res.parent_id(), a1.id());
assert_eq!(a1_child_res.round(), 11);
assert_eq!(a1_child_res.height(), 2);
assert_eq!(a1_child_res.quorum_cert().certified_block_id(), a1.id());
let vote_msg_b1 = VoteMsg::new(
VoteData::new(
b1.id(),
block_store
.get_compute_result(b1.id())
.unwrap()
.executed_state
.state_id,
b1.round(),
b1.quorum_cert().parent_block_id(),
b1.quorum_cert().parent_block_round(),
b1.quorum_cert().grandparent_block_id(),
b1.quorum_cert().grandparent_block_round(),
),
block_store.signer().author(),
placeholder_ledger_info(),
block_store.signer(),
);
block_store.insert_vote_and_qc(vote_msg_b1, 1);
let b1_child_res =
block_on(proposal_generator.generate_proposal(12, minute_from_now())).unwrap();
assert_eq!(b1_child_res.parent_id(), b1.id());
assert_eq!(b1_child_res.round(), 12);
assert_eq!(b1_child_res.height(), 2);
assert_eq!(b1_child_res.quorum_cert().certified_block_id(), b1.id());
} | rust_cleaned_test_functions.jsonl/95673 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1366
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21663,
32556,
64191,
15960,
368,
341,
262,
1077,
2504,
14809,
284,
1936,
15124,
11663,
543,
262,
1077,
5206,
47325,
465,
284,
8942,
641,
90727,
486,
931,
18682,
14809,
15997,
1423,
262,
1077,
13734,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_preorder_traversal() {
let text = r"
fn main() {
let foo = 1;
let bar = if foo > 2 {
true
} else {
false
};
}";
let mut parser = tree_sitter::Parser::new();
parser.set_language(tree_sitter_rust::language()).unwrap();
let tree = parser.parse(&text, None).unwrap();
let tree_iter = TreeIterator::new(&tree);
let nodes = tree_iter.map(|node| node).collect::<Vec<_>>();
let bytes = text.as_bytes();
println!("{:?}", nodes[1].utf8_text(bytes).unwrap());
// let kinds = vec![
} | rust_cleaned_test_functions.jsonl/112022 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 661
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10442,
1358,
3547,
45545,
368,
341,
286,
1077,
1467,
284,
435,
698,
8822,
1887,
368,
341,
262,
1077,
15229,
284,
220,
16,
280,
262,
1077,
3619,
284,
421,
15229,
861,
220,
17,
341,
286,
830,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_get_rsna_psk() {
let bss = fake_protected_bss_description(b"foo_bss".to_vec());
let credential = fidl_sme::Credential::Psk(vec![0xAA; 32]);
get_rsna(&fake_device_info(CLIENT_ADDR), &credential, &bss)
.expect("expected successful RSNA with valid PSK");
} | rust_cleaned_test_functions.jsonl/113761 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 152
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
47115,
3376,
620,
4886,
368,
341,
286,
1077,
293,
778,
284,
12418,
22357,
1569,
880,
778,
11448,
1883,
1,
7975,
880,
778,
3263,
983,
13251,
1423,
286,
1077,
40207,
284,
32104,
75,
643,
266... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_workload_from_str() {
assert_eq!(Workload::from_str("I"), Ok(Workload::Initialize));
assert_eq!(
Workload::from_str("RU"),
Ok(Workload::ReadUpdate {
read_pct: Percent::new(100),
})
);
assert_eq!(
Workload::from_str("RU,50"),
Ok(Workload::ReadUpdate {
read_pct: Percent::new(50),
})
);
} | rust_cleaned_test_functions.jsonl/7513 | {
"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,
11498,
1078,
5673,
2895,
368,
341,
286,
2060,
10714,
10297,
6776,
1078,
486,
1499,
2895,
445,
40,
3975,
7622,
7,
6776,
1078,
486,
9928,
1106,
286,
2060,
10714,
33673,
310,
5547,
1078,
486,
1499,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_trace() {
lazy_static! {
static ref TRACED_STMTS: Mutex<Vec<String>> = Mutex::new(Vec::new());
}
fn tracer(s: &str) {
let mut traced_stmts = TRACED_STMTS.lock().unwrap();
traced_stmts.push(s.to_owned());
}
let mut db = Connection::open_in_memory().unwrap();
db.trace(Some(tracer));
{
let _ = db.query_row("SELECT ?", &[&1i32], |_| Ok(()));
let _ = db.query_row("SELECT ?", &[&"hello"], |_| Ok(()));
}
db.trace(None);
{
let _ = db.query_row("SELECT ?", &[&2i32], |_| Ok(()));
let _ = db.query_row("SELECT ?", &[&"goodbye"], |_| Ok(()));
}
let traced_stmts = TRACED_STMTS.lock().unwrap();
assert_eq!(traced_stmts.len(), 2);
assert_eq!(traced_stmts[0], "SELECT 1");
assert_eq!(traced_stmts[1], "SELECT 'hello'");
} | rust_cleaned_test_functions.jsonl/32210 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 518
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
23575,
368,
341,
286,
15678,
25360,
0,
341,
310,
1099,
2053,
4984,
1706,
1479,
97963,
50,
25,
66215,
50439,
3464,
2452,
284,
66215,
486,
931,
49923,
486,
931,
1423,
286,
456,
286,
5168,
64306,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_decoder_complex() {
let _m = mock("GET", "/schemas/ids/6?deleted=true")
.with_status(200)
.with_header("content-type", "application/vnd.schemaregistry.v1+json")
.with_body(&get_proto_body_with_reference(
get_proto_complex(),
2,
get_proto_complex_references(),
))
.create();
let _m = mock("GET", "/subjects/result.proto/versions/1")
.with_status(200)
.with_header("content-type", "application/vnd.schemaregistry.v1+json")
.with_body(&get_proto_body(get_proto_result(), 1))
.create();
let sr_settings = SrSettings::new(format!("http://{}", server_address()));
let mut decoder = ProtoRawDecoder::new(sr_settings);
let proto_test = decoder.decode(Some(get_proto_complex_proto_test_message()));
let raw_result = match proto_test {
Ok(Some(x)) => x,
Err(e) => panic!("Error: {:?}, while none expected", e),
Ok(v) => panic!("Other value: {:?} than expected Message", v),
};
assert_eq!(raw_result.bytes, get_proto_complex_only_data())
} | rust_cleaned_test_functions.jsonl/100939 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 601
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
49843,
41522,
368,
341,
286,
1077,
716,
76,
284,
7860,
445,
3806,
497,
3521,
56543,
14,
3365,
14,
21,
30,
26521,
11265,
1138,
310,
659,
4197,
4773,
7,
17,
15,
15,
340,
310,
659,
4197,
8757,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_fpu() {
let KVM_FPU_CWD: usize = 0x37f;
let KVM_FPU_MXCSR: usize = 0x1f80;
let kvm = Kvm::new().unwrap();
let vm = kvm.create_vm().unwrap();
let vcpu = vm.create_vcpu(0).unwrap();
let mut fpu: kvm_fpu = kvm_fpu {
fcw: KVM_FPU_CWD as u16,
mxcsr: KVM_FPU_MXCSR as u32,
..Default::default()
};
fpu.fcw = KVM_FPU_CWD as u16;
fpu.mxcsr = KVM_FPU_MXCSR as u32;
vcpu.set_fpu(&fpu).unwrap();
assert_eq!(vcpu.get_fpu().unwrap().fcw, KVM_FPU_CWD as u16);
} | rust_cleaned_test_functions.jsonl/92514 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 375
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
761,
5584,
368,
341,
1789,
286,
1077,
730,
11187,
1400,
6325,
920,
17563,
25,
22301,
284,
220,
15,
87,
18,
22,
69,
280,
286,
1077,
730,
11187,
1400,
6325,
1245,
55,
70022,
25,
22301,
284,
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_parse_valid_elasticbeanstalk_delete_application() {
let mock_response = MockResponseReader::read_response(
"test_resources/generated/valid",
"elasticbeanstalk-delete-application.xml",
);
let mock = MockRequestDispatcher::with_status(200).with_body(&mock_response);
let client =
ElasticBeanstalkClient::new(mock, MockCredentialsProvider, rusoto_region::UsEast1);
let request = DeleteApplicationMessage::default();
let result = client.delete_application(request).sync();
assert!(result.is_ok(), "parse error: {:?}", result);
} | rust_cleaned_test_functions.jsonl/15238 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 258
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
8337,
21602,
5064,
17479,
89749,
11353,
38721,
368,
341,
286,
1077,
7860,
9655,
284,
14563,
2582,
5062,
486,
878,
9655,
1006,
310,
330,
1944,
35569,
79372,
14,
1891,
756,
310,
330,
61964,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_concatenated_frames() {
let mut buffer = Vec::new();
copy_encode(&b"foo"[..], &mut buffer, 1).unwrap();
copy_encode(&b"bar"[..], &mut buffer, 2).unwrap();
copy_encode(&b"baz"[..], &mut buffer, 3).unwrap();
assert_eq!(
&decode_all(&buffer[..]).unwrap(),
b"foobarbaz",
"Error decoding concatenated frames."
);
} | rust_cleaned_test_functions.jsonl/134365 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 175
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
57478,
268,
657,
29319,
368,
341,
262,
1077,
5206,
4147,
284,
11312,
486,
931,
543,
262,
2975,
11224,
2099,
65,
1,
7975,
36864,
496,
1125,
609,
6984,
4147,
11,
220,
16,
568,
15454,
543,
262,
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_vectors_aes_256_gcm() {
test_aead_all::<Aes256Gcm>(&include!("fixtures/aes_256_gcm.rs")).unwrap();
} | rust_cleaned_test_functions.jsonl/99030 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 74
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
49158,
90958,
62,
17,
20,
21,
1889,
6226,
368,
341,
286,
1273,
4306,
3149,
5705,
27638,
32,
288,
17,
20,
21,
38,
6226,
44784,
997,
17223,
45247,
14186,
288,
62,
17,
20,
21,
1889,
6226,
25638,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_internally_a_ser() {
let v = EnumStructInternally::VariantA {
foo: 1,
bar: 2,
different: 3,
};
let e = "(type:\"VariantA\",foo:1,bar:2,different:3,)";
test_ser(&v, e);
} | rust_cleaned_test_functions.jsonl/110469 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 122
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4042,
932,
745,
4306,
75861,
368,
341,
262,
1077,
348,
284,
14086,
9422,
67916,
745,
486,
20746,
32,
341,
286,
15229,
25,
220,
16,
345,
286,
3619,
25,
220,
17,
345,
286,
2155,
25,
220,
18,
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_simulate_set() {
let hands: Vec<Hand> = ["6d6h", "3d3h"]
.iter()
.map(|s| Hand::new_from_str(s).unwrap())
.collect();
let board: Vec<Card> = vec![
Card {
value: Value::Six,
suit: Suit::Spade,
},
Card {
value: Value::King,
suit: Suit::Diamond,
},
Card {
value: Value::Queen,
suit: Suit::Heart,
},
];
let mut g = MonteCarloGame::new_with_hands(hands, board).unwrap();
let result = g.simulate();
assert!(result.1 >= Rank::ThreeOfAKind(4));
} | rust_cleaned_test_functions.jsonl/18432 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 426
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18314,
6334,
2602,
368,
341,
286,
1077,
6078,
25,
11312,
27,
2314,
29,
284,
4383,
21,
67,
21,
71,
497,
330,
18,
67,
18,
71,
7026,
310,
659,
2015,
741,
310,
659,
2186,
22428,
82,
91,
8536,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_status_only_todo() {
let dir = tempdir().unwrap();
let repo = init_repo_with_tasks(
dir.path(),
&[
Task::new(TaskStatus::ToDo, "Foo"),
Task::new(TaskStatus::ToDo, "Bar"),
],
);
check_current_status(&repo, DisplayMode::ShowAll, "To Do:\n* Foo\n* Bar\n");
} | rust_cleaned_test_functions.jsonl/36274 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 213
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4773,
18410,
87686,
368,
341,
286,
1077,
5419,
284,
2730,
3741,
1005,
15454,
543,
286,
1077,
15867,
284,
2930,
37784,
6615,
32823,
1006,
310,
5419,
3875,
3148,
310,
609,
9640,
394,
5430,
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_flac_reader_get_tag_is_case_insensitive() {
let flac_reader = claxon::FlacReader::open("testsamples/p4.flac").unwrap();
// This file contains the following metadata:
// METADATA block #2
// is last: false
// length: 241
// comments: 5
// comment[0]: REPLAYGAIN_TRACK_PEAK=0.69879150
// comment[1]: REPLAYGAIN_TRACK_GAIN=-4.00 dB
// comment[2]: REPLAYGAIN_ALBUM_PEAK=0.69879150
// comment[3]: REPLAYGAIN_ALBUM_GAIN=-3.68 dB
let mut replaygain_upper = flac_reader.get_tag("REPLAYGAIN_TRACK_GAIN");
assert_eq!(replaygain_upper.next(), Some("-4.00 dB"));
assert_eq!(replaygain_upper.next(), None);
// The lookup should be case-insensitive.
let mut replaygain_lower = flac_reader.get_tag("replaygain_track_gain");
assert_eq!(replaygain_lower.next(), Some("-4.00 dB"));
assert_eq!(replaygain_lower.next(), None);
// Non-existing tags should not be found.
let mut foobar = flac_reader.get_tag("foobar");
assert_eq!(foobar.next(), None);
} | rust_cleaned_test_functions.jsonl/39103 | {
"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,
5081,
580,
22306,
3062,
9372,
6892,
19096,
34386,
18723,
368,
341,
262,
1077,
1320,
580,
22306,
284,
1185,
51836,
486,
3882,
580,
5062,
486,
2508,
445,
23841,
4023,
4322,
19,
8103,
580,
1827,
1545... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_bits_to_number() {
assert_eq!(6, bits_to_number(&[1, 1, 0]));
assert_eq!(4, bits_to_number(&[1, 0, 0]));
} | rust_cleaned_test_functions.jsonl/133802 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 84
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20034,
2346,
5500,
368,
341,
286,
2060,
10714,
10297,
21,
11,
9472,
2346,
5500,
2099,
58,
16,
11,
220,
16,
11,
220,
15,
14382,
286,
2060,
10714,
10297,
19,
11,
9472,
2346,
5500,
2099,
58,
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 |
#[test]
fn test_try_from_canonical() {
let og = Orthographia::try_from_canonical("i\u{0304}nfa\u{0304}ns").unwrap();
assert_eq!("\u{012b}nf\u{0101}ns", &og.s);
let og = Orthographia::try_from_canonical("i\u{0304}nf\u{0101}ns").unwrap();
assert_eq!("\u{012b}nf\u{0101}ns", &og.s);
let og = Orthographia::try_from_canonical("J\u{016b}ppiter").unwrap();
assert_eq!("J\u{016b}ppiter", &og.s);
// semivowel v and vowel u
let og = Orthographia::try_from_canonical("ve\u{0304}r|um").unwrap();
assert_eq!("v\u{0113}r|um", &og.s);
// compound word
let og = Orthographia::try_from_canonical("duo-decim").unwrap();
assert_eq!("duo-decim", &og.s);
// suffix
let og = Orthographia::try_from_canonical("-que").unwrap();
assert_eq!("-que", &og.s);
// stem and ending separation
let og = Orthographia::try_from_canonical("leg|is").unwrap();
assert_eq!("leg|is", &og.s);
// stem and ending separation with additional vertical bar
let og = Orthographia::try_from_canonical("l\u{0113}g|er\u{0101}|mus").unwrap();
assert_eq!("l\u{0113}g|er\u{0101}|mus", &og.s);
// stem
let og = Orthographia::try_from_canonical("magn|").unwrap();
assert_eq!("magn|", &og.s);
// word ending
let og = Orthographia::try_from_canonical("|us").unwrap();
assert_eq!("|us", &og.s);
// word ending with additional separator
let og = Orthographia::try_from_canonical("|eri|mus").unwrap();
assert_eq!("|eri|mus", &og.s);
// errors
// empty
let og = Orthographia::try_from_canonical("");
assert!(matches!(og, Err(Irritus)));
let og = Orthographia::try_from_canonical("\u{0304}cauda");
assert!(matches!(og, Err(Irritus)));
let og = Orthographia::try_from_canonical("s\u{0304}ol");
assert!(matches!(og, Err(Irritus)));
// double hyphen
let og = Orthographia::try_from_canonical("ex--it");
assert!(matches!(og, Err(Irritus)));
// double vertical line
let og = Orthographia::try_from_canonical("can||it");
assert!(matches!(og, Err(Irritus)));
// non-initial capital letter
let og = Orthographia::try_from_canonical("ITA");
assert!(matches!(og, Err(Irritus)));
let og = Orthographia::try_from_canonical("wind");
assert!(matches!(og, Err(Irritus)));
// punctuation
let og = Orthographia::try_from_canonical("S.P.Q.R.");
assert!(matches!(og, Err(Irritus)));
} | rust_cleaned_test_functions.jsonl/102150 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1117
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
53283,
5673,
27421,
22391,
368,
341,
1066,
262,
1077,
7350,
284,
31110,
3178,
685,
486,
1539,
5673,
27421,
22391,
445,
72,
3770,
90,
15,
18,
15,
19,
92,
77,
3632,
3770,
90,
15,
18,
15,
19,
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_compaction_guard() {
// Test comopaction guard disabled.
{
let mut config = DefaultCfConfig::default();
config.target_file_size_base = ReadableSize::mb(16);
config.enable_compaction_guard = false;
let provider = Some(MockRegionInfoProvider::new(vec![]));
let cf_opts = build_cf_opt!(config, CF_DEFAULT, None /*cache*/, provider);
assert_eq!(
config.target_file_size_base.0,
cf_opts.get_target_file_size_base()
);
}
// Test compaction guard enabled but region info provider is missing.
{
let mut config = DefaultCfConfig::default();
config.target_file_size_base = ReadableSize::mb(16);
config.enable_compaction_guard = true;
let provider: Option<MockRegionInfoProvider> = None;
let cf_opts = build_cf_opt!(config, CF_DEFAULT, None /*cache*/, provider);
assert_eq!(
config.target_file_size_base.0,
cf_opts.get_target_file_size_base()
);
}
// Test compaction guard enabled.
{
let mut config = DefaultCfConfig::default();
config.target_file_size_base = ReadableSize::mb(16);
config.enable_compaction_guard = true;
config.compaction_guard_min_output_file_size = ReadableSize::mb(4);
config.compaction_guard_max_output_file_size = ReadableSize::mb(64);
let provider = Some(MockRegionInfoProvider::new(vec![]));
let cf_opts = build_cf_opt!(config, CF_DEFAULT, None /*cache*/, provider);
assert_eq!(
config.compaction_guard_max_output_file_size.0,
cf_opts.get_target_file_size_base()
);
}
} | rust_cleaned_test_functions.jsonl/80169 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 904
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18177,
1311,
36796,
368,
341,
286,
442,
3393,
469,
453,
1311,
7616,
8386,
624,
286,
341,
310,
1077,
5206,
2193,
284,
7899,
34,
69,
2648,
486,
2258,
543,
310,
2193,
6539,
2458,
2368,
7651,
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_smoke_single_command() {
assert_eq!(
apply(raw_call, "raw_call", "git add ."),
build(b::call(
b::bare("git"),
vec![b::sp(), b::bare("add"), b::sp(), b::bare(".")]
))
);
assert_eq!(
apply(raw_call, "raw_call", "open Cargo.toml"),
build(b::call(
b::bare("open"),
vec![b::sp(), b::bare("Cargo.toml")]
))
);
assert_eq!(
apply(raw_call, "raw_call", "select package.version"),
build(b::call(
b::bare("select"),
vec![b::sp(), b::bare("package.version")]
))
);
assert_eq!(
apply(raw_call, "raw_call", "echo $it"),
build(b::call(b::bare("echo"), vec![b::sp(), b::var("it")]))
);
assert_eq!(
apply(raw_call, "raw_call", "open Cargo.toml --raw"),
build(b::call(
b::bare("open"),
vec![b::sp(), b::bare("Cargo.toml"), b::sp(), b::flag("raw")]
))
);
assert_eq!(
apply(raw_call, "raw_call", "open Cargo.toml -r"),
build(b::call(
b::bare("open"),
vec![b::sp(), b::bare("Cargo.toml"), b::sp(), b::shorthand("r")]
))
);
assert_eq!(
apply(raw_call, "raw_call", "config --set tabs 2"),
build(b::call(
b::bare("config"),
vec![
b::sp(),
b::flag("set"),
b::sp(),
b::bare("tabs"),
b::sp(),
b::int(2)
]
))
);
} | rust_cleaned_test_functions.jsonl/46729 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1129
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15874,
4740,
19487,
10811,
368,
341,
286,
2060,
10714,
33673,
310,
3796,
22460,
13429,
11,
330,
1041,
13429,
497,
330,
12882,
912,
659,
4461,
310,
1936,
1883,
486,
6659,
1006,
394,
293,
486,
54102... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parse_debug_info_offset_32() {
let section = Section::with_endian(Endian::Little).L32(0x0403_0201);
let buf = section.get_contents().unwrap();
let buf = &mut EndianSlice::new(&buf, LittleEndian);
match parse_debug_info_offset(buf, Format::Dwarf32) {
Ok(val) => assert_eq!(val, DebugInfoOffset(0x0403_0201)),
otherwise => panic!("Unexpected result: {:?}", otherwise),
};
} | rust_cleaned_test_functions.jsonl/101992 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 210
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
15446,
3109,
6917,
62,
18,
17,
368,
341,
286,
1077,
3772,
284,
11113,
486,
4197,
87193,
7,
43231,
486,
38103,
568,
43,
18,
17,
7,
15,
87,
15,
19,
15,
18,
62,
15,
17,
15,
16,
317,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_metrics() {
let m = Metrics::new();
println!("{}", m);
assert!(m.get_hits().is_none());
assert!(m.get_misses().is_none());
assert!(m.get_keys_added().is_none());
assert!(m.get_keys_updated().is_none());
assert!(m.get_keys_evicted().is_none());
assert!(m.get_sets_dropped().is_none());
assert!(m.get_gets_dropped().is_none());
assert!(m.get_gets_kept().is_none());
assert!(m.get_sets_dropped().is_none());
assert!(m.get_sets_rejected().is_none());
assert!(m.get_cost_evicted().is_none());
assert!(m.get_cost_added().is_none());
assert!(m.life_expectancy_seconds().is_none());
m.track_eviction(10);
assert!(m.is_noop());
let m = Metrics::new_op();
m.get_hits().unwrap();
m.get_misses().unwrap();
m.get_keys_added().unwrap();
m.get_keys_updated().unwrap();
m.get_keys_evicted().unwrap();
m.get_sets_dropped().unwrap();
m.get_gets_dropped().unwrap();
m.get_gets_kept().unwrap();
m.get_sets_dropped().unwrap();
m.get_sets_rejected().unwrap();
m.get_cost_evicted().unwrap();
m.get_cost_added().unwrap();
m.life_expectancy_seconds().unwrap();
m.track_eviction(10);
assert!(m.is_op());
println!("{}", m);
} | rust_cleaned_test_functions.jsonl/10258 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 716
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
37686,
368,
341,
286,
1077,
296,
284,
54190,
486,
931,
543,
286,
13751,
79878,
296,
317,
286,
2060,
10297,
76,
670,
63832,
1005,
285,
31488,
1423,
286,
2060,
10297,
76,
670,
67722,
288,
1005,
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_altlogical() {
test! {
#[derive(Debug, Clone)]
struct IsEven {
len: usize,
}
impl AltrepImpl for IsEven {
fn length(&self) -> usize {
self.len as usize
}
}
impl AltLogicalImpl for IsEven {
fn elt(&self, index: usize) -> Bool {
(index % 2 == 1).into()
}
}
let mystate = IsEven { len: 10 };
let class = Altrep::make_altlogical_class::<IsEven>("iseven", "mypkg");
let obj = Altrep::from_state_and_class(mystate, class, false);
assert_eq!(obj.len(), 10);
assert_eq!(obj.as_robj().as_logical_slice().unwrap(), [FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE]);
}
} | rust_cleaned_test_functions.jsonl/5815 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 422
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
32105,
30256,
368,
341,
262,
1273,
0,
341,
286,
11506,
27098,
42618,
11,
27913,
5563,
286,
2036,
2160,
13159,
341,
310,
2422,
25,
22301,
345,
286,
555,
286,
11605,
23682,
9995,
9673,
369,
2160,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ack_device_status() {
// We're using the `Dummy` struct that gets a `VirtioDevice` implementation
// automatically via the logic in `virtio_config`. The auto implementation does
// not override the default `ack_device_status` implementation.
let mut d = Dummy::new(0, 0, Vec::new());
// TODO: This is just a quick test for the happy path mostly. Find a better way to test
// things for the various combinations which are possible.
assert_eq!(d.cfg.device_status, 0);
// Doesn't do anything; `ACKNOWLEDGE` has to be set first.
d.ack_device_status(DRIVER);
assert_eq!(d.cfg.device_status, 0);
let mut status = ACKNOWLEDGE;
d.ack_device_status(status);
assert_eq!(d.cfg.device_status, status);
status |= DRIVER;
d.ack_device_status(status);
assert_eq!(d.cfg.device_status, status);
// Test several `ack_device_status` cases.
{
let old_status = status;
status |= FEATURES_OK;
d.ack_device_status(status);
assert_eq!(d.cfg.device_status, status);
// Make sure the EVENT_IDX feature was not advertised.
assert_eq!(d.cfg.device_features & (1 << VIRTIO_F_RING_EVENT_IDX), 0);
for q in d.cfg.queues.iter() {
assert!(!q.state.event_idx_enabled);
}
// Revert status.
d.cfg.device_status = old_status;
d.cfg.driver_features |= 1 << VIRTIO_F_RING_EVENT_IDX;
d.ack_device_status(status);
// The device status didn't change because the "driver" acknowledged a feature that's
// not advertised by the device.
assert_eq!(d.cfg.device_status, old_status);
d.cfg.device_features |= 1 << VIRTIO_F_RING_EVENT_IDX;
d.ack_device_status(status);
assert_eq!(d.cfg.device_status, status);
for q in d.cfg.queues.iter() {
assert!(q.state.event_idx_enabled);
}
}
status |= FEATURES_OK;
d.ack_device_status(status);
assert_eq!(d.cfg.device_status, status);
assert_eq!(d.activate_count, 0);
status |= DRIVER_OK;
d.ack_device_status(status);
assert_eq!(d.cfg.device_status, status);
assert_eq!(d.activate_count, 1);
d.ack_device_status(FAILED);
assert_ne!(d.cfg.device_status & FAILED, 0);
assert_eq!(d.reset_count, 0);
d.ack_device_status(RESET);
assert_eq!(d.reset_count, 1);
} | rust_cleaned_test_functions.jsonl/19622 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1240
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
48447,
9204,
4773,
368,
341,
286,
442,
1205,
2299,
1667,
279,
1565,
43344,
63,
2036,
429,
5221,
264,
1565,
53,
2106,
815,
6985,
63,
8129,
198,
286,
442,
9463,
4566,
279,
12218,
304,
1565,
47381,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_ast_what() {
enable_logging();
assert_parse(
Rule::block_modifiers,
"default partial alphanumeric_keys modifier_keys\n",
BlockModifiers {
values: vec![
BlockModifier { content: "default" },
BlockModifier { content: "partial" },
BlockModifier { content: "alphanumeric_keys" },
BlockModifier { content: "modifier_keys" },
],
},
);
} | rust_cleaned_test_functions.jsonl/23471 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 242
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
48019,
62,
12555,
368,
341,
262,
7283,
59982,
1428,
262,
2060,
21039,
1006,
286,
18100,
486,
4574,
7480,
11836,
345,
286,
330,
2258,
7130,
98979,
12631,
22739,
12631,
1699,
756,
286,
8362,
66937,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.