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_number_successes() {
assert_token!("4", TokenKind::IntegerLiteral, 0, 1);
assert_token!("4.123", TokenKind::FloatLiteral, 0, 5);
assert_token!("-4", TokenKind::IntegerLiteral, 0, 2);
assert_token!("9", TokenKind::IntegerLiteral, 0, 1);
assert_token!("0", TokenKind::IntegerLiteral, 0, 1);
assert_token!("-4.123", TokenKind::FloatLiteral, 0, 6);
assert_token!("0.123", TokenKind::FloatLiteral, 0, 5);
assert_token!("123e4", TokenKind::FloatLiteral, 0, 5);
assert_token!("123E4", TokenKind::FloatLiteral, 0, 5);
assert_token!("123e-4", TokenKind::FloatLiteral, 0, 6);
assert_token!("123e+4", TokenKind::FloatLiteral, 0, 6);
assert_token!("-1.123e4", TokenKind::FloatLiteral, 0, 8);
assert_token!("-1.123E4", TokenKind::FloatLiteral, 0, 8);
assert_token!("-1.123e-4", TokenKind::FloatLiteral, 0, 9);
assert_token!("-1.123e+4", TokenKind::FloatLiteral, 0, 9);
assert_token!("-1.123e4567", TokenKind::FloatLiteral, 0, 11);
assert_token!("-0", TokenKind::IntegerLiteral, 0, 2);
} | rust_cleaned_test_functions.jsonl/1903 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 531
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5500,
18632,
288,
368,
341,
286,
2060,
6458,
17223,
19,
497,
9660,
10629,
486,
3486,
17350,
11,
220,
15,
11,
220,
16,
317,
286,
2060,
6458,
17223,
19,
13,
16,
17,
18,
497,
9660,
10629,
486,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_node_compact_reserve_max_ticks() {
let count = 5;
let mut cluster = new_node_cluster(0, count);
test_compact_reserve_max_ticks(&mut cluster);
} | rust_cleaned_test_functions.jsonl/110348 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 78
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5084,
18177,
531,
89591,
6345,
49961,
368,
341,
262,
1077,
1760,
284,
220,
20,
280,
262,
1077,
5206,
10652,
284,
501,
5084,
28441,
7,
15,
11,
1760,
317,
262,
1273,
18177,
531,
89591,
6345,
49961... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_second_order_problem_rkf45_adaptive() -> Result<(), Error> {
let dydt = |_t: f64, y: &[f64]| -> Vec<f64> { vec![y[1], -y[0]] };
let y_true = |t: f64| -> f64 { f64::cos(t) };
let options = AdaptiveOdeSolverOptions {
t_initial: 0.0,
t_final: 2.0 * PI,
dt_initial: PI / 4.0,
error_control: ErrorControlOptions::simple(1e-6),
};
let mut y = [1.0, 0.0];
rkf45_adaptive(&mut y, &dydt, &options)?;
let actual_error = (y_true(options.t_final) - y[0]).abs();
assert_lt!(actual_error, 1e-4);
assert_gt!(actual_error, 1e-7);
Ok(())
} | rust_cleaned_test_functions.jsonl/23083 | {
"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,
29644,
7869,
60139,
1710,
81869,
19,
20,
10027,
27781,
368,
1464,
5714,
68843,
4600,
29,
341,
286,
1077,
13955,
8047,
284,
70886,
83,
25,
282,
21,
19,
11,
379,
25,
44590,
69,
21,
19,
29685,
14... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_update_operation() {
assert_eq!(
"UPDATE Table SET field2 = field2 + 1 WHERE Table.id = 1",
to_sql!(Table.get(1).update(field2 += 1))
);
assert_eq!(
"UPDATE Table SET field2 = field2 - 3 WHERE Table.id = 1",
to_sql!(Table.get(1).update(field2 -= 3))
);
assert_eq!(
"UPDATE Table SET field2 = field2 % 7 WHERE Table.id = 1",
to_sql!(Table.get(1).update(field2 %= 7))
);
assert_eq!(
"UPDATE Table SET field2 = field2 * 2 WHERE Table.id = 1",
to_sql!(Table.get(1).update(field2 *= 2))
);
assert_eq!(
"UPDATE Table SET field2 = field2 / 3 WHERE Table.id = 1",
to_sql!(Table.get(1).update(field2 /= 3))
);
assert_eq!(
"UPDATE Table SET field2 = field2 + 10, field3 = field3 / 3 WHERE Table.id = 1",
to_sql!(Table.get(1).update(field2 += 10, field3 /= 3))
);
} | rust_cleaned_test_functions.jsonl/50739 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 434
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8882,
32565,
368,
341,
262,
2060,
10714,
33673,
286,
330,
9239,
6633,
9019,
2070,
17,
284,
2070,
17,
488,
220,
16,
5288,
6633,
1764,
284,
220,
16,
756,
286,
311,
18063,
10297,
2556,
670,
7,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_convert_accumulator_proof_malformed_hashes() {
let mut sibling0 = b"0".test_only_hash().to_vec();
sibling0.push(1);
let mut compressed_proof = crate::proto::proof::AccumulatorProof::new();
compressed_proof.set_bitmap(0b100);
compressed_proof.mut_non_default_siblings().push(sibling0);
assert!(AccumulatorProof::from_proto(compressed_proof).is_err());
} | rust_cleaned_test_functions.jsonl/103130 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 156
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34910,
75837,
10511,
86757,
717,
278,
10155,
91616,
368,
341,
262,
1077,
5206,
44223,
15,
284,
293,
1,
15,
3263,
1944,
18410,
8950,
1005,
983,
13251,
543,
262,
44223,
15,
2552,
7,
16,
626,
262,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_do_not_graft_within_default_backoff_period_after_receiving_prune_without_backoff() {
//set default backoff period to 1 second
let config = GossipsubConfigBuilder::default()
.prune_backoff(Duration::from_millis(90))
.backoff_slack(1)
.heartbeat_interval(Duration::from_millis(100))
.build()
.unwrap();
//only one peer => mesh too small and will try to regraft as early as possible
let (mut gs, peers, topics) = inject_nodes1()
.peer_no(1)
.topics(vec!["test".into()])
.to_subscribe(true)
.gs_config(config)
.create_network();
//handle prune from peer without a specified backoff
gs.handle_prune(&peers[0], vec![(topics[0].clone(), Vec::new(), None)]);
//forget all events until now
flush_events(&mut gs);
//call heartbeat
gs.heartbeat();
//Apply one more heartbeat
sleep(Duration::from_millis(100));
gs.heartbeat();
//Check that no graft got created (we have backoff_slack = 1 therefore one more heartbeat
assert_eq!(
count_control_msgs(&gs, |_, m| match m {
GossipsubControlAction::Graft { .. } => true,
_ => false,
}),
0,
"Graft message created too early within backoff period"
);
//Heartbeat one more time this should graft now
sleep(Duration::from_millis(100));
gs.heartbeat();
//check that graft got created
assert!(
count_control_msgs(&gs, |_, m| match m {
GossipsubControlAction::Graft { .. } => true,
_ => false,
}) > 0,
"No graft message was created after backoff period"
);
} | rust_cleaned_test_functions.jsonl/66901 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 901
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26309,
7913,
15682,
64,
723,
72385,
9993,
3895,
1847,
20818,
19844,
1288,
46344,
5294,
2886,
39904,
3895,
1847,
368,
341,
286,
442,
746,
1638,
1182,
1847,
4168,
311,
220,
16,
2086,
198,
286,
1077,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_token_id_shift() {
let expansion = parse_macro(
r#"
macro_rules! foobar {
($e:ident) => { foo bar $e }
}
"#,
)
.expand_tt("foobar!(baz);");
fn get_id(t: &tt::TokenTree) -> Option<u32> {
if let tt::TokenTree::Leaf(tt::Leaf::Ident(ident)) = t {
return Some(ident.id.0);
}
None
}
assert_eq!(expansion.token_trees.len(), 3);
// 012345 67 8 9 T 12
assert_eq!(get_id(&expansion.token_trees[0]), Some(9));
assert_eq!(get_id(&expansion.token_trees[1]), Some(10));
// The input args of macro call include parentheses:
// So baz should be 12+1+1
assert_eq!(get_id(&expansion.token_trees[2]), Some(14));
} | rust_cleaned_test_functions.jsonl/28701 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 362
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6458,
842,
22230,
368,
341,
262,
1077,
14461,
284,
4715,
58810,
1006,
286,
435,
2,
698,
32606,
21407,
0,
11756,
31393,
341,
262,
1711,
68,
25,
1713,
8,
589,
314,
15229,
3619,
400,
68,
456,
532... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_double() {
match Variant::VInteger(1).plus(Variant::VDouble(0.6)).unwrap() {
Variant::VDouble(result) => assert_eq!(result, 1.6),
_ => panic!("assertion failed"),
}
} | rust_cleaned_test_functions.jsonl/84544 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 155
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
24598,
368,
341,
394,
2432,
39292,
486,
53,
3486,
7,
16,
568,
7138,
12410,
15341,
486,
53,
7378,
7,
15,
13,
21,
4579,
15454,
368,
341,
503,
39292,
486,
53,
7378,
4456,
8,
589,
2060,
10714,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_print() {
let e1 = Expr::symbol("hello");
let e2 = Expr::fnum(3.2);
let e3 = Expr::list(&[Expr::symbol("hello"), Expr::symbol("world")]);
let mut env = Environment::empty();
assert_eq!("hello", gen_print_output(e1.clone(), &mut env));
assert_eq!("3.2", gen_print_output(e2.clone(), &mut env));
assert_eq!("(hello world)", gen_print_output(e3.clone(), &mut env));
env.push_context();
env.add_fn(
"test-func",
&["x1".into(), "x2".into()],
Expr::symbol("body"),
)
.map_or_else(
|e| assert!(false, format!("got error {}", e)),
|_| {
assert_eq!(
"<func-object: test-func>",
gen_print_output(Expr::symbol("test-func"), &mut env)
)
},
);
let _ = env
.add_var("x", Expr::fnum(42.0))
.map_err(|e| assert!(false, format!("got error {}", e)));
let e4 = Expr::list(&[Expr::symbol("test-func"), Expr::symbol("x"), e3.clone()]);
assert_eq!(
"(<func-object: test-func> 42 (hello world))",
gen_print_output(e4.clone(), &mut env)
);
let e5 = Expr::list(&[
Expr::symbol("print"),
e4.clone(),
e3.clone(),
e2.clone(),
e1.clone(),
]);
eval(e5.clone(), &mut env);
let e6 = Expr::list(&[
Expr::symbol("print"),
Expr::symbol("Hello"),
Expr::symbol("world!"),
]);
eval(e6.clone(), &mut env);
} | rust_cleaned_test_functions.jsonl/55391 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 946
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10064,
368,
341,
286,
1077,
384,
16,
284,
28819,
486,
18785,
445,
14990,
797,
286,
1077,
384,
17,
284,
28819,
486,
69,
2413,
7,
18,
13,
17,
317,
286,
1077,
384,
18,
284,
28819,
486,
1607,
20... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_example_circuit() {
let circuit = parse_input(INPUT).unwrap();
assert_eq!(circuit.value("d"), Some(72));
assert_eq!(circuit.value("e"), Some(507));
assert_eq!(circuit.value("f"), Some(492));
assert_eq!(circuit.value("g"), Some(114));
assert_eq!(circuit.value("h"), Some(65412));
assert_eq!(circuit.value("i"), Some(65079));
assert_eq!(circuit.value("x"), Some(123));
assert_eq!(circuit.value("y"), Some(456));
} | rust_cleaned_test_functions.jsonl/7237 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 240
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39304,
666,
37268,
368,
341,
286,
1077,
16224,
284,
4715,
5898,
57911,
568,
15454,
543,
286,
2060,
10714,
10297,
66,
37268,
2824,
445,
67,
3975,
4329,
7,
22,
17,
1106,
286,
2060,
10714,
10297,
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_is_slot_confirmed_unknown_slot() {
let locktower = Locktower::new(EpochStakes::new_for_tests(2), 1, 0.67);
let stakes = HashMap::new();
assert!(!locktower.is_slot_confirmed(0, &stakes));
} | rust_cleaned_test_functions.jsonl/25561 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 108
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6892,
27563,
16059,
8434,
57507,
27563,
368,
341,
286,
1077,
5296,
77578,
284,
15701,
77578,
486,
931,
10722,
79,
4953,
623,
2050,
486,
931,
5478,
32509,
7,
17,
701,
220,
16,
11,
220,
15,
13,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parse_comment() {
let comment = parse_comment(FileSpan::new(Rc::new(String::from(" \t#test\n")), Rc::new(String::from("input")))).unwrap().1;
assert_eq!(&*comment, "test");
} | rust_cleaned_test_functions.jsonl/68369 | {
"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,
21039,
17638,
368,
341,
262,
1077,
3980,
284,
4715,
17638,
19821,
12485,
486,
931,
2785,
66,
486,
931,
2242,
486,
1499,
445,
1124,
83,
2,
1944,
1699,
35674,
81463,
486,
931,
2242,
486,
1499,
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 |
#[test]
fn test_set_state() {
let mut search_info: SearchInfo<TestBackend> = SearchInfo::default();
let query = String::from("this is test query");
let mode = SearchMode::ThirtyMinutes;
let state = SearchState::new(query.clone(), mode.clone());
assert!(!search_info.is_same_state(&state));
search_info.set_state(state.clone());
assert!(search_info.is_same_state(&state));
} | rust_cleaned_test_functions.jsonl/106404 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 180
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2602,
4387,
368,
341,
286,
1077,
5206,
2711,
3109,
25,
7542,
1731,
71273,
29699,
29,
284,
7542,
1731,
486,
2258,
543,
286,
1077,
3239,
284,
923,
486,
1499,
445,
574,
374,
1273,
3239,
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_full_node() {
let env = SynchronizerEnv::new(SynchronizerEnv::default_handler(), RoleType::FullNode);
env.commit(1, 10);
// first sync should be fulfilled immediately after peer discovery
assert!(env.wait_for_version(0, 10));
env.commit(1, 20);
// second sync will be done via long polling cause first node should send new request
// after receiving first chunk immediately
assert!(env.wait_for_version(0, 20));
} | rust_cleaned_test_functions.jsonl/37391 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 158
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16372,
5084,
368,
341,
262,
1077,
6105,
284,
328,
14113,
3135,
14359,
486,
931,
3759,
14113,
3135,
14359,
486,
2258,
10183,
1507,
15404,
929,
486,
9432,
1955,
317,
262,
6105,
15728,
7,
16,
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_count_leading_lines() {
assert_eq!(count_leading_lines(""), ("", 0));
assert_eq!(count_leading_lines("foo"), ("foo", 0));
assert_eq!(count_leading_lines("foo\n"), ("foo\n", 0));
assert_eq!(count_leading_lines("foo\nbar"), ("bar", 1));
assert_eq!(count_leading_lines("foo\nbar\n"), ("bar\n", 1));
assert_eq!(count_leading_lines("\nfoo\n\nbar\n"), ("bar\n", 3));
assert_eq!(count_leading_lines("foo\r\nbar\r\n"), ("bar\r\n", 1));
assert_eq!(count_leading_lines("foo\nbar\rbaz"), ("baz", 2));
assert_eq!(count_leading_lines("foo\nbar\n\n"), ("\n", 2));
assert_eq!(
count_leading_lines(
r#"// This example is a GitHub Action if it used KDL syntax.
// See .github/workflows/ci.yml for the file this was based on.
name "CI"
on "push" "pull_request"
env {
RUSTFLAGS "-Dwarnings"
"#
),
(" RUSTFLAGS \"-Dwarnings\"\n", 7)
);
} | rust_cleaned_test_functions.jsonl/118129 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 481
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3180,
11751,
2228,
18323,
368,
341,
286,
2060,
10714,
10297,
1830,
11751,
2228,
18323,
86076,
3489,
497,
220,
15,
1106,
286,
2060,
10714,
10297,
1830,
11751,
2228,
18323,
445,
7975,
3975,
3489,
7975... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_new_empty() {
let root_hash = *SPARSE_MERKLE_PLACEHOLDER_HASH;
let smt = SparseMerkleTree::new(root_hash);
assert!(smt.root_weak().is_empty());
assert_eq!(smt.root_hash(), root_hash);
} | rust_cleaned_test_functions.jsonl/63259 | {
"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,
5921,
15124,
368,
341,
262,
1077,
3704,
8950,
284,
353,
4592,
79097,
1245,
640,
42,
867,
81924,
94629,
32309,
280,
262,
1077,
1525,
83,
284,
71794,
44,
16754,
273,
6533,
486,
931,
9206,
8950,
31... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_update_config_version() -> Result<(), Box<dyn std::error::Error>> {
let conf = corosync_conf_fixture();
let conf = std::str::from_utf8(&conf)?
.trim()
.lines()
.map(|x| x.to_string());
let conf = Vec::from_iter(update_config_version(conf, 10)).join("\n");
insta::assert_display_snapshot!(conf);
Ok(())
} | rust_cleaned_test_functions.jsonl/23873 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 201
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8882,
5332,
9438,
368,
1464,
5714,
68843,
8261,
92846,
1460,
486,
841,
486,
1454,
2452,
341,
286,
1077,
2335,
284,
1829,
436,
1721,
16059,
74409,
1428,
286,
1077,
2335,
284,
1460,
486,
495,
486,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_check_update_vote_state_slots_not_ordered() {
let slot_hashes = build_slot_hashes(vec![1, 2, 3, 4]);
let vote_state = build_vote_state(vec![1], &slot_hashes);
// Test with a `vote_state_update` where the slots are out of order
let vote_slot = 3;
let vote_slot_hash = slot_hashes
.iter()
.find(|(slot, _hash)| *slot == vote_slot)
.unwrap()
.1;
let mut vote_state_update = VoteStateUpdate::from(vec![(2, 2), (1, 3), (vote_slot, 1)]);
vote_state_update.hash = vote_slot_hash;
assert_eq!(
vote_state
.check_update_vote_state_slots_are_valid(&mut vote_state_update, &slot_hashes),
Err(VoteError::SlotsNotOrdered),
);
// Test with a `vote_state_update` where there are multiples of the same slot
let mut vote_state_update = VoteStateUpdate::from(vec![(2, 2), (2, 2), (vote_slot, 1)]);
vote_state_update.hash = vote_slot_hash;
assert_eq!(
vote_state
.check_update_vote_state_slots_are_valid(&mut vote_state_update, &slot_hashes),
Err(VoteError::SlotsNotOrdered),
);
} | rust_cleaned_test_functions.jsonl/6134 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 600
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7200,
8882,
54360,
4387,
54161,
7913,
75272,
368,
341,
286,
1077,
9446,
91616,
284,
1936,
27563,
91616,
25592,
20703,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
2558,
286,
1077,
6910,
4387,
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_checkmates() {
//rook back-rank
let mut game = Game::new();
game.create_piece(1, 5, 0);
game.create_piece(0, 5, 16);
game.create_piece(0, 3, 15);
game.set_moves();
assert_eq!(
crate::best_move(&mut game, 0, 1, i128::max_value()).unwrap(),
(
PieceMove {
start: 15,
end: 7,
special: SpecialMove::None,
},
10000.0
)
);
} | rust_cleaned_test_functions.jsonl/120648 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 342
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7200,
16457,
368,
341,
286,
442,
299,
562,
1182,
3795,
1180,
198,
286,
1077,
5206,
1809,
284,
4050,
486,
931,
543,
286,
1809,
2520,
48470,
7,
16,
11,
220,
20,
11,
220,
15,
317,
286,
1809,
25... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_get_source_code_multiple_downloads_of_same_file() {
let http_server_guard = crate::test_util::http_server();
let (_temp_dir, fetcher) = test_setup();
let specifier = ModuleSpecifier::resolve_url(
"http://localhost:4545/tests/subdir/mismatch_ext.ts",
)
.unwrap();
let headers_file_name = fetcher.deps_cache.location.join(
fetcher
.deps_cache
.get_cache_filename_with_extension(specifier.as_url(), "headers.json"),
);
// first download
tokio_util::run(fetcher.fetch_source_file_async(&specifier, None).map(
|r| {
assert!(r.is_ok());
},
));
let result = fs::File::open(&headers_file_name);
assert!(result.is_ok());
let headers_file = result.unwrap();
// save modified timestamp for headers file
let headers_file_metadata = headers_file.metadata().unwrap();
let headers_file_modified = headers_file_metadata.modified().unwrap();
// the same as after first download)
tokio_util::run(fetcher.fetch_source_file_async(&specifier, None).map(
|r| {
assert!(r.is_ok());
},
));
let result = fs::File::open(&headers_file_name);
assert!(result.is_ok());
let headers_file_2 = result.unwrap();
// save modified timestamp for headers file
let headers_file_metadata_2 = headers_file_2.metadata().unwrap();
let headers_file_modified_2 = headers_file_metadata_2.modified().unwrap();
assert_eq!(headers_file_modified, headers_file_modified_2);
drop(http_server_guard);
} | rust_cleaned_test_functions.jsonl/16753 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 626
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
10347,
4136,
45233,
13998,
32685,
3575,
33574,
2458,
368,
341,
262,
1077,
1758,
12015,
36796,
284,
17717,
486,
1944,
18974,
486,
1254,
12015,
543,
262,
1077,
5453,
3888,
4334,
11,
7807,
261,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_many_float() {
let s = "1576540098.52,1576540098.53";
let (_, next) = DateTime::read(s, Format::EpochSeconds, ',').expect("valid");
assert_eq!(next, "1576540098.53");
} | rust_cleaned_test_functions.jsonl/33402 | {
"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,
6443,
22101,
17586,
368,
341,
286,
1077,
274,
284,
330,
16,
20,
22,
21,
20,
19,
15,
15,
24,
23,
13,
20,
17,
11,
16,
20,
22,
21,
20,
19,
15,
15,
24,
23,
13,
20,
18,
876,
286,
1077,
39... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parsing_of_recursive_type_fixed() {
let schema = r#"
{
"type": "record",
"name": "User",
"namespace": "office",
"fields": [
{
"name": "details",
"type": [
{
"type": "record",
"name": "Employee",
"fields": [
{
"name": "id",
"type": {
"type": "fixed",
"name": "EmployeeId",
"size": 16
},
"default": "female"
}
]
},
{
"type": "record",
"name": "Manager",
"fields": [
{
"name": "id",
"type": "EmployeeId"
}
]
}
]
}
]
}
"#;
let schema = Schema::parse_str(schema).unwrap();
let schema_str = schema.canonical_form();
let expected = r#"{"name":"office.User","type":"record","fields":[{"name":"details","type":[{"name":"Employee","type":"record","fields":[{"name":"id","type":{"name":"EmployeeId","type":"fixed","size":16}}]},{"name":"Manager","type":"record","fields":[{"name":"id","type":{"name":"EmployeeId","type":"fixed","size":16}}]}]}]}"#;
assert_eq!(schema_str, expected);
} | rust_cleaned_test_functions.jsonl/108438 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 966
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
28598,
3575,
66242,
1819,
37839,
368,
341,
286,
1077,
10802,
284,
435,
2,
698,
262,
341,
286,
330,
1313,
788,
330,
8548,
756,
286,
330,
606,
788,
330,
1474,
756,
286,
330,
2231,
788,
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_try_from_get_info() {
let (mut sender, receiver) = UnixStream::pair().unwrap();
let mut connection = HttpConnection::new(receiver);
sender
.write_all(http_request("GET", "/", None).as_bytes())
.unwrap();
assert!(connection.try_read().is_ok());
let req = connection.pop_parsed_request().unwrap();
assert!(ParsedRequest::try_from_request(&req).is_ok());
} | rust_cleaned_test_functions.jsonl/106571 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 202
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
53283,
5673,
3062,
3109,
368,
341,
286,
1077,
320,
6984,
4646,
11,
13964,
8,
284,
46995,
3027,
486,
12670,
1005,
15454,
543,
286,
1077,
5206,
3633,
284,
4823,
4526,
486,
931,
78126,
317,
286,
46... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_option_argument() {
let err = OptParseError::invalid_option_argument("--abc", "invalid float literal");
let thing = format!("{}", err);
let expect = "Invalid option argument: --abc: invalid float literal";
assert_eq!(thing, expect);
} | rust_cleaned_test_functions.jsonl/8273 | {
"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,
31433,
9672,
9025,
368,
341,
286,
1077,
1848,
284,
16554,
14463,
1454,
486,
11808,
9672,
9025,
21549,
13683,
497,
330,
11808,
2224,
23141,
797,
286,
1077,
3166,
284,
3561,
79878,
1848,
317,
286,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_spawn_sched() {
use clone::Clone;
let (tx, rx) = channel();
fn f(i: i32, tx: Sender<()>) {
let tx = tx.clone();
thread::spawn(move|| {
if i == 0 {
tx.send(()).unwrap();
} else {
f(i - 1, tx);
}
});
}
f(10, tx);
rx.recv().unwrap();
} | rust_cleaned_test_functions.jsonl/109008 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 286
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
76026,
67394,
368,
341,
286,
990,
14715,
486,
37677,
401,
286,
1077,
320,
3998,
11,
19111,
8,
284,
5496,
1428,
286,
5168,
282,
1956,
25,
600,
18,
17,
11,
9854,
25,
54610,
27,
368,
9231,
341,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_poly_is_convex() {
let poly = [
Point2D::new(0.0, 0.0),
Point2D::new(5.0, 0.0),
Point2D::new(5.0, 5.0),
Point2D::new(0.0, 5.0),
Point2D::new(0.0, 0.0),
];
// point on rectangle
assert!(poly_is_convex(&poly));
let poly = [
Point2D::new(0.0, 0.0),
Point2D::new(5.0, 0.0),
Point2D::new(5.0, 5.0),
Point2D::new(2.5, 3.0),
Point2D::new(0.0, 5.0),
Point2D::new(0.0, 0.0),
];
// point on rectangle
assert_eq!(poly_is_convex(&poly), false);
} | rust_cleaned_test_functions.jsonl/40387 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 426
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36133,
6892,
22716,
327,
368,
341,
286,
1077,
9861,
284,
2278,
310,
5126,
17,
35,
486,
931,
7,
15,
13,
15,
11,
220,
15,
13,
15,
1326,
310,
5126,
17,
35,
486,
931,
7,
20,
13,
15,
11,
220,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_contains() {
let r = Rect::new(Point2D::new(-20, 15), Size2D::new(100, 200));
assert!(r.contains(&Point2D::new(0, 50)));
assert!(r.contains(&Point2D::new(-10, 200)));
// bottom/right edges.
assert!(r.contains(&Point2D::new(-20, 15)));
assert!(!r.contains(&Point2D::new(80, 15)));
assert!(!r.contains(&Point2D::new(80, 215)));
assert!(!r.contains(&Point2D::new(-20, 215)));
// Points beyond the top-left corner.
assert!(!r.contains(&Point2D::new(-25, 15)));
assert!(!r.contains(&Point2D::new(-15, 10)));
// Points beyond the top-right corner.
assert!(!r.contains(&Point2D::new(85, 20)));
assert!(!r.contains(&Point2D::new(75, 10)));
// Points beyond the bottom-right corner.
assert!(!r.contains(&Point2D::new(85, 210)));
assert!(!r.contains(&Point2D::new(75, 220)));
// Points beyond the bottom-left corner.
assert!(!r.contains(&Point2D::new(-25, 210)));
assert!(!r.contains(&Point2D::new(-15, 220)));
let r = Rect::new(Point2D::new(-20.0, 15.0), Size2D::new(100.0, 200.0));
assert!(r.contains_rect(&r));
assert!(!r.contains_rect(&r.translate(&Point2D::new( 0.1, 0.0))));
assert!(!r.contains_rect(&r.translate(&Point2D::new(-0.1, 0.0))));
assert!(!r.contains_rect(&r.translate(&Point2D::new( 0.0, 0.1))));
assert!(!r.contains_rect(&r.translate(&Point2D::new( 0.0, -0.1))));
// even if their origin is not.
let p = Point2D::new(1.0, 1.0);
assert!(!r.contains(&p));
assert!(r.contains_rect(&Rect::new(p, Size2D::zero())));
} | rust_cleaned_test_functions.jsonl/24158 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 862
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
63598,
368,
341,
286,
1077,
435,
284,
11920,
486,
931,
32737,
17,
35,
486,
931,
4080,
17,
15,
11,
220,
16,
20,
701,
8478,
17,
35,
486,
931,
7,
16,
15,
15,
11,
220,
17,
15,
15,
3237,
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_invalid_funding_tx() {
// Test that we properly handle invalid funding transactions sent to us from a peer.
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100_000, 10_000, 42, None).unwrap();
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), InitFeatures::known(), &get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id()));
nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), InitFeatures::known(), &get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id()));
let (temporary_channel_id, mut tx, _) = create_funding_transaction(&nodes[0], 100_000, 42);
for output in tx.output.iter_mut() {
// Make the confirmed funding transaction have a bogus script_pubkey
output.script_pubkey = bitcoin::Script::new();
}
nodes[0].node.funding_transaction_generated_unchecked(&temporary_channel_id, tx.clone(), 0).unwrap();
nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id()));
check_added_monitors!(nodes[1], 1);
nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id()));
check_added_monitors!(nodes[0], 1);
let events_1 = nodes[0].node.get_and_clear_pending_events();
assert_eq!(events_1.len(), 0);
assert_eq!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().len(), 1);
assert_eq!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap()[0], tx);
nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().clear();
confirm_transaction_at(&nodes[1], &tx, 1);
check_closed_event!(nodes[1], 1, ClosureReason::CommitmentTxConfirmed);
check_added_monitors!(nodes[1], 1);
let events_2 = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(events_2.len(), 1);
if let MessageSendEvent::HandleError { node_id, action } = &events_2[0] {
assert_eq!(*node_id, nodes[0].node.get_our_node_id());
if let msgs::ErrorAction::SendErrorMessage { msg } = action {
assert_eq!(msg.data, "funding tx had wrong script/value or output index");
} else { panic!(); }
} else { panic!(); }
assert_eq!(nodes[1].node.list_channels().len(), 0);
} | rust_cleaned_test_functions.jsonl/16963 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1003
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31433,
761,
37189,
17805,
368,
341,
197,
322,
3393,
429,
582,
10277,
3705,
8318,
10773,
14131,
3208,
311,
601,
504,
264,
14397,
624,
11120,
49106,
10217,
26023,
1645,
18343,
82,
284,
1855,
45552,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
#[test]
fn test_add_worker() {
new_test_ext().execute_with(|| {
set_block_1();
let worker1 = worker_pubkey(1);
let worker2 = worker_pubkey(2);
assert_ok!(PhalaRegistry::force_register_worker(
Origin::root(),
worker1.clone(),
ecdh_pubkey(1),
Some(1)
));
assert_ok!(PhalaStakePool::create(Origin::signed(1)));
// Bad inputs
assert_noop!(
PhalaStakePool::add_worker(Origin::signed(1), 1, worker2.clone()),
Error::<Test>::WorkerNotRegistered
);
assert_noop!(
PhalaStakePool::add_worker(Origin::signed(2), 0, worker1.clone()),
Error::<Test>::UnauthorizedOperator
);
assert_noop!(
PhalaStakePool::add_worker(Origin::signed(1), 0, worker1.clone()),
Error::<Test>::BenchmarkMissing
);
// Add benchmark and retry
PhalaRegistry::internal_set_benchmark(&worker1, Some(1));
assert_ok!(PhalaStakePool::add_worker(
Origin::signed(1),
0,
worker1.clone()
));
// Check binding
let subaccount = pool_sub_account(0, &worker_pubkey(1));
assert_eq!(
PhalaMining::ensure_worker_bound(&worker_pubkey(1)).unwrap(),
subaccount,
);
assert_eq!(
PhalaMining::ensure_miner_bound(&subaccount).unwrap(),
worker_pubkey(1),
);
// Check assignments
assert_eq!(WorkerAssignments::<Test>::get(&worker_pubkey(1)), Some(0));
// Other bad cases
assert_noop!(
PhalaStakePool::add_worker(Origin::signed(1), 100, worker1.clone()),
Error::<Test>::PoolDoesNotExist
);
assert_ok!(PhalaStakePool::create(Origin::signed(1)));
assert_noop!(
PhalaStakePool::add_worker(Origin::signed(1), 1, worker1.clone()),
Error::<Test>::FailedToBindMinerAndWorker
);
});
} | rust_cleaned_test_functions.jsonl/60459 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 831
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
40385,
368,
341,
298,
8638,
4452,
9927,
1005,
10257,
6615,
79453,
341,
571,
8196,
7113,
62,
16,
543,
571,
10217,
11864,
16,
284,
11864,
34014,
792,
7,
16,
317,
571,
10217,
11864,
17,
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... | 2 |
#[test]
fn test_boolean_equal() {
let a = BooleanArray::from(vec![false, false, true]);
let b = BooleanArray::from(vec![false, false, true]);
assert!(a.equals(&b));
assert!(b.equals(&a));
let b = BooleanArray::from(vec![false, false, false]);
assert!(!a.equals(&b));
assert!(!b.equals(&a));
// Test the case where null_count > 0
let a = BooleanArray::from(vec![Some(false), None, None, Some(true)]);
let b = BooleanArray::from(vec![Some(false), None, None, Some(true)]);
assert!(a.equals(&b));
assert!(b.equals(&a));
let b = BooleanArray::from(vec![None, None, None, Some(true)]);
assert!(!a.equals(&b));
assert!(!b.equals(&a));
let b = BooleanArray::from(vec![Some(true), None, None, Some(true)]);
assert!(!a.equals(&b));
assert!(!b.equals(&a));
// Test the case where offset != 0
let a = BooleanArray::from(vec![false, true, false, true, false, false, true]);
let b = BooleanArray::from(vec![false, false, false, true, false, true, true]);
assert!(!a.equals(&b));
assert!(!b.equals(&a));
let a_slice = a.slice(2, 3);
let b_slice = b.slice(2, 3);
assert!(a_slice.equals(&*b_slice));
assert!(b_slice.equals(&*a_slice));
let a_slice = a.slice(3, 4);
let b_slice = b.slice(3, 4);
assert!(!a_slice.equals(&*b_slice));
assert!(!b_slice.equals(&*a_slice));
} | rust_cleaned_test_functions.jsonl/887 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 728
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
46642,
11478,
368,
341,
286,
1077,
264,
284,
6992,
1857,
486,
1499,
25592,
20703,
3849,
11,
895,
11,
830,
2558,
286,
1077,
293,
284,
6992,
1857,
486,
1499,
25592,
20703,
3849,
11,
895,
11,
830,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_vcx_credential_create_with_offer_success() {
let _setup = SetupMocks::init();
let handle = _vcx_credential_create_with_offer_c_closure(ARIES_CREDENTIAL_OFFER).unwrap();
assert!(handle > 0);
} | rust_cleaned_test_functions.jsonl/115031 | {
"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,
2273,
25844,
666,
30320,
8657,
6615,
67814,
18632,
368,
341,
286,
1077,
716,
15188,
284,
18626,
72577,
486,
2327,
1428,
286,
1077,
3705,
284,
716,
7362,
87,
666,
30320,
8657,
6615,
67814,
666,
728... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_startup_sync_state_with_empty_consensus_db() {
let mut swarm = new_local_swarm(4);
let validator_peer_ids = swarm.validators().map(|v| v.peer_id()).collect::<Vec<_>>();
let client_1 = swarm
.validator(validator_peer_ids[1])
.unwrap()
.json_rpc_client();
let transaction_factory = swarm.chain_info().transaction_factory();
let mut account_0 = create_and_fund_account(&mut swarm, 100);
let account_1 = create_and_fund_account(&mut swarm, 10);
let txn = transfer_coins(
&client_1,
&transaction_factory,
&mut account_0,
&account_1,
10,
);
assert_balance(&client_1, &account_0, 90);
assert_balance(&client_1, &account_1, 20);
// Stop a node
let node_to_restart = validator_peer_ids[0];
let node_config = swarm.validator(node_to_restart).unwrap().config().clone();
swarm.validator_mut(node_to_restart).unwrap().stop();
let consensus_db_path = node_config.storage.dir().join("consensusdb");
// Verify that consensus db exists and
// we are not deleting a non-existent directory
assert!(consensus_db_path.as_path().exists());
// Delete the consensus db to simulate consensus db is nuked
fs::remove_dir_all(consensus_db_path).unwrap();
swarm
.validator_mut(node_to_restart)
.unwrap()
.start()
.unwrap();
swarm
.validator_mut(node_to_restart)
.unwrap()
.wait_until_healthy(Instant::now() + Duration::from_secs(10))
.unwrap();
let client_0 = swarm.validator(node_to_restart).unwrap().json_rpc_client();
// Wait for the txn to by synced to the restarted node
client_0
.wait_for_signed_transaction(&txn, None, None)
.unwrap();
assert_balance(&client_0, &account_0, 90);
assert_balance(&client_0, &account_1, 20);
let txn = transfer_coins(
&client_1,
&transaction_factory,
&mut account_0,
&account_1,
10,
);
client_0
.wait_for_signed_transaction(&txn, None, None)
.unwrap();
assert_balance(&client_0, &account_0, 80);
assert_balance(&client_0, &account_1, 30);
} | rust_cleaned_test_functions.jsonl/10526 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 959
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
80858,
23008,
4387,
6615,
15124,
31971,
13626,
8685,
368,
341,
262,
1077,
5206,
60841,
284,
501,
13564,
32581,
2178,
7,
19,
317,
262,
1077,
22935,
45159,
8077,
284,
60841,
82728,
1005,
2186,
22428,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_sboxes() {
test_sbox(sboxes::S_TC26, sboxes_exp::S_TC26);
test_sbox(sboxes::S_TEST, sboxes_exp::S_TEST);
test_sbox(sboxes::S_CRYPTOPRO_A, sboxes_exp::S_CRYPTOPRO_A);
test_sbox(sboxes::S_CRYPTOPRO_B, sboxes_exp::S_CRYPTOPRO_B);
test_sbox(sboxes::S_CRYPTOPRO_C, sboxes_exp::S_CRYPTOPRO_C);
test_sbox(sboxes::S_CRYPTOPRO_D, sboxes_exp::S_CRYPTOPRO_D);
} | rust_cleaned_test_functions.jsonl/18967 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 222
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
643,
22204,
368,
341,
262,
1273,
643,
2011,
1141,
22204,
486,
50,
56738,
17,
21,
11,
274,
22204,
14214,
486,
50,
56738,
17,
21,
317,
262,
1273,
643,
2011,
1141,
22204,
486,
50,
11641,
11,
274,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_name_space_truncate() {
init_logging();
let bucket_name = format!("test-name-space-{}", get_time().sec);
let test_client = TestS3Client::new(bucket_name.clone());
test_client.create_test_bucket(bucket_name.clone());
let filename_spaces = "spaces ".to_owned();
test_client.put_test_object(filename_spaces.clone());
let req = ListObjectsV2Request {
bucket: bucket_name.clone(),
..Default::default()
};
let key = &test_client
.s3
.list_objects_v2(req)
.sync()
.unwrap()
.contents
.unwrap()[0]
.clone()
.key
.unwrap();
assert_eq!(*key, filename_spaces);
test_delete_object(&test_client.s3, &bucket_name, &filename_spaces);
} | rust_cleaned_test_functions.jsonl/112580 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 364
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1269,
14663,
3547,
26900,
368,
341,
262,
2930,
59982,
1428,
262,
1077,
15621,
1269,
284,
3561,
17223,
1944,
11494,
27947,
12,
42351,
633,
3009,
1005,
5024,
317,
262,
1077,
1273,
8179,
284,
3393,
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_spqlios_fft_ifft() {
let n = 1024;
let mut plan = FFTPlan::new(n);
let mut rng = rand::thread_rng();
let mut a: Vec<u32> = vec![0u32; n];
a.iter_mut().for_each(|e| *e = rng.gen::<u32>());
let a_fft = plan.spqlios.ifft(&a);
let res = plan.spqlios.fft(&a_fft);
for i in 0..n {
let diff = a[i] as i32 - res[i] as i32;
assert!(diff < 2 && diff > -2);
println!("{} {} {}", a_fft[i], a[i], res[i]);
}
} | rust_cleaned_test_functions.jsonl/109564 | {
"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,
10123,
6905,
436,
67059,
11119,
723,
368,
341,
286,
1077,
308,
284,
220,
16,
15,
17,
19,
280,
286,
1077,
5206,
3119,
284,
60036,
20485,
486,
931,
1445,
317,
286,
1077,
5206,
28422,
284,
10382,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_serde_roundtrip() {
::init().unwrap();
// Some
let clocktime = ClockTime::from_nseconds(42_123_456_789);
let clocktime_ser = ron::ser::to_string(&clocktime).unwrap();
let clocktime: ClockTime = ron::de::from_str(clocktime_ser.as_str()).unwrap();
assert_eq!(clocktime.seconds(), Some(42));
assert_eq!(clocktime.mseconds(), Some(42_123));
assert_eq!(clocktime.useconds(), Some(42_123_456));
assert_eq!(clocktime.nseconds(), Some(42_123_456_789));
// None
let clocktime = ClockTime(None);
let clocktime_ser = ron::ser::to_string(&clocktime).unwrap();
let clocktime: ClockTime = ron::de::from_str(clocktime_ser.as_str()).unwrap();
assert_eq!(clocktime.nseconds(), None);
} | rust_cleaned_test_functions.jsonl/5553 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 362
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
75861,
450,
29896,
32981,
368,
341,
286,
3504,
2327,
1005,
15454,
1428,
286,
442,
4329,
198,
286,
1077,
8866,
1678,
284,
26142,
1462,
486,
1499,
1089,
17403,
7,
19,
17,
62,
16,
17,
18,
62,
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_channel_data_decode() -> Result<()> {
let tests = vec![
("small", vec![1, 2, 3], Error::ErrUnexpectedEof),
(
"zeroes",
vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
Error::ErrInvalidChannelNumber,
),
(
"bad chan number",
vec![63, 255, 0, 0, 0, 4, 0, 0, 1, 2, 3, 4],
Error::ErrInvalidChannelNumber,
),
(
"bad length",
vec![0x40, 0x40, 0x02, 0x23, 0x16, 0, 0, 0, 0, 0, 0, 0],
Error::ErrBadChannelDataLength,
),
];
for (name, buf, want_err) in tests {
let mut m = ChannelData {
raw: buf,
..Default::default()
};
if let Err(err) = m.decode() {
assert!(
want_err.equal(&err),
"unexpected: ({}) {} != {}",
name,
want_err,
err
);
} else {
assert!(false, "expected error, but got ok");
}
}
Ok(())
} | rust_cleaned_test_functions.jsonl/76713 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 650
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14571,
1769,
15227,
368,
1464,
5714,
71698,
341,
262,
1077,
7032,
284,
7486,
90515,
286,
3489,
9004,
497,
7486,
20703,
16,
11,
220,
17,
11,
220,
18,
1125,
4600,
486,
7747,
29430,
36,
1055,
1326,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_parse_token() {
let mint_pubkey = SplTokenPubkey::new(&[2; 32]);
let owner_pubkey = SplTokenPubkey::new(&[3; 32]);
let mut account_data = vec![0; Account::get_packed_len()];
let mut account = Account::unpack_unchecked(&account_data).unwrap();
account.mint = mint_pubkey;
account.owner = owner_pubkey;
account.amount = 42;
account.state = AccountState::Initialized;
account.is_native = COption::None;
account.close_authority = COption::Some(owner_pubkey);
Account::pack(account, &mut account_data).unwrap();
assert!(parse_token(&account_data, None).is_err());
assert_eq!(
parse_token(&account_data, Some(2)).unwrap(),
TokenAccountType::Account(UiTokenAccount {
mint: mint_pubkey.to_string(),
owner: owner_pubkey.to_string(),
token_amount: UiTokenAmount {
ui_amount: Some(0.42),
decimals: 2,
amount: "42".to_string(),
ui_amount_string: "0.42".to_string()
},
delegate: None,
state: UiAccountState::Initialized,
is_native: false,
rent_exempt_reserve: None,
delegated_amount: None,
close_authority: Some(owner_pubkey.to_string()),
extensions: vec![],
}),
);
let mut mint_data = vec![0; Mint::get_packed_len()];
let mut mint = Mint::unpack_unchecked(&mint_data).unwrap();
mint.mint_authority = COption::Some(owner_pubkey);
mint.supply = 42;
mint.decimals = 3;
mint.is_initialized = true;
mint.freeze_authority = COption::Some(owner_pubkey);
Mint::pack(mint, &mut mint_data).unwrap();
assert_eq!(
parse_token(&mint_data, None).unwrap(),
TokenAccountType::Mint(UiMint {
mint_authority: Some(owner_pubkey.to_string()),
supply: 42.to_string(),
decimals: 3,
is_initialized: true,
freeze_authority: Some(owner_pubkey.to_string()),
extensions: vec![],
}),
);
let signer1 = SplTokenPubkey::new(&[1; 32]);
let signer2 = SplTokenPubkey::new(&[2; 32]);
let signer3 = SplTokenPubkey::new(&[3; 32]);
let mut multisig_data = vec![0; Multisig::get_packed_len()];
let mut signers = [SplTokenPubkey::default(); 11];
signers[0] = signer1;
signers[1] = signer2;
signers[2] = signer3;
let mut multisig = Multisig::unpack_unchecked(&multisig_data).unwrap();
multisig.m = 2;
multisig.n = 3;
multisig.is_initialized = true;
multisig.signers = signers;
Multisig::pack(multisig, &mut multisig_data).unwrap();
assert_eq!(
parse_token(&multisig_data, None).unwrap(),
TokenAccountType::Multisig(UiMultisig {
num_required_signers: 2,
num_valid_signers: 3,
is_initialized: true,
signers: vec![
signer1.to_string(),
signer2.to_string(),
signer3.to_string()
],
}),
);
let bad_data = vec![0; 4];
assert!(parse_token(&bad_data, None).is_err());
} | rust_cleaned_test_functions.jsonl/103627 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1821
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
6458,
368,
341,
286,
1077,
28337,
34014,
792,
284,
51198,
3323,
29162,
792,
486,
931,
2099,
58,
17,
26,
220,
18,
17,
2558,
286,
1077,
6372,
34014,
792,
284,
51198,
3323,
29162,
792,
486,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_basic_block_ordering() {
let context = Context::create();
let module = context.create_module("test");
let builder = context.create_builder();
assert!(builder.get_insert_block().is_none());
let i128_type = context.i128_type();
let fn_type = i128_type.fn_type(&[], false);
let function = module.add_function("testing", fn_type, None);
assert!(function.get_first_basic_block().is_none());
let basic_block = context.append_basic_block(function, "entry");
let basic_block4 = context.insert_basic_block_after(basic_block, "block4");
let basic_block2 = context.insert_basic_block_after(basic_block, "block2");
let basic_block3 = context.prepend_basic_block(basic_block4, "block3");
let basic_blocks = function.get_basic_blocks();
assert_eq!(basic_blocks.len(), 4);
assert_eq!(basic_blocks[0], basic_block);
assert_eq!(basic_blocks[1], basic_block2);
assert_eq!(basic_blocks[2], basic_block3);
assert_eq!(basic_blocks[3], basic_block4);
assert!(basic_block3.move_before(basic_block2).is_ok());
assert!(basic_block.move_after(basic_block4).is_ok());
let basic_block5 = context.prepend_basic_block(basic_block, "block5");
let basic_blocks = function.get_basic_blocks();
assert_eq!(basic_blocks.len(), 5);
assert_eq!(basic_blocks[0], basic_block3);
assert_eq!(basic_blocks[1], basic_block2);
assert_eq!(basic_blocks[2], basic_block4);
assert_eq!(basic_blocks[3], basic_block5);
assert_eq!(basic_blocks[4], basic_block);
assert_ne!(basic_blocks[0], basic_block);
assert_ne!(basic_blocks[1], basic_block3);
assert_ne!(basic_blocks[2], basic_block2);
assert_ne!(basic_blocks[3], basic_block4);
assert_ne!(basic_blocks[4], basic_block5);
context.append_basic_block(function, "block6");
let bb1 = function.get_first_basic_block().unwrap();
let bb4 = basic_block5.get_previous_basic_block().unwrap();
assert_eq!(bb1, basic_block3);
assert_eq!(bb4, basic_block4);
assert!(basic_block3.get_previous_basic_block().is_none());
unsafe {
assert!(bb4.delete().is_ok());
}
let bb2 = basic_block5.get_previous_basic_block().unwrap();
assert_eq!(bb2, basic_block2);
let bb3 = function.get_first_basic_block().unwrap();
assert_eq!(bb3, basic_block3);
#[cfg(not(any(feature = "llvm3-6", feature = "llvm3-7", feature = "llvm3-8")))]
{
assert_eq!(basic_block.get_name().to_str(), Ok("entry"));
assert_eq!(basic_block2.get_name().to_str(), Ok("block2"));
assert_eq!(basic_block3.get_name().to_str(), Ok("block3"));
assert_eq!(basic_block5.get_name().to_str(), Ok("block5"));
}
} | rust_cleaned_test_functions.jsonl/125600 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1103
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34729,
7113,
7869,
287,
368,
341,
262,
1077,
2266,
284,
9608,
486,
3182,
543,
262,
1077,
4688,
284,
2266,
2520,
10750,
445,
1944,
797,
262,
1077,
7363,
284,
2266,
2520,
28532,
1428,
262,
2060,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_pem() {
let sk_pem = "-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEIMXY1NUbUe/3dW2YUoKW5evsnCJPMfj60/q0RzGne3gg
-----END PRIVATE KEY-----\n";
let sk = SecretKey::from_pem(sk_pem).unwrap();
let pk_pem = "-----BEGIN PUBLIC KEY-----
MCowBQYDK2VwAyEAyrRjJfTnhMcW5igzYvPirFW5eUgMdKeClGzQhd4qw+Y=
-----END PUBLIC KEY-----\n";
let pk = PublicKey::from_pem(pk_pem).unwrap();
assert_eq!(sk.public_key(), pk);
#[cfg(features = "std")]
{
let sk_pem2 = sk.to_pem();
let pk_pem2 = pk.to_pem();
assert_eq!(sk_pem, sk_pem2);
assert_eq!(pk_pem, pk_pem2);
}
} | rust_cleaned_test_functions.jsonl/64225 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 360
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
336,
368,
341,
262,
1077,
1901,
620,
336,
284,
330,
15081,
37588,
57793,
12013,
34764,
11604,
19,
5049,
48,
22600,
33,
48,
56,
18301,
17,
53,
86,
4897,
5371,
1791,
16356,
16,
3926,
65,
52... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_report() {
let test_parser = parsers::Parser::Test;
let mock = mock_request();
let report_result = report(&test_parser, "prefix", None, "123abc", "swift", "xyz");
assert!(report_result.is_ok());
mock.assert();
} | rust_cleaned_test_functions.jsonl/130166 | {
"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,
14813,
368,
341,
286,
1077,
1273,
18517,
284,
87073,
486,
6570,
486,
2271,
280,
286,
1077,
7860,
284,
7860,
7893,
1428,
286,
1077,
1895,
5287,
284,
1895,
2099,
1944,
18517,
11,
330,
11849,
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_filter_shebang() {
assert_eq!(filter_shebang(b"#!"[..].to_owned()), b"");
assert_eq!(filter_shebang(b"#!\n\n"[..].to_owned()), b"\n\n");
let code = b"#!/usr/bin/env deno\nconsole.log('hello');\n"[..].to_owned();
assert_eq!(filter_shebang(code), b"\nconsole.log('hello');\n");
} | rust_cleaned_test_functions.jsonl/72066 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 153
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8727,
643,
383,
27174,
368,
341,
262,
2060,
10714,
10297,
5315,
643,
383,
27174,
1883,
1,
8010,
36864,
496,
936,
983,
51973,
11858,
293,
1,
797,
262,
2060,
10714,
10297,
5315,
643,
383,
27174,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_home_archive_old_key() {
let dir = tempdir().unwrap();
fs::create_dir_all(dir.path().join(".shuffle/accounts/latest")).unwrap();
let home = Home::new(dir.path()).unwrap();
let private_key = home.generate_key_file().unwrap();
let time = duration_since_epoch();
let archived_dir = home.create_archive_dir(time).unwrap();
home.archive_old_key(&archived_dir).unwrap();
let test_archive_key_path = dir
.path()
.join(".shuffle/accounts")
.join(time.as_secs().to_string())
.join("dev.key");
let archived_key = generate_key::load_key(test_archive_key_path);
assert_eq!(private_key, archived_key);
} | rust_cleaned_test_functions.jsonl/123533 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 346
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21653,
42873,
21108,
3097,
368,
341,
286,
1077,
5419,
284,
2730,
3741,
1005,
15454,
543,
286,
8619,
486,
3182,
4334,
5705,
14161,
3875,
1005,
5987,
5680,
65355,
83743,
33149,
15197,
15454,
1428,
286... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_mut_int_totalord() {
assert_eq!((&mut 5i).cmp(&&mut 10), Less);
assert_eq!((&mut 10i).cmp(&&mut 5), Greater);
assert_eq!((&mut 5i).cmp(&&mut 5), Equal);
assert_eq!((&mut -5i).cmp(&&mut 12), Less);
assert_eq!((&mut 12i).cmp(&&mut -5), Greater);
} | rust_cleaned_test_functions.jsonl/101457 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 136
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
29523,
4042,
10784,
539,
368,
341,
262,
2060,
10714,
0,
42902,
6984,
220,
20,
72,
568,
7293,
2099,
5,
6984,
220,
16,
15,
701,
9668,
317,
262,
2060,
10714,
0,
42902,
6984,
220,
16,
15,
72,
56... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
#[test]
fn test_read_length_prefix() {
let test_bytes: Vec<u8> = hex::decode(TEST_HEX).expect("");
let mut binary_parser = BinaryParser::from(test_bytes.as_ref());
let result = binary_parser.read_length_prefix();
assert!(result.is_ok());
assert_eq!(result, Ok(0));
} | rust_cleaned_test_functions.jsonl/20417 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 144
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
5118,
13974,
368,
341,
286,
1077,
1273,
12524,
25,
11312,
34837,
23,
29,
284,
12371,
486,
18196,
50320,
86502,
568,
17119,
13056,
286,
1077,
5206,
7868,
18517,
284,
17718,
6570,
486,
1499,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_option_parse() {
// one octet of padding
let opt = Ipv6Option::new_unchecked(&IPV6OPTION_BYTES_PAD1);
let pad1 = Repr::parse(&opt).unwrap();
assert_eq!(pad1, Repr::Pad1);
assert_eq!(pad1.buffer_len(), 1);
// two or more octets of padding
let opt = Ipv6Option::new_unchecked(&IPV6OPTION_BYTES_PADN);
let padn = Repr::parse(&opt).unwrap();
assert_eq!(padn, Repr::PadN(1));
assert_eq!(padn.buffer_len(), 3);
// unrecognized option type
let data = [0u8; 3];
let opt = Ipv6Option::new_unchecked(&IPV6OPTION_BYTES_UNKNOWN);
let unknown = Repr::parse(&opt).unwrap();
assert_eq!(unknown, Repr::Unknown { type_: Type::Unknown(255), length: 3, data: &data });
} | rust_cleaned_test_functions.jsonl/130721 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 385
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9672,
21039,
368,
341,
286,
442,
825,
18491,
295,
315,
5300,
198,
286,
1077,
3387,
284,
358,
30168,
21,
5341,
486,
931,
4907,
7549,
2099,
3298,
53,
21,
34057,
40705,
36451,
16,
317,
286,
1077,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_variants() {
serde_test::assert_tokens(&WebhookType::Incoming, &[Token::U8(1)]);
serde_test::assert_tokens(&WebhookType::ChannelFollower, &[Token::U8(2)]);
serde_test::assert_tokens(&WebhookType::Application, &[Token::U8(3)]);
} | rust_cleaned_test_functions.jsonl/77833 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 131
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4612,
62278,
368,
341,
286,
61570,
4452,
486,
2207,
28838,
2099,
5981,
20873,
929,
486,
97564,
11,
44590,
3323,
486,
52,
23,
7,
16,
41958,
286,
61570,
4452,
486,
2207,
28838,
2099,
5981,
20873,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_schnorr_vectors() {
fn verify_only(test: &TestVector) {
let pubkey = match PublicKey::from_compressed(&test.pk) {
Ok(k) => k,
Err(_) => {
assert_eq!(test.verify_result, false);
return;
}
};
let msg = test.msg;
let sig = SchnorrSignature::parse(test.sig);
assert_eq!(test.verify_result, pubkey.verify_schnorr(&msg, sig, false));
}
fn sign_and_verify(test: &TestVector) {
let privkey = PrivateKey::from_serialized(&test.sk);
let m = test.msg;
let sig = privkey.sign_schnorr(&m, false);
let pubkey = match PublicKey::from_compressed(&test.pk) {
Ok(k) => k,
Err(_) => {
assert_eq!(test.verify_result, false);
return;
}
};
let othersig = SchnorrSignature::parse(test.sig);
assert_eq!(sig, othersig);
assert_eq!(test.verify_result, pubkey.verify_schnorr(&m, othersig, false));
}
fn parse_pubkey_only(test: &TestVector) {
assert_eq!(test.verify_result, PublicKey::from_compressed(&test.pk).is_ok());
}
for vec in &SCHNORR_VECTORS {
match vec.mode {
TestMode::All => sign_and_verify(vec),
TestMode::VerifyOnly => verify_only(vec),
TestMode::ParsePubkeyOnly => parse_pubkey_only(vec),
};
}
} | rust_cleaned_test_functions.jsonl/36205 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 889
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
643,
2125,
17391,
49158,
368,
341,
286,
5168,
10146,
18410,
8623,
25,
609,
2271,
3781,
8,
341,
310,
1077,
95116,
284,
2432,
70280,
486,
1499,
2965,
14318,
2099,
1944,
38628,
8,
341,
394,
7622,
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_endline() {
let mut res = scan("hi 15.7\r\n", "{} {}");
assert_eq!(res.next().unwrap(), "hi");
assert_eq!(res.next().unwrap(), "15.7");
} | rust_cleaned_test_functions.jsonl/50243 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 83
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6213,
1056,
368,
341,
262,
1077,
5206,
592,
284,
8569,
445,
6023,
220,
16,
20,
13,
22,
12016,
1699,
497,
35503,
4687,
797,
262,
2060,
10714,
10297,
416,
4529,
1005,
15454,
1507,
330,
6023,
797,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_evaluate() {
let x = hex2binary("C200B40A82").unwrap();
let (_, p) = parse_packet(&x).unwrap();
assert_eq!(evaluate_packet(&p), 3);
let x = hex2binary("04005AC33890").unwrap();
let (_, p) = parse_packet(&x).unwrap();
assert_eq!(evaluate_packet(&p), 54);
let x = hex2binary("880086C3E88112").unwrap();
let (_, p) = parse_packet(&x).unwrap();
assert_eq!(evaluate_packet(&p), 7);
let x = hex2binary("CE00C43D881120").unwrap();
let (_, p) = parse_packet(&x).unwrap();
assert_eq!(evaluate_packet(&p), 9);
let x = hex2binary("D8005AC2A8F0").unwrap();
let (_, p) = parse_packet(&x).unwrap();
assert_eq!(evaluate_packet(&p), 1);
let x = hex2binary("F600BC2D8F").unwrap();
let (_, p) = parse_packet(&x).unwrap();
assert_eq!(evaluate_packet(&p), 0);
let x = hex2binary("9C005AC2F8F0").unwrap();
let (_, p) = parse_packet(&x).unwrap();
assert_eq!(evaluate_packet(&p), 0);
let x = hex2binary("9C0141080250320F1802104A08").unwrap();
let (_, p) = parse_packet(&x).unwrap();
assert_eq!(evaluate_packet(&p), 1);
} | rust_cleaned_test_functions.jsonl/6778 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 606
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2204,
19642,
368,
341,
286,
1077,
856,
284,
12371,
17,
25891,
445,
34,
17,
15,
15,
33,
19,
15,
32,
23,
17,
1827,
15454,
543,
286,
1077,
39464,
281,
8,
284,
4715,
21078,
2099,
87,
568,
15454,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_encode_hashmap_with_numeric_key() {
use std::str::from_utf8;
use std::io::Writer;
use std::collections::HashMap;
let mut hm: HashMap<uint, bool> = HashMap::new();
hm.insert(1, true);
let mut mem_buf = Vec::new();
{
let mut encoder = Encoder::new(&mut mem_buf as &mut io::Writer);
hm.encode(&mut encoder).unwrap();
}
let json_str = from_utf8(mem_buf[]).unwrap();
match 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/6582 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 330
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11224,
8950,
2186,
6615,
29418,
3097,
368,
341,
286,
990,
1460,
486,
495,
486,
1499,
39453,
23,
280,
286,
990,
1460,
486,
815,
486,
6492,
280,
286,
990,
1460,
486,
51137,
486,
18497,
280,
286,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_parse() {
let username = "nagle";
let password = "1984";
let address = "127.0.0.1:9090";
let (user, pass, addr) =
parse_user_pass_and_addr(&format!("{}:{}@{}", username, password, address)).unwrap();
assert_eq!(user, username);
assert_eq!(pass, password);
assert_eq!(addr, address);
let (user, pass, addr) = parse_user_pass_and_addr(address).unwrap();
assert_eq!(user, "");
assert_eq!(pass, "");
assert_eq!(addr, address);
} | rust_cleaned_test_functions.jsonl/52028 | {
"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,
21039,
368,
341,
286,
1077,
5934,
284,
330,
77,
32674,
876,
286,
1077,
3552,
284,
330,
16,
24,
23,
19,
876,
286,
1077,
2621,
284,
330,
16,
17,
22,
13,
15,
13,
15,
13,
16,
25,
24,
15,
24,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_call_broadcast_without_args() {
let output = Command::new("./target/release/tio")
.arg("broadcast")
.output()
.expect("failed to broadcast message");
assert!(String::from_utf8_lossy(&output.stdout).contains(BASE_BROADCAST_OUTPUT))
} | rust_cleaned_test_functions.jsonl/41466 | {
"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,
13429,
74923,
39904,
8384,
368,
341,
286,
1077,
2550,
284,
7348,
486,
931,
13988,
5657,
88648,
5523,
815,
1138,
310,
659,
858,
445,
54162,
1138,
310,
659,
3006,
741,
310,
659,
17119,
445,
16091,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_secp256k1_public_key() {
// Create a secp256k1 identity from a PEM file.
let identity = Secp256k1Identity::from_pem(IDENTITY_FILE.as_bytes())
.expect("Cannot create secp256k1 identity from PEM file.");
// Assert the DER-encoded secp256k1 public key matches what we would expect.
assert!(DER_ENCODED_PUBLIC_KEY == hex::encode(identity.der_encoded_public_key));
} | rust_cleaned_test_functions.jsonl/81518 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 186
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3453,
4672,
17,
20,
21,
74,
16,
27074,
3097,
368,
341,
286,
442,
4230,
264,
511,
4672,
17,
20,
21,
74,
16,
9569,
504,
264,
96734,
1034,
624,
286,
1077,
9569,
284,
4520,
79,
17,
20,
21,
74,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_basics() {
let mut testdata = get_path();
testdata.push("alltypes_plain.parquet");
let mut file = File::open(testdata).unwrap();
let metadata = read_metadata(&mut file).unwrap();
let columns = metadata.schema_descr.columns();
/*
from pyarrow:
required group field_id=0 schema {
optional int32 field_id=1 id;
optional boolean field_id=2 bool_col;
optional int32 field_id=3 tinyint_col;
optional int32 field_id=4 smallint_col;
optional int32 field_id=5 int_col;
optional int64 field_id=6 bigint_col;
optional float field_id=7 float_col;
optional double field_id=8 double_col;
optional binary field_id=9 date_string_col;
optional binary field_id=10 string_col;
optional int96 field_id=11 timestamp_col;
}
*/
let expected = vec![
PhysicalType::Int32,
PhysicalType::Boolean,
PhysicalType::Int32,
PhysicalType::Int32,
PhysicalType::Int32,
PhysicalType::Int64,
PhysicalType::Float,
PhysicalType::Double,
PhysicalType::ByteArray,
PhysicalType::ByteArray,
PhysicalType::Int96,
];
let result = columns
.iter()
.map(|column| match column.type_() {
ParquetType::PrimitiveType {
physical_type,
basic_info,
..
} => {
assert_eq!(basic_info.repetition(), &FieldRepetitionType::Optional);
*physical_type
}
_ => {
panic!("All types should be primitives");
}
})
.collect::<Vec<_>>();
assert_eq!(expected, result);
} | rust_cleaned_test_functions.jsonl/87587 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1027
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
880,
67981,
368,
341,
286,
1077,
5206,
1273,
691,
284,
633,
2638,
543,
286,
1273,
691,
2552,
445,
541,
9242,
41015,
33277,
23300,
797,
286,
1077,
5206,
1034,
284,
2887,
486,
2508,
8623,
691,
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... | 2 |
#[test]
fn test_struct_with_borrowed_fields() {
use std::borrow::Cow;
#[derive(Tsify)]
struct Borrow<'a> {
raw: &'a str,
cow: Cow<'a, str>,
}
assert_eq!(
Borrow::DECL,
indoc! {"
export interface Borrow {
raw: string;
cow: string;
}"
}
);
} | rust_cleaned_test_functions.jsonl/121074 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 220
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15126,
6615,
880,
7768,
291,
12132,
368,
341,
262,
990,
1460,
486,
71141,
486,
89915,
401,
262,
11506,
27098,
4140,
82,
1437,
5563,
262,
2036,
77947,
18291,
64,
29,
341,
286,
7112,
25,
30136,
64... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_large_body_without_content_length() {
let body = "123".repeat(2048);
let _mock = mock("POST", "/").match_body(body.as_str()).create();
let stream = request_stream("1.0", "POST /", "", &body);
stream.shutdown(Shutdown::Write).unwrap();
let (status_line, _, _) = parse_stream(stream, false);
assert_eq!("HTTP/1.0 200 OK\r\n", status_line);
} | rust_cleaned_test_functions.jsonl/82446 | {
"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,
45228,
14114,
39904,
7495,
5118,
368,
341,
262,
1077,
2487,
284,
330,
16,
17,
18,
3263,
30624,
7,
17,
15,
19,
23,
626,
262,
1077,
716,
16712,
284,
7860,
445,
2946,
497,
3521,
1827,
6347,
14114... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_check_format() {
let caller = Address::from_hex("0x755cdba6ae4f479f7164792b318b2a06c759833b").unwrap();
let mut service = TestService::new();
let ctx = mock_context(caller);
// test create_asset
let create_asset_resp = service.create_asset(ctx.clone(), CreateAssetPayload {
name: "咪咪".to_owned(),
symbol: "MIMI".to_owned(),
admin: Address::from_hex(ADMIN).unwrap(),
supply: 10000,
init_mints: vec![IssuerWithBalance {
addr: Address::from_hex(<&str>::clone(&ADMIN)).unwrap(),
balance: 10000,
}],
precision: 100,
relayable: true,
});
assert!(create_asset_resp.is_error());
let create_asset_resp = service.create_asset(ctx.clone(), CreateAssetPayload {
name: "we1l".to_owned(),
symbol: "😺".to_owned(),
admin: Address::from_hex(ADMIN).unwrap(),
supply: 10000,
init_mints: vec![IssuerWithBalance {
addr: Address::from_hex(<&str>::clone(&ADMIN)).unwrap(),
balance: 10000,
}],
precision: 100,
relayable: true,
});
assert!(create_asset_resp.is_error());
let create_asset_resp = service.create_asset(ctx.clone(), CreateAssetPayload {
name: "we1l".to_owned(),
symbol: "m".to_owned(),
admin: Address::from_hex(ADMIN).unwrap(),
supply: 10000,
init_mints: vec![IssuerWithBalance {
addr: Address::from_hex(<&str>::clone(&ADMIN)).unwrap(),
balance: 10000,
}],
precision: 100,
relayable: true,
});
assert!(create_asset_resp.is_error());
let create_asset_resp = service.create_asset(ctx.clone(), CreateAssetPayload {
name: "_we1l".to_owned(),
symbol: "M".to_owned(),
admin: Address::from_hex(ADMIN).unwrap(),
supply: 10000,
init_mints: vec![IssuerWithBalance {
addr: Address::from_hex(<&str>::clone(&ADMIN)).unwrap(),
balance: 10000,
}],
precision: 100,
relayable: true,
});
assert!(create_asset_resp.is_error());
let create_asset_resp = service.create_asset(ctx.clone(), CreateAssetPayload {
name: "we1l_".to_owned(),
symbol: "M".to_owned(),
admin: Address::from_hex(ADMIN).unwrap(),
supply: 10000,
init_mints: vec![IssuerWithBalance {
addr: Address::from_hex(<&str>::clone(&ADMIN)).unwrap(),
balance: 10000,
}],
precision: 100,
relayable: true,
});
assert!(create_asset_resp.is_error());
let create_asset_resp = service.create_asset(ctx.clone(), CreateAssetPayload {
name: " we1l".to_owned(),
symbol: "M".to_owned(),
admin: Address::from_hex(ADMIN).unwrap(),
supply: 10000,
init_mints: vec![IssuerWithBalance {
addr: Address::from_hex(<&str>::clone(&ADMIN)).unwrap(),
balance: 10000,
}],
precision: 100,
relayable: true,
});
assert!(create_asset_resp.is_error());
let create_asset_resp = service.create_asset(ctx.clone(), CreateAssetPayload {
name: "we1l ".to_owned(),
symbol: "M".to_owned(),
admin: Address::from_hex(ADMIN).unwrap(),
supply: 10000,
init_mints: vec![IssuerWithBalance {
addr: Address::from_hex(<&str>::clone(&ADMIN)).unwrap(),
balance: 10000,
}],
precision: 100,
relayable: true,
});
assert!(create_asset_resp.is_error());
let create_asset_resp = service.create_asset(ctx, CreateAssetPayload {
name: "1we1l ".to_owned(),
symbol: "M".to_owned(),
admin: Address::from_hex(ADMIN).unwrap(),
supply: 10000,
init_mints: vec![IssuerWithBalance {
addr: Address::from_hex(<&str>::clone(&ADMIN)).unwrap(),
balance: 10000,
}],
precision: 100,
relayable: true,
});
assert!(create_asset_resp.is_error());
} | rust_cleaned_test_functions.jsonl/32951 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2108
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7200,
8955,
368,
341,
262,
1077,
19865,
284,
9177,
486,
1499,
32655,
445,
15,
87,
22,
20,
20,
85301,
64,
21,
5918,
19,
69,
19,
22,
24,
69,
22,
16,
21,
19,
22,
24,
17,
65,
18,
16,
23,
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_output_broken_pipe() {
let cmdstr = format!(
"cat \"{}\" | \"{}\" -h 10 | head -n 2",
"fixtures/sherlock.txt", TARGET_EXE_PATH
);
let oup = exec_target("sh", &["-c", &cmdstr]);
assert_eq!(oup.stderr, "");
assert_eq!(
oup.stdout,
concat!(
"You could not possibly have come at a better time, my dear Watson,\n",
"he said cordially.\n"
)
);
assert_eq!(oup.status.success(), true);
} | rust_cleaned_test_functions.jsonl/67527 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 309
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7645,
880,
81709,
41862,
368,
341,
286,
1077,
5439,
495,
284,
3561,
33673,
310,
330,
4616,
7245,
6257,
2105,
760,
7245,
6257,
2105,
481,
71,
220,
16,
15,
760,
1968,
481,
77,
220,
17,
756,
310,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_check_leader() {
let sandbox = timestamping_sandbox();
let sandbox_state = SandboxState::new();
// option: with transaction
let tx = gen_timestamping_tx();
sandbox.recv(&tx);
// TODO would be nice to check also for RequestPeers message which will appear
let n_rounds_without_request_peers = Round(
(sandbox.cfg().consensus.peers_timeout /
sandbox.cfg().consensus.round_timeout) as u32,
);
for round in Round::first().iter_to(n_rounds_without_request_peers) {
sandbox.assert_state(HEIGHT_ONE, round);
add_round_with_transactions(&sandbox, &sandbox_state, &[tx.hash()]);
sandbox.assert_state(HEIGHT_ONE, round.next());
}
} | rust_cleaned_test_functions.jsonl/8869 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 294
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7200,
79991,
368,
341,
262,
1077,
42754,
284,
11441,
287,
643,
31536,
543,
262,
1077,
42754,
4387,
284,
96860,
1397,
486,
931,
1428,
262,
442,
2999,
25,
448,
7745,
198,
262,
1077,
9854,
284,
408... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_sanitize() {
assert_eq!(sanitize("type", Case::Snake), "type_");
assert_eq!(sanitize("ref", Case::Snake), "ref_");
assert_eq!(sanitize("+1", Case::Snake), "plus_1");
assert_eq!(sanitize("-1", Case::Snake), "_1");
assert_eq!(sanitize("@timestamp", Case::Pascal), "Timestamp");
} | rust_cleaned_test_functions.jsonl/53304 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 164
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
643,
58652,
368,
341,
286,
2060,
10714,
10297,
65704,
445,
1313,
497,
11538,
486,
83420,
701,
330,
1313,
62,
797,
286,
2060,
10714,
10297,
65704,
445,
1097,
497,
11538,
486,
83420,
701,
330,
1097,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_escape_unicode() {
assert_eq!("abc".escape_unicode().to_string(), "\\u{61}\\u{62}\\u{63}");
assert_eq!("a c".escape_unicode().to_string(), "\\u{61}\\u{20}\\u{63}");
assert_eq!("\r\n\t".escape_unicode().to_string(), "\\u{d}\\u{a}\\u{9}");
assert_eq!("'\"\\".escape_unicode().to_string(), "\\u{27}\\u{22}\\u{5c}");
assert_eq!("\x00\x01\u{fe}\u{ff}".escape_unicode().to_string(), "\\u{0}\\u{1}\\u{fe}\\u{ff}");
assert_eq!("\u{100}\u{ffff}".escape_unicode().to_string(), "\\u{100}\\u{ffff}");
assert_eq!("\u{10000}\u{10ffff}".escape_unicode().to_string(), "\\u{10000}\\u{10ffff}");
assert_eq!("ab\u{fb00}".escape_unicode().to_string(), "\\u{61}\\u{62}\\u{fb00}");
assert_eq!("\u{1d4ea}\r".escape_unicode().to_string(), "\\u{1d4ea}\\u{d}");
} | rust_cleaned_test_functions.jsonl/119408 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 404
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21832,
54662,
368,
341,
262,
2060,
10714,
17223,
13683,
3263,
12998,
54662,
1005,
983,
3904,
1507,
26468,
84,
90,
21,
16,
85539,
84,
90,
21,
17,
85539,
84,
90,
21,
18,
20305,
262,
2060,
10714,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_deref() {
let mut stats = PerfStatisticsDelta(PerfStatisticsFields {
internal_key_skipped_count: 1,
internal_delete_skipped_count: 2,
block_cache_hit_count: 3,
block_read_count: 4,
block_read_byte: 5,
..Default::default()
});
assert_eq!(stats.0.block_cache_hit_count, 3);
stats.0.block_cache_hit_count = 6;
assert_eq!(stats.0.block_cache_hit_count, 6);
} | rust_cleaned_test_functions.jsonl/76516 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 257
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
814,
43970,
368,
341,
286,
1077,
5206,
10472,
284,
71448,
38599,
20277,
7,
3889,
69,
38599,
8941,
341,
310,
5306,
3097,
33811,
6450,
3180,
25,
220,
16,
345,
310,
5306,
11353,
33811,
6450,
3180,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_sign_encode_id_changed() {
let mut message = Message::new();
message.set_id(123).add_answer(Record::new());
let key_name = Name::from_ascii("some.name").unwrap();
let pre_tsig = TSIG::new(
TsigAlgorithm::HmacSha256,
12345,
60,
vec![],
message.id(),
0,
vec![],
);
let tbs = message_tbs(None, &message, &pre_tsig, &key_name).unwrap();
let pre_tsig = pre_tsig.set_mac(b"some signature".to_vec());
let tsig = make_tsig_record(key_name, pre_tsig);
message.add_tsig(tsig);
let message_byte = message.to_bytes().unwrap();
let mut message = Message::from_bytes(&message_byte).unwrap();
message.set_id(456); // simulate the request id being changed due to request forwarding
let message_byte = message.to_bytes().unwrap();
let tbv = signed_bitmessage_to_buf(None, &message_byte, true)
.unwrap()
.0;
assert_eq!(tbs, tbv);
// sign and verify
let key = &[0, 1, 2, 3, 4];
let tag = TsigAlgorithm::HmacSha256.mac_data(key, &tbv).unwrap();
TsigAlgorithm::HmacSha256
.verify_mac(key, &tbv, &tag)
.expect("did not verify")
} | rust_cleaned_test_functions.jsonl/60099 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 668
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11172,
11224,
842,
25213,
368,
341,
286,
1077,
5206,
1943,
284,
4856,
486,
931,
543,
286,
1943,
980,
842,
7,
16,
17,
18,
568,
718,
28534,
7,
6471,
486,
931,
5231,
286,
1077,
1376,
1269,
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_cleanup() {
let mut man: Manager<TestResources> = Manager::new();
let _ = man.make_frame_buffer(());
let mut count = 0u8;
man.clean_with(&mut count,
|_,_| (),
|_,_| (),
|_,_| (),
|_,_| (),
|b,_| { *b += 1; },
|_,_| (),
|_,_| (),
|_,_| (),
|_,_| ()
);
assert_eq!(count, 1);
} | rust_cleaned_test_functions.jsonl/83366 | {
"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,
42444,
368,
341,
262,
1077,
5206,
883,
25,
10567,
71273,
11277,
29,
284,
10567,
486,
931,
543,
262,
1077,
716,
284,
883,
10117,
8929,
7776,
7,
1423,
262,
1077,
5206,
1760,
284,
220,
15,
84,
23... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_op_read() {
assert_eq!(ior!(b'z', 10, 1), 0x80017A0A);
assert_eq!(ior!(b'z', 10, 512), 0x82007A0A);
} | rust_cleaned_test_functions.jsonl/85182 | {
"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,
10287,
6443,
368,
341,
286,
2060,
10714,
10297,
2462,
10297,
65,
6,
89,
516,
220,
16,
15,
11,
220,
16,
701,
220,
15,
87,
23,
15,
15,
16,
22,
32,
15,
32,
317,
286,
2060,
10714,
10297,
2462,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_progress_paused() {
setup_for_test();
let mut raft = new_test_raft(1, vec![1, 2], 5, 1, new_storage());
raft.become_candidate();
raft.become_leader();
let mut m = Message::new();
m.set_from(1);
m.set_to(1);
m.set_msg_type(MessageType::MsgPropose);
let mut e = Entry::new();
e.set_data(b"some_data".to_vec());
m.set_entries(RepeatedField::from_vec(vec![e]));
raft.step(m.clone()).expect("");
raft.step(m.clone()).expect("");
raft.step(m.clone()).expect("");
let ms = read_messages(&mut raft);
assert_eq!(ms.len(), 1);
} | rust_cleaned_test_functions.jsonl/107091 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 279
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
27200,
55475,
2591,
368,
341,
262,
6505,
5478,
4452,
543,
262,
1077,
5206,
52455,
284,
501,
4452,
62,
2944,
7,
16,
11,
7486,
20703,
16,
11,
220,
17,
1125,
220,
20,
11,
220,
16,
11,
501,
2331... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_complete_install() {
let inspector = finspect::Inspector::new();
let mut dynamic_index = DynamicIndex::new(inspector.root().create_child("index"));
let hash = Hash::from([2; 32]);
let path = PackagePath::from_name_and_variant(
"fake-package".parse().unwrap(),
"0".parse().unwrap(),
);
let required_blobs =
hashset! { Hash::from([3; 32]), Hash::from([4; 32]), Hash::from([5; 32]) };
let previous_hash = Hash::from([6; 32]);
dynamic_index.add_package(
previous_hash,
Package::Active {
path: path.clone(),
required_blobs: hashset! { Hash::from([7; 32]) },
},
);
dynamic_index.add_package(
hash,
Package::WithMetaFar { path: path.clone(), required_blobs: required_blobs.clone() },
);
dynamic_index.complete_install(hash).unwrap();
assert_eq!(
dynamic_index.packages(),
hashmap! {
hash => Package::Active {
path: path.clone(),
required_blobs,
},
}
);
assert_eq!(dynamic_index.active_packages(), hashmap! { path => hash });
} | rust_cleaned_test_functions.jsonl/74634 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 657
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
27675,
34245,
368,
341,
286,
1077,
44725,
284,
64979,
987,
486,
46230,
486,
931,
543,
286,
1077,
5206,
8741,
3560,
284,
21886,
1552,
486,
931,
56337,
18997,
12576,
1005,
3182,
17268,
445,
1252,
14... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_malicious_ca() {
simple_logging::log_to_stderr(LevelFilter::Debug);
let (server_started_signal_tx, server_started_signal_rx) = mpsc::channel::<()>();
let addr = "127.0.0.1:8444";
let server_key = PathBuf::from(format!(
"{}/../test_pki/resources/openssl/out/{}",
env!("CARGO_MANIFEST_DIR"),
"test_server.key"
));
log::debug!("{}", server_key.display());
let client_key = PathBuf::from(format!(
"{}/../test_pki/resources/openssl/malicious_ca/{}",
env!("CARGO_MANIFEST_DIR"),
"test_client.key"
));
log::debug!("{}", client_key.display());
let server_chain = PathBuf::from(format!(
"{}/../test_pki/resources/openssl/out/{}",
env!("CARGO_MANIFEST_DIR"),
"test_server.chain"
));
let client_chain = PathBuf::from(format!(
"{}/../test_pki/resources/openssl/malicious_ca/{}",
env!("CARGO_MANIFEST_DIR"),
"test_client.chain"
));
let malicious_ca_cert = PathBuf::from(format!(
"{}/../test_pki/resources/openssl/malicious_ca/{}",
env!("CARGO_MANIFEST_DIR"),
"rootCA.crt"
));
let ca_cert = PathBuf::from(format!(
"{}/../test_pki/resources/openssl/{}",
env!("CARGO_MANIFEST_DIR"),
"root-ca/certs/rootCA.crt"
));
log::debug!("{}", ca_cert.display());
let _join_handle = thread::spawn(move || {
let mut acceptor_builder = SslAcceptor::mozilla_intermediate(SslMethod::tls()).unwrap();
acceptor_builder.set_ca_file(ca_cert).unwrap();
acceptor_builder.set_verify(SslVerifyMode::PEER | SslVerifyMode::FAIL_IF_NO_PEER_CERT);
acceptor_builder
.set_private_key_file(server_key.as_path(), SslFiletype::PEM)
.unwrap();
acceptor_builder
.set_certificate_chain_file(server_chain.as_path())
.unwrap();
acceptor_builder.check_private_key().unwrap();
let acceptor = Arc::new(acceptor_builder.build());
let l = TcpListener::bind(addr).unwrap();
server_started_signal_tx.send(()).unwrap();
if let Some(Ok(tcp_stream)) = l.incoming().next() {
match acceptor.accept(tcp_stream) {
Ok(_) => panic!("No Error when connecting with malicious certificate chain"),
Err(e) => log::debug!("Error {}", e),
}
}
});
let mut connector_builder = SslConnector::builder(SslMethod::tls()).unwrap();
connector_builder.set_ca_file(malicious_ca_cert).unwrap();
connector_builder.set_verify(SslVerifyMode::PEER | SslVerifyMode::FAIL_IF_NO_PEER_CERT);
connector_builder
.set_private_key_file(client_key.as_path(), SslFiletype::PEM)
.unwrap();
connector_builder
.set_certificate_chain_file(client_chain.as_path())
.unwrap();
let connector = connector_builder.build();
server_started_signal_rx.recv().expect("server terminated?");
let tcp_stream = TcpStream::connect(addr).unwrap();
match connector.connect("idscp-test.de", tcp_stream) {
Ok(_) => panic!("No Error when connecting with malicious certificate chain"),
Err(e) => log::debug!("Error {}", e),
}
} | rust_cleaned_test_functions.jsonl/103498 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1773
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
717,
278,
9627,
49604,
368,
341,
286,
4285,
59982,
486,
839,
2346,
93033,
30263,
5632,
486,
7939,
317,
286,
1077,
320,
4030,
55679,
21137,
17805,
11,
3538,
55679,
21137,
24330,
8,
284,
296,
81984,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_derivative1() {
let mut candles = RandomCandles::default();
let mut ma = TestingMethod::new(1, candles.first().close).unwrap();
let mut prev = None;
candles.take(100).map(|x| x.close).for_each(|x| {
assert_eq_float(x - prev.unwrap_or(x), ma.next(x));
prev = Some(x);
});
} | rust_cleaned_test_functions.jsonl/108500 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 136
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
95930,
16,
368,
341,
197,
10217,
5206,
51205,
284,
10612,
34,
20125,
486,
2258,
1428,
197,
10217,
5206,
7491,
284,
26768,
3523,
486,
931,
7,
16,
11,
51205,
7389,
1005,
5552,
568,
15454,
543,
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_upload_zero_size() {
let s3client = crate::get_s3client();
let filename = "test0b.bin";
let filepath = format!("tests/data/{}", filename);
let s3_key = format!("test_upload_zero_size/{}", filename);
let res = blocking::upload(s3client.as_ref(), crate::TEST_BUCKET, &s3_key, &filepath);
assert!(res.is_ok());
} | rust_cleaned_test_functions.jsonl/84177 | {
"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,
21691,
19359,
2368,
368,
341,
262,
1077,
274,
18,
2972,
284,
17717,
486,
455,
643,
18,
2972,
543,
262,
1077,
3899,
284,
330,
1944,
15,
65,
29394,
876,
262,
1077,
26054,
284,
3561,
17223,
23841,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_after_clone_override_from_project() {
let config = a_config();
let logger = a_logger();
let resolved = config.resolve_after_clone(&logger, config.projects.get("test3").unwrap());
assert_that(&resolved).is_equal_to(vec!["clone1".to_string(), "clone override in project".to_owned()]);
} | rust_cleaned_test_functions.jsonl/52630 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 121
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19844,
54742,
48576,
5673,
16352,
368,
341,
262,
1077,
2193,
284,
264,
5332,
543,
262,
1077,
5925,
284,
264,
27413,
543,
262,
1077,
19673,
284,
2193,
14691,
19844,
54742,
2099,
9786,
11,
2193,
593... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_auto_async() {
block_on(async {
let srv = TestServer::start(|| HttpService::new(App::new().service(auto_async)));
let request = srv.request(http::Method::GET, srv.url("/test"));
let response = request.send().await.unwrap();
assert!(response.status().is_success());
})
} | rust_cleaned_test_functions.jsonl/129742 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 145
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
27740,
28346,
368,
341,
262,
2504,
4470,
18285,
341,
286,
1077,
43578,
284,
3393,
5475,
486,
2468,
79453,
4823,
1860,
486,
931,
23231,
486,
931,
1005,
7936,
21680,
28346,
22525,
286,
1077,
1681,
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_circle_2d() {
let result = circle_2d(10.0, 10);
let truth = vec![
(10.0, 0.0),
(8.097, 5.878),
(3.090, 9.511),
(-3.090, 9.511),
(-8.097, 5.878),
(-10.0, 0.0),
(-8.097, -5.878),
(-3.090, -9.511),
(3.090, -9.511),
(8.097, -5.878)
];
println!("{:?}", result);
} | rust_cleaned_test_functions.jsonl/129682 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 310
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
42222,
62,
17,
67,
368,
1476,
286,
1077,
1102,
284,
12671,
62,
17,
67,
7,
16,
15,
13,
15,
11,
220,
16,
15,
317,
286,
1077,
8046,
284,
7486,
90515,
310,
320,
16,
15,
13,
15,
11,
220,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_intrdoduce_var_expr_stmt() {
check_action_range(
"
fn foo() {
<|>1 + 1<|>;
}", "
fn foo() {
let <|>var_name = 1 + 1;
}",
|file, range| introduce_variable(file, range).map(|f| f()),
);
} | rust_cleaned_test_functions.jsonl/100438 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 141
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
59888,
67,
347,
10521,
4612,
21915,
21824,
368,
341,
2028,
7931,
9698,
1006,
310,
6228,
8822,
15229,
368,
341,
262,
82639,
29,
16,
488,
220,
16,
27,
91,
10133,
9545,
6228,
8822,
15229,
368,
341,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_binomial() {
let mut rng = ::test::rng(351);
test_binomial_mean_and_variance(150, 0.1, &mut rng);
test_binomial_mean_and_variance(70, 0.6, &mut rng);
test_binomial_mean_and_variance(40, 0.5, &mut rng);
test_binomial_mean_and_variance(20, 0.7, &mut rng);
test_binomial_mean_and_variance(20, 0.5, &mut rng);
} | rust_cleaned_test_functions.jsonl/32035 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 199
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21816,
20855,
368,
341,
286,
1077,
5206,
28422,
284,
3504,
1944,
486,
69890,
7,
18,
20,
16,
317,
286,
1273,
21816,
20855,
16933,
8378,
77450,
7,
16,
20,
15,
11,
220,
15,
13,
16,
11,
609,
698... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_names() {
let tmp = TempDir::new("weave").unwrap();
let path = tmp.path().to_str().unwrap();
let nm = SimpleNaming::new(tmp.path(), "sample", "weave", true);
assert_eq!(
nm.main_file(),
Path::new(&format!("{}/sample.weave.gz", path))
);
assert_eq!(
nm.backup_file(),
Path::new(&format!("{}/sample.bak.gz", path))
);
for i in 0..100 {
let (tname, _tfd) = nm.temp_file().unwrap();
assert_eq!(tname, Path::new(&format!("{}/sample.{}", path, i)));
println!("tname: {:?}", tname);
}
} | rust_cleaned_test_functions.jsonl/132892 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 292
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9187,
368,
341,
262,
1077,
4174,
284,
19944,
6184,
486,
931,
445,
896,
523,
1827,
15454,
1428,
262,
1077,
1815,
284,
4174,
3875,
1005,
983,
2895,
1005,
15454,
1428,
262,
1077,
25723,
284,
8993,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_extend_from() {
let mut a = PackedStringArray::<i32>::new();
a.append("hello");
a.append("world");
a.append("cupcake");
a.append("");
let mut b = PackedStringArray::<i32>::new();
b.append("foo");
b.append("bar");
a.extend_from(&b);
let a_content: Vec<_> = a.iter().collect();
assert_eq!(
a_content,
vec!["hello", "world", "cupcake", "", "foo", "bar"]
);
} | rust_cleaned_test_functions.jsonl/52659 | {
"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,
70265,
5673,
368,
341,
286,
1077,
5206,
264,
284,
393,
11191,
703,
1857,
27638,
72,
18,
17,
6831,
931,
1428,
286,
264,
2057,
445,
14990,
797,
286,
264,
2057,
445,
14615,
797,
286,
264,
2057,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_cvtsi2sd() {
assert_emit!(0xf2, 0x0f, 0x2a, 0xc1; cvtsi2sd(XMM0, 0, RCX));
assert_emit!(0xf2, 0x41, 0x0f, 0x2a, 0xdf; cvtsi2sd(XMM3, 0, R15));
assert_emit!(0xf2, 0x44, 0x0f, 0x2a, 0xc4; cvtsi2sd(XMM8, 0, RSP));
assert_emit!(0xf2, 0x48, 0x0f, 0x2a, 0xc1; cvtsi2sd(XMM0, 1, RCX));
assert_emit!(0xf2, 0x49, 0x0f, 0x2a, 0xdf; cvtsi2sd(XMM3, 1, R15));
assert_emit!(0xf2, 0x4c, 0x0f, 0x2a, 0xc4; cvtsi2sd(XMM8, 1, RSP));
} | rust_cleaned_test_functions.jsonl/85499 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 335
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
43233,
2576,
72,
17,
13446,
368,
341,
286,
2060,
69082,
10297,
15,
5848,
17,
11,
220,
15,
87,
15,
69,
11,
220,
15,
87,
17,
64,
11,
220,
15,
8148,
16,
26,
5544,
2576,
72,
17,
13446,
7644,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_dotty_version() {
let dotty_version = "Scala compiler version 3.0.0-RC1 -- Copyright 2002-2021, LAMP/EPFL";
assert_eq!(
parse_scala_version(dotty_version),
Some("3.0.0-RC1".to_string())
);
} | rust_cleaned_test_functions.jsonl/23149 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 140
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
814,
57639,
9438,
368,
341,
286,
1077,
294,
57639,
9438,
284,
330,
93231,
19415,
2319,
220,
18,
13,
15,
13,
15,
12,
7380,
16,
1177,
2955,
220,
17,
15,
15,
17,
12,
17,
15,
17,
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... | 1 |
#[test]
fn test_update_key() {
KeysManagerTest::new(ALICE)
.set_key_weight(BOB, Weight::new(1))
.assert_success_status_and_commit()
.set_key_weight(BOB, Weight::new(2))
.assert_success_status_and_commit()
.assert_keys(vec![(ALICE, Weight::new(1)), (BOB, Weight::new(2))]);
} | rust_cleaned_test_functions.jsonl/96210 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 157
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8882,
3097,
368,
341,
262,
24133,
2043,
2271,
486,
931,
46232,
5487,
340,
286,
659,
746,
3097,
15876,
7,
4677,
33,
11,
16516,
486,
931,
7,
16,
1171,
286,
659,
2207,
18632,
4773,
8378,
36346,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_get_node() {
let querier = new_valid_db("get_node.db");
let got_node = querier.get_node(100);
assert_eq!(common_node(), got_node);
} | rust_cleaned_test_functions.jsonl/107720 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 91
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
5084,
368,
341,
286,
1077,
29134,
1268,
284,
501,
8337,
8685,
445,
455,
5084,
7076,
3071,
286,
1077,
2684,
5084,
284,
29134,
1268,
670,
5084,
7,
16,
15,
15,
317,
286,
2060,
10714,
10297,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_insert() {
let db = Connection::open_in_memory().unwrap();
db.execute_batch("CREATE TABLE foo(x INTEGER UNIQUE)")
.unwrap();
let mut stmt = db
.prepare("INSERT OR IGNORE INTO foo (x) VALUES (?)")
.unwrap();
assert_eq!(stmt.insert(&[1i32]).unwrap(), 1);
assert_eq!(stmt.insert(&[2i32]).unwrap(), 2);
match stmt.insert(&[1i32]).unwrap_err() {
Error::StatementChangedRows(0) => (),
err => panic!("Unexpected error {}", err),
}
let mut multi = db
.prepare("INSERT INTO foo (x) SELECT 3 UNION ALL SELECT 4")
.unwrap();
match multi.insert(NO_PARAMS).unwrap_err() {
Error::StatementChangedRows(2) => (),
err => panic!("Unexpected error {}", err),
}
} | rust_cleaned_test_functions.jsonl/57179 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 426
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17678,
368,
341,
286,
1077,
2927,
284,
11032,
486,
2508,
1243,
19195,
1005,
15454,
543,
286,
2927,
7769,
14534,
445,
22599,
14363,
15229,
2075,
30381,
72350,
19107,
310,
659,
15454,
543,
286,
1077,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_runtime_create_invalid_handle() {
let lib_path = CString::new("some/path").expect("Invalid library path");
let handle = unsafe {
mun_runtime_create(
lib_path.into_raw(),
RuntimeOptions::default(),
ptr::null_mut(),
)
};
assert_ne!(handle.token(), 0);
let message = unsafe { CStr::from_ptr(mun_error_message(handle)) };
assert_eq!(
message.to_str().unwrap(),
"Invalid argument: 'handle' is null pointer."
);
unsafe { mun_destroy_string(message.as_ptr()) };
} | rust_cleaned_test_functions.jsonl/120551 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 252
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
33232,
8657,
31433,
10630,
368,
341,
262,
1077,
3051,
2638,
284,
56956,
486,
931,
445,
14689,
50976,
1827,
17119,
445,
7928,
6733,
1815,
3071,
262,
1077,
3705,
284,
19860,
341,
286,
49979,
33232,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_imm() {
let mut opcode = OpcodeData {
name: "TestOp",
immediates: vec![],
inputs: Inputs::NOV,
outputs: Outputs::NOV,
flags: InstrFlags::NF,
};
let fixups = hashmap! {
"TestOp" => vec! {
insert_imm(0, "imm1", ImmType::SA),
},
};
fixups::apply_fixups(&mut opcode, &fixups);
assert_eq!(
opcode,
OpcodeData {
name: "TestOp",
immediates: vec![("imm1", ImmType::SA)],
inputs: Inputs::NOV,
outputs: Outputs::NOV,
flags: InstrFlags::NF,
}
);
} | rust_cleaned_test_functions.jsonl/54513 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 450
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17678,
71370,
368,
341,
286,
1077,
5206,
30028,
284,
78899,
1043,
341,
310,
829,
25,
330,
2271,
7125,
756,
310,
5551,
973,
25,
7486,
20703,
1259,
310,
11127,
25,
46281,
486,
8996,
53,
345,
310,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_from_u512_zero() {
let modulus = modulus();
assert_eq!(
Scalar::zero(),
Scalar::from_u512([
modulus.0[0],
modulus.0[1],
modulus.0[2],
modulus.0[3],
0,
0,
0,
0
])
);
} | rust_cleaned_test_functions.jsonl/108340 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 218
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5673,
7300,
20,
16,
17,
19359,
368,
341,
262,
1077,
74024,
284,
74024,
543,
262,
2060,
10714,
33673,
286,
35176,
486,
14154,
3148,
286,
35176,
486,
1499,
7300,
20,
16,
17,
8956,
310,
74024,
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_increment_major() {
let mut chrome_release = Version::parse("46.1.246773").unwrap();
chrome_release.increment_major();
assert_eq!(chrome_release, Version::parse("47.0.0").unwrap());
} | rust_cleaned_test_functions.jsonl/43097 | {
"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,
51482,
47916,
368,
341,
286,
1077,
5206,
26429,
24577,
284,
6079,
486,
6400,
445,
19,
21,
13,
16,
13,
17,
19,
21,
22,
22,
18,
1827,
15454,
543,
286,
26429,
24577,
56936,
47916,
543,
286,
2060,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_col_prune_cross_join() {
assert_j_plan("select t2.c0 from t2, t3", |sql, mut plan| {
let subq = get_lvl_queries(&plan, 1);
assert_eq!(2, subq.len());
assert_eq!(3, subq[0].out_cols().len());
assert_eq!(4, subq[1].out_cols().len());
col_prune(&mut plan.qry_set, plan.root).unwrap();
print_plan(sql, &plan);
let subq = get_lvl_queries(&plan, 1);
assert_eq!(1, subq[0].out_cols().len());
assert_eq!(0, subq[1].out_cols().len());
})
} | rust_cleaned_test_functions.jsonl/27138 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 327
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10211,
5294,
2886,
35284,
31017,
368,
341,
286,
2060,
5374,
26564,
445,
1742,
259,
17,
520,
15,
504,
259,
17,
11,
259,
18,
497,
760,
3544,
11,
5206,
3119,
91,
341,
310,
1077,
1186,
80,
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_set_max_background_jobs() {
let path = tempdir_with_prefix("_rust_rocksdb_max_background_jobs");
let mut opts = DBOptions::new();
opts.create_if_missing(true);
opts.set_max_background_jobs(4);
DB::open(opts, path.path().to_str().unwrap()).unwrap();
} | rust_cleaned_test_functions.jsonl/34114 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 125
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2602,
6345,
24103,
37247,
368,
341,
262,
1077,
1815,
284,
2730,
3741,
6615,
13974,
16975,
35788,
26608,
14553,
1999,
6345,
24103,
37247,
797,
262,
1077,
5206,
12185,
284,
5952,
3798,
486,
931,
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_glyph_buffer_serialization_text() {
let path = "testfiles/SourceSansVariable-Roman.ttf";
let face = Face::from_file(path, 0).unwrap();
let font = Font::new(face);
let buffer = UnicodeBuffer::new().add_str("Hello 🌍");
let glyph_buffer = shape(&font, buffer, &[]);
// serializes only glyph indices
let mut serializer = glyph_buffer.serializer(
Some(&font),
SerializeFormat::Text,
SerializeFlags::NO_ADVANCES
| SerializeFlags::NO_CLUSTERS
| SerializeFlags::NO_POSITIONS
| SerializeFlags::NO_GLYPH_NAMES,
);
let mut string = String::new();
serializer.read_to_string(&mut string).unwrap();
for (serialized_glyph, glyph_info) in string
.split_terminator::<&[char]>(&['|', '[', ']'])
.filter(|c| !c.is_empty())
.zip(glyph_buffer.get_glyph_infos())
{
assert_eq!(
serialized_glyph.parse::<u32>().unwrap(),
glyph_info.codepoint
);
}
} | rust_cleaned_test_functions.jsonl/63453 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 574
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
88703,
7776,
25602,
2022,
4326,
368,
341,
286,
1077,
1815,
284,
330,
1944,
7198,
14,
3608,
46882,
7827,
10911,
6908,
45192,
876,
286,
1077,
3579,
284,
18596,
486,
1499,
2458,
5581,
11,
220,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_language_specific_resources_multiple_languages() {
let data_dir = build_data_dir_with_resources(vec![
(PathBuf::from("polish/test.txt"), Vec::from("test")),
(PathBuf::from("polish/test2.txt"), Vec::from("test")),
(PathBuf::from("german/test3.txt"), Vec::from("test")),
(PathBuf::from("other/data.txt"), Vec::from("data")),
]);
let guess = Guess {
vanilla_version: None,
};
let version = guess
.guess_by_language_specific_resources(&data_dir.path().join("data"))
.unwrap();
assert_eq!(version, None);
} | rust_cleaned_test_functions.jsonl/118443 | {
"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,
29021,
56592,
35569,
45233,
77576,
368,
341,
286,
1077,
821,
4334,
284,
1936,
1769,
4334,
6615,
35569,
25592,
90515,
310,
320,
1820,
15064,
486,
1499,
445,
9896,
812,
12697,
3909,
3975,
11312,
486,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_temperature_converter_from_c_to_kelvin() {
let conv = TemperatureConverter::new(-273.15, TemperatureUnit::Celsius);
let res = conv.convert(TemperatureUnit::Kelvin);
assert!(res.is_ok());
let res = res.unwrap();
assert!(is_close(0.0, res.scalar()));
assert_eq!(&TemperatureUnit::Kelvin, res.unit());
} | rust_cleaned_test_functions.jsonl/76286 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 171
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
53525,
74073,
5673,
666,
2346,
59222,
9603,
368,
341,
286,
1077,
5686,
284,
37022,
14920,
486,
931,
4080,
17,
22,
18,
13,
16,
20,
11,
37022,
4562,
486,
34,
40247,
317,
286,
1077,
592,
284,
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 |
#[test]
fn test_leading_whitespace_in_free_argument_should_imply_padding() {
new_ucmd!()
.args(&["--from=auto", " 1Ki"])
.run()
.stdout_is(" 1024\n");
} | rust_cleaned_test_functions.jsonl/46011 | {
"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,
11751,
2228,
86175,
1243,
8905,
9025,
43378,
17895,
2541,
40726,
368,
341,
262,
501,
68887,
2277,
0,
741,
286,
659,
2116,
2099,
1183,
313,
1499,
28,
3902,
497,
330,
256,
220,
16,
72572,
14108,
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 |
#[test]
fn test_mul_overflow() {
fn test_mul_typed_overflow<T>()
where
T: Integer + Bounded + Clone + Debug + NumAssign + CheckedMul,
{
let two = T::one() + T::one();
let _3 = T::one() + T::one() + T::one();
let big = T::max_value() / two.clone() / two.clone() * two.clone();
let _1_big: Ratio<T> = Ratio::new(T::one(), big.clone());
let _2_3: Ratio<T> = Ratio::new(two.clone(), _3.clone());
assert_eq!(None, big.clone().checked_mul(&_3.clone()));
let expected = Ratio::new(T::one(), big / two.clone() * _3.clone());
assert_eq!(expected.clone(), _1_big.clone() * _2_3.clone());
assert_eq!(
Some(expected.clone()),
_1_big.clone().checked_mul(&_2_3.clone())
);
assert_eq!(expected, {
let mut tmp = _1_big.clone();
tmp *= _2_3;
tmp
});
// big/3 * 3 = big/1
let big = T::max_value() / two.clone() / _3.clone() * _3.clone() + T::one();
assert_eq!(None, big.clone().checked_mul(&_3.clone()));
let big_3 = Ratio::new(big.clone(), _3.clone());
let expected = Ratio::new(big.clone(), T::one());
assert_eq!(expected, big_3.clone() * _3.clone());
assert_eq!(expected, {
let mut tmp = big_3.clone();
tmp *= _3.clone();
tmp
});
}
test_mul_typed_overflow::<u16>();
test_mul_typed_overflow::<u8>();
test_mul_typed_overflow::<u32>();
test_mul_typed_overflow::<u64>();
test_mul_typed_overflow::<usize>();
#[cfg(has_u128)]
test_mul_typed_overflow::<u128>();
test_mul_typed_overflow::<i8>();
test_mul_typed_overflow::<i16>();
test_mul_typed_overflow::<i32>();
test_mul_typed_overflow::<i64>();
test_mul_typed_overflow::<isize>();
#[cfg(has_i128)]
test_mul_typed_overflow::<i128>();
} | rust_cleaned_test_functions.jsonl/853 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1415
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
24944,
79073,
368,
341,
310,
5168,
1273,
24944,
528,
32501,
79073,
3125,
18949,
310,
1380,
198,
394,
350,
25,
4440,
488,
425,
13082,
488,
27913,
488,
11091,
488,
16212,
28933,
488,
93361,
59155,
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... | 2 |
#[test]
fn test_shrink_to_fit() {
let mut xs = vec![0, 1, 2, 3];
for i in range(4, 100) {
xs.push(i)
}
assert_eq!(xs.capacity(), 128);
xs.shrink_to_fit();
assert_eq!(xs.capacity(), 100);
assert_eq!(xs, range(0, 100).collect::<Vec<_>>());
} | rust_cleaned_test_functions.jsonl/75634 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 183
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3712,
34365,
2346,
32416,
368,
341,
286,
1077,
5206,
11943,
284,
7486,
20703,
15,
11,
220,
16,
11,
220,
17,
11,
220,
18,
935,
286,
369,
600,
304,
2088,
7,
19,
11,
220,
16,
15,
15,
8,
341,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_resolve() {
// TODO: these module ids should be normalized into a URL:
let cases = [
(
"./tests/hello.ts",
".",
"././tests/hello.ts",
"<cwd>/tests/hello.ts",
),
(
"./hello.ts",
"./tests/main.ts",
"./tests/./hello.ts",
"<cwd>/tests/hello.ts",
),
(
"../hello.ts",
"./tests/subdir/index.ts",
"./tests/subdir/../hello.ts",
"<cwd>/tests/hello.ts",
),
(
"<cwd>/tests/hello.ts",
".",
"<cwd>/tests/hello.ts",
"<cwd>/tests/hello.ts",
),
];
let current_dir = std::env::current_dir().expect("current_dir failed");
let local_disk_resolver = LocalDiskModuleResolver::new(None);
let resolvers = vec![Box::new(local_disk_resolver) as Box<ModuleResolver>];
let compiler = Compiler::new(resolvers);
for &test in cases.iter() {
let specifier = String::from(test.0).replace("<cwd>", current_dir.to_str().unwrap());
let containing_file = String::from(test.1).replace("<cwd>", current_dir.to_str().unwrap());
;
let module_info = compiler
.fetch_module(&specifier, &containing_file)
.unwrap();
assert_eq!(
String::from(test.2).replace("<cwd>", current_dir.to_str().unwrap()),
module_info.module_id,
);
assert_eq!(
String::from(test.3).replace("<cwd>", current_dir.to_str().unwrap()),
module_info.file_name,
);
}
} | rust_cleaned_test_functions.jsonl/4197 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 757
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
77291,
368,
341,
262,
442,
5343,
25,
1493,
4688,
14151,
1265,
387,
29410,
1119,
264,
5548,
510,
1066,
262,
1077,
5048,
284,
2278,
414,
2399,
286,
5924,
23841,
7530,
4791,
21288,
756,
286,
5933,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_doc_store() {
let mut writer = DocWriter::new(0);
let mut sink = vec![];
let doc1 = r#"{"test":"ok"}"#;
let doc2 = r#"{"test2":"ok"}"#;
let doc3 = r#"{"test3":"ok"}"#;
writer.add_doc(doc1, &mut sink).unwrap();
writer.add_doc(doc2, &mut sink).unwrap();
writer.add_doc(doc3, &mut sink).unwrap();
writer.finish(&mut sink).unwrap();
use std::slice;
let offset_bytes = unsafe { slice::from_raw_parts(writer.offsets.as_ptr() as *const u8, writer.offsets.len() * mem::size_of::<(u32, u64)>()) };
assert_eq!(doc1.to_string(), DocLoader::get_doc(&sink, &offset_bytes, 0).unwrap());
assert_eq!(doc2.to_string(), DocLoader::get_doc(&sink, &offset_bytes, 1).unwrap());
assert_eq!(doc3.to_string(), DocLoader::get_doc(&sink, &offset_bytes, 2).unwrap());
} | rust_cleaned_test_functions.jsonl/114200 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 358
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18869,
14809,
368,
341,
262,
1077,
5206,
6916,
284,
21709,
6492,
486,
931,
7,
15,
626,
262,
1077,
5206,
19309,
284,
7486,
0,
15078,
262,
1077,
4629,
16,
284,
435,
55543,
4913,
1944,
3252,
562,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_try_from() {
let _ = ByteString::try_from(&b"nice bytes"[..]).unwrap();
let _ = ByteString::try_from(b"nice bytes".to_vec()).unwrap();
let _ = ByteString::try_from(Bytes::from_static(b"nice bytes")).unwrap();
let _ = ByteString::try_from(BytesMut::from(&b"nice bytes"[..])).unwrap();
let _ =
ByteString::try_from(BytesVec::copy_from_slice(&b"nice bytes"[..])).unwrap();
} | rust_cleaned_test_functions.jsonl/65287 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 201
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
53283,
5673,
368,
341,
286,
1077,
716,
284,
95302,
486,
1539,
5673,
2099,
65,
1,
52796,
5820,
36864,
496,
10697,
15454,
543,
286,
1077,
716,
284,
95302,
486,
1539,
5673,
1883,
1,
52796,
5820,
32... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_identifier() {
assert_eq!(ParseProgress::none(""), identifier(""));
assert_eq!(ParseProgress::none("10"), identifier("10"));
assert_eq!(ParseProgress::some("", "a"), identifier("a"));
assert_eq!(ParseProgress::some("", "ab"), identifier("ab"));
assert_eq!(ParseProgress::some("", "_ab"), identifier("_ab"));
assert_eq!(ParseProgress::some(".", "_ab"), identifier("_ab."));
assert_eq!(ParseProgress::some("", "__"), identifier("__"));
assert_eq!(ParseProgress::some("", "_1"), identifier("_1"));
} | rust_cleaned_test_functions.jsonl/26569 | {
"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,
33176,
368,
341,
286,
2060,
10714,
10297,
14463,
9496,
486,
6697,
86076,
12816,
89744,
286,
2060,
10714,
10297,
14463,
9496,
486,
6697,
445,
16,
15,
3975,
12816,
445,
16,
15,
4010,
286,
2060,
1071... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_basic_connection() {
let mut socket = EngineSocket::new(true);
assert!(socket
.on_open(|_| {
println!("Open event!");
})
.is_ok());
assert!(socket
.on_close(|_| {
println!("Close event!");
})
.is_ok());
assert!(socket
.on_packet(|packet| {
println!("Received packet: {:?}", packet);
})
.is_ok());
assert!(socket
.on_data(|data| {
println!("Received packet: {:?}", std::str::from_utf8(&data));
})
.is_ok());
assert!(socket.bind(SERVER_URL).is_ok());
assert!(socket
.emit(Packet::new(
PacketId::Message,
Bytes::from_static(b"Hello World"),
))
.is_ok());
assert!(socket
.emit(Packet::new(
PacketId::Message,
Bytes::from_static(b"Hello World2"),
))
.is_ok());
assert!(socket
.emit(Packet::new(PacketId::Pong, Bytes::new()))
.is_ok());
assert!(socket
.emit(Packet::new(PacketId::Ping, Bytes::new()))
.is_ok());
sleep(Duration::from_secs(26));
assert!(socket
.emit(Packet::new(
PacketId::Message,
Bytes::from_static(b"Hello World3"),
))
.is_ok());
} | rust_cleaned_test_functions.jsonl/109227 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 919
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34729,
15866,
368,
341,
286,
1077,
5206,
7575,
284,
8200,
10286,
486,
931,
3715,
626,
286,
2060,
10297,
9556,
198,
310,
659,
263,
11311,
22428,
35395,
341,
394,
13751,
17223,
5002,
1538,
11142,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.