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_process_store_with_bad_additional_signer() {
solana_logger::setup();
let signer0_pubkey = Pubkey::new_unique();
let signer1_pubkey = Pubkey::new_unique();
let signer0_account = AccountSharedData::new_ref(0, 0, &Pubkey::new_unique());
let signer1_account = AccountSharedData::new_ref(0, 0, &Pubkey::new_unique());
let keys = vec![(signer0_pubkey, true)];
let (config_keypair, config_account) = create_config_account(keys.clone());
let config_pubkey = config_keypair.pubkey();
let my_config = MyConfig::new(42);
let instruction = config_instruction::store(&config_pubkey, true, keys, &my_config);
// Config-data pubkey doesn't match signer
let mut keyed_accounts = [
(true, false, config_pubkey, config_account),
(true, false, signer1_pubkey, signer1_account),
];
assert_eq!(
process_instruction(&instruction.data, &keyed_accounts),
Err(InstructionError::MissingRequiredSignature)
);
// Config-data pubkey not a signer
keyed_accounts[1] = (false, false, signer0_pubkey, signer0_account);
assert_eq!(
process_instruction(&instruction.data, &keyed_accounts),
Err(InstructionError::MissingRequiredSignature)
);
} | rust_cleaned_test_functions.jsonl/36697 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 599
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11305,
14809,
6615,
34199,
81742,
11172,
261,
368,
341,
286,
2048,
3362,
27413,
486,
15188,
543,
286,
1077,
70039,
15,
34014,
792,
284,
22611,
792,
486,
931,
21218,
543,
286,
1077,
70039,
16,
3401... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_serialize_check_option() {
let m = UciMessage::Option(UciOptionConfig::Check {
name: "Nullmove".to_string(),
default: Some(false),
});
assert_eq!(m.serialize(), "option name Nullmove type check default false");
} | rust_cleaned_test_functions.jsonl/19050 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 128
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
88686,
7200,
9672,
368,
341,
286,
1077,
296,
284,
547,
5855,
2052,
486,
5341,
12317,
5855,
5341,
2648,
486,
3973,
341,
310,
829,
25,
330,
3280,
3397,
3263,
983,
3904,
3148,
310,
1638,
25,
4329,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_noto_serif() {
run_test(
&TEST_DATA,
"harfbuzz/good-noto-serif.te",
"noto/NotoSerifTelugu-Regular.ttf",
&[JOINER_GLYPH_INDEX],
14,
);
} | rust_cleaned_test_functions.jsonl/91179 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 223
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1089,
2072,
75861,
333,
368,
341,
394,
1598,
4452,
1006,
503,
609,
10033,
7896,
345,
503,
330,
12982,
10798,
8889,
4846,
1386,
29169,
78,
27566,
31853,
756,
503,
330,
1921,
78,
20290,
2072,
31745,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_missing_field() {
#[derive(Deserialize, Debug)]
struct Basic {
v: bool,
w: bool,
}
let yaml = indoc! {"
---
v: true
"};
let expected = "missing field `w` at line 2 column 2";
test_error::<Basic>(yaml, expected);
} | rust_cleaned_test_functions.jsonl/45564 | {
"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,
40447,
5013,
368,
341,
262,
11506,
27098,
7,
64465,
11,
11091,
5563,
262,
2036,
14625,
341,
286,
348,
25,
1807,
345,
286,
289,
25,
1807,
345,
262,
456,
262,
1077,
32246,
284,
1257,
509,
0,
314... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_field_expr() {
check_assist(
inline_local_variable,
r"
struct Bar {
foo: usize
}
fn foo() {
let bar = Bar { foo: 1 };
let a$0 = bar.foo;
let b = a * 10;
let c = a as usize;
}",
r"
struct Bar {
foo: usize
}
fn foo() {
let bar = Bar { foo: 1 };
let b = bar.foo * 10;
let c = bar.foo as usize;
}",
);
} | rust_cleaned_test_functions.jsonl/3232 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 227
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5013,
21915,
368,
341,
286,
1779,
12083,
380,
1006,
310,
7381,
13564,
14635,
345,
310,
435,
698,
1235,
4716,
341,
262,
15229,
25,
22301,
198,
630,
8822,
15229,
368,
341,
262,
1077,
3619,
284,
47... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_add_a() {
let mut state = State8080::empty_state();
state.memory = vec![0x87];
state.a = 0x04;
emulate_8080_op(&mut state);
assert_eq!(state.a, 0x08);
} | rust_cleaned_test_functions.jsonl/7780 | {
"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,
2891,
4306,
368,
341,
286,
1077,
5206,
1584,
284,
3234,
23,
15,
23,
15,
486,
3194,
4387,
543,
286,
1584,
36611,
284,
7486,
20703,
15,
87,
23,
22,
935,
286,
1584,
5849,
284,
220,
15,
87,
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_derive_struct() {
#[derive(Debug, Encodable, Decodable, Eq, PartialEq)]
struct TestStruct {
vec: Vec<u8>,
num: u32,
}
let reference = TestStruct {
vec: vec![1, 2, 3],
num: 42,
};
let bytes = [3, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 42, 0, 0, 0];
test_roundtrip_expected(reference, &bytes);
} | rust_cleaned_test_functions.jsonl/78900 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 236
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
35345,
533,
15126,
368,
341,
286,
11506,
27098,
42618,
11,
10751,
69129,
11,
3714,
69129,
11,
33122,
11,
55039,
5563,
286,
2036,
3393,
9422,
341,
310,
7486,
25,
11312,
34837,
23,
12520,
310,
1629,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_hex_function_path() {
assert_eq!(
HexOpt { number: 5 },
HexOpt::try_parse_from(&["test", "-n", "5"]).unwrap()
);
assert_eq!(
HexOpt {
number: 0x00ab_cdef
},
HexOpt::try_parse_from(&["test", "-n", "abcdef"]).unwrap()
);
let err = HexOpt::try_parse_from(&["test", "-n", "gg"]).unwrap_err();
assert!(
err.to_string().contains("invalid digit found in string"),
"{}",
err
);
} | rust_cleaned_test_functions.jsonl/18743 | {
"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,
21039,
32655,
9174,
2638,
368,
341,
262,
2060,
10714,
33673,
286,
27228,
21367,
314,
1372,
25,
220,
20,
1153,
286,
27228,
21367,
486,
1539,
21039,
5673,
2099,
1183,
1944,
497,
6523,
77,
497,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_create1() {
CLASS_RESULT.with(|result| {
*result.borrow_mut() = 0;
});
let mut vm = VirtualMachine::new();
vm.add_external_function(
FunctionDeclaration::with_external(
"print_point".to_owned(), vec![TypeId::Class("Point".to_owned())], TypeId::Void,
print_point as *mut std::ffi::c_void
)
);
vm.add_function(Function::new(
FunctionDeclaration::with_managed("main".to_owned(), Vec::new(), TypeId::Int32),
Vec::new(),
vec![
Instruction::NewObject("Point".to_owned()),
Instruction::Call(FunctionSignature::new("print_point".to_owned(), vec![TypeId::Class("Point".to_owned())])),
Instruction::LoadInt32(0),
Instruction::Return,
]
)).unwrap();
vm.add_class(Class::new(
"Point".to_owned(),
vec![
Field::new("x".to_owned(), TypeId::Int32),
Field::new("y".to_owned(), TypeId::Int32),
]
));
let execution_result = vm.execute().unwrap();
assert_eq!(0, execution_result);
get_vm(|vm| {
assert!(vm.memory_manager.is_owned(CLASS_RESULT.with(|result| *result.borrow()) as *const std::ffi::c_void));
});
} | rust_cleaned_test_functions.jsonl/17391 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 582
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8657,
16,
368,
341,
262,
27939,
21181,
18164,
22428,
1382,
91,
341,
286,
353,
1382,
83640,
29523,
368,
284,
220,
15,
280,
262,
3011,
262,
1077,
5206,
10995,
284,
20721,
21605,
486,
931,
1428,
26... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_dynaerrorkind_as_str_success() {
assert_eq!(
DynaErrorKind::UnhandledError.as_str(),
"unhandled internal error"
);
assert_eq!(DynaErrorKind::ProviderError.as_str(), "provider error");
assert_eq!(
DynaErrorKind::LockAlreadyAcquired.as_str(),
"lock has been acquired by another processor"
);
} | rust_cleaned_test_functions.jsonl/133081 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 197
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
814,
52344,
615,
669,
484,
11898,
2895,
18632,
368,
341,
286,
2060,
10714,
33673,
310,
43938,
64,
1454,
10629,
486,
95539,
1454,
5357,
2895,
3148,
310,
330,
359,
38821,
5306,
1465,
698,
286,
1439,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_block_segment_postings_skip() {
for i in 0..4 {
let mut block_postings = build_block_postings(&[3]);
assert_eq!(
block_postings.skip_to(i),
BlockSegmentPostingsSkipResult::Success(0u32)
);
assert_eq!(
block_postings.skip_to(i),
BlockSegmentPostingsSkipResult::Terminated
);
}
let mut block_postings = build_block_postings(&[3]);
assert_eq!(
block_postings.skip_to(4u32),
BlockSegmentPostingsSkipResult::Terminated
);
} | rust_cleaned_test_functions.jsonl/281 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 347
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7113,
28061,
6333,
819,
44830,
368,
341,
286,
369,
600,
304,
220,
15,
496,
19,
341,
310,
1077,
5206,
2504,
6333,
819,
284,
1936,
7113,
6333,
819,
2099,
58,
18,
2558,
310,
2060,
10714,
33673,
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_parse_arrow_single_right() {
let text = "-> not";
let text: Vec<_> = text.split_whitespace().collect();
let (a, b) = parse_arrow(&text).unwrap();
assert!(a.is_empty());
assert_eq!(b, &["not"]);
} | rust_cleaned_test_functions.jsonl/65982 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 129
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
46566,
19487,
10539,
368,
341,
286,
1077,
1467,
284,
88720,
537,
876,
286,
1077,
1467,
25,
11312,
32399,
29,
284,
1467,
5289,
86175,
1005,
17384,
543,
286,
1077,
320,
64,
11,
293,
8,
284,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_remove_function() {
let db = Connection::open_in_memory().unwrap();
db.create_scalar_function("half", 1, true, half).unwrap();
let result: Result<f64> = db.query_row("SELECT half(6)", NO_PARAMS, |r| r.get(0));
assert!((3f64 - result.unwrap()).abs() < EPSILON);
db.remove_function("half", 1).unwrap();
let result: Result<f64> = db.query_row("SELECT half(6)", NO_PARAMS, |r| r.get(0));
assert!(result.is_err());
} | rust_cleaned_test_functions.jsonl/41667 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 225
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18193,
9174,
368,
341,
286,
1077,
2927,
284,
11032,
486,
2508,
1243,
19195,
1005,
15454,
543,
286,
2927,
2520,
41652,
9174,
445,
37006,
497,
220,
16,
11,
830,
11,
4279,
568,
15454,
543,
286,
107... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_process_op_ne() {
let filter = filter();
let mut op = Operator::Neq(schema_id_tag(), unencrypted_target(SCHEMA_ID.to_string()));
assert!(Verifier::_process_operator("zip", &op, &filter).is_err());
op = Operator::Neq(schema_id_tag(), unencrypted_target("NOT HERE".to_string()));
Verifier::_process_operator("zip", &op, &filter).unwrap()
} | rust_cleaned_test_functions.jsonl/71867 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 172
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11305,
10287,
13925,
368,
341,
286,
1077,
4051,
284,
4051,
543,
286,
1077,
5206,
1179,
284,
28498,
486,
8813,
80,
42735,
842,
9372,
1507,
650,
36444,
11123,
59461,
35839,
3450,
2389,
3904,
7392,
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_cmd_with_json_output() {
let output = launch_command_line(vec![
"-i",
"./tests/data/luxembourg_filtered.osm.pbf",
"-o",
concat!(env!("OUT_DIR"), "/test_cosmogony.json"),
]);
assert!(output.status.success());
} | rust_cleaned_test_functions.jsonl/22516 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 138
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11684,
6615,
9455,
7645,
368,
341,
262,
1077,
2550,
284,
7050,
10811,
6528,
25592,
90515,
286,
6523,
72,
756,
286,
5924,
23841,
13167,
13328,
2200,
55018,
51429,
9291,
76,
556,
13233,
756,
286,
65... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_cli_program_show() {
solana_logger::setup();
let mut noop_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
noop_path.push("tests");
noop_path.push("fixtures");
noop_path.push("noop");
noop_path.set_extension("so");
let mint_keypair = Keypair::new();
let mint_pubkey = mint_keypair.pubkey();
let faucet_addr = run_local_faucet(mint_keypair, None);
let test_validator =
TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified);
let rpc_client =
RpcClient::new_with_commitment(test_validator.rpc_url(), CommitmentConfig::processed());
let mut file = File::open(noop_path.to_str().unwrap()).unwrap();
let mut program_data = Vec::new();
file.read_to_end(&mut program_data).unwrap();
let max_len = program_data.len();
let minimum_balance_for_buffer = rpc_client
.get_minimum_balance_for_rent_exemption(
UpgradeableLoaderState::programdata_len(max_len).unwrap(),
)
.unwrap();
let mut config = CliConfig::recent_for_tests();
let keypair = Keypair::new();
config.json_rpc_url = test_validator.rpc_url();
config.output_format = OutputFormat::Json;
// Airdrop
config.signers = vec![&keypair];
config.command = CliCommand::Airdrop {
pubkey: None,
lamports: 100 * minimum_balance_for_buffer,
};
process_command(&config).unwrap();
// Write a buffer
let buffer_keypair = Keypair::new();
let authority_keypair = Keypair::new();
config.signers = vec![&keypair, &buffer_keypair, &authority_keypair];
config.command = CliCommand::Program(ProgramCliCommand::WriteBuffer {
program_location: noop_path.to_str().unwrap().to_string(),
buffer_signer_index: Some(1),
buffer_pubkey: Some(buffer_keypair.pubkey()),
buffer_authority_signer_index: Some(2),
max_len: None,
});
process_command(&config).unwrap();
// Verify show
config.signers = vec![&keypair];
config.command = CliCommand::Program(ProgramCliCommand::Show {
account_pubkey: Some(buffer_keypair.pubkey()),
authority_pubkey: keypair.pubkey(),
get_programs: false,
get_buffers: false,
all: false,
use_lamports_unit: false,
});
let response = process_command(&config);
let json: Value = serde_json::from_str(&response.unwrap()).unwrap();
let address_str = json
.as_object()
.unwrap()
.get("address")
.unwrap()
.as_str()
.unwrap();
assert_eq!(
buffer_keypair.pubkey(),
Pubkey::from_str(address_str).unwrap()
);
let authority_str = json
.as_object()
.unwrap()
.get("authority")
.unwrap()
.as_str()
.unwrap();
assert_eq!(
authority_keypair.pubkey(),
Pubkey::from_str(authority_str).unwrap()
);
let data_len = json
.as_object()
.unwrap()
.get("dataLen")
.unwrap()
.as_u64()
.unwrap();
assert_eq!(max_len, data_len as usize);
// Deploy
let program_keypair = Keypair::new();
config.signers = vec![&keypair, &authority_keypair, &program_keypair];
config.command = CliCommand::Program(ProgramCliCommand::Deploy {
program_location: Some(noop_path.to_str().unwrap().to_string()),
program_signer_index: Some(2),
program_pubkey: Some(program_keypair.pubkey()),
buffer_signer_index: None,
buffer_pubkey: None,
allow_excessive_balance: false,
upgrade_authority_signer_index: 1,
is_final: false,
max_len: Some(max_len),
});
config.output_format = OutputFormat::JsonCompact;
let min_slot = rpc_client.get_slot().unwrap();
process_command(&config).unwrap();
let max_slot = rpc_client.get_slot().unwrap();
// Verify show
config.signers = vec![&keypair];
config.command = CliCommand::Program(ProgramCliCommand::Show {
account_pubkey: Some(program_keypair.pubkey()),
authority_pubkey: keypair.pubkey(),
get_programs: false,
get_buffers: false,
all: false,
use_lamports_unit: false,
});
let response = process_command(&config);
let json: Value = serde_json::from_str(&response.unwrap()).unwrap();
let address_str = json
.as_object()
.unwrap()
.get("programId")
.unwrap()
.as_str()
.unwrap();
assert_eq!(
program_keypair.pubkey(),
Pubkey::from_str(address_str).unwrap()
);
let programdata_address_str = json
.as_object()
.unwrap()
.get("programdataAddress")
.unwrap()
.as_str()
.unwrap();
let (programdata_pubkey, _) = Pubkey::find_program_address(
&[program_keypair.pubkey().as_ref()],
&bpf_loader_upgradeable::id(),
);
assert_eq!(
programdata_pubkey,
Pubkey::from_str(programdata_address_str).unwrap()
);
let authority_str = json
.as_object()
.unwrap()
.get("authority")
.unwrap()
.as_str()
.unwrap();
assert_eq!(
authority_keypair.pubkey(),
Pubkey::from_str(authority_str).unwrap()
);
let deployed_slot = json
.as_object()
.unwrap()
.get("lastDeploySlot")
.unwrap()
.as_u64()
.unwrap();
assert!(deployed_slot >= min_slot);
assert!(deployed_slot <= max_slot);
let data_len = json
.as_object()
.unwrap()
.get("dataLen")
.unwrap()
.as_u64()
.unwrap();
assert_eq!(max_len, data_len as usize);
} | rust_cleaned_test_functions.jsonl/703 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2629
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
47147,
25096,
15267,
368,
341,
262,
2048,
3362,
27413,
486,
15188,
1428,
262,
1077,
5206,
60829,
2638,
284,
7933,
15064,
486,
1499,
16978,
17223,
34,
7581,
46,
25143,
91120,
8291,
4010,
262,
60829,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_decode_malicious_v1_message() {
// 10 byte snappy stream identifier
let stream_identifier: &'static [u8] = b"\xFF\x06\x00\x00sNaPpY";
assert_eq!(stream_identifier.len(), 10);
let malicious_padding: &'static [u8] = b"\xFE\x00\x00\x00";
let status_message_bytes = StatusMessage {
fork_digest: [0; 4],
finalized_root: Hash256::from_low_u64_be(0),
finalized_epoch: Epoch::new(1),
head_root: Hash256::from_low_u64_be(0),
head_slot: Slot::new(1),
}
.as_ssz_bytes();
assert_eq!(status_message_bytes.len(), 84);
assert_eq!(snap::raw::max_compress_len(status_message_bytes.len()), 130);
let mut uvi_codec: Uvi<usize> = Uvi::default();
let mut dst = BytesMut::with_capacity(1024);
// Insert length-prefix
uvi_codec
.encode(status_message_bytes.len(), &mut dst)
.unwrap();
// Insert snappy stream identifier
dst.extend_from_slice(stream_identifier);
// Insert malicious padding of 80 bytes.
for _ in 0..20 {
dst.extend_from_slice(malicious_padding);
}
let mut writer = FrameEncoder::new(Vec::new());
writer.write_all(&status_message_bytes).unwrap();
writer.flush().unwrap();
assert_eq!(writer.get_ref().len(), 42);
dst.extend_from_slice(writer.get_ref());
assert_eq!(
decode(Protocol::Status, Version::V1, &mut dst).unwrap_err(),
RPCError::InvalidData
);
} | rust_cleaned_test_functions.jsonl/57908 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 823
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15227,
717,
278,
9627,
2273,
16,
6462,
368,
341,
286,
442,
220,
16,
15,
4922,
4131,
11144,
4269,
12816,
198,
286,
1077,
4269,
33176,
25,
30136,
1978,
508,
84,
23,
60,
284,
293,
11934,
9264,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_branch_truncate_to() {
let hdr: VecxVs<String> = VecxVs::new();
let vn = VersionName(b"manster0");
pnk!(hdr.version_create(vn));
let mval = String::from("value1");
hdr.push(mval.clone());
pnk!(hdr.version_create(VersionName(b"manster1")));
let tval = String::from("value2");
hdr.push(tval.clone());
pnk!(hdr.branch_truncate_to(INITIAL_BRANCH_NAME, vn));
assert_eq!(pnk!(hdr.get(0)), mval);
} | rust_cleaned_test_functions.jsonl/92144 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 224
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28031,
3547,
26900,
2346,
368,
341,
262,
1077,
36615,
25,
11312,
87,
51737,
3464,
29,
284,
11312,
87,
51737,
486,
931,
543,
262,
1077,
51017,
284,
6079,
675,
1883,
1,
1515,
3667,
15,
797,
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_short_vec_u8() {
let vec = ShortVec(vec![4u8; 32]);
let bytes = serialize(&vec).unwrap();
assert_eq!(bytes.len(), vec.0.len() + 1);
let vec1: ShortVec<u8> = deserialize(&bytes).unwrap();
assert_eq!(vec.0, vec1.0);
} | rust_cleaned_test_functions.jsonl/91792 | {
"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,
16673,
13251,
7300,
23,
368,
341,
286,
1077,
7486,
284,
10698,
10050,
25592,
20703,
19,
84,
23,
26,
220,
18,
17,
2558,
286,
1077,
5820,
284,
24235,
2099,
4083,
568,
15454,
543,
286,
2060,
10714,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_basic() {
let (crypto_provider, _) = get_test_db_crypto_provider();
// We start un-encrypted and unlocked.
assert!(!crypto_provider.is_db_encrypted());
assert!(crypto_provider.is_unlocked());
// check_and_store_password should only accept an empty password and we should stay
// unencrypted.
assert!(crypto_provider
.check_and_store_password(&[1, 2, 3])
.is_err());
assert!(!crypto_provider.is_db_encrypted());
assert!(crypto_provider.is_unlocked());
assert!(crypto_provider.check_and_store_password(&[]).is_ok());
assert!(!crypto_provider.is_db_encrypted());
assert!(crypto_provider.is_unlocked());
// Encrypting/decrypting should be a no-op at this point.
assert_eq!(
crypto_provider.encrypt(&TEST_DATA[..]).unwrap(),
TEST_DATA.to_vec()
);
assert_eq!(
crypto_provider.decrypt(&TEST_DATA[..]).unwrap(),
TEST_DATA.to_vec()
);
assert_eq!(
crypto_provider
.encrypt_with_password(&[], &TEST_DATA[..])
.unwrap(),
TEST_DATA.to_vec()
);
assert_ne!(
crypto_provider
.encrypt_with_password(&[1; PASSWORD_LEN], &TEST_DATA[..])
.unwrap(),
TEST_DATA.to_vec()
);
// Changing to empty password should not affect anything.
let db_txn = crypto_provider.env.begin_rw_txn().unwrap();
crypto_provider.change_password(db_txn, &[]).unwrap();
assert!(crypto_provider
.check_and_store_password(&[1, 2, 3])
.is_err());
assert!(!crypto_provider.is_db_encrypted());
assert!(crypto_provider.is_unlocked());
assert!(crypto_provider.check_and_store_password(&[]).is_ok());
assert!(crypto_provider.check_and_store_password(&[200; 1]).is_err());
assert!(crypto_provider
.check_and_store_password(&[200; PASSWORD_LEN])
.is_err());
assert!(!crypto_provider.is_db_encrypted());
assert!(crypto_provider.is_unlocked());
// Encrypting/decrypting should be a no-op at this point.
assert_eq!(
crypto_provider.encrypt(&TEST_DATA[..]).unwrap(),
TEST_DATA.to_vec()
);
assert_eq!(
crypto_provider.decrypt(&TEST_DATA[..]).unwrap(),
TEST_DATA.to_vec()
);
assert_eq!(
crypto_provider
.encrypt_with_password(&[], &TEST_DATA[..])
.unwrap(),
TEST_DATA.to_vec()
);
assert_ne!(
crypto_provider
.encrypt_with_password(&[1; PASSWORD_LEN], &TEST_DATA[..])
.unwrap(),
TEST_DATA.to_vec()
);
// should no longer be the identity function.
let db_txn = crypto_provider.env.begin_rw_txn().unwrap();
crypto_provider
.change_password(db_txn, &[6; PASSWORD_LEN])
.unwrap();
assert!(crypto_provider.check_and_store_password(&[]).is_err());
assert!(crypto_provider.check_and_store_password(&[200; 1]).is_err());
assert!(crypto_provider
.check_and_store_password(&[200; PASSWORD_LEN])
.is_err());
assert!(crypto_provider
.check_and_store_password(&[6; PASSWORD_LEN])
.is_ok());
assert!(crypto_provider.is_db_encrypted());
assert!(crypto_provider.is_unlocked());
let encrypted_data = crypto_provider.encrypt(&TEST_DATA[..]).unwrap();
assert_ne!(encrypted_data, TEST_DATA.to_vec()); // No longer the identity function
assert!(crypto_provider.decrypt(&TEST_DATA[..]).is_err()); // TEST_DATA is not encrypted so this shoud fail.
assert_eq!(
TEST_DATA.to_vec(),
crypto_provider.decrypt(&encrypted_data).unwrap()
);
assert_eq!(
encrypted_data,
crypto_provider
.encrypt_with_password(&[6; PASSWORD_LEN], &TEST_DATA[..])
.unwrap()
);
// Changing to a different password should result in different encrypted data.
let db_txn = crypto_provider.env.begin_rw_txn().unwrap();
crypto_provider
.change_password(db_txn, &[7; PASSWORD_LEN])
.unwrap();
assert!(crypto_provider.is_db_encrypted());
assert!(crypto_provider.is_unlocked());
let encrypted_data2 = crypto_provider.encrypt(&TEST_DATA[..]).unwrap();
assert_ne!(encrypted_data, encrypted_data2);
assert_ne!(TEST_DATA.to_vec(), encrypted_data2);
assert_eq!(
encrypted_data2,
crypto_provider
.encrypt_with_password(&[7; PASSWORD_LEN], &TEST_DATA[..])
.unwrap()
);
// Previously encrypted data should not decrypt.
assert!(crypto_provider.decrypt(&encrypted_data).is_err());
// check_and_store_password should behave as expected.
assert!(crypto_provider.check_and_store_password(&[]).is_err());
assert!(crypto_provider.check_and_store_password(&[200; 1]).is_err());
assert!(crypto_provider
.check_and_store_password(&[200; PASSWORD_LEN])
.is_err());
assert!(crypto_provider
.check_and_store_password(&[7; PASSWORD_LEN])
.is_ok());
// Changing back to an empty password should clear the is_db_encrypted flag.
let db_txn = crypto_provider.env.begin_rw_txn().unwrap();
crypto_provider.change_password(db_txn, &[]).unwrap();
assert!(crypto_provider.check_and_store_password(&[]).is_ok());
assert!(!crypto_provider.is_db_encrypted());
assert!(crypto_provider.is_unlocked());
// Encrypting/decrypting should be a no-op at this point.
assert_eq!(
crypto_provider.encrypt(&TEST_DATA[..]).unwrap(),
TEST_DATA.to_vec()
);
assert_eq!(
crypto_provider.decrypt(&TEST_DATA[..]).unwrap(),
TEST_DATA.to_vec()
);
assert_eq!(
crypto_provider
.encrypt_with_password(&[], &TEST_DATA[..])
.unwrap(),
TEST_DATA.to_vec()
);
assert_ne!(
crypto_provider
.encrypt_with_password(&[1; PASSWORD_LEN], &TEST_DATA[..])
.unwrap(),
TEST_DATA.to_vec()
);
// check_and_store_password should behave as expected.
assert!(crypto_provider.check_and_store_password(&[]).is_ok());
assert!(crypto_provider.check_and_store_password(&[200; 1]).is_err());
assert!(crypto_provider
.check_and_store_password(&[200; PASSWORD_LEN])
.is_err());
assert!(crypto_provider.check_and_store_password(&[7; 1]).is_err());
} | rust_cleaned_test_functions.jsonl/33083 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 3509
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34729,
368,
341,
286,
1077,
320,
35772,
29518,
11,
27439,
284,
633,
4452,
8685,
78298,
29518,
1428,
286,
442,
1205,
1191,
650,
12,
36444,
323,
35618,
624,
286,
2060,
0,
3471,
35772,
29518,
2079,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_single_big_args() {
const FILE: &str = "single_big_args.txt";
const EXPECTED_FILE: &str = "single_big_args_expected.txt";
const LINES: usize = 1_000_000;
const N_ARG: usize = 100_000;
let (at, mut ucmd) = at_and_ucmd!();
let mut big_input = at.make_file(FILE);
for i in 0..LINES {
writeln!(&mut big_input, "Line {}", i).expect("Could not write to FILE");
}
big_input.flush().expect("Could not flush FILE");
let mut big_expected = at.make_file(EXPECTED_FILE);
for i in (LINES - N_ARG)..LINES {
writeln!(&mut big_expected, "Line {}", i).expect("Could not write to EXPECTED_FILE");
}
big_expected.flush().expect("Could not flush EXPECTED_FILE");
ucmd.arg(FILE)
.arg("-n")
.arg(format!("{}", N_ARG))
.run()
.stdout_is(at.read(EXPECTED_FILE));
} | rust_cleaned_test_functions.jsonl/39291 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 394
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19487,
36386,
8384,
368,
341,
262,
733,
11837,
25,
609,
495,
284,
330,
15338,
36386,
8384,
3909,
876,
262,
733,
8921,
1479,
8087,
25,
609,
495,
284,
330,
15338,
36386,
8384,
32190,
3909,
876,
26... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_tanh_derivative() {
fn f(x: f32) -> f32 {
1.0 - x.tanh().powf(2.0)
}
let activation = Activation::Tanh;
assert_eq!(
activation.calculate_derivative(&array![[0.0]]).unwrap(),
&array![[f(0.0)]]
);
assert_eq!(
activation
.calculate_derivative(&array![[0.0, 1.0]])
.unwrap(),
&array![[f(0.0), f(1.0)]]
);
assert_eq!(
activation
.calculate_derivative(&array![[0.0], [1.0]])
.unwrap(),
&array![[f(0.0)], [f(1.0)]]
);
assert_eq!(
activation
.calculate_derivative(&array![[0.0, 1.0], [2.0, 3.0]])
.unwrap(),
&array![[f(0.0), f(1.0)], [f(2.0), f(3.0)]]
);
} | rust_cleaned_test_functions.jsonl/65373 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 569
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
528,
27924,
95930,
368,
341,
286,
5168,
282,
2075,
25,
282,
18,
17,
8,
1464,
282,
18,
17,
341,
310,
220,
16,
13,
15,
481,
856,
734,
27924,
1005,
21743,
69,
7,
17,
13,
15,
340,
286,
555,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_hover_shadowing_pat() {
check(
r#"
fn x() {}
fn y() {
let x = 0i32;
x$0;
}
"#,
expect![[r#"
*x*
```rust
let x: i32
```
"#]],
)
} | rust_cleaned_test_functions.jsonl/66639 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 207
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
53445,
53120,
287,
55824,
368,
341,
286,
1779,
1006,
310,
435,
2,
698,
8822,
856,
368,
10086,
8822,
379,
368,
341,
262,
1077,
856,
284,
220,
15,
72,
18,
17,
280,
262,
856,
3,
15,
280,
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... | 1 |
#[test]
fn test_phy_payload_is_none_when_too_few_bytes() {
let bytes = &vec![
0x80, 0x04, 0x03, 0x02, 0x01, 0x00, 0xff, 0x01, 0x02, 0x03, 0x04
];
let phy = PhyPayload::new(bytes);
assert!(phy.is_err());
} | rust_cleaned_test_functions.jsonl/81588 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 130
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
50266,
32813,
6892,
31488,
47636,
2346,
78,
761,
365,
12524,
368,
341,
262,
1077,
5820,
284,
609,
4083,
90515,
286,
220,
15,
87,
23,
15,
11,
220,
15,
87,
15,
19,
11,
220,
15,
87,
15,
18,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_read_identifiers_streaming() {
assert_eq!(Parser::new("null".chars()).next(), Some(NullValue));
assert_eq!(Parser::new("true".chars()).next(), Some(BooleanValue(true)));
assert_eq!(Parser::new("false".chars()).next(), Some(BooleanValue(false)));
assert_eq!(last_event("n"), Error(SyntaxError(InvalidSyntax, 1, 2)));
assert_eq!(last_event("nul"), Error(SyntaxError(InvalidSyntax, 1, 4)));
assert_eq!(last_event("t"), Error(SyntaxError(InvalidSyntax, 1, 2)));
assert_eq!(last_event("truz"), Error(SyntaxError(InvalidSyntax, 1, 4)));
assert_eq!(last_event("f"), Error(SyntaxError(InvalidSyntax, 1, 2)));
assert_eq!(last_event("faz"), Error(SyntaxError(InvalidSyntax, 1, 3)));
} | rust_cleaned_test_functions.jsonl/6587 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 345
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
38399,
11836,
12673,
287,
368,
341,
286,
2060,
10714,
10297,
6570,
486,
931,
445,
2921,
3263,
19255,
6011,
3600,
1507,
4329,
7,
3280,
1130,
1106,
286,
2060,
10714,
10297,
6570,
486,
931,
445... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_string() {
let col_index = LineIndex::new(
"
const C: char = \"メ メ\";
",
);
assert_eq!(col_index.utf16_lines.len(), 1);
assert_eq!(col_index.utf16_lines[&1].len(), 2);
assert_eq!(col_index.utf16_lines[&1][0], Utf16Char { start: 17.into(), end: 20.into() });
assert_eq!(col_index.utf16_lines[&1][1], Utf16Char { start: 21.into(), end: 24.into() });
// UTF-8 to UTF-16
assert_eq!(col_index.utf8_to_utf16_col(1, 15.into()), 15);
assert_eq!(col_index.utf8_to_utf16_col(1, 21.into()), 19);
assert_eq!(col_index.utf8_to_utf16_col(1, 25.into()), 21);
assert!(col_index.utf8_to_utf16_col(2, 15.into()) == 15);
// UTF-16 to UTF-8
assert_eq!(col_index.utf16_to_utf8_col(1, 15), TextSize::from(15));
// メ assert_eq!(col_index.utf16_to_utf8_col(1, 17), TextSize::from(17)); // fir assert_eq!(col_index.utf16_to_utf8_col(1, 18), TextSize::from(20)); // space assert_eq!(col_index.utf16_to_utf8_col(1, 19), TextSize::from(21)); // seconassert_eq!(col_index.utf16_to_utf8_col(2, 15), TextSize::from(15));
} | rust_cleaned_test_functions.jsonl/76438 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 573
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3904,
368,
341,
286,
1077,
1375,
3560,
284,
7083,
1552,
486,
931,
1006,
310,
6228,
1024,
356,
25,
1161,
284,
7245,
38750,
20711,
94,
59,
876,
756,
286,
3475,
286,
2060,
10714,
10297,
2074,
3560,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ao_issue() {
use leaky_bucket_lite::sync::LeakyBucket;
use std::time::{Duration, Instant};
let mut rate_limiter = LeakyBucket::builder()
.refill_amount(1.0)
.refill_interval(Duration::from_secs(2))
.max(5.0)
.tokens(5.0)
.build();
let begin = Instant::now();
std::thread::sleep(Duration::from_secs(10));
for _ in 0..10 {
rate_limiter.acquire_one();
}
let elapsed = Instant::now().duration_since(begin);
println!("Elapsed: {:?}", elapsed);
assert!(elapsed.as_millis() >= 20000 && elapsed.as_millis() <= 20050);
} | rust_cleaned_test_functions.jsonl/25012 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 285
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
3441,
53340,
368,
341,
262,
990,
23352,
88,
38749,
89191,
486,
12996,
486,
2304,
28100,
36018,
280,
262,
990,
1460,
486,
1678,
22964,
12945,
11,
18058,
2315,
262,
1077,
5206,
4379,
907,
17700,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_insert() {
let inputs = vec!["key1", "key3", "key5", "key7", "key9"];
let skl = new_test_skl();
for key in inputs.clone() {
skl.insert(key.as_bytes());
}
let mut node = skl.head;
for input_key in inputs {
unsafe {
let next = (*node).get_next(1);
let key = (*next).key();
assert_eq!(key, input_key.as_bytes());
node = next;
}
}
unsafe {
// should be the last node
assert_eq!((*node).get_next(1), ptr::null_mut());
}
} | rust_cleaned_test_functions.jsonl/15461 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 363
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17678,
368,
341,
286,
1077,
11127,
284,
7486,
0,
1183,
792,
16,
497,
330,
792,
18,
497,
330,
792,
20,
497,
330,
792,
22,
497,
330,
792,
24,
6332,
286,
1077,
82542,
284,
501,
4452,
643,
10561... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_update_finalized_transaction_finalized() {
// Don't wait once the transaction has been finalized.
let mut db =
PickleDb::new_yaml(NamedTempFile::new().unwrap(), PickleDbDumpPolicy::NeverDump);
let signature = Signature::default();
let transaction_info = TransactionInfo::default();
db.set(&signature.to_string(), &transaction_info).unwrap();
let transaction_status = TransactionStatus {
slot: 0,
confirmations: None,
err: None,
status: Ok(()),
confirmation_status: Some(TransactionConfirmationStatus::Finalized),
};
assert_eq!(
update_finalized_transaction(&mut db, &signature, Some(transaction_status), 0, 0)
.unwrap(),
None
);
assert!(db
.get::<TransactionInfo>(&signature.to_string())
.unwrap()
.finalized_date
.is_some());
} | rust_cleaned_test_functions.jsonl/73564 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 465
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8882,
20676,
1506,
28884,
20676,
1506,
368,
341,
286,
442,
4320,
944,
3783,
3055,
279,
7745,
702,
1012,
60387,
624,
286,
1077,
5206,
2927,
4035,
310,
19725,
89506,
486,
931,
64380,
8204,
3606,
121... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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() {
assert_eq!(
set("key", "value", None, None),
"set key 0 0 5\r\nvalue\r\n"
);
} | rust_cleaned_test_functions.jsonl/26807 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 95
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2602,
368,
341,
286,
2060,
10714,
33673,
310,
738,
445,
792,
497,
330,
957,
497,
2240,
11,
2240,
1326,
310,
330,
746,
1376,
220,
15,
220,
15,
220,
20,
12016,
1699,
957,
12016,
1699,
698,
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 |
#[test]
fn test_array_element_function_call_as_dimension() {
assert_expression!(
"cards(lbound(cards) + 1).Value",
Expression::Property(
Box::new(Expression::func(
"cards",
vec![Expression::BinaryExpression(
Operator::Plus,
Box::new(
Expression::func("lbound", vec!["cards".as_var_expr(1, 20)])
.at_rc(1, 13)
),
Box::new(1.as_lit_expr(1, 29)),
ExpressionType::Unresolved
)
.at_rc(1, 27)]
)),
"Value".into(),
ExpressionType::Unresolved
)
);
} | rust_cleaned_test_functions.jsonl/102645 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 625
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3858,
7894,
9174,
13429,
11898,
49619,
368,
341,
310,
2060,
28068,
33673,
394,
330,
25024,
2333,
10891,
73863,
8,
488,
220,
16,
568,
1130,
756,
394,
16378,
486,
3052,
1006,
503,
8261,
486,
931,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_filter_binary_array_with_null() {
let data: Vec<Option<&[u8]>> = vec![Some(b"hello"), None, Some(b"world"), None];
let a = BinaryArray::from(data);
let b = BooleanArray::from(vec![true, false, false, true]);
let c = filter(&a, &b).unwrap();
let d = c.as_ref().as_any().downcast_ref::<BinaryArray>().unwrap();
assert_eq!(2, d.len());
assert_eq!(b"hello", d.value(0));
assert_eq!(false, d.is_null(0));
assert_eq!(true, d.is_null(1));
} | rust_cleaned_test_functions.jsonl/28231 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 260
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8727,
31761,
3858,
6615,
15162,
368,
341,
286,
1077,
821,
25,
11312,
94150,
52244,
58,
84,
23,
60,
2452,
284,
7486,
20703,
8373,
1883,
1,
14990,
3975,
2240,
11,
4329,
1883,
1,
14615,
3975,
2240,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_single() {
struct Foo;
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Foo")
.field("bar", &true)
.finish()
}
}
assert_eq!("Foo { bar: true }", format!("{:?}", Foo));
assert_eq!(
"Foo {
bar: true,
}",
format!("{:#?}", Foo));
} | rust_cleaned_test_functions.jsonl/69308 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 270
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19487,
368,
341,
286,
2036,
33428,
401,
286,
11605,
8879,
486,
7939,
369,
33428,
341,
310,
5168,
8879,
2099,
721,
11,
8879,
25,
609,
6984,
8879,
486,
14183,
18291,
62,
9231,
1464,
8879,
486,
207... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_server_received_push_stream() {
let (mut hconn, mut peer_conn) = connect();
// create a push stream.
let push_stream_id = peer_conn.stream_create(StreamType::UniDi).unwrap();
let _ = peer_conn.stream_send(push_stream_id, &[0x1]);
let out = peer_conn.process(None, now());
let out = hconn.process(out.dgram(), now());
let _ = peer_conn.conn.process(out.dgram(), now());
assert_closed(&mut hconn, &Error::HttpStreamCreation);
} | rust_cleaned_test_functions.jsonl/52187 | {
"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,
12015,
40783,
14218,
12673,
368,
341,
286,
1077,
320,
6984,
305,
5148,
11,
5206,
14397,
17241,
8,
284,
4564,
1428,
286,
442,
1855,
264,
4484,
4269,
624,
286,
1077,
4484,
12673,
842,
284,
14397,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_request_parse_absolute_uri() {
let mut hyper_request = HttpRequest::new(Body::empty());
*hyper_request.method_mut() = Method::GET;
*hyper_request.uri_mut() = "http://my-host/path".parse().unwrap();
let iron_request = Request::from_http(hyper_request, None, &Protocol::http())
.expect("A valid Iron request");
assert_eq!(iron_request.url.host(), Domain("my-host"));
} | rust_cleaned_test_functions.jsonl/73131 | {
"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,
7893,
21039,
50874,
15572,
368,
341,
286,
1077,
5206,
17071,
7893,
284,
44049,
486,
931,
5349,
1076,
486,
3194,
1423,
286,
353,
68192,
7893,
12908,
29523,
368,
284,
6730,
486,
3806,
280,
286,
353,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_inspect_pulse_persist() {
let _executor = fuchsia_async::TestExecutor::new();
let inspector = finspect::Inspector::new();
let sme_root_node = inspector.root().create_child("sme");
let (persistence_req_sender, mut persistence_receiver) =
test_utils::create_inspect_persistence_channel();
let (mut sme, _mlme_stream, mut time_stream) = ClientSme::new(
ClientConfig::from_config(SmeConfig::default().with_wep(), false),
test_utils::fake_device_info(CLIENT_ADDR),
Arc::new(wlan_inspect::iface_mgr::IfaceTreeHolder::new(sme_root_node)),
WlanHasher::new(DUMMY_HASH_KEY),
persistence_req_sender,
fake_mac_sublayer_support(),
fake_security_support(),
fake_spectrum_management_support_empty(),
);
assert_eq!(ClientSmeStatus::Idle, sme.status());
// Verify we request persistence on startup
assert_variant!(persistence_receiver.try_next(), Ok(Some(tag)) => {
assert_eq!(&tag, "wlanstack-last-pulse");
});
let mut persist_event = None;
while let Ok(Some((_timeout, timed_event))) = time_stream.try_next() {
match timed_event.event {
Event::InspectPulsePersist(..) => {
persist_event = Some(timed_event);
break;
}
_ => (),
}
}
assert!(persist_event.is_some());
sme.on_timeout(persist_event.unwrap());
// Verify we request persistence again on timeout
assert_variant!(persistence_receiver.try_next(), Ok(Some(tag)) => {
assert_eq!(&tag, "wlanstack-last-pulse");
});
} | rust_cleaned_test_functions.jsonl/33067 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 852
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34386,
987,
83645,
620,
4975,
368,
341,
286,
1077,
716,
80787,
284,
282,
73391,
28346,
486,
2271,
25255,
486,
931,
543,
286,
1077,
44725,
284,
64979,
987,
486,
46230,
486,
931,
543,
286,
1077,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_bin_too_few_args() {
let args = [String::from("command"), String::from("too few arguments")];
let config = parse_config(&args);
assert!(config.is_err());
} | rust_cleaned_test_functions.jsonl/19379 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 74
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21816,
2346,
78,
761,
365,
8384,
368,
341,
262,
1077,
2827,
284,
508,
703,
486,
1499,
445,
5631,
3975,
923,
486,
1499,
445,
36127,
2421,
5977,
899,
935,
262,
1077,
2193,
284,
4715,
5332,
2099,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_generic_struct() {
assert_tokens(
&GenericStruct { x: 5u32 },
&[
Token::Struct {
name: "GenericStruct",
len: 1,
},
Token::Str("x"),
Token::U32(5),
Token::StructEnd,
],
);
} | rust_cleaned_test_functions.jsonl/56424 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 198
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
41232,
15126,
368,
341,
262,
2060,
28838,
1006,
286,
609,
19964,
9422,
314,
856,
25,
220,
20,
84,
18,
17,
1153,
286,
609,
9640,
310,
9660,
486,
9422,
341,
394,
829,
25,
330,
19964,
9422,
756,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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() {
let m: Map<u8, MVReg<u8, _>, u8> = Map::new();
assert_eq!(m.len().val, 0);
assert!(m.is_empty().val);
} | rust_cleaned_test_functions.jsonl/61620 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 79
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5921,
368,
341,
262,
1077,
296,
25,
5027,
34837,
23,
11,
42271,
3477,
34837,
23,
11,
716,
8066,
575,
23,
29,
284,
5027,
486,
931,
543,
262,
2060,
10714,
10297,
76,
19406,
1005,
831,
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 |
#[test]
fn test_disable_ime() {
let mut interrupts = Interrupts::new();
// Count down.
interrupts.disable_ime();
assert_eq!(interrupts.disable_ime_counter, 2);
interrupts.tick_ime_timer();
assert_eq!(interrupts.disable_ime_counter, 1);
interrupts.tick_ime_timer();
assert_eq!(interrupts.disable_ime_counter, 0);
interrupts.tick_ime_timer();
assert_eq!(interrupts.disable_ime_counter, 0);
// Spam and reset.
interrupts.disable_ime();
interrupts.disable_ime();
interrupts.disable_ime();
assert_eq!(interrupts.disable_ime_counter, 2);
interrupts.tick_ime_timer();
interrupts.disable_ime();
assert_eq!(interrupts.disable_ime_counter, 2);
} | rust_cleaned_test_functions.jsonl/17897 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 352
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
33842,
62,
545,
368,
341,
286,
1077,
5206,
43437,
284,
22145,
82,
486,
931,
1428,
286,
442,
4504,
1495,
624,
286,
43437,
42628,
62,
545,
543,
286,
2060,
10714,
10297,
54805,
82,
42628,
62,
545,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_reset() {
let mut bb = BollingerBands::new(5, 2.0_f64).unwrap();
let out = bb.nexta(3.0);
assert_eq!(out.average, 3.0);
assert_eq!(out.upper, 3.0);
assert_eq!(out.lower, 3.0);
bb.nexta(2.5);
bb.nexta(3.5);
bb.nexta(4.0);
let out = bb.nexta(2.0);
assert_eq!(out.average, 3.0);
assert_eq!(round(out.upper), 4.414);
assert_eq!(round(out.lower), 1.586);
bb.reset();
let out = bb.nexta(3.0);
assert_eq!(out.average, 3.0);
assert_eq!(out.upper, 3.0);
assert_eq!(out.lower, 3.0);
} | rust_cleaned_test_functions.jsonl/99260 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 377
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18983,
368,
341,
286,
1077,
5206,
16520,
284,
425,
965,
5137,
33,
2844,
486,
931,
7,
20,
11,
220,
17,
13,
15,
761,
21,
19,
568,
15454,
1428,
286,
1077,
700,
284,
16520,
4529,
64,
7,
18,
13... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_do_not_remove_set_setter_to_getter() {
test_same(concat!(
"var a = {",
" get property() {},",
" set property(x) {}",
"};",
"a.property = a.property;",
));
} | rust_cleaned_test_functions.jsonl/496 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 127
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26309,
7913,
18193,
2602,
2602,
465,
2346,
3062,
465,
368,
341,
262,
1273,
33574,
96360,
33673,
286,
330,
947,
264,
284,
314,
497,
715,
286,
330,
220,
633,
3343,
368,
16452,
756,
286,
330,
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 |
#[test]
fn test_force_install_no_reboot() {
let update =
Update::from_args(&["update"], &["force-install", "--reboot", "false", "url"]).unwrap();
assert_eq!(
update,
Update {
cmd: Command::ForceInstall(ForceInstall {
update_pkg_url: "url".to_owned(),
reboot: false,
})
}
);
} | rust_cleaned_test_functions.jsonl/50083 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 245
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
40739,
34245,
6536,
1288,
4619,
368,
341,
286,
1077,
2647,
4035,
310,
5549,
486,
1499,
8384,
2099,
1183,
2386,
7914,
609,
1183,
8833,
57899,
497,
14482,
265,
4619,
497,
330,
3849,
497,
330,
1085,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_recursive_tuple() {
assert_eq!(
&("one", ("two", 42)).to_vec(),
&[2, 111, 110, 101, 0, 5, 2, 116, 119, 111, 0, 21, 42, 0]
);
assert_eq!(
&("one", ("two", 42, ("three", 33))).to_vec(),
&[
2, 111, 110, 101, 0, 5, 2, 116, 119, 111, 0, 21, 42, 5, 2, 116, 104, 114, 101, 101,
0, 21, 33, 0, 0,
]
);
// from Python impl:
assert_eq!(
&(None::<i64>, (None::<i64>, None::<i64>)).to_vec(),
&[0, 5, 0, 255, 0, 255, 0]
)
} | rust_cleaned_test_functions.jsonl/127223 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 399
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11224,
66242,
21773,
368,
341,
286,
2060,
10714,
33673,
310,
609,
445,
603,
497,
3489,
19789,
497,
220,
19,
17,
4579,
983,
13251,
3148,
310,
44590,
17,
11,
220,
16,
16,
16,
11,
220,
16,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_shuffle_unshuffle() {
let shuffles = DATA.parse().unwrap();
let deck = shuffle(10_007, &shuffles);
let card = deck.into_iter().position(|c| c == 2019).unwrap();
assert_eq!(
shuffle_index(10_007, 2019, &shuffles),
card as u128,
)
} | rust_cleaned_test_functions.jsonl/104852 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 129
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
73484,
4907,
65355,
368,
341,
10217,
557,
77453,
284,
14112,
4632,
1005,
15454,
543,
1572,
10217,
9530,
284,
25947,
7,
16,
15,
62,
15,
15,
22,
11,
609,
927,
77453,
317,
10217,
3701,
284,
9530,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_deletable_not_readonly() {
with_object(0, |activation, object| {
object.as_script_object().unwrap().define_value(
activation.context.gc_context,
"test",
"initial".into(),
DontDelete.into(),
);
assert_eq!(object.delete(activation, "test"), false);
assert_eq!(object.get("test", activation).unwrap(), "initial".into());
object
.as_script_object()
.unwrap()
.set("test", "replaced".into(), activation)
.unwrap();
assert_eq!(object.delete(activation, "test"), false);
assert_eq!(object.get("test", activation).unwrap(), "replaced".into());
})
} | rust_cleaned_test_functions.jsonl/66740 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 412
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2259,
1149,
480,
7913,
6443,
3243,
368,
341,
286,
448,
5314,
7,
15,
11,
760,
23002,
11,
1633,
91,
341,
310,
1633,
5357,
14660,
5314,
1005,
15454,
1005,
1289,
3142,
1006,
394,
15099,
8681,
65554,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_data_with_decorator() {
let mut handlebars = Registry::new();
handlebars
.register_template_string("t0", "{{hello}}{{*foo}}{{hello}}".to_string())
.unwrap();
let data = btreemap! {
"hello".to_string() => "world".to_string()
};
handlebars.register_decorator(
"foo",
Box::new(
|_: &Directive,
_: &Registry,
ctx: &Context,
rc: &mut RenderContext|
-> Result<(), RenderError> {
// modify json object
let mut new_ctx = ctx.clone();
{
let data = new_ctx.data_mut();
if let Some(ref mut m) = data.as_object_mut().as_mut() {
m.insert("hello".to_string(), to_json("war"));
}
}
rc.set_context(new_ctx);
Ok(())
},
),
);
assert_eq!(
handlebars.render("t0", &data).ok().unwrap(),
"worldwar".to_string()
);
let data2 = 0;
handlebars.register_decorator(
"bar",
Box::new(
|d: &Directive,
_: &Registry,
_: &Context,
rc: &mut RenderContext|
-> Result<(), RenderError> {
// modify value
let v = d
.param(0)
.and_then(|v| Context::wraps(v.value()).ok())
.unwrap_or(Context::null());
rc.set_context(v);
Ok(())
},
),
);
handlebars
.register_template_string("t1", "{{this}}{{*bar 1}}{{this}}".to_string())
.unwrap();
assert_eq!(
handlebars.render("t1", &data2).ok().unwrap(),
"01".to_string()
);
handlebars
.register_template_string(
"t2",
"{{this}}{{*bar \"string_literal\"}}{{this}}".to_string(),
)
.unwrap();
assert_eq!(
handlebars.render("t2", &data2).ok().unwrap(),
"0string_literal".to_string()
);
handlebars
.register_template_string("t3", "{{this}}{{*bar}}{{this}}".to_string())
.unwrap();
assert_eq!(
handlebars.render("t3", &data2).ok().unwrap(),
"0".to_string()
);
} | rust_cleaned_test_functions.jsonl/50779 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1622
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8882,
1769,
6615,
87252,
368,
341,
286,
1077,
5206,
3705,
24950,
284,
32112,
486,
931,
543,
286,
3705,
24950,
198,
310,
659,
6343,
8693,
3904,
445,
83,
15,
497,
47219,
14990,
77286,
9,
7975,
772... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_arguments_non_rlib_crate() {
parses!(
"--crate-type",
"rlib",
"--emit",
"link",
"foo.rs",
"--out-dir",
"out",
"--crate-name",
"foo"
);
parses!(
"--crate-type",
"lib",
"--emit",
"link",
"foo.rs",
"--out-dir",
"out",
"--crate-name",
"foo"
);
parses!(
"--crate-type",
"staticlib",
"--emit",
"link",
"foo.rs",
"--out-dir",
"out",
"--crate-name",
"foo"
);
parses!(
"--crate-type",
"rlib,staticlib",
"--emit",
"link",
"foo.rs",
"--out-dir",
"out",
"--crate-name",
"foo"
);
fails!(
"--crate-type",
"bin",
"--emit",
"link",
"foo.rs",
"--out-dir",
"out",
"--crate-name",
"foo"
);
fails!(
"--crate-type",
"rlib,dylib",
"--emit",
"link",
"foo.rs",
"--out-dir",
"out",
"--crate-name",
"foo"
);
} | rust_cleaned_test_functions.jsonl/8161 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1066
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
43433,
21637,
1710,
2740,
666,
7698,
368,
341,
286,
70835,
33673,
310,
14482,
61711,
10604,
756,
310,
330,
2381,
579,
756,
310,
14482,
18712,
756,
310,
330,
2080,
756,
310,
330,
7975,
25638... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_select_compound_identifiers() {
let query_plan = convert_select_to_query_plan(
"SELECT MEASURE(`KibanaSampleDataEcommerce`.`maxPrice`) AS maxPrice, MEASURE(`KibanaSampleDataEcommerce`.`minPrice`) AS minPrice FROM KibanaSampleDataEcommerce".to_string(), DatabaseProtocol::MySQL
);
let logical_plan = query_plan.as_logical_plan();
assert_eq!(
logical_plan.find_cube_scan().request,
V1LoadRequestQuery {
measures: Some(vec![
"KibanaSampleDataEcommerce.maxPrice".to_string(),
"KibanaSampleDataEcommerce.minPrice".to_string(),
]),
segments: Some(vec![]),
dimensions: Some(vec![]),
time_dimensions: None,
order: None,
limit: None,
offset: None,
filters: None
}
);
} | rust_cleaned_test_functions.jsonl/59240 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 500
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13051,
18177,
795,
38399,
11836,
368,
341,
286,
1077,
3239,
26564,
284,
5508,
13051,
2346,
5738,
26564,
1006,
310,
330,
4858,
16292,
72169,
5809,
42,
579,
3362,
17571,
1043,
36,
43194,
28905,
2810,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_fix_sort_query_parameters() {
let sort = fix_sort_query_parameters("_geoPoint(12, 13):asc");
assert_eq!(sort, vec!["_geoPoint(12,13):asc".to_string()]);
let sort = fix_sort_query_parameters("doggo:asc,_geoPoint(12.45,13.56):desc");
assert_eq!(
sort,
vec![
"doggo:asc".to_string(),
"_geoPoint(12.45,13.56):desc".to_string(),
]
);
let sort = fix_sort_query_parameters(
"doggo:asc , _geoPoint(12.45, 13.56, 2590352):desc , catto:desc",
);
assert_eq!(
sort,
vec![
"doggo:asc".to_string(),
"_geoPoint(12.45,13.56,2590352):desc".to_string(),
"catto:desc".to_string(),
]
);
let sort = fix_sort_query_parameters("doggo:asc , _geoPoint(1, 2), catto:desc");
assert_eq!(
sort,
vec![
"doggo:asc".to_string(),
"_geoPoint(1,2),catto:desc".to_string(),
]
);
} | rust_cleaned_test_functions.jsonl/53316 | {
"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,
36060,
18435,
5738,
18263,
368,
341,
286,
1077,
3378,
284,
5046,
18435,
5738,
18263,
16975,
13052,
2609,
7,
16,
17,
11,
220,
16,
18,
1648,
5061,
797,
286,
2060,
10714,
10297,
6860,
11,
7486,
0,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_includes() {
assert_eq!(document(json!({})).includes(), Vec::<String>::new());
assert_eq!(document(json!({ "include": []})).includes(), Vec::<String>::new());
assert_eq!(
document(json!({ "include": [ "foo.cml", "bar.cml" ]})).includes(),
vec!["foo.cml", "bar.cml"]
);
} | rust_cleaned_test_functions.jsonl/34909 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 172
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1243,
7396,
368,
341,
286,
2060,
10714,
10297,
6062,
9304,
0,
2306,
92,
4579,
14526,
1507,
11312,
27638,
703,
6831,
931,
1423,
286,
2060,
10714,
10297,
6062,
9304,
0,
2306,
330,
997,
788,
3056,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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() {
let mut t = init();
t.least_cost_method();
t.replenish();
assert_eq!(t.check(), Some((3, 3, -2)));
} | rust_cleaned_test_functions.jsonl/26613 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 75
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7200,
368,
341,
262,
1077,
5206,
259,
284,
2930,
543,
262,
259,
30502,
559,
15890,
9032,
543,
262,
259,
1327,
86535,
812,
543,
262,
2060,
10714,
10297,
83,
9093,
1507,
4329,
1188,
18,
11,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_node_multiple_rollback_merge() {
let mut cluster = new_node_cluster(0, 3);
configure_for_merge(&mut cluster);
cluster.cfg.raft_store.right_derive_when_split = true;
cluster.cfg.raft_store.merge_check_tick_interval = ReadableDuration::millis(20);
let pd_client = Arc::clone(&cluster.pd_client);
pd_client.disable_default_operator();
cluster.run();
for i in 0..10 {
cluster.must_put(format!("k{}", i).as_bytes(), b"v");
}
let region = pd_client.get_region(b"k1").unwrap();
cluster.must_split(®ion, b"k2");
let left = pd_client.get_region(b"k1").unwrap();
let right = pd_client.get_region(b"k2").unwrap();
let left_peer_1 = find_peer(&left, 1).unwrap().to_owned();
cluster.must_transfer_leader(left.get_id(), left_peer_1.clone());
assert_eq!(left_peer_1.get_id(), 1001);
let on_schedule_merge_fp = "on_schedule_merge";
let on_check_merge_not_1001_fp = "on_check_merge_not_1001";
let mut right_peer_1_id = find_peer(&right, 1).unwrap().get_id();
for i in 0..3 {
fail::cfg(on_schedule_merge_fp, "return()").unwrap();
cluster.must_try_merge(left.get_id(), right.get_id());
// Change the epoch of target region and the merge will fail
pd_client.must_remove_peer(right.get_id(), new_peer(1, right_peer_1_id));
right_peer_1_id += 100;
pd_client.must_add_peer(right.get_id(), new_peer(1, right_peer_1_id));
// Only the source leader is running `on_check_merge`
fail::cfg(on_check_merge_not_1001_fp, "return()").unwrap();
fail::remove(on_schedule_merge_fp);
// So wait for the leader propose rollback merge if possible
sleep_ms(100);
// Check if the source region is still in merging mode.
let mut l_r = pd_client.get_region(b"k1").unwrap();
let req = new_request(
l_r.get_id(),
l_r.take_region_epoch(),
vec![new_put_cf_cmd(
"default",
format!("k1{}", i).as_bytes(),
b"vv",
)],
false,
);
let resp = cluster
.call_command_on_leader(req, Duration::from_millis(100))
.unwrap();
if !resp
.get_header()
.get_error()
.get_message()
.contains("merging mode")
{
panic!("resp {:?} does not contain merging mode error", resp);
}
fail::remove(on_check_merge_not_1001_fp);
// Write data for waiting the merge to rollback easily
cluster.must_put(format!("k1{}", i).as_bytes(), b"vv");
// Make sure source region is not merged to target region
assert_eq!(pd_client.get_region(b"k1").unwrap().get_id(), left.get_id());
}
} | rust_cleaned_test_functions.jsonl/56288 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1321
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5084,
45233,
62,
33559,
20888,
368,
341,
262,
1077,
5206,
10652,
284,
501,
5084,
28441,
7,
15,
11,
220,
18,
317,
262,
14411,
5478,
20888,
2099,
6984,
10652,
317,
262,
10652,
30481,
13,
2944,
148... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_compute_comm_d_empty() {
let comm_d = compute_comm_d(SectorSize(2048), &[]).unwrap();
assert_eq!(
comm_d,
[
252, 126, 146, 130, 150, 229, 22, 250, 173, 233, 134, 178, 143, 146, 212, 74, 79,
36, 185, 53, 72, 82, 35, 55, 106, 121, 144, 39, 188, 24, 248, 51
]
);
let comm_d = compute_comm_d(SectorSize(128), &[]).unwrap();
assert_eq!(
hex::encode(&comm_d),
"3731bb99ac689f66eef5973e4a94da188f4ddcae580724fc6f3fd60dfd488333",
);
} | rust_cleaned_test_functions.jsonl/55451 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 344
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
57028,
25149,
814,
15124,
368,
341,
286,
1077,
1063,
814,
284,
12564,
25149,
814,
3759,
1256,
1695,
7,
17,
15,
19,
23,
701,
609,
1294,
568,
15454,
543,
286,
2060,
10714,
33673,
310,
1063,
814,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_str_to_type() {
assert_eq!(
tvm_str_to_type("float24").unwrap().1,
DataType::float(24, 1)
);
assert_eq!(
tvm_str_to_type("uint111x44").unwrap().1,
DataType::uint(111, 44)
);
} | rust_cleaned_test_functions.jsonl/56100 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 172
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2895,
2346,
1819,
368,
341,
286,
2060,
10714,
33673,
310,
259,
7338,
2895,
2346,
1819,
445,
3649,
17,
19,
1827,
15454,
1005,
16,
345,
310,
33172,
486,
3649,
7,
17,
19,
11,
220,
16,
340,
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_try_from_patch_balloon() {
let (mut sender, receiver) = UnixStream::pair().unwrap();
let mut connection = HttpConnection::new(receiver);
let body = "{ \"amount_mib\": 1 }";
sender
.write_all(http_request("PATCH", "/balloon", Some(&body)).as_bytes())
.unwrap();
assert!(connection.try_read().is_ok());
let req = connection.pop_parsed_request().unwrap();
assert!(ParsedRequest::try_from_request(&req).is_ok());
let body = "{ \
\"stats_polling_interval_s\": 1 \
}";
sender
.write_all(http_request("PATCH", "/balloon/statistics", Some(&body)).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/106590 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 414
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
53283,
5673,
39643,
56441,
31335,
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,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_groupnum() {
assert_eq!("12,379,821,234", group_num("12379821234"));
assert_eq!("21,234", group_num("21234"));
assert_eq!("821,234", group_num("821234"));
assert_eq!("1,821,234", group_num("1821234"));
assert_eq!("1,234", group_num("1234"));
assert_eq!("234", group_num("234"));
assert_eq!("24", group_num("24"));
assert_eq!("4", group_num("4"));
assert_eq!("", group_num(""));
} | rust_cleaned_test_functions.jsonl/36715 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 209
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6288,
2413,
368,
341,
262,
2060,
10714,
17223,
16,
17,
11,
18,
22,
24,
11,
23,
17,
16,
11,
17,
18,
19,
497,
1874,
4273,
445,
16,
17,
18,
22,
24,
23,
17,
16,
17,
18,
19,
4010,
262,
2060... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_empty_string_output() {
let mut processor = processor_stub();
processor.json = r#"["",""]"#.to_owned();
processor.program = ".[]".to_owned();
processor.pretty_output = true;
let context = Context::new().unwrap();
let output = processor.run(&context).unwrap();
assert!(output.is_none())
} | rust_cleaned_test_functions.jsonl/90635 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 191
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15124,
3904,
7645,
368,
341,
310,
1077,
5206,
17654,
284,
17654,
62781,
543,
310,
17654,
4323,
284,
435,
55543,
1183,
2198,
1341,
57676,
13,
983,
51973,
543,
310,
17654,
45082,
284,
5933,
1294,
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_lazy_groupby_sort() {
let df = df! {
"a" => ["a", "b", "a", "b", "b", "c"],
"b" => [1, 2, 3, 4, 5, 6]
}
.unwrap();
let out = df
.clone()
.lazy()
.groupby(vec![col("a")])
.agg(vec![col("b").sort(false).first()])
.collect()
.unwrap()
.sort("a", false)
.unwrap();
assert_eq!(
Vec::from(out.column("b_first").unwrap().i32().unwrap()),
[Some(1), Some(2), Some(6)]
);
let out = df
.lazy()
.groupby(vec![col("a")])
.agg(vec![col("b").sort(false).last()])
.collect()
.unwrap()
.sort("a", false)
.unwrap();
assert_eq!(
Vec::from(out.column("b_last").unwrap().i32().unwrap()),
[Some(3), Some(5), Some(6)]
);
} | rust_cleaned_test_functions.jsonl/22387 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 474
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
49646,
6288,
1694,
18435,
368,
341,
262,
1077,
6764,
284,
6764,
0,
341,
286,
330,
64,
1,
589,
4383,
64,
497,
330,
65,
497,
330,
64,
497,
330,
65,
497,
330,
65,
497,
330,
66,
8097,
286,
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_init_stream() {
use crate::stream::Streamer;
use ark_bls12_381::Fr;
use ark_std::UniformRand;
for _ in 0..100 {
let rng = &mut ark_std::test_rng();
let size = 1000;
let mut a = Vec::new();
for _ in 0..size {
a.push(Fr::rand(rng));
}
let x = Fr::rand(rng);
let y = Fr::rand(rng);
let mut ans = Vec::new();
for i in 0..size {
ans.push(y - (x * a[size - 1 - i]));
}
a.reverse();
let st = InitStream::new(a.as_slice(), x, y);
for (i, res) in st.stream().enumerate() {
assert_eq!(res, ans[i]);
}
}
} | rust_cleaned_test_functions.jsonl/88511 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 378
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6137,
12673,
368,
341,
262,
990,
17717,
486,
4027,
486,
80063,
280,
262,
990,
55217,
880,
4730,
16,
17,
62,
18,
23,
16,
486,
22560,
280,
262,
990,
55217,
15656,
486,
20152,
56124,
401,
262,
36... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_rand_encrypt_decrypt() {
let mut rand_seed: [u8; 1072] = [0; 1072];
rand::random(&mut rand_seed).unwrap();
let mut key = [0u8; 32];
key.copy_from_slice(&rand_seed[..32]);
let mut iv: [u8; 12] = [0; 12];
iv.clone_from_slice(&rand_seed[32..44]);
let msg = rand_seed[44..1068].to_vec();
let ciphertext = encrypt_with_nonce(&msg, &key, Some(iv)).unwrap();
assert_eq!(msg, decrypt(&ciphertext, &key).unwrap());
} | rust_cleaned_test_functions.jsonl/45466 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 248
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
33864,
66593,
80764,
368,
341,
286,
1077,
5206,
10382,
33809,
25,
508,
84,
23,
26,
220,
16,
15,
22,
17,
60,
284,
508,
15,
26,
220,
16,
15,
22,
17,
935,
286,
10382,
486,
11463,
2099,
6984,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_example_1() {
let contents = get_contents("src/days/day_16/example_01.txt");
let packets = parse_packets(contents);
assert_eq!(packets.len(), 4);
assert!(packets.get(&1).unwrap().length_type == LengthType::Subpackets(1, 1));
assert!(packets.get(&2).unwrap().length_type == LengthType::Subpackets(1, 1));
assert!(packets.get(&3).unwrap().length_type == LengthType::Bits(11, 11));
assert!(packets.get(&4).unwrap().type_id == TypeId::Literal);
assert!(packets.get(&4).unwrap().value == Some(15));
} | rust_cleaned_test_functions.jsonl/905 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 259
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39304,
62,
16,
368,
341,
286,
1077,
8794,
284,
633,
16682,
445,
3548,
3446,
942,
44739,
62,
16,
21,
65182,
62,
15,
16,
3909,
797,
286,
1077,
27035,
284,
4715,
63569,
46964,
317,
286,
2060,
107... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_as_array(){
let json_value = from_str("[1, 2, 3]").unwrap();
let json_array = json_value.as_array();
let expected_length = 3;
assert!(json_array.is_some() && json_array.unwrap().len() == expected_length);
} | rust_cleaned_test_functions.jsonl/6568 | {
"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,
11898,
3858,
3032,
286,
1077,
2951,
3142,
284,
504,
2895,
10937,
16,
11,
220,
17,
11,
220,
18,
44891,
15454,
543,
286,
1077,
2951,
3858,
284,
2951,
3142,
5357,
3858,
543,
286,
1077,
3601,
5118,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_get_fdt_addr() {
let regions = arch_memory_regions(layout::FDT_MAX_SIZE - 0x1000);
let mem = vm_memory::test_utils::create_anon_guest_memory(®ions, false)
.expect("Cannot initialize memory");
assert_eq!(get_fdt_addr(&mem), layout::DRAM_MEM_START);
let regions = arch_memory_regions(layout::FDT_MAX_SIZE);
let mem = vm_memory::test_utils::create_anon_guest_memory(®ions, false)
.expect("Cannot initialize memory");
assert_eq!(get_fdt_addr(&mem), layout::DRAM_MEM_START);
let regions = arch_memory_regions(layout::FDT_MAX_SIZE + 0x1000);
let mem = vm_memory::test_utils::create_anon_guest_memory(®ions, false)
.expect("Cannot initialize memory");
assert_eq!(get_fdt_addr(&mem), 0x1000 + layout::DRAM_MEM_START);
} | rust_cleaned_test_functions.jsonl/75934 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 381
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
761,
8047,
7387,
368,
341,
286,
1077,
13604,
284,
5325,
19195,
58035,
19930,
486,
37,
10599,
6806,
4098,
481,
220,
15,
87,
16,
15,
15,
15,
317,
286,
1077,
1833,
284,
10995,
19195,
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... | 1 |
#[test]
fn test_convert_sparse_merkle_proof_malformed_leaf() {
let sibling0 = b"0".test_only_hash().to_vec();
let mut compressed_proof = crate::proto::proof::SparseMerkleProof::new();
compressed_proof.set_leaf(vec![1, 2, 3]);
compressed_proof.mut_bitmap().push(0b1000_0000);
compressed_proof.mut_non_default_siblings().push(sibling0);
assert!(SparseMerkleProof::from_proto(compressed_proof).is_err());
} | rust_cleaned_test_functions.jsonl/103134 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 175
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34910,
71123,
717,
16754,
273,
86757,
717,
278,
10155,
38909,
368,
341,
262,
1077,
44223,
15,
284,
293,
1,
15,
3263,
1944,
18410,
8950,
1005,
983,
13251,
1428,
262,
1077,
5206,
30649,
86757,
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_node_merge_prerequisites_check() {
let mut cluster = new_node_cluster(0, 3);
configure_for_merge(&mut cluster);
let pd_client = Arc::clone(&cluster.pd_client);
cluster.run();
cluster.must_put(b"k1", b"v1");
cluster.must_put(b"k3", b"v3");
let region = pd_client.get_region(b"k1").unwrap();
cluster.must_split(®ion, b"k2");
let left = pd_client.get_region(b"k1").unwrap();
let right = pd_client.get_region(b"k2").unwrap();
let left_on_store1 = find_peer(&left, 1).unwrap().to_owned();
cluster.must_transfer_leader(left.get_id(), left_on_store1);
let right_on_store1 = find_peer(&right, 1).unwrap().to_owned();
cluster.must_transfer_leader(right.get_id(), right_on_store1);
cluster.add_send_filter(CloneFilterFactory(RegionPacketFilter::new(
left.get_id(),
3,
)));
cluster.must_split(&left, b"k11");
let res = cluster.try_merge(left.get_id(), right.get_id());
// log gap contains admin entries.
assert!(res.get_header().has_error(), "{:?}", res);
cluster.clear_send_filters();
cluster.must_put(b"k22", b"v22");
must_get_equal(&cluster.get_engine(3), b"k22", b"v22");
cluster.add_send_filter(CloneFilterFactory(RegionPacketFilter::new(
right.get_id(),
3,
)));
// It doesn't matter if the index and term is correct.
let compact_log = new_compact_log_request(100, 10);
let req = new_admin_request(right.get_id(), right.get_region_epoch(), compact_log);
debug!("requesting {:?}", req);
let res = cluster
.call_command_on_leader(req, Duration::from_secs(3))
.unwrap();
assert!(res.get_header().has_error(), "{:?}", res);
let res = cluster.try_merge(right.get_id(), left.get_id());
// log gap contains admin entries.
assert!(res.get_header().has_error(), "{:?}", res);
cluster.clear_send_filters();
cluster.must_put(b"k23", b"v23");
must_get_equal(&cluster.get_engine(3), b"k23", b"v23");
cluster.add_send_filter(CloneFilterFactory(RegionPacketFilter::new(
right.get_id(),
3,
)));
let mut large_bytes = vec![b'k', b'3'];
// 3M
large_bytes.extend(repeat(b'0').take(1024 * 1024 * 3));
cluster.must_put(&large_bytes, &large_bytes);
cluster.must_put(&large_bytes, &large_bytes);
let res = cluster.try_merge(right.get_id(), left.get_id());
// log gap contains admin entries.
assert!(res.get_header().has_error(), "{:?}", res);
cluster.clear_send_filters();
cluster.must_put(b"k24", b"v24");
must_get_equal(&cluster.get_engine(3), b"k24", b"v24");
} | rust_cleaned_test_functions.jsonl/27245 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1125
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5084,
20888,
5294,
82301,
7200,
368,
341,
262,
1077,
5206,
10652,
284,
501,
5084,
28441,
7,
15,
11,
220,
18,
317,
262,
14411,
5478,
20888,
2099,
6984,
10652,
317,
262,
1077,
7744,
8179,
284,
196... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_rgb() -> Result<(), Box<dyn std::error::Error>> {
use crate::parser::code_span;
use crate::parser::formalargs::call_args;
use crate::value::Rgba;
let scope = ScopeRef::new_global(Default::default());
assert_eq!(
FUNCTIONS.get(&name!(rgb)).unwrap().call(
scope.clone(),
&call_args(code_span(b"(17, 0, 225)"))?
.1
.evaluate(scope, true)?
)?,
Value::Color(Rgba::from_rgb(17, 0, 225).into(), None)
);
Ok(())
} | rust_cleaned_test_functions.jsonl/108178 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 270
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
37407,
368,
1464,
5714,
68843,
8261,
92846,
1460,
486,
841,
486,
1454,
2452,
341,
262,
990,
17717,
486,
9657,
486,
1851,
37382,
280,
262,
990,
17717,
486,
9657,
486,
627,
278,
2116,
486,
6659,
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... | 4 |
#[test]
fn test_sample() {
let min_val = 1;
let max_val = 100;
let mut r = thread_rng();
let vals = (min_val..max_val).collect::<Vec<int>>();
let small_sample = sample(&mut r, vals.iter(), 5);
let large_sample = sample(&mut r, vals.iter(), vals.len() + 5);
assert_eq!(small_sample.len(), 5);
assert_eq!(large_sample.len(), vals.len());
assert!(small_sample.iter().all(|e| {
**e >= min_val && **e <= max_val
}));
} | rust_cleaned_test_functions.jsonl/76082 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 258
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17491,
368,
341,
286,
1077,
1308,
6189,
284,
220,
16,
280,
286,
1077,
1932,
6189,
284,
220,
16,
15,
15,
401,
286,
1077,
5206,
435,
284,
4516,
66849,
543,
286,
1077,
28356,
284,
320,
1065,
6189... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_noatime_does_not_update_ofile_atime() {
// NOTE: Not all environments support tracking access time. If this
// is not working and the systems that pass it simply don't update file access time.
let fname = "this-ofile-exists-noatime.txt";
assert_fixture_exists!(&fname);
let (fix, mut ucmd) = at_and_ucmd!();
ucmd.args(&["status=none", "oflag=noatime", of!(fname)]);
let pre_atime = fix.metadata(fname).accessed().unwrap();
ucmd.pipe_in("").run().no_stderr().success();
let post_atime = fix.metadata(fname).accessed().unwrap();
assert_eq!(pre_atime, post_atime);
} | rust_cleaned_test_functions.jsonl/59387 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 253
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6536,
266,
545,
96374,
7913,
8882,
3575,
457,
3752,
545,
368,
341,
262,
442,
16743,
25,
2806,
678,
21737,
1824,
14849,
2615,
882,
13,
1416,
419,
7213,
262,
442,
374,
537,
3238,
323,
279,
5942,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_prehashed() {
let mut rng = Hc128Rng::seed_from_u64(0);
let pair = Ed25519Pair::from_random(&mut rng);
let data = YoloStruct {
a: 12345,
b: vec![0x31, 0x33, 0x70],
c: 54321,
};
let mut hasher = PseudoMerlin(Sha512::default());
data.append_to_transcript(b"test", &mut hasher);
let sig = pair
.try_sign_digest(hasher.inner)
.expect("Failed to sign digest");
let mut hasher = PseudoMerlin(Sha512::default());
data.append_to_transcript(b"test", &mut hasher);
pair.verify_digest(hasher.inner, &sig)
.expect("Failed to validate digest signature");
} | rust_cleaned_test_functions.jsonl/55260 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 372
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10442,
95647,
368,
341,
286,
1077,
5206,
28422,
284,
472,
66,
16,
17,
23,
49,
968,
486,
22602,
5673,
7300,
21,
19,
7,
15,
317,
286,
1077,
6716,
284,
3199,
17,
20,
20,
16,
24,
12443,
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... | 1 |
#[test]
fn test_write_string_to_writer() {
let mut cursor = Cursor::new(vec![]);
let position = cursor.position();
DictionaryBuilder::write_string_to_writer(&mut cursor, "").unwrap();
assert_eq!(0, cursor.get_ref()[0]);
assert_eq!(position + 1, cursor.position());
let position = cursor.position() as usize;
DictionaryBuilder::write_string_to_writer(&mut cursor, "あ𠮟").unwrap();
assert_eq!(3, cursor.get_ref()[position as usize]);
assert_eq!(
"あ",
UTF_16LE
.decode(&cursor.get_ref()[position + 1..position + 3])
.0
);
assert_eq!(
55362,
u16::from_le_bytes([
cursor.get_ref()[position + 3],
cursor.get_ref()[position + 4],
])
);
assert_eq!(
57247,
u16::from_le_bytes([
cursor.get_ref()[position + 5],
cursor.get_ref()[position + 6],
])
);
let position = cursor.position() as usize;
let long_str = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
let len = long_str.chars().count();
DictionaryBuilder::write_string_to_writer(&mut cursor, long_str).unwrap();
assert_eq!((len >> 8) | 0x80, cursor.get_ref()[position] as usize);
assert_eq!(len & 0xff, cursor.get_ref()[position + 1] as usize);
assert_eq!(position + 2 + 2 * len, cursor.position() as usize);
} | rust_cleaned_test_functions.jsonl/134079 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 634
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9165,
3904,
2346,
28908,
368,
341,
262,
1077,
5206,
8128,
284,
28067,
486,
931,
25592,
0,
1294,
626,
262,
1077,
2309,
284,
8128,
6187,
543,
262,
10466,
3297,
486,
4934,
3904,
2346,
28908,
2099,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_link() {
assert_eq!(
parse_line("LINK -1\nok"),
Ok(("ok", Instruction::Link(Target::Literal(-1))))
);
assert_eq!(
parse_line("LINK #NRV\nok"),
Ok((
"ok",
Instruction::Link(Target::Register(String::from("#nrv")))
))
);
assert_eq!(
parse_line("LINK 999 \nok"),
Ok(("ok", Instruction::Link(Target::Literal(999))))
);
} | rust_cleaned_test_functions.jsonl/989 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 299
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7233,
368,
341,
286,
2060,
10714,
33673,
310,
4715,
6528,
445,
35956,
481,
16,
1699,
562,
4461,
310,
7622,
30873,
562,
497,
29051,
486,
3939,
80613,
486,
17350,
4080,
16,
22788,
286,
1439,
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_hash_many_avx2() {
if !crate::avx2_detected() {
return;
}
test_hash_many_fn(crate::ffi::x86::blake3_hash_many_avx2);
} | rust_cleaned_test_functions.jsonl/79365 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 90
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8950,
22101,
26173,
87,
17,
368,
341,
262,
421,
753,
61711,
486,
402,
87,
17,
98876,
368,
341,
286,
470,
280,
262,
456,
262,
1273,
8950,
22101,
15246,
54907,
486,
53799,
486,
87,
23,
21,
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
] | 2 |
#[test]
fn test_clone() {
let lua_string = String::new("burritos").unwrap();
let clone = lua_string.clone();
assert_eq!(clone.as_c_str(), lua_string.as_c_str());
// read after copy
assert_eq!(lua_string.size, 8);
let cstring = CString::try_from(lua_string).unwrap();
assert_eq!(&cstring.into_string().unwrap(), "burritos");
} | rust_cleaned_test_functions.jsonl/101287 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 184
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
54742,
368,
341,
286,
1077,
20357,
3904,
284,
923,
486,
931,
445,
11240,
94012,
1827,
15454,
543,
286,
1077,
14715,
284,
20357,
3904,
15997,
543,
286,
2060,
10714,
10297,
19982,
5357,
666,
2895,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_expect_document() {
let test = |value| expect_document(&mut json_token_iter(value).peekable()).unwrap();
assert_eq!(Document::Null, test(b"null"));
assert_eq!(Document::Bool(true), test(b"true"));
assert_eq!(Document::Number(Number::Float(3.2)), test(b"3.2"));
assert_eq!(Document::String("Foo\nBar".into()), test(b"\"Foo\\nBar\""));
assert_eq!(Document::Array(Vec::new()), test(b"[]"));
assert_eq!(Document::Object(HashMap::new()), test(b"{}"));
assert_eq!(
Document::Array(vec![
Document::Number(Number::PosInt(1)),
Document::Bool(false),
Document::String("s".into()),
Document::Array(Vec::new()),
Document::Object(HashMap::new()),
]),
test(b"[1,false,\"s\",[],{}]")
);
assert_eq!(
Document::Object(
vec![
("num".to_string(), Document::Number(Number::PosInt(1))),
("bool".to_string(), Document::Bool(true)),
("string".to_string(), Document::String("s".into())),
(
"array".to_string(),
Document::Array(vec![
Document::Object(
vec![("foo".to_string(), Document::Bool(false))]
.into_iter()
.collect(),
),
Document::Object(
vec![("bar".to_string(), Document::Bool(true))]
.into_iter()
.collect(),
),
])
),
(
"nested".to_string(),
Document::Object(
vec![("test".to_string(), Document::Null),]
.into_iter()
.collect()
)
),
]
.into_iter()
.collect()
),
test(
br#"
{ "num": 1,
"bool": true,
"string": "s",
"array":
[{ "foo": false },
{ "bar": true }],
"nested": { "test": null } }
"#
)
);
} | rust_cleaned_test_functions.jsonl/58158 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1686
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
68918,
26231,
368,
341,
286,
1077,
1273,
284,
760,
957,
91,
1720,
26231,
2099,
6984,
2951,
6458,
11723,
3679,
568,
29107,
480,
6011,
15454,
543,
286,
2060,
10714,
10297,
7524,
486,
3280,
11,
1273,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_cast1() {
let mut octants = octree::Octants::default();
let points = vec![
Point3i::new(0, 0, 0),
Point3i::new(0, 11, 11),
Point3i::new(15, 15, 15),
];
// let points = [
let root =
octree::create_octants_bottom_up(&mut octants, &points).expect("failed to create octree");
println!("root: {:?}", root);
for o in octants.octants.iter() {
println!("{:?}", o);
}
cast_ray(
&octants,
root,
Vec3::new(20f32, 12f32, 12f32),
Vec3::new(-20f32, -0.001f32, -0.001f32),
);
// cast_ray(
// cast_ray(
// cast_ray(
} | rust_cleaned_test_functions.jsonl/66112 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 491
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5303,
16,
368,
341,
262,
1077,
5206,
18491,
1783,
284,
18491,
765,
486,
18053,
1783,
486,
2258,
1428,
80719,
41693,
14808,
262,
1077,
3501,
284,
7486,
90515,
286,
5126,
18,
72,
486,
931,
7,
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_get_txs_to_rebroadcast_reorged() {
let responder = init_responder(MockedServerQuery::Regular);
let current_height = 100;
let user_id = get_random_user_id();
responder
.dbm
.lock()
.unwrap()
.store_user(user_id, &UserInfo::new(21, 42))
.unwrap();
// Transactions are flagged to be rebroadcast when they've been in mempool for longer than CONFIRMATIONS_BEFORE_RETRY
let mut txs = HashMap::new();
for i in 0..10 {
// Add the appointment to the db so FK rules are satisfied
let (uuid, appointment) = generate_dummy_appointment_with_user(user_id, None);
responder
.dbm
.lock()
.unwrap()
.store_appointment(uuid, &appointment)
.unwrap();
let breach = get_random_breach();
responder.add_tracker(
uuid,
breach.clone(),
user_id,
ConfirmationStatus::ConfirmedIn(current_height),
);
// Since we are adding trackers using add_trackers we'll need to manually change the state of the transaction
// Not doing should will trigger an error in the dbm since reorged transactions are not stored in the db.
if i % 2 == 0 {
responder
.trackers
.lock()
.unwrap()
.get_mut(&uuid)
.unwrap()
.status = ConfirmationStatus::ReorgedOut;
// Here the dispute is also included
txs.insert(
uuid,
(breach.penalty_tx.clone(), Some(breach.dispute_tx.clone())),
);
}
}
assert_eq!(responder.get_txs_to_rebroadcast(current_height), txs)
} | rust_cleaned_test_functions.jsonl/55480 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1085
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
17805,
82,
2346,
1288,
54162,
1288,
1775,
291,
368,
341,
1789,
286,
1077,
64034,
284,
2930,
4918,
20328,
66436,
291,
5475,
2859,
486,
30404,
317,
286,
1077,
1482,
9561,
284,
220,
16,
15,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_compatible_wpa3_rsne() {
let mut a_rsne = make_rsne(Some(cipher::CCMP_128), vec![cipher::CCMP_128], vec![akm::SAE]);
a_rsne.rsn_capabilities = Some(
RsnCapabilities(0)
.with_mgmt_frame_protection_cap(true)
.with_mgmt_frame_protection_req(true),
);
assert_eq!(is_rsn_compatible(&a_rsne), false);
assert_eq!(is_wpa3_rsn_compatible(&a_rsne), true);
} | rust_cleaned_test_functions.jsonl/113749 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 246
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2965,
37079,
1670,
6595,
18,
47115,
811,
368,
341,
286,
1077,
5206,
264,
47115,
811,
284,
1281,
47115,
811,
65405,
1337,
10558,
486,
3706,
5781,
62,
16,
17,
23,
701,
7486,
20703,
67586,
486,
370... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_del_errors() {
check_load_save_common_errors("DEL");
Tester::default().run("DEL").expect_err("DEL requires a filename").check();
check_stmt_err("Entry not found", r#"DEL "missing-file""#);
Tester::default()
.write_file("mismatched-extension.bat", "")
.run(r#"DEL "mismatched-extension""#)
.expect_err("Entry not found")
.expect_file("MEMORY:/mismatched-extension.bat", "")
.check();
} | rust_cleaned_test_functions.jsonl/112738 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 248
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18029,
20196,
368,
341,
286,
1779,
12411,
15376,
21107,
20196,
445,
38332,
3071,
286,
76816,
486,
2258,
1005,
6108,
445,
38332,
1827,
17119,
9266,
445,
38332,
7460,
264,
3899,
1827,
2028,
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_padded_frame_copy() {
let (frame, fi) = create_frame();
let tile = frame.as_tile();
let sbo = TileSuperBlockOffset(SuperBlockOffset { x: 1, y: 2 });
let pad = 2;
let padded_frame = cdef_sb_padded_frame_copy(&fi, sbo, 1, 1, &tile, pad);
assert_eq!(padded_frame.planes[0].cfg.width, 64);
assert_eq!(padded_frame.planes[0].cfg.height, 64);
let po = PlaneOffset { x: 62, y: 126 };
let in_luma_slice = frame.planes[0].slice(po);
let out_luma_region =
padded_frame.planes[0].region(Area::StartingAt { x: -2, y: -2 });
// values from the input frame
for row in 0..68 {
for col in 0..68 {
let in_pixel = in_luma_slice[row][col];
let out_pixel = out_luma_region[row][col];
assert_eq!(in_pixel, out_pixel);
}
}
} | rust_cleaned_test_functions.jsonl/77072 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 393
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
16828,
8929,
16096,
368,
341,
262,
1077,
320,
6763,
11,
9136,
8,
284,
1855,
8929,
543,
262,
1077,
10023,
284,
4034,
5357,
29844,
543,
1066,
262,
1077,
274,
749,
284,
20744,
19284,
4713,
644... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_longest_common_prefix() {
assert_eq!(
Z2::longest_common_prefix(&[u64::max_value(), u64::max_value() - 15]).prefix,
u64::max_value() - 15
);
assert_eq!(Z2::longest_common_prefix(&[15, 13]).prefix, 12);
assert_eq!(Z2::longest_common_prefix(&[12, 15]).prefix, 12);
} | rust_cleaned_test_functions.jsonl/85854 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 248
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17799,
477,
21107,
13974,
368,
341,
286,
2060,
10714,
33673,
310,
1863,
17,
486,
4825,
477,
21107,
13974,
2099,
58,
84,
21,
19,
486,
2810,
3142,
1507,
575,
21,
19,
486,
2810,
3142,
368,
481,
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_parse_simple_query() {
let did: DID = DID::parse("did:example:123456?query=true").unwrap();
assert_eq!(did.method(), "example");
assert_eq!(did.method_id(), "123456");
assert_eq!(did.path(), "");
assert_eq!(did.query(), Some("query=true"));
assert_eq!(did.fragment(), None);
} | rust_cleaned_test_functions.jsonl/93405 | {
"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,
21039,
30015,
5738,
368,
341,
220,
1077,
1521,
25,
59119,
284,
59119,
486,
6400,
445,
22920,
25,
8687,
25,
16,
17,
18,
19,
20,
21,
30,
1631,
11265,
1827,
15454,
543,
220,
2060,
10714,
10297,
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_switch_threshold_uses_gossip_votes() {
solana_logger::setup_with_default(RUST_LOG_FILTER);
let total_stake = 100;
// Minimum stake needed to generate a switching proof
let minimum_switch_stake = (SWITCH_FORK_THRESHOLD as f64 * total_stake as f64) as u64;
// Make the heavier stake insufficient for switching so tha the lighter validator
// cannot switch without seeing a vote from the dead/failure_stake validator.
let heavier_stake = minimum_switch_stake;
let lighter_stake = heavier_stake - 1;
let failures_stake = total_stake - heavier_stake - lighter_stake;
let partitions: &[&[(usize, usize)]] = &[
&[(heavier_stake as usize, 8)],
&[(lighter_stake as usize, 8)],
];
#[derive(Default)]
struct PartitionContext {
heaviest_validator_key: Pubkey,
lighter_validator_key: Pubkey,
dead_validator_info: Option<ClusterValidatorInfo>,
}
let on_partition_start = |_cluster: &mut LocalCluster,
validator_keys: &[Pubkey],
mut dead_validator_infos: Vec<ClusterValidatorInfo>,
context: &mut PartitionContext| {
assert_eq!(dead_validator_infos.len(), 1);
context.dead_validator_info = Some(dead_validator_infos.pop().unwrap());
// stake == `failures_stake`
context.heaviest_validator_key = validator_keys[1];
context.lighter_validator_key = validator_keys[2];
};
let on_before_partition_resolved = |_: &mut LocalCluster, _: &mut PartitionContext| {};
// Check that new roots were set after the partition resolves (gives time
// for lockouts built during partition to resolve and gives validators an opportunity
// to try and switch forks)
let on_partition_resolved = |cluster: &mut LocalCluster, context: &mut PartitionContext| {
let lighter_validator_ledger_path = cluster.ledger_path(&context.lighter_validator_key);
let heavier_validator_ledger_path = cluster.ledger_path(&context.heaviest_validator_key);
let (lighter_validator_latest_vote, _) = last_vote_in_tower(
&lighter_validator_ledger_path,
&context.lighter_validator_key,
)
.unwrap();
info!(
"Lighter validator's latest vote is for slot {}",
lighter_validator_latest_vote
);
// Lighter partition should stop voting after detecting the heavier partition and try
// to switch. Loop until we see a greater vote by the heavier validator than the last
// vote made by the lighter validator on the lighter fork.
let mut heavier_validator_latest_vote;
let mut heavier_validator_latest_vote_hash;
let heavier_blockstore = open_blockstore(&heavier_validator_ledger_path);
loop {
let (sanity_check_lighter_validator_latest_vote, _) = last_vote_in_tower(
&lighter_validator_ledger_path,
&context.lighter_validator_key,
)
.unwrap();
// called after a propagation time where blocks from the other fork should have
// finished propagating
assert_eq!(
sanity_check_lighter_validator_latest_vote,
lighter_validator_latest_vote
);
let (new_heavier_validator_latest_vote, new_heavier_validator_latest_vote_hash) =
last_vote_in_tower(
&heavier_validator_ledger_path,
&context.heaviest_validator_key,
)
.unwrap();
heavier_validator_latest_vote = new_heavier_validator_latest_vote;
heavier_validator_latest_vote_hash = new_heavier_validator_latest_vote_hash;
// Latest vote for each validator should be on different forks
assert_ne!(lighter_validator_latest_vote, heavier_validator_latest_vote);
if heavier_validator_latest_vote > lighter_validator_latest_vote {
let heavier_ancestors: HashSet<Slot> =
AncestorIterator::new(heavier_validator_latest_vote, &heavier_blockstore)
.collect();
assert!(!heavier_ancestors.contains(&lighter_validator_latest_vote));
break;
}
}
info!("Checking to make sure lighter validator doesn't switch");
let mut latest_slot = lighter_validator_latest_vote;
// Number of chances the validator had to switch votes but didn't
let mut total_voting_opportunities = 0;
while total_voting_opportunities <= 5 {
let (new_latest_slot, latest_slot_ancestors) =
find_latest_replayed_slot_from_ledger(&lighter_validator_ledger_path, latest_slot);
latest_slot = new_latest_slot;
// Ensure `latest_slot` is on the other fork
if latest_slot_ancestors.contains(&heavier_validator_latest_vote) {
let tower = restore_tower(
&lighter_validator_ledger_path,
&context.lighter_validator_key,
)
.unwrap();
// Check that there was an opportunity to vote
if !tower.is_locked_out(latest_slot, &latest_slot_ancestors) {
// Ensure the lighter blockstore has not voted again
let new_lighter_validator_latest_vote = tower.last_voted_slot().unwrap();
assert_eq!(
new_lighter_validator_latest_vote,
lighter_validator_latest_vote
);
info!(
"Incrementing voting opportunities: {}",
total_voting_opportunities
);
total_voting_opportunities += 1;
} else {
info!(
"Tower still locked out, can't vote for slot: {}",
latest_slot
);
}
} else if latest_slot > heavier_validator_latest_vote {
warn!(
"validator is still generating blocks on its own fork, last processed slot: {}",
latest_slot
);
}
sleep(Duration::from_millis(50));
}
// Make a vote from the killed validator for slot `heavier_validator_latest_vote` in gossip
info!(
"Simulate vote for slot: {} from dead validator",
heavier_validator_latest_vote
);
let vote_keypair = &context
.dead_validator_info
.as_ref()
.unwrap()
.info
.voting_keypair
.clone();
let node_keypair = &context
.dead_validator_info
.as_ref()
.unwrap()
.info
.keypair
.clone();
cluster_tests::submit_vote_to_cluster_gossip(
node_keypair,
vote_keypair,
heavier_validator_latest_vote,
heavier_validator_latest_vote_hash,
// never makes it into a block
Hash::new_unique(),
cluster
.get_contact_info(&context.heaviest_validator_key)
.unwrap()
.gossip,
&SocketAddrSpace::Unspecified,
)
.unwrap();
loop {
// Wait for the lighter validator to switch to the heavier fork
let (new_lighter_validator_latest_vote, _) = last_vote_in_tower(
&lighter_validator_ledger_path,
&context.lighter_validator_key,
)
.unwrap();
if new_lighter_validator_latest_vote != lighter_validator_latest_vote {
info!(
"Lighter validator switched forks at slot: {}",
new_lighter_validator_latest_vote
);
let (heavier_validator_latest_vote, _) = last_vote_in_tower(
&heavier_validator_ledger_path,
&context.heaviest_validator_key,
)
.unwrap();
let (smaller, larger) =
if new_lighter_validator_latest_vote > heavier_validator_latest_vote {
(
heavier_validator_latest_vote,
new_lighter_validator_latest_vote,
)
} else {
(
new_lighter_validator_latest_vote,
heavier_validator_latest_vote,
)
};
// Check the new vote is on the same fork as the heaviest fork
let heavier_blockstore = open_blockstore(&heavier_validator_ledger_path);
let larger_slot_ancestors: HashSet<Slot> =
AncestorIterator::new(larger, &heavier_blockstore)
.chain(std::iter::once(larger))
.collect();
assert!(larger_slot_ancestors.contains(&smaller));
break;
} else {
sleep(Duration::from_millis(50));
}
}
};
let ticks_per_slot = 8;
run_kill_partition_switch_threshold(
&[&[(failures_stake as usize, 0)]],
partitions,
// Partition long enough such that the first vote made by validator with
None,
Some(ticks_per_slot),
PartitionContext::default(),
on_partition_start,
on_before_partition_resolved,
on_partition_resolved,
);
} | rust_cleaned_test_functions.jsonl/31759 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 4939
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
27652,
21858,
62,
4776,
1889,
41473,
65116,
368,
341,
262,
2048,
3362,
27413,
486,
15188,
6615,
9993,
2785,
8553,
8419,
23728,
317,
262,
1077,
2790,
1261,
726,
284,
220,
16,
15,
15,
401,
262,
44... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
#[test]
fn test_to_ascii() {
let test_cases = vec![
("abc", "abc"),
("abc ", "abc "),
("abc\x01", "abc\\0x01"),
("abc\\x01", "abc\\\\x01"),
("\raaaa\tbbb\nccc", "\\raaaa\\tbbb\\nccc"),
("\nabc\u{7f}", "\\nabc\\0x7f"),
("\u{0}abc", "\\0x00abc"),
(
"\u{01}abc\u{02}abcefd901\u{03}",
"\\0x01abc\\0x02abcefd901\\0x03",
),
];
test_cases.iter().for_each(|(value, result)| {
assert_eq!(
to_quoted_ascii(http_token(value)),
format!("\"{}\"", result)
);
});
let bytes = [0x81, b'a', b'b', b'c', 0x82, b'0', b'1', b'2', 0x83];
assert_eq!(
to_quoted_ascii(&bytes),
format!("\"{}\"", "\\0x81abc\\0x82012\\0x83")
);
} | rust_cleaned_test_functions.jsonl/88825 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 583
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2346,
50238,
368,
341,
286,
1077,
1273,
41427,
284,
7486,
90515,
310,
3489,
13683,
497,
330,
13683,
4461,
310,
3489,
13683,
3670,
330,
13683,
84119,
310,
3489,
13683,
3462,
15,
16,
497,
330,
13683... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_split_ext() {
assert_eq!(get_last("file.e", '.'), ("file", "e"));
assert_eq!(get_last("file.beans.e", '.'), ("file.beans", "e"));
} | rust_cleaned_test_functions.jsonl/15090 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 93
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17052,
9927,
368,
972,
286,
2060,
10714,
10297,
455,
12195,
445,
1192,
1734,
497,
24361,
701,
3489,
1192,
497,
330,
68,
15397,
286,
2060,
10714,
10297,
455,
12195,
445,
1192,
14196,
1734,
497,
243... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_purge_triggered_by_compact() {
let dir = tempfile::Builder::new()
.prefix("test_purge_triggered_by_compact")
.tempdir()
.unwrap();
let cfg = Config {
dir: dir.path().to_str().unwrap().to_owned(),
target_file_size: ReadableSize::kb(5),
purge_threshold: ReadableSize::kb(150),
..Default::default()
};
let engine = RaftLogEngine::open(cfg).unwrap();
let data = vec![b'x'; 1024];
for index in 0..100 {
engine.append(1, index, index + 1, Some(&data));
}
let count = engine.compact_to(1, 100);
assert_eq!(count, 100);
assert!(!engine
.purge_manager
.needs_rewrite_log_files(LogQueue::Append));
// Append more logs to make total size greater than `purge_threshold`.
for index in 100..250 {
engine.append(1, index, index + 1, Some(&data));
}
// GC first 101 log entries.
assert_eq!(engine.compact_to(1, 101), 1);
// Needs to purge because the total size is greater than `purge_threshold`.
assert!(engine
.purge_manager
.needs_rewrite_log_files(LogQueue::Append));
let old_min_file_seq = engine.file_span(LogQueue::Append).0;
let will_force_compact = engine.purge_expired_files().unwrap();
let new_min_file_seq = engine.file_span(LogQueue::Append).0;
// Some entries are rewritten.
assert!(new_min_file_seq > old_min_file_seq);
// No regions need to be force compacted because the threshold is not reached.
assert!(will_force_compact.is_empty());
assert!(engine.get_entry::<Entry>(1, 101).unwrap().is_some());
assert_eq!(engine.compact_to(1, 102), 1);
// Needs to purge because the total size is greater than `purge_threshold`.
assert!(engine
.purge_manager
.needs_rewrite_log_files(LogQueue::Append));
let will_force_compact = engine.purge_expired_files().unwrap();
// The region needs to be force compacted because the threshold is reached.
assert!(!will_force_compact.is_empty());
assert_eq!(will_force_compact[0], 1);
} | rust_cleaned_test_functions.jsonl/91525 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1060
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
39823,
78678,
3710,
18177,
531,
368,
341,
286,
1077,
5419,
284,
54819,
486,
3297,
486,
931,
741,
310,
659,
11849,
445,
1944,
620,
39823,
78678,
3710,
18177,
531,
1138,
310,
659,
3888,
3741,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_query_conversion_no_pagination() {
let sr = meta_search::SearchRequest {
key: Some("key".to_string()),
resource_type: Some(meta_search::ResourceType::Dataset as i32),
conditions: vec![meta_search::FieldQuery {
key: "fancy_key".to_owned(),
query: "\"fancy_value\"".to_owned(),
}],
pagination: None,
};
let spec: SearchSpec = sr.try_into().unwrap();
let query = spec.filter;
let expected = mongodb::bson::doc! {
"resource_type" : meta_search::ResourceType::Dataset as i32,
"key": "key",
"metadata.fancy_key" : "fancy_value"
};
assert_eq!(super::DEFAULT_PAGE, spec.page);
assert_eq!(super::DEFAULT_PAGE_SIZE, spec.page_size);
assert_eq!(expected, query);
} | rust_cleaned_test_functions.jsonl/113859 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 443
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5738,
64132,
6536,
82231,
368,
341,
286,
1077,
18962,
284,
8823,
10716,
486,
5890,
1900,
341,
310,
1376,
25,
4329,
445,
792,
3263,
983,
3904,
14702,
310,
5101,
1819,
25,
4329,
45119,
10716,
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_format_java_version_zulu() {
let java_8 = "OpenJDK 64-Bit Server VM (25.222-b10) for linux-amd64 JRE (Zulu 8.40.0.25-CA-linux64) (1.8.0_222-b10), built on Jul 11 2019 11:36:39 by \"zulu_re\" with gcc 4.4.7 20120313 (Red Hat 4.4.7-3)";
let java_11 = "OpenJDK 64-Bit Server VM (11.0.4+11-LTS) for linux-amd64 JRE (Zulu11.33+15-CA) (11.0.4+11-LTS), built on Jul 11 2019 21:37:17 by \"zulu_re\" with gcc 4.9.2 20150212 (Red Hat 4.9.2-6)";
assert_eq!(
format_java_version(java_8, "v${raw}"),
Some("v1.8.0".to_string())
);
assert_eq!(
format_java_version(java_11, "v${raw}"),
Some("v11.0.4".to_string())
);
} | rust_cleaned_test_functions.jsonl/113479 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 386
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8955,
77323,
9438,
6415,
24411,
368,
341,
286,
1077,
1642,
62,
23,
284,
330,
5002,
41,
18301,
220,
21,
19,
7671,
275,
8422,
17792,
320,
17,
20,
13,
17,
17,
17,
1455,
16,
15,
8,
369,
36245,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_populate_pool() {
assert_eq!(populate_pool(&[3, 1, 2]), [0, 0, 0, 1, 2, 2]);
} | rust_cleaned_test_functions.jsonl/115262 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 63
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17061,
6334,
15709,
368,
341,
286,
2060,
10714,
10297,
47721,
15709,
2099,
58,
18,
11,
220,
16,
11,
220,
17,
9719,
508,
15,
11,
220,
15,
11,
220,
15,
11,
220,
16,
11,
220,
17,
11,
220,
17,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_primary_expression_literal() {
assert_parse_success!(
primary_expression(false, false),
"null",
Expression::Literal {
value: Literal::NullLiteral(NullLiteral),
loc: Some(((1, 0), (1, 4)).into())
}
);
assert_parse_success!(
primary_expression(false, false),
"true",
Expression::Literal {
value: Literal::BooleanLiteral(BooleanLiteral(true)),
loc: Some(((1, 0), (1, 4)).into())
}
);
assert_parse_success!(
primary_expression(false, false),
"false",
Expression::Literal {
value: Literal::BooleanLiteral(BooleanLiteral(false)),
loc: Some(((1, 0), (1, 5)).into())
}
);
assert_parse_success!(
primary_expression(false, false),
"123.e1",
Expression::Literal {
value: Literal::NumericLiteral(NumericLiteral(1230f64)),
loc: Some(((1, 0), (1, 6)).into())
}
);
assert_parse_success!(
primary_expression(false, false),
"'abc'",
Expression::Literal {
value: Literal::StringLiteral(StringLiteral("abc".to_string())),
loc: Some(((1, 0), (1, 5)).into()),
}
);
assert_parse_success!(
primary_expression(false, false),
"/\\a/",
Expression::Literal {
value: Literal::RegExpLiteral(RegExpLiteral {
pattern: "\\a".to_string(),
flags: String::new(),
}),
loc: Some(((1, 0), (1, 4)).into())
}
);
} | rust_cleaned_test_functions.jsonl/66470 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 843
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
45314,
28068,
34100,
368,
341,
262,
2060,
21039,
18632,
33673,
286,
6028,
28068,
3576,
11,
895,
1326,
286,
330,
2921,
756,
286,
16378,
486,
17350,
341,
310,
897,
25,
49674,
486,
3280,
17350,
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_parse_font_weight() {
assert_eq!(parse_font_weight("lighter"), Some(100));
assert_eq!(parse_font_weight("normal"), Some(400));
assert_eq!(parse_font_weight("bold"), Some(700));
assert_eq!(parse_font_weight("bolder"), Some(700));
assert_eq!(parse_font_weight("100"), Some(100));
assert_eq!(parse_font_weight("100.1"), Some(100));
assert_eq!(parse_font_weight("120"), Some(120));
assert_eq!(parse_font_weight("0.01"), None);
assert_eq!(parse_font_weight("-20"), None);
assert_eq!(parse_font_weight("whatever"), None);
} | rust_cleaned_test_functions.jsonl/15470 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 214
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
17451,
15876,
368,
341,
220,
2060,
10714,
10297,
6400,
17451,
15876,
445,
4145,
261,
3975,
4329,
7,
16,
15,
15,
1106,
220,
2060,
10714,
10297,
6400,
17451,
15876,
445,
8252,
3975,
4329,
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_fields() -> Result<()> {
#[bitcoin_code(crate = "crate")]
#[derive(PartialEq, Debug, BitcoinCode)]
struct TestPack {
a: u8,
b: u16,
c: u32,
d: u64,
e: i8,
f: i16,
g: i32,
h: i64,
}
#[bitcoin_code(crate = "crate")]
#[derive(PartialEq, Debug, BitcoinCode)]
struct Test {
int: u32,
seq: Vec<ByteArray>,
relay: bool,
pack: TestPack,
}
let sample = Test {
int: 1,
seq: vec![b"\x77".into(), b"\x99".into()],
relay: true,
pack: TestPack {
a: 1,
b: 2,
c: 3,
d: 4,
e: 5,
f: 6,
g: 7,
h: 8,
},
};
let sample_encoded = hex::decode(format!(
"01000000\
0201770199\
01\
010200030000000400000000000000\
050600070000000800000000000000",
))?;
assert_eq!(sample, Test::deser(sample.ser())?);
assert_eq!(sample, Test::deser(sample_encoded.as_slice().into())?);
assert_eq!(sample.ser().as_slice(), sample_encoded.as_slice());
Ok(())
} | rust_cleaned_test_functions.jsonl/77194 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 868
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12132,
368,
1464,
5714,
71698,
341,
286,
11506,
83910,
4136,
54907,
284,
330,
61711,
5422,
286,
11506,
27098,
5304,
20894,
27312,
11,
11091,
11,
13127,
2078,
5563,
286,
2036,
3393,
30684,
341,
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... | 4 |
#[test]
fn test_intersection_skip() {
let left = VecDocSet::from(vec![0, 1, 2, 4]);
let right = VecDocSet::from(vec![2, 5]);
let mut intersection = Intersection::new(vec![left, right]);
assert_eq!(intersection.seek(2), 2);
assert_eq!(intersection.doc(), 2);
} | rust_cleaned_test_functions.jsonl/13258 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 143
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
82558,
44830,
368,
341,
286,
1077,
2115,
284,
11312,
9550,
1649,
486,
1499,
25592,
20703,
15,
11,
220,
16,
11,
220,
17,
11,
220,
19,
2558,
286,
1077,
1290,
284,
11312,
9550,
1649,
486,
1499,
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_debug() {
assert_eq!(
format!("{:?}", Scalar::zero()),
"Scalar(0x0000000000000000000000000000000000000000000000000000000000000000)"
);
assert_eq!(
format!("{:?}", Scalar::one()),
"Scalar(0x0000000000000000000000000000000000000000000000000000000000000001)"
);
assert_eq!(
format!("{:?}", R2),
"Scalar(0x1824b159acc5056f998c4fefecbc4ff55884b7fa0003480200000001fffffffe)"
);
} | rust_cleaned_test_functions.jsonl/54650 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 264
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15446,
368,
341,
286,
2060,
10714,
33673,
310,
3561,
88928,
25,
52652,
35176,
486,
14154,
14702,
310,
330,
20639,
7,
15,
87,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_tcpds_query_8() {
assert_eq!(parse_sql("
SELECT s_store_name,
Sum(ss_net_profit)
FROM store_sales,
date_dim,
store,
(SELECT ca_zip
FROM (SELECT Substr(ca_zip, 1, 5) ca_zip
FROM customer_address
WHERE Substr(ca_zip, 1, 5) IN ( '67436', '26121', '38443',
'63157',
'68856', '19485', '86425',
'26741',
'70991', '60899', '63573',
'47556',
'56193', '93314', '87827',
'62017',
'85067', '95390', '48091',
'43224',
'22322', '86959', '68519',
'14308',
'46501', '81131', '34056',
'61991',
'19896', '87804', '65774',
'92564' )
INTERSECT
SELECT ca_zip
FROM (SELECT Substr(ca_zip, 1, 5) ca_zip,
Count(*) cnt
FROM customer_address,
customer
WHERE ca_address_sk = c_current_addr_sk
AND c_preferred_cust_flag = 'Y'
GROUP BY ca_zip
HAVING Count(*) > 10)A1)A2) V1
WHERE ss_store_sk = s_store_sk
AND ss_sold_date_sk = d_date_sk
AND d_qoy = 2
AND d_year = 2000
AND ( Substr(s_zip, 1, 2) = Substr(V1.ca_zip, 1, 2) )
GROUP BY s_store_name
ORDER BY s_store_name
LIMIT 100;
").unwrap(), QueryMetadata {
inputs: vec![
String::from("customer"),
String::from("customer_address"),
String::from("date_dim"),
String::from("store"),
String::from("store_sales"),
],
output: None
})
} | rust_cleaned_test_functions.jsonl/50107 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2001
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
45562,
5356,
5738,
62,
23,
368,
341,
262,
2060,
10714,
10297,
6400,
18063,
70576,
286,
19094,
274,
14809,
1269,
345,
5180,
8116,
30678,
19722,
72042,
340,
286,
4295,
256,
3553,
47067,
345,
2290,
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_inflation_and_slashing_with_activating_and_deactivating_stake() {
// some really boring delegation and stake_history setup
let (delegated_stake, mut stake, stake_history) = {
let cluster_stake = 1_000;
let delegated_stake = 700;
let stake = Delegation {
stake: delegated_stake,
activation_epoch: 0,
deactivation_epoch: 4,
..Delegation::default()
};
let mut stake_history = StakeHistory::default();
stake_history.add(
0,
StakeHistoryEntry {
effective: cluster_stake,
activating: delegated_stake,
..StakeHistoryEntry::default()
},
);
let newly_effective_at_epoch1 = (cluster_stake as f64 * 0.25) as u64;
assert_eq!(newly_effective_at_epoch1, 250);
stake_history.add(
1,
StakeHistoryEntry {
effective: cluster_stake + newly_effective_at_epoch1,
activating: delegated_stake - newly_effective_at_epoch1,
..StakeHistoryEntry::default()
},
);
let newly_effective_at_epoch2 =
((cluster_stake + newly_effective_at_epoch1) as f64 * 0.25) as u64;
assert_eq!(newly_effective_at_epoch2, 312);
stake_history.add(
2,
StakeHistoryEntry {
effective: cluster_stake
+ newly_effective_at_epoch1
+ newly_effective_at_epoch2,
activating: delegated_stake
- newly_effective_at_epoch1
- newly_effective_at_epoch2,
..StakeHistoryEntry::default()
},
);
stake_history.add(
3,
StakeHistoryEntry {
effective: cluster_stake + delegated_stake,
..StakeHistoryEntry::default()
},
);
stake_history.add(
4,
StakeHistoryEntry {
effective: cluster_stake + delegated_stake,
deactivating: delegated_stake,
..StakeHistoryEntry::default()
},
);
let newly_not_effective_stake_at_epoch5 =
((cluster_stake + delegated_stake) as f64 * 0.25) as u64;
assert_eq!(newly_not_effective_stake_at_epoch5, 425);
stake_history.add(
5,
StakeHistoryEntry {
effective: cluster_stake + delegated_stake
- newly_not_effective_stake_at_epoch5,
deactivating: delegated_stake - newly_not_effective_stake_at_epoch5,
..StakeHistoryEntry::default()
},
);
(delegated_stake, stake, stake_history)
};
// helper closures
let calculate_each_staking_status = |stake: &Delegation, epoch_count: usize| -> Vec<_> {
(0..epoch_count)
.map(|epoch| {
stake.stake_activating_and_deactivating(epoch as u64, Some(&stake_history))
})
.collect::<Vec<_>>()
};
let adjust_staking_status = |rate: f64, status: &[StakeActivationStatus]| {
status
.iter()
.map(|entry| StakeActivationStatus {
effective: (entry.effective as f64 * rate) as u64,
activating: (entry.activating as f64 * rate) as u64,
deactivating: (entry.deactivating as f64 * rate) as u64,
})
.collect::<Vec<_>>()
};
let expected_staking_status_transition = vec![
StakeActivationStatus::with_effective_and_activating(0, 700),
StakeActivationStatus::with_effective_and_activating(250, 450),
StakeActivationStatus::with_effective_and_activating(562, 138),
StakeActivationStatus::with_effective(700),
StakeActivationStatus::with_deactivating(700),
StakeActivationStatus::with_deactivating(275),
StakeActivationStatus::default(),
];
let expected_staking_status_transition_base = vec![
StakeActivationStatus::with_effective_and_activating(0, 700),
StakeActivationStatus::with_effective_and_activating(250, 450),
StakeActivationStatus::with_effective_and_activating(562, 138 + 1), // +1 is needed for rounding
StakeActivationStatus::with_effective(700),
StakeActivationStatus::with_deactivating(700),
StakeActivationStatus::with_deactivating(275 + 1), // +1 is needed for rounding
StakeActivationStatus::default(),
];
assert_eq!(
expected_staking_status_transition,
calculate_each_staking_status(&stake, expected_staking_status_transition.len())
);
let rate = 1.10;
stake.stake = (delegated_stake as f64 * rate) as u64;
let expected_staking_status_transition =
adjust_staking_status(rate, &expected_staking_status_transition_base);
assert_eq!(
expected_staking_status_transition,
calculate_each_staking_status(&stake, expected_staking_status_transition_base.len()),
);
let rate = 0.5;
stake.stake = (delegated_stake as f64 * rate) as u64;
let expected_staking_status_transition =
adjust_staking_status(rate, &expected_staking_status_transition_base);
assert_eq!(
expected_staking_status_transition,
calculate_each_staking_status(&stake, expected_staking_status_transition_base.len()),
);
} | rust_cleaned_test_functions.jsonl/15287 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 3162
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1243,
64149,
8378,
11886,
19049,
6615,
71684,
1095,
8378,
2259,
8859,
1095,
1261,
726,
368,
341,
286,
442,
1045,
2167,
27759,
45261,
323,
18279,
19802,
6505,
198,
286,
1077,
320,
450,
1937,
657,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_iter() {
let keys = vec![1, 2, 3];
let sgs = SgSet::<_, 3>::from_iter(keys.into_iter());
let mut sgs_iter = sgs.iter();
assert_eq!(sgs_iter.next(), Some(&1));
assert_eq!(sgs_iter.next(), Some(&2));
assert_eq!(sgs_iter.next(), Some(&3));
assert_eq!(sgs_iter.next(), None);
} | rust_cleaned_test_functions.jsonl/68242 | {
"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,
2602,
11723,
368,
341,
262,
1077,
6894,
284,
7486,
20703,
16,
11,
220,
17,
11,
220,
18,
935,
262,
1077,
274,
5857,
284,
328,
70,
1649,
27638,
6878,
220,
18,
6831,
1499,
11723,
36131,
39860,
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_rans_decode_with_order_0() -> io::Result<()> {
let expected = b"noodles";
let data = vec![
0x00, 0x25, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x64, 0x82, 0x49, 0x65, 0x00,
0x82, 0x49, 0x6c, 0x82, 0x49, 0x6e, 0x82, 0x49, 0x6f, 0x00, 0x84, 0x92, 0x73, 0x82,
0x49, 0x00, 0xe2, 0x06, 0x83, 0x18, 0x74, 0x7b, 0x41, 0x0c, 0x2b, 0xa9, 0x41, 0x0c,
0x25, 0x31, 0x80, 0x03,
];
let mut reader = &data[..];
let actual = rans_decode(&mut reader)?;
assert_eq!(actual, expected);
Ok(())
} | rust_cleaned_test_functions.jsonl/121773 | {
"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,
1710,
596,
15227,
6615,
7869,
62,
15,
368,
1464,
6399,
486,
2077,
71698,
341,
286,
1077,
3601,
284,
293,
1,
77,
97121,
3302,
286,
1077,
821,
284,
7486,
90515,
310,
220,
15,
87,
15,
15,
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... | 2 |
#[test]
fn test_adding_jobs_to_runner() {
let some_job = SomeJob;
let another_job = AnotherJob;
let runner = Runner::new()
.add(Box::new(some_job))
.add(Box::new(another_job));
assert_eq!(runner.jobs_to_run(), 2);
} | rust_cleaned_test_functions.jsonl/45095 | {
"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,
2891,
287,
37247,
2346,
54828,
368,
341,
286,
1077,
1045,
20298,
284,
4329,
12245,
280,
286,
1077,
2441,
20298,
284,
13293,
12245,
401,
286,
1077,
22259,
284,
44946,
486,
931,
741,
310,
659,
718,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_estimate_equal() {
let mut p = build_problem();
p.k = 1;
let s = find_optimal_sequence(&p);
let n = new_node(&p);
let e = estimate(&n, &s, &p);
assert_eq!(e, 3f64);
} | rust_cleaned_test_functions.jsonl/69079 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 160
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
78718,
11478,
368,
341,
310,
1077,
5206,
281,
284,
1936,
60139,
543,
310,
281,
5202,
284,
220,
16,
280,
310,
1077,
274,
284,
1477,
15032,
2861,
23735,
2099,
79,
317,
310,
1077,
308,
284,
501,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.