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_to_hex() {
assert_eq!(
[0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72].encode_hex::<String>(),
"666f6f626172".to_string(),
);
assert_eq!(
[0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72].encode_hex_upper::<String>(),
"666F6F626172".to_string(),
);
} | rust_cleaned_test_functions.jsonl/33270 | {
"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,
2346,
32655,
368,
341,
286,
2060,
10714,
33673,
310,
508,
15,
87,
21,
21,
11,
220,
15,
87,
21,
69,
11,
220,
15,
87,
21,
69,
11,
220,
15,
87,
21,
17,
11,
220,
15,
87,
21,
16,
11,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_iter_fold_uneven_folds() {
let records =
Array2::from_shape_vec((5, 2), vec![1., 1., 2., 2., 3., 3., 4., 4., 5., 5.]).unwrap();
let targets = Array1::from_shape_vec(5, vec![1., 2., 3., 4., 5.]).unwrap();
let mut dataset: Dataset<f64, f64, Ix1> = (records, targets).into();
let params = MockFittable { mock_var: 1 };
// If we request three folds from a dataset with 5 samples it will cut the
// last two samples from the folds and always add them as a tail of the training
// data
for (i, (model, validation_set)) in
dataset.iter_fold(3, |v| params.fit(v).unwrap()).enumerate()
{
assert_eq!(model.mock_var, 4);
assert_eq!(validation_set.records().row(0)[0] as usize, i + 1);
assert_eq!(validation_set.records().row(0)[1] as usize, i + 1);
assert_eq!(validation_set.targets()[0] as usize, i + 1);
assert_eq!(validation_set.records().dim(), (1, 2));
assert_eq!(validation_set.targets().dim(), 1);
assert!(i < 3);
}
// the same goes for the last sample if we choose 4 folds
for (i, (model, validation_set)) in
dataset.iter_fold(4, |v| params.fit(v).unwrap()).enumerate()
{
assert_eq!(model.mock_var, 4);
assert_eq!(validation_set.records().row(0)[0] as usize, i + 1);
assert_eq!(validation_set.records().row(0)[1] as usize, i + 1);
assert_eq!(validation_set.targets()[0] as usize, i + 1);
assert_eq!(validation_set.records().dim(), (1, 2));
assert_eq!(validation_set.targets().dim(), 1);
assert!(i < 4);
}
// if we choose 2 folds then again the last sample will be only
// used for trainig
for (i, (model, validation_set)) in
dataset.iter_fold(2, |v| params.fit(v).unwrap()).enumerate()
{
assert_eq!(model.mock_var, 3);
assert_eq!(validation_set.targets().dim(), 2);
assert!(i < 2);
}
} | rust_cleaned_test_functions.jsonl/98110 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1048
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11723,
61187,
62,
2886,
1037,
761,
18431,
368,
341,
286,
1077,
7424,
4035,
310,
2910,
17,
486,
1499,
13597,
13251,
1188,
20,
11,
220,
17,
701,
7486,
20703,
16,
2572,
220,
16,
2572,
220,
17,
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... | 4 |
#[test]
fn test_ipblock_merge() {
assert_eq!(IpBlock::merge(&as_input(INPUT)),
as_input(
"0-2
4-8"));
assert_eq!(IpBlock::merge(
&as_input(
"5-7
8-9")),
as_input(
"5-9"));
assert_eq!(IpBlock::merge(
&as_input(
"5-6
7-8
4-9
9-11
15-18
18-20")),
as_input(
"4-11
15-20"));
} | rust_cleaned_test_functions.jsonl/109570 | {
"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,
10385,
4574,
20888,
368,
341,
286,
2060,
10714,
10297,
23378,
4713,
486,
19052,
2099,
300,
5898,
57911,
6965,
310,
438,
5898,
1006,
394,
330,
15,
12,
17,
198,
338,
220,
19,
12,
23,
4010,
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_column_f64() {
let fields = vec![
field_type(FieldTypeTp::Float),
field_type(FieldTypeTp::Double),
];
let data = vec![Datum::Null, Datum::F64(f64::MIN), Datum::F64(f64::MAX)];
test_colum_datum(fields, data);
} | rust_cleaned_test_functions.jsonl/24363 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 156
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8744,
761,
21,
19,
368,
341,
286,
1077,
5043,
284,
7486,
90515,
310,
2070,
1819,
57788,
929,
62241,
486,
5442,
1326,
310,
2070,
1819,
57788,
929,
62241,
486,
7378,
1326,
286,
9747,
286,
1077,
82... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_repeat() {
let mut it = repeat(42);
assert_eq!(it.next(), Some(42));
assert_eq!(it.next(), Some(42));
assert_eq!(it.next(), Some(42));
} | rust_cleaned_test_functions.jsonl/25953 | {
"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,
41975,
368,
341,
262,
1077,
5206,
432,
284,
13153,
7,
19,
17,
317,
262,
2060,
10714,
10297,
275,
4529,
1507,
4329,
7,
19,
17,
1106,
262,
2060,
10714,
10297,
275,
4529,
1507,
4329,
7,
19,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_swap_top() {
let mut stack = Stack::new();
let _ = stack.push(U256::MAX);
let _ = stack.push(U256::one());
let _ = stack.push(U256::zero());
assert_eq!(stack.swap_top(2), Ok(()));
assert_eq!(stack.get(0), Some(&U256::MAX));
assert_eq!(stack.swap_top(2), Ok(()));
assert_eq!(stack.get(0), Some(&U256::zero()));
assert_eq!(stack.swap_top(1), Ok(()));
assert_eq!(stack.get(0), Some(&U256::one()));
assert_eq!(stack.get(1), Some(&U256::zero()));
assert_eq!(stack.get(2), Some(&U256::MAX));
} | rust_cleaned_test_functions.jsonl/90843 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 348
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
40991,
10426,
368,
341,
286,
1077,
5206,
5611,
284,
14284,
486,
931,
1428,
1789,
286,
1077,
716,
284,
5611,
2552,
12317,
17,
20,
21,
486,
10586,
317,
286,
1077,
716,
284,
5611,
2552,
12317,
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_mov() {
let mut mcu = McuFactory::create("attiny85");
mcu.set_register(1, 0xC5);
mcu.set_register(2, 0x95);
let memory_data = vec![0x12, 0x2C];
mcu.load_program_memory(&memory_data);
assert_eq!(mcu.get_program_counter(), 0x0);
mcu.step();
assert_eq!(mcu.get_program_counter(), 0x2);
assert_eq!(mcu.get_register(1), 0x95);
} | rust_cleaned_test_functions.jsonl/54994 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 187
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
55798,
368,
341,
262,
1077,
5206,
19223,
84,
284,
4483,
84,
4153,
486,
3182,
445,
1587,
6441,
23,
20,
797,
262,
19223,
84,
980,
14000,
7,
16,
11,
220,
15,
12125,
20,
317,
262,
19223,
84,
980... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_strbox_serialize() {
let strx: &'static str = "hello world";
let serialized = serialize(&Cow::Borrowed(strx)).unwrap();
let deserialized: Cow<'static, String> = deserialize_from(&mut &serialized[..]).unwrap();
let stringx: String = deserialized.into_owned();
assert!(strx == &stringx[..]);
} | rust_cleaned_test_functions.jsonl/6271 | {
"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,
2895,
2011,
88686,
368,
341,
262,
1077,
607,
87,
25,
30136,
1978,
607,
284,
330,
14990,
1879,
876,
262,
1077,
32916,
284,
24235,
2099,
89915,
486,
33,
7768,
291,
4199,
87,
4579,
15454,
543,
262,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_fill_pdt_from_tokens_errors() {
use DateTimeField::*;
let test_cases = [
// Mismatched syntax
(
"1 2 3",
"0-0 0",
Year,
1,
"Invalid syntax at offset 1: provided Delim but expected Dash",
),
];
for test in test_cases.iter() {
let mut pdt = ParsedDateTime::default();
let mut actual = tokenize_time_str(test.0).unwrap();
let expected = tokenize_time_str(test.1).unwrap();
match fill_pdt_from_tokens(&mut pdt, &mut actual, &expected, test.2, test.3) {
Err(e) => assert_eq!(e.to_string(), test.4),
Ok(_) => panic!("Test passed when expected to fail, generated {:?}", pdt),
};
}
} | rust_cleaned_test_functions.jsonl/100326 | {
"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,
30728,
620,
8047,
5673,
28838,
20196,
368,
341,
286,
990,
6520,
1877,
56162,
286,
1077,
1273,
41427,
284,
2278,
310,
442,
386,
24976,
291,
19482,
198,
310,
2399,
394,
330,
16,
220,
17,
220,
18,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_exe_does_not_exist() {
let exists: bool = ExeExists(String::from("HoardTestNotExist"))
.try_into()
.expect("failed to check if exe exists");
assert!(!exists);
} | rust_cleaned_test_functions.jsonl/24124 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 113
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
76074,
96374,
7913,
35906,
368,
341,
286,
1077,
6724,
25,
1807,
284,
1374,
68,
15575,
2242,
486,
1499,
445,
39,
33386,
2271,
45535,
5455,
310,
659,
1539,
45514,
741,
310,
659,
17119,
445,
16091,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_class_does_not_exist() {
common::setup();
let mut oso = OsoTest::new();
#[derive(PolarClass)]
struct Foo {
#[polar(attribute)]
x: i64,
}
impl Foo {
fn new() -> Self {
Foo { x: 1 }
}
}
let foo_class = Foo::get_polar_class_builder()
.set_constructor(Foo::new)
.build();
oso.oso.register_class(foo_class).unwrap();
oso.load_str("bar(b) if b = new Bar();");
let mut query = oso.oso.query("bar(b)").unwrap();
assert!(query.next().unwrap().is_err());
} | rust_cleaned_test_functions.jsonl/5011 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 287
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4790,
96374,
7913,
35906,
368,
341,
262,
4185,
486,
15188,
1428,
262,
1077,
5206,
297,
704,
284,
506,
704,
2271,
486,
931,
1428,
262,
11506,
27098,
5304,
7417,
1957,
5563,
262,
2036,
33428,
341,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_get_start_position() {
use crate::app::ScrollDirection::{self, Down, Up};
fn test(
bar: usize, num: usize, direction: ScrollDirection, selected: usize, force: bool,
expected_posn: usize, expected_bar: usize,
) {
let mut bar = bar;
assert_eq!(
get_start_position(num, &direction, &mut bar, selected, force),
expected_posn
);
assert_eq!(bar, expected_bar);
}
// Scrolling down from start
test(0, 10, Down, 0, false, 0, 0);
// Simple scrolling down
test(0, 10, Down, 1, false, 0, 0);
// Scrolling down from the middle high up
test(0, 10, Down, 5, false, 0, 0);
// Scrolling down into boundary
test(0, 10, Down, 11, false, 1, 1);
// Scrolling down from the with non-zero bar
test(5, 10, Down, 15, false, 5, 5);
test(5, 15, Down, 15, true, 0, 0);
// Test jumping down
test(1, 10, Down, 20, true, 10, 10);
// Scrolling up from bottom
test(10, 10, Up, 20, false, 10, 10);
// Simple scrolling up
test(10, 10, Up, 19, false, 10, 10);
// Scrolling up from the middle
test(10, 10, Up, 10, false, 10, 10);
// Scrolling up into boundary
test(10, 10, Up, 9, false, 9, 9);
test(5, 10, Up, 15, true, 5, 5);
// Test jumping up
test(10, 10, Up, 0, false, 0, 0);
} | rust_cleaned_test_functions.jsonl/4465 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 755
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
4906,
9661,
368,
341,
286,
990,
17717,
486,
676,
486,
8425,
9268,
22964,
721,
11,
6285,
11,
3138,
2315,
286,
5168,
1273,
1006,
310,
3619,
25,
22301,
11,
1629,
25,
22301,
11,
5106,
25,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_no_headers() {
let _ = ::env_logger::try_init();
let multipart = Multipart::with_body(
mock_stream(&[b"--boundary", b"\r\n", b"\r\n", b"--boundary--"]),
BOUNDARY,
);
pin_mut!(multipart);
ready_assert_eq!(|cx| multipart.as_mut().poll_has_next_field(cx), Ok(true));
until_ready!(|cx| multipart.as_mut().poll_field_headers(cx)).unwrap_err();
ready_assert_eq!(|cx| multipart.as_mut().poll_has_next_field(cx), Ok(false));
} | rust_cleaned_test_functions.jsonl/131801 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 272
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6536,
26719,
368,
341,
286,
1077,
716,
284,
3504,
3160,
27413,
486,
1539,
6137,
543,
286,
1077,
68058,
284,
386,
18204,
486,
4197,
14114,
1006,
310,
7860,
12673,
2099,
58,
65,
74757,
65180,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ipv4_embedded() {
// Test Ipv4Addr's to_ipv6_compatible and to_ipv6_mapped methods.
assert_eq!(
Ipv4Addr::new([1, 2, 3, 4]).to_ipv6_compatible(),
Ipv6Addr::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4])
);
assert_eq!(
Ipv4Addr::new([1, 2, 3, 4]).to_ipv6_mapped(),
Ipv6Addr::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 1, 2, 3, 4]),
);
// Test Ipv6Addr's to_ipv4_compatible and to_ipv4_mapped methods.
let compatible = Ipv6Addr::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4]);
let mapped = Ipv6Addr::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 1, 2, 3, 4]);
let not_embedded = Ipv6Addr::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 1, 2, 3, 4]);
let v4 = Ipv4Addr::new([1, 2, 3, 4]);
assert_eq!(compatible.to_ipv4_compatible(), Some(v4));
assert_eq!(compatible.to_ipv4_mapped(), None);
assert_eq!(mapped.to_ipv4_compatible(), None);
assert_eq!(mapped.to_ipv4_mapped(), Some(v4));
assert_eq!(not_embedded.to_ipv4_compatible(), None);
assert_eq!(not_embedded.to_ipv4_mapped(), None);
} | rust_cleaned_test_functions.jsonl/31870 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 687
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
49378,
19,
24007,
9789,
368,
341,
286,
442,
3393,
358,
30168,
19,
13986,
594,
311,
49378,
21,
2965,
37079,
323,
311,
49378,
21,
91933,
5413,
382,
286,
2060,
10714,
33673,
310,
358,
30168,
19,
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_get_devices_in_group() {
let mut device1 = Device::new("test1", 1, false);
let mut device2 = Device::new("test2", 2, false);
let repo = Repo::new("test.db");
repo.assure_created().unwrap();
assert!(repo.add_device(&mut device1).is_ok());
assert!(repo.add_device(&mut device2).is_ok());
let group_devices = repo.get_group(1).unwrap();
assert!(1 == group_devices.len())
} | rust_cleaned_test_functions.jsonl/48632 | {
"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,
3062,
41334,
1243,
6288,
368,
341,
262,
1077,
5206,
3671,
16,
284,
13903,
486,
931,
445,
1944,
16,
497,
220,
16,
11,
895,
317,
262,
1077,
5206,
3671,
17,
284,
13903,
486,
931,
445,
1944,
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_generate_enum_is_from_variant() {
check_assist(
generate_enum_is_method,
r#"
enum Variant {
Undefined,
Minor$0,
Major,
}"#,
r#"enum Variant {
Undefined,
Minor,
Major,
}
impl Variant {
/// Returns `true` if the variant is [`Minor`].
///
/// [`Minor`]: Variant::Minor
#[must_use]
fn is_minor(&self) -> bool {
matches!(self, Self::Minor)
}
}"#,
);
} | rust_cleaned_test_functions.jsonl/117712 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 249
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
48851,
31054,
6892,
5673,
46112,
368,
341,
286,
1779,
12083,
380,
1006,
310,
6923,
31054,
6892,
9032,
345,
310,
435,
2,
698,
9018,
39292,
341,
262,
62370,
345,
262,
29793,
3,
15,
345,
262,
17121... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_request() {
use helix::*;
let req = GetTeamsRequest::builder().id(Some("6358".into())).build();
// From twitch docs
let data = br#"
{
"data": [
{
"users": [
{
"user_id": "278217731",
"user_name": "mastermndio",
"user_login": "mastermndio"
},
{
"user_id": "41284990",
"user_name": "jenninexus",
"user_login": "jenninexus"
}
],
"background_image_url": null,
"banner": null,
"created_at": "2019-02-11T12:09:22Z",
"updated_at": "2020-11-18T15:56:41Z",
"info": "<p>An outgoing and enthusiastic group of friendly channels that write code, teach about technology, and promote the technical community.</p>",
"thumbnail_url": "https://static-cdn.jtvnw.net/jtv_user_pictures/team-livecoders-team_logo_image-bf1d9a87ca81432687de60e24ad9593d-600x600.png",
"team_name": "livecoders",
"team_display_name": "Live Coders",
"id": "6358"
}
]
}
"#
.to_vec();
let http_response = http::Response::builder().body(data).unwrap();
let uri = req.get_uri().unwrap();
assert_eq!(uri.to_string(), "https://api.twitch.tv/helix/teams?id=6358");
dbg!(GetTeamsRequest::parse_response(Some(req), &uri, http_response).unwrap());
} | rust_cleaned_test_functions.jsonl/86337 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 786
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7893,
368,
341,
262,
990,
11338,
941,
56162,
262,
1077,
4232,
284,
2126,
60669,
1900,
486,
17850,
1005,
307,
65405,
445,
21,
18,
20,
23,
3263,
18122,
34670,
5834,
1428,
262,
442,
5542,
59413,
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_parse_ip_packet() {
use crate::testdata::icmp_redirect::IP_PACKET_BYTES;
let (body, src_ip, dst_ip, proto, ttl) = parse_ip_packet::<Ipv4>(IP_PACKET_BYTES).unwrap();
assert_eq!(body, &IP_PACKET_BYTES[20..]);
assert_eq!(src_ip, Ipv4Addr::new([10, 123, 0, 2]));
assert_eq!(dst_ip, Ipv4Addr::new([10, 123, 0, 1]));
assert_eq!(proto, Ipv4Proto::Icmp);
assert_eq!(ttl, 255);
use crate::testdata::icmp_echo_v6::REQUEST_IP_PACKET_BYTES;
let (body, src_ip, dst_ip, proto, ttl) =
parse_ip_packet::<Ipv6>(REQUEST_IP_PACKET_BYTES).unwrap();
assert_eq!(body, &REQUEST_IP_PACKET_BYTES[40..]);
assert_eq!(src_ip, Ipv6Addr::new([0, 0, 0, 0, 0, 0, 0, 1]));
assert_eq!(dst_ip, Ipv6Addr::new([0xfec0, 0, 0, 0, 0, 0, 0, 0]));
assert_eq!(proto, Ipv6Proto::Icmpv6);
assert_eq!(ttl, 64);
} | rust_cleaned_test_functions.jsonl/13584 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 523
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
10385,
21078,
368,
341,
286,
990,
17717,
486,
92425,
486,
50774,
30043,
486,
3298,
40328,
40705,
280,
286,
1077,
320,
2599,
11,
2286,
10385,
11,
10648,
10385,
11,
18433,
11,
53932,
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_display_mock_matching_any_path() {
let mock = mock("GET", Matcher::Any);
assert_eq!("\r\nGET (any)\r\n", format!("{}", mock));
} | rust_cleaned_test_functions.jsonl/82418 | {
"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,
14825,
34134,
70763,
37248,
2638,
368,
341,
262,
1077,
7860,
284,
7860,
445,
3806,
497,
60632,
486,
8610,
626,
262,
2060,
10714,
0,
4921,
81,
1699,
3806,
320,
3767,
10699,
81,
1699,
497,
3561,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_smoother() {
let mut smoother = Smoother::<u64, 5>::default();
smoother.observe(1);
smoother.observe(6);
smoother.observe(2);
smoother.observe(3);
smoother.observe(4);
smoother.observe(5);
smoother.observe(0);
assert!((smoother.get_avg() - 2.8).abs() < f64::EPSILON);
assert_eq!(smoother.get_recent(), 0);
assert_eq!(smoother.get_max(), 5);
assert_eq!(smoother.get_percentile_90(), 4);
assert_eq!(smoother.trend(), Trend::NoTrend);
let mut smoother = Smoother::<f64, 5>::default();
smoother.observe(1.0);
smoother.observe(6.0);
smoother.observe(2.0);
smoother.observe(3.0);
smoother.observe(4.0);
smoother.observe(5.0);
smoother.observe(9.0);
assert!((smoother.get_avg() - 4.6).abs() < f64::EPSILON);
assert!((smoother.get_recent() - 9.0).abs() < f64::EPSILON);
assert!((smoother.get_max() - 9.0).abs() < f64::EPSILON);
assert!((smoother.get_percentile_90() - 5.0).abs() < f64::EPSILON);
assert_eq!(smoother.trend(), Trend::Increasing);
} | rust_cleaned_test_functions.jsonl/120663 | {
"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,
643,
6355,
1575,
368,
341,
286,
1077,
5206,
60305,
284,
4388,
78,
1575,
27638,
84,
21,
19,
11,
220,
20,
6831,
2258,
543,
286,
60305,
53093,
7,
16,
317,
286,
60305,
53093,
7,
21,
317,
286,
60... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_print_key() {
let (_env, op_tool, backend, storage) = launch_swarm_with_op_tool_and_backend(1, 0);
// Print the operator key
let op_tool_operator_key = op_tool.print_key(OPERATOR_KEY, &backend).unwrap();
let storage_operator_key = storage.get_public_key(OPERATOR_KEY).unwrap().public_key;
assert_eq!(storage_operator_key, op_tool_operator_key);
// Print the consensus key
let op_tool_consensus_key = op_tool.print_key(CONSENSUS_KEY, &backend).unwrap();
let storage_consensus_key = storage.get_public_key(CONSENSUS_KEY).unwrap().public_key;
assert_eq!(storage_consensus_key, op_tool_consensus_key);
} | rust_cleaned_test_functions.jsonl/64972 | {
"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,
10064,
3097,
368,
341,
262,
1077,
5453,
3160,
11,
1179,
22785,
11,
19163,
11,
5819,
8,
284,
7050,
32581,
2178,
6615,
10287,
22785,
8378,
40011,
7,
16,
11,
220,
15,
626,
262,
442,
8213,
279,
56... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_agent_endpoint_with_version() {
let with_tail_slash =
DatadogPipelineBuilder::build_endpoint("http://localhost:8126/", Version05.path());
let without_tail_slash =
DatadogPipelineBuilder::build_endpoint("http://localhost:8126", Version05.path());
let with_query = DatadogPipelineBuilder::build_endpoint(
"http://localhost:8126?api_key=123",
Version05.path(),
);
let invalid = DatadogPipelineBuilder::build_endpoint(
"http://localhost:klsajfjksfh",
Version05.path(),
);
assert_eq!(
with_tail_slash.unwrap().to_string(),
"http://localhost:8126/v0.5/traces"
);
assert_eq!(
without_tail_slash.unwrap().to_string(),
"http://localhost:8126/v0.5/traces"
);
assert_eq!(
with_query.unwrap().to_string(),
"http://localhost:8126/v0.5/traces?api_key=123"
);
assert!(invalid.is_err())
} | rust_cleaned_test_functions.jsonl/119459 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 539
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25730,
36699,
6615,
9438,
368,
341,
286,
1077,
448,
35471,
11886,
988,
4035,
310,
21631,
329,
538,
34656,
3297,
486,
5834,
36699,
445,
1254,
1110,
8301,
25,
23,
16,
17,
21,
28105,
6079,
15,
20,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_unqualified_identifier_debug_print() {
assert_eq!(
format!(
"{:?}",
UnqualifiedIdentifier::Identifier(Identifier { identifier: "hello".to_string() })
),
"\"hello\""
);
assert_eq!(format!("{:?}", UnqualifiedIdentifier::Constructor), "Constructor");
assert_eq!(format!("{:?}", UnqualifiedIdentifier::Destructor), "Destructor");
} | rust_cleaned_test_functions.jsonl/45460 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 223
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4907,
36335,
33176,
15446,
10064,
368,
341,
286,
2060,
10714,
33673,
310,
3561,
33673,
394,
13868,
76475,
24375,
394,
1230,
36335,
8714,
486,
8714,
7,
8714,
314,
12816,
25,
330,
14990,
3263,
983,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_difference() {
fn check_difference(a: &[i32], b: &[i32], expected: &[i32]) {
check(a, b, expected, |x, y, f| x.difference(y).all(f))
}
check_difference(&[], &[], &[]);
check_difference(&[1, 12], &[], &[1, 12]);
check_difference(&[], &[1, 2, 3, 9], &[]);
check_difference(&[1, 3, 5, 9, 11],
&[3, 9],
&[1, 5, 11]);
check_difference(&[-5, 11, 22, 33, 40, 42],
&[-12, -5, 14, 23, 34, 38, 39, 50],
&[11, 22, 33, 40, 42]);
} | rust_cleaned_test_functions.jsonl/4411 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 328
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
47525,
368,
341,
262,
5168,
1779,
47525,
2877,
25,
44590,
72,
18,
17,
1125,
293,
25,
44590,
72,
18,
17,
1125,
3601,
25,
44590,
72,
18,
17,
2467,
341,
286,
1779,
2877,
11,
293,
11,
3601,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_protocol_unreachable() {
// sure that we respond with the appropriate ICMP message.
// IPv6 networks.
test_receive_ip_packet(
&mut [0u8; 128],
DUMMY_CONFIG_V4.local_ip,
64,
IpProto::Other(255),
&["send_icmp_protocol_unreachable", "send_icmp_response"],
IcmpDestUnreachable::default(),
Icmpv4DestUnreachableCode::DestProtocolUnreachable,
// ensure packet is truncated to the right length
|packet| assert_eq!(packet.original_packet().bytes().len(), 84),
);
} | rust_cleaned_test_functions.jsonl/55691 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 337
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34880,
4907,
46550,
368,
341,
1789,
286,
442,
2704,
429,
582,
5889,
448,
279,
8311,
83988,
1943,
624,
16885,
286,
442,
31560,
21,
14155,
624,
286,
1273,
38557,
10385,
21078,
1006,
310,
609,
6984,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_new_empty() {
let root_hash = *SPARSE_MERKLE_PLACEHOLDER_HASH;
let smt = SparseMerkleTree::new(root_hash);
assert!(smt.root.read_lock().is_empty());
assert_eq!(smt.root_hash(), root_hash);
} | rust_cleaned_test_functions.jsonl/15421 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 109
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5921,
15124,
368,
341,
262,
1077,
3704,
8950,
284,
353,
4592,
79097,
1245,
640,
42,
867,
81924,
94629,
32309,
280,
262,
1077,
1525,
83,
284,
71794,
44,
16754,
273,
6533,
486,
931,
9206,
8950,
31... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parse_paratemers() {
let result = parse_parameters(&mut Lexer::new("x y z"));
let expected = Ok(vec![
Identifier::new("x"),
Identifier::new("y"),
Identifier::new("z"),
]);
assert_eq!(expected, result);
} | rust_cleaned_test_functions.jsonl/19437 | {
"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,
21039,
22654,
37246,
388,
368,
341,
286,
1077,
1102,
284,
4715,
18263,
2099,
6984,
85082,
486,
931,
445,
87,
379,
1147,
4010,
286,
1077,
3601,
284,
7622,
25592,
90515,
310,
34621,
486,
931,
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... | 1 |
#[test]
fn test_p2p_protocol() {
use super::block::*;
use super::protocol::*;
use async_trait::async_trait;
use futures_executor::block_on;
use starsig::{Signature, VerificationKey};
use std::fmt;
use std::sync::mpsc::{channel, Receiver, Sender};
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
struct PID(u8);
impl fmt::Debug for PID {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Peer#{}", self.0)
}
}
impl AsRef<[u8]> for PID {
fn as_ref(&self) -> &[u8] {
core::slice::from_ref(&self.0)
}
}
struct MockNode {
id: PID,
state: BlockchainState,
blocks: Vec<Block>,
mailbox: Sender<(PID, PID, Message)>,
}
#[derive(Debug)]
struct Mailbox {
rx: Receiver<(PID, PID, Message)>,
}
impl Mailbox {
fn process(
&self,
nodes: &mut [&mut BlockchainProtocol<MockNode>],
) -> Vec<(PID, Result<(), BlockchainError>)> {
let mut r = Vec::new();
while let Ok((pid_from, pid_to, msg)) = self.rx.try_recv() {
dbg!((pid_from, pid_to, &msg));
let result = block_on(nodes[pid_to.0 as usize].process_message(pid_from, msg));
if let Err(e) = result {
panic!("Message processing failed: {:?}", e);
}
r.push((pid_to, result));
}
r
}
fn process_must_succeed(&self, nodes: &mut [&mut BlockchainProtocol<MockNode>]) {
let results = self.process(nodes);
assert!(results.into_iter().all(|(_pid, r)| r.is_ok()));
}
}
#[async_trait]
impl Delegate for MockNode {
type PeerIdentifier = PID;
/// ID of our node.
fn self_id(&self) -> Self::PeerIdentifier {
self.id
}
/// Send a message to a given peer.
async fn send(&mut self, pid_to: Self::PeerIdentifier, message: Message) {
self.mailbox.send((self.id, pid_to, message)).unwrap();
}
/// Returns the signed tip of the blockchain
fn tip(&self) -> (BlockHeader, Signature) {
let last_block = self.blocks.last().unwrap();
(last_block.header.clone(), last_block.signature)
}
/// Returns a block at a given height
fn block_at_height(&self, height: u64) -> Option<Block> {
if height < 1 {
return None;
}
self.blocks.get((height - 1) as usize).map(|b| b.clone())
}
/// Blockchain state
fn blockchain_state(&self) -> &BlockchainState {
&self.state
}
/// Stores the new block and an updated state.
fn store_block(&mut self, verified_block: VerifiedBlock, signature: Signature) {
// TODO: update all proofs in the wallet with a catchup structure.
assert!(verified_block.header.height == self.state.tip.height + 1);
self.state = verified_block.blockchain_state();
self.blocks.push(Block {
header: verified_block.header,
signature,
txs: verified_block.raw_txs,
});
}
}
let bp_gens = BulletproofGens::new(256, 1);
let network_signing_key = Scalar::from(9000u64);
let network_pubkey = VerificationKey::from_secret(&network_signing_key);
let wallet_privkey = Scalar::from(1u64);
let initial_contract = make_nonce_contract(1u64, 100);
let (state, block_sig, proofs) = BlockchainProtocol::<MockNode>::new_network(
network_signing_key,
0,
vec![initial_contract.id()],
);
let utxo0 = UTXO {
contract: initial_contract.clone(),
proof: proofs[0].clone(),
privkey: wallet_privkey,
};
let (mailbox_tx, mailbox_rx) = channel();
let mailbox = Mailbox { rx: mailbox_rx };
let mut nodes = (0..3)
.map(|pid| MockNode {
id: PID(pid),
state: state.clone(),
blocks: vec![Block {
header: state.tip.clone(),
signature: block_sig.clone(),
txs: Vec::new(),
}],
mailbox: mailbox_tx.clone(),
})
.map(|mock| BlockchainProtocol::new(network_pubkey, mock));
// Now all the nodes have the same state and can make transactions.
let mut node0 = nodes.next().unwrap().set_inventory_interval(0);
let mut node1 = nodes.next().unwrap().set_inventory_interval(0);
let mut node2 = nodes.next().unwrap().set_inventory_interval(0);
// connect all the peers to each other
block_on(node0.peer_connected(node1.id()));
block_on(node1.peer_connected(node0.id()));
block_on(node2.peer_connected(node1.id()));
block_on(node1.peer_connected(node2.id()));
block_on(node2.peer_connected(node0.id()));
block_on(node0.peer_connected(node2.id()));
mailbox.process_must_succeed(&mut [&mut node0, &mut node1, &mut node2]);
block_on(node0.synchronize());
block_on(node1.synchronize());
block_on(node2.synchronize());
mailbox.process_must_succeed(&mut [&mut node0, &mut node1, &mut node2]);
let (tx1, _utxo1) = dummy_tx(utxo0, &bp_gens);
node0.submit_tx(tx1).unwrap();
// send out requests for inventory
block_on(node1.synchronize());
block_on(node2.synchronize());
mailbox.process_must_succeed(&mut [&mut node0, &mut node1, &mut node2]);
// send back the inventory
block_on(node0.synchronize());
mailbox.process_must_succeed(&mut [&mut node0, &mut node1, &mut node2]);
block_on(node1.synchronize());
block_on(node2.synchronize());
mailbox.process_must_succeed(&mut [&mut node0, &mut node1, &mut node2]);
block_on(node0.synchronize());
block_on(node1.synchronize());
block_on(node2.synchronize());
mailbox.process_must_succeed(&mut [&mut node0, &mut node1, &mut node2]);
block_on(node0.synchronize());
block_on(node1.synchronize());
block_on(node2.synchronize());
mailbox.process_must_succeed(&mut [&mut node0, &mut node1, &mut node2]);
node0.create_block(1u64, network_signing_key);
dbg!("creating a block 2");
block_on(node0.synchronize());
block_on(node1.synchronize());
block_on(node2.synchronize());
mailbox.process_must_succeed(&mut [&mut node0, &mut node1, &mut node2]);
block_on(node0.synchronize());
block_on(node1.synchronize());
block_on(node2.synchronize());
mailbox.process_must_succeed(&mut [&mut node0, &mut node1, &mut node2]);
block_on(node0.synchronize());
block_on(node1.synchronize());
block_on(node2.synchronize());
mailbox.process_must_succeed(&mut [&mut node0, &mut node1, &mut node2]);
} | rust_cleaned_test_functions.jsonl/51380 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 3145
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
17,
79,
34880,
368,
341,
262,
990,
2256,
486,
4574,
56162,
262,
990,
2256,
486,
17014,
56162,
262,
990,
3312,
78491,
486,
7692,
78491,
280,
262,
990,
36823,
81207,
486,
4574,
4470,
280,
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_gt_dyn_scalar_float() {
let array: Float32Array = vec![6.0, 7.0, 8.0, 8.0, 10.0]
.into_iter()
.map(Some)
.collect();
let expected = BooleanArray::from(
vec![Some(false), Some(false), Some(false), Some(false), Some(true)],
);
assert_eq!(gt_dyn_scalar(&array, 8).unwrap(), expected);
let array: ArrayRef = Arc::new(array);
let array = crate::compute::cast(&array, &DataType::Float64).unwrap();
assert_eq!(gt_dyn_scalar(&array, 8).unwrap(), expected);
} | rust_cleaned_test_functions.jsonl/98219 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 291
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
37479,
69213,
41652,
17586,
368,
341,
286,
1077,
1334,
25,
13001,
18,
17,
1857,
284,
7486,
20703,
21,
13,
15,
11,
220,
22,
13,
15,
11,
220,
23,
13,
15,
11,
220,
23,
13,
15,
11,
220,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_overlapped_ts_prewrite_before_rollback() {
let engine = TestEngineBuilder::new().build().unwrap();
let (k1, v1) = (b"key1", b"v1");
let (k2, v2) = (b"key2", b"v2");
let key2 = k2.to_vec();
let secondaries = Some(vec![key2]);
must_prewrite_put_async_commit(&engine, k1, v1, k1, &secondaries, 10, 0);
must_prewrite_put_async_commit(&engine, k2, v2, k1, &secondaries, 10, 0);
must_prewrite_put_err(&engine, k2, v2, k2, 20);
must_cleanup(&engine, k2, 20, 0);
// commit T1
must_commit(&engine, k1, 10, 20);
must_commit(&engine, k2, 10, 20);
let w = must_written(&engine, k2, 10, 20, WriteType::Put);
assert!(w.has_overlapped_rollback);
must_prewrite_put_err(&engine, k2, v2, k2, 20);
} | rust_cleaned_test_functions.jsonl/16098 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 439
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15431,
75,
5677,
25023,
620,
52473,
23708,
62,
33559,
368,
341,
286,
1077,
4712,
284,
3393,
4571,
3297,
486,
931,
1005,
5834,
1005,
15454,
543,
286,
1077,
320,
74,
16,
11,
348,
16,
8,
284,
320... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_role_tags_none() {
let tags = RoleTags {
bot_id: None,
integration_id: None,
premium_subscriber: false,
};
serde_test::assert_tokens(
&tags,
&[
Token::Struct {
name: "RoleTags",
len: 0,
},
Token::StructEnd,
],
);
} | rust_cleaned_test_functions.jsonl/65943 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 283
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19792,
16333,
31488,
368,
341,
286,
1077,
9492,
284,
15404,
15930,
341,
310,
10924,
842,
25,
2240,
345,
310,
17590,
842,
25,
2240,
345,
310,
14848,
5228,
20351,
25,
895,
345,
286,
3634,
286,
615... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_from_str_with_genotype_info() -> Result<(), ParseError> {
let s = "chr1\t13\tnd0\tATCG\tA\t5.8\tPASS\tSVTYPE=DEL\tGT:GQ\t0|1:13";
let record: Record = s.parse()?;
let expected = [
genotype::field::Key::Genotype,
genotype::field::Key::ConditionalGenotypeQuality,
];
assert_eq!(record.format().map(|f| &f[..]), Some(&expected[..]));
let genotypes = record.genotypes();
let expected = vec![
genotype::Field::new(
genotype::field::Key::Genotype,
genotype::field::Value::String(String::from("0|1")),
),
genotype::Field::new(
genotype::field::Key::ConditionalGenotypeQuality,
genotype::field::Value::Integer(13),
),
];
assert_eq!(genotypes.len(), 1);
assert_eq!(&genotypes[0][..], &expected[..]);
Ok(())
} | rust_cleaned_test_functions.jsonl/116554 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 495
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5673,
2895,
6615,
16322,
4156,
3109,
368,
1464,
5714,
68843,
14775,
1454,
29,
341,
286,
1077,
274,
284,
330,
16789,
16,
4955,
16,
18,
4955,
303,
15,
4955,
828,
8798,
4955,
32,
4955,
20,
13,
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... | 2 |
#[test]
fn test_run() {
let mut config: Config = toml::from_str(CONFIG_DEFAULT).unwrap();
config.pager.mode = ConfigPagerMode::Disable;
let args = vec!["procs"];
let opt = Opt::from_iter(args.iter());
let ret = run_default(&opt, &config);
assert!(ret.is_ok());
} | rust_cleaned_test_functions.jsonl/53090 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 150
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14007,
368,
341,
286,
1077,
5206,
2193,
25,
5532,
284,
311,
1014,
486,
1499,
2895,
38958,
13811,
568,
15454,
543,
286,
2193,
556,
1409,
22981,
284,
5532,
22640,
3636,
486,
25479,
401,
286,
1077,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_credential_from_bytes() {
assert_eq!(Credential::from_bytes(vec![1]), Credential::Password(vec![1]));
assert_eq!(Credential::from_bytes(vec![2; 63]), Credential::Password(vec![2; 63]));
assert_eq!(
Credential::from_bytes(vec![2; WPA_PSK_BYTE_LEN]),
Credential::Password(vec![2; WPA_PSK_BYTE_LEN])
);
assert_eq!(Credential::from_bytes(vec![]), Credential::None);
} | rust_cleaned_test_functions.jsonl/114358 | {
"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,
666,
30320,
5673,
12524,
368,
341,
286,
2060,
10714,
10297,
48265,
486,
1499,
12524,
25592,
20703,
16,
9719,
93379,
486,
4876,
25592,
20703,
16,
14382,
286,
2060,
10714,
10297,
48265,
486,
1499,
125... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_result_with_list() {
let numbers = vec![27, 297, 38502, 81];
assert_eq!(format!("{:?}", result_with_list(numbers)), "Ok([1, 11, 1426, 3])");
} | rust_cleaned_test_functions.jsonl/45641 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 92
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5287,
6615,
2019,
368,
341,
286,
1077,
5109,
284,
7486,
20703,
17,
22,
11,
220,
17,
24,
22,
11,
220,
18,
23,
20,
15,
17,
11,
220,
23,
16,
935,
286,
2060,
10714,
10297,
2243,
88928,
25,
526... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_runner() {
let revision = Revision::Istanbul;
let compiled = COMPILED.get("GreeterTest").expect("could not find contract");
let host = MockedHost::default();
let addr: Address = "0x1000000000000000000000000000000000000000".parse().unwrap();
let gas_limit = 12_000_000;
let evm = EvmOdin::new(host, gas_limit, revision, NoopTracer);
super::test_runner(evm, addr, compiled);
} | rust_cleaned_test_functions.jsonl/17792 | {
"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,
54828,
368,
341,
310,
1077,
23578,
284,
26795,
486,
40,
45116,
280,
310,
1077,
19697,
284,
7682,
1893,
13639,
670,
445,
64747,
1404,
2271,
1827,
17119,
445,
28077,
537,
1477,
5116,
3071,
310,
1077... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_schema_id_parts_for_id_as_qualified() {
let (did, _, _) = _schema_id_qualified().parts().unwrap();
assert_eq!(_did_qualified(), did);
} | rust_cleaned_test_functions.jsonl/130825 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 96
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25371,
842,
33217,
5478,
842,
11898,
62,
36335,
368,
341,
310,
1077,
320,
22920,
11,
8358,
27439,
284,
716,
17349,
842,
62,
36335,
1005,
18252,
1005,
15454,
543,
310,
2060,
10714,
0,
2490,
22920,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_map_is_novel() {
// sanity check
assert!(AllIsNovel::is_novel(0_u8, 0));
assert!(!NewIsNovel::is_novel(0_u8, NoReducer::reduce(0x42, 0)));
assert!(NewIsNovel::is_novel(66, NoReducer::reduce(0x42, 66)));
assert!(!NextPow2IsNovel::is_novel(0_u8, 0));
assert!(NextPow2IsNovel::is_novel(0_u8, 1));
assert!(!NextPow2IsNovel::is_novel(1_u8, 1));
assert!(NextPow2IsNovel::is_novel(1_u8, 2));
assert!(!NextPow2IsNovel::is_novel(2_u8, 2));
assert!(!NextPow2IsNovel::is_novel(2_u8, 3));
assert!(NextPow2IsNovel::is_novel(2_u8, 4));
assert!(!NextPow2IsNovel::is_novel(128_u8, 128));
assert!(!NextPow2IsNovel::is_novel(129_u8, 128));
assert!(NextPow2IsNovel::is_novel(128_u8, 255));
assert!(!NextPow2IsNovel::is_novel(255_u8, 128));
assert!(NextPow2IsNovel::is_novel(254_u8, 255));
assert!(!NextPow2IsNovel::is_novel(255_u8, 255));
} | rust_cleaned_test_functions.jsonl/113489 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 555
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5376,
6892,
1089,
43335,
368,
341,
286,
442,
46842,
1779,
198,
286,
2060,
10297,
2403,
3872,
18944,
301,
486,
285,
1089,
43335,
7,
15,
7300,
23,
11,
220,
15,
3237,
286,
2060,
0,
3471,
3564,
38... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_logger_with_feature_test_logger() {
let cur_dir = env::current_dir().unwrap();
let test_dir = cur_dir
.join("..")
.join("..")
.join("testing")
.join("test-test_logger");
let cmd_line = format!(
"cd {} && cargo test --features logging/test_logger",
test_dir.to_str().unwrap()
);
let output = run_cmd(&cmd_line);
let data = String::from_utf8(output.unwrap().stderr).unwrap();
println!("data={}", data);
assert!(data.contains("INFO hi, "));
} | rust_cleaned_test_functions.jsonl/82769 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 253
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4452,
27413,
6615,
17069,
4452,
27413,
368,
341,
262,
1077,
2847,
4334,
284,
6105,
486,
3231,
4334,
1005,
15454,
543,
262,
1077,
1273,
4334,
284,
2847,
4334,
198,
286,
659,
5987,
95032,
1138,
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_indexed_reader_reused_buffer() {
let mut reader = IndexedReader::new(io::Cursor::new(FASTA_FILE), FAI_FILE).unwrap();
let mut seq = Vec::new();
reader.fetch("id", 1, 5).unwrap();
reader.read(&mut seq).unwrap();
assert_eq!(seq, b"CCGT");
reader.fetch("id", 13, 23).unwrap();
reader.read(&mut seq).unwrap();
assert_eq!(seq, b"CGTAGGCTGA");
} | rust_cleaned_test_functions.jsonl/62842 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 209
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3560,
291,
22306,
1288,
2591,
7776,
368,
341,
286,
1077,
5206,
6604,
284,
8008,
17120,
486,
931,
37258,
486,
14543,
486,
931,
7,
59206,
32,
8087,
701,
15008,
40,
8087,
568,
15454,
543,
286,
1077... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_gt_varying_positive_precisions() {
assert!(decimal("1.1") > decimal("1.01"));
assert!(decimal("1.01") > decimal("1.0"));
assert!(decimal("1.0") > decimal("0.1"));
assert!(decimal("0.1") > decimal("0.01"));
} | rust_cleaned_test_functions.jsonl/58120 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 117
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
37479,
2273,
658,
287,
54160,
59179,
6805,
368,
341,
262,
2060,
10297,
23289,
445,
16,
13,
16,
899,
861,
12122,
445,
16,
13,
15,
16,
4010,
262,
2060,
10297,
23289,
445,
16,
13,
15,
16,
899,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_string_array() {
let session = quick_session().expect("simple session");
session
.set_server_var::<str>("TEST", "177")
.expect("could not set var");
let var_count = ffi::get_server_env_var_count(&session).unwrap();
let handles = ffi::get_server_env_var_list(&session, var_count).unwrap();
let array = super::get_string_array(&handles, &session).unwrap();
assert_eq!(array.iter_str().count(), var_count as usize);
assert_eq!(array.iter_cstr().count(), var_count as usize);
assert!(array.iter_str().any(|s| s == "TEST=177"));
assert!(array
.iter_cstr()
.any(|s| s == unsafe { CStr::from_bytes_with_nul_unchecked(b"TEST=177\0") }));
let mut owned: super::OwnedStringIter = array.into_iter();
assert!(owned.any(|s| s == "TEST=177"));
} | rust_cleaned_test_functions.jsonl/123708 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 414
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3904,
3858,
368,
341,
286,
1077,
3797,
284,
3974,
12316,
1005,
17119,
445,
22944,
3797,
797,
286,
3797,
198,
310,
659,
746,
12015,
4612,
27638,
495,
13211,
10033,
497,
330,
16,
22,
22,
1138,
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_accounts_empty_hash_internal_state() {
let accounts = Accounts::new(None);
assert_eq!(accounts.hash_internal_state(0), None);
accounts.store_slow(0, &Pubkey::default(), &Account::new(1, 0, &sysvar::id()));
assert_eq!(accounts.hash_internal_state(0), None);
} | rust_cleaned_test_functions.jsonl/104351 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 138
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
55665,
15124,
8950,
23472,
4387,
368,
341,
286,
1077,
9618,
284,
40655,
486,
931,
26717,
317,
286,
2060,
10714,
10297,
26206,
15101,
23472,
4387,
7,
15,
701,
2240,
317,
286,
9618,
16114,
82447,
7,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_process_chunk_response_target() {
// Create a coordinator for a validator
let mut validator_coordinator = test_utils::create_validator_coordinator();
// Create a peer for the node and add the peer as a known peer
let peer_network_id = PeerNetworkId::random_validator();
process_new_peer_event(&mut validator_coordinator, &peer_network_id);
let (sync_request, _) = create_sync_notification_at_version(10);
let _ = block_on(validator_coordinator.process_sync_request(sync_request));
// Verify wrong chunk type for waypoint message
let chunk_responses = create_non_empty_chunk_responses(1);
verify_all_chunk_responses_are_the_wrong_type(
&mut validator_coordinator,
&peer_network_id,
&chunk_responses[0..1], // Ignore the target and highest chunk responses
);
// Verify ledger info version doesn't exceed sync request version
let ledger_info = create_ledger_info_at_version(100);
let response_ledger_info = ResponseLedgerInfo::VerifiableLedgerInfo(ledger_info);
let target_response = create_chunk_response_message(
response_ledger_info,
create_dummy_transaction_list_with_proof(1),
);
verify_all_chunk_responses_are_invalid(
&mut validator_coordinator,
&peer_network_id,
&[target_response],
);
// Verify invalid ledger infos are rejected
let ledger_info = create_ledger_info_at_version(5);
let response_ledger_info = ResponseLedgerInfo::VerifiableLedgerInfo(ledger_info);
let target_response = create_chunk_response_message(
response_ledger_info,
create_dummy_transaction_list_with_proof(1),
);
verify_all_chunk_responses_are_invalid(
&mut validator_coordinator,
&peer_network_id,
&[target_response],
);
} | rust_cleaned_test_functions.jsonl/84050 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 855
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11305,
30539,
9655,
11123,
368,
341,
286,
442,
4230,
264,
30284,
369,
264,
22935,
198,
286,
1077,
5206,
22935,
11393,
17442,
284,
1273,
17309,
486,
3182,
64959,
11393,
17442,
1428,
286,
442,
4230,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_valid_vm_config_pmem() {
vec![
(
vec![
"cloud-hypervisor",
"--kernel",
"/path/to/kernel",
"--pmem",
"file=/path/to/img/1,size=1G",
"file=/path/to/img/2,size=2G",
],
r#"{
"kernel": {"path": "/path/to/kernel"},
"pmem": [
{"file": "/path/to/img/1", "size": 1073741824},
{"file": "/path/to/img/2", "size": 2147483648}
]
}"#,
true,
),
(
vec![
"cloud-hypervisor",
"--kernel",
"/path/to/kernel",
"--pmem",
"file=/path/to/img/1,size=1G,iommu=on",
],
r#"{
"kernel": {"path": "/path/to/kernel"},
"pmem": [
{"file": "/path/to/img/1", "size": 1073741824, "iommu": true}
],
"iommu": true
}"#,
true,
),
(
vec![
"cloud-hypervisor",
"--kernel",
"/path/to/kernel",
"--pmem",
"file=/path/to/img/1,size=1G,iommu=on",
],
r#"{
"kernel": {"path": "/path/to/kernel"},
"pmem": [
{"file": "/path/to/img/1", "size": 1073741824, "iommu": true}
]
}"#,
false,
),
(
vec![
"cloud-hypervisor",
"--kernel",
"/path/to/kernel",
"--pmem",
"file=/path/to/img/1,size=1G,mergeable=on",
],
r#"{
"kernel": {"path": "/path/to/kernel"},
"pmem": [
{"file": "/path/to/img/1", "size": 1073741824, "mergeable": true}
]
}"#,
true,
),
(
vec![
"cloud-hypervisor",
"--kernel",
"/path/to/kernel",
"--pmem",
"file=/path/to/img/1,size=1G,mergeable=off",
],
r#"{
"kernel": {"path": "/path/to/kernel"},
"pmem": [
{"file": "/path/to/img/1", "size": 1073741824, "mergeable": false}
]
}"#,
true,
),
]
.iter()
.for_each(|(cli, openapi, equal)| {
compare_vm_config_cli_vs_json(cli, openapi, *equal);
});
} | rust_cleaned_test_functions.jsonl/4728 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2188
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8337,
39008,
5332,
620,
10536,
368,
341,
286,
7486,
90515,
310,
2399,
394,
7486,
90515,
503,
330,
12361,
2832,
1082,
31396,
756,
503,
14482,
23248,
756,
503,
3521,
2343,
32429,
58343,
756,
503,
14... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_vincenty_distance_equatorial() {
let a = Point::<f64>::new(0.0, 0.0);
let b = Point::<f64>::new(100.0, 0.0);
assert_relative_eq!(
a.vincenty_distance(&b).unwrap(),
11131949.079,
epsilon = 1.0e-3
);
} | rust_cleaned_test_functions.jsonl/15218 | {
"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,
2273,
258,
1168,
88,
19464,
41443,
37936,
368,
341,
286,
1077,
264,
284,
5126,
27638,
69,
21,
19,
6831,
931,
7,
15,
13,
15,
11,
220,
15,
13,
15,
317,
286,
1077,
293,
284,
5126,
27638,
69,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_negate_dot() -> TestResult {
let p = Polar::new();
p.load_str(r#"f(x) if not (x.y = 1 and x.b = 2);"#)?;
let mut q = p.new_query_from_term(term!(call!("f", [sym!("x")])), false);
assert_partial_expression!(next_binding(&mut q)?, "x", "(1 != _this.y or 2 != _this.b)");
assert_query_done!(q);
Ok(())
} | rust_cleaned_test_functions.jsonl/63026 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 193
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28209,
349,
30941,
368,
1464,
3393,
2077,
341,
286,
1077,
281,
284,
55896,
486,
931,
543,
286,
281,
5104,
2895,
2601,
55543,
69,
2075,
8,
421,
537,
320,
87,
2384,
284,
220,
16,
323,
856,
948,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_static_provider_creation() {
let result = StaticProvider::new(
"fake-key".to_owned(),
"fake-secret".to_owned(),
Some("token".to_owned()),
Some(300),
)
.credentials()
.wait();
assert!(result.is_ok());
} | rust_cleaned_test_functions.jsonl/83673 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 172
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25360,
29518,
46163,
368,
341,
286,
1077,
1102,
284,
23105,
5179,
486,
931,
1006,
310,
330,
30570,
16173,
3263,
983,
51973,
3148,
310,
330,
30570,
68892,
3263,
983,
51973,
3148,
310,
4329,
445,
58... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parse_valid_ses_send_email() {
let mock_response = MockResponseReader::read_response(
"test_resources/generated/valid",
"ses-send-email.xml",
);
let mock = MockRequestDispatcher::with_status(200).with_body(&mock_response);
let client = SesClient::new(mock, MockCredentialsProvider, rusoto_region::UsEast1);
let request = SendEmailRequest::default();
let result = client.send_email(request).sync();
assert!(result.is_ok(), "parse error: {:?}", result);
} | rust_cleaned_test_functions.jsonl/21978 | {
"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,
21039,
8337,
643,
288,
13565,
9172,
368,
341,
286,
1077,
7860,
9655,
284,
14563,
2582,
5062,
486,
878,
9655,
1006,
310,
330,
1944,
35569,
79372,
14,
1891,
756,
310,
330,
9275,
74118,
42117,
9028,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_rgb() {
let dye_factory = DyeFactory::rgb(&[Effect::Bold]);
let dye = dye_factory.make(&(255, 0, 0));
let text = dye("shakes - rgb");
println!("{}", text);
} | rust_cleaned_test_functions.jsonl/40866 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 109
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
37407,
368,
341,
286,
1077,
53531,
24269,
284,
422,
9011,
4153,
486,
16509,
2099,
58,
7738,
486,
42800,
2558,
286,
1077,
53531,
284,
53531,
24269,
10117,
29089,
17,
20,
20,
11,
220,
15,
11,
220,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_rand_new() {
let mut rng1 = MySQLRng::new();
std::thread::sleep(std::time::Duration::from_millis(100));
let mut rng2 = MySQLRng::new();
let got1 = rng1.gen();
let got2 = rng2.gen();
assert!(got1 < 1.0);
assert!(got1 >= 0.0);
assert_ne!(got1, rng1.gen());
assert!(got2 < 1.0);
assert!(got2 >= 0.0);
assert_ne!(got2, rng2.gen());
assert_ne!(got1, got2);
} | rust_cleaned_test_functions.jsonl/9510 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 262
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
33864,
5921,
368,
341,
286,
1077,
5206,
28422,
16,
284,
26339,
49,
968,
486,
931,
543,
286,
1460,
486,
4528,
486,
25809,
5194,
486,
1678,
486,
12945,
486,
1499,
717,
56212,
7,
16,
15,
15,
1106... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_renaming_of_conditional_edges() {
// Given:
// x = 1
// barr +---+
// x = x <---+
// barr +---+
// x = x <---+
let mut cfg = ControlFlowGraph::new();
let block0 = cfg.new_block();
block0.assign(variable("x"), expr_const(1)).unwrap();
block0.barrier();
let block1 = cfg.new_block();
block1.assign(variable("x"), variable("x").into()).unwrap();
block1.barrier();
let block2 = cfg.new_block();
block2.assign(variable("x"), variable("x").into()).unwrap();
cfg.set_entry(0).unwrap();
cfg.conditional_edge(0, 1, variable("x").into()).unwrap();
cfg.conditional_edge(1, 2, variable("x").into()).unwrap();
let mut versioning = VariableVersioning::new();
versioning.start_new_scope();
cfg.rename_variables(&mut versioning).unwrap();
// Expected:
// x_1 = 1
// barr +---+
// x_2 = x_1 <---+
// barr +---+
// x_3 = x_2 <---+
let ssa_block0 = cfg.block(0).unwrap();
assert_eq!(
ssa_block0.instruction(0).unwrap().operation(),
&Operation::assign(variable_ssa("x", 1), expr_const(1)).unwrap()
);
let ssa_block1 = cfg.block(1).unwrap();
assert_eq!(
ssa_block1.instruction(0).unwrap().operation(),
&Operation::assign(variable_ssa("x", 2), variable_ssa("x", 1).into()).unwrap()
);
let ssa_block2 = cfg.block(2).unwrap();
assert_eq!(
ssa_block2.instruction(0).unwrap().operation(),
&Operation::assign(variable_ssa("x", 3), variable_ssa("x", 2).into()).unwrap()
);
let ssa_edge01 = cfg.edge(0, 1).unwrap();
assert_eq!(
ssa_edge01.condition().unwrap(),
&variable_ssa("x", 1).into()
);
let ssa_edge12 = cfg.edge(1, 2).unwrap();
assert_eq!(
ssa_edge12.condition().unwrap(),
&variable_ssa("x", 2).into()
);
} | rust_cleaned_test_functions.jsonl/13499 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1108
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1288,
77,
6469,
3575,
24433,
3005,
28026,
368,
341,
286,
442,
16246,
510,
286,
442,
856,
284,
220,
16,
198,
286,
442,
30939,
220,
488,
4421,
16930,
1789,
286,
442,
856,
284,
856,
366,
4421,
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_single_basic() {
let engine = new_sample_engine_2();
let mut getter = new_single_point_getter(&engine, 1.into());
must_get_none(&mut getter, b"foo1");
let mut getter = new_single_point_getter(&engine, 3.into());
must_get_value(&mut getter, b"bar", b"barv");
must_get_none(&mut getter, b"bar");
must_get_none(&mut getter, b"foo1");
let mut getter = new_single_point_getter(&engine, 3.into());
must_get_value(&mut getter, b"foo1", b"foo1v");
must_get_none(&mut getter, b"foo2");
let mut getter = new_single_point_getter(&engine, 3.into());
must_get_none(&mut getter, b"foo2");
must_get_none(&mut getter, b"foo2");
let mut getter = new_single_point_getter(&engine, 4.into());
must_get_err(&mut getter, b"bar");
must_get_none(&mut getter, b"bar");
must_get_none(&mut getter, b"a");
must_get_none(&mut getter, b"foo1");
let mut getter = new_single_point_getter(&engine, 4.into());
must_get_value(&mut getter, b"foo1", b"foo1v");
must_get_none(&mut getter, b"foo1");
} | rust_cleaned_test_functions.jsonl/32895 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 545
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19487,
34729,
368,
341,
286,
1077,
4712,
284,
501,
17491,
24823,
62,
17,
1428,
286,
1077,
5206,
33429,
284,
501,
19487,
6085,
3062,
465,
2099,
8512,
11,
220,
16,
39860,
1423,
286,
1969,
3062,
31... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_cluster_nodes_retransmit() {
let mut rng = rand::thread_rng();
let (nodes, stakes, cluster_info) = make_cluster(&mut rng);
let this_node = cluster_info.my_contact_info();
// ClusterInfo::tvu_peers excludes the node itself.
assert_eq!(cluster_info.tvu_peers().len(), nodes.len() - 1);
let cluster_nodes = new_cluster_nodes::<RetransmitStage>(&cluster_info, &stakes);
// All nodes with contact-info should be in the index.
assert_eq!(cluster_nodes.index.len(), nodes.len());
// Staked nodes with no contact-info should be included.
assert!(cluster_nodes.nodes.len() > nodes.len());
// Assert that all nodes keep their contact-info.
{
let cluster_nodes: HashMap<_, _> = cluster_nodes
.nodes
.iter()
.map(|node| (node.pubkey(), node))
.collect();
for node in &nodes {
assert_eq!(cluster_nodes[&node.id].contact_info().unwrap().id, node.id);
}
for (pubkey, stake) in &stakes {
if *stake > 0 {
assert_eq!(cluster_nodes[pubkey].stake, *stake);
}
}
}
let (peers, stakes_and_index) =
sorted_retransmit_peers_and_stakes(&cluster_info, Some(&stakes));
assert_eq!(stakes_and_index.len(), peers.len());
assert_eq!(cluster_nodes.index.len(), peers.len());
for (i, node) in cluster_nodes
.index
.iter()
.map(|(_, i)| &cluster_nodes.nodes[*i])
.enumerate()
{
let (stake, index) = stakes_and_index[i];
// Wallclock may be update by ClusterInfo::push_self.
if node.pubkey() == this_node.id {
assert_eq!(this_node.id, peers[index].id)
} else {
assert_eq!(node.contact_info().unwrap(), &peers[index]);
}
assert_eq!(node.stake.max(1), stake);
}
let slot_leader = nodes[1..].choose(&mut rng).unwrap().id;
// Remove slot leader from peers indices.
let stakes_and_index: Vec<_> = stakes_and_index
.into_iter()
.filter(|(_stake, index)| peers[*index].id != slot_leader)
.collect();
assert_eq!(peers.len(), stakes_and_index.len() + 1);
let mut shred_seed = [0u8; 32];
rng.fill(&mut shred_seed[..]);
let (self_index, shuffled_peers_and_stakes) =
shuffle_peers_and_index(&this_node.id, &peers, &stakes_and_index, shred_seed);
let shuffled_index: Vec<_> = shuffled_peers_and_stakes
.into_iter()
.map(|(_, index)| index)
.collect();
assert_eq!(this_node.id, peers[shuffled_index[self_index]].id);
for fanout in 1..200 {
let (neighbors_indices, children_indices) =
compute_retransmit_peers(fanout, self_index, &shuffled_index);
let (neighbors, children) =
cluster_nodes.get_retransmit_peers_compat(shred_seed, fanout, slot_leader);
assert_eq!(children.len(), children_indices.len());
for (node, index) in children.into_iter().zip(children_indices) {
assert_eq!(*node.contact_info().unwrap(), peers[index]);
}
assert_eq!(neighbors.len(), neighbors_indices.len());
assert_eq!(neighbors[0].pubkey(), peers[neighbors_indices[0]].id);
for (node, index) in neighbors.into_iter().zip(neighbors_indices).skip(1) {
assert_eq!(*node.contact_info().unwrap(), peers[index]);
}
}
} | rust_cleaned_test_functions.jsonl/18829 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1882
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28441,
14896,
1288,
1458,
1763,
368,
341,
286,
1077,
5206,
28422,
284,
10382,
486,
4528,
66849,
543,
286,
1077,
320,
20008,
11,
44425,
11,
10652,
3109,
8,
284,
1281,
28441,
2099,
6984,
28422,
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... | 9 |
#[test]
fn test_continuity_counter() {
let mut p = PacketInfo::null_packet();
for cc in 0..15 {
p.set_continuity_counter(cc);
assert_eq!(p.continuity_counter(), cc);
}
} | rust_cleaned_test_functions.jsonl/47183 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 119
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
68948,
34494,
15730,
368,
341,
286,
1077,
5206,
281,
284,
28889,
1731,
486,
2921,
21078,
543,
286,
369,
12527,
304,
220,
15,
496,
16,
20,
341,
310,
281,
980,
68948,
34494,
15730,
31424,
317,
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
] | 2 |
#[test]
fn test_binomial() {
macro_rules! check {
($t:ty, $x:expr, $y:expr, $r:expr) => { {
let x: $t = $x;
let y: $t = $y;
let expected: $t = $r;
assert_eq!(binomial(x, y), expected);
if y <= x {
assert_eq!(binomial(x, x - y), expected);
}
} }
}
check!(u8, 9, 4, 126);
check!(u8, 0, 0, 1);
check!(u8, 2, 3, 0);
check!(i8, 9, 4, 126);
check!(i8, 0, 0, 1);
check!(i8, 2, 3, 0);
check!(u16, 100, 2, 4950);
check!(u16, 14, 4, 1001);
check!(u16, 0, 0, 1);
check!(u16, 2, 3, 0);
check!(i16, 100, 2, 4950);
check!(i16, 14, 4, 1001);
check!(i16, 0, 0, 1);
check!(i16, 2, 3, 0);
check!(u32, 100, 2, 4950);
check!(u32, 35, 11, 417225900);
check!(u32, 14, 4, 1001);
check!(u32, 0, 0, 1);
check!(u32, 2, 3, 0);
check!(i32, 100, 2, 4950);
check!(i32, 35, 11, 417225900);
check!(i32, 14, 4, 1001);
check!(i32, 0, 0, 1);
check!(i32, 2, 3, 0);
check!(u64, 100, 2, 4950);
check!(u64, 35, 11, 417225900);
check!(u64, 14, 4, 1001);
check!(u64, 0, 0, 1);
check!(u64, 2, 3, 0);
check!(i64, 100, 2, 4950);
check!(i64, 35, 11, 417225900);
check!(i64, 14, 4, 1001);
check!(i64, 0, 0, 1);
check!(i64, 2, 3, 0);
} | rust_cleaned_test_functions.jsonl/5339 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 791
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21816,
20855,
368,
341,
262,
18072,
21407,
0,
1779,
341,
286,
1711,
83,
25,
1881,
11,
400,
87,
96011,
11,
400,
88,
96011,
11,
400,
81,
96011,
8,
589,
314,
341,
310,
1077,
856,
25,
400,
83,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_runnables_doc_test() {
check(
r#"
//- /lib.rs
$0
fn main() {}
/// ```
/// let x = 5;
/// ```
fn should_have_runnable() {}
/// ```edition2018
/// let x = 5;
/// ```
fn should_have_runnable_1() {}
/// ```
/// let z = 55;
/// ```
///
/// ```ignore
/// let z = 56;
/// ```
fn should_have_runnable_2() {}
/**
```rust
let z = 55;
```
*/
fn should_have_no_runnable_3() {}
/**
```rust
let z = 55;
```
*/
fn should_have_no_runnable_4() {}
/// ```no_run
/// let z = 55;
/// ```
fn should_have_no_runnable() {}
/// ```ignore
/// let z = 55;
/// ```
fn should_have_no_runnable_2() {}
/// ```compile_fail
/// let z = 55;
/// ```
fn should_have_no_runnable_3() {}
/// ```text
/// arbitrary plain text
/// ```
fn should_have_no_runnable_4() {}
/// ```text
/// arbitrary plain text
/// ```
///
/// ```sh
/// $ shell code
/// ```
fn should_have_no_runnable_5() {}
/// ```rust,no_run
/// let z = 55;
/// ```
fn should_have_no_runnable_6() {}
/// ```
/// let x = 5;
/// ```
struct StructWithRunnable(String);
"#,
&[&BIN, &DOCTEST, &DOCTEST, &DOCTEST, &DOCTEST, &DOCTEST, &DOCTEST],
expect![[r#"
[
Runnable {
nav: NavigationTarget {
file_id: FileId(
0,
),
full_range: 1..13,
focus_range: 4..8,
name: "main",
kind: Function,
},
kind: Bin,
cfg: None,
},
Runnable {
nav: NavigationTarget {
file_id: FileId(
0,
),
full_range: 15..74,
name: "should_have_runnable",
},
kind: DocTest {
test_id: Path(
"should_have_runnable",
),
},
cfg: None,
},
Runnable {
nav: NavigationTarget {
file_id: FileId(
0,
),
full_range: 76..148,
name: "should_have_runnable_1",
},
kind: DocTest {
test_id: Path(
"should_have_runnable_1",
),
},
cfg: None,
},
Runnable {
nav: NavigationTarget {
file_id: FileId(
0,
),
full_range: 150..254,
name: "should_have_runnable_2",
},
kind: DocTest {
test_id: Path(
"should_have_runnable_2",
),
},
cfg: None,
},
Runnable {
nav: NavigationTarget {
file_id: FileId(
0,
),
full_range: 256..320,
name: "should_have_no_runnable_3",
},
kind: DocTest {
test_id: Path(
"should_have_no_runnable_3",
),
},
cfg: None,
},
Runnable {
nav: NavigationTarget {
file_id: FileId(
0,
),
full_range: 322..398,
name: "should_have_no_runnable_4",
},
kind: DocTest {
test_id: Path(
"should_have_no_runnable_4",
),
},
cfg: None,
},
Runnable {
nav: NavigationTarget {
file_id: FileId(
0,
),
full_range: 900..965,
name: "StructWithRunnable",
},
kind: DocTest {
test_id: Path(
"StructWithRunnable",
),
},
cfg: None,
},
]
"#]],
);
} | rust_cleaned_test_functions.jsonl/2489 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 3780
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14007,
77,
4788,
18869,
4452,
368,
341,
286,
1779,
1006,
310,
435,
2,
698,
61463,
608,
2740,
25638,
198,
3,
15,
198,
8822,
1887,
368,
10086,
2575,
41233,
2575,
1077,
856,
284,
220,
20,
280,
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_enum_in_struct() {
let input = b"\x00\x00\x00\x00\x02";
let res = S1::parse(input);
assert_eq!(
res,
Ok((
&input[5..],
S1 {
msg_type: MessageType(0),
msg_value: U1::Field1(2)
}
))
);
} | rust_cleaned_test_functions.jsonl/96090 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 204
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31054,
1243,
15126,
368,
341,
262,
1077,
1946,
284,
293,
11934,
87,
15,
15,
3462,
15,
15,
3462,
15,
15,
3462,
15,
15,
3462,
15,
17,
876,
262,
1077,
592,
284,
328,
16,
486,
6400,
5384,
317,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_read_block_size() {
let test_data = [
(Some("1024".to_string()), 1024),
(Some("K".to_string()), 1024),
(None, 1024),
];
for it in &test_data {
assert_eq!(read_block_size(it.0.as_deref()), it.1);
}
} | rust_cleaned_test_functions.jsonl/21664 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 177
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
7113,
2368,
368,
341,
286,
1077,
1273,
1769,
284,
2278,
310,
320,
8373,
445,
16,
15,
17,
19,
3263,
983,
3904,
11858,
220,
16,
15,
17,
19,
1326,
310,
320,
8373,
445,
42,
3263,
983,
3904... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_dbpath_for_term() {
// woefully inadequate test coverage
use std::env;
fn x(t: &str) -> String {
let p = get_dbpath_for_term(t).expect("no terminfo entry found");
p.to_str().unwrap().to_string()
}
assert!(x("screen") == "/usr/share/terminfo/s/screen");
assert!(get_dbpath_for_term("") == None);
env::set_var("TERMINFO_DIRS", ":");
assert!(x("screen") == "/usr/share/terminfo/s/screen");
env::remove_var("TERMINFO_DIRS");
} | rust_cleaned_test_functions.jsonl/39428 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 232
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
8685,
2343,
5478,
17464,
368,
341,
262,
442,
23738,
72992,
45479,
1273,
10191,
7213,
262,
990,
1460,
486,
3160,
280,
1066,
262,
5168,
856,
1155,
25,
609,
495,
8,
1464,
923,
341,
286,
1077,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_app() {
let res = expression(Span::new("f 1"));
assert!(res.is_ok());
assert_eq!(
res.unwrap().1,
Expr::App(
Box::new(Expr::Ref("f")),
Box::new(Expr::Literal(Literal::Int64(1)))
)
)
} | rust_cleaned_test_functions.jsonl/32924 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 157
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8191,
368,
341,
262,
1077,
592,
284,
7493,
3759,
848,
486,
931,
445,
69,
220,
16,
14929,
262,
2060,
10297,
416,
2079,
19817,
5231,
262,
2060,
10714,
33673,
286,
592,
55395,
1005,
16,
345,
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_parse() {
assert_eq!(
parse_input_line(String::from("Step B must be finished before step E can begin.")),
Dependency { id: 'E', depends_on: 'B' }
)
} | rust_cleaned_test_functions.jsonl/5913 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 106
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
368,
341,
286,
2060,
10714,
33673,
310,
4715,
5898,
6528,
2242,
486,
1499,
445,
8304,
425,
1969,
387,
8060,
1573,
3019,
468,
646,
3161,
1189,
6965,
310,
32977,
314,
877,
25,
364,
36,
516,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_conflicting_recursive_skip_children() {
if !crate::is_nightly_channel!() {
return;
}
let toml = "skip_children = true\nrecursive = true";
// https://github.com/rust-lang/rust/issues/62358
match Config::from_toml(toml, Path::new("")) {
Ok(_) => panic!("Expected configuration error"),
Err(msg) => assert_eq!(
msg,
"Error: Conflicting config options `skip_children` and `recursive` are both enabled. `skip_children` has been deprecated and should be removed from your config.",
),
}
} | rust_cleaned_test_functions.jsonl/62925 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 309
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16059,
78208,
66242,
44830,
31206,
368,
341,
286,
421,
753,
61711,
486,
285,
1089,
71948,
14571,
0,
368,
341,
310,
470,
280,
286,
555,
286,
1077,
311,
1014,
284,
330,
20599,
31206,
284,
830,
169... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_csp_basic() {
let json = r#"{
"csp-report": {
"document-uri": "http://example.com",
"violated-directive": "style-src cdn.example.com",
"blocked-uri": "http://example.com/lol.css",
"effective-directive": "style-src"
}
}"#;
let mut event = Event::default();
Csp::apply_to_event(json.as_bytes(), &mut event).unwrap();
assert_annotated_snapshot!(Annotated::new(event), @r###"
{
"culprit": "style-src cdn.example.com",
"logentry": {
"formatted": "Blocked 'style' from 'example.com'"
},
"request": {
"url": "http://example.com"
},
"tags": [
[
"effective-directive",
"style-src"
],
[
"blocked-uri",
"http://example.com/lol.css"
]
],
"csp": {
"effective_directive": "style-src",
"blocked_uri": "http://example.com/lol.css",
"document_uri": "http://example.com",
"violated_directive": "style-src cdn.example.com"
}
}
"###);
} | rust_cleaned_test_functions.jsonl/4016 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 730
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
666,
2154,
34729,
368,
341,
286,
1077,
2951,
284,
435,
55543,
515,
310,
330,
66,
2154,
47411,
788,
341,
394,
330,
6062,
87232,
788,
330,
1254,
1110,
8687,
905,
756,
394,
330,
55151,
657,
43524,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_if() {
let tests = vec![
(
ScalarFuncSig::IfInt,
Datum::I64(1),
Datum::I64(1),
Datum::I64(2),
Datum::I64(1),
),
(
ScalarFuncSig::IfInt,
Datum::Null,
Datum::I64(1),
Datum::I64(2),
Datum::I64(2),
),
(
ScalarFuncSig::IfInt,
Datum::I64(0),
Datum::I64(1),
Datum::I64(2),
Datum::I64(2),
),
(
ScalarFuncSig::IfReal,
Datum::I64(1),
Datum::F64(1.1),
Datum::F64(2.2),
Datum::F64(1.1),
),
(
ScalarFuncSig::IfReal,
Datum::Null,
Datum::F64(1.1),
Datum::F64(2.2),
Datum::F64(2.2),
),
(
ScalarFuncSig::IfReal,
Datum::I64(0),
Datum::F64(1.1),
Datum::F64(2.2),
Datum::F64(2.2),
),
(
ScalarFuncSig::IfString,
Datum::I64(1),
Datum::Bytes(b"abc".to_vec()),
Datum::Bytes(b"abd".to_vec()),
Datum::Bytes(b"abc".to_vec()),
),
(
ScalarFuncSig::IfString,
Datum::Null,
Datum::Bytes(b"abc".to_vec()),
Datum::Bytes(b"abd".to_vec()),
Datum::Bytes(b"abd".to_vec()),
),
(
ScalarFuncSig::IfString,
Datum::I64(0),
Datum::Bytes(b"abc".to_vec()),
Datum::Bytes(b"abd".to_vec()),
Datum::Bytes(b"abd".to_vec()),
),
(
ScalarFuncSig::IfDecimal,
Datum::I64(1),
str2dec("1.123"),
str2dec("2.345"),
str2dec("1.123"),
),
(
ScalarFuncSig::IfDecimal,
Datum::Null,
str2dec("1.123"),
str2dec("2.345"),
str2dec("2.345"),
),
(
ScalarFuncSig::IfDecimal,
Datum::I64(0),
str2dec("1.123"),
str2dec("2.345"),
str2dec("2.345"),
),
(
ScalarFuncSig::IfDuration,
Datum::I64(1),
Datum::Dur(Duration::from_nanos(123, 1).unwrap()),
Datum::Dur(Duration::from_nanos(345, 2).unwrap()),
Datum::Dur(Duration::from_nanos(123, 1).unwrap()),
),
(
ScalarFuncSig::IfDuration,
Datum::Null,
Datum::Dur(Duration::from_nanos(123, 1).unwrap()),
Datum::Dur(Duration::from_nanos(345, 2).unwrap()),
Datum::Dur(Duration::from_nanos(345, 2).unwrap()),
),
(
ScalarFuncSig::IfDuration,
Datum::I64(0),
Datum::Dur(Duration::from_nanos(123, 1).unwrap()),
Datum::Dur(Duration::from_nanos(345, 2).unwrap()),
Datum::Dur(Duration::from_nanos(345, 2).unwrap()),
),
(
ScalarFuncSig::IfTime,
Datum::I64(0),
Datum::Time(Time::parse_utc_datetime("1970-01-01 12:00:00", 6).unwrap()),
Datum::Time(Time::parse_utc_datetime("1971-01-01 12:00:00", 6).unwrap()),
Datum::Time(Time::parse_utc_datetime("1971-01-01 12:00:00", 6).unwrap()),
),
(
ScalarFuncSig::IfJson,
Datum::I64(0),
Datum::Json(Json::I64(300)),
Datum::Json(Json::String("hello".to_owned())),
Datum::Json(Json::String("hello".to_owned())),
),
];
let ctx = EvalContext::default();
for (operator, cond, branch1, branch2, exp) in tests {
let arg1 = datum_expr(cond);
let arg2 = datum_expr(branch1);
let arg3 = datum_expr(branch2);
let expected = Expression::build(&ctx, datum_expr(exp)).unwrap();
let op = Expression::build(&ctx, fncall_expr(operator, &[arg1, arg2, arg3])).unwrap();
let lhs = op.eval(&ctx, &[]).unwrap();
let rhs = expected.eval(&ctx, &[]).unwrap();
assert_eq!(lhs, rhs);
}
} | rust_cleaned_test_functions.jsonl/32216 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 3111
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11119,
368,
341,
286,
1077,
7032,
284,
7486,
90515,
310,
2399,
394,
35176,
9626,
47246,
486,
2679,
1072,
345,
394,
68459,
486,
40,
21,
19,
7,
16,
1326,
394,
68459,
486,
40,
21,
19,
7,
16,
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... | 2 |
#[test]
fn test_hex_serializations_tenant_id() {
let original_struct = TestStruct {
field: Some(ZTenantId::from_array(hex!(
"11223344556677881122334455667788"
))),
};
let serialized_string = serde_json::to_string(&original_struct).unwrap();
assert_eq!(
serialized_string,
r#"{"field":"11223344556677881122334455667788"}"#
);
let deserialized_struct: TestStruct<FromHexError, ZTenantId> =
serde_json::from_str(&serialized_string).unwrap();
assert_eq!(original_struct, deserialized_struct);
} | rust_cleaned_test_functions.jsonl/124098 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 314
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
32655,
25602,
8040,
528,
25121,
842,
368,
341,
286,
1077,
4024,
15126,
284,
3393,
9422,
341,
310,
2070,
25,
4329,
27855,
71252,
764,
486,
1499,
3858,
44660,
33673,
394,
330,
16,
16,
17,
17,
18,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_serialize_info_refutation() {
#[cfg(not(feature = "chess"))]
let attributes: Vec<UciInfoAttribute> = vec![
UciInfoAttribute::Refutation(vec![
UciMove::from_to(
UciSquare::from('d', 1),
UciSquare::from('h', 5),
),
UciMove::from_to(
UciSquare::from('g', 6),
UciSquare::from('h', 5),
)
])
];
#[cfg(feature = "chess")]
let attributes: Vec<UciInfoAttribute> = vec![
UciInfoAttribute::Refutation(vec![
ChessMove::new(Square::D1, Square::H5, None),
ChessMove::new(Square::G6, Square::H5, None),
])
];
let m = UciMessage::Info(attributes);
assert_eq!(m.serialize(), "info refutation d1h5 g6h5");
} | rust_cleaned_test_functions.jsonl/19068 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 525
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
88686,
3109,
7793,
22705,
368,
341,
286,
11506,
14072,
24772,
27062,
284,
330,
331,
433,
2761,
921,
286,
1077,
8201,
25,
11312,
36397,
5855,
1731,
3907,
29,
284,
7486,
90515,
310,
547,
5855,
1731,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_valueende() {
let cnt = 500;
let dehdr = {
let hdr: MapxOrdRawKeyVs<usize> = MapxOrdRawKeyVs::new();
pnk!(hdr.version_create(VersionName(b"manster0")));
(0..cnt).map(|i: usize| (i, i)).for_each(|(key, value)| {
let key = <usize as ValueEnDe>::encode(&key);
assert!(pnk!(hdr.insert(key, value)).is_none());
});
<MapxOrdRawKeyVs<usize> as ValueEnDe>::encode(&hdr)
};
let reloaded = pnk!(<MapxOrdRawKeyVs<usize> as ValueEnDe>::decode(&dehdr));
assert_eq!(cnt, reloaded.len());
(0..cnt).map(|i: usize| i).for_each(|i| {
let key = <usize as ValueEnDe>::encode(&i);
assert_eq!(i, reloaded.get(&key).unwrap());
});
} | rust_cleaned_test_functions.jsonl/53985 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 383
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3142,
10938,
368,
341,
262,
1077,
13195,
284,
220,
20,
15,
15,
280,
262,
1077,
409,
28785,
284,
341,
286,
1077,
36615,
25,
5027,
87,
24621,
20015,
1592,
51737,
90244,
29,
284,
5027,
87,
24621,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_lints_tracking_hash_different_construction_order() {
let mut v1 = Options::default();
let mut v2 = Options::default();
v1.lint_opts = vec![
(String::from("a"), lint::Allow),
(String::from("b"), lint::Warn),
(String::from("c"), lint::Deny),
(String::from("d"), lint::Forbid),
];
v2.lint_opts = vec![
(String::from("a"), lint::Allow),
(String::from("c"), lint::Deny),
(String::from("b"), lint::Warn),
(String::from("d"), lint::Forbid),
];
assert_eq!(v1.dep_tracking_hash(), v2.dep_tracking_hash());
// Check clone
assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
} | rust_cleaned_test_functions.jsonl/44822 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 432
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
907,
21042,
66105,
8950,
82741,
3382,
3024,
7869,
368,
341,
286,
1077,
5206,
348,
16,
284,
14566,
486,
2258,
543,
286,
1077,
5206,
348,
17,
284,
14566,
486,
2258,
1428,
286,
348,
16,
918,
396,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_publickey_serialization() {
let elem = [0, 31, 183, 170, 199, 212, 167, 3, 66, 81, 201, 4, 241, 48, 79, 223, 24, 52, 101, 225, 116, 36, 166, 246, 213, 127, 77, 200, 154, 183, 73, 53, 249, 207, 6, 102, 170, 157, 11, 128, 177, 20, 254, 185, 15, 142, 231, 68, 0, 222, 228, 89, 156, 13, 254, 199, 91, 133, 241, 129, 173, 74, 215, 198, 210, 32, 83, 154, 161, 153, 255, 92, 239, 64, 69, 147, 39, 48, 118, 242, 26, 126, 220, 109, 229, 226, 101, 150, 25, 228, 38, 133, 96, 89, 73, 238, 0, 105, 186, 188, 162, 17, 191, 123, 4, 159, 165, 161, 68, 105, 85, 121, 63, 19, 169, 22, 165, 195, 165, 66, 206, 1, 108, 166, 186, 198, 49, 232, 110, 212, 243, 6, 4, 6, 2, 95, 165, 241, 12, 160, 98, 34, 217, 143, 1, 42, 244, 0, 161, 173, 241, 170, 146, 11, 183, 159, 9, 30, 138, 40, 3, 30, 231, 111, 97, 118, 217, 229, 221, 205, 106, 218, 224, 24, 116, 233, 237, 223, 225, 180, 55, 239, 219, 248, 119, 10, 49, 96, 145, 22, 219, 26];
let elem_result = PublicKey { pk: (G2Projective::generator() * &Scalar::from(5)) }.serialize();
assert_eq!(&elem[..], &elem_result[..]);
} | rust_cleaned_test_functions.jsonl/131746 | {
"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,
27074,
792,
25602,
2022,
368,
341,
262,
1077,
11750,
284,
508,
15,
11,
220,
18,
16,
11,
220,
16,
23,
18,
11,
220,
16,
22,
15,
11,
220,
16,
24,
24,
11,
220,
17,
16,
17,
11,
220,
16,
21,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_cache_put_at_capacity() {
let mut token_cache = TokenCache::new(CACHE_SIZE);
// Populate cache to capacity
let original_keys: Vec<TestKey> =
(0..CACHE_SIZE).map(|key_num| build_test_key(&key_num.to_string(), "")).collect();
for key in original_keys.iter() {
token_cache.put(key.clone(), build_test_token(LONG_EXPIRY, ""));
}
// Add one token past capacity
let new_key = build_test_key("extra", "");
token_cache.put(new_key.clone(), build_test_token(LONG_EXPIRY, ""));
assert!(token_cache.get(&new_key).is_some());
assert_eq!(original_keys.iter().filter(|key| token_cache.get(*key).is_none()).count(), 1);
assert_eq!(token_cache.token_map.len(), CACHE_SIZE);
// Adding a duplicate key when cache is at capacity shouldn't evict anything.
let mut token_cache = TokenCache::new(CACHE_SIZE);
for key in original_keys.iter() {
token_cache.put(key.clone(), build_test_token(LONG_EXPIRY, ""));
}
let dup_key = original_keys.iter().next().unwrap().clone();
token_cache.put(dup_key, build_test_token(LONG_EXPIRY, "duplicate"));
assert!(original_keys.iter().all(|key| token_cache.get(key).is_some()));
assert_eq!(token_cache.token_map.len(), CACHE_SIZE);
} | rust_cleaned_test_functions.jsonl/88814 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 616
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11529,
15557,
3752,
35603,
368,
341,
286,
1077,
5206,
3950,
11529,
284,
9660,
8233,
486,
931,
3025,
17810,
4098,
317,
286,
442,
70938,
6500,
311,
8654,
198,
286,
1077,
4024,
12631,
25,
11312,
7127... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_child_count() {
let container = [0u8; constants::MIN_ORDER_SIZE];
let block = get_reserved(&container);
assert!(block.become_node(2, 3).is_ok());
assert_eq!(container[..8], [0x31, 0x03, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00]);
assert_eq!(container[8..], [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
assert!(block.set_child_count(4).is_ok());
assert_eq!(block.child_count().unwrap(), 4);
assert_eq!(container[..8], [0x31, 0x03, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00]);
assert_eq!(container[8..], [0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
let types = BTreeSet::from_iter(vec![BlockType::Tombstone, BlockType::NodeValue]);
test_ok_types(move |b| b.child_count(), &types);
test_ok_types(move |b| b.set_child_count(3), &types);
} | rust_cleaned_test_functions.jsonl/100151 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 439
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17268,
3180,
368,
341,
286,
1077,
5476,
284,
508,
15,
84,
23,
26,
18021,
486,
16413,
26677,
4098,
935,
286,
1077,
2504,
284,
633,
74913,
2099,
3586,
317,
286,
2060,
10297,
4574,
948,
51421,
5084... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_build_upload_policy_with_save_key() -> Result<(), Box<dyn Error>> {
let policy = UploadPolicyBuilder::new_policy_for_bucket("test_bucket", &Config::default())
.save_as("target_file", false)
.build();
assert_eq!(policy.save_key(), Some("target_file"));
assert_eq!(policy.is_save_key_forced(), false);
let v: Value = serde_json::from_str(policy.as_json().as_str())?;
assert_eq!(v["saveKey"], "target_file");
assert_eq!(v["forceSaveKey"], json!(null));
Ok(())
} | rust_cleaned_test_functions.jsonl/2360 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 257
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20801,
21691,
22773,
6615,
15376,
3097,
368,
1464,
5714,
68843,
8261,
92846,
4600,
2452,
341,
286,
1077,
4842,
284,
24996,
13825,
3297,
486,
931,
22773,
5478,
38749,
445,
1944,
38749,
497,
609,
2648... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_invalid_method() {
let mut buff = AsyncBuffer::new("FOOBAR /hello HTTP/1.1\r\nHost: 0.0.0.0:8080\r\n\r\n");
let result = block_on(async { recognize(&mut buff).await });
assert!(result.is_err());
} | rust_cleaned_test_functions.jsonl/48179 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 100
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31433,
9032,
368,
341,
220,
1077,
5206,
11522,
284,
21433,
4095,
486,
931,
445,
3788,
20608,
934,
608,
14990,
10130,
14,
16,
13,
16,
12016,
1699,
9296,
25,
220,
15,
13,
15,
13,
15,
13,
15,
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_default() {
let builder = Builder::default();
assert!(builder.bin_builders.is_empty());
assert!(builder.intervals.is_empty());
assert_eq!(builder.start_position, bgzf::VirtualPosition::max());
assert_eq!(builder.end_position, bgzf::VirtualPosition::default());
assert_eq!(builder.mapped_record_count, 0);
assert_eq!(builder.unmapped_record_count, 0);
} | rust_cleaned_test_functions.jsonl/42568 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 183
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9993,
368,
341,
286,
1077,
7363,
284,
20626,
486,
2258,
1428,
286,
2060,
10297,
17850,
29394,
20801,
388,
2079,
15124,
1423,
286,
2060,
10297,
17850,
6403,
42198,
2079,
15124,
5231,
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_parse_key_without_info_and_with_description() {
let text = "AAAAA-BBBBB-CCCCC-DDDD -> Some game";
let parsed_input = parse_message(text);
assert_eq!(parsed_input.value, "AAAAA-BBBBB-CCCCC-DDDD");
assert_eq!(parsed_input.description, Some(format!("Some game")));
assert_eq!(parsed_input.object_info, None);
assert_eq!(parsed_input.object_type, ObjectType::Key);
} | rust_cleaned_test_functions.jsonl/97564 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 199
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
3097,
39904,
3109,
8378,
6615,
11448,
368,
341,
286,
1077,
1467,
284,
330,
25699,
32,
7671,
73442,
12,
47932,
34,
40175,
4103,
1464,
4329,
1809,
876,
286,
1077,
15676,
5898,
284,
4715,
6462... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_vcx_connection_connect() {
init!("true");
let cb = return_types_u32::Return_U32_STR::new().unwrap();
let rc = vcx_connection_connect(cb.command_handle, 0, CString::new("{}").unwrap().into_raw(), Some(cb.get_callback()));
assert_eq!(rc, error::INVALID_CONNECTION_HANDLE.code_num);
let handle = build_test_connection();
assert!(handle > 0);
let cb = return_types_u32::Return_U32_STR::new().unwrap();
let rc = vcx_connection_connect(cb.command_handle, handle, CString::new("{}").unwrap().into_raw(), Some(cb.get_callback()));
assert_eq!(rc, error::SUCCESS.code_num);
let invite_details = cb.receive(Some(Duration::from_secs(10))).unwrap();
assert!(invite_details.is_some());
} | rust_cleaned_test_functions.jsonl/25721 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 348
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2273,
25844,
15866,
15720,
368,
341,
286,
2930,
17223,
1866,
797,
286,
1077,
9858,
284,
470,
9763,
7300,
18,
17,
486,
5598,
6665,
18,
17,
7159,
486,
931,
1005,
15454,
543,
286,
1077,
10192,
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_schema_type_thrift_conversion_decimal() {
let message_type = "
message decimals {
OPTIONAL INT32 field0;
OPTIONAL INT64 field1 (DECIMAL (18, 2));
OPTIONAL FIXED_LEN_BYTE_ARRAY (16) field2 (DECIMAL (38, 18));
OPTIONAL BYTE_ARRAY field3 (DECIMAL (9));
}
";
let expected_schema = parse_message_type(message_type).unwrap();
let thrift_schema = to_thrift(&expected_schema).unwrap();
let result_schema = from_thrift(&thrift_schema).unwrap();
assert_eq!(result_schema, Arc::new(expected_schema));
} | rust_cleaned_test_functions.jsonl/16693 | {
"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,
25371,
1819,
5854,
41380,
64132,
74429,
368,
341,
286,
1077,
1943,
1819,
284,
6228,
262,
1943,
58328,
341,
414,
76232,
9221,
18,
17,
2070,
15,
280,
414,
76232,
9221,
21,
19,
2070,
16,
320,
30726... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_to_fixed_array() {
let bytes = rand_bytes(3);
let a = to_fixed_array::<3>(&bytes);
let mut b = [0u8; 3];
b.copy_from_slice(&bytes);
assert_eq!(a, b);
} | rust_cleaned_test_functions.jsonl/48677 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 120
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2346,
37839,
3858,
368,
341,
286,
1077,
5820,
284,
10382,
12524,
7,
18,
317,
286,
1077,
264,
284,
311,
37839,
3858,
27638,
18,
44784,
9651,
317,
286,
1077,
5206,
293,
284,
508,
15,
84,
23,
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_division_assignment() {
let mut length: Length<f32, Mm> = Length::new(10.0);
length /= 2.0;
let expected: Length<f32, Mm> = Length::new(5.0);
assert_eq!(length, expected);
} | rust_cleaned_test_functions.jsonl/50589 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 114
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16237,
1816,
51891,
368,
341,
286,
1077,
5206,
3084,
25,
17287,
63895,
18,
17,
11,
386,
76,
29,
284,
17287,
486,
931,
7,
16,
15,
13,
15,
626,
286,
3084,
16455,
220,
17,
13,
15,
401,
286,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_verify_three_element_sparse_merkle() {
// root
// a default
// key1 b
// key2 key3
let key1 = b"hello".test_only_hash();
let key2 = b"world".test_only_hash();
let key3 = b"!".test_only_hash();
assert_eq!(key1[0], 0b0011_0011);
assert_eq!(key2[0], 0b0100_0010);
assert_eq!(key3[0], 0b0110_1001);
let blob1 = AccountStateBlob::from(b"1".to_vec());
let blob2 = AccountStateBlob::from(b"2".to_vec());
let blob3 = AccountStateBlob::from(b"3".to_vec());
let leaf1 = SparseMerkleLeafNode::new(key1, blob1.hash());
let leaf1_hash = leaf1.hash();
let leaf2_hash = SparseMerkleLeafNode::new(key2, blob2.hash()).hash();
let leaf3_hash = SparseMerkleLeafNode::new(key3, blob3.hash()).hash();
let internal_b_hash = SparseMerkleInternalNode::new(leaf2_hash, leaf3_hash).hash();
let internal_a_hash = SparseMerkleInternalNode::new(leaf1_hash, internal_b_hash).hash();
let root_hash =
SparseMerkleInternalNode::new(internal_a_hash, *SPARSE_MERKLE_PLACEHOLDER_HASH).hash();
let non_existing_key1 = b"abc".test_only_hash();
let non_existing_key2 = b"def".test_only_hash();
assert_eq!(non_existing_key1[0], 0b0011_1010);
assert_eq!(non_existing_key2[0], 0b1000_1110);
{
// Construct a proof of key1.
let proof = SparseMerkleProof::new(
Some(leaf1),
vec![internal_b_hash, *SPARSE_MERKLE_PLACEHOLDER_HASH],
);
// The exact key value exists.
assert!(proof.verify(root_hash, key1, Some(&blob1)).is_ok());
// Trying to show that this key has another value.
assert!(proof.verify(root_hash, key1, Some(&blob2)).is_err());
// Trying to show that this key doesn't exist.
assert!(proof.verify(root_hash, key1, None).is_err());
// This proof can't be used to show anything about key2.
assert!(proof.verify(root_hash, key2, None).is_err());
assert!(proof.verify(root_hash, key2, Some(&blob1)).is_err());
assert!(proof.verify(root_hash, key2, Some(&blob2)).is_err());
// This proof can be used to show that non_existing_key1 indeed doesn't exist.
assert!(proof.verify(root_hash, non_existing_key1, None).is_ok());
// This proof can't be used to show that non_existing_key2 doesn't exist because it lives
// in a different subtree.
assert!(proof.verify(root_hash, non_existing_key2, None).is_err());
}
{
// Construct a proof of the default node.
let proof = SparseMerkleProof::new(None, vec![internal_a_hash]);
// This proof can't be used to show that a key starting with 0 doesn't exist.
assert!(proof.verify(root_hash, non_existing_key1, None).is_err());
// This proof can be used to show that a key starting with 1 doesn't exist.
assert!(proof.verify(root_hash, non_existing_key2, None).is_ok());
}
} | rust_cleaned_test_functions.jsonl/33627 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1313
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
35638,
50016,
7894,
71123,
717,
16754,
273,
368,
341,
262,
442,
310,
3704,
7213,
262,
442,
688,
264,
414,
1638,
7213,
262,
442,
257,
1376,
16,
256,
293,
7213,
262,
442,
981,
1376,
17,
256,
137... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_payment_txn() {
settings::set_defaults();
settings::set_config_value(settings::CONFIG_ENABLE_TEST_MODE,"true");
let handle = credential::from_string(::utils::constants::FULL_CREDENTIAL_SERIALIZED).unwrap();
vcx_credential_get_payment_txn(0, handle, Some(get_offers_cb));
thread::sleep(Duration::from_millis(200));
} | rust_cleaned_test_functions.jsonl/7553 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 169
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
26696,
92299,
368,
341,
286,
5003,
486,
746,
42290,
543,
286,
5003,
486,
746,
5332,
3142,
23369,
486,
24652,
14379,
11641,
8414,
1335,
1866,
3071,
286,
1077,
3705,
284,
40207,
486,
1499,
390... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_mul_scale() {
let s = SideOffsets2DMm::new(0.0, 1.0, 3.0, 2.0);
let cm_per_mm: Scale<f32, Mm, Cm> = Scale::new(0.1);
let result = s * cm_per_mm;
assert_eq!(result, SideOffsets2DCm::new(0.0, 0.1, 0.3, 0.2));
} | rust_cleaned_test_functions.jsonl/96607 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 155
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
24944,
16727,
368,
341,
286,
1077,
274,
284,
16659,
81095,
17,
8395,
76,
486,
931,
7,
15,
13,
15,
11,
220,
16,
13,
15,
11,
220,
18,
13,
15,
11,
220,
17,
13,
15,
317,
286,
1077,
9961,
567... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_compile() {
let _chrono = chrono::Utc::now(); // chrono
let _rw = sync::RwLock::new(10);
info!("Message {}", *TEST);
let _regex = regex::Regex::new("[abc]+").unwrap();
url::Url::parse("http://abc.ru").unwrap();
let _ = percent_encoding::utf8_percent_encode("abc", percent_encoding::NON_ALPHANUMERIC);
let mut cur = std::io::Cursor::new(vec![0u8; 8]);
let _be = cur.read_u64::<byteorder::BigEndian>().unwrap();
let name = "SomeName";
let _ = may_throw();
format_f!("My name is {name}");
} | rust_cleaned_test_functions.jsonl/82841 | {
"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,
74170,
368,
341,
262,
1077,
716,
25768,
284,
80372,
486,
97768,
486,
3328,
2129,
442,
80372,
198,
262,
1077,
716,
31768,
284,
12811,
486,
49,
86,
11989,
486,
931,
7,
16,
15,
317,
262,
3546,
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_infer_nhwc_1() {
let mut op = Conv::default().nhwc().hwio().padding(PaddingSpec::SameUpper);
let ifact = InferenceFact::dt_shape(DatumType::F32, shapefactoid!(1, 2, 2, 2));
let kfact = InferenceFact::dt_shape(DatumType::F32, shapefactoid!(2, 2, 2, 1));
let ofact = InferenceFact::default();
let facts = op.infer_facts(tvec!(&ifact, &kfact), tvec!(&ofact), tvec!()).unwrap();
assert_eq!(
facts.1,
tvec!(InferenceFact::dt_shape(DatumType::F32, shapefactoid!(1, 2, 2, 1)))
);
} | rust_cleaned_test_functions.jsonl/51974 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 285
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1243,
802,
93934,
24028,
62,
16,
368,
341,
286,
1077,
5206,
1179,
284,
28988,
486,
2258,
1005,
16719,
24028,
1005,
27827,
815,
1005,
9571,
5304,
2998,
8327,
486,
19198,
14251,
317,
286,
1077,
421,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_notnull_constraint_error() -> Result<()> {
let db = checked_memory_handle();
db.execute_batch("CREATE TABLE foo(x TEXT NOT NULL)")?;
let result = db.execute("INSERT INTO foo (x) VALUES (NULL)", []);
assert!(result.is_err());
match result.unwrap_err() {
Error::DuckDBFailure(err, _) => {
assert_eq!(err.code, ErrorCode::Unknown);
}
err => panic!("Unexpected error {}", err),
}
Ok(())
} | rust_cleaned_test_functions.jsonl/113060 | {
"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,
7913,
2921,
46973,
4096,
368,
1464,
5714,
71698,
341,
286,
1077,
2927,
284,
10067,
19195,
10630,
543,
286,
2927,
7769,
14534,
445,
22599,
14363,
15229,
2075,
15762,
4183,
1770,
68191,
69493,
286,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_query_transaction_history() {
let (init_result, mut deps) = init_helper_with_config(
vec![InitialBalance {
address: HumanAddr("bob".to_string()),
amount: Uint128(10000),
}],
true,
true,
true,
true,
1000,
);
assert!(
init_result.is_ok(),
"Init failed: {}",
init_result.err().unwrap()
);
let handle_msg = HandleMsg::SetViewingKey {
key: "key".to_string(),
padding: None,
};
let handle_result = handle(&mut deps, mock_env("bob", &[]), handle_msg);
assert!(ensure_success(handle_result.unwrap()));
let handle_msg = HandleMsg::Burn {
amount: Uint128(1),
memo: Some("my burn message".to_string()),
padding: None,
};
let handle_result = handle(&mut deps, mock_env("bob", &[]), handle_msg);
assert!(
handle_result.is_ok(),
"Pause handle failed: {}",
handle_result.err().unwrap()
);
let handle_msg = HandleMsg::Redeem {
amount: Uint128(1000),
denom: None,
padding: None,
};
let handle_result = handle(&mut deps, mock_env("bob", &[]), handle_msg);
assert!(
handle_result.is_ok(),
"handle() failed: {}",
handle_result.err().unwrap()
);
let handle_msg = HandleMsg::Mint {
recipient: HumanAddr("bob".to_string()),
amount: Uint128(100),
memo: Some("my mint message".to_string()),
padding: None,
};
let handle_result = handle(&mut deps, mock_env("admin", &[]), handle_msg);
assert!(ensure_success(handle_result.unwrap()));
let handle_msg = HandleMsg::Deposit { padding: None };
let handle_result = handle(
&mut deps,
mock_env(
"bob",
&[Coin {
denom: "uscrt".to_string(),
amount: Uint128(1000),
}],
),
handle_msg,
);
assert!(
handle_result.is_ok(),
"handle() failed: {}",
handle_result.err().unwrap()
);
let handle_msg = HandleMsg::Transfer {
recipient: HumanAddr("alice".to_string()),
amount: Uint128(1000),
memo: Some("my transfer message #1".to_string()),
padding: None,
};
let handle_result = handle(&mut deps, mock_env("bob", &[]), handle_msg);
let result = handle_result.unwrap();
assert!(ensure_success(result));
let handle_msg = HandleMsg::Transfer {
recipient: HumanAddr("banana".to_string()),
amount: Uint128(500),
memo: Some("my transfer message #2".to_string()),
padding: None,
};
let handle_result = handle(&mut deps, mock_env("bob", &[]), handle_msg);
let result = handle_result.unwrap();
assert!(ensure_success(result));
let handle_msg = HandleMsg::Transfer {
recipient: HumanAddr("mango".to_string()),
amount: Uint128(2500),
memo: Some("my transfer message #3".to_string()),
padding: None,
};
let handle_result = handle(&mut deps, mock_env("bob", &[]), handle_msg);
let result = handle_result.unwrap();
assert!(ensure_success(result));
let query_msg = QueryMsg::TransferHistory {
address: HumanAddr("bob".to_string()),
key: "key".to_string(),
page: None,
page_size: 10,
};
let query_result = query(&deps, query_msg);
let transfers = match from_binary(&query_result.unwrap()).unwrap() {
QueryAnswer::TransferHistory { txs, .. } => txs,
_ => panic!("Unexpected"),
};
assert_eq!(transfers.len(), 3);
let query_msg = QueryMsg::TransactionHistory {
address: HumanAddr("bob".to_string()),
key: "key".to_string(),
page: None,
page_size: 10,
};
let query_result = query(&deps, query_msg);
let transfers = match from_binary(&query_result.unwrap()).unwrap() {
QueryAnswer::TransactionHistory { txs, .. } => txs,
other => panic!("Unexpected: {:?}", other),
};
use crate::transaction_history::{RichTx, TxAction};
let expected_transfers = [
RichTx {
id: 8,
action: TxAction::Transfer {
from: HumanAddr("bob".to_string()),
sender: HumanAddr("bob".to_string()),
recipient: HumanAddr("mango".to_string()),
},
coins: Coin {
denom: "SECSEC".to_string(),
amount: Uint128(2500),
},
memo: Some("my transfer message #3".to_string()),
block_time: 1571797419,
block_height: 12345,
},
RichTx {
id: 7,
action: TxAction::Transfer {
from: HumanAddr("bob".to_string()),
sender: HumanAddr("bob".to_string()),
recipient: HumanAddr("banana".to_string()),
},
coins: Coin {
denom: "SECSEC".to_string(),
amount: Uint128(500),
},
memo: Some("my transfer message #2".to_string()),
block_time: 1571797419,
block_height: 12345,
},
RichTx {
id: 6,
action: TxAction::Transfer {
from: HumanAddr("bob".to_string()),
sender: HumanAddr("bob".to_string()),
recipient: HumanAddr("alice".to_string()),
},
coins: Coin {
denom: "SECSEC".to_string(),
amount: Uint128(1000),
},
memo: Some("my transfer message #1".to_string()),
block_time: 1571797419,
block_height: 12345,
},
RichTx {
id: 5,
action: TxAction::Deposit {},
coins: Coin {
denom: "uscrt".to_string(),
amount: Uint128(1000),
},
memo: None,
block_time: 1571797419,
block_height: 12345,
},
RichTx {
id: 4,
action: TxAction::Mint {
minter: HumanAddr("admin".to_string()),
recipient: HumanAddr("bob".to_string()),
},
coins: Coin {
denom: "SECSEC".to_string(),
amount: Uint128(100),
},
memo: Some("my mint message".to_string()),
block_time: 1571797419,
block_height: 12345,
},
RichTx {
id: 3,
action: TxAction::Redeem {},
coins: Coin {
denom: "SECSEC".to_string(),
amount: Uint128(1000),
},
memo: None,
block_time: 1571797419,
block_height: 12345,
},
RichTx {
id: 2,
action: TxAction::Burn {
burner: HumanAddr("bob".to_string()),
owner: HumanAddr("bob".to_string()),
},
coins: Coin {
denom: "SECSEC".to_string(),
amount: Uint128(1),
},
memo: Some("my burn message".to_string()),
block_time: 1571797419,
block_height: 12345,
},
RichTx {
id: 1,
action: TxAction::Mint {
minter: HumanAddr("admin".to_string()),
recipient: HumanAddr("bob".to_string()),
},
coins: Coin {
denom: "SECSEC".to_string(),
amount: Uint128(10000),
},
memo: Some("Initial Balance".to_string()),
block_time: 1571797419,
block_height: 12345,
},
];
assert_eq!(transfers, expected_transfers);
} | rust_cleaned_test_functions.jsonl/69632 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 4946
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5738,
28884,
19802,
368,
341,
286,
1077,
320,
2327,
5287,
11,
5206,
48178,
8,
284,
2930,
10418,
6615,
5332,
1006,
310,
7486,
20703,
6341,
21190,
341,
394,
2621,
25,
11097,
13986,
445,
47086,
3263,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_upgrade() {
let root = init_simulator(None);
let test_user = root.create_user("test".to_string(), to_yocto("100"));
let farming = deploy!(
contract: Farming,
contract_id: "farming".to_string(),
bytes: &PREV_FARMING_WASM_BYTES,
signer_account: root,
init_method: new(ValidAccountId::try_from(root.account_id.clone()).unwrap())
);
// Failed upgrade with no permissions.
let result = test_user
.call(
farming.user_account.account_id.clone(),
"upgrade",
&PREV_FARMING_WASM_BYTES,
near_sdk_sim::DEFAULT_GAS,
0,
)
.status();
assert!(format!("{:?}", result).contains("ERR_NOT_ALLOWED"));
// Upgrade with calling migration. Should fail as currently migration not implemented
root.call(
farming.user_account.account_id.clone(),
"upgrade",
&FARMING_WASM_BYTES,
near_sdk_sim::DEFAULT_GAS,
0,
)
.assert_success();
// Upgrade to the same code without migration is successful.
root.call(
farming.user_account.account_id.clone(),
"upgrade",
&FARMING_WASM_BYTES,
near_sdk_sim::DEFAULT_GAS,
0,
)
.assert_success();
} | rust_cleaned_test_functions.jsonl/15409 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 619
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
67794,
368,
341,
262,
1077,
3704,
284,
2930,
18314,
10511,
26717,
317,
262,
1077,
1273,
3317,
284,
3704,
2520,
3317,
445,
1944,
3263,
983,
3904,
1507,
311,
4178,
41692,
78,
445,
16,
15,
15,
4010... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_byte_array() {
let mut buf = vec![255; 8];
let arr = [2u8, 5, 2, 3, 56, 3];
Field::write(&arr.as_ref(), &mut buf, 0, 8);
<&[u8] as Field>::check(&buf, 0.into(), 8.into(), 8.into()).unwrap();
let buf2 = buf.clone();
<&[u8] as Field>::check(&buf2, 0.into(), 8.into(), 8.into()).unwrap();
let dat2: &[u8] = unsafe { Field::read(&buf2, 0, 8) };
assert_eq!(dat2, arr);
assert_eq!(buf.len(), 8 + arr.len());
} | rust_cleaned_test_functions.jsonl/118848 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 222
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19737,
3858,
368,
341,
262,
1077,
5206,
6607,
284,
7486,
20703,
17,
20,
20,
26,
220,
23,
935,
262,
1077,
2890,
284,
508,
17,
84,
23,
11,
220,
20,
11,
220,
17,
11,
220,
18,
11,
220,
20,
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_iterator_size_hint() {
let c = (0..).step_by(1);
let v: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
let v2 = &[10, 11, 12];
let vi = v.iter();
assert_eq!(c.size_hint(), (usize::MAX, None));
assert_eq!(vi.clone().size_hint(), (10, Some(10)));
assert_eq!(c.clone().take(5).size_hint(), (5, Some(5)));
assert_eq!(c.clone().skip(5).size_hint().1, None);
assert_eq!(c.clone().take_while(|_| false).size_hint(), (0, None));
assert_eq!(c.clone().skip_while(|_| false).size_hint(), (0, None));
assert_eq!(c.clone().enumerate().size_hint(), (usize::MAX, None));
assert_eq!(c.clone().chain(vi.clone().cloned()).size_hint(), (usize::MAX, None));
assert_eq!(c.clone().zip(vi.clone()).size_hint(), (10, Some(10)));
assert_eq!(c.clone().scan(0, |_,_| Some(0)).size_hint(), (0, None));
assert_eq!(c.clone().filter(|_| false).size_hint(), (0, None));
assert_eq!(c.clone().map(|_| 0).size_hint(), (usize::MAX, None));
assert_eq!(c.filter_map(|_| Some(0)).size_hint(), (0, None));
assert_eq!(vi.clone().take(5).size_hint(), (5, Some(5)));
assert_eq!(vi.clone().take(12).size_hint(), (10, Some(10)));
assert_eq!(vi.clone().skip(3).size_hint(), (7, Some(7)));
assert_eq!(vi.clone().skip(12).size_hint(), (0, Some(0)));
assert_eq!(vi.clone().take_while(|_| false).size_hint(), (0, Some(10)));
assert_eq!(vi.clone().skip_while(|_| false).size_hint(), (0, Some(10)));
assert_eq!(vi.clone().enumerate().size_hint(), (10, Some(10)));
assert_eq!(vi.clone().chain(v2).size_hint(), (13, Some(13)));
assert_eq!(vi.clone().zip(v2).size_hint(), (3, Some(3)));
assert_eq!(vi.clone().scan(0, |_,_| Some(0)).size_hint(), (0, Some(10)));
assert_eq!(vi.clone().filter(|_| false).size_hint(), (0, Some(10)));
assert_eq!(vi.clone().map(|&i| i+1).size_hint(), (10, Some(10)));
assert_eq!(vi.filter_map(|_| Some(0)).size_hint(), (0, Some(10)));
} | rust_cleaned_test_functions.jsonl/25928 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 926
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13491,
2368,
45825,
368,
341,
262,
1077,
272,
284,
320,
15,
496,
568,
9520,
3710,
7,
16,
317,
262,
1077,
348,
25,
609,
13496,
60,
284,
44590,
15,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ledger_db_initialization() {
let ledger_db = create_db();
assert_eq!(ledger_db.num_blocks().unwrap(), 0);
assert_eq!(ledger_db.num_txos().unwrap(), 0);
} | rust_cleaned_test_functions.jsonl/89687 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 100
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
38367,
1389,
8685,
15809,
2022,
368,
341,
286,
1077,
46933,
8685,
284,
1855,
8685,
543,
286,
2060,
10714,
10297,
50704,
8685,
10522,
25201,
1005,
15454,
1507,
220,
15,
317,
286,
2060,
10714,
10297,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_single() {
struct Foo;
impl Debug for Foo {
fn fmt(&self, fmt: &mut Formatter) {
fmt.debug_tuple("Foo").field(&true).finish()
}
}
assert_eq!("Foo(true)", debug3::pprint(Foo));
} | rust_cleaned_test_functions.jsonl/124749 | {
"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,
19487,
368,
341,
286,
2036,
33428,
401,
286,
11605,
11091,
369,
33428,
341,
310,
5168,
8879,
2099,
721,
11,
8879,
25,
609,
6984,
81387,
8,
341,
394,
8879,
7883,
21773,
445,
40923,
1827,
2566,
20... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_rfc3164_decode_invalid_event() {
let msg = "test message";
let cfg = Config::from_string("[input]\n[input.ltsv_schema]\nformat = \"rfc3164\"\n").unwrap();
let decoder = RFC3164Decoder::new(&cfg);
let res = decoder.decode(msg);
assert!(res.is_err());
} | rust_cleaned_test_functions.jsonl/100808 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 132
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1710,
8316,
18,
16,
21,
19,
15227,
31433,
6748,
368,
341,
262,
1077,
3750,
284,
330,
1944,
1943,
876,
262,
1077,
13286,
284,
5532,
486,
1499,
3904,
10937,
1355,
17960,
77,
74039,
918,
2576,
85,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ignore_px_from_negative_scored_peer() {
let config = GossipsubConfig::default();
//build mesh with one peer
let (mut gs, peers, topics) = inject_nodes1()
.peer_no(1)
.topics(vec!["test".into()])
.to_subscribe(true)
.gs_config(config.clone())
.scoring(Some((
PeerScoreParams::default(),
PeerScoreThresholds::default(),
)))
.create_network();
//penalize peer
gs.peer_score.as_mut().unwrap().0.add_penalty(&peers[0], 1);
//handle prune from single peer with px peers
let px = vec![PeerInfo {
peer_id: Some(PeerId::random()),
}];
gs.handle_prune(
&peers[0],
vec![(
topics[0].clone(),
px.clone(),
Some(config.prune_backoff().as_secs()),
)],
);
//assert no dials
assert_eq!(
gs.events
.iter()
.filter(|e| match e {
NetworkBehaviourAction::DialPeer { .. } => true,
_ => false,
})
.count(),
0
);
} | rust_cleaned_test_functions.jsonl/66910 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 741
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
58493,
67162,
5673,
53865,
10405,
67,
45159,
368,
341,
286,
1077,
2193,
284,
479,
41473,
1966,
2648,
486,
2258,
1428,
286,
442,
5834,
11294,
448,
825,
14397,
198,
286,
1077,
320,
6984,
28081,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_rod_cutting() {
assert_eq!(8, rod_cutting(&mut vec![1, 2, 3, 4, 5, 6, 7, 8]));
assert_eq!(22, rod_cutting(&mut vec![1, 5, 8, 9, 10, 17, 17, 20]));
assert_eq!(13, rod_cutting(&mut vec![1, 5, 8, 9, 10]));
} | rust_cleaned_test_functions.jsonl/56981 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 138
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
23505,
41317,
1280,
368,
341,
286,
2060,
10714,
10297,
23,
11,
20589,
41317,
1280,
2099,
6984,
7486,
20703,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11,
220,
21,
11,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_binary_string() {
let ddl = "
CREATE TABLE IF NOT EXISTS clickhouse_binary_string (
text String,
fx_text FixedString(4),
opt_text Nullable(String),
fx_opt_text Nullable(FixedString(4))
) Engine=Memory";
let query = "
SELECT
text,
fx_text,
opt_text,
fx_opt_text
FROM clickhouse_binary_string";
let block = Block::new()
.column("text", vec![vec![0_u8, 159, 146, 150]])
.column("fx_text", vec![vec![0_u8, 159, 146, 150]])
.column("opt_text", vec![Some(vec![0_u8, 159, 146, 150])])
.column("fx_opt_text", vec![Some(vec![0_u8, 159, 146, 150])]);
let pool = Pool::new(database_url());
let done = pool
.get_handle()
.and_then(|c| c.execute("DROP TABLE IF EXISTS clickhouse_binary_string"))
.and_then(move |c| c.execute(ddl))
.and_then(move |c| c.insert("clickhouse_binary_string", block))
.and_then(move |c| c.query(query).fetch_all())
.and_then(move |(_, block)| {
let text: &[u8] = block.get(0, "text")?;
let fx_text: &[u8] = block.get(0, "fx_text")?;
let opt_text: Option<&[u8]> = block.get(0, "opt_text")?;
let fx_opt_text: Option<&[u8]> = block.get(0, "fx_opt_text")?;
assert_eq!(1, block.row_count());
assert_eq!([0, 159, 146, 150].as_ref(), text);
assert_eq!([0, 159, 146, 150].as_ref(), fx_text);
assert_eq!(Some([0, 159, 146, 150].as_ref()), opt_text);
assert_eq!(Some([0, 159, 146, 150].as_ref()), fx_opt_text);
Ok(())
});
run(done).unwrap();
} | rust_cleaned_test_functions.jsonl/30940 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 931
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31761,
3904,
368,
341,
262,
1077,
55780,
284,
6228,
286,
30776,
14363,
11551,
4183,
34839,
4205,
7675,
31761,
3904,
2399,
310,
1467,
286,
923,
345,
310,
33219,
4326,
257,
20149,
703,
7,
19,
1326,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
#[test]
fn test_unknown_union() -> Result<()> {
// See unknownUnion
// Build the empty union
let u = Un::default();
let s = String::from_utf8(serialize(&u).to_vec()).unwrap();
let expected_string = "{}";
assert_eq!(expected_string, s);
// Assert that deserialize builts the exact same struct
assert_eq!(u, deserialize(s).unwrap());
// extra weirdness
// Build an explicit unknown
let explicit_unknown = Un::UnknownField(100);
let s2 = String::from_utf8(serialize(&explicit_unknown).to_vec()).unwrap();
let expected_string = "{}";
assert_eq!(expected_string, s2);
// protocols behavior
assert_eq!(u, deserialize(s2).unwrap());
// backwards compat test
let old_output = r#"{
"UnknownField":-1
}"#
.replace(" ", "")
.replace("\n", "");
assert_eq!(u, deserialize(old_output).unwrap());
Ok(())
} | rust_cleaned_test_functions.jsonl/122584 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 367
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
57507,
51621,
368,
1464,
5714,
71698,
341,
262,
442,
3496,
9788,
32658,
271,
262,
442,
7854,
279,
4287,
11300,
198,
262,
1077,
575,
284,
1230,
486,
2258,
1428,
262,
1077,
274,
284,
923,
486,
149... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_temp_field_unnamed() {
#[deku_derive(DekuRead, DekuWrite)]
#[derive(PartialEq, Debug)]
struct TestStruct(#[deku(temp)] u8, #[deku(count = "field_0")] Vec<u8>);
let test_data: Vec<u8> = [0x01, 0x02].to_vec();
let ret_read = TestStruct::try_from(test_data.as_ref()).unwrap();
assert_eq!(TestStruct(vec![0x02]), ret_read);
let ret_write: Vec<u8> = ret_read.try_into().unwrap();
assert_eq!(test_data[1..].to_vec(), ret_write);
} | rust_cleaned_test_functions.jsonl/97094 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 230
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11771,
5013,
4907,
30245,
368,
341,
262,
11506,
450,
12133,
35345,
533,
5432,
1225,
84,
4418,
11,
74463,
84,
7985,
5563,
262,
11506,
27098,
5304,
20894,
27312,
11,
11091,
5563,
262,
2036,
3393,
94... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_select_except() {
let df = df! {
"foo" => &[1, 1, 2, 2, 3],
"bar" => &[1.0, 1.0, 2.0, 2.0, 3.0],
"ham" => &[1.0, 1.0, 2.0, 2.0, 3.0]
}
.unwrap();
let out = df
.lazy()
.select(&[col("*"), except("foo")])
.collect()
.unwrap();
assert_eq!(out.get_column_names(), &["ham", "bar"]);
} | rust_cleaned_test_functions.jsonl/14684 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 276
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13051,
54633,
368,
341,
286,
1077,
6764,
284,
6764,
0,
341,
310,
330,
7975,
1,
589,
44590,
16,
11,
220,
16,
11,
220,
17,
11,
220,
17,
11,
220,
18,
1259,
310,
330,
2257,
1,
589,
44590,
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_bool() {
let array = BooleanArray::from(vec![Some(false), Some(true), None, Some(false)]);
let mut a = GrowableBoolean::new(&[&array], false, 0);
a.extend(0, 1, 2);
let result: BooleanArray = a.into();
let expected = BooleanArray::from(vec![Some(true), None]);
assert_eq!(result, expected);
} | rust_cleaned_test_functions.jsonl/114560 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 162
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
22159,
368,
341,
286,
1077,
1334,
284,
6992,
1857,
486,
1499,
25592,
20703,
8373,
3576,
701,
4329,
3715,
701,
2240,
11,
4329,
3576,
7252,
626,
286,
1077,
5206,
264,
284,
479,
14941,
6890,
486,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.