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_add_assign() {
let mut vector = Vector3D::new(3, 4, 5);
vector += Vector3D::new(10, 20, 30);
assert_eq!(vector, Vector3D::from([13, 24, 35]));
} | rust_cleaned_test_functions.jsonl/21639 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 115
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
20688,
368,
341,
310,
1077,
5206,
4621,
284,
4196,
18,
35,
486,
931,
7,
18,
11,
220,
19,
11,
220,
20,
317,
310,
4621,
1421,
4196,
18,
35,
486,
931,
7,
16,
15,
11,
220,
17,
15,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_append() {
let mut column1 = VectorValue::with_capacity(0, EvalType::Real);
let mut column2 = VectorValue::with_capacity(3, EvalType::Real);
column1.append(&mut column2);
assert_eq!(column1.len(), 0);
assert_eq!(column1.capacity(), 0);
assert_eq!(column2.len(), 0);
assert_eq!(column2.capacity(), 3);
column2.push_real(Real::new(1.0).ok());
column2.append(&mut column1);
assert_eq!(column1.len(), 0);
assert_eq!(column1.capacity(), 0);
assert_eq!(column1.to_real_vec(), &[]);
assert_eq!(column2.len(), 1);
assert_eq!(column2.capacity(), 3);
assert_eq!(column2.to_real_vec(), &[Real::new(1.0).ok()]);
column1.push_real(None);
column1.push_real(None);
column1.append(&mut column2);
assert_eq!(column1.len(), 3);
assert!(column1.capacity() > 0);
assert_eq!(column1.to_real_vec(), &[None, None, Real::new(1.0).ok()]);
assert_eq!(column2.len(), 0);
assert_eq!(column2.capacity(), 3);
assert_eq!(column2.to_real_vec(), &[]);
column1.push_real(Real::new(1.1).ok());
column2.push_real(Real::new(3.5).ok());
column2.push_real(Real::new(4.1).ok());
column2.truncate(1);
column2.append(&mut column1);
assert_eq!(column1.len(), 0);
assert!(column1.capacity() > 0);
assert_eq!(column1.to_real_vec(), &[]);
assert_eq!(column2.len(), 5);
assert!(column2.capacity() > 3);
assert_eq!(
column2.to_real_vec(),
&[
Real::new(3.5).ok(),
None,
None,
Real::new(1.0).ok(),
Real::new(1.1).ok()
]
);
} | rust_cleaned_test_functions.jsonl/79386 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 945
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26041,
368,
341,
286,
1077,
5206,
3250,
16,
284,
4196,
1130,
486,
4197,
35603,
7,
15,
11,
58239,
929,
486,
12768,
317,
286,
1077,
5206,
3250,
17,
284,
4196,
1130,
486,
4197,
35603,
7,
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_get_proof_request() {
init!("true");
let connection_h = connection::tests::build_test_connection();
let request = get_proof_request(connection_h, "123").unwrap();
assert!(request.len() > 50);
} | rust_cleaned_test_functions.jsonl/106021 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 107
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
86757,
7893,
368,
341,
286,
2930,
17223,
1866,
3071,
286,
1077,
3633,
1523,
284,
3633,
486,
23841,
486,
5834,
4452,
15866,
1428,
286,
1077,
1681,
284,
633,
86757,
7893,
24147,
1523,
11,
330,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_insert_in_between_semiglobal() {
let x = b"GGGGG";
let y = b"GGTAGGG";
let score = |a: u8, b: u8| if a == b { 1i32 } else { -3i32 };
let mut aligner = Aligner::new(-5, -1, &score);
let alignment = aligner.semiglobal(x, y);
assert_eq!(
alignment.operations,
[Match, Match, Del, Del, Match, Match, Match]
);
} | rust_cleaned_test_functions.jsonl/16849 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 216
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17678,
1243,
48302,
30442,
343,
2042,
368,
341,
286,
1077,
856,
284,
293,
1,
22254,
22254,
38,
876,
286,
1077,
379,
284,
293,
1,
22254,
32144,
22254,
3302,
286,
1077,
5456,
284,
760,
64,
25,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_ecc_curves() {
let mut context = create_ctx_without_session();
let (_capabs, _more) = context
.get_capability(CapabilityType::ECCCurves, 0, 80)
.unwrap();
} | rust_cleaned_test_functions.jsonl/49686 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 111
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2204,
638,
18956,
2342,
368,
341,
286,
1077,
5206,
2266,
284,
1855,
15147,
39904,
12316,
1428,
286,
1077,
5453,
11346,
3435,
11,
716,
6384,
8,
284,
2266,
198,
310,
659,
455,
89686,
3025,
391,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_parser_returns_multiple_lookup_commands() {
let path = "./tests/manifests/k8s_multiple_keys.yaml".to_string();
let data = read_to_string(path).expect("Can't read the file.");
let instance = VaultCommandParser::new();
let commands = instance.parse(&data);
assert_eq!(commands.len(), 6);
} | rust_cleaned_test_functions.jsonl/113256 | {
"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,
18517,
58900,
45233,
27464,
44151,
368,
341,
286,
1077,
1815,
284,
5924,
23841,
14,
42315,
82,
14109,
23,
82,
45233,
12631,
33406,
3263,
983,
3904,
543,
286,
1077,
821,
284,
1349,
2346,
3904,
5581... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_real_as_unsigned_real() {
let cs = vec![
// not in union
// TODO: add test case of negative real to unsigned real
(u64::MIN as f64, u64::MIN as f64, false),
(1.0, 1.0, false),
(i64::MAX as f64, i64::MAX as f64, false),
(u64::MAX as f64, u64::MAX as f64, false),
(f64::MAX, f64::MAX, false),
// in union
(-1.0, 0.0, true),
(i64::MIN as f64, 0.0, true),
(u64::MIN as f64, 0.0, true),
(f64::MIN, 0.0, true),
(1.0, 1.0, true),
(i64::MAX as f64, i64::MAX as f64, true),
(u64::MAX as f64, u64::MAX as f64, true),
(f64::MAX, f64::MAX, true),
];
for (input, expect, in_union) in cs {
let ia = make_implicit_args(in_union);
let rft = make_ret_field_type_1(true);
let extra = make_extra(&rft, &ia);
let r = cast_real_as_unsigned_real(&extra, &Some(Real::new(input).unwrap()));
let r = r.map(|x| x.map(|x| x.into_inner()));
let log = format!(
"input: {}, expect: {}, in_union: {}",
input, expect, in_union
);
check_result(Some(&expect), &r, log.as_str());
}
} | rust_cleaned_test_functions.jsonl/101777 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 812
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15266,
11898,
67830,
15266,
368,
341,
286,
1077,
10532,
284,
7486,
90515,
3374,
310,
442,
537,
304,
11300,
198,
310,
442,
5343,
25,
912,
1273,
1142,
315,
8225,
1931,
311,
3774,
1931,
18574,
34642,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_single() {
let result = get_doc_strings(&[MetaNameValue {
path: ident("doc").into(),
eq_token: Default::default(),
lit: litstr("foo"),
}]);
assert_eq!(
&result.unwrap(),
Some(&strs_to_strings(vec!["foo"])).unwrap()
);
} | rust_cleaned_test_functions.jsonl/96240 | {
"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,
19487,
368,
341,
310,
1077,
1102,
284,
633,
18869,
33500,
2099,
58,
12175,
675,
1130,
341,
394,
1815,
25,
3524,
445,
5236,
1827,
18122,
3148,
394,
8939,
6458,
25,
7899,
486,
2258,
3148,
394,
130... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_config_set_client_hello_cb_no_func() {
let mut config = Config::new();
config
.set_client_hello_cb::<Option<()>>(None, None)
;
} | rust_cleaned_test_functions.jsonl/51687 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 103
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5332,
2602,
8179,
96724,
16450,
6536,
9596,
368,
341,
286,
1077,
5206,
2193,
284,
5532,
486,
931,
1428,
286,
2193,
198,
310,
659,
746,
8179,
96724,
16450,
27638,
5341,
71698,
2235,
4064,
11,
2240,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_and_write_at_max_offset_suceeds() {
let (_ramdisk, remote_block_device) = make_ramdisk();
let mut cache = Cache::new(remote_block_device).expect("Cache::new failed");
let buf = [0xd4u8; 2];
cache.write_at(&buf, RAMDISK_SIZE - buf.len() as u64).expect("write_at failed");
let mut read_buf = [0xf3u8; 2];
cache.read_at(&mut read_buf, RAMDISK_SIZE - buf.len() as u64).expect("read_at failed");
assert_eq!(&buf, &read_buf);
} | rust_cleaned_test_functions.jsonl/96363 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 233
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
8378,
9165,
3752,
6345,
6917,
89927,
4635,
82,
368,
341,
286,
1077,
5453,
2396,
30496,
11,
8699,
7113,
9204,
8,
284,
1281,
62124,
30496,
543,
286,
1077,
5206,
6500,
284,
19479,
486,
931,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_get_pair_found() {
let hole = [&Card {
value: CardValue::Value3,
suit: CardSuit::Spades,
},
&Card {
value: CardValue::Value3,
suit: CardSuit::Spades,
}];
let table = [&Card {
value: CardValue::Value3,
suit: CardSuit::Spades,
},
&Card {
value: CardValue::Value5,
suit: CardSuit::Spades,
},
&Card {
value: CardValue::ValueQ,
suit: CardSuit::Spades,
},
&Card {
value: CardValue::Value5,
suit: CardSuit::Spades,
},
&Card {
value: CardValue::ValueQ,
suit: CardSuit::Spades,
}];
let hand: Hand = get_pair(hole, table).unwrap();
assert!(hand.hand_type == HandType::Pair);
assert!(hand.cards[0].value == CardValue::ValueQ);
assert!(hand.cards[1].value == CardValue::ValueQ);
assert!(hand.cards[2].value == CardValue::Value5);
assert!(hand.cards[3].value == CardValue::Value5);
assert!(hand.cards[4].value == CardValue::Value3);
} | rust_cleaned_test_functions.jsonl/45777 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 964
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
14445,
21480,
368,
341,
286,
1077,
14178,
284,
34336,
5770,
341,
664,
897,
25,
6795,
1130,
486,
1130,
18,
345,
664,
7781,
25,
6795,
62898,
486,
6406,
3452,
345,
503,
1153,
503,
609,
5770,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_internal_validity() {
let result = panic::catch_unwind(|| {
let children = Children::default();
InternalNode::new(children)
});
assert!(result.is_err());
let result = panic::catch_unwind(|| {
let mut children = Children::default();
children.insert(
Nibble::from(1),
Child::new(
HashValue::random(),
0, /* version */
true, /* is_leaf */
),
);
InternalNode::new(children);
});
assert!(result.is_err());
} | rust_cleaned_test_functions.jsonl/56486 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 288
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
23472,
8337,
487,
368,
341,
262,
1077,
1102,
284,
21975,
486,
7173,
4907,
19154,
79453,
341,
286,
1077,
2841,
284,
15044,
486,
2258,
543,
286,
15412,
1955,
486,
931,
46203,
340,
262,
1625,
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... | 3 |
#[test]
fn test_x() {
let vec = vec3(0.0, 0.0, 1.0);
let rot = Matrix3::from_angle_x(Deg(90.0));
println!("x mat: {:?}", rot);
assert_ulps_eq!(vec3(0.0, -1.0, 0.0), rot * vec);
} | rust_cleaned_test_functions.jsonl/105486 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 151
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3212,
368,
341,
310,
1077,
7486,
284,
7486,
18,
7,
15,
13,
15,
11,
220,
15,
13,
15,
11,
220,
16,
13,
15,
626,
310,
1077,
5749,
284,
11631,
18,
486,
1499,
21727,
3212,
5432,
791,
7,
24,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_from_config_invalid() {
let yaml_string = "sorting:\n column: foo";
let yaml = YamlLoader::load_from_str(yaml_string).unwrap()[0].clone();
assert_eq!(None, SortColumn::from_config(&Config::with_yaml(yaml)));
} | rust_cleaned_test_functions.jsonl/54298 | {
"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,
5673,
5332,
31433,
368,
341,
286,
1077,
32246,
3904,
284,
330,
67039,
7190,
77,
220,
3250,
25,
15229,
876,
286,
1077,
32246,
284,
809,
9467,
9181,
486,
1078,
5673,
2895,
7021,
9467,
3904,
568,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_roll_range() {
let mut rng = RandomNumberGenerator::new();
for _ in 0..100 {
let n = rng.roll_dice(1, 20);
assert!(n > 0 && n < 21);
}
} | rust_cleaned_test_functions.jsonl/67935 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 118
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
57578,
9698,
368,
341,
286,
1077,
5206,
28422,
284,
10612,
2833,
12561,
486,
931,
543,
286,
369,
716,
304,
220,
15,
496,
16,
15,
15,
341,
310,
1077,
308,
284,
28422,
62614,
97196,
7,
16,
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... | 3 |
#[test]
fn test_categorical_builder() {
let mut builder = CategoricalChunkedBuilder::new("foo", 10);
builder.append_value("hello");
builder.append_null();
builder.append_value("world");
let ca = builder.finish();
let v = AnyValue::Utf8("hello");
assert_eq!(ca.get_any_value(0), v);
let v = AnyValue::Null;
assert_eq!(ca.get_any_value(1), v);
} | rust_cleaned_test_functions.jsonl/41384 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 200
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
87455,
28532,
368,
341,
286,
1077,
5206,
7363,
284,
356,
46047,
28304,
291,
3297,
486,
931,
445,
7975,
497,
220,
16,
15,
626,
286,
7363,
2057,
3142,
445,
14990,
797,
286,
7363,
2057,
15162,
543,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ipv6_icmp_parameter_problem_must() {
let mut ctx = DummyEventDispatcherBuilder::from_config(DUMMY_CONFIG_V6)
.build::<DummyEventDispatcher>();
let device = DeviceId::new_ethernet(0);
// Test parsing an IPv6 packet where we MUST send an ICMP parameter problem
#[rustfmt::skip]
let bytes: &mut [u8] = &mut [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
// Routing Extension Header
IpProto::Udp.into(), // Next Header
4,
255,
1, // Segments Left
0, 0, 0, 0, // Reserved
// Addresses for Routing Header w/ Type 0
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
// Body
1, 2, 3, 4, 5,
][..];
bytes[..4].copy_from_slice(&[0x60, 0x20, 0x00, 0x77][..]);
let payload_len = u16::try_from(bytes.len() - 40).unwrap();
bytes[4..6].copy_from_slice(&payload_len.to_be_bytes());
bytes[6] = Ipv6ExtHdrType::Routing.into();
bytes[7] = 64;
bytes[8..24].copy_from_slice(DUMMY_CONFIG_V6.remote_ip.bytes());
bytes[24..40].copy_from_slice(DUMMY_CONFIG_V6.local_ip.bytes());
let buf = Buf::new(bytes, ..);
receive_ipv6_packet(&mut ctx, device, FrameDestination::Unicast, buf);
assert_eq!(ctx.dispatcher().frames_sent().len(), 1);
verify_icmp_for_unrecognized_ext_hdr_option(
&mut ctx,
Icmpv6ParameterProblemCode::ErroneousHeaderField,
42,
0,
);
} | rust_cleaned_test_functions.jsonl/122981 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1110
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
49378,
21,
32747,
1307,
24899,
60139,
717,
590,
368,
341,
286,
1077,
5206,
5635,
284,
50567,
1556,
21839,
3297,
486,
1499,
5332,
5432,
58673,
12568,
2334,
21,
340,
310,
659,
5834,
27638,
43344,
15... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_without_normalization() {
let capture = CapturedWriter::new();
info!(
event_name = "foo bar",
other_event = "baz",
"This is an info message"
);
// double assure that normalization isn't messing with things by
// checking for presence of strings as well
let log_string = normalize(capture.to_strings().iter()).join("\n");
assert!(log_string.contains("This is an info message"));
assert!(log_string.contains("event_name"));
assert!(log_string.contains("other_event"));
assert!(log_string.contains("baz"));
assert!(log_string.contains("foo bar"));
} | rust_cleaned_test_functions.jsonl/10390 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 244
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39904,
13973,
2022,
368,
341,
262,
1077,
12322,
284,
16603,
3073,
6492,
486,
931,
543,
262,
3546,
33673,
286,
1538,
1269,
284,
330,
7975,
3619,
756,
286,
1008,
6748,
284,
330,
42573,
756,
286,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_should_not_add_newline_when_line_less_than_fold() {
new_ucmd!().pipe_in("1234").succeeds().stdout_is("1234");
} | rust_cleaned_test_functions.jsonl/23269 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 66
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
43378,
7913,
2891,
5921,
1056,
47636,
6528,
50747,
51613,
61187,
368,
341,
262,
501,
68887,
2277,
0,
1005,
13768,
1243,
445,
16,
17,
18,
19,
1827,
82,
29264,
82,
1005,
36358,
6892,
445,
16,
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 |
#[test]
fn test_unknown_field_rename_enum() {
assert_de_tokens_error::<AliasEnum>(
&[Token::StructVariant {
name: "AliasEnum",
variant: "SailorMoon",
len: 3,
}],
"unknown variant `SailorMoon`, expected `sailor_moon`",
);
assert_de_tokens_error::<AliasEnum>(
&[
Token::StructVariant {
name: "AliasEnum",
variant: "usagi_tsukino",
len: 3,
},
Token::Str("a"),
Token::I8(0),
Token::Str("c"),
Token::I8(1),
Token::Str("d"),
Token::I8(2),
],
"unknown field `d`, expected one of `a`, `b`, `f`",
);
} | rust_cleaned_test_functions.jsonl/59140 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 438
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
57507,
5013,
79399,
31054,
368,
341,
262,
2060,
2259,
28838,
4096,
27638,
22720,
10766,
17055,
286,
44590,
3323,
486,
9422,
20746,
341,
310,
829,
25,
330,
22720,
10766,
756,
310,
11424,
25,
330,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_dir() {
Python::with_gil(|py| {
let obj = py.eval("42", None, None).unwrap();
let dir = py
.eval("dir(42)", None, None)
.unwrap()
.downcast::<PyList>()
.unwrap();
let a = obj
.dir()
.into_iter()
.map(|x| x.extract::<String>().unwrap());
let b = dir.into_iter().map(|x| x.extract::<String>().unwrap());
assert!(a.eq(b));
});
} | rust_cleaned_test_functions.jsonl/93718 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 334
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4334,
368,
341,
286,
13027,
486,
4197,
1889,
321,
22428,
3288,
91,
341,
310,
1077,
2839,
284,
4510,
31710,
445,
19,
17,
497,
2240,
11,
2240,
568,
15454,
543,
310,
1077,
5419,
284,
4510,
198,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_append_command() {
let mut ed = Editor::new();
let mut cl = CommandLine {
addr_1: None,
addr_2: None,
cmd: "e".to_string(),
flag: false,
params: vec![TEST_FILE.to_string()]
};
ed.edit_command(cl.clone()).ok();
cl.cmd = "a".to_string();
cl.addr_1 = Some(0);
assert_eq!(ed.append_command(cl.clone()), Ok(State::Running));
assert_eq!(ed.addr, 0);
assert_eq!(ed.insert_mode, true);
cl.addr_1 = Some(1);
assert_eq!(ed.append_command(cl.clone()), Ok(State::Running));
assert_eq!(ed.addr, 1);
assert_eq!(ed.insert_mode, true);
} | rust_cleaned_test_functions.jsonl/75801 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 389
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26041,
10811,
368,
341,
286,
1077,
5206,
1578,
284,
12580,
486,
931,
543,
286,
1077,
5206,
1185,
284,
78218,
341,
310,
10789,
62,
16,
25,
2240,
345,
310,
10789,
62,
17,
25,
2240,
345,
310,
543... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_apply_patch_to_disk() {
let thor_dir_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("resources/tests/thor");
{
let temp_dir = tempdir().unwrap();
let count_files = |dir_path| {
WalkDir::new(dir_path)
.into_iter()
.filter_map(|e| e.ok())
.filter_map(|entry| entry.metadata().ok())
.filter(|metadata| metadata.is_file())
.count()
};
let expected_file_path = temp_dir
.path()
.join("data/wav/se_subterranean_rustyengine.wav");
let thor_archive_path = thor_dir_path.join("small.thor");
let mut thor_archive = ThorArchive::open(&thor_archive_path).unwrap();
let nb_of_added_files = thor_archive.file_count() - 1;
// Before patching
assert!(!expected_file_path.exists());
assert_eq!(0, count_files(temp_dir.path()));
apply_patch_to_disk(temp_dir.path(), &mut thor_archive).unwrap();
// After patching
assert!(expected_file_path.exists());
assert_eq!(nb_of_added_files, count_files(temp_dir.path()));
}
} | rust_cleaned_test_functions.jsonl/110296 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 689
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36551,
39643,
2346,
41687,
368,
341,
286,
1077,
72733,
4334,
2638,
284,
7933,
15064,
486,
1499,
16978,
17223,
34,
7581,
46,
25143,
91120,
8291,
15197,
5987,
445,
12745,
62468,
20439,
269,
797,
286,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_serialize_zeroes() {
// Test that TcpSegmentBuilder::serialize properly zeroes memory before
// serializing the header.
let mut buf_0 = [0; HDR_PREFIX_LEN];
let _: Buf<&mut [u8]> = Buf::new(&mut buf_0[..], HDR_PREFIX_LEN..)
.encapsulate(new_builder(TEST_SRC_IPV4, TEST_DST_IPV4))
.serialize_vec_outer()
.unwrap()
.unwrap_a();
let mut buf_1 = [0xFF; HDR_PREFIX_LEN];
let _: Buf<&mut [u8]> = Buf::new(&mut buf_1[..], HDR_PREFIX_LEN..)
.encapsulate(new_builder(TEST_SRC_IPV4, TEST_DST_IPV4))
.serialize_vec_outer()
.unwrap()
.unwrap_a();
assert_eq!(&buf_0[..], &buf_1[..]);
} | rust_cleaned_test_functions.jsonl/121765 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 421
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
88686,
19359,
288,
368,
341,
286,
442,
3393,
429,
64876,
21086,
3297,
486,
24166,
10277,
97443,
4938,
1573,
198,
286,
442,
6146,
4849,
279,
4247,
624,
286,
1077,
5206,
6607,
62,
15,
284,
508,
15... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_table_check_observer() {
let path = TempDir::new("test_table_check_observer").unwrap();
let engine = Arc::new(new_engine(path.path().to_str().unwrap(), ALL_CFS, None).unwrap());
let write_cf = engine.cf_handle(CF_WRITE).unwrap();
let mut region = Region::new();
region.set_id(1);
region.mut_peers().push(Peer::new());
region.mut_region_epoch().set_version(2);
region.mut_region_epoch().set_conf_ver(5);
let (tx, rx) = mpsc::sync_channel(100);
let ch = RetryableSendCh::new(tx, "test-split-table");
let (stx, _rx) = mpsc::sync_channel::<Msg>(100);
let sch = RetryableSendCh::new(stx, "test-split-size");
let mut cfg = Config::default();
// Enable table split.
cfg.split_region_on_table = true;
// Try to "disable" size split.
cfg.region_max_size = ReadableSize::gb(2);
cfg.region_split_size = ReadableSize::gb(1);
// Try to "disable" keys split
cfg.region_max_keys = 2000000000;
cfg.region_split_keys = 1000000000;
// Try to ignore the ApproximateRegionSize
let coprocessor = CoprocessorHost::new(cfg, sch);
let mut runnable =
SplitCheckRunner::new(Arc::clone(&engine), ch.clone(), Arc::new(coprocessor));
type Case = (Option<Vec<u8>>, Option<Vec<u8>>, Option<i64>);
let mut check_cases = |cases: Vec<Case>| {
for (encoded_start_key, encoded_end_key, table_id) in cases {
region.set_start_key(encoded_start_key.unwrap_or_else(Vec::new));
region.set_end_key(encoded_end_key.unwrap_or_else(Vec::new));
runnable.run(SplitCheckTask::new(region.clone(), true, CheckPolicy::SCAN));
if let Some(id) = table_id {
let key = Key::from_raw(&gen_table_prefix(id));
match rx.try_recv() {
Ok(Msg::SplitRegion { split_keys, .. }) => {
assert_eq!(split_keys, vec![key.into_encoded()]);
}
others => panic!("expect {:?}, but got {:?}", key, others),
}
} else {
match rx.try_recv() {
Err(mpsc::TryRecvError::Empty) => (),
others => panic!("expect empty, but got {:?}", others),
}
}
}
};
let gen_encoded_table_prefix = |table_id| {
let key = Key::from_raw(&gen_table_prefix(table_id));
key.into_encoded()
};
// arbitrary padding.
let padding = b"_r00000005";
// Put some tables
for i in 1..4 {
if i % 2 == 0 {
// leave some space.
continue;
}
let mut key = gen_table_prefix(i);
key.extend_from_slice(padding);
let s = keys::data_key(Key::from_raw(&key).as_encoded());
engine.put_cf(write_cf, &s, &s).unwrap();
}
check_cases(vec![
(None, None, Some(1)),
(Some(gen_encoded_table_prefix(1)), None, Some(3)),
(
Some(gen_encoded_table_prefix(1)),
Some(gen_encoded_table_prefix(5)),
Some(3),
),
(
Some(gen_encoded_table_prefix(2)),
Some(gen_encoded_table_prefix(4)),
Some(3),
),
]);
// Put some data to t3
for i in 1..4 {
let mut key = gen_table_prefix(3);
key.extend_from_slice(format!("{:?}{}", padding, i).as_bytes());
let s = keys::data_key(Key::from_raw(&key).as_encoded());
engine.put_cf(write_cf, &s, &s).unwrap();
}
check_cases(vec![
(Some(gen_encoded_table_prefix(1)), None, Some(3)),
(Some(gen_encoded_table_prefix(3)), None, None),
(
Some(gen_encoded_table_prefix(3)),
Some(gen_encoded_table_prefix(5)),
None,
),
]);
// Put some data before t and after t.
for i in 0..3 {
// m is less than t and is the prefix of meta keys.
let key = format!("m{:?}{}", padding, i);
let s = keys::data_key(Key::from_raw(key.as_bytes()).as_encoded());
engine.put_cf(write_cf, &s, &s).unwrap();
let key = format!("u{:?}{}", padding, i);
let s = keys::data_key(Key::from_raw(key.as_bytes()).as_encoded());
engine.put_cf(write_cf, &s, &s).unwrap();
}
check_cases(vec![
(None, None, Some(1)),
(None, Some(gen_encoded_table_prefix(1)), None),
(None, Some(gen_encoded_table_prefix(3)), Some(1)),
(None, Some(b"s".to_vec()), None),
(Some(b"u".to_vec()), None, None),
(Some(gen_encoded_table_prefix(3)), None, None),
(Some(gen_encoded_table_prefix(1)), None, Some(3)),
]);
} | rust_cleaned_test_functions.jsonl/100514 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2938
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5237,
7200,
81912,
368,
341,
286,
1077,
1815,
284,
19944,
6184,
486,
931,
445,
1944,
5237,
7200,
81912,
1827,
15454,
543,
286,
1077,
4712,
284,
19689,
486,
931,
1755,
24823,
5581,
3875,
1005,
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... | 9 |
#[test]
fn test_paren_matching() {
assert_eq!(
parse(vec!(
Token::OpenParen,
Token::OpenBrace,
Token::CloseBrace,
Token::CloseParen).iter()).unwrap(),
vec!(Expr::SExpr(vec!(Expr::SExpr(vec!()))))
);
} | rust_cleaned_test_functions.jsonl/37724 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 159
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
9151,
70763,
368,
341,
262,
2060,
10714,
33673,
286,
4715,
25592,
33673,
310,
9660,
486,
5002,
83997,
345,
310,
9660,
486,
5002,
6828,
578,
345,
310,
9660,
486,
7925,
6828,
578,
345,
310,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_empty_rpc() {
let (mut sender, mut receiver) = build_node_pair();
let rpc_request = RPCRequest::Hello(HelloMessage {
heaviest_tip_set: vec![empty_cid()],
heaviest_tipset_weight: BigUint::from(1u8),
heaviest_tipset_height: 2,
genesis_hash: empty_cid(),
});
let c_request = rpc_request.clone();
let rpc_response = RPCResponse::Hello(HelloResponse {
arrival: 4,
sent: 5,
});
let c_response = rpc_response.clone();
let sender_fut = async move {
loop {
match sender.next().await {
RPCMessage::PeerDialed(peer_id) => {
sender.send_rpc(peer_id, RPCEvent::Request(1, c_request.clone()));
}
RPCMessage::RPC(_peer_id, event) => match event {
RPCEvent::Response(req_id, res) => {
return (req_id, res);
}
ev => panic!("Sender invalid RPC received, {:?}", ev),
},
e => panic!("unexpected {:?}", e),
}
}
};
let receiver_fut = async move {
loop {
match receiver.next().await {
RPCMessage::RPC(peer_id, event) => {
match event {
RPCEvent::Request(req_id, req) => {
assert_eq!(rpc_request.clone(), req);
assert_eq!(req_id, 1);
// send the response
receiver.send_rpc(peer_id, RPCEvent::Response(1, c_response.clone()));
}
ev => panic!("Receiver invalid RPC received, {:?}", ev),
}
}
RPCMessage::PeerDialed(_) => (),
e => panic!("unexpected {:?}", e),
}
}
};
let result = future::select(Box::pin(sender_fut), Box::pin(receiver_fut));
let ((req_id, res), _) = async_std::task::block_on(result).factor_first();
assert_eq!(res, rpc_response);
assert_eq!(req_id, 1);
} | rust_cleaned_test_functions.jsonl/49602 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1171
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15124,
60799,
368,
341,
262,
1077,
320,
6984,
4646,
11,
5206,
13964,
8,
284,
1936,
5084,
14445,
1428,
262,
1077,
35596,
7893,
284,
34008,
1900,
486,
9707,
7,
9707,
2052,
341,
286,
566,
98362,
48... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
#[test]
fn test_chan_reserve_violation_inbound_htlc_inbound_chan() {
let chanmon_cfgs = create_chanmon_cfgs(3);
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 95000000, InitFeatures::known(), InitFeatures::known());
let _ = create_announced_chan_between_nodes_with_value(&nodes, 1, 2, 100000, 95000000, InitFeatures::known(), InitFeatures::known());
let feemsat = 239;
let total_routing_fee_msat = (nodes.len() - 2) as u64 * feemsat;
let chan_stat = get_channel_value_stat!(nodes[0], chan.2);
let feerate = get_feerate!(nodes[0], chan.2);
// Add a 2* and +1 for the fee spike reserve.
let commit_tx_fee_2_htlc = 2*commit_tx_fee_msat(feerate, 2 + 1);
let recv_value_1 = (chan_stat.value_to_self_msat - chan_stat.channel_reserve_msat - total_routing_fee_msat - commit_tx_fee_2_htlc)/2;
let amt_msat_1 = recv_value_1 + total_routing_fee_msat;
// Add a pending HTLC.
let (route_1, our_payment_hash_1, _, our_payment_secret_1) = get_route_and_payment_hash!(nodes[0], nodes[2], amt_msat_1);
let payment_event_1 = {
nodes[0].node.send_payment(&route_1, our_payment_hash_1, &Some(our_payment_secret_1)).unwrap();
check_added_monitors!(nodes[0], 1);
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 1);
SendEvent::from_event(events.remove(0))
};
nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event_1.msgs[0]);
// Attempt to trigger a channel reserve violation --> payment failure.
let commit_tx_fee_2_htlcs = commit_tx_fee_msat(feerate, 2);
let recv_value_2 = chan_stat.value_to_self_msat - amt_msat_1 - chan_stat.channel_reserve_msat - total_routing_fee_msat - commit_tx_fee_2_htlcs + 1;
let amt_msat_2 = recv_value_2 + total_routing_fee_msat;
let (route_2, _, _, _) = get_route_and_payment_hash!(nodes[0], nodes[2], amt_msat_2);
let secp_ctx = Secp256k1::new();
let session_priv = SecretKey::from_slice(&[42; 32]).unwrap();
let cur_height = nodes[0].node.best_block.read().unwrap().height() + 1;
let onion_keys = onion_utils::construct_onion_keys(&secp_ctx, &route_2.paths[0], &session_priv).unwrap();
let (onion_payloads, htlc_msat, htlc_cltv) = onion_utils::build_onion_payloads(&route_2.paths[0], recv_value_2, &None, cur_height, &None).unwrap();
let onion_packet = onion_utils::construct_onion_packet(onion_payloads, onion_keys, [0; 32], &our_payment_hash_1);
let msg = msgs::UpdateAddHTLC {
channel_id: chan.2,
htlc_id: 1,
amount_msat: htlc_msat + 1,
payment_hash: our_payment_hash_1,
cltv_expiry: htlc_cltv,
onion_routing_packet: onion_packet,
};
nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &msg);
// Check that the payment failed and the channel is closed in response to the malicious UpdateAdd.
nodes[1].logger.assert_log("lightning::ln::channelmanager".to_string(), "Remote HTLC add would put them under remote reserve value".to_string(), 1);
assert_eq!(nodes[1].node.list_channels().len(), 1);
let err_msg = check_closed_broadcast!(nodes[1], true).unwrap();
assert_eq!(err_msg.data, "Remote HTLC add would put them under remote reserve value");
check_added_monitors!(nodes[1], 1);
check_closed_event!(nodes[1], 1, ClosureReason::ProcessingError { err: "Remote HTLC add would put them under remote reserve value".to_string() });
} | rust_cleaned_test_functions.jsonl/16875 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1430
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
45552,
89591,
2273,
24903,
367,
1243,
10891,
49086,
17257,
1243,
10891,
45552,
368,
341,
10217,
26023,
1645,
18343,
82,
284,
1855,
45552,
1645,
18343,
82,
7,
18,
317,
10217,
2436,
18343,
82,
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_linearise() {
let context = PyContext::new();
let object = context.object;
let type_type = context.type_type;
let a = new(type_type.clone(), "A", vec![object.clone()], HashMap::new()).unwrap();
let b = new(type_type.clone(), "B", vec![object.clone()], HashMap::new()).unwrap();
assert_eq!(
map_ids(linearise_mro(vec![
vec![object.clone()],
vec![object.clone()]
])),
map_ids(Some(vec![object.clone()]))
);
assert_eq!(
map_ids(linearise_mro(vec![
vec![a.clone(), object.clone()],
vec![b.clone(), object.clone()],
])),
map_ids(Some(vec![a.clone(), b.clone(), object.clone()]))
);
} | rust_cleaned_test_functions.jsonl/2108 | {
"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,
40674,
1064,
368,
341,
286,
1077,
2266,
284,
5355,
1972,
486,
931,
543,
286,
1077,
1633,
284,
2266,
6035,
280,
286,
1077,
943,
1819,
284,
2266,
4852,
1819,
401,
286,
1077,
264,
284,
501,
5808,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_io_timer_sleep_oneshot_forget() {
let mut timer = Timer::new().unwrap();
timer.oneshot(Duration::milliseconds(100000000));
} | rust_cleaned_test_functions.jsonl/6046 | {
"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,
16939,
16255,
49393,
62,
3154,
10622,
5478,
455,
368,
341,
286,
1077,
5206,
9021,
284,
17759,
486,
931,
1005,
15454,
543,
286,
9021,
31790,
10622,
64114,
486,
60772,
7,
16,
15,
15,
15,
15,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_append_multi() {
let mut io_loop = Runtime::new().unwrap();
let (bg, mut client, origin) = create_sig0_ready_client(&mut io_loop);
// append a record
let mut record = Record::with(
Name::from_str("new.example.com").unwrap(),
RecordType::A,
Duration::minutes(5).num_seconds() as u32,
);
record.set_rdata(RData::A(Ipv4Addr::new(100, 10, 100, 10)));
// first check the must_exist option
io_loop.spawn(bg);
let result = io_loop
.block_on(client.append(record.clone(), origin.clone(), true))
.expect("append failed");
assert_eq!(result.response_code(), ResponseCode::NXRRSet);
// next append to a non-existent RRset
let result = io_loop
.block_on(client.append(record.clone(), origin.clone(), false))
.expect("append failed");
assert_eq!(result.response_code(), ResponseCode::NoError);
// verify record contents
let result = io_loop
.block_on(client.query(record.name().clone(), record.dns_class(), record.rr_type()))
.expect("query failed");
assert_eq!(result.response_code(), ResponseCode::NoError);
assert_eq!(result.answers().len(), 1);
assert_eq!(result.answers()[0], record);
// will fail if already set and not the same value.
let mut record2 = record.clone();
record2.set_rdata(RData::A(Ipv4Addr::new(101, 11, 101, 11)));
let mut record3 = record.clone();
record3.set_rdata(RData::A(Ipv4Addr::new(101, 11, 101, 12)));
// build the append set
let mut rrset = RecordSet::from(record2.clone());
rrset.insert(record3.clone(), 0);
let result = io_loop
.block_on(client.append(rrset, origin.clone(), true))
.expect("create failed");
assert_eq!(result.response_code(), ResponseCode::NoError);
let result = io_loop
.block_on(client.query(record.name().clone(), record.dns_class(), record.rr_type()))
.expect("query failed");
assert_eq!(result.response_code(), ResponseCode::NoError);
assert_eq!(result.answers().len(), 3);
assert!(result.answers().iter().any(|rr| *rr == record));
assert!(result.answers().iter().any(|rr| *rr == record2));
assert!(result.answers().iter().any(|rr| *rr == record3));
let result = io_loop
.block_on(client.append(record.clone(), origin.clone(), true))
.expect("create failed");
assert_eq!(result.response_code(), ResponseCode::NoError);
let result = io_loop
.block_on(client.query(record.name().clone(), record.dns_class(), record.rr_type()))
.expect("query failed");
assert_eq!(result.response_code(), ResponseCode::NoError);
assert_eq!(result.answers().len(), 3);
} | rust_cleaned_test_functions.jsonl/33939 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1096
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26041,
25133,
368,
341,
262,
1077,
5206,
6399,
17198,
284,
10954,
486,
931,
1005,
15454,
543,
262,
1077,
320,
12220,
11,
5206,
2943,
11,
6238,
8,
284,
1855,
29252,
15,
35456,
8179,
2099,
6984,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_valid_vm_config_default() {
let cli = vec!["cloud-hypervisor", "--kernel", "/path/to/kernel"];
let openapi = r#"{ "kernel": {"path": "/path/to/kernel"} }"#;
// First we check we get identical VmConfig structures.
let (result_vm_config, _) = compare_vm_config_cli_vs_json(&cli, openapi, true);
test_block!(tb, "", {
let expected_vm_config = VmConfig {
cpus: CpusConfig {
boot_vcpus: 1,
max_vcpus: 1,
topology: None,
kvm_hyperv: false,
max_phys_bits: None,
},
memory: MemoryConfig {
size: 536_870_912,
mergeable: false,
hotplug_method: HotplugMethod::Acpi,
hotplug_size: None,
hotplugged_size: None,
shared: false,
hugepages: false,
zones: None,
hugepage_size: None,
},
kernel: Some(KernelConfig {
path: PathBuf::from("/path/to/kernel"),
}),
initramfs: None,
cmdline: CmdlineConfig {
args: String::from(""),
},
disks: None,
net: None,
rng: RngConfig {
src: PathBuf::from("/dev/urandom"),
iommu: false,
},
balloon: None,
fs: None,
pmem: None,
serial: ConsoleConfig {
file: None,
mode: ConsoleOutputMode::Null,
iommu: false,
},
console: ConsoleConfig {
file: None,
mode: ConsoleOutputMode::Tty,
iommu: false,
},
devices: None,
vsock: None,
iommu: false,
#[cfg(target_arch = "x86_64")]
sgx_epc: None,
numa: None,
watchdog: false,
#[cfg(feature = "tdx")]
tdx: None,
};
aver_eq!(tb, expected_vm_config, result_vm_config);
Ok(())
})
} | rust_cleaned_test_functions.jsonl/69471 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1538
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8337,
39008,
5332,
9993,
368,
341,
286,
1077,
21348,
284,
7486,
0,
1183,
12361,
2832,
1082,
31396,
497,
14482,
23248,
497,
3521,
2343,
32429,
58343,
6332,
286,
1077,
1787,
2068,
284,
435,
2,
14129... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_create_shares_err() {
assert_eq!(create_shares(DATA, 0, 0), Err(SSSError::InvalidN(0)));
assert_eq!(create_shares(DATA, 5, 0), Err(SSSError::InvalidK(0)));
assert_eq!(create_shares(DATA, 5, 6), Err(SSSError::InvalidK(6)));
assert_eq!(create_shares(&[], 5, 3), Err(SSSError::BadInputLen(0)));
} | rust_cleaned_test_functions.jsonl/70732 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 176
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8657,
3712,
5403,
9266,
368,
341,
286,
2060,
10714,
10297,
3182,
3712,
5403,
59093,
11,
220,
15,
11,
220,
15,
701,
15495,
93544,
19224,
486,
7928,
45,
7,
15,
4945,
286,
2060,
10714,
10297,
3182,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_async_id() {
async_std::task::block_on(async {
println!("{}", async_snowflake_id().await);
println!("{}", async_snowflake_id().await);
});
} | rust_cleaned_test_functions.jsonl/101183 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 115
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5921,
28346,
842,
368,
341,
286,
3312,
15656,
486,
8202,
486,
4574,
4470,
18285,
341,
310,
13751,
79878,
3312,
643,
3328,
63456,
842,
1005,
11421,
317,
310,
13751,
79878,
3312,
643,
3328,
63456,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_sub_assign() {
let z = Vec3::zero();
let mut v1 = Vec3::new(1.0f64, 2.0f64, 3.0f64);
let v2 = Vec3::new(1.0f64, 2.0f64, 3.0f64);
v1 -= v2;
assert_eq!(v1, z);
let mut v1 = Vec3::new(3.0f64, 5.0f64, 7.0f64);
let v2 = Vec3::new(1.0f64, 2.0f64, 3.0f64);
let v3 = Vec3::new(2.0f64, 3.0f64, 4.0f64);
v1 -= v2;
assert_eq!(v1, v3);
} | rust_cleaned_test_functions.jsonl/120475 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 296
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5228,
20688,
368,
972,
286,
1077,
1147,
284,
11312,
18,
486,
14154,
1647,
286,
1077,
5206,
348,
16,
284,
11312,
18,
486,
931,
7,
16,
13,
15,
69,
21,
19,
11,
220,
17,
13,
15,
69,
21,
19,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_read_identifiers() {
assert_eq!(Json::from_str("n"), Err(SyntaxError(InvalidSyntax, 1, 2)));
assert_eq!(Json::from_str("nul"), Err(SyntaxError(InvalidSyntax, 1, 4)));
assert_eq!(Json::from_str("t"), Err(SyntaxError(InvalidSyntax, 1, 2)));
assert_eq!(Json::from_str("truz"), Err(SyntaxError(InvalidSyntax, 1, 4)));
assert_eq!(Json::from_str("f"), Err(SyntaxError(InvalidSyntax, 1, 2)));
assert_eq!(Json::from_str("faz"), Err(SyntaxError(InvalidSyntax, 1, 3)));
assert_eq!(Json::from_str("null"), Ok(Null));
assert_eq!(Json::from_str("true"), Ok(Boolean(true)));
assert_eq!(Json::from_str("false"), Ok(Boolean(false)));
assert_eq!(Json::from_str(" null "), Ok(Null));
assert_eq!(Json::from_str(" true "), Ok(Boolean(true)));
assert_eq!(Json::from_str(" false "), Ok(Boolean(false)));
} | rust_cleaned_test_functions.jsonl/22714 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 437
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
38399,
11836,
368,
341,
286,
2060,
10714,
10297,
5014,
486,
1499,
2895,
445,
77,
3975,
262,
15495,
93549,
1454,
7,
7928,
33890,
11,
220,
16,
11,
220,
17,
4945,
286,
2060,
10714,
10297,
501... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_u32() {
check_round_trip(vec![1, 2, 3, ::std::u32::MIN, 0, 1, ::std::u32::MAX, 2, 1]);
} | rust_cleaned_test_functions.jsonl/24183 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 63
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7300,
18,
17,
368,
341,
262,
1779,
29896,
63883,
25592,
20703,
16,
11,
220,
17,
11,
220,
18,
11,
3504,
1834,
486,
84,
18,
17,
486,
16413,
11,
220,
15,
11,
220,
16,
11,
3504,
1834,
486,
84,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_cartesian() -> Result<()> {
let sc = CONTEXT.clone();
let rdd1 = sc.parallelize((0..2).collect::<Vec<_>>(), 2);
let rdd2 = sc.parallelize("αβ".chars().collect::<Vec<_>>(), 2);
let res = rdd1.cartesian(rdd2).collect()?;
itertools::assert_equal(res, vec![(0, 'α'), (0, 'β'), (1, 'α'), (1, 'β')]);
Ok(())
} | rust_cleaned_test_functions.jsonl/27947 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 170
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
24186,
29221,
368,
1464,
5714,
71698,
341,
262,
1077,
1136,
284,
87336,
15997,
543,
262,
1077,
435,
631,
16,
284,
1136,
71457,
551,
1188,
15,
496,
17,
568,
17384,
27638,
10050,
32399,
2452,
1507,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_der_indefinite_length() {
let bytes = &hex!("23 80 03 03 00 0a 3b 03 05 04 5f 29 1c d0 00 00");
assert_eq!(
parse_der_bitstring(bytes),
Err(Err::Error(BerError::DerConstraintFailed))
);
} | rust_cleaned_test_functions.jsonl/45863 | {
"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,
35345,
1243,
750,
15856,
5118,
368,
341,
262,
1077,
5820,
284,
609,
17308,
17223,
17,
18,
220,
23,
15,
220,
15,
18,
220,
15,
18,
220,
15,
15,
220,
15,
64,
220,
18,
65,
220,
15,
18,
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_add() {
let mut book = Book::new();
let bid_order = Order {
time: 0,
id: 1,
price: 3.14,
qty: 100,
side: Side::BID,
};
let ask_order = Order {
time: 0,
id: 2,
price: 3.14,
qty: 100,
side: Side::ASK,
};
book.add_order(&bid_order);
book.add_order(&ask_order);
assert_eq!(book.bids_id.len(), 1);
assert_eq!(book.asks_id.len(), 1);
} | rust_cleaned_test_functions.jsonl/120785 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 341
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
368,
341,
286,
1077,
5206,
2311,
284,
5893,
486,
931,
1428,
286,
1077,
14103,
7869,
284,
7217,
341,
310,
882,
25,
220,
15,
345,
310,
877,
25,
220,
16,
345,
310,
3349,
25,
220,
18,
13,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_top_level_options_tracked_no_crate() {
let reference = Options::default();
let mut opts;
macro_rules! tracked {
($name: ident, $non_default_value: expr) => {
opts = reference.clone();
assert_ne!(opts.$name, $non_default_value);
opts.$name = $non_default_value;
// The crate hash should be the same
assert_eq!(reference.dep_tracking_hash(true), opts.dep_tracking_hash(true));
// The incremental hash should be different
assert_ne!(reference.dep_tracking_hash(false), opts.dep_tracking_hash(false));
};
}
// Make sure that changing a [TRACKED_NO_CRATE_HASH] option leaves the crate hash unchanged but changes the incremental hash.
// This list is in alphabetical order.
tracked!(remap_path_prefix, vec![("/home/bors/rust".into(), "src".into())]);
tracked!(
real_rust_source_base_dir,
Some("/home/bors/rust/.rustup/toolchains/nightly/lib/rustlib/src/rust".into())
);
} | rust_cleaned_test_functions.jsonl/100724 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 435
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10426,
8274,
8743,
3547,
11191,
6536,
666,
7698,
368,
341,
262,
1077,
5785,
284,
14566,
486,
2258,
543,
262,
1077,
5206,
12185,
401,
262,
18072,
21407,
0,
33056,
341,
286,
1711,
606,
25,
3524,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_elt() {
let test_cases: Vec<(Vec<ScalarValue>, _)> = vec![
(
vec![
Some(1).into(),
Some(b"DataBase".to_vec()).into(),
Some(b"Hello World!".to_vec()).into(),
],
Some(b"DataBase".to_vec()),
),
(
vec![
Some(2).into(),
Some(b"DataBase".to_vec()).into(),
Some(b"Hello World!".to_vec()).into(),
],
Some(b"Hello World!".to_vec()),
),
(
vec![
None::<Int>.into(),
Some(b"DataBase".to_vec()).into(),
Some(b"Hello World!".to_vec()).into(),
],
None,
),
(vec![None::<Int>.into(), None::<Bytes>.into()], None),
(
vec![
Some(1).into(),
None::<Bytes>.into(),
Some(b"Hello World!".to_vec()).into(),
],
None,
),
(
vec![
Some(3).into(),
None::<Bytes>.into(),
Some(b"Hello World!".to_vec()).into(),
],
None,
),
(
vec![
Some(0).into(),
None::<Bytes>.into(),
Some(b"Hello World!".to_vec()).into(),
],
None,
),
(
vec![
Some(-1).into(),
None::<Bytes>.into(),
Some(b"Hello World!".to_vec()).into(),
],
None,
),
(
vec![
Some(4).into(),
None::<Bytes>.into(),
Some(b"Hello".to_vec()).into(),
Some(b"Hola".to_vec()).into(),
Some("Cześć".as_bytes().to_vec()).into(),
Some("你好".as_bytes().to_vec()).into(),
Some("Здравствуйте".as_bytes().to_vec()).into(),
Some(b"Hello World!".to_vec()).into(),
],
Some("Cześć".as_bytes().to_vec()),
),
];
for (args, expect_output) in test_cases {
let output = RpnFnScalarEvaluator::new()
.push_params(args)
.evaluate(ScalarFuncSig::Elt)
.unwrap();
assert_eq!(output, expect_output);
}
} | rust_cleaned_test_functions.jsonl/10180 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1835
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
91034,
368,
341,
286,
1077,
1273,
41427,
25,
11312,
28706,
10050,
78505,
1130,
8066,
716,
16018,
284,
7486,
90515,
310,
2399,
394,
7486,
90515,
503,
4329,
7,
16,
568,
18122,
3148,
503,
4329,
1883,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_pipeline_simple() {
let mut p = make_parser_with(r#" $foo, $bar := yay | blub "2000" }}"#);
let pipe = p.pipeline("range");
// broken for now
assert!(pipe.is_err());
} | rust_cleaned_test_functions.jsonl/8630 | {
"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,
45187,
30015,
368,
341,
286,
1077,
5206,
281,
284,
1281,
18517,
6615,
2601,
55543,
400,
7975,
11,
400,
2257,
1669,
97559,
760,
1501,
392,
330,
17,
15,
15,
15,
1,
14483,
2,
317,
286,
1077,
1364... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_store() {
let file_1 = Path::new("/tmp/rill-rs.store.test-1");
{
let _ = std::fs::remove_file(file_1);
let mut pairs = Pairs::with_capacity(10).unwrap();
pairs.push(2, 10).unwrap();
pairs.push(3, 30).unwrap();
pairs.push(2, 30).unwrap();
pairs.push(1, 10).unwrap();
pairs.push(2, 20).unwrap();
Store::write(file_1, 100, 0, &pairs).unwrap();
}
let file_2 = Path::new("/tmp/rill-rs.store.test-2");
{
let _ = std::fs::remove_file(file_2);
let mut pairs = Pairs::with_capacity(10).unwrap();
pairs.push(2, 10).unwrap();
pairs.push(3, 30).unwrap();
pairs.push(4, 30).unwrap();
pairs.push(2, 10).unwrap();
pairs.push(3, 20).unwrap();
Store::write(file_2, 100, 0, &pairs).unwrap();
}
let file_merge = Path::new("/tmp/rill-rs.store.test-merge");
{
let _ = std::fs::remove_file(file_merge);
let mut to_merge = vec![
Store::open(file_1).unwrap(),
Store::open(file_2).unwrap()
];
Store::merge(file_merge, 123, 60, to_merge.as_slice()).unwrap();
to_merge[0].rm().unwrap();
to_merge[1].rm().unwrap();
}
assert!(Store::open(file_1).is_err());
assert!(Store::open(file_2).is_err());
let store = Store::open(file_merge).unwrap();
{
let mut pairs = Pairs::with_capacity(1).unwrap();
store.key(1, &mut pairs).unwrap();
assert_eq!(pairs.len(), 1);
assert_eq!(pairs.get(0).unwrap(), KV{key: 1, val: 10});
pairs.clear();
store.key(2, &mut pairs).unwrap();
assert_eq!(pairs.len(), 3);
assert_eq!(pairs.get(0).unwrap(), KV{key: 2, val: 10});
assert_eq!(pairs.get(1).unwrap(), KV{key: 2, val: 20});
assert_eq!(pairs.get(2).unwrap(), KV{key: 2, val: 30});
pairs.clear();
store.key(3, &mut pairs).unwrap();
assert_eq!(pairs.len(), 2);
assert_eq!(pairs.get(0).unwrap(), KV{key: 3, val: 20});
assert_eq!(pairs.get(1).unwrap(), KV{key: 3, val: 30});
pairs.clear();
store.key(4, &mut pairs).unwrap();
assert_eq!(pairs.len(), 1);
assert_eq!(pairs.get(0).unwrap(), KV{key: 4, val: 30});
}
} | rust_cleaned_test_functions.jsonl/60109 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1399
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14809,
368,
341,
286,
1077,
1034,
62,
16,
284,
7933,
486,
931,
4283,
5173,
7382,
483,
3795,
82,
16114,
5958,
12,
16,
797,
286,
341,
310,
1077,
716,
284,
1460,
486,
3848,
486,
5399,
2458,
4866,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_cos() {
let tests = vec![
(ScalarFuncSig::Cos, Datum::F64(0f64), 1f64),
(ScalarFuncSig::Cos, Datum::F64(f64::consts::PI / 2f64), 0f64),
(ScalarFuncSig::Cos, Datum::F64(f64::consts::PI), -1f64),
(ScalarFuncSig::Cos, Datum::F64(-f64::consts::PI), -1f64),
];
let mut ctx = EvalContext::new(Arc::new(EvalConfig::new().set_ignore_truncate(true)));
for (sig, arg, exp) in tests {
let arg = datum_expr(arg);
let expr = scalar_func_expr(sig, &[arg.clone()]);
let op = Expression::build(&mut ctx, expr).unwrap();
let got = op.eval(&mut ctx, &[]).unwrap();
match got {
Datum::F64(result) => assert!((result - exp).abs() < f64::EPSILON),
_ => panic!("F64 result was expected"),
}
}
} | rust_cleaned_test_functions.jsonl/125527 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 488
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
61192,
368,
341,
286,
1077,
7032,
284,
7486,
90515,
310,
320,
20639,
9626,
47246,
486,
54224,
11,
68459,
486,
37,
21,
19,
7,
15,
69,
21,
19,
701,
220,
16,
69,
21,
19,
1326,
310,
320,
20639,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_get_rooted_block_with_commitment() {
// Build BlockCommitmentCache with rooted votes
let mut cache0 = BlockCommitment::new([0; MAX_LOCKOUT_HISTORY]);
cache0.increase_confirmation_stake(MAX_LOCKOUT_HISTORY, 40);
cache0.increase_confirmation_stake(MAX_LOCKOUT_HISTORY - 1, 10);
let mut cache1 = BlockCommitment::new([0; MAX_LOCKOUT_HISTORY]);
cache1.increase_confirmation_stake(MAX_LOCKOUT_HISTORY, 30);
cache1.increase_confirmation_stake(MAX_LOCKOUT_HISTORY - 1, 10);
cache1.increase_confirmation_stake(MAX_LOCKOUT_HISTORY - 2, 10);
let mut block_commitment = HashMap::new();
block_commitment.entry(0).or_insert(cache0.clone());
block_commitment.entry(1).or_insert(cache1.clone());
let block_commitment_cache = BlockCommitmentCache::new(block_commitment, 50);
// Only slot 0 meets the minimum level of commitment 0.66 at root
assert_eq!(
block_commitment_cache.get_rooted_block_with_commitment(0.66),
Some(0)
);
assert_eq!(
block_commitment_cache.get_rooted_block_with_commitment(0.6),
Some(1)
);
// Neither slot meets the minimum level of commitment 0.9 at root
assert_eq!(
block_commitment_cache.get_rooted_block_with_commitment(0.9),
None
);
} | rust_cleaned_test_functions.jsonl/65257 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 639
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
12993,
291,
7113,
6615,
36346,
478,
368,
341,
286,
442,
7854,
8362,
33441,
478,
8233,
448,
40876,
12684,
198,
286,
1077,
5206,
6500,
15,
284,
8362,
33441,
478,
486,
931,
2561,
15,
26,
8334... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_sync_wal() {
let path = tempdir_with_prefix("_rust_rocksdb_test_sync_wal");
let mut opts = DBOptions::new();
opts.create_if_missing(true);
let db = DB::open(opts, path.path().to_str().unwrap()).unwrap();
db.put(b"key", b"value").unwrap();
db.sync_wal().unwrap();
drop(db);
} | rust_cleaned_test_functions.jsonl/34094 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 147
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
23008,
1670,
278,
368,
341,
262,
1077,
1815,
284,
2730,
3741,
6615,
13974,
16975,
35788,
26608,
14553,
1999,
4452,
23008,
1670,
278,
797,
262,
1077,
5206,
12185,
284,
5952,
3798,
486,
931,
543,
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_handler_with_prefix() {
let mut app = App::new()
.prefix("prefix")
.handler("/test", |_| HttpResponse::Ok())
.finish();
let req = TestRequest::with_uri("/prefix/test").finish();
let resp = app.run(req);
assert_eq!(resp.as_msg().status(), StatusCode::OK);
let req = TestRequest::with_uri("/prefix/test/").finish();
let resp = app.run(req);
assert_eq!(resp.as_msg().status(), StatusCode::OK);
let req = TestRequest::with_uri("/prefix/test/app").finish();
let resp = app.run(req);
assert_eq!(resp.as_msg().status(), StatusCode::OK);
let req = TestRequest::with_uri("/prefix/testapp").finish();
let resp = app.run(req);
assert_eq!(resp.as_msg().status(), StatusCode::NOT_FOUND);
let req = TestRequest::with_uri("/prefix/blah").finish();
let resp = app.run(req);
assert_eq!(resp.as_msg().status(), StatusCode::NOT_FOUND);
} | rust_cleaned_test_functions.jsonl/24272 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 458
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10183,
6615,
13974,
368,
341,
286,
1077,
5206,
906,
284,
1845,
486,
931,
741,
310,
659,
11849,
445,
11849,
1138,
310,
659,
17905,
4283,
1944,
497,
66091,
17580,
486,
11578,
2398,
310,
659,
30150,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_sum_rule() {
let rule: BinProtRule = serde_json::from_str(SUM_RULE).unwrap();
let example = vec![0x01, 0x00];
let mut de = Deserializer::from_reader(Cursor::new(example.as_slice())).with_layout(&rule);
let result: Value = Deserialize::deserialize(&mut de).expect("Failed to deserialize");
assert_eq!(
result,
Value::Sum {
name: "two".to_string(),
index: 1,
value: Box::new(Value::Tuple(vec![Value::Bool(false)]))
}
);
test_reserialize(&result, &example);
} | rust_cleaned_test_functions.jsonl/134753 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 319
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10160,
21124,
368,
341,
286,
1077,
5912,
25,
29344,
12423,
11337,
284,
61570,
9455,
486,
1499,
2895,
3759,
2794,
50495,
568,
15454,
543,
286,
1077,
3110,
284,
7486,
20703,
15,
87,
15,
16,
11,
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_broken_rule2() {
let src = "%%
[0-9] "
.to_string();
assert!(parse_lex::<u8>(&src).is_err());
match parse_lex::<u8>(&src) {
Ok(_) => panic!("Broken rule parsed"),
Err(LexBuildError {
kind: LexErrorKind::MissingSpace,
line: 2,
col: 1
}) => (),
Err(e) => panic!("Incorrect error returned {}", e)
}
} | rust_cleaned_test_functions.jsonl/54001 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 267
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
880,
81709,
21124,
17,
368,
341,
286,
1077,
2286,
284,
330,
51377,
58,
15,
12,
24,
60,
6228,
310,
659,
983,
3904,
543,
286,
2060,
10297,
6400,
74547,
27638,
84,
23,
44784,
3548,
568,
285,
9266... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_format_rate_limits() {
let mut rate_limits = RateLimits::new();
// Add a generic rate limit for all categories.
rate_limits.add(RateLimit {
categories: DataCategories::new(),
scope: RateLimitScope::Organization(42),
reason_code: Some(ReasonCode::new("my_limit")),
retry_after: RetryAfter::from_secs(42),
});
// Add a more specific rate limit for just one category.
rate_limits.add(RateLimit {
categories: smallvec![DataCategory::Transaction, DataCategory::Security],
scope: RateLimitScope::Project(ProjectId::new(21)),
reason_code: None,
retry_after: RetryAfter::from_secs(4711),
});
let formatted = format_rate_limits(&rate_limits);
let expected = "42::organization:my_limit, 4711:transaction;security:project";
assert_eq!(formatted, expected);
} | rust_cleaned_test_functions.jsonl/101156 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 407
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8955,
9246,
31820,
368,
341,
286,
1077,
5206,
4379,
31820,
284,
19775,
94588,
486,
931,
1428,
286,
442,
2691,
264,
13954,
4379,
3930,
369,
678,
11059,
624,
286,
4379,
31820,
1364,
2785,
349,
16527... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_scala_version() {
let scala_2_13 =
"Scala compiler version 2.13.5 -- Copyright 2002-2020, LAMP/EPFL and Lightbend, Inc.";
assert_eq!(parse_scala_version(scala_2_13), Some("2.13.5".to_string()));
} | rust_cleaned_test_functions.jsonl/23148 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 124
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
28656,
64,
9438,
368,
341,
286,
1077,
15771,
62,
17,
62,
16,
18,
4035,
310,
330,
93231,
19415,
2319,
220,
17,
13,
16,
18,
13,
20,
1177,
2955,
220,
17,
15,
15,
17,
12,
17,
15,
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_try_borrow_mut_with_ok() {
let mut lazycell = LazyCell::new();
{
let result = lazycell.try_borrow_mut_with::<(), _>(|| Ok(1));
assert_eq!(result, Ok(&mut 1));
*result.unwrap() = 2;
}
assert_eq!(&mut 2, lazycell.borrow().unwrap());
} | rust_cleaned_test_functions.jsonl/5803 | {
"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,
53283,
880,
7768,
29523,
6615,
19817,
368,
341,
286,
1077,
5206,
64436,
3337,
613,
284,
44263,
3599,
486,
931,
543,
286,
341,
310,
1077,
1102,
284,
64436,
3337,
613,
48779,
880,
7768,
29523,
6615,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_encode_hashmap_with_numeric_key() {
use std::collections::HashMap;
let mut hm: HashMap<usize, bool> = HashMap::new();
hm.insert(1, true);
let json_str = super::as_pretty_json(&hm).to_string();
match Json::from_str(&json_str) {
Err(_) => panic!("Unable to parse json_str: {}", json_str),
_ => {} // it parsed and we are good to go
}
} | rust_cleaned_test_functions.jsonl/22756 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 208
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11224,
8950,
2186,
6615,
29418,
3097,
368,
341,
286,
990,
1460,
486,
51137,
486,
18497,
280,
286,
1077,
5206,
49362,
25,
10528,
90244,
11,
1807,
29,
284,
10528,
486,
931,
543,
286,
49362,
7030,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_chars_decoding() {
let mut bytes = [0u8; 4];
for c in range(0u32, 0x110000).filter_map(|c| ::core::char::from_u32(c)) {
let len = c.encode_utf8(&mut bytes).unwrap_or(0);
let s = ::core::str::from_utf8(&bytes[..len]).unwrap();
if Some(c) != s.chars().next() {
panic!("character {:x}={} does not decode correctly", c as u32, c);
}
}
} | rust_cleaned_test_functions.jsonl/2467 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 238
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
37418,
13783,
3700,
368,
341,
286,
1077,
5206,
5820,
284,
508,
15,
84,
23,
26,
220,
19,
935,
286,
369,
272,
304,
2088,
7,
15,
84,
18,
17,
11,
220,
15,
87,
16,
16,
15,
15,
15,
15,
568,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_invalid_mode() {
assert_eq!(
split_mode_string("rbsss"),
Err("invalid mode: 'rbsss'".to_owned())
);
assert_eq!(
split_mode_string("rrb"),
Err("invalid mode: 'rrb'".to_owned())
);
assert_eq!(
split_mode_string("rbb"),
Err("invalid mode: 'rbb'".to_owned())
);
} | rust_cleaned_test_functions.jsonl/105632 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 289
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31433,
7302,
368,
341,
310,
2060,
10714,
33673,
394,
6718,
7302,
3904,
445,
10681,
84160,
4461,
394,
15495,
445,
11808,
3856,
25,
364,
10681,
84160,
6,
3263,
983,
51973,
2398,
310,
1439,
310,
2060... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_update_array_with_two_integers() {
let data = vec![0x82, 0x01, 0x02];
let mut parsed: ParsedArray<super::ParsedArraySize2> =
ParsedArray::deserialize_data(&data).expect("Failed to parse");
assert_eq!(parsed.raw_values(), vec![vec![0x01], vec![0x02]]);
assert_eq!(parsed.get::<u8>(0).unwrap(), 1);
assert_eq!(parsed.get::<u8>(1).unwrap(), 2);
let new = 3;
parsed.set(1, &new).expect("Failed to update");
assert_eq!(parsed.get::<u8>(1).unwrap(), 3);
let serialized = parsed.serialize_data().expect("Failed to serialize");
assert_eq!(serialized, vec![0x82, 0x01, 0x03]);
} | rust_cleaned_test_functions.jsonl/10822 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 341
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8882,
3858,
6615,
23241,
4042,
67592,
368,
341,
286,
1077,
821,
284,
7486,
20703,
15,
87,
23,
17,
11,
220,
15,
87,
15,
16,
11,
220,
15,
87,
15,
17,
935,
286,
1077,
5206,
15676,
25,
393,
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_fetch_problem_list() {
let client = AtCoderClient::default();
let problems = block_on(client.fetch_problem_list("abc107")).unwrap();
assert_eq!(problems.len(), 4);
} | rust_cleaned_test_functions.jsonl/132992 | {
"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,
11803,
60139,
2019,
368,
341,
286,
1077,
2943,
284,
2411,
35290,
2959,
486,
2258,
543,
286,
1077,
5322,
284,
2504,
4470,
12805,
16121,
60139,
2019,
445,
13683,
16,
15,
22,
15197,
15454,
543,
286,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_ft_on_transfer() {
let mut runner = AuroraRunner::new();
let nep141 = "tt.testnet".to_string();
let alice = "alice".to_string();
let token = runner.deploy_erc20_token(&nep141);
let amount = 10;
let recipient = runner.create_account().address;
let balance = runner.balance_of(token, recipient, origin());
assert_eq!(balance, U256::from(0));
let res = runner.ft_on_transfer(nep141, alice.clone(), alice, amount, hex::encode(recipient));
// Transaction should succeed so return amount is 0
assert_eq!(res, "\"0\"");
let balance = runner.balance_of(token, recipient, origin());
assert_eq!(balance, U256::from(amount));
} | rust_cleaned_test_functions.jsonl/11798 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 255
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
41572,
4470,
35403,
368,
341,
262,
1077,
5206,
22259,
284,
46792,
19486,
486,
931,
543,
262,
1077,
91534,
16,
19,
16,
284,
330,
5566,
5958,
4711,
3263,
983,
3904,
543,
262,
1077,
70433,
284,
330... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_round_timeout_increase() {
let sandbox = timestamping_sandbox();
let sandbox_state = SandboxState::new();
sandbox.add_time(Duration::from_millis(sandbox.first_round_timeout() - 1));
sandbox.assert_state(Height(1), Round(1));
sandbox.add_time(Duration::from_millis(1));
sandbox.assert_state(Height(1), Round(2));
sandbox.add_time(Duration::from_millis(
sandbox.first_round_timeout() + sandbox.round_timeout_increase() - 1,
));
sandbox.assert_state(Height(1), Round(2));
sandbox.add_time(Duration::from_millis(1));
sandbox.assert_state(Height(1), Round(3));
//to make sure that there are no unchecked messages from validator 0 we skip round 3
add_round_with_transactions(&sandbox, &sandbox_state, &[]);
sandbox.assert_state(Height(1), Round(4));
sandbox.add_time(Duration::from_millis(
sandbox.first_round_timeout() + 3 * sandbox.round_timeout_increase() - 1,
));
sandbox.assert_state(Height(1), Round(4));
sandbox.add_time(Duration::from_millis(1));
sandbox.assert_state(Height(1), Round(5));
} | rust_cleaned_test_functions.jsonl/87836 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 415
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
29896,
20537,
73807,
368,
341,
262,
1077,
42754,
284,
11441,
287,
643,
31536,
543,
262,
1077,
42754,
4387,
284,
96860,
1397,
486,
931,
1428,
262,
42754,
1364,
3009,
64114,
486,
1499,
717,
56212,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_dive_aim_example() {
let input = utils::read_file_lines("input/day2_1.txt".to_string());
assert_eq!(Day2::dive_aim(input), 900);
} | rust_cleaned_test_functions.jsonl/55650 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 85
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
814,
533,
62,
2640,
39304,
368,
341,
286,
1077,
1946,
284,
12439,
486,
878,
2458,
18323,
445,
1355,
44739,
17,
62,
16,
3909,
3263,
983,
3904,
1423,
286,
2060,
10714,
10297,
10159,
17,
486,
67,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_c_layout() {
let arr = Array::<i32, Ix2>::from_shape_vec((2, 2), vec![1, 2, 3, 4]).unwrap();
assert!(arr.is_standard_layout());
test_as_standard_layout_for(arr);
} | rust_cleaned_test_functions.jsonl/92646 | {
"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,
666,
14466,
368,
341,
286,
1077,
2890,
284,
2910,
27638,
72,
18,
17,
11,
358,
87,
17,
6831,
1499,
13597,
13251,
1188,
17,
11,
220,
17,
701,
7486,
20703,
16,
11,
220,
17,
11,
220,
18,
11,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_print() -> TestResult {
// TODO: If POLAR_LOG is on this test will fail.
let p = Polar::new();
p.load_str("f(x,y,z) if print(x, y, z);")?;
let message_handler = |output: &Message| {
assert!(matches!(&output.kind, MessageKind::Print));
assert_eq!(&output.msg, "1, 2, 3");
};
let q = p.new_query("f(1, 2, 3)", false)?;
let _results = query_results!(q, @msgs message_handler);
Ok(())
} | rust_cleaned_test_functions.jsonl/97645 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 205
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10064,
368,
1464,
3393,
2077,
341,
262,
442,
5343,
25,
1416,
31640,
934,
8419,
374,
389,
419,
1273,
686,
3690,
624,
262,
1077,
281,
284,
55896,
486,
931,
543,
262,
281,
5104,
2895,
445,
69,
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... | 3 |
#[test]
fn test_router_detect1() {
let router = Router::default().push(
Router::with_path("users")
.push(Router::with_path("<id>").push(Router::with_path("emails").get(fake_handler))),
);
let mut req: Request = hyper::Request::builder()
.uri("http://local.host/users/12/emails")
.body(hyper::Body::empty())
.unwrap()
.into();
let mut path_state = PathState::new(req.uri().path());
let matched = router.detect(&mut req, &mut path_state);
assert!(matched.is_some());
} | rust_cleaned_test_functions.jsonl/3294 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 289
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
55587,
56457,
16,
368,
341,
286,
1077,
9273,
284,
10554,
486,
2258,
1005,
9077,
1006,
310,
10554,
486,
4197,
2638,
445,
4218,
1138,
394,
659,
9077,
2785,
2676,
486,
4197,
2638,
9639,
307,
61032,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_vectors_ipv6hint() {
let rdata =
b"\x00\x01\
\x03\x66\x6f\x6f\x07\x65\x78\x61\x6d\x70\x6c\x65\x03\x63\x6f\x6d\x00\
\x00\x06\
\x00\x20\
\x20\x01\x0d\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\
\x20\x01\x0d\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x53\x00\x01";
// parse test
let mut parser = Parser::from_ref(rdata.as_ref());
let svcb = Svcb::parse(&mut parser).unwrap();
assert_eq!(1, svcb.priority);
assert_eq!(
"foo.example.com".parse::<Dname<Octets512>>().unwrap(),
svcb.target
);
let mut param_iter = svcb.iter();
let r = param_iter.next();
match r {
Some(Ok(AllParams::Ipv6Hint(param))) => {
let mut iter = param.iter();
assert_eq!(
"2001:db8::1",
format!("{}", iter.next().unwrap().unwrap()),
);
assert_eq!(
"2001:db8::53:1",
format!("{}", iter.next().unwrap().unwrap()),
);
assert_eq!(None, iter.next());
}
_ => panic!("{:?}", r),
}
assert_eq!(None, param_iter.next());
// compose test
let mut svcb_builder =
Svcb::new(svcb.priority, svcb.target, Octets512::new());
let mut ipv6_hint_builder = param::Ipv6Hint::new(Octets512::new());
ipv6_hint_builder
.push(
[
0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
]
.into(),
)
.unwrap();
ipv6_hint_builder
.push(
[
0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x53, 0x00, 0x01,
]
.into(),
)
.unwrap();
svcb_builder
.push(ipv6_hint_builder.freeze().into())
.unwrap();
let mut buf = Octets512::new();
svcb_builder.freeze().compose(&mut buf).unwrap();
assert_eq!(rdata.as_ref(), buf.as_ref());
} | rust_cleaned_test_functions.jsonl/132757 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1516
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
49158,
49378,
21,
46125,
368,
341,
286,
1077,
435,
691,
4035,
310,
293,
11934,
87,
15,
15,
3462,
15,
16,
5661,
1060,
1124,
87,
15,
18,
3462,
21,
21,
3462,
21,
69,
3462,
21,
69,
3462,
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... | 2 |
#[test]
fn test_part_2() {
assert_eq!(run(INPUT_1, true), 610);
assert_eq!(run(INPUT_2, true), 410);
assert_eq!(run(include_str!("../../input/03.txt"), true), 14358);
} | rust_cleaned_test_functions.jsonl/8087 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 105
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10495,
62,
17,
368,
341,
286,
2060,
10714,
10297,
6108,
57911,
62,
16,
11,
830,
701,
220,
21,
16,
15,
317,
286,
2060,
10714,
10297,
6108,
57911,
62,
17,
11,
830,
701,
220,
19,
16,
15,
317,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_movavg() {
let mut ma = MovAvg::new(4, 10.0);
assert_eq!(ma.avg, 10.0);
assert_eq!(ma.update(50.0), 20.0);
} | rust_cleaned_test_functions.jsonl/11968 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 95
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
55798,
13961,
368,
341,
286,
1077,
5206,
7491,
284,
53285,
39447,
486,
931,
7,
19,
11,
220,
16,
15,
13,
15,
317,
286,
2060,
10714,
10297,
1728,
61071,
11,
220,
16,
15,
13,
15,
317,
286,
2060... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_invalid_age() {
test_login("Sergio", "password", "20", Status::Ok, "must be at least 21.");
test_login("Sergio", "password", "-100", Status::Ok, "must be at least 21.");
test_login("Sergio", "password", "hi", Status::Ok, "value is not a number");
} | rust_cleaned_test_functions.jsonl/46557 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 111
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31433,
32053,
368,
341,
262,
1273,
13681,
445,
50,
2375,
815,
497,
330,
3833,
497,
330,
17,
15,
497,
8104,
486,
11578,
11,
330,
24812,
387,
518,
3245,
220,
17,
16,
7320,
262,
1273,
13681,
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_time_squashing() {
assert!(time_squash(2000u64, 9, 27) < time_squash(2001u64, 8, 13));
assert!(time_squash(2000u64, 9, 27) > time_squash(1997u64, 5, 27));
} | rust_cleaned_test_functions.jsonl/39030 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 101
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3009,
643,
446,
19049,
368,
341,
286,
2060,
10297,
1678,
643,
446,
988,
7,
17,
15,
15,
15,
84,
21,
19,
11,
220,
24,
11,
220,
17,
22,
8,
366,
882,
643,
446,
988,
7,
17,
15,
15,
16,
84,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_symlink_as_root() {
let mut te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);
te.create_broken_symlink("broken_symlink")
.expect("Failed to create broken symlink.");
// Key points:
// More:
let parent_parent = if cfg!(windows) { ".." } else { "../.." };
te.assert_output_subdirectory(
"symlink",
&["", parent_parent],
&format!(
"{dir}/a.foo
{dir}/broken_symlink
{dir}/e1 e2
{dir}/one
{dir}/one/b.foo
{dir}/one/two
{dir}/one/two/c.foo
{dir}/one/two/C.Foo2
{dir}/one/two/three
{dir}/one/two/three/d.foo
{dir}/one/two/three/directory_foo
{dir}/symlink",
dir = &parent_parent
),
);
} | rust_cleaned_test_functions.jsonl/10884 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 527
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
58530,
44243,
11898,
12993,
368,
341,
262,
1077,
5206,
1013,
284,
3393,
14359,
486,
931,
43175,
90560,
11,
11955,
48010,
317,
262,
1013,
2520,
880,
81709,
58530,
44243,
445,
48909,
58530,
44243,
113... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_origin() {
let origin = Header::parse_header(&vec![b"http://foo.com".to_vec()].into());
assert_eq!(origin.ok(), Some(Origin::new("http", "foo.com", None)));
let origin = Header::parse_header(&vec![b"https://foo.com:443".to_vec()].into());
assert_eq!(origin.ok(), Some(Origin::new("https", "foo.com", Some(443))));
} | rust_cleaned_test_functions.jsonl/13282 | {
"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,
34043,
368,
341,
286,
1077,
6238,
284,
12104,
486,
6400,
8757,
2099,
4083,
20703,
65,
76932,
1110,
7975,
905,
3263,
983,
13251,
57590,
18122,
1423,
286,
2060,
10714,
10297,
8611,
18165,
1507,
4329,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_tags_with_parse_error() {
let language = get_language("python");
let tags_config = TagsConfiguration::new(language, PYTHON_TAG_QUERY, "").unwrap();
let mut tag_context = TagsContext::new();
let source = br#"
class Fine: pass
class Bad
"#;
let (tags, failed) = tag_context
.generate_tags(&tags_config, source, None)
.unwrap();
let newtags = tags.collect::<Result<Vec<_>, _>>().unwrap();
assert!(failed, "syntax error should have been detected");
assert_eq!(
newtags
.iter()
.map(|t| (
substr(source, &t.name_range),
tags_config.syntax_type_name(t.syntax_type_id)
))
.collect::<Vec<_>>(),
&[("Fine", "class"),]
);
} | rust_cleaned_test_functions.jsonl/66041 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 379
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16333,
6615,
21039,
4096,
368,
341,
262,
1077,
4128,
284,
633,
29021,
445,
12669,
797,
262,
1077,
9492,
5332,
284,
27683,
7688,
486,
931,
60740,
11,
76678,
16592,
31585,
11,
35229,
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_adjust_lockouts_after_replay_vote_on_root() {
let mut tower = Tower::new_for_tests(10, 0.9);
tower.vote_state.root_slot = Some(42);
tower.vote_state.votes.push_back(Lockout::new(42));
tower.vote_state.votes.push_back(Lockout::new(43));
tower.vote_state.votes.push_back(Lockout::new(44));
let vote = Vote::new(vec![44], Hash::default());
tower.last_vote = vote;
let mut slot_history = SlotHistory::default();
slot_history.add(42);
let tower = tower.adjust_lockouts_after_replay(42, &slot_history);
assert_eq!(tower.unwrap().voted_slots(), [43, 44]);
} | rust_cleaned_test_functions.jsonl/61178 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 299
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
44153,
9818,
11672,
19844,
1288,
1363,
54360,
4470,
12993,
368,
341,
286,
1077,
5206,
21271,
284,
21938,
486,
931,
5478,
32509,
7,
16,
15,
11,
220,
15,
13,
24,
317,
286,
21271,
79422,
4387,
1257... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_add_from_impl_struct_variant() {
check_assist_not_applicable(add_from_impl_for_enum, "enum A { <|>One { x: u32 } }");
} | rust_cleaned_test_functions.jsonl/15727 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 76
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
5673,
21007,
15126,
46112,
368,
341,
286,
1779,
12083,
380,
7913,
8191,
46114,
25906,
5673,
21007,
5478,
31054,
11,
330,
9018,
362,
314,
82639,
29,
3966,
314,
856,
25,
575,
18,
17,
335,
33... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_struct_field_completion_for_method_call() {
mark::check!(test_no_struct_field_completion_for_method_call);
check(
r#"
struct A { the_field: u32 }
fn foo(a: A) { a.$0() }
"#,
expect![[""]],
);
} | rust_cleaned_test_functions.jsonl/26248 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 146
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6536,
15126,
5013,
60164,
5478,
9032,
13429,
368,
341,
286,
1868,
486,
2028,
10297,
1944,
6536,
15126,
5013,
60164,
5478,
9032,
13429,
317,
286,
1779,
1006,
310,
435,
2,
698,
1235,
362,
314,
279,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_leaves() {
let mut rng = CustomRng;
let mut tree = MerkleTree::new(create(3), POOL_PARAMS.clone());
let leaves_count = 6;
for index in 0..leaves_count {
let leaf = rng.gen();
tree.add_hash(index, leaf, true);
}
let leaves = tree.get_leaves();
assert_eq!(leaves.len(), leaves_count as usize);
for index in 0..leaves_count {
assert!(leaves.iter().any(|node| node.index == index));
}
} | rust_cleaned_test_functions.jsonl/23756 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 260
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
11751,
4693,
368,
341,
286,
1077,
5206,
28422,
284,
8406,
49,
968,
280,
286,
1077,
5206,
4916,
284,
8755,
23089,
6533,
486,
931,
32602,
7,
18,
701,
12932,
1930,
37488,
15997,
5231,
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_split_full_amount_minimum_stake_delegation() {
for (stake_delegation, expected_result) in [
(MINIMUM_STAKE_DELEGATION, Ok(())),
(
MINIMUM_STAKE_DELEGATION - 1,
Err(InstructionError::InsufficientFunds),
),
] {
let rent = Rent::default();
let rent_exempt_reserve = rent.minimum_balance(std::mem::size_of::<StakeState>());
let source_pubkey = Pubkey::new_unique();
let source_meta = Meta {
rent_exempt_reserve,
..Meta::auto(&source_pubkey)
};
for source_stake_state in &[
StakeState::Initialized(source_meta),
StakeState::Stake(source_meta, just_stake(stake_delegation)),
] {
let source_account = AccountSharedData::new_ref_data_with_space(
stake_delegation + rent_exempt_reserve,
source_stake_state,
std::mem::size_of::<StakeState>(),
&id(),
)
.unwrap();
let source_keyed_account = KeyedAccount::new(&source_pubkey, true, &source_account);
let dest_pubkey = Pubkey::new_unique();
let dest_account = AccountSharedData::new_ref_data_with_space(
0,
&StakeState::Uninitialized,
std::mem::size_of::<StakeState>(),
&id(),
)
.unwrap();
let dest_keyed_account = KeyedAccount::new(&dest_pubkey, true, &dest_account);
assert_eq!(
expected_result,
source_keyed_account.split(
source_keyed_account.lamports().unwrap(),
&dest_keyed_account,
&HashSet::from([source_pubkey]),
),
);
}
}
} | rust_cleaned_test_functions.jsonl/87041 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1169
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17052,
16372,
13471,
84855,
1261,
726,
2259,
87566,
368,
341,
286,
369,
320,
267,
726,
2259,
87566,
11,
3601,
5287,
8,
304,
2278,
310,
320,
16413,
40025,
2402,
25474,
2881,
35213,
3495,
11,
7622,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_borrow_mut_with_already_filled() {
let mut lazycell = LazyCell::new();
lazycell.fill(1).unwrap();
let value = lazycell.borrow_mut_with(|| 1);
assert_eq!(&1, value);
} | rust_cleaned_test_functions.jsonl/5797 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 110
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
880,
7768,
29523,
6615,
80772,
90592,
368,
341,
286,
1077,
5206,
64436,
3337,
613,
284,
44263,
3599,
486,
931,
543,
286,
64436,
3337,
613,
12467,
7,
16,
568,
15454,
1428,
286,
1077,
897,
284,
64... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
#[test]
fn test_set_should_succeed() {
let mut matrix = MatrixBuf::new(42, 4.2);
matrix.as_matrix_mut().set(13, 7, 0.42);
assert_eq!(matrix.as_matrix().row(13)[7], 0.42);
} | rust_cleaned_test_functions.jsonl/34510 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 95
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2602,
43378,
643,
29264,
368,
341,
262,
1077,
5206,
6172,
284,
11631,
15064,
486,
931,
7,
19,
17,
11,
220,
19,
13,
17,
317,
262,
6172,
5357,
10193,
29523,
1005,
746,
7,
16,
18,
11,
220,
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_ls_width() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
at.touch(&at.plus_as_string("test-width-1"));
at.touch(&at.plus_as_string("test-width-2"));
at.touch(&at.plus_as_string("test-width-3"));
at.touch(&at.plus_as_string("test-width-4"));
for option in &["-w 100", "-w=100", "--width=100", "--width 100"] {
scene
.ucmd()
.args(&option.split(" ").collect::<Vec<_>>())
.succeeds()
.stdout_only("test-width-1 test-width-2 test-width-3 test-width-4\n");
}
for option in &["-w 50", "-w=50", "--width=50", "--width 50"] {
scene
.ucmd()
.args(&option.split(" ").collect::<Vec<_>>())
.succeeds()
.stdout_only("test-width-1 test-width-3\ntest-width-2 test-width-4\n");
}
for option in &[
"-w 25",
"-w=25",
"--width=25",
"--width 25",
"-w 0",
"-w=0",
"--width=0",
"--width 0",
] {
scene
.ucmd()
.args(&option.split(" ").collect::<Vec<_>>())
.succeeds()
.stdout_only("test-width-1\ntest-width-2\ntest-width-3\ntest-width-4\n");
}
scene
.ucmd()
.arg("-w=bad")
.fails()
.stderr_contains("invalid line width");
for option in &["-w 1a", "-w=1a", "--width=1a", "--width 1a"] {
scene
.ucmd()
.args(&option.split(" ").collect::<Vec<_>>())
.fails()
.stderr_only("ls: error: invalid line width: ‘1a’");
}
} | rust_cleaned_test_functions.jsonl/71195 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 903
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
53174,
7927,
368,
341,
262,
1077,
6109,
284,
3393,
54031,
486,
931,
67811,
1269,
0,
1423,
262,
1077,
518,
284,
609,
22483,
67785,
18513,
280,
262,
518,
42129,
2099,
266,
60540,
11898,
3904,
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... | 5 |
#[test]
fn test_boolean_buffer_builder_write_bytes() {
let mut b = BooleanBufferBuilder::new(4);
b.append(false);
b.append(true);
b.append(false);
b.append(true);
assert_eq!(4, b.len());
assert_eq!(512, b.capacity());
let buffer = b.finish();
assert_eq!(1, buffer.len());
// Overallocate capacity
let mut b = BooleanBufferBuilder::new(8);
b.append_slice(&[false, true, false, true]);
assert_eq!(4, b.len());
assert_eq!(512, b.capacity());
let buffer = b.finish();
assert_eq!(1, buffer.len());
} | rust_cleaned_test_functions.jsonl/87771 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 308
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
46642,
7776,
28532,
9165,
12524,
368,
341,
286,
1077,
5206,
293,
284,
6992,
4095,
3297,
486,
931,
7,
19,
317,
286,
293,
2057,
3576,
317,
286,
293,
2057,
3715,
317,
286,
293,
2057,
3576,
317,
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_ipv6_packet_too_big() {
// Test sending an IPv6 Packet Too Big Error when receiving a packet that is
// too big to be forwarded when it isn't destined for the node it arrived at.
let dummy_config = get_dummy_config::<Ipv6Addr>();
let mut state_builder = StackStateBuilder::default();
state_builder.ip_builder().forward(true);
let mut ndp_configs = crate::device::ndp::NdpConfigurations::default();
ndp_configs.set_dup_addr_detect_transmits(None);
state_builder.device_builder().set_default_ndp_configs(ndp_configs);
let mut dispatcher_builder = DummyEventDispatcherBuilder::from_config(dummy_config.clone());
let extra_ip = Ipv6Addr::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 168, 0, 100]);
let extra_mac = Mac::new([13, 14, 15, 16, 17, 18]);
dispatcher_builder.add_ndp_table_entry(0, extra_ip, extra_mac);
dispatcher_builder.add_ndp_table_entry(0, extra_mac.to_ipv6_link_local().get(), extra_mac);
let mut ctx = dispatcher_builder.build_with(state_builder, DummyEventDispatcher::default());
let device = DeviceId::new_ethernet(0);
let frame_dst = FrameDestination::Unicast;
let mut rng = new_rng(70812476915813);
let mut body: Vec<u8> = std::iter::repeat_with(|| rng.gen()).take(5000).collect();
let mut ipv6_packet_buf = Buf::new(body.clone(), ..)
.encapsulate(Ipv6PacketBuilder::new(extra_ip, dummy_config.remote_ip, 64, IpProto::Tcp))
.serialize_vec_outer()
.unwrap();
// Receive the IP packet.
receive_ip_packet::<_, _, Ipv6>(&mut ctx, device, frame_dst, ipv6_packet_buf.clone());
// Should not have dispatched the packet.
assert_eq!(get_counter_val(&mut ctx, "dispatch_receive_ip_packet"), 0);
assert_eq!(get_counter_val(&mut ctx, "send_icmpv6_packet_too_big"), 1);
// Should have sent out one frame though.
assert_eq!(ctx.dispatcher.frames_sent().len(), 1);
// Received packet should be a Packet Too Big ICMP error message.
let mut buf = &ctx.dispatcher.frames_sent()[0].1[..];
// The original packet's TTL gets decremented so we decrement here
// to validate the rest of the icmp message body.
let ipv6_packet_buf_mut: &mut [u8] = ipv6_packet_buf.as_mut();
ipv6_packet_buf_mut[7] -= 1;
let (_, _, _, _, message, code) =
parse_icmp_packet_in_ip_packet_in_ethernet_frame::<Ipv6, _, Icmpv6PacketTooBig, _>(
buf,
move |packet| {
// Size of the ICMP message body should be size of the
// MTU without IP and ICMP headers.
let expected_len = 1280 - 48;
let actual_body: &[u8] = ipv6_packet_buf.as_ref();
let actual_body = &actual_body[..expected_len];
assert_eq!(packet.body().len(), expected_len);
assert_eq!(packet.body().bytes(), actual_body);
},
)
.unwrap();
assert_eq!(code, IcmpUnusedCode);
// MTU should match the mtu for the link.
assert_eq!(message, Icmpv6PacketTooBig::new(1280));
} | rust_cleaned_test_functions.jsonl/94412 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1568
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
49378,
21,
21078,
2346,
78,
36386,
368,
341,
1789,
286,
442,
3393,
11628,
458,
31560,
21,
28889,
24599,
6164,
4600,
979,
12308,
264,
10151,
429,
374,
198,
286,
442,
2238,
2409,
311,
387,
52246,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_folder_dup() {
let items = vec![
Path::new("a/file.txt"),
Path::new("a/file2.txt"),
];
let tree =
FileTreeItems::new(&items, &BTreeSet::new()).unwrap();
assert_eq!(tree.file_count(), 2);
assert_eq!(tree.len(), 3);
let res = tree
.tree_items
.iter()
.map(|i| i.info().full_path_str().to_string())
.collect::<Vec<_>>();
assert_eq!(
res,
vec![
String::from("a"),
String::from("a/file.txt"),
String::from("a/file2.txt"),
]
);
} | rust_cleaned_test_functions.jsonl/129790 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 259
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15268,
51932,
368,
341,
197,
10217,
3589,
284,
7486,
90515,
298,
69640,
486,
931,
445,
64,
23903,
3909,
3975,
2303,
298,
69640,
486,
931,
445,
64,
23903,
17,
3909,
3975,
715,
197,
197,
4821,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_max_power_of_2() {
assert_eq!(max_power_of_2(0), 0);
assert_eq!(max_power_of_2(1), 0);
assert_eq!(max_power_of_2(2), 1);
assert_eq!(max_power_of_2(4), 2);
assert_eq!(max_power_of_2(8), 3);
assert_eq!(max_power_of_2(16), 4);
assert_eq!(max_power_of_2(49), 5);
assert_eq!(max_power_of_2(std::u16::MAX), 15);
} | rust_cleaned_test_functions.jsonl/70021 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 233
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6345,
20421,
3575,
62,
17,
368,
341,
286,
2060,
10714,
10297,
2810,
20421,
3575,
62,
17,
7,
15,
701,
220,
15,
317,
286,
2060,
10714,
10297,
2810,
20421,
3575,
62,
17,
7,
16,
701,
220,
15,
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_whitelist_pre_ipo_asset() {
let mut deps = mock_dependencies(&[]);
deps.querier
.with_terraswap_pairs(&[(&"uusdmirror0000".to_string(), &"MIRLP0000".to_string())]);
let msg = InstantiateMsg {
base_denom: BASE_DENOM.to_string(),
token_code_id: TOKEN_CODE_ID,
distribution_schedule: vec![],
};
let info = mock_info("addr0000", &[]);
let _res = instantiate(deps.as_mut(), mock_env(), info.clone(), msg).unwrap();
let msg = ExecuteMsg::PostInitialize {
owner: "owner0000".to_string(),
mirror_token: "mirror0000".to_string(),
mint_contract: "mint0000".to_string(),
staking_contract: "staking0000".to_string(),
commission_collector: "collector0000".to_string(),
oracle_contract: "oracle0000".to_string(),
terraswap_factory: "terraswapfactory".to_string(),
};
let _res = execute(deps.as_mut(), mock_env(), info, msg).unwrap();
let msg = ExecuteMsg::Whitelist {
name: "pre-IPO asset".to_string(),
symbol: "mPreIPO".to_string(),
oracle_proxy: "oracleproxy0000".to_string(),
params: Params {
auction_discount: Decimal::percent(5),
min_collateral_ratio: Decimal::percent(1000),
weight: Some(100u32),
mint_period: Some(10000u64),
min_collateral_ratio_after_ipo: Some(Decimal::percent(150)),
pre_ipo_price: Some(Decimal::percent(1)),
ipo_trigger_addr: Some("trigger0000".to_string()),
},
};
let info = mock_info("owner0000", &[]);
let res = execute(deps.as_mut(), mock_env(), info, msg).unwrap();
// token creation submsg should be returned
assert_eq!(
res.messages,
vec![SubMsg {
msg: WasmMsg::Instantiate {
admin: None,
code_id: TOKEN_CODE_ID,
funds: vec![],
label: "".to_string(),
msg: to_binary(&TokenInstantiateMsg {
name: "pre-IPO asset".to_string(),
symbol: "mPreIPO".to_string(),
decimals: 6u8,
initial_balances: vec![],
mint: Some(MinterResponse {
minter: "mint0000".to_string(),
cap: None,
}),
})
.unwrap(),
}
.into(),
gas_limit: None,
id: 1,
reply_on: ReplyOn::Success,
}]
);
let params: Params = read_params(&deps.storage).unwrap();
assert_eq!(
params,
Params {
auction_discount: Decimal::percent(5),
min_collateral_ratio: Decimal::percent(1000),
weight: Some(100u32),
mint_period: Some(10000u64),
min_collateral_ratio_after_ipo: Some(Decimal::percent(150)),
pre_ipo_price: Some(Decimal::percent(1)),
ipo_trigger_addr: Some("trigger0000".to_string())
}
);
//ensure temp oracle was stored
let tmp_oracle = read_tmp_oracle(&deps.storage).unwrap();
assert_eq!(tmp_oracle.to_string(), "oracleproxy0000");
// callback 1
let mut token_inst_res = MsgInstantiateContractResponse::new();
token_inst_res.set_contract_address("asset0000".to_string());
let reply_msg = Reply {
id: 1,
result: ContractResult::Ok(SubMsgExecutionResponse {
events: vec![],
data: Some(token_inst_res.write_to_bytes().unwrap().into()),
}),
};
let res = reply(deps.as_mut(), mock_env(), reply_msg).unwrap();
//ensure asset token was stored
let tmp_asset = read_tmp_asset(&deps.storage).unwrap();
assert_eq!(tmp_asset.to_string(), "asset0000");
assert_eq!(
res.messages,
vec![
SubMsg::new(CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: "mint0000".to_string(),
funds: vec![],
msg: to_binary(&MintExecuteMsg::RegisterAsset {
asset_token: "asset0000".to_string(),
auction_discount: Decimal::percent(5),
min_collateral_ratio: Decimal::percent(1000),
ipo_params: Some(IPOParams {
mint_end: mock_env().block.time.plus_seconds(10000u64).nanos()
/ 1_000_000_000,
min_collateral_ratio_after_ipo: Decimal::percent(150),
pre_ipo_price: Decimal::percent(1),
trigger_addr: "trigger0000".to_string()
}),
})
.unwrap(),
})),
SubMsg::new(CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: "oracle0000".to_string(),
funds: vec![],
msg: to_binary(&TeFiOracleExecuteMsg::RegisterProxy {
asset_token: "asset0000".to_string(),
proxy_addr: "oracleproxy0000".to_string(),
priority: None,
})
.unwrap(),
})),
SubMsg {
msg: WasmMsg::Execute {
contract_addr: "terraswapfactory".to_string(),
funds: vec![],
msg: to_binary(&TerraswapFactoryExecuteMsg::CreatePair {
asset_infos: [
AssetInfo::NativeToken {
denom: BASE_DENOM.to_string(),
},
AssetInfo::Token {
contract_addr: "asset0000".to_string(),
},
],
})
.unwrap(),
}
.into(),
gas_limit: None,
id: 2,
reply_on: ReplyOn::Success,
}
]
);
assert_eq!(
res.attributes,
vec![
attr("asset_token_addr", "asset0000"),
attr("is_pre_ipo", "true"),
attr(
"mint_end",
(mock_env().block.time.plus_seconds(10000u64).seconds()).to_string()
),
attr("min_collateral_ratio_after_ipo", "1.5"),
attr("pre_ipo_price", "0.01"),
attr("ipo_trigger_addr", "trigger0000"),
]
);
} | rust_cleaned_test_functions.jsonl/36379 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 3546
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36225,
57645,
10442,
62,
6943,
42299,
368,
341,
262,
1077,
5206,
48178,
284,
7860,
71841,
2099,
56703,
262,
48178,
13,
15959,
1268,
198,
286,
659,
4197,
72493,
12784,
21726,
36430,
2099,
58,
2099,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_var_and_long_string_are_equal() {
let text = r#" {% if var == "hello there!" %} true {% else %} false {% endif %} "#;
assert_template_result!(" true ", text, v!({"var": "hello there!"}));
} | rust_cleaned_test_functions.jsonl/28133 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 93
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4612,
8378,
17799,
3904,
56855,
11478,
368,
341,
262,
1077,
1467,
284,
435,
55543,
52261,
421,
762,
621,
330,
14990,
1052,
8958,
1018,
92,
830,
52261,
770,
1018,
92,
895,
52261,
12330,
1018,
92,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ln_pdf() {
test_case(0.0, 0.0, f64::NEG_INFINITY, |x| x.ln_pdf(-5.0));
test_case(0.0, 0.0, f64::INFINITY, |x| x.ln_pdf(0.0));
test_case(0.0, 0.0, f64::NEG_INFINITY, |x| x.ln_pdf(5.0));
test_case(0.0, 0.1, f64::NEG_INFINITY, |x| x.ln_pdf(-5.0));
test_almost(0.0, 0.1, 2.302585092994045684018, 1e-15, |x| x.ln_pdf(0.05));
test_case(0.0, 0.1, f64::NEG_INFINITY, |x| x.ln_pdf(5.0));
test_case(0.0, 1.0, f64::NEG_INFINITY, |x| x.ln_pdf(-5.0));
test_case(0.0, 1.0, 0.0, |x| x.ln_pdf(0.5));
test_case(0.0, 0.1, f64::NEG_INFINITY, |x| x.ln_pdf(5.0));
test_case(0.0, 10.0, f64::NEG_INFINITY, |x| x.ln_pdf(-5.0));
test_case(0.0, 10.0, -2.302585092994045684018, |x| x.ln_pdf(1.0));
test_case(0.0, 10.0, -2.302585092994045684018, |x| x.ln_pdf(5.0));
test_case(0.0, 10.0, f64::NEG_INFINITY, |x| x.ln_pdf(11.0));
test_case(-5.0, 100.0, f64::NEG_INFINITY, |x| x.ln_pdf(-10.0));
test_case(-5.0, 100.0, -4.653960350157523371101, |x| x.ln_pdf(-5.0));
test_case(-5.0, 100.0, -4.653960350157523371101, |x| x.ln_pdf(0.0));
test_case(-5.0, 100.0, f64::NEG_INFINITY, |x| x.ln_pdf(101.0));
test_case(0.0, f64::INFINITY, f64::NEG_INFINITY, |x| x.ln_pdf(-5.0));
test_case(0.0, f64::INFINITY, f64::NEG_INFINITY, |x| x.ln_pdf(10.0));
test_case(0.0, f64::INFINITY, f64::NEG_INFINITY, |x| x.ln_pdf(f64::INFINITY));
} | rust_cleaned_test_functions.jsonl/47375 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 908
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
60401,
39948,
368,
341,
286,
1273,
19096,
7,
15,
13,
15,
11,
220,
15,
13,
15,
11,
282,
21,
19,
486,
97127,
91110,
11,
760,
87,
91,
856,
918,
77,
39948,
4080,
20,
13,
15,
1106,
286,
1273,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_for_range_based() {
let source = Source::from_file(
"tests/for_range_based.cpp".to_owned(),
DeclarationFromPHCMode::Exclude,
DiagnosticsMode::Enabled,
vec!["-std=c+14".to_owned()],
TUOptionsBuilder::new(),
)
.unwrap();
let translation_units: Result<Vec<_>, _> = source.translation_units.into_iter().collect();
let translation_unit = translation_units.unwrap().into_iter().nth(0).unwrap();
let ast = translation_unit.ast();
assert_eq!(
ast,
&Entry {
current_kind: CursorKind::Root,
children: vec![Entry {
current_kind: CursorKind::Function {
spelling: "f".to_owned(),
display_name: "f(const std::vector<int> &)".to_owned(),
code_span: CodeSpan {
start_pos: Position {
file_name: "tests/for_range_based.cpp".to_owned(),
line: 3,
col: 1
},
end_pos: Position {
file_name: "tests/for_range_based.cpp".to_owned(),
line: 6,
col: 2
}
},
cur_type: CursorType::FunctionProto,
return_type: CursorType::Void,
canonical_return_type: CursorType::Void
},
children: vec![
Entry {
current_kind: CursorKind::Parameter(
"a".to_owned(),
CodeSpan {
start_pos: Position {
file_name: "tests/for_range_based.cpp".to_owned(),
line: 3,
col: 8
},
end_pos: Position {
file_name: "tests/for_range_based.cpp".to_owned(),
line: 3,
col: 33
}
},
CursorType::LValueReference
),
children: vec![
Entry {
current_kind: CursorKind::NamespaceReference(
"std".to_owned(),
CodeSpan {
start_pos: Position {
file_name: "tests/for_range_based.cpp".to_owned(),
line: 3,
col: 14
},
end_pos: Position {
file_name: "tests/for_range_based.cpp".to_owned(),
line: 3,
col: 17
}
}
),
children: vec![]
},
Entry {
current_kind: CursorKind::TemplateReference(
"vector".to_owned(),
CodeSpan {
start_pos: Position {
file_name: "tests/for_range_based.cpp".to_owned(),
line: 3,
col: 19
},
end_pos: Position {
file_name: "tests/for_range_based.cpp".to_owned(),
line: 3,
col: 25
}
}
),
children: vec![]
}
]
},
Entry {
current_kind: CursorKind::CompoundStatement(CodeSpan {
start_pos: Position {
file_name: "tests/for_range_based.cpp".to_owned(),
line: 3,
col: 35
},
end_pos: Position {
file_name: "tests/for_range_based.cpp".to_owned(),
line: 6,
col: 2
}
}),
children: vec![Entry {
current_kind: CursorKind::RangeBasedForStatement(CodeSpan {
start_pos: Position {
file_name: "tests/for_range_based.cpp".to_owned(),
line: 4,
col: 3
},
end_pos: Position {
file_name: "tests/for_range_based.cpp".to_owned(),
line: 5,
col: 4
}
}),
children: vec![
Entry {
current_kind: CursorKind::Variable(
"val".to_owned(),
CodeSpan {
start_pos: Position {
file_name: "tests/for_range_based.cpp".to_owned(),
line: 4,
col: 8
},
end_pos: Position {
file_name: "tests/for_range_based.cpp".to_owned(),
line: 4,
col: 25
}
},
CursorType::LValueReference
),
children: vec![Entry {
current_kind: CursorKind::CallExpression(
"operator*".to_owned(),
CodeSpan {
start_pos: Position {
file_name: "tests/for_range_based.cpp"
.to_owned(),
line: 4,
col: 24
},
end_pos: Position {
file_name: "tests/for_range_based.cpp"
.to_owned(),
line: 4,
col: 25
}
},
),
children: vec![
Entry {
current_kind: CursorKind::UnexposedExpression(
"__begin1".to_owned(),
CodeSpan {
start_pos: Position {
file_name: "tests/for_range_based.cpp"
.to_owned(),
line: 4,
col: 24
},
end_pos: Position {
file_name: "tests/for_range_based.cpp"
.to_owned(),
line: 4,
col: 25
}
}
),
children: vec![Entry {
current_kind:
CursorKind::DeclarationReferenceExpression(
"__begin1".to_owned(),
CodeSpan {
start_pos: Position {
file_name:
"tests/for_range_based.cpp"
.to_owned(),
line: 4,
col: 24
},
end_pos: Position {
file_name:
"tests/for_range_based.cpp"
.to_owned(),
line: 4,
col: 25
}
}
),
children: vec![]
}]
},
Entry {
current_kind: CursorKind::UnexposedExpression(
"operator*".to_owned(),
CodeSpan {
start_pos: Position {
file_name: "tests/for_range_based.cpp"
.to_owned(),
line: 4,
col: 24
},
end_pos: Position {
file_name: "tests/for_range_based.cpp"
.to_owned(),
line: 4,
col: 25
}
}
),
children: vec![Entry {
current_kind:
CursorKind::DeclarationReferenceExpression(
"operator*".to_owned(),
CodeSpan {
start_pos: Position {
file_name:
"tests/for_range_based.cpp"
.to_owned(),
line: 4,
col: 24
},
end_pos: Position {
file_name:
"tests/for_range_based.cpp"
.to_owned(),
line: 4,
col: 25
}
}
),
children: vec![]
}]
}
]
}]
},
Entry {
current_kind: CursorKind::DeclarationReferenceExpression(
"a".to_owned(),
CodeSpan {
start_pos: Position {
file_name: "tests/for_range_based.cpp".to_owned(),
line: 4,
col: 26
},
end_pos: Position {
file_name: "tests/for_range_based.cpp".to_owned(),
line: 4,
col: 27
}
}
),
children: vec![]
},
Entry {
current_kind: CursorKind::CompoundStatement(CodeSpan {
start_pos: Position {
file_name: "tests/for_range_based.cpp".to_owned(),
line: 4,
col: 29
},
end_pos: Position {
file_name: "tests/for_range_based.cpp".to_owned(),
line: 5,
col: 4
}
}),
children: vec![]
}
]
}]
}
]
}]
}
);
} | rust_cleaned_test_functions.jsonl/96432 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 13203
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5478,
9698,
66679,
368,
341,
262,
1077,
2530,
284,
8748,
486,
1499,
2458,
1006,
286,
330,
23841,
14,
1958,
9698,
66679,
7208,
3263,
983,
51973,
3148,
286,
40921,
3830,
10842,
34,
3636,
486,
95239,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_fold_array_lit_spread_get_elem() {
fold("x = [...[0 ]][0]", "x = 0;");
fold("x = [0, 1, ...[2, 3, 4]][3]", "x = 3;");
fold("x = [...[0, 1], 2, ...[3, 4]][3]", "x = 3;");
fold("x = [...[...[0, 1], 2, 3], 4][0]", "x = 0");
fold("x = [...[...[0, 1], 2, 3], 4][3]", "x = 3");
fold("x = [...[]][100]", "x = void 0;");
fold("x = [...[0]][100]", "x = void 0;");
} | rust_cleaned_test_functions.jsonl/122195 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 228
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
61187,
3858,
98399,
10123,
878,
3062,
28179,
368,
341,
262,
11555,
445,
87,
284,
16303,
58,
15,
262,
2279,
1457,
15,
19076,
330,
87,
284,
220,
15,
34649,
262,
11555,
445,
87,
284,
508,
15,
11,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_fetch_submission_list() {
let client = AtCoderClient::default();
let response = block_on(client.fetch_atcoder_submission_list("xmascon17", None)).unwrap();
assert_eq!(response.submissions.len(), 20);
let response =
block_on(client.fetch_atcoder_submission_list("xmascon17", Some(response.max_page)))
.unwrap();
assert!(!response.submissions.is_empty());
let response = block_on(
client.fetch_atcoder_submission_list("xmascon17", Some(response.max_page + 1)),
);
assert!(response.is_err());
} | rust_cleaned_test_functions.jsonl/132993 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 284
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11803,
75866,
2019,
368,
341,
286,
1077,
2943,
284,
2411,
35290,
2959,
486,
2258,
543,
286,
1077,
2033,
284,
2504,
4470,
12805,
16121,
3752,
40170,
75866,
2019,
445,
87,
6899,
443,
16,
22,
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_iter_reader() {
let mut r = IterReader::new(range(0u8, 8));
let mut buf = [0, 0, 0];
let len = r.read(&mut buf).unwrap();
assert_eq!(len, 3);
assert!(buf == [0, 1, 2]);
let len = r.read(&mut buf).unwrap();
assert_eq!(len, 3);
assert!(buf == [3, 4, 5]);
let len = r.read(&mut buf).unwrap();
assert_eq!(len, 2);
assert!(buf == [6, 7, 5]);
assert_eq!(r.read(&mut buf).unwrap_err().kind, io::EndOfFile);
} | rust_cleaned_test_functions.jsonl/91544 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 275
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11723,
22306,
368,
341,
286,
1077,
5206,
435,
284,
13704,
5062,
486,
931,
22345,
7,
15,
84,
23,
11,
220,
23,
1106,
286,
1077,
5206,
6607,
284,
508,
15,
11,
220,
15,
11,
220,
15,
935,
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_xpub_derive() {
let enc = fiatproof::ui::bitcoin::MAINNET.create_xpub_encoder();
let t = |parent:bip32::XPub, te:&TestEntity| -> bip32::XPub {
let xpub0 = te.xpub();
let xpub = parent.derive(te.index);
if te.is_hardened() {
assert!(xpub.is_err());
} else {
assert!(xpub.is_ok());
let xpub = xpub.unwrap();
assert_eq!(xpub.depth, xpub0.depth);
assert_eq!(xpub.index, xpub0.index);
assert_eq!(xpub.parent_fingerprint, xpub0.parent_fingerprint);
assert_eq!(xpub.chain_code, xpub0.chain_code);
assert_eq!(xpub.public_key, xpub0.public_key);
assert_eq!(enc.encode(&xpub).as_str(), te.xpub_hex);
}
xpub0
};
let xpub = TEST_VECTOR_1.e[0].xpub();
let xpub = t(xpub, &TEST_VECTOR_1.e[1]);
let xpub = t(xpub, &TEST_VECTOR_1.e[2]);
let xpub = t(xpub, &TEST_VECTOR_1.e[3]);
let xpub = t(xpub, &TEST_VECTOR_1.e[4]);
let _pub = t(xpub, &TEST_VECTOR_1.e[5]);
let xpub = TEST_VECTOR_2.e[0].xpub();
let xpub = t(xpub, &TEST_VECTOR_2.e[1]);
let xpub = t(xpub, &TEST_VECTOR_2.e[2]);
let xpub = t(xpub, &TEST_VECTOR_2.e[3]);
let xpub = t(xpub, &TEST_VECTOR_2.e[4]);
let _pub = t(xpub, &TEST_VECTOR_2.e[5]);
let xpub = TEST_VECTOR_3.e[0].xpub();
let _pub = t(xpub, &TEST_VECTOR_3.e[1]);
} | rust_cleaned_test_functions.jsonl/98410 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 749
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3212,
9585,
35345,
533,
368,
341,
256,
1077,
3209,
284,
53830,
15780,
486,
1963,
486,
83910,
486,
41815,
15373,
2520,
3212,
9585,
39068,
543,
256,
1077,
259,
284,
760,
3765,
43973,
573,
18,
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... | 2 |
#[test]
fn test_first_deal() {
use BJCard::*;
let mut rng = SmallRng::seed_from_u64(0_u64);
let (d, p) = first_deal(&mut rng);
assert_eq!(vec![Seven], d);
assert_eq!(vec![Ace, Eight], p);
} | rust_cleaned_test_functions.jsonl/74258 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 133
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12978,
2259,
278,
368,
341,
286,
990,
86499,
5770,
79304,
286,
1077,
5206,
28422,
284,
14994,
49,
968,
486,
22602,
5673,
7300,
21,
19,
7,
15,
7300,
21,
19,
317,
286,
1077,
320,
67,
11,
281,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_affine_reflection_y_axis1() {
// The y-axis is the normal vector to the plane of the y-axis.
let bias = Vector2::zero();
let normal = Unit::from_value(Vector2::unit_x());
let expected = Matrix3x3::new(
-1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0
);
let result = Matrix3x3::from_affine_reflection(&normal, &bias);
assert_eq!(result, expected);
} | rust_cleaned_test_functions.jsonl/129050 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 254
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5673,
48914,
482,
7793,
1170,
4178,
23567,
16,
368,
341,
286,
442,
576,
379,
35321,
374,
279,
4622,
4621,
311,
279,
11031,
315,
279,
379,
35321,
624,
286,
1077,
15470,
284,
4196,
17,
486,
14154,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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() {
let indicator = SlowStochastic::new(10, 2).unwrap();
assert_eq!(format!("{}", indicator), "SLOW_STOCH(10, 2)");
} | rust_cleaned_test_functions.jsonl/72388 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 81
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14825,
368,
341,
286,
1077,
20438,
284,
38147,
623,
65954,
486,
931,
7,
16,
15,
11,
220,
17,
568,
15454,
543,
286,
2060,
10714,
10297,
2243,
79878,
20438,
701,
330,
50,
9441,
2402,
46,
2149,
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 |
#[test]
fn test_str_to_ident() {
use proc_macro2::Span;
use schemafy_lib::str_to_ident;
use syn::Ident;
assert_eq!(
str_to_ident("normalField"),
Ident::new("normalField", Span::call_site())
);
assert_eq!(str_to_ident("ref"), Ident::new("ref_", Span::call_site()));
assert_eq!(str_to_ident(""), Ident::new("empty_", Span::call_site()));
assert_eq!(
str_to_ident("_"),
Ident::new("underscore_", Span::call_site())
);
assert_eq!(
str_to_ident("__"),
Ident::new("underscore_", Span::call_site())
);
assert_eq!(str_to_ident("_7_"), Ident::new("_7_", Span::call_site()));
assert_eq!(
str_to_ident("thieves' tools"),
// only one underscore
Ident::new("thieves_tools", Span::call_site())
);
} | rust_cleaned_test_functions.jsonl/97073 | {
"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,
2895,
2346,
38399,
368,
341,
262,
990,
13674,
58810,
17,
486,
12485,
280,
262,
990,
19650,
2577,
88,
16142,
486,
495,
2346,
38399,
280,
262,
990,
6782,
486,
28301,
401,
262,
2060,
10714,
33673,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_fails_to_verify_a_bad_signature_on_an_empty_string() {
let out_dir = std::env::var("OUT_DIR").unwrap();
let mut jscontext = JavaScript::new(format!("{}/xpring.js", out_dir))?;
let verified_message = verify(
&mut jscontext,
"".to_owned(),
"DEADBEEF".to_owned(),
"038BF420B5271ADA2D7479358FF98A29954CF18DC25155184AEAD05796DA737E89".to_owned(),
)?;
assert!(!verified_message);
} | rust_cleaned_test_functions.jsonl/118752 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 254
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
761,
6209,
2346,
35638,
4306,
34199,
39859,
4470,
12008,
15124,
3904,
368,
341,
286,
1077,
700,
4334,
284,
1460,
486,
3160,
486,
947,
445,
3656,
8291,
1827,
15454,
543,
286,
1077,
5206,
6994,
2147... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_hashable() {
let mut counter: HashMap<Method,usize> = HashMap::new();
counter.insert(Get, 1);
assert_eq!(Some(&1), counter.get(&Get));
} | rust_cleaned_test_functions.jsonl/73812 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 88
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8950,
480,
368,
341,
286,
1077,
5206,
5546,
25,
10528,
27,
3523,
11,
51878,
29,
284,
10528,
486,
931,
543,
286,
5546,
7030,
24460,
11,
220,
16,
317,
286,
2060,
10714,
10297,
8373,
2099,
16,
70... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_replace_range_out_of_bounds() {
let mut s = TinyString::<[u8; 8]>::from("12345");
s.replace_range(5..6, "789");
} | rust_cleaned_test_functions.jsonl/3645 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 66
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10633,
9698,
6068,
3575,
36878,
368,
341,
10217,
5206,
274,
284,
47974,
703,
27638,
58,
84,
23,
26,
220,
23,
60,
6831,
1499,
445,
16,
17,
18,
19,
20,
797,
1903,
6980,
9698,
7,
20,
496,
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 |
#[test]
fn test_stepper() {
let c = Connection::open_private("tcp:host=192.168.66.59,port=6666").expect("open private connection tcp:host=192.168.66.59,port=6666");
c.register();
let mut x = Stepper::new(&c,"/com/lar/nodes/Doppelmotor1".to_owned(),1);
let mut y = Stepper::new(&c,"/com/lar/nodes/Doppelmotor2".to_owned(),1);
let mut z = Stepper::new(&c,"/com/lar/nodes/Doppelmotor2".to_owned(),2);
println!("X:max {}",x.get_max().unwrap());
println!("X:pos {}",x.get_position().unwrap());
println!("X:par {}",x.get_parameter().unwrap());
println!("X:final {}",x.final_pos().unwrap());
println!("Y:max {}",y.get_max().unwrap());
println!("Y:pos {}",y.get_position().unwrap());
println!("Y:par {}",y.get_parameter().unwrap());
println!("Y:final {}",y.final_pos().unwrap());
println!("Z:max {}",z.get_max().unwrap());
println!("Z:pos {}",z.get_position().unwrap());
println!("Z:par {}",z.get_parameter().unwrap());
println!("Z:final {}",z.final_pos().unwrap());
} | rust_cleaned_test_functions.jsonl/68942 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 577
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
65937,
6922,
368,
341,
1789,
286,
1077,
272,
284,
11032,
486,
2508,
26249,
445,
27161,
72361,
28,
16,
24,
17,
13,
16,
21,
23,
13,
21,
21,
13,
20,
24,
96898,
28,
21,
21,
21,
21,
1827,
17119... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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.