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_parse() {
let (map, bbox) = parse3(CONTENT, 0);
assert_eq!(map, exp_map());
assert_eq!(bbox, BBox3 { x_rg: (0, 3), y_rg: (0, 3), z_rg: (0, 1) })
} | rust_cleaned_test_functions.jsonl/34497 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 113
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
368,
341,
286,
1077,
320,
2186,
11,
29749,
8,
284,
4715,
18,
98747,
1825,
11,
220,
15,
317,
286,
2060,
10714,
10297,
2186,
11,
1343,
5376,
1423,
286,
2060,
10714,
10297,
58456,
11,
425,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_assign_from_string_override() {
let mut env = Env::new();
env.insert("FOO".to_string(), EnvKey::Single("whiskeyBAR".to_string()));
let env = assign_from_string(env, "FOO=milkBAR").unwrap();
assert_eq!(
env.get(&"FOO".to_string()).unwrap(),
&EnvKey::Single("milkBAR".to_string()),
);
} | rust_cleaned_test_functions.jsonl/131139 | {
"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,
20688,
5673,
3904,
48576,
368,
341,
286,
1077,
5206,
6105,
284,
37039,
486,
931,
543,
286,
6105,
7030,
445,
3788,
46,
3263,
983,
3904,
1507,
37039,
1592,
486,
10888,
445,
1312,
46090,
33065,
3263,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_module_gen_code() {
let module = Module {
package: "mechiru.type".into(),
include: true,
imported_by: {
let mut set = HashSet::new();
set.insert("mechiru.type".into());
set
},
children: HashMap::new(),
};
assert_eq!(
module.gen_code(),
r###"#[cfg(any(feature = "mechiru-type",))]
include_proto!("mechiru.r#type");
"###
);
} | rust_cleaned_test_functions.jsonl/8980 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 296
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10750,
16322,
4136,
368,
341,
286,
1077,
4688,
284,
13711,
341,
310,
6328,
25,
330,
2660,
331,
404,
84,
4852,
3263,
18122,
3148,
310,
2924,
25,
830,
345,
310,
24928,
3710,
25,
341,
394,
1077,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_execute_details_timing_acumulate() {
// Acumulate an erroring transaction
let program_id = Pubkey::new_unique();
let us = 100;
let compute_units_consumed = 1;
let mut execute_details_timings = ExecuteDetailsTimings::default();
// Construct another separate instance of ExecuteDetailsTimings with non default fields
let mut other_execute_details_timings =
construct_execute_timings_with_program(&program_id, us, compute_units_consumed);
let account_count = 1;
let data_size_changed = 1;
other_execute_details_timings.serialize_us = us;
other_execute_details_timings.create_vm_us = us;
other_execute_details_timings.execute_us = us;
other_execute_details_timings.deserialize_us = us;
other_execute_details_timings.changed_account_count = account_count;
other_execute_details_timings.total_account_count = account_count;
other_execute_details_timings.total_data_size = data_size_changed;
other_execute_details_timings.data_size_changed = data_size_changed;
// Accumulate the other instance into the current instance
execute_details_timings.accumulate(&other_execute_details_timings);
// Check that the two instances are equal
assert_eq!(execute_details_timings, other_execute_details_timings);
} | rust_cleaned_test_functions.jsonl/34971 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 534
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
44329,
13260,
70973,
14718,
372,
6334,
368,
341,
286,
442,
6381,
372,
6334,
458,
1465,
287,
7745,
198,
286,
1077,
2025,
842,
284,
22611,
792,
486,
931,
21218,
543,
286,
1077,
601,
284,
220,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_sorted_storages_none() {
let result = SortedStorages::new_with_slots([].iter().zip([].iter()), None, None);
assert_eq!(result.range, Range::default());
assert_eq!(result.slot_count, 0);
assert_eq!(result.storages.len(), 0);
assert!(result.get(0).is_none());
} | rust_cleaned_test_functions.jsonl/23713 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 152
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
41277,
1261,
269,
1134,
31488,
368,
341,
286,
1077,
1102,
284,
52688,
623,
269,
1134,
486,
931,
6615,
54161,
2561,
936,
2015,
1005,
9964,
2561,
936,
2015,
11858,
2240,
11,
2240,
317,
286,
2060,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_fill_struct_fields_enum() {
check_fix(
r#"
enum Expr {
Bin { lhs: Box<Expr>, rhs: Box<Expr> }
}
impl Expr {
fn new_bin(lhs: Box<Expr>, rhs: Box<Expr>) -> Expr {
Expr::Bin {$0 }
}
}
"#,
r#"
enum Expr {
Bin { lhs: Box<Expr>, rhs: Box<Expr> }
}
impl Expr {
fn new_bin(lhs: Box<Expr>, rhs: Box<Expr>) -> Expr {
Expr::Bin { lhs, rhs }
}
}
"#,
);
} | rust_cleaned_test_functions.jsonl/15149 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 268
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
30728,
15126,
12132,
31054,
368,
341,
286,
1779,
36060,
1006,
310,
435,
2,
698,
9018,
28819,
341,
262,
29344,
314,
22505,
25,
8261,
27,
16041,
8066,
12916,
25,
8261,
27,
16041,
29,
456,
630,
638... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_get_empty_body() {
let req = Request::with_connector(
Get, Url::parse("http://example.dom").unwrap(), &mut MockConnector
).unwrap();
let bytes = run_request(req);
let s = from_utf8(&bytes[..]).unwrap();
assert_no_body(s);
} | rust_cleaned_test_functions.jsonl/2064 | {
"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,
3062,
15124,
14114,
368,
341,
286,
1077,
4232,
284,
6145,
486,
4197,
76393,
1006,
310,
2126,
11,
22840,
486,
6400,
445,
1254,
1110,
8687,
21435,
1827,
15454,
1507,
609,
6984,
14563,
35954,
198,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_address_book_basics() {
let config = ConfigBuilder::new()
.with_dns_seeds(vec![String::from("127.0.0.1")])
.build();
let mut book = AddressBook::new(&config, make_logger()).expect("invalid init");
let addr = SocketAddr::from_str("127.0.0.1:8333").expect("invalid address");
assert!(book.known_addresses.is_empty());
let result = book.pop();
let err = result.unwrap_err();
assert!(
matches!(err, AddressBookError::AddressesDepleted),
"expected to see a depleted error"
);
book.add(addr);
let result = book.pop();
assert!(result.is_ok());
let entry = result.unwrap();
assert_eq!(entry.addr(), &addr);
} | rust_cleaned_test_functions.jsonl/10127 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 376
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6744,
26421,
880,
67981,
368,
341,
286,
1077,
2193,
284,
5532,
3297,
486,
931,
741,
310,
659,
4197,
71125,
3453,
6767,
25592,
20703,
703,
486,
1499,
445,
16,
17,
22,
13,
15,
13,
15,
13,
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_buf_writer() {
let mut buf = [0 as u8; 9];
{
let mut writer = Cursor::new(&mut buf[..]);
assert_eq!(writer.position(), 0);
assert_eq!(writer.write(&[0]).unwrap(), 1);
assert_eq!(writer.position(), 1);
assert_eq!(writer.write(&[1, 2, 3]).unwrap(), 3);
assert_eq!(writer.write(&[4, 5, 6, 7]).unwrap(), 4);
assert_eq!(writer.position(), 8);
assert_eq!(writer.write(&[]).unwrap(), 0);
assert_eq!(writer.position(), 8);
assert_eq!(writer.write(&[8, 9]).unwrap(), 1);
assert_eq!(writer.write(&[10]).unwrap(), 0);
}
let b: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7, 8];
assert_eq!(buf, b);
} | rust_cleaned_test_functions.jsonl/4221 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 417
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10363,
28908,
368,
341,
286,
1077,
5206,
6607,
284,
508,
15,
438,
575,
23,
26,
220,
24,
935,
286,
341,
310,
1077,
5206,
6916,
284,
28067,
486,
931,
2099,
6984,
6607,
95874,
2558,
310,
2060,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_arg() {
macro_rules! test_arg {
($val:expr, $t:ty) => {{
let val1: $t = $val;
let arg = super::arg(val1.clone());
let val2: $t = serde_json::from_str(arg.get()).expect(stringify!($val));
assert_eq!(val1, val2, "failed test for {}", stringify!($val));
}}
}
test_arg!(true, bool);
test_arg!(42, u8);
test_arg!(42, usize);
test_arg!(42, isize);
test_arg!(vec![42, 35], Vec<u8>);
test_arg!(String::from("test"), String);
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
struct Test {
v: String,
}
test_arg!(Test { v: String::from("test"), }, Test);
} | rust_cleaned_test_functions.jsonl/112191 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 431
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6057,
368,
341,
286,
18072,
21407,
0,
1273,
6057,
341,
310,
1711,
831,
96011,
11,
400,
83,
25,
1881,
8,
589,
80505,
394,
1077,
1044,
16,
25,
400,
83,
284,
400,
831,
280,
394,
1077,
1392,
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_eval_offset() {
let cie = make_test_cie();
let ctx = UnwindContext::new();
let mut expected = ctx.clone();
expected
.set_register_rule(
Register(2),
RegisterRule::Offset(3 * cie.data_alignment_factor),
)
.unwrap();
let instructions = [(
Ok(false),
CallFrameInstruction::Offset {
register: Register(2),
factored_offset: 3,
},
)];
assert_eval(ctx, expected, cie, None, instructions);
} | rust_cleaned_test_functions.jsonl/9356 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 326
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21296,
6917,
368,
341,
286,
1077,
272,
645,
284,
1281,
4452,
666,
645,
543,
286,
1077,
5635,
284,
1230,
19154,
1972,
486,
931,
543,
286,
1077,
5206,
3601,
284,
5635,
15997,
543,
286,
3601,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_voted_for() {
let mut store = MemLog::new();
assert_eq!(None, store.voted_for().unwrap());
let id = ServerId::from(0);
store.set_voted_for(id).unwrap();
assert_eq!(Some(id), store.voted_for().unwrap());
} | rust_cleaned_test_functions.jsonl/5431 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 134
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2273,
9253,
5478,
368,
341,
286,
1077,
5206,
3553,
284,
13550,
2201,
486,
931,
543,
286,
2060,
10714,
10297,
4064,
11,
3553,
3133,
9253,
5478,
1005,
15454,
1423,
286,
1077,
877,
284,
8422,
764,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_commutativity() {
let mut graph_1 = setup_basic_graph();
let mut graph_2 = setup_basic_graph();
let mut graph_3 = setup_basic_graph();
let first = Instant::now();
let second = Instant::now();
let third = Instant::now();
graph_1.add_vertex(4, Some(first));
graph_1.add_edge(4, 3, Some(second));
graph_1.add_edge(4, 2, Some(third));
assert!(graph_1.contains_vertex(4));
assert_eq!(graph_1.get_connected_vertices(4), [2, 3]);
graph_2.add_edge(4, 3, Some(second));
graph_2.add_edge(4, 2, Some(third));
graph_2.add_vertex(4, Some(first));
assert!(graph_2.contains_vertex(4));
assert_eq!(graph_2.get_connected_vertices(4), [2, 3]);
graph_3.add_edge(4, 2, Some(third));
graph_3.add_edge(4, 3, Some(second));
graph_3.add_vertex(4, Some(first));
assert!(graph_3.contains_vertex(4));
assert_eq!(graph_3.get_connected_vertices(4), [2, 3]);
} | rust_cleaned_test_functions.jsonl/40990 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 419
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2965,
6984,
43415,
368,
341,
262,
1077,
5206,
4771,
62,
16,
284,
6505,
34729,
14738,
543,
262,
1077,
5206,
4771,
62,
17,
284,
6505,
34729,
14738,
543,
262,
1077,
5206,
4771,
62,
18,
284,
6505,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_withdraw_stake_invalid_state() {
let stake_pubkey = Pubkey::new_rand();
let total_lamports = 100;
let stake_account = Account::new_ref_data_with_space(
total_lamports,
&StakeState::RewardsPool,
std::mem::size_of::<StakeState>(),
&id(),
)
.expect("stake_account");
let to = Pubkey::new_rand();
let to_account = Account::new_ref(1, 0, &system_program::id());
let to_keyed_account = KeyedAccount::new(&to, false, &to_account);
let stake_keyed_account = KeyedAccount::new(&stake_pubkey, true, &stake_account);
let signers = vec![stake_pubkey].into_iter().collect();
assert_eq!(
stake_keyed_account.withdraw(
total_lamports,
&to_keyed_account,
&Clock::default(),
&StakeHistory::default(),
&signers,
),
Err(InstructionError::InvalidAccountData)
);
} | rust_cleaned_test_functions.jsonl/39444 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 528
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6615,
7633,
1261,
726,
31433,
4387,
368,
341,
286,
1077,
18279,
34014,
792,
284,
22611,
792,
486,
931,
33864,
543,
286,
1077,
2790,
907,
309,
3394,
284,
220,
16,
15,
15,
280,
286,
1077,
18279,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_wait_mode_ready() {
let mut rfm = setup_rfm(Vec::new(), vec![0b0_0000000, 0]);
rfm.wait_mode_ready().err().unwrap();
assert_eq!(rfm.spi.rx_buffer[0], Registers::IrqFlags1.read());
rfm.spi.tx_buffer[0] = 0b1_0000000;
rfm.spi.rx_buffer.clear();
rfm.wait_mode_ready().ok().unwrap();
assert_eq!(rfm.spi.rx_buffer[0], Registers::IrqFlags1.read());
} | rust_cleaned_test_functions.jsonl/3701 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 190
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18760,
7302,
35456,
368,
341,
262,
1077,
5206,
435,
21112,
284,
6505,
1710,
21112,
49923,
486,
931,
1507,
7486,
20703,
15,
65,
15,
62,
15,
15,
15,
15,
15,
15,
15,
11,
220,
15,
10149,
262,
43... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_get_vertex_edge_by_id() {
let data_dir = "data/small_data";
let root_dir = "data/small_data";
let schema_file = "data/schema.json";
let mut loader =
GraphLoader::<DefaultId, u32>::new(data_dir, root_dir, schema_file, 20, 0, 1);
// load whole graph
loader.load().expect("Load graph error!");
let graphdb = loader.into_graph();
let v1_id = LDBCVertexParser::to_global_id(6455, 5);
let v2_id = LDBCVertexParser::to_global_id(1, 0);
let v1 = graphdb.get_vertex(v1_id).unwrap();
let v2 = graphdb.get_vertex(v2_id).unwrap();
assert_eq!(v1.get_id(), v1_id);
assert_eq!(v1.get_label(), [5, 12]);
check_properties(
&graphdb,
&v1,
"6455|Tsing_Hua_University|http://dbpedia.org/resource/Tsing_Hua_University",
);
assert_eq!(v2.get_id(), v2_id);
assert_eq!(v2.get_label(), [0, 8]);
check_properties(&graphdb, &v2, "1|China|http://dbpedia.org/resource/China");
let e1_id = (v1_id, 2);
let e1 = graphdb.get_edge(e1_id).unwrap();
assert_eq!(e1.get_edge_id(), e1_id);
assert_eq!(e1.get_src_id(), v1_id);
assert_eq!(e1.get_dst_id(), v2_id);
assert_eq!(e1.get_label(), 11);
assert!(e1.clone_all_properties().unwrap().is_empty());
let mut edges = graphdb.get_out_edges(v1_id, None);
let e1 = loop {
if let Some(e) = edges.next() {
if e.get_edge_id().1 == 2 {
break e;
}
}
};
let mut edges = graphdb.get_in_edges(v2_id, None);
let e2 = loop {
if let Some(e) = edges.next() {
if e.get_edge_id().1 == 2 {
break e;
}
}
};
assert_eq!(e1.get_src_id(), e2.get_src_id());
assert_eq!(e1.get_dst_id(), e2.get_dst_id());
assert_eq!(e1.get_other_id(), v2_id);
assert_eq!(e2.get_other_id(), v1_id);
} | rust_cleaned_test_functions.jsonl/22815 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1175
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
26611,
17932,
3710,
842,
368,
341,
286,
1077,
821,
4334,
284,
330,
691,
96816,
1769,
876,
286,
1077,
3704,
4334,
284,
330,
691,
96816,
1769,
876,
286,
1077,
10802,
2458,
284,
330,
691,
611... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_param_offset() {
info("fun f(a: bool, b: int) { let c = 1; }", |fct, jit_info| {
assert_eq!(12, jit_info.localsize);
for (var, offset) in fct.vars.iter().zip(&[-1, -8, -12]) {
assert_eq!(*offset, jit_info.offset(var.id));
}
});
} | rust_cleaned_test_functions.jsonl/73141 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 187
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4090,
6917,
368,
341,
286,
3546,
445,
11894,
282,
2877,
25,
1807,
11,
293,
25,
526,
8,
314,
1077,
272,
284,
220,
16,
26,
335,
497,
760,
69,
302,
11,
84573,
3109,
91,
341,
310,
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... | 2 |
#[test]
fn test_get_region_approximate_middle_cf() {
let tmp = Builder::new()
.prefix("test_raftstore_util")
.tempdir()
.unwrap();
let path = tmp.path().to_str().unwrap();
let db_opts = DBOptions::new();
let mut cf_opts = ColumnFamilyOptions::new();
cf_opts.set_level_zero_file_num_compaction_trigger(10);
let f = Box::new(RangePropertiesCollectorFactory::default());
cf_opts.add_table_properties_collector_factory("tikv.size-collector", f);
let cfs_opts = LARGE_CFS
.iter()
.map(|cf| CFOptions::new(cf, cf_opts.clone()))
.collect();
let engine =
Arc::new(engine_rocks::raw_util::new_engine_opt(path, db_opts, cfs_opts).unwrap());
let cf_handle = engine.cf_handle(CF_DEFAULT).unwrap();
let mut big_value = Vec::with_capacity(256);
big_value.extend(iter::repeat(b'v').take(256));
for i in 0..100 {
let k = format!("key_{:03}", i).into_bytes();
let k = keys::data_key(Key::from_raw(&k).as_encoded());
engine.put_cf(cf_handle, &k, &big_value).unwrap();
// Flush for every key so that we can know the exact middle key.
engine.flush_cf(cf_handle, true).unwrap();
}
let mut region = Region::default();
region.mut_peers().push(Peer::default());
let middle_key = get_region_approximate_middle_cf(engine.c(), CF_DEFAULT, ®ion)
.unwrap()
.unwrap();
let middle_key = Key::from_encoded_slice(keys::origin_key(&middle_key))
.into_raw()
.unwrap();
assert_eq!(escape(&middle_key), "key_049");
} | rust_cleaned_test_functions.jsonl/43995 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 845
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
20627,
90425,
3426,
62580,
71143,
368,
341,
286,
1077,
4174,
284,
20626,
486,
931,
741,
310,
659,
11849,
445,
1944,
62,
2944,
4314,
18974,
1138,
310,
659,
3888,
3741,
741,
310,
659,
15454,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_sim_withdraw() {
let (master_account, contract) = init();
call_deposit(&master_account, &contract);
let withdraw_amount: u128 = 100;
let _res = call!(
master_account,
contract.withdraw(RECIPIENT_ETH_ADDRESS.into(), withdraw_amount as u64),
gas = DEFAULT_GAS * 3
);
let minted_balance =
view!(contract.ft_balance_of(DEPOSITED_RECIPIENT.into())).unwrap_json::<u128>();
assert_eq!(
minted_balance,
DEPOSITED_AMOUNT - DEPOSITED_FEE - withdraw_amount
);
let minted_balance = view!(contract.ft_balance_of(CONTRACT_ACC.into())).unwrap_json::<u128>();
assert_eq!(minted_balance, DEPOSITED_FEE);
} | rust_cleaned_test_functions.jsonl/52146 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 312
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18314,
6615,
7633,
368,
341,
262,
1077,
320,
13629,
13500,
11,
5116,
8,
284,
2930,
543,
262,
1618,
85798,
2099,
13629,
13500,
11,
609,
20257,
626,
262,
1077,
14798,
13471,
25,
575,
16,
17,
23,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_generic_struct_deku() {
let test_data: Vec<u8> = [0x01].to_vec();
let ret_read = samples::GenericStructDeku::<u8>::try_from(test_data.as_ref()).unwrap();
assert_eq!(samples::GenericStructDeku::<u8> { field_a: 0x01 }, ret_read);
let ret_write: Vec<u8> = ret_read.try_into().unwrap();
assert_eq!(test_data, ret_write);
} | rust_cleaned_test_functions.jsonl/123228 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 165
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
41232,
15126,
2259,
12133,
368,
341,
262,
1077,
1273,
1769,
25,
11312,
34837,
23,
29,
284,
508,
15,
87,
15,
16,
936,
983,
13251,
1428,
262,
1077,
2112,
6443,
284,
10469,
486,
19964,
9422,
35,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_pool_has_expired_withdraw() {
// Default pool setup
let mut pool: PoolInfo<u64, Balance> = Default::default();
pool.total_shares = 1000 * DOLLARS;
pool.total_stake = 900 * DOLLARS;
pool.withdraw_queue.push_back(WithdrawInfo {
user: 1,
shares: 100 * DOLLARS,
start_time: 0,
});
pool.withdraw_queue.push_back(WithdrawInfo {
user: 2,
shares: 200 * DOLLARS,
start_time: 100,
});
pool.withdraw_queue.push_back(WithdrawInfo {
user: 3,
shares: 400 * DOLLARS,
start_time: 200,
});
// No releasing stake
let pool1 = PoolInfo::<u64, Balance> {
releasing_stake: 0,
..pool.clone()
};
assert!(!pool1.has_expired_withdrawal(0, 100), "All in grace period");
assert!(
!pool1.has_expired_withdrawal(100, 100),
"Still all in grace period"
);
assert!(
pool1.has_expired_withdrawal(101, 100),
"First withdraw request expired"
);
// Releaing stake to cover the first request
let pool2 = PoolInfo::<u64, Balance> {
releasing_stake: 90 * DOLLARS,
..pool.clone()
};
assert!(
!pool2.has_expired_withdrawal(101, 100),
"First withdraw request fulfilled"
);
assert!(
pool2.has_expired_withdrawal(201, 100),
"Second withdraw request expired"
);
let pool3 = PoolInfo::<u64, Balance> {
releasing_stake: 630 * DOLLARS - 10,
..pool.clone()
};
assert!(
pool3.has_expired_withdrawal(1000, 100),
"No enought releasing stake to fulfill all"
);
let pool4 = PoolInfo::<u64, Balance> {
releasing_stake: 630 * DOLLARS,
..pool.clone()
};
assert!(!pool4.has_expired_withdrawal(1000, 100), "Enough stake");
} | rust_cleaned_test_functions.jsonl/60470 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 773
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15709,
21778,
80221,
6615,
7633,
368,
341,
298,
197,
322,
7899,
7314,
6505,
198,
298,
10217,
5206,
7314,
25,
22728,
1731,
34837,
21,
19,
11,
30846,
29,
284,
7899,
486,
2258,
543,
298,
85273,
137... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_explain() {
let schema = Schema::new(vec![Field::new("id", DataType::Int32, false)]);
let logical_plan =
LogicalPlanBuilder::scan_empty(Some("employee"), &schema, None)
.unwrap()
.explain(true, false)
.unwrap()
.build()
.unwrap();
let plan = plan(&logical_plan).unwrap();
if let Some(plan) = plan.as_any().downcast_ref::<ExplainExec>() {
let stringified_plans = plan.stringified_plans();
assert!(stringified_plans.len() >= 4);
assert!(stringified_plans
.iter()
.any(|p| matches!(p.plan_type, PlanType::FinalLogicalPlan)));
assert!(stringified_plans
.iter()
.any(|p| matches!(p.plan_type, PlanType::InitialPhysicalPlan)));
assert!(stringified_plans
.iter()
.any(|p| matches!(p.plan_type, PlanType::OptimizedPhysicalPlan { .. })));
assert!(stringified_plans
.iter()
.any(|p| matches!(p.plan_type, PlanType::FinalPhysicalPlan)));
} else {
panic!(
"Plan was not an explain plan: {}",
displayable(plan.as_ref()).indent()
);
}
} | rust_cleaned_test_functions.jsonl/35514 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 733
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2702,
20772,
368,
341,
286,
1077,
10802,
284,
12539,
486,
931,
25592,
20703,
1877,
486,
931,
445,
307,
497,
33172,
486,
1072,
18,
17,
11,
895,
7252,
626,
286,
1077,
19819,
26564,
4035,
310,
6206... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_rotate() {
assert_eq!(Permutation::parse("x y z' y'").unwrap().order(), 1);
assert_eq!(Permutation::parse("x y").unwrap().order(), 3);
assert_eq!(Permutation::parse("U x").unwrap().order(), 1260);
} | rust_cleaned_test_functions.jsonl/31487 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 115
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
60834,
368,
341,
286,
2060,
10714,
10297,
3889,
30971,
486,
6400,
445,
87,
379,
1147,
6,
379,
6,
1827,
15454,
1005,
1358,
1507,
220,
16,
317,
286,
2060,
10714,
10297,
3889,
30971,
486,
6400,
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_compute_loops_self_loop() {
let graph = {
let mut graph = Graph::new();
graph.insert_vertex(1).unwrap();
graph.insert_vertex(2).unwrap();
graph.insert_vertex(3).unwrap();
graph.insert_edge((1, 2)).unwrap();
graph.insert_edge((2, 3)).unwrap();
graph.insert_edge((2, 2)).unwrap(); // back edge
graph
};
let loops = graph.compute_loops(1).unwrap();
assert_eq!(loops.len(), 1);
assert_eq!(loops[0].header(), 2);
assert_eq!(loops[0].nodes(), &vec![2].into_iter().collect());
} | rust_cleaned_test_functions.jsonl/1499 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 333
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
57028,
5560,
3721,
25637,
17198,
368,
341,
286,
1077,
4771,
284,
341,
310,
1077,
5206,
4771,
284,
12165,
486,
931,
1428,
310,
4771,
7030,
26611,
7,
16,
568,
15454,
543,
310,
4771,
7030,
26611,
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_follower_vote() {
let l = default_logger();
let mut tests = vec![
(INVALID_ID, 1, false),
(INVALID_ID, 2, false),
(1, 1, false),
(2, 2, false),
(1, 2, true),
(2, 1, true),
];
for (i, (vote, nvote, wreject)) in tests.drain(..).enumerate() {
let mut r = new_test_raft(1, vec![1, 2, 3], 10, 1, new_storage(), &l);
r.load_state(&hard_state(1, 1, vote));
let mut m = new_message(nvote, 1, MessageType::MsgRequestVote, 0);
m.term = 1;
m.log_term = 1;
m.index = 1;
r.step(m).expect("");
let msgs = r.read_messages();
let mut m = new_message(1, nvote, MessageType::MsgRequestVoteResponse, 0);
m.term = 1;
m.reject = wreject;
let expect_msgs = vec![m];
if msgs != expect_msgs {
panic!("#{}: msgs = {:?}, want {:?}", i, msgs, expect_msgs);
}
}
} | rust_cleaned_test_functions.jsonl/62296 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 503
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
761,
29034,
54360,
368,
341,
262,
1077,
326,
284,
1638,
27413,
543,
262,
1077,
5206,
7032,
284,
7486,
90515,
286,
320,
46859,
3450,
11,
220,
16,
11,
895,
1326,
286,
320,
46859,
3450,
11,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_from_raw() {
let headers = Headers::from_raw(&mut mem("Content-Length: 10\r\n\r\n")).unwrap();
assert_eq!(headers.get(), Some(&ContentLength(10)));
} | rust_cleaned_test_functions.jsonl/18236 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 88
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5673,
16067,
368,
341,
286,
1077,
7102,
284,
21426,
486,
1499,
16067,
2099,
6984,
1833,
445,
2762,
52493,
25,
220,
16,
15,
12016,
1699,
12016,
1699,
15197,
15454,
543,
286,
2060,
10714,
10297,
771... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_with_no_doc_stage0() {
let mut config = configure(&[], &[]);
config.stage = Some(0);
config.cmd = Subcommand::Test {
paths: vec!["src/libstd".into()],
test_args: vec![],
rustc_args: vec![],
fail_fast: true,
doc_tests: DocTests::No,
bless: false,
compare_mode: None,
};
let build = Build::new(config);
let mut builder = Builder::new(&build);
let host = INTERNER.intern_str("A");
builder.run_step_descriptions(
&[StepDescription::from::<test::Crate>()],
&["src/libstd".into()],
);
// Ensure we don't build any compiler artifacts.
assert!(!builder.cache.contains::<compile::Rustc>());
assert_eq!(
first(builder.cache.all::<test::Crate>()),
&[test::Crate {
compiler: Compiler { host, stage: 0 },
target: host,
mode: Mode::Std,
test_kind: test::TestKind::Test,
krate: INTERNER.intern_str("std"),
},]
);
} | rust_cleaned_test_functions.jsonl/1470 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 614
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6615,
6536,
18869,
35238,
15,
368,
341,
286,
1077,
5206,
2193,
284,
14411,
2099,
12995,
609,
56703,
286,
2193,
33745,
284,
4329,
7,
15,
317,
286,
2193,
25724,
284,
3719,
5631,
486,
2271,
341,
31... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_write() {
const INITIAL: &'static [u8] = b"abcdef123456";
let wbuf = "CDEF".to_string().into_bytes();
let mut rbuf = Vec::new();
const EXPECT: &'static [u8] = b"abCDEF123456";
let mut f = tempfile().unwrap();
f.write(INITIAL).unwrap();
let mut aiocb = AioCb::from_slice( f.as_raw_fd(),
2, //offset
&wbuf,
0, //priority
SigevNotify::SigevNone,
LioOpcode::LIO_NOP);
aiocb.write().unwrap();
let err = poll_aio(&mut aiocb);
assert!(err == Ok(()));
assert!(aiocb.aio_return().unwrap() as usize == wbuf.len());
f.seek(SeekFrom::Start(0)).unwrap();
let len = f.read_to_end(&mut rbuf).unwrap();
assert!(len == EXPECT.len());
assert!(rbuf == EXPECT);
} | rust_cleaned_test_functions.jsonl/7359 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 470
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9165,
368,
341,
262,
733,
56854,
25,
30136,
1978,
508,
84,
23,
60,
284,
293,
1,
41202,
16,
17,
18,
19,
20,
21,
876,
262,
1077,
289,
5909,
284,
330,
34,
13649,
3263,
983,
3904,
1005,
18122,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_from_into_signature_algorithm() {
let cbor_signature_algorithm = cbor_int!(ecdsa::PubKey::ES256_ALGORITHM);
let signature_algorithm = SignatureAlgorithm::try_from(&cbor_signature_algorithm);
let expected_signature_algorithm = SignatureAlgorithm::ES256;
assert_eq!(signature_algorithm, Ok(expected_signature_algorithm));
let created_cbor: cbor::Value = cbor_int!(signature_algorithm.unwrap() as i64);
assert_eq!(created_cbor, cbor_signature_algorithm);
let cbor_unknown_algorithm = cbor_int!(-1);
let unknown_algorithm = SignatureAlgorithm::try_from(&cbor_unknown_algorithm);
let expected_unknown_algorithm = SignatureAlgorithm::Unknown;
assert_eq!(unknown_algorithm, Ok(expected_unknown_algorithm));
} | rust_cleaned_test_functions.jsonl/51445 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 323
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5673,
45514,
39859,
59531,
368,
341,
286,
1077,
272,
9368,
39859,
59531,
284,
272,
9368,
4042,
10297,
757,
96780,
486,
29162,
1592,
486,
1570,
17,
20,
21,
8912,
74585,
317,
286,
1077,
11957,
59531... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_locate_binary_2_args() {
let cases = vec![
("", "foobArbar", 1),
("", "", 1),
("xxx", "", 0),
("BaR", "foobArbar", 0),
("bar", "foobArbar", 7),
(
"好世",
"你好世界",
1 + "你好世界".find("好世").unwrap() as i64,
),
];
for (substr, s, exp) in cases {
let substr = Datum::Bytes(substr.as_bytes().to_vec());
let s = Datum::Bytes(s.as_bytes().to_vec());
let got = eval_func(ScalarFuncSig::LocateBinary2Args, &[substr, s]).unwrap();
assert_eq!(got, Datum::I64(exp))
}
let null_cases = vec![
(Datum::Null, Datum::Bytes(b"".to_vec()), Datum::Null),
(Datum::Bytes(b"".to_vec()), Datum::Null, Datum::Null),
(Datum::Null, Datum::Null, Datum::Null),
];
for (substr, s, exp) in null_cases {
let got = eval_func(ScalarFuncSig::LocateBinary2Args, &[substr, s]).unwrap();
assert_eq!(got, exp);
}
} | rust_cleaned_test_functions.jsonl/9084 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 656
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13400,
349,
31761,
62,
17,
8384,
368,
341,
286,
1077,
5048,
284,
7486,
90515,
310,
3489,
497,
330,
824,
674,
6953,
2257,
497,
220,
16,
1326,
310,
3489,
497,
7342,
220,
16,
1326,
310,
3489,
240... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_bpf_loader_invoke_main() {
let program_id = solana_sdk::pubkey::new_rand();
let program_key = solana_sdk::pubkey::new_rand();
// Create program account
let mut file = File::open("test_elfs/noop_aligned.so").expect("file open failed");
let mut elf = Vec::new();
file.read_to_end(&mut elf).unwrap();
let program_account = Account::new_ref(1, 0, &program_id);
program_account.borrow_mut().data = elf;
program_account.borrow_mut().executable = true;
let mut keyed_accounts = vec![KeyedAccount::new(&program_key, false, &program_account)];
let mut invoke_context = MockInvokeContext::default();
// Case: Empty keyed accounts
assert_eq!(
Err(InstructionError::NotEnoughAccountKeys),
process_instruction(&bpf_loader::id(), &[], &[], &mut invoke_context)
);
// Case: Only a program account
assert_eq!(
Ok(()),
process_instruction(&bpf_loader::id(), &keyed_accounts, &[], &mut invoke_context)
);
// Case: Account not executable
keyed_accounts[0].account.borrow_mut().executable = false;
assert_eq!(
Err(InstructionError::InvalidInstructionData),
process_instruction(&bpf_loader::id(), &keyed_accounts, &[], &mut invoke_context)
);
keyed_accounts[0].account.borrow_mut().executable = true;
// Case: With program and parameter account
let parameter_account = Account::new_ref(1, 0, &program_id);
keyed_accounts.push(KeyedAccount::new(&program_key, false, ¶meter_account));
assert_eq!(
Ok(()),
process_instruction(&bpf_loader::id(), &keyed_accounts, &[], &mut invoke_context)
);
// Case: limited budget
let program_id = Pubkey::default();
let mut invoke_context = ThisInvokeContext::new(
&program_id,
Rent::default(),
vec![],
&[],
None,
BpfComputeBudget {
max_units: 1,
log_units: 100,
log_64_units: 100,
create_program_address_units: 1500,
invoke_units: 1000,
max_invoke_depth: 2,
sha256_base_cost: 85,
sha256_byte_cost: 1,
max_call_depth: 20,
stack_frame_size: 4096,
log_pubkey_units: 100,
},
Rc::new(RefCell::new(Executors::default())),
None,
Arc::new(FeatureSet::default()),
);
assert_eq!(
Err(InstructionError::Custom(194969602)),
process_instruction(&bpf_loader::id(), &keyed_accounts, &[], &mut invoke_context)
);
// Case: With duplicate accounts
let duplicate_key = solana_sdk::pubkey::new_rand();
let parameter_account = Account::new_ref(1, 0, &program_id);
let mut keyed_accounts = vec![KeyedAccount::new(&program_key, false, &program_account)];
keyed_accounts.push(KeyedAccount::new(&duplicate_key, false, ¶meter_account));
keyed_accounts.push(KeyedAccount::new(&duplicate_key, false, ¶meter_account));
assert_eq!(
Ok(()),
process_instruction(
&bpf_loader::id(),
&keyed_accounts,
&[],
&mut MockInvokeContext::default()
)
);
} | rust_cleaned_test_functions.jsonl/57224 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1720
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
880,
15897,
22139,
79779,
11027,
368,
341,
286,
1077,
2025,
842,
284,
2048,
3362,
61783,
486,
9585,
792,
486,
931,
33864,
543,
286,
1077,
2025,
3097,
284,
2048,
3362,
61783,
486,
9585,
792,
486,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_fizz_or_buzz() {
let three_four = FizzBuzz::new(3, 4);
assert_eq!("fizz", three_four.get_value(9));
assert_eq!("buzz", three_four.get_value(8));
assert_eq!("fizz", three_four.get_value(13));
assert_eq!("buzz", three_four.get_value(116));
assert_eq!("fizz", three_four.get_value(13125));
let two_five = FizzBuzz::new(2, 5);
assert_eq!("buzz", two_five.get_value(59));
assert_eq!("fizz", two_five.get_value(29));
assert_eq!("buzz", two_five.get_value(11511));
assert_eq!("fizz", two_five.get_value(4342));
} | rust_cleaned_test_functions.jsonl/74962 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 311
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
761,
8759,
8734,
880,
8889,
368,
341,
286,
1077,
2326,
56142,
284,
434,
8759,
59473,
486,
931,
7,
18,
11,
220,
19,
317,
286,
2060,
10714,
17223,
69,
8759,
497,
2326,
56142,
670,
3142,
7,
24,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_push_data() {
let mut script = Script::new(32);
script.data(&[1, 2, 3]);
script.data(&[10, 20, 30]);
let mut exector = Exector::new();
exector.exec(&script, &TestEnv {}).unwrap();
assert_eq!(exector.len(), 2);
let d1: &[u8] = exector.top(1).try_into().unwrap();
assert_eq!(d1, [1, 2, 3]);
let d2: &[u8] = exector.top(2).try_into().unwrap();
assert_eq!(d2, [10, 20, 30]);
} | rust_cleaned_test_functions.jsonl/78508 | {
"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,
14218,
1769,
368,
341,
262,
1077,
5206,
5316,
284,
13710,
486,
931,
7,
18,
17,
317,
262,
5316,
2196,
2099,
58,
16,
11,
220,
17,
11,
220,
18,
2558,
262,
5316,
2196,
2099,
58,
16,
15,
11,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_dialer_and_listener() {
// Setup listener.
let rand_port = rand::random::<u64>().saturating_add(1);
let t1_addr: Multiaddr = format!("/memory/{}", rand_port).parse().unwrap();
let cloned_t1_addr = t1_addr.clone();
let psk = "/key/swarm/psk/1.0.0/\n/base16/\n6189c5cf0b87fb800c1a9feeda73c6ab5e998db48fb9e6a978575c770ceef683"
.parse::<PreSharedKey>()
.unwrap();
let pnet = PnetConfig::new(psk);
let pro_trans = ProtectorTransport::new(MemoryTransport::default(), pnet);
let mut t1 = TransportUpgrade::new(pro_trans.clone(), DummyUpgrader::new(), DummyUpgrader::new());
let listener = async move {
let mut listener = t1.listen_on(t1_addr.clone()).unwrap();
let mut socket = match listener.accept().await.unwrap() {
ListenerEvent::Accepted(s) => s,
_ => panic!("unreachable"),
};
socket.accept_stream().await.unwrap_err();
};
// Setup dialer.
let mut t2 = TransportUpgrade::new(pro_trans, DummyUpgrader::new(), DummyUpgrader::new());
let dialer = async move {
let mut socket = t2.dial(cloned_t1_addr).await.unwrap();
let r = socket.open_stream().await;
assert!(r.is_err());
};
// Wait for both to finish.
futures::executor::block_on(futures::future::join(listener, dialer));
} | rust_cleaned_test_functions.jsonl/99418 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 708
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
814,
530,
261,
8378,
46493,
368,
341,
286,
442,
18626,
11446,
624,
286,
1077,
10382,
8716,
284,
10382,
486,
11463,
27638,
84,
21,
19,
10483,
82,
2628,
1095,
2891,
7,
16,
317,
286,
1077,
259,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_clean_old_with_zero_lamport_account() {
solana_logger::setup();
let accounts = AccountsDB::new(Vec::new());
let pubkey1 = Pubkey::new_rand();
let pubkey2 = Pubkey::new_rand();
let normal_account = Account::new(1, 0, &Account::default().owner);
let zero_account = Account::new(0, 0, &Account::default().owner);
//store an account
accounts.store(0, &[(&pubkey1, &normal_account)]);
accounts.store(1, &[(&pubkey1, &zero_account)]);
accounts.store(0, &[(&pubkey2, &normal_account)]);
accounts.store(1, &[(&pubkey2, &normal_account)]);
//simulate slots are rooted after while
accounts.add_root(0);
accounts.add_root(1);
assert_eq!(accounts.store_count_for_slot(0), 2);
assert_eq!(accounts.store_count_for_slot(1), 2);
accounts.clean_accounts();
//still old state behind zero-lamport account isn't cleaned up
assert_eq!(accounts.store_count_for_slot(0), 1);
assert_eq!(accounts.store_count_for_slot(1), 2);
} | rust_cleaned_test_functions.jsonl/33676 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 492
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19573,
21108,
6615,
19359,
907,
309,
403,
13500,
368,
341,
286,
2048,
3362,
27413,
486,
15188,
1428,
286,
1077,
9618,
284,
40655,
3506,
486,
931,
49923,
486,
931,
1423,
286,
1077,
95116,
16,
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_request_from_settings_empty() {
let request = SettingRequest::from(IntlSettings::empty());
assert_eq!(
request,
SettingRequest::SetIntlInfo(IntlInfo {
locales: None,
temperature_unit: None,
time_zone_id: None,
hour_cycle: None,
})
);
} | rust_cleaned_test_functions.jsonl/95264 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 212
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7893,
5673,
10853,
15124,
368,
341,
286,
1077,
1681,
284,
20037,
1900,
486,
1499,
24123,
75,
6086,
486,
3194,
5231,
286,
2060,
10714,
33673,
310,
1681,
345,
310,
20037,
1900,
486,
1649,
98691,
173... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_tokenstream() {
let tts = TokenStream::from_str("[a + 1]").unwrap();
#[cfg(not(span_locations))]
let expected = "\
TokenStream [
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
sym: a,
},
Punct {
char: '+',
spacing: Alone,
},
Literal {
lit: 1,
},
],
},
]\
";
#[cfg(not(span_locations))]
let expected_before_trailing_commas = "\
TokenStream [
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
sym: a
},
Punct {
char: '+',
spacing: Alone
},
Literal {
lit: 1
}
]
}
]\
";
#[cfg(span_locations)]
let expected = "\
TokenStream [
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
sym: a,
span: bytes(2..3),
},
Punct {
char: '+',
spacing: Alone,
span: bytes(4..5),
},
Literal {
lit: 1,
span: bytes(6..7),
},
],
span: bytes(1..8),
},
]\
";
#[cfg(span_locations)]
let expected_before_trailing_commas = "\
TokenStream [
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
sym: a,
span: bytes(2..3)
},
Punct {
char: '+',
spacing: Alone,
span: bytes(4..5)
},
Literal {
lit: 1,
span: bytes(6..7)
}
],
span: bytes(1..8)
}
]\
";
let actual = format!("{:#?}", tts);
if actual.ends_with(",\n]") {
assert_eq!(expected, actual);
} else {
assert_eq!(expected_before_trailing_commas, actual);
}
} | rust_cleaned_test_functions.jsonl/109302 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1310
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15446,
6458,
4027,
368,
341,
262,
1077,
98540,
284,
9660,
3027,
486,
1499,
2895,
10937,
64,
488,
220,
16,
44891,
15454,
1428,
262,
11506,
14072,
24772,
66092,
45032,
22297,
262,
1077,
3601,
284,
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... | 2 |
#[test]
fn test_find_parent() {
//0 a/
//1 b/
//2 c
//3 d
let res = FileTreeItems::new(
&string_vec_to_status(&[
"a/b/c",
"a/b/d",
]),
&BTreeSet::new(),
)
.unwrap();
assert_eq!(res.find_parent_index(3), 1);
} | rust_cleaned_test_functions.jsonl/56876 | {
"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,
21814,
15960,
368,
341,
286,
442,
15,
264,
5894,
286,
442,
16,
256,
293,
5894,
286,
442,
17,
257,
272,
198,
286,
442,
18,
257,
294,
271,
286,
1077,
592,
284,
2887,
6533,
4353,
486,
931,
1006... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_tagged_struct() {
#[derive(Tsify)]
#[serde(tag = "type")]
struct TaggedStruct {
x: i32,
y: i32,
}
assert_eq!(
TaggedStruct::DECL,
indoc! {r#"
export interface TaggedStruct {
type: "TaggedStruct";
x: number;
y: number;
}"#
}
);
} | rust_cleaned_test_functions.jsonl/121075 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 238
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9372,
3556,
15126,
368,
341,
262,
11506,
27098,
4140,
82,
1437,
5563,
262,
11506,
47024,
19343,
284,
330,
1313,
5422,
262,
2036,
12353,
3556,
9422,
341,
286,
856,
25,
600,
18,
17,
345,
286,
379,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_writer_properties_builder_partial_defaults() {
let props = WriterProperties::builder()
.set_encoding(Encoding::DELTA_BINARY_PACKED)
.set_compression(Compression::GZIP)
.set_column_encoding(ColumnPath::from("col"), Encoding::RLE)
.build();
assert_eq!(
props.encoding(&ColumnPath::from("col")),
Some(Encoding::RLE)
);
assert_eq!(
props.compression(&ColumnPath::from("col")),
Compression::GZIP
);
assert_eq!(
props.dictionary_enabled(&ColumnPath::from("col")),
DEFAULT_DICTIONARY_ENABLED
);
} | rust_cleaned_test_functions.jsonl/56729 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 358
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28908,
25158,
28532,
52068,
42290,
368,
341,
286,
1077,
6914,
284,
29404,
7903,
486,
17850,
741,
310,
659,
746,
37613,
85177,
486,
38332,
15204,
49754,
23987,
1479,
340,
310,
659,
746,
2965,
4011,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_get_table_schema() {
let result = Postgres::get_table_schema(
"postgres://postgres:password@localhost:5432/postgres",
"arrow_data",
)
.expect("Unable to get table schema");
dbg!(result);
} | rust_cleaned_test_functions.jsonl/3794 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 136
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
5237,
25371,
368,
341,
286,
1077,
1102,
284,
3877,
17818,
486,
455,
5237,
25371,
1006,
310,
330,
43070,
1110,
43070,
25,
3833,
31,
8301,
25,
20,
19,
18,
17,
29996,
17818,
756,
310,
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_class_having_private_method() {
let hdr = indoc! {"
#include <cstdint>
class A {
private:
inline uint32_t private_method() { return 0; }
};
"};
let rs = quote! {};
run_test("", hdr, rs, &[], &["A"]);
} | rust_cleaned_test_functions.jsonl/9971 | {
"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,
4790,
1523,
2317,
26249,
9032,
368,
341,
262,
1077,
36615,
284,
1257,
509,
0,
314,
698,
262,
671,
997,
366,
96975,
397,
262,
536,
362,
341,
262,
869,
510,
286,
7381,
2622,
18,
17,
528,
869,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_credential_source_invalid_cbor() {
assert!(PublicKeyCredentialSource::try_from(cbor_false!()).is_err());
assert!(PublicKeyCredentialSource::try_from(cbor_array!(false)).is_err());
assert!(PublicKeyCredentialSource::try_from(cbor_array!(b"foo".to_vec())).is_err());
} | rust_cleaned_test_functions.jsonl/49016 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 140
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
666,
30320,
10347,
31433,
666,
9368,
368,
341,
286,
2060,
10297,
61822,
48265,
3608,
486,
1539,
5673,
1337,
9368,
36015,
0,
6011,
285,
9266,
1423,
286,
2060,
10297,
61822,
48265,
3608,
486,
1539,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_quoted_word() {
// Simple string
assert_eq!(
pqw("\"abc\""),
Ok((Word::Value(Value::from("abc")), "".into()))
);
// Simple string with text following
assert_eq!(
pqw("\"abc\" "),
Ok((Word::Value(Value::from("abc")), " ".into()))
);
assert_eq!(
pqw("\"\\x77-\" "),
Ok((Word::Value(Value::from("w-")), " ".into()))
);
assert_eq!(
pqw("\"-\\x77-\" "),
Ok((Word::Value(Value::from("-w-")), " ".into()))
);
assert_eq!(
pqw("\"-\\x77\" "),
Ok((Word::Value(Value::from("-w")), " ".into()))
);
// Variable reference
assert_eq!(
pqw("\"a$x.b\" "),
Ok((
Word::Tokens(vec![
Word::String("a".into()),
Word::VarRef("x".into()),
Word::String(".b".into()),
]),
" ".into()
))
);
assert_eq!(
pqw("\"a${x}b\" "),
Ok((
Word::Tokens(vec![
Word::String("a".into()),
Word::VarRef("x".into()),
Word::String("b".into()),
]),
" ".into()
))
);
// Not actually a variable reference
assert_eq!(
pqw("\"a$.b\" "),
Ok((Word::Value(Value::from("a$.b")), " ".into()))
);
// Brackets
assert_eq!(
pqw("\"a[list b]c\" "),
Ok((
Word::Tokens(vec![
Word::String("a".into()),
Word::Script(pbrack("[list b]").unwrap()),
Word::String("c".into()),
]),
" ".into()
))
);
// Missing close quote
assert_eq!(pqw("\"abc"), molt_err!("missing \""));
// Extra characters after close-quote
assert_eq!(
pqw("\"abc\"x "),
molt_err!("extra characters after close-quote")
);
} | rust_cleaned_test_functions.jsonl/59327 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1356
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
11280,
9253,
13533,
368,
341,
286,
442,
8993,
914,
198,
286,
2060,
10714,
33673,
310,
39639,
86,
38915,
13683,
2105,
4461,
310,
7622,
1188,
10879,
486,
1130,
25346,
486,
1499,
445,
13683,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ge() {
assert!(Version::parse("1.2.3-alpha2") >= Version::parse("0.0.0"));
assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.0.0"));
assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.2.0"));
assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.2.3-alpha1"));
assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.2.3-alpha2"));
assert!(Version::parse("1.2.3+23") >= Version::parse("1.2.3+42"));
} | rust_cleaned_test_functions.jsonl/43108 | {
"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,
32933,
368,
341,
286,
2060,
10297,
5637,
486,
6400,
445,
16,
13,
17,
13,
18,
64538,
17,
899,
2604,
6079,
486,
6400,
445,
15,
13,
15,
13,
15,
4010,
286,
2060,
10297,
5637,
486,
6400,
445,
16,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_single_node() {
init_log();
let mem_router = Arc::new(MemRouter::new(1));
let node = NodeId::new(1, 1);
mem_router.new_node(node, MemVoteFactor::new(0));
sleep(Duration::from_secs(1));
mem_router.assert_node_state(node, State::Startup, 0, None);
let options = Options::builder()
.election_timeout_min(1000)
.election_timeout_max(1100)
.heartbeat_interval(300)
.build()
.unwrap();
mem_router.update_node_options(node, options);
sleep(Duration::from_secs(1));
mem_router.assert_node_state(node, State::Startup, 0, None);
mem_router.init_node(node, Vec::new(), InitialMode::Normal);
sleep(Duration::from_secs(1));
mem_router.assert_node_state(node, State::Leader, 1, Some(node));
} | rust_cleaned_test_functions.jsonl/8667 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 342
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19487,
5084,
368,
341,
262,
2930,
5224,
1428,
262,
1077,
1833,
55587,
284,
19689,
486,
931,
3189,
336,
9523,
486,
931,
7,
16,
1106,
262,
1077,
2436,
284,
6018,
764,
486,
931,
7,
16,
11,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_dat_unicode_grapheme_cluster() {
let strs: Vec<&str> = vec!["a", "abc", "abcde\u{0301}"];
let da = DoubleArrayTrieBuilder::new().build(&strs);
let input1 = "abcde\u{0301}\u{1100}\u{1161}\u{AC00}";
let result1: Vec<&str> = da
.common_prefix_iter(input1)
.map(|(end_idx, _)| &input1[..end_idx])
.collect();
assert_eq!(result1, vec!["a", "abc", "abcde\u{0301}"]);
} | rust_cleaned_test_functions.jsonl/6382 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 255
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15353,
54662,
14738,
3894,
28441,
368,
341,
286,
1077,
57584,
25,
11312,
52244,
495,
29,
284,
7486,
0,
1183,
64,
497,
330,
13683,
497,
330,
13683,
450,
3770,
90,
15,
18,
15,
16,
92,
6332,
286,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parse_literal_ip() {
assert_eq!(
parse_literal_ip("127.0.0.1").expect("failed"),
RData::A(Ipv4Addr::new(127, 0, 0, 1))
);
assert_eq!(
parse_literal_ip("::1").expect("failed"),
RData::AAAA(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1))
);
assert!(parse_literal_ip("example.com").is_none());
} | rust_cleaned_test_functions.jsonl/38044 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 233
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
34100,
10385,
368,
341,
286,
2060,
10714,
33673,
310,
4715,
34100,
10385,
445,
16,
17,
22,
13,
15,
13,
15,
13,
16,
1827,
17119,
445,
16091,
4461,
310,
431,
1043,
486,
32,
8972,
30168,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_table_neg() {
for (name, p) in PERMUTATION_TABLE.iter() {
let inv = if name.len() > 1 {
PERMUTATION_TABLE.get(&[name[0]][..])
} else {
PERMUTATION_TABLE.get(&[name[0], b'\''][..])
};
assert_eq!(-(*p), *inv.unwrap());
}
} | rust_cleaned_test_functions.jsonl/31485 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 206
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5237,
28209,
368,
341,
286,
369,
320,
606,
11,
281,
8,
304,
17854,
44,
1381,
3495,
16039,
19471,
368,
341,
310,
1077,
1529,
284,
421,
829,
19406,
368,
861,
220,
16,
341,
394,
17854,
44,
1381,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_cost_tracker_ok_add_one() {
let (mint_keypair, start_hash) = test_setup();
let (_tx, keys, cost) = build_simple_transaction(&mint_keypair, &start_hash);
// build testee to have capacity for one simple transaction
let mut testee = CostTracker::new(cost, cost);
assert!(testee.would_fit(&keys, &cost).is_ok());
testee.add_transaction(&keys, &cost);
assert_eq!(cost, testee.block_cost);
} | rust_cleaned_test_functions.jsonl/21952 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 200
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15890,
50264,
19817,
2891,
11667,
368,
341,
286,
1077,
320,
67791,
3097,
12670,
11,
1191,
8950,
8,
284,
1273,
21363,
543,
286,
1077,
5453,
3998,
11,
6894,
11,
2783,
8,
284,
1936,
30015,
28884,
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_add_to_missing_role() {
let mut context = VMContextBuilder::new();
testing_env!(context.predecessor_account_id(accounts(1)).build());
let mut contract = Contract::new(
Config::test_config(),
VersionedPolicy::Default(vec![accounts(1).into()]),
);
testing_env!(context.attached_deposit(to_yocto("1")).build());
let id = contract.add_proposal(ProposalInput {
description: "test".to_string(),
kind: ProposalKind::AddMemberToRole {
member_id: accounts(2).into(),
role: "missing".to_string(),
},
});
contract.act_proposal(id, Action::VoteApprove, None);
let x = contract.get_policy();
// still 2 roles: all and council.
assert_eq!(x.roles.len(), 2);
} | rust_cleaned_test_functions.jsonl/16639 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 401
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
2346,
40447,
19792,
368,
341,
286,
1077,
5206,
2266,
284,
17792,
1972,
3297,
486,
931,
543,
286,
7497,
15879,
10297,
2147,
6225,
26911,
269,
13500,
842,
91868,
7,
16,
4579,
5834,
1423,
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_type()
{
test_parse("type x = {};");
test_parse("type x = { f1: T1 };");
test_parse("type x@(summary) = { f1: T1 };");
test_parse("type x = { f1: T1 }@{-description-};");
test_parse("type x@(summary) = { f1: T1 }@{-description-};");
test_parse("type x @ (summary) = { f1: T1 } @ {-description-};");
test_parse("type x = { f1: T1 @{- desc -}, };");
test_parse("type x = { f1: T1, @// desc\n};");
test_parse("type x = { f1: T1, };");
test_parse("type x = { f1: T1, f2: T2 };");
test_parse("type x = { f1: T1, f2: T2, };");
test_parse("type x = {, f1: T1, f2: T2, };");
test_parse("type x = { f1: { f2: T } };");
test_parse("type x = a b;");
test_parse("type x y = a b;");
test_parse("type Either a b = Left a | Right b;");
test_parse("type x = a;");
test_parse("type x = a |;");
test_parse("type x = a | b;");
test_parse("type x = a | b |;");
test_parse("type x = a | b | c {} | {};");
test_parse("type x = | a;");
test_parse("type x = | a |;");
} | rust_cleaned_test_functions.jsonl/91398 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 449
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1819,
741,
515,
18185,
21039,
445,
1313,
856,
284,
4687,
34649,
18185,
21039,
445,
1313,
856,
284,
314,
282,
16,
25,
350,
16,
20066,
797,
18185,
21039,
445,
1313,
856,
59404,
1708,
8,
284,
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_parse_custom_with_preceding_and_trailing_whitespace() {
let s = "1d{ 1 ,\t1\t, \t0 \t,\t \t0\t \t,\t -1\t , -1 }";
let roll: Roll = s.parse().expect("Bad parse");
assert_eq!(roll.sides, 6);
assert_eq!(roll.values, vec![1, 1, 0, 0, -1, -1]);
} | rust_cleaned_test_functions.jsonl/52853 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 170
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
15875,
6615,
10442,
1998,
287,
8378,
3547,
14277,
86175,
368,
341,
286,
1077,
274,
284,
330,
16,
67,
90,
220,
16,
1154,
59,
83,
16,
4955,
11,
1124,
83,
15,
1124,
83,
26266,
83,
1124,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_stack_accumulator() {
let code = vec![0x48, 0x68]; //push pull
let mut nes = Cpu::new();
let mut memory = new_memory(code);
nes.A = 0x44;
nes.next(&mut memory).unwrap();
nes.A = 0x00;
assert_eq!(0xFC, nes.SP);
assert_eq!(0x44, memory.get(0x01FD));
nes.next(&mut memory).unwrap();
assert_eq!(0xFD, nes.SP);
assert_eq!(0x44, nes.A);
} | rust_cleaned_test_functions.jsonl/38724 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 251
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15528,
75837,
10511,
368,
341,
286,
1077,
2038,
284,
7486,
20703,
15,
87,
19,
23,
11,
220,
15,
87,
21,
23,
5265,
442,
9077,
6815,
198,
286,
1077,
5206,
308,
288,
284,
356,
5584,
486,
931,
54... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_it_works_integration() {
use tipb::ExprType;
use tipb_helper::ExprDefBuilder;
// This test creates a stream aggregation executor with the following aggregate functions:
// And group by:
// - col_0
// - col_1 + 2.0
let group_by_exps = vec![
RpnExpressionBuilder::new_for_test()
.push_column_ref_for_test(0)
.build_for_test(),
RpnExpressionBuilder::new_for_test()
.push_column_ref_for_test(1)
.push_constant_for_test(2.0)
.push_fn_call_for_test(arithmetic_fn_meta::<RealPlus>(), 2, FieldTypeTp::Double)
.build_for_test(),
];
let aggr_definitions = vec![
ExprDefBuilder::aggr_func(ExprType::Count, FieldTypeTp::LongLong)
.push_child(ExprDefBuilder::constant_int(1))
.build(),
ExprDefBuilder::aggr_func(ExprType::Avg, FieldTypeTp::Double)
.push_child(
ExprDefBuilder::scalar_func(ScalarFuncSig::PlusReal, FieldTypeTp::Double)
.push_child(ExprDefBuilder::column_ref(1, FieldTypeTp::Double))
.push_child(ExprDefBuilder::constant_real(1.0)),
)
.build(),
];
let src_exec = make_src_executor();
let mut exec = BatchStreamAggregationExecutor::new_for_test(
src_exec,
group_by_exps,
aggr_definitions,
AllAggrDefinitionParser,
);
let r = exec.next_batch(1);
assert_eq!(&r.logical_rows, &[0, 1]);
assert_eq!(r.physical_columns.rows_len(), 2);
assert_eq!(r.physical_columns.columns_len(), 5);
assert!(!r.is_drained.unwrap());
// COUNT
assert_eq!(
r.physical_columns[0].decoded().to_int_vec(),
&[Some(1), Some(2)]
);
// AVG_COUNT
assert_eq!(
r.physical_columns[1].decoded().to_int_vec(),
&[Some(0), Some(2)]
);
// AVG_SUM
assert_eq!(
r.physical_columns[2].decoded().to_real_vec(),
&[None, Real::new(5.0).ok()]
);
// col_0
assert_eq!(
r.physical_columns[3].decoded().to_bytes_vec(),
&[None, None]
);
// col_1
assert_eq!(
r.physical_columns[4].decoded().to_real_vec(),
&[None, Real::new(3.5).ok()]
);
let r = exec.next_batch(1);
assert!(r.logical_rows.is_empty());
assert_eq!(r.physical_columns.rows_len(), 0);
assert!(!r.is_drained.unwrap());
let r = exec.next_batch(1);
assert_eq!(&r.logical_rows, &[0]);
assert_eq!(r.physical_columns.rows_len(), 1);
assert_eq!(r.physical_columns.columns_len(), 5);
assert!(r.is_drained.unwrap());
// COUNT
assert_eq!(r.physical_columns[0].decoded().to_int_vec(), &[Some(5)]);
// AVG_COUNT
assert_eq!(r.physical_columns[1].decoded().to_int_vec(), &[Some(5)]);
// AVG_SUM
assert_eq!(
r.physical_columns[2].decoded().to_real_vec(),
&[Real::new(-20.0).ok()]
);
// col_0
assert_eq!(
r.physical_columns[3].decoded().to_bytes_vec(),
&[Some(b"ABC".to_vec())]
);
// col_1
assert_eq!(
r.physical_columns[4].decoded().to_real_vec(),
&[Real::new(-3.0).ok()]
);
} | rust_cleaned_test_functions.jsonl/97345 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2008
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14631,
11498,
82,
90250,
368,
341,
286,
990,
11552,
65,
486,
16041,
929,
280,
286,
990,
11552,
65,
10418,
486,
16041,
2620,
3297,
401,
286,
442,
1096,
1273,
11450,
264,
4269,
51629,
31558,
448,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_keep_alive_packet() {
let client_idx = 5;
let max_clients = 10;
test_encode_decode(
Packet::KeepAlive(KeepAlivePacket {
client_idx,
max_clients,
}),
None,
None,
|p| match p {
Packet::KeepAlive(p) => {
assert_eq!(p.client_idx, client_idx);
}
_ => assert!(false),
},
);
} | rust_cleaned_test_functions.jsonl/18957 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 262
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
50293,
58850,
21078,
368,
341,
262,
1077,
2943,
7258,
284,
220,
20,
280,
262,
1077,
1932,
56899,
284,
220,
16,
15,
401,
262,
1273,
11224,
15227,
1006,
286,
28889,
486,
19434,
32637,
7,
19434,
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... | 2 |
#[test]
fn test_forall_with_dots_on_rhs() -> TestResult {
let p = polar();
p.load_str("goo(x, y) if forall(z in y, z.n < x);")?;
qeval(&p, "goo(10, [])");
qeval(&p, "goo(10, [{n:1}, {n:2}, {n:3}])");
qnull(&p, "goo(10, [{n:11}, {n:10}, {n:9}])");
Ok(())
} | rust_cleaned_test_functions.jsonl/68150 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 163
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5478,
541,
6615,
814,
2412,
4470,
64537,
368,
1464,
3393,
2077,
341,
262,
1077,
281,
284,
24660,
543,
262,
281,
5104,
2895,
445,
62048,
2075,
11,
379,
8,
421,
31647,
13174,
304,
379,
11,
1147,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_encode_non_fqdn() {
let name_bytes: &[u8] = b"issueexample.com";
let header: &[u8] = &[128, 5];
let encoded: Vec<u8> = header
.into_iter()
.chain(name_bytes.iter())
.map(|b| *b)
.collect();
test_encode(
CAA::new_issue(
true,
Some(Name::parse("example.com", None).unwrap()),
vec![],
),
&encoded,
);
} | rust_cleaned_test_functions.jsonl/24520 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 310
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11224,
21637,
761,
80,
17395,
368,
341,
286,
1077,
829,
12524,
25,
44590,
84,
23,
60,
284,
293,
1,
11159,
8687,
905,
876,
286,
1077,
4247,
25,
44590,
84,
23,
60,
284,
44590,
16,
17,
23,
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_config_validate() {
let mut cfg = Config::default();
cfg.validate().unwrap();
cfg = Config::default();
cfg.region_max_size = ReadableSize(10);
cfg.region_split_size = ReadableSize(20);
assert!(cfg.validate().is_err());
cfg = Config::default();
cfg.region_max_keys = 10;
cfg.region_split_keys = 20;
assert!(cfg.validate().is_err());
} | rust_cleaned_test_functions.jsonl/94481 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 213
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5332,
42681,
368,
341,
286,
1077,
5206,
13286,
284,
5532,
486,
2258,
543,
286,
13286,
19520,
1005,
15454,
1428,
286,
13286,
284,
5532,
486,
2258,
543,
286,
13286,
42976,
6345,
2368,
284,
4457,
480... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_hdlr() {
let src_box = HdlrBox {
version: 0,
flags: 0,
handler_type: str::parse::<FourCC>("vide").unwrap(),
name: String::from("VideoHandler"),
};
let mut buf = Vec::new();
src_box.write_box(&mut buf).unwrap();
assert_eq!(buf.len(), src_box.box_size() as usize);
let mut reader = Cursor::new(&buf);
let header = BoxHeader::read(&mut reader).unwrap();
assert_eq!(header.name, BoxType::HdlrBox);
assert_eq!(src_box.box_size(), header.size);
let dst_box = HdlrBox::read_box(&mut reader, header.size).unwrap();
assert_eq!(src_box, dst_box);
} | rust_cleaned_test_functions.jsonl/64032 | {
"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,
66154,
81,
368,
341,
286,
1077,
2286,
10194,
284,
472,
8736,
81,
1611,
341,
310,
2319,
25,
220,
15,
345,
310,
8042,
25,
220,
15,
345,
310,
7013,
1819,
25,
607,
486,
6400,
27638,
26972,
3706,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_bytea_params() {
test_type(
"BYTEA",
&[
(Some(vec![0u8, 1, 2, 3, 254, 255]), "'\\x00010203feff'"),
(None, "NULL"),
],
);
} | rust_cleaned_test_functions.jsonl/120855 | {
"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,
19737,
64,
6745,
368,
341,
262,
1273,
1819,
1006,
286,
330,
33908,
32,
756,
286,
609,
9640,
310,
320,
8373,
25592,
20703,
15,
84,
23,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
17,
20... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_from_signed_bytes_le() {
fn check(s: &[u8], result: &str) {
assert_eq!(
BigInt::from_signed_bytes_le(s),
BigInt::parse_bytes(result.as_bytes(), 10).unwrap()
);
}
check(&[], "0");
check(&[0], "0");
check(&[0; 10], "0");
check(&[0xff, 0x7f], "32767");
check(&[0xff], "-1");
check(&[0, 0, 0, 1], "16777216");
check(&[156], "-100");
check(&[0, 0, 0x80], "-8388608");
check(&[0xff; 10], "-1");
check(&[0x40, 0xff], "-192");
} | rust_cleaned_test_functions.jsonl/56611 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 281
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5673,
55617,
12524,
11751,
368,
341,
262,
5168,
1779,
1141,
25,
44590,
84,
23,
1125,
1102,
25,
609,
495,
8,
341,
286,
2060,
10714,
33673,
310,
62608,
486,
1499,
55617,
12524,
11751,
1141,
1326,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_double_initialize() {
let location = TempLocation::new();
request_stream_test(
location.to_persistent_lifetime(),
create_clean_pre_auth_manager(),
None,
Arc::new(Inspector::new()),
|proxy| async move {
proxy.create_account(None).await??;
assert_eq!(proxy.create_account(None).await?, Err(ApiError::FailedPrecondition));
Ok(())
},
);
} | rust_cleaned_test_functions.jsonl/105833 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 266
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
24598,
40889,
368,
341,
286,
1077,
3728,
284,
19944,
4707,
486,
931,
543,
286,
1681,
12673,
4452,
1006,
310,
3728,
2389,
620,
13931,
98827,
3148,
310,
1855,
19573,
10442,
14014,
12144,
3148,
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_partial_trie_update_whole_trie() {
let trie1 = build_test_trie();
let mut read_ctx: ReadTrieContext<Key, _, _> = ReadTrieContext::new(&trie1, trie1.root);
read_ctx.read(&key!("0a77d337")).unwrap();
read_ctx.read(&key!("0b123456")).unwrap();
let partial_trie1: PartialTrie = read_ctx.into_proof().into();
assert_eq!(trie1.root, partial_trie1.root_hash());
let partial_trie2 = PartialTrie::from_root_hash(trie1.root);
let diff = diff_missing_branches(&partial_trie2, &partial_trie1);
let partial_trie3 = apply_diff(&partial_trie2, &diff, true).unwrap();
assert_eq!(trie1.root, partial_trie3.root_hash());
let diff2 = PartialTrieDiff::diff_from_empty(&partial_trie1);
assert_eq!(diff, diff2);
let partial_trie4 = diff2.to_standalone_trie().unwrap();
assert_eq!(trie1.root, partial_trie4.root_hash());
} | rust_cleaned_test_functions.jsonl/16371 | {
"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,
52068,
3547,
645,
8882,
36225,
1263,
3547,
645,
368,
341,
262,
1077,
59067,
16,
284,
1936,
4452,
3547,
645,
1428,
262,
1077,
5206,
1349,
15147,
25,
4457,
51,
7231,
1972,
42003,
11,
8358,
716,
29... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_fs_fsentry_hidden_files() {
let t_now: SystemTime = SystemTime::now();
let entry: FsEntry = FsEntry::File(FsFile {
name: String::from("bar.txt"),
abs_path: PathBuf::from("/bar.txt"),
last_change_time: t_now,
last_access_time: t_now,
creation_time: t_now,
size: 8192,
readonly: false,
ftype: Some(String::from("txt")),
symlink: None, // UNIX only
user: Some(0), // UNIX only
group: Some(0), // UNIX only
unix_pex: Some((6, 4, 4)), // UNIX only
});
assert_eq!(entry.is_hidden(), false);
let entry: FsEntry = FsEntry::File(FsFile {
name: String::from(".gitignore"),
abs_path: PathBuf::from("/.gitignore"),
last_change_time: t_now,
last_access_time: t_now,
creation_time: t_now,
size: 8192,
readonly: false,
ftype: Some(String::from("txt")),
symlink: None, // UNIX only
user: Some(0), // UNIX only
group: Some(0), // UNIX only
unix_pex: Some((6, 4, 4)), // UNIX only
});
assert_eq!(entry.is_hidden(), true);
let entry: FsEntry = FsEntry::Directory(FsDirectory {
name: String::from(".git"),
abs_path: PathBuf::from("/.git"),
last_change_time: t_now,
last_access_time: t_now,
creation_time: t_now,
readonly: false,
symlink: None, // UNIX only
user: Some(0), // UNIX only
group: Some(0), // UNIX only
unix_pex: Some((7, 5, 5)), // UNIX only
});
assert_eq!(entry.is_hidden(), true);
} | rust_cleaned_test_functions.jsonl/38164 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1070
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34470,
34470,
4085,
26739,
10931,
368,
341,
286,
1077,
259,
20813,
25,
739,
1462,
284,
739,
1462,
486,
3328,
543,
286,
1077,
4343,
25,
84619,
5874,
284,
84619,
5874,
486,
1703,
7832,
82,
1703,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_decode_select1() {
let n = 100;
let mut rng: StdRng = SeedableRng::from_seed([0; 32]);
for _ in 0..n {
let bits: u64 = rng.gen();
let k = bits.count_ones() as u8;
let mut ans = 0;
for r in 0..k {
while ans < 64 {
if bits & (1 << ans) > 0 {
break;
}
ans += 1;
}
assert_eq!(decode_select1(encode(bits, k).0, k, r), ans);
ans += 1;
}
}
} | rust_cleaned_test_functions.jsonl/50477 | {
"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,
15227,
13051,
16,
368,
341,
286,
1077,
308,
284,
220,
16,
15,
15,
280,
286,
1077,
5206,
28422,
25,
42517,
49,
968,
284,
35822,
480,
49,
968,
486,
1499,
33809,
2561,
15,
26,
220,
18,
17,
2558... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_ops_precedence() -> Result<(), Box<EvalAltResult>> {
let engine = Engine::new();
assert_eq!(
engine.eval::<INT>("let x = 0; if x == 10 || true { x = 1} x")?,
1
);
Ok(())
} | rust_cleaned_test_functions.jsonl/49954 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 110
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21959,
10442,
1998,
763,
368,
1464,
5714,
68843,
8261,
23835,
831,
26017,
2077,
2452,
341,
262,
1077,
4712,
284,
8200,
486,
931,
1428,
262,
2060,
10714,
33673,
286,
4712,
31710,
27638,
3221,
13211,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_error_for_status_4xx() {
let server = server! {
request: b"\
GET /1 HTTP/1.1\r\n\
user-agent: $USERAGENT\r\n\
accept: */*\r\n\
accept-encoding: gzip\r\n\
host: $HOST\r\n\
\r\n\
",
response: b"\
HTTP/1.1 400 OK\r\n\
Server: test\r\n\
Content-Length: 0\r\n\
\r\n\
"
};
let url = format!("http://{}/1", server.addr());
let res = reqwest::get(&url).unwrap();
let err = res.error_for_status().err().unwrap();
assert!(err.is_client_error());
assert_eq!(err.status(), Some(reqwest::StatusCode::BAD_REQUEST));
} | rust_cleaned_test_functions.jsonl/26237 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 410
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4096,
5478,
4773,
62,
19,
4146,
368,
341,
262,
1077,
3538,
284,
3538,
0,
341,
286,
1681,
25,
293,
83383,
310,
7890,
608,
16,
10130,
14,
16,
13,
16,
12016,
1699,
5661,
310,
1196,
41935,
25,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_bit_or() {
let mut ctx = EvalContext::default();
let function = AggrFnBitOp::<BitOr>(std::marker::PhantomData);
let mut state = function.create_state();
let mut result = [VectorValue::with_capacity(0, EvalType::Int)];
state.push_result(&mut ctx, &mut result).unwrap();
assert_eq!(result[0].to_int_vec(), &[Some(0)]);
update!(state, &mut ctx, Option::<&Int>::None).unwrap();
result[0].clear();
state.push_result(&mut ctx, &mut result).unwrap();
assert_eq!(result[0].to_int_vec(), &[Some(0)]);
update!(state, &mut ctx, Some(&1i64)).unwrap();
result[0].clear();
state.push_result(&mut ctx, &mut result).unwrap();
assert_eq!(result[0].to_int_vec(), &[Some(1)]);
update!(state, &mut ctx, Some(&4i64)).unwrap();
result[0].clear();
state.push_result(&mut ctx, &mut result).unwrap();
assert_eq!(result[0].to_int_vec(), &[Some(5)]);
update_repeat!(state, &mut ctx, Some(&8), 10).unwrap();
update_repeat!(state, &mut ctx, Option::<&Int>::None, 7).unwrap();
result[0].clear();
state.push_result(&mut ctx, &mut result).unwrap();
assert_eq!(result[0].to_int_vec(), &[Some(13)]);
update!(state, &mut ctx, Some(&2i64)).unwrap();
let chunked_vec: ChunkedVecSized<Int> = vec![Some(2i64), None, Some(1i64)].into();
update_vector!(state, &mut ctx, chunked_vec, &[0, 1, 2]).unwrap();
result[0].clear();
state.push_result(&mut ctx, &mut result).unwrap();
assert_eq!(result[0].to_int_vec(), &[Some(15)]);
update!(state, &mut ctx, Some(&2i64)).unwrap();
result[0].clear();
state.push_result(&mut ctx, &mut result).unwrap();
assert_eq!(result[0].to_int_vec(), &[Some(15)]);
update!(state, &mut ctx, Some(&-1i64)).unwrap();
result[0].clear();
state.push_result(&mut ctx, &mut result).unwrap();
assert_eq!(
result[0].to_int_vec(),
&[Some(18446744073709551615u64 as i64)]
);
} | rust_cleaned_test_functions.jsonl/23518 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1047
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13996,
8734,
368,
341,
286,
1077,
5206,
5635,
284,
58239,
1972,
486,
2258,
543,
286,
1077,
729,
284,
4598,
901,
24911,
8344,
7125,
27638,
8344,
2195,
2235,
1834,
486,
27742,
486,
3357,
30002,
1043... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_csp_get_message_1() {
let json = r#"{
"csp-report": {
"document-uri": "http://example.com/foo",
"effective-directive": "style-src",
"blocked-uri": ""
}
}"#;
let mut event = Event::default();
Csp::apply_to_event(json.as_bytes(), &mut event).unwrap();
let message = &event.logentry.value().unwrap().formatted;
insta::assert_debug_snapshot!(message.as_str().unwrap(), @r###""Blocked inline \'style\'""###);
} | rust_cleaned_test_functions.jsonl/4028 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 280
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
666,
2154,
3062,
6462,
62,
16,
368,
341,
286,
1077,
2951,
284,
435,
55543,
515,
310,
330,
66,
2154,
47411,
788,
341,
394,
330,
6062,
87232,
788,
330,
1254,
1110,
8687,
905,
60555,
756,
394,
33... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_unrelayable() {
let caller = Address::from_hex("0x755cdba6ae4f479f7164792b318b2a06c759833b").unwrap();
let mut service = TestService::new();
let ctx = mock_context(caller);
// test create_asset
let asset = service
.create_asset(ctx.clone(), CreateAssetPayload {
name: "Cat9".to_owned(),
symbol: "MIMI".to_owned(),
admin: Address::from_hex(ADMIN).unwrap(),
supply: 10000,
init_mints: vec![IssuerWithBalance {
addr: Address::from_hex(<&str>::clone(&ADMIN)).unwrap(),
balance: 10000,
}],
precision: 100,
relayable: false,
})
.succeed_data;
let resp = service.relay(ctx, RelayAssetPayload {
asset_id: asset.id,
amount: 100,
proof: Hex::from_string("0xaaBB".to_owned()).unwrap(),
memo: "".to_owned(),
});
assert!(resp.is_error())
} | rust_cleaned_test_functions.jsonl/32949 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 518
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4907,
90891,
480,
368,
341,
262,
1077,
19865,
284,
9177,
486,
1499,
32655,
445,
15,
87,
22,
20,
20,
85301,
64,
21,
5918,
19,
69,
19,
22,
24,
69,
22,
16,
21,
19,
22,
24,
17,
65,
18,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_fold_useless_for_integration() {
test("for(;!true;) { foo() }", "");
test("for(;void 0;) { foo() }", "");
test("for(;undefined;) { foo() }", "");
test("for(;1;) foo()", "for(;;) foo()");
test("for(;!void 0;) foo()", "for(;;) foo()");
// Make sure proper empty nodes are inserted.
test(
"if(foo())for(;false;){foo()}else bar()",
"if (foo()); else bar();",
);
} | rust_cleaned_test_functions.jsonl/114464 | {
"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,
61187,
15951,
1717,
5478,
90250,
368,
341,
262,
1273,
445,
1958,
54924,
0,
1866,
36174,
314,
15229,
368,
335,
497,
14498,
262,
1273,
445,
1958,
54924,
1004,
220,
15,
36174,
314,
15229,
368,
335,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_aggsig_single() {
let secp = Secp256k1::with_caps(ContextFlag::Full);
let (sk, pk) = secp.generate_keypair(&mut thread_rng()).unwrap();
println!(
"Performing aggsig single context with seckey, pubkey: {:?},{:?}",
sk, pk
);
let mut msg = [0u8; 32];
thread_rng().fill(&mut msg);
let msg = Message::from_slice(&msg).unwrap();
let sig = sign_single(&secp, &msg, &sk, None, None, None, None, None).unwrap();
println!(
"Verifying aggsig single: {:?}, msg: {:?}, pk:{:?}",
sig, msg, pk
);
let result = verify_single(&secp, &sig, &msg, None, &pk, None, None, false);
println!("Signature verification single (correct): {}", result);
assert!(result == true);
let mut msg = [0u8; 32];
thread_rng().fill(&mut msg);
let msg = Message::from_slice(&msg).unwrap();
println!(
"Verifying aggsig single: {:?}, msg: {:?}, pk:{:?}",
sig, msg, pk
);
let result = verify_single(&secp, &sig, &msg, None, &pk, None, None, false);
println!("Signature verification single (wrong message): {}", result);
assert!(result == false);
// test optional extra key
let mut msg = [0u8; 32];
thread_rng().fill(&mut msg);
let msg = Message::from_slice(&msg).unwrap();
let (sk_extra, pk_extra) = secp.generate_keypair(&mut thread_rng()).unwrap();
let sig = sign_single(&secp, &msg, &sk, None, Some(&sk_extra), None, None, None).unwrap();
let result = verify_single(&secp, &sig, &msg, None, &pk, None, Some(&pk_extra), false);
assert!(result == true);
} | rust_cleaned_test_functions.jsonl/15034 | {
"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,
20587,
5857,
343,
19487,
368,
341,
197,
10217,
511,
4672,
284,
4520,
79,
17,
20,
21,
74,
16,
486,
4197,
52955,
14001,
12135,
486,
9432,
317,
197,
10217,
320,
4886,
11,
22458,
8,
284,
511,
4672... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_distribute_mnt_tokens_to_suppliers() {
ExtBuilder::default()
.enable_minting_for_all_pools(10 * DOLLARS)
.mnt_account_balance(MNT_PALLET_START_BALANCE)
.set_mnt_claim_threshold(0)
// total borrows needs to calculate mnt_speeds
.pool_total_borrowed(DOT, 50 * DOLLARS)
.build()
.execute_with(|| {
let alice_balance = 20 * DOLLARS;
let bob_balance = 80 * DOLLARS;
let alice_award_per_block = 2 * DOLLARS;
let bob_award_per_block = 8 * DOLLARS;
// set total issuance
Currencies::deposit(MDOT, &ALICE, alice_balance).unwrap();
Currencies::deposit(MDOT, &BOB, bob_balance).unwrap();
let move_flywheel = || {
MntToken::update_mnt_supply_index(DOT).unwrap();
MntToken::distribute_supplier_mnt(DOT, &ALICE, false).unwrap();
MntToken::distribute_supplier_mnt(DOT, &BOB, false).unwrap();
};
let check_supplier_award =
|supplier_id: AccountId, distributed_amount: Balance, expected_user_mnt_balance: Balance| {
let pool_state = MntToken::mnt_pools_state(DOT);
let supplier_index = MntToken::mnt_supplier_index(DOT, supplier_id).unwrap();
assert_eq!(supplier_index, pool_state.supply_state.mnt_distribution_index);
assert_eq!(get_mnt_account_balance(supplier_id), expected_user_mnt_balance);
// it should be 0 because threshold is 0
assert_eq!(MntToken::mnt_accrued(supplier_id), 0);
let supplier_index = MntToken::mnt_supplier_index(DOT, supplier_id).unwrap();
let event = Event::MntToken(crate::Event::MntDistributedToSupplier(
DOT,
supplier_id,
distributed_amount,
supplier_index,
));
assert!(System::events().iter().any(|record| record.event == event));
};
/* -------TEST SCENARIO------- */
move_flywheel();
check_supplier_award(ALICE, alice_award_per_block, alice_award_per_block);
check_supplier_award(BOB, bob_award_per_block, bob_award_per_block);
// Go from first block to third
System::set_block_number(3);
let current_block = 3;
let block_delta = 2;
move_flywheel();
check_supplier_award(
BOB,
bob_award_per_block * block_delta,
bob_award_per_block * current_block,
);
check_supplier_award(
ALICE,
alice_award_per_block * block_delta,
alice_award_per_block * current_block,
);
assert_eq!(
MNT_PALLET_START_BALANCE - get_mnt_account_balance(ALICE) - get_mnt_account_balance(BOB),
get_mnt_account_balance(MntToken::get_account_id())
)
});
} | rust_cleaned_test_functions.jsonl/115705 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1112
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
814,
80133,
717,
406,
28838,
2346,
23723,
15178,
368,
341,
76605,
3297,
486,
2258,
741,
197,
197,
28697,
717,
396,
287,
5478,
5705,
620,
6178,
7,
16,
15,
353,
422,
21535,
17048,
340,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_split_into_sections() {
let data = vec![
"0: 4 1 5",
"1: 2 3 | 3 2",
"2: 4 4 | 5 5",
"3: 4 5 | 5 4",
"4: \"a\"",
"5: \"b\"",
"",
"ababbb",
"bababa",
"abbbab",
"aaabbb",
"aaaabbb",
];
let (rules, messages) = split_into_sections(&data);
assert_eq!(rules.len(), 6);
assert_eq!(messages.len(), 5);
} | rust_cleaned_test_functions.jsonl/50122 | {
"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,
17052,
45514,
59485,
368,
341,
262,
1077,
821,
284,
7486,
90515,
414,
330,
15,
25,
220,
19,
220,
16,
220,
20,
756,
414,
330,
16,
25,
220,
17,
220,
18,
760,
220,
18,
220,
17,
756,
414,
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_double_underscores_ignored() {
let hdr = indoc! {"
#include <cstdint>
struct __FOO {
uint32_t a;
};
struct B {
B() :a(1) {}
uint32_t take_foo(__FOO a) const {
return 3;
}
void do__something() const { }
uint32_t get_a() const { return 2; }
uint32_t a;
};
"};
let rs = quote! {
let b = ffi::B::make_unique();
assert_eq!(b.get_a(), 2);
};
run_test("", hdr, rs, &["B"], &[]);
} | rust_cleaned_test_functions.jsonl/9876 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 287
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
24598,
62,
31009,
7701,
62,
58471,
368,
341,
262,
1077,
36615,
284,
1257,
509,
0,
314,
698,
262,
671,
997,
366,
96975,
397,
262,
2036,
1304,
3788,
46,
341,
286,
2622,
18,
17,
528,
264,
280,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_sha256t() {
assert_eq!(
TestHash::hash(&[0]).to_hex(),
"29589d5122ec666ab5b4695070b6debc63881a4f85d88d93ddc90078038213ed"
);
} | rust_cleaned_test_functions.jsonl/83782 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 115
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
48836,
17,
20,
21,
83,
368,
341,
981,
2060,
10714,
33673,
1843,
3393,
6370,
486,
8296,
2099,
58,
15,
10697,
983,
32655,
3148,
1843,
330,
17,
24,
20,
23,
24,
67,
20,
16,
17,
17,
757,
21,
21... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_jlt_imm() {
test_interpreter_and_jit_asm!(
"
mov32 r0, 0
mov32 r1, 5
jlt r1, 4, +2
jlt r1, 5, +1
jlt r1, 6, +1
exit
mov32 r0, 1
exit",
[],
(),
{ |_vm, res: Result| { res.unwrap() == 0x1 } },
7
);
} | rust_cleaned_test_functions.jsonl/59016 | {
"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,
5374,
4832,
71370,
368,
341,
262,
1273,
15318,
28637,
8378,
5374,
275,
67529,
33673,
286,
6228,
286,
1974,
18,
17,
435,
15,
11,
220,
15,
198,
286,
1974,
18,
17,
435,
16,
11,
220,
20,
198,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_check_details_length() {
let short_details = (0..MAX_LONG_FIELD_LENGTH).map(|_| "X").collect::<String>();
assert_eq!(check_details_length(short_details), Ok(()));
let long_details = (0..MAX_LONG_FIELD_LENGTH + 1)
.map(|_| "X")
.collect::<String>();
assert_eq!(
check_details_length(long_details),
Err(format!(
"validator details longer than {:?}-byte limit",
MAX_LONG_FIELD_LENGTH
))
);
} | rust_cleaned_test_functions.jsonl/12690 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 289
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7200,
13260,
5118,
368,
341,
286,
1077,
2805,
13260,
284,
320,
15,
496,
10586,
19903,
17354,
15023,
568,
2186,
22428,
35395,
330,
55,
1827,
17384,
27638,
703,
3913,
286,
2060,
10714,
10297,
2028,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_postprocessors() {
let tmp_dir = TempDir::new().expect("failed to make tempdir");
let mut exporter = Exporter::new(
PathBuf::from("tests/testdata/input/postprocessors"),
tmp_dir.path().to_path_buf(),
);
exporter.add_postprocessor(&foo_to_bar);
exporter.add_postprocessor(&append_frontmatter);
exporter.run().unwrap();
let expected = read_to_string("tests/testdata/expected/postprocessors/Note.md").unwrap();
let actual = read_to_string(tmp_dir.path().clone().join(PathBuf::from("Note.md"))).unwrap();
assert_eq!(expected, actual);
} | rust_cleaned_test_functions.jsonl/116606 | {
"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,
6333,
81748,
368,
341,
262,
1077,
4174,
4334,
284,
19944,
6184,
486,
931,
1005,
17119,
445,
16091,
311,
1281,
2730,
3741,
797,
262,
1077,
5206,
57378,
284,
22191,
261,
486,
931,
1006,
286,
7933,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_store2() {
FLOAT_RESULT.with(|result| {
*result.borrow_mut() = 0.0;
});
let mut vm = VirtualMachine::new();
vm.add_class(Class::new(
"Point".to_owned(),
vec![
Field::new("x".to_owned(), TypeId::Float32),
Field::new("y".to_owned(), TypeId::Float32),
]
));
vm.add_external_function(
FunctionDeclaration::with_external(
"set_float".to_owned(), vec![TypeId::Float32], TypeId::Void,
set_float as *mut std::ffi::c_void
)
);
vm.add_function(Function::new(
FunctionDeclaration::with_managed("main".to_owned(), Vec::new(), TypeId::Int32),
vec![TypeId::Class("Point".to_owned())],
vec![
Instruction::NewObject("Point".to_owned()),
Instruction::StoreLocal(0),
Instruction::LoadLocal(0),
Instruction::LoadFloat32(1337.0),
Instruction::StoreField("Point".to_owned(), "x".to_owned()),
Instruction::LoadLocal(0),
Instruction::LoadFloat32(4711.0),
Instruction::StoreField("Point".to_owned(), "y".to_owned()),
Instruction::LoadLocal(0),
Instruction::LoadField("Point".to_owned(), "x".to_owned()),
Instruction::LoadLocal(0),
Instruction::LoadField("Point".to_owned(), "y".to_owned()),
Instruction::Add,
Instruction::Call(FunctionSignature::new("set_float".to_owned(), vec![TypeId::Float32])),
Instruction::LoadInt32(0),
Instruction::Return,
]
)).unwrap();
let execution_result = vm.execute().unwrap();
assert_eq!(0, execution_result);
assert_eq!(1337.0 + 4711.0, FLOAT_RESULT.with(|result| *result.borrow()));
} | rust_cleaned_test_functions.jsonl/17394 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 838
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14809,
17,
368,
341,
262,
50116,
21181,
18164,
22428,
1382,
91,
341,
286,
353,
1382,
83640,
29523,
368,
284,
220,
15,
13,
15,
280,
262,
3011,
262,
1077,
5206,
10995,
284,
20721,
21605,
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_root_mean_squared_error_rgb() {
let left = rgb_image!([1, 2, 3], [4, 5, 6]);
let right = rgb_image!([8, 4, 7], [6, 9, 1]);
let rms = root_mean_squared_error(&left, &right);
let expected = (114f64 / 6f64).sqrt();
assert_eq!(rms, expected);
} | rust_cleaned_test_functions.jsonl/38569 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 157
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12993,
16933,
54641,
4096,
37407,
368,
341,
286,
1077,
2115,
284,
17993,
4954,
0,
2561,
16,
11,
220,
17,
11,
220,
18,
1125,
508,
19,
11,
220,
20,
11,
220,
21,
2558,
286,
1077,
1290,
284,
179... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_validate_instruction_evaluates_comparison_to_registry() {
let mut test_hash: HashMap<String, i32> = HashMap::new();
test_hash.insert("foo".to_string(), 10);
test_hash.insert("bar".to_string(), -10);
assert_eq!(false, validate_instruction(&mut test_hash, "foo", "<", 10));
assert_eq!(true, validate_instruction(&mut test_hash, "foo", "<=", 10));
assert_eq!(false, validate_instruction(&mut test_hash, "foo", ">", 10));
assert_eq!(true, validate_instruction(&mut test_hash, "foo", ">=", 10));
assert_eq!(true, validate_instruction(&mut test_hash, "foo", "==", 10));
assert_eq!(false, validate_instruction(&mut test_hash, "foo", "!=", 10));
assert_eq!(false, validate_instruction(&mut test_hash, "bar", "<", -10));
assert_eq!(true, validate_instruction(&mut test_hash, "bar", "<=", -10));
assert_eq!(false, validate_instruction(&mut test_hash, "bar", ">", -10));
assert_eq!(true, validate_instruction(&mut test_hash, "bar", ">=", -10));
assert_eq!(true, validate_instruction(&mut test_hash, "bar", "==", -10));
assert_eq!(false, validate_instruction(&mut test_hash, "bar", "!=", -10));
assert_eq!(false, validate_instruction(&mut test_hash, "baz", ">", 10));
assert_eq!(true, validate_instruction(&mut test_hash, "hello", "==", 0));
} | rust_cleaned_test_functions.jsonl/42002 | {
"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,
42681,
54923,
21296,
50985,
90797,
2346,
50650,
368,
341,
286,
1077,
5206,
1273,
8950,
25,
10528,
3464,
11,
600,
18,
17,
29,
284,
10528,
486,
931,
543,
286,
1273,
8950,
7030,
445,
7975,
3263,
98... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_tokens() {
let mut bucket = GenericTokenBucket::new();
bucket.empty::<RealTimeClock>();
bucket.refill::<RealTimeClock>(20);
assert_eq!(bucket.check::<RealTimeClock>(10), true);
bucket.deplete::<RealTimeClock>(40);
assert_eq!(bucket.check::<RealTimeClock>(10), false);
} | rust_cleaned_test_functions.jsonl/36840 | {
"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,
28838,
368,
341,
262,
1077,
5206,
15621,
284,
21281,
3323,
36018,
486,
931,
543,
262,
15621,
9178,
27638,
12768,
1462,
26104,
3913,
262,
15621,
11053,
483,
27638,
12768,
1462,
26104,
2235,
17,
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_ordering() {
use persian_rug::Owner;
let mut s: State = Default::default();
let f1 = s.add(Foo {
a: 1,
_marker: Default::default(),
});
let f2 = s.add(Foo {
a: 2,
_marker: Default::default(),
});
let f3 = s.add(Foo {
a: 3,
_marker: Default::default(),
});
let f4 = s.add(Foo {
a: 4,
_marker: Default::default(),
});
let f5 = s.add(Foo {
a: 5,
_marker: Default::default(),
});
let b1 = s.add(Bar { a: 2, foo: f1 });
let b2 = s.add(Bar { a: 1, foo: f2 });
let b3 = s.add(Bar { a: 3, foo: f3 });
let b4 = s.add(Bar { a: 4, foo: f4 });
let b5 = s.add(Bar { a: 5, foo: f5 });
s.add(Baz { a: 3, bar: b1 });
s.add(Baz { a: 1, bar: b2 });
s.add(Baz { a: 2, bar: b3 });
s.add(Baz { a: 4, bar: b4 });
s.add(Baz { a: 5, bar: b5 });
let os =
::django_query::sorting::OrderingSetWithContext::<persian_rug::Proxy<Foo<State>>, _>::new(
&s,
);
let mut foos = s.get_proxy_iter().copied().collect();
let sort = os.create_sort("a").unwrap();
sort.sort_vec(&mut foos);
println!("Foos: {:?}", foos);
let os =
::django_query::sorting::OrderingSetWithContext::<persian_rug::Proxy<Bar<State>>, _>::new(
&s,
);
let mut bars = s.get_proxy_iter().copied().collect();
let sort = os.create_sort("a").unwrap();
sort.sort_vec(&mut bars);
println!("Bars (by a): {:?}", bars);
let sort = os.create_sort("foo").unwrap();
sort.sort_vec(&mut bars);
println!("Bars (by foo): {:?}", bars);
let os =
::django_query::sorting::OrderingSetWithContext::<persian_rug::Proxy<Baz<State>>, _>::new(
&s,
);
let mut bazs = s.get_proxy_iter().copied().collect();
let sort = os.create_sort("a").unwrap();
sort.sort_vec(&mut bazs);
println!("Bazs (by a): {:?}", bazs);
let sort = os.create_sort("bar").unwrap();
sort.sort_vec(&mut bazs);
println!("Bazs (by bar): {:?}", bazs);
} | rust_cleaned_test_functions.jsonl/128427 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1043
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7869,
287,
368,
341,
262,
990,
7413,
1103,
1710,
768,
486,
13801,
401,
262,
1077,
5206,
274,
25,
3234,
284,
7899,
486,
2258,
1428,
262,
1077,
282,
16,
284,
274,
1364,
7832,
2624,
341,
286,
264... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_sentence_type_enum() {
// So we don't trip over the max value of u128 when shifting it with
// SentenceType as u32
assert!((SentenceType::None as u32) < 127);
} | rust_cleaned_test_functions.jsonl/65865 | {
"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,
48332,
1819,
31054,
368,
341,
286,
442,
2055,
582,
1513,
944,
8411,
916,
279,
1932,
897,
315,
575,
16,
17,
23,
979,
31831,
432,
448,
198,
286,
442,
79542,
929,
438,
575,
18,
17,
198,
286,
20... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_map_loading() {
match Tilemap::by_name("map001") {
Ok(_) => {
// Success!
}
Err(e) => panic!("{}", e),
}
} | rust_cleaned_test_functions.jsonl/55962 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 102
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5376,
57726,
368,
341,
262,
2432,
20744,
2186,
486,
1694,
1269,
445,
2186,
15,
15,
16,
899,
341,
286,
7622,
48139,
589,
341,
310,
442,
13047,
4894,
286,
335,
715,
286,
15495,
2026,
8,
589,
219... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_readlines() {
let req = TestRequest::default()
.set_payload(Bytes::from_static(
b"Lorem Ipsum is simply dummy text of the printing and typesetting\n\
industry. Lorem Ipsum has been the industry's standard dummy\n\
Contrary to popular belief, Lorem Ipsum is not simply random text.",
))
.finish();
let mut r = Readlines::new(&req);
match r.poll().ok().unwrap() {
Async::Ready(Some(s)) => assert_eq!(
s,
"Lorem Ipsum is simply dummy text of the printing and typesetting\n"
),
_ => unreachable!("error"),
}
match r.poll().ok().unwrap() {
Async::Ready(Some(s)) => assert_eq!(
s,
"industry. Lorem Ipsum has been the industry's standard dummy\n"
),
_ => unreachable!("error"),
}
match r.poll().ok().unwrap() {
Async::Ready(Some(s)) => assert_eq!(
s,
"Contrary to popular belief, Lorem Ipsum is not simply random text."
),
_ => unreachable!("error"),
}
} | rust_cleaned_test_functions.jsonl/7656 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 632
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
7969,
368,
341,
286,
1077,
4232,
284,
3393,
1900,
486,
2258,
741,
310,
659,
746,
32813,
76423,
486,
1499,
25360,
1006,
394,
293,
1,
32783,
61362,
374,
4936,
17292,
1467,
315,
279,
18484,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
#[test]
fn test_handle_breach_rejected() {
let responder = init_responder(MockedServerQuery::Error(
rpc_errors::RPC_VERIFY_ERROR as i64,
));
let user_id = get_random_user_id();
let uuid = generate_uuid();
let breach = get_random_breach();
let penalty_txid = breach.penalty_tx.txid();
assert_eq!(
responder.handle_breach(uuid, breach, user_id),
ConfirmationStatus::Rejected(rpc_errors::RPC_VERIFY_ERROR)
);
assert!(!responder.trackers.lock().unwrap().contains_key(&uuid));
assert!(!responder
.tx_tracker_map
.lock()
.unwrap()
.contains_key(&penalty_txid));
} | rust_cleaned_test_functions.jsonl/55474 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 373
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10630,
880,
22606,
1288,
28303,
368,
341,
286,
1077,
64034,
284,
2930,
4918,
20328,
66436,
291,
5475,
2859,
486,
1454,
1006,
310,
35596,
20196,
486,
29528,
56042,
5414,
438,
600,
21,
19,
345,
286,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_executor_execute_and_commit_chunk() {
let first_batch_size = 30;
let second_batch_size = 40;
let third_batch_size = 20;
let overlapping_size = 5;
let (chunks, ledger_info) = {
let first_batch_start = 1;
let second_batch_start = first_batch_start + first_batch_size;
let third_batch_start = second_batch_start + second_batch_size - overlapping_size;
create_transaction_chunks(vec![
first_batch_start..first_batch_start + first_batch_size,
second_batch_start..second_batch_start + second_batch_size,
third_batch_start..third_batch_start + third_batch_size,
])
};
// Now we execute these two chunks of transactions.
let (config, _) = build_test_config();
let db = create_storage(&config);
let mut executor = Executor::<MockVM>::new(db.clone());
executor
.execute_and_commit_chunk(chunks[0].clone(), ledger_info.clone(), None)
.unwrap();
let li = db.reader.get_latest_ledger_info().unwrap();
assert_eq!(li.ledger_info().version(), 0);
assert_eq!(li.ledger_info().consensus_block_id(), HashValue::zero());
executor
.execute_and_commit_chunk(chunks[1].clone(), ledger_info.clone(), None)
.unwrap();
let li = db.reader.get_latest_ledger_info().unwrap();
assert_eq!(li.ledger_info().version(), 0);
assert_eq!(li.ledger_info().consensus_block_id(), HashValue::zero());
executor
.execute_and_commit_chunk(
TransactionListWithProof::new_empty(),
ledger_info.clone(),
None,
)
.unwrap();
let li = db.reader.get_latest_ledger_info().unwrap();
assert_eq!(li.ledger_info().version(), 0);
assert_eq!(li.ledger_info().consensus_block_id(), HashValue::zero());
executor
.execute_and_commit_chunk(chunks[1].clone(), ledger_info.clone(), None)
.unwrap();
let li = db.reader.get_latest_ledger_info().unwrap();
assert_eq!(li.ledger_info().version(), 0);
assert_eq!(li.ledger_info().consensus_block_id(), HashValue::zero());
executor
.execute_and_commit_chunk(chunks[2].clone(), ledger_info.clone(), None)
.unwrap();
let li = db.reader.get_latest_ledger_info().unwrap();
assert_eq!(li, ledger_info);
} | rust_cleaned_test_functions.jsonl/36532 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1009
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
81207,
44329,
8378,
36346,
30539,
368,
341,
262,
1077,
1156,
14534,
2368,
284,
220,
18,
15,
280,
262,
1077,
2086,
14534,
2368,
284,
220,
19,
15,
280,
262,
1077,
4843,
14534,
2368,
284,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_null_comparison1() {
fold("null == undefined", "true");
fold("null == null", "true");
fold("null == void 0", "true");
fold("null == 0", "false");
fold("null == 1", "false");
fold("null == 'hi'", "false");
fold("null == true", "false");
fold("null == false", "false");
fold("null === undefined", "false");
fold("null === null", "true");
fold("null === void 0", "false");
fold_same("null === x");
fold_same("null == this");
fold_same("null == x");
fold("null != undefined", "false");
fold("null != null", "false");
fold("null != void 0", "false");
fold("null != 0", "true");
fold("null != 1", "true");
fold("null != 'hi'", "true");
fold("null != true", "true");
fold("null != false", "true");
fold("null !== undefined", "true");
fold("null !== void 0", "true");
fold("null !== null", "false");
fold_same("null != this");
fold_same("null != x");
fold("null < null", "false");
fold("null > null", "false");
fold("null >= null", "true");
fold("null <= null", "true");
fold("0 < null", "false");
fold("0 > null", "false");
fold("0 >= null", "true");
fold("true > null", "true");
fold("'hi' < null", "false");
fold("'hi' >= null", "false");
fold("null <= null", "true");
fold("null < 0", "false");
fold("null > true", "false");
fold("null < 'hi'", "false");
fold("null >= 'hi'", "false");
fold("null <= null", "true");
fold("null == null", "true");
fold("0 == null", "false");
fold("1 == null", "false");
fold("'hi' == null", "false");
fold("true == null", "false");
fold("false == null", "false");
fold("null === null", "true");
fold("void 0 === null", "false");
fold("null == NaN", "false");
fold("NaN == null", "false");
fold("null == Infinity", "false");
fold("Infinity == null", "false");
fold("null == -Infinity", "false");
fold("-Infinity == null", "false");
fold("({}) == null", "false");
fold("null == ({})", "false");
fold("([]) == null", "false");
fold("null == ([])", "false");
fold("(/a/g) == null", "false");
fold("null == (/a/g)", "false");
fold("(function(){}) == null", "false");
fold("null == (function(){})", "false");
fold("null != NaN", "true");
fold("NaN != null", "true");
fold("null != Infinity", "true");
fold("Infinity != null", "true");
fold("null != -Infinity", "true");
fold("-Infinity != null", "true");
fold("({}) != null", "true");
fold("null != ({})", "true");
fold("([]) != null", "true");
fold("null != ([])", "true");
fold("(/a/g) != null", "true");
fold("null != (/a/g)", "true");
fold("(function(){}) != null", "true");
fold("null != (function(){})", "true");
fold("({a:f()}) == null", "f(), false;");
fold("null == ({a:f()})", "f(), false");
fold("([f()]) == null", "f(), false");
fold("null == ([f()])", "f(), false");
fold_same("this == null");
fold_same("x == null");
} | rust_cleaned_test_functions.jsonl/122152 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1219
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15162,
90797,
16,
368,
341,
262,
11555,
445,
2921,
621,
5614,
497,
330,
1866,
797,
262,
11555,
445,
2921,
621,
845,
497,
330,
1866,
797,
262,
11555,
445,
2921,
621,
737,
220,
15,
497,
330,
186... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_from_int() {
macro_rules! check {
($ty:ident, $min:expr, $max:expr) => {
assert_eq!(BigInt::from($ty::MIN), $min);
assert_eq!(BigInt::from($ty::MIN + $ty::one()), $min + BigInt::one());
assert_eq!(BigInt::from(-$ty::one()), -BigInt::one());
assert_eq!(BigInt::from($ty::zero()), BigInt::zero());
assert_eq!(BigInt::from($ty::one()), BigInt::one());
assert_eq!(BigInt::from($ty::MAX - $ty::one()), $max - BigInt::one());
assert_eq!(BigInt::from($ty::MAX), $max);
}
}
check!(i8, BigInt::from_slice(Minus, &[1 << 7]),
BigInt::from_slice(Plus, &[i8::MAX as BigDigit]));
check!(i16, BigInt::from_slice(Minus, &[1 << 15]),
BigInt::from_slice(Plus, &[i16::MAX as BigDigit]));
check!(i32, BigInt::from_slice(Minus, &[1 << 31]),
BigInt::from_slice(Plus, &[i32::MAX as BigDigit]));
check!(i64, BigInt::from_slice(Minus, &[0, 1 << 31]),
BigInt::from_slice(Plus, &[u32::MAX as BigDigit, i32::MAX as BigDigit]));
check!(isize, BigInt::from(isize::MIN as i64),
BigInt::from(isize::MAX as i64));
} | rust_cleaned_test_functions.jsonl/90164 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 691
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34910,
5673,
4042,
368,
341,
286,
18072,
21407,
0,
1779,
341,
310,
1711,
1881,
25,
1713,
11,
400,
1065,
96011,
11,
400,
2810,
96011,
8,
589,
341,
394,
2060,
10714,
10297,
87474,
486,
1499,
699,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_rpc_get_account_info() {
let bob_pubkey = solana_sdk::pubkey::new_rand();
let RpcHandler { io, meta, bank, .. } = start_rpc_handler_with_tx(&bob_pubkey);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"getAccountInfo","params":["{}"]}}"#,
bob_pubkey
);
let res = io.handle_request_sync(&req, meta.clone());
let expected = json!({
"jsonrpc": "2.0",
"result": {
"context":{"slot":0},
"value":{
"owner": "11111111111111111111111111111111",
"lamports": 20,
"data": "",
"executable": false,
"rentEpoch": 0
},
},
"id": 1,
});
let expected: Response =
serde_json::from_value(expected).expect("expected response deserialization");
let result: Response = serde_json::from_str(&res.expect("actual response"))
.expect("actual response deserialization");
assert_eq!(expected, result);
let address = solana_sdk::pubkey::new_rand();
let data = vec![1, 2, 3, 4, 5];
let mut account = AccountSharedData::new(42, 5, &Pubkey::default());
account.set_data(data.clone());
bank.store_account(&address, &account);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"getAccountInfo","params":["{}", {{"encoding":"base64"}}]}}"#,
address
);
let res = io.handle_request_sync(&req, meta.clone());
let result: Value = serde_json::from_str(&res.expect("actual response"))
.expect("actual response deserialization");
assert_eq!(
result["result"]["value"]["data"],
json!([base64::encode(&data), "base64"]),
);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"getAccountInfo","params":["{}", {{"encoding":"base64", "dataSlice": {{"length": 2, "offset": 1}}}}]}}"#,
address
);
let res = io.handle_request_sync(&req, meta.clone());
let result: Value = serde_json::from_str(&res.expect("actual response"))
.expect("actual response deserialization");
assert_eq!(
result["result"]["value"]["data"],
json!([base64::encode(&data[1..3]), "base64"]),
);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"getAccountInfo","params":["{}", {{"encoding":"binary", "dataSlice": {{"length": 2, "offset": 1}}}}]}}"#,
address
);
let res = io.handle_request_sync(&req, meta.clone());
let result: Value = serde_json::from_str(&res.expect("actual response"))
.expect("actual response deserialization");
assert_eq!(
result["result"]["value"]["data"],
bs58::encode(&data[1..3]).into_string(),
);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"getAccountInfo","params":["{}", {{"encoding":"jsonParsed", "dataSlice": {{"length": 2, "offset": 1}}}}]}}"#,
address
);
let res = io.handle_request_sync(&req, meta);
let result: Value = serde_json::from_str(&res.expect("actual response"))
.expect("actual response deserialization");
result["error"].as_object().unwrap();
} | rust_cleaned_test_functions.jsonl/3730 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1680
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
60799,
3062,
13500,
3109,
368,
341,
286,
1077,
35192,
34014,
792,
284,
2048,
3362,
61783,
486,
9585,
792,
486,
931,
33864,
543,
286,
1077,
79961,
3050,
314,
6399,
11,
8823,
11,
6073,
11,
5241,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_instruction_within_range() {
let program = program();
let instruction = program.instruction(1);
match instruction {
Some(&Instruction::Increment(Register::B)) => (),
_ => panic!("Incorrect instruction {:?}", instruction)
}
} | rust_cleaned_test_functions.jsonl/134342 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 171
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
54923,
72385,
9698,
368,
341,
286,
1077,
2025,
284,
2025,
543,
286,
1077,
7600,
284,
2025,
1858,
3024,
7,
16,
626,
286,
2432,
7600,
341,
310,
4329,
2099,
16664,
486,
38311,
79203,
486,
33,
593,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
#[test]
fn test_bus_device_write() {
let m = GuestMemory::new(&[(GuestAddress(0), 0x1000)]).unwrap();
let dummy_box = Box::new(DummyDevice::new());
let p = &dummy_box.acked_features as *const u32;
let mut d = MmioDevice::new(m, dummy_box).unwrap();
let mut buf = vec![0; 5];
LittleEndian::write_u32(&mut buf[..4], 1);
d.features_select = 0;
d.write(0x14, &buf[..]);
assert_eq!(d.features_select, 0);
buf.pop();
assert_eq!(d.driver_status, DEVICE_INIT);
set_driver_status(&mut d, DEVICE_ACKNOWLEDGE);
// Acking features in invalid state shouldn't take effect.
assert_eq!(unsafe { *p }, 0x0);
d.acked_features_select = 0x0;
LittleEndian::write_u32(&mut buf[..], 1);
d.write(0x20, &buf[..]);
assert_eq!(unsafe { *p }, 0x0);
// Write to device specific configuration space should be ignored before setting DEVICE_DRIVER
let buf1 = vec![1; 0xeff];
for i in (0..0xeff).rev() {
let mut buf2 = vec![0; 0xeff];
d.write(0x100 + i as u64, &buf1[i..]);
d.read(0x100, &mut buf2[..]);
for item in buf2.iter().take(0xeff) {
assert_eq!(*item, 0);
}
}
set_driver_status(&mut d, DEVICE_ACKNOWLEDGE | DEVICE_DRIVER);
assert_eq!(d.driver_status, DEVICE_ACKNOWLEDGE | DEVICE_DRIVER);
// now writes should work
d.features_select = 0;
LittleEndian::write_u32(&mut buf[..], 1);
d.write(0x14, &buf[..]);
assert_eq!(d.features_select, 1);
d.acked_features_select = 0x123;
LittleEndian::write_u32(&mut buf[..], 1);
d.write(0x20, &buf[..]);
assert_eq!(unsafe { *p }, 0x124);
d.acked_features_select = 0;
LittleEndian::write_u32(&mut buf[..], 2);
d.write(0x24, &buf[..]);
assert_eq!(d.acked_features_select, 2);
set_driver_status(
&mut d,
DEVICE_ACKNOWLEDGE | DEVICE_DRIVER | DEVICE_FEATURES_OK,
);
// Acking features in invalid state shouldn't take effect.
assert_eq!(unsafe { *p }, 0x124);
d.acked_features_select = 0x0;
LittleEndian::write_u32(&mut buf[..], 1);
d.write(0x20, &buf[..]);
assert_eq!(unsafe { *p }, 0x124);
// Setup queues
d.queue_select = 0;
LittleEndian::write_u32(&mut buf[..], 3);
d.write(0x30, &buf[..]);
assert_eq!(d.queue_select, 3);
d.queue_select = 0;
assert_eq!(d.queues[0].size, 0);
LittleEndian::write_u32(&mut buf[..], 16);
d.write(0x38, &buf[..]);
assert_eq!(d.queues[0].size, 16);
assert!(!d.queues[0].ready);
LittleEndian::write_u32(&mut buf[..], 1);
d.write(0x44, &buf[..]);
assert!(d.queues[0].ready);
assert_eq!(d.queues[0].desc_table.0, 0);
LittleEndian::write_u32(&mut buf[..], 123);
d.write(0x80, &buf[..]);
assert_eq!(d.queues[0].desc_table.0, 123);
d.write(0x84, &buf[..]);
assert_eq!(d.queues[0].desc_table.0, 123 + (123 << 32));
assert_eq!(d.queues[0].avail_ring.0, 0);
LittleEndian::write_u32(&mut buf[..], 124);
d.write(0x90, &buf[..]);
assert_eq!(d.queues[0].avail_ring.0, 124);
d.write(0x94, &buf[..]);
assert_eq!(d.queues[0].avail_ring.0, 124 + (124 << 32));
assert_eq!(d.queues[0].used_ring.0, 0);
LittleEndian::write_u32(&mut buf[..], 125);
d.write(0xa0, &buf[..]);
assert_eq!(d.queues[0].used_ring.0, 125);
d.write(0xa4, &buf[..]);
assert_eq!(d.queues[0].used_ring.0, 125 + (125 << 32));
set_driver_status(
&mut d,
DEVICE_ACKNOWLEDGE | DEVICE_DRIVER | DEVICE_FEATURES_OK | DEVICE_DRIVER_OK,
);
d.interrupt_status.store(0b10_1010, Ordering::Relaxed);
LittleEndian::write_u32(&mut buf[..], 0b111);
d.write(0x64, &buf[..]);
assert_eq!(d.interrupt_status.load(Ordering::Relaxed), 0b10_1000);
// Write to an invalid address in generic register range.
LittleEndian::write_u32(&mut buf[..], 0xf);
d.config_generation = 0;
d.write(0xfb, &buf[..]);
assert_eq!(d.config_generation, 0);
// Write to an invalid length in generic register range.
d.write(0xfc, &buf[..2]);
assert_eq!(d.config_generation, 0);
// Here we test writes/read into/from the device specific configuration space.
let buf1 = vec![1; 0xeff];
for i in (0..0xeff).rev() {
let mut buf2 = vec![0; 0xeff];
d.write(0x100 + i as u64, &buf1[i..]);
d.read(0x100, &mut buf2[..]);
for item in buf2.iter().take(i) {
assert_eq!(*item, 0);
}
assert_eq!(buf1[i..], buf2[i..]);
}
} | rust_cleaned_test_functions.jsonl/85622 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2567
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25418,
9204,
9165,
368,
341,
286,
1077,
296,
284,
26215,
10642,
486,
931,
2099,
9697,
37804,
4286,
7,
15,
701,
220,
15,
87,
16,
15,
15,
15,
7252,
568,
15454,
1428,
286,
1077,
17292,
10194,
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... | 5 |
#[test]
fn test_gaussian_filter_1d() {
let mut a: Array1<f32> = (0..7).map(|v| v as f32).collect();
assert_relative_eq!(
gaussian_filter(&a, 1.0, 4.0),
arr1(&[0.42704096, 1.0679559, 2.0048335, 3.0, 3.9951665, 4.932044, 5.572959]),
epsilon = 1e-5
);
a[0] = 0.7;
assert_relative_eq!(
gaussian_filter(&a.view(), 2.0, 3.0),
arr1(&[1.4193099, 1.737984, 2.3200142, 3.0642939, 3.8351974, 4.4778357, 4.845365]),
epsilon = 1e-5
);
} | rust_cleaned_test_functions.jsonl/57229 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 291
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1889,
46972,
8727,
62,
16,
67,
368,
341,
262,
1077,
5206,
264,
25,
2910,
16,
63895,
18,
17,
29,
284,
320,
15,
496,
22,
568,
2186,
22428,
85,
91,
348,
438,
282,
18,
17,
568,
17384,
543,
262... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_t100() {
init();
let result = t100(*SSO_VERSION, 2, *MAIN_SIG_MAP);
println!("{}", result.len());
println!("{:?}", result)
} | rust_cleaned_test_functions.jsonl/104723 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 99
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
528,
16,
15,
15,
368,
341,
286,
2930,
543,
286,
1077,
1102,
284,
259,
16,
15,
15,
4071,
1220,
46,
10678,
11,
220,
17,
11,
353,
41815,
55687,
16306,
317,
286,
13751,
79878,
1102,
19406,
1423,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_union() {
let a: SgSet<_, DEFAULT_CAPACITY> = SgSet::from_iter([1, 3, 9, 7]);
let b = SgSet::<_, DEFAULT_CAPACITY>::from_iter([2, 8]);
assert_eq!(
a.union(&b).copied().collect::<Vec<usize>>(),
vec![1, 2, 3, 7, 8, 9]
);
} | rust_cleaned_test_functions.jsonl/68247 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 152
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2602,
51621,
368,
341,
262,
1077,
264,
25,
328,
70,
1649,
27,
6878,
11955,
92153,
29,
284,
328,
70,
1649,
486,
1499,
11723,
2561,
16,
11,
220,
18,
11,
220,
24,
11,
220,
22,
2558,
262,
1077,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_register_multiplecollector() {
let counters = vec![
Counter::new("c1", "c1 is a counter").unwrap(),
Counter::new("c2", "c2 is a counter").unwrap(),
];
let descs = counters.iter().map(|c| c.desc().into_iter().cloned()).fold(
Vec::new(),
|mut acc, ds| {
acc.extend(ds);
acc
},
);
let mc = MultipleCollector { descs, counters };
let r = Registry::new();
r.register(Box::new(mc)).unwrap();
} | rust_cleaned_test_functions.jsonl/132420 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 296
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14000,
45233,
91469,
368,
341,
286,
1077,
31532,
284,
7486,
90515,
310,
19735,
486,
931,
445,
66,
16,
497,
330,
66,
16,
374,
264,
5546,
1827,
15454,
3148,
310,
19735,
486,
931,
445,
66,
17,
49... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_drop_on_broken() {
static DROPPED: AtomicBool = AtomicBool::new(false);
#[derive(Default)]
struct Connection;
impl Drop for Connection {
fn drop(&mut self) {
DROPPED.store(true, Ordering::SeqCst);
}
}
struct Handler;
impl ManageConnection for Handler {
type Connection = Connection;
type Error = Error;
fn connect(&self) -> Box<Future<Item = Self::Connection, Error = Self::Error> + Send> {
Box::new(ok(Default::default()))
}
fn is_valid(
&self,
conn: Self::Connection,
) -> Box<Future<Item = Self::Connection, Error = (Self::Error, Self::Connection)> + Send>
{
Box::new(ok(conn))
}
fn has_broken(&self, _: &mut Self::Connection) -> bool {
true
}
}
let mut event_loop = Runtime::new().unwrap();
let pool = event_loop
.block_on(lazy(|| Pool::builder().build(Handler)))
.unwrap();
event_loop
.block_on(
pool.run(move |conn| {
let r: Result<_, (Error, _)> = Ok(((), conn));
r.into_future()
})
.map_err(|_| ()),
)
.unwrap();
assert!(DROPPED.load(Ordering::SeqCst));
} | rust_cleaned_test_functions.jsonl/127887 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 652
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
29584,
4470,
880,
81709,
368,
341,
262,
1099,
422,
1285,
4406,
1479,
25,
30316,
11233,
284,
30316,
11233,
486,
931,
3576,
626,
262,
11506,
27098,
87874,
5563,
262,
2036,
11032,
401,
262,
11605,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.