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_case_11() {
let key = "4739a0ad2169b9c89edd74e16fbcecc748c25dc338041fc34af0f1bda20eaf3f";
let nonce = "ff7b372aa801eb98a1298bc610280737";
let expected_output =
"06ccde41d10d6466859927bfc9a476dbc84064838ec721261cb548c18bd14c67";
hchacha_test_runner(key, nonce, expected_output);
} | rust_cleaned_test_functions.jsonl/44673 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 214
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19096,
62,
16,
16,
368,
341,
310,
1077,
1376,
284,
330,
19,
22,
18,
24,
64,
15,
329,
17,
16,
21,
24,
65,
24,
66,
23,
24,
53537,
22,
19,
68,
16,
21,
10798,
346,
638,
22,
19,
23,
66,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_attribute_flag_false() {
let buf = [0x00];
let unit = test_parse_attribute_unit_default();
let form = constants::DW_FORM_flag;
let value = AttributeValue::Flag(false);
test_parse_attribute(&buf, 1, &unit, form, value);
} | rust_cleaned_test_functions.jsonl/102024 | {
"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,
21039,
16791,
10933,
36015,
368,
341,
286,
1077,
6607,
284,
508,
15,
87,
15,
15,
935,
286,
1077,
4982,
284,
1273,
21039,
16791,
14832,
9993,
543,
286,
1077,
1352,
284,
18021,
486,
54219,
12705,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_disconnected() {
let mut exec = fasync::TestExecutor::new().expect("executor should build");
let (proxy, _stream) =
create_proxy_and_stream::<ProfileMarker>().expect("Profile proxy should be created");
let (remote, signaling) = Channel::create();
let id = PeerId(1);
let avdtp = avdtp::Peer::new(signaling);
let peer = Peer::create(id, avdtp, Streams::new(), None, proxy, None);
let closed_fut = peer.closed();
pin_mut!(closed_fut);
assert!(exec.run_until_stalled(&mut closed_fut).is_pending());
// Close the remote channel
drop(remote);
assert!(exec.run_until_stalled(&mut closed_fut).is_ready());
} | rust_cleaned_test_functions.jsonl/91775 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 318
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9932,
15288,
368,
341,
286,
1077,
5206,
3883,
284,
282,
7692,
486,
2271,
25255,
486,
931,
1005,
17119,
445,
80787,
1265,
1936,
797,
286,
1077,
320,
22803,
11,
716,
4027,
8,
4035,
310,
1855,
2971... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_json_parser() -> Result<(), Box<dyn std::error::Error>> {
let content = r#"
DEBUG = true
FOO = "foo"
PORT = 8080
bars = [ 1, 2, 3 ]
[test]
FLAGS = "none"
FOO = "test_foo"
PORT = "3000"
"#;
let mut defaults_expected: EnvVariableMap = BTreeMap::new();
defaults_expected.insert(
"DEBUG".to_owned(),
EnvVariable::new("DEBUG", "true".to_owned()),
);
defaults_expected.insert("FOO".to_owned(), EnvVariable::new("FOO", "foo".to_owned()));
defaults_expected.insert(
"PORT".to_owned(),
EnvVariable::new("PORT", "8080".to_owned()),
);
let mut overrides_expected: BTreeMap<String, EnvVariableMap> = BTreeMap::new();
let mut test_env_var_map: EnvVariableMap = BTreeMap::new();
test_env_var_map.insert(
"FLAGS".to_owned(),
EnvVariable::new("FLAGS", "none".to_owned()),
);
test_env_var_map.insert(
"FOO".to_owned(),
EnvVariable::new("FOO", "test_foo".to_owned()),
);
test_env_var_map.insert(
"PORT".to_owned(),
EnvVariable::new("PORT", "3000".to_owned()),
);
overrides_expected.insert("test".to_owned(), test_env_var_map);
let (defaults, overrides) = super::parse_config(content, Path::new("testfile.json"))?;
assert_eq!(defaults, defaults_expected);
assert_eq!(overrides, overrides_expected);
return Ok(());
} | rust_cleaned_test_functions.jsonl/32852 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 818
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9455,
18517,
368,
1464,
5714,
68843,
8261,
92846,
1460,
486,
841,
486,
1454,
2452,
341,
286,
1077,
2213,
284,
435,
2,
698,
310,
12657,
284,
830,
198,
310,
434,
19499,
284,
330,
7975,
698,
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... | 2 |
#[test]
fn test_file_decoration_style_omit() {
_do_test_file_style_no_decoration(&[
"--file-style",
"green",
"--file-decoration-style",
"omit",
]);
} | rust_cleaned_test_functions.jsonl/70070 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 133
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2458,
2259,
26452,
15117,
62,
77968,
368,
341,
286,
716,
2982,
4452,
2458,
15117,
6536,
2259,
26452,
2099,
9640,
310,
14482,
1192,
11297,
756,
310,
330,
13250,
756,
310,
14482,
1192,
30266,
11297,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_to_bytes() {
assert!(to_bytes(&mut "64K".to_string()).is_ok());
assert!(to_bytes(&mut "64M".to_string()).is_ok());
let res = to_bytes(&mut "64KK".to_string());
assert!(
res.is_err()
&& format!("{}", res.unwrap_err())
== "Invalid \"Size\" cache attribute: invalid digit found in string"
);
let res = to_bytes(&mut "64G".to_string());
assert!(
res.is_err()
&& format!("{}", res.unwrap_err()) == "Invalid \"Size\" cache attribute: 64G"
);
let res = to_bytes(&mut "".to_string());
assert!(
res.is_err()
&& format!("{}", res.unwrap_err())
== "Invalid \"Size\" cache attribute: Empty string was provided"
);
} | rust_cleaned_test_functions.jsonl/125483 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 437
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2346,
12524,
368,
341,
286,
2060,
10297,
983,
12524,
2099,
6984,
330,
21,
19,
42,
3263,
983,
3904,
6011,
285,
19817,
1423,
286,
2060,
10297,
983,
12524,
2099,
6984,
330,
21,
19,
44,
3263,
983,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
#[test]
fn test_epoch_slots_fill_random_range() {
use rand::Rng;
for _ in 0..10 {
let mut range: Vec<Slot> = vec![];
for _ in 0..5000 {
let last = *range.last().unwrap_or(&0);
range.push(last + rand::thread_rng().gen_range(1, 5));
}
let mut slots = EpochSlots::default();
let sz = slots.fill(&range, 1);
let last = range[sz - 1];
assert_eq!(
last,
slots.slots.last().unwrap().first_slot()
+ slots.slots.last().unwrap().num_slots() as u64
- 1
);
for s in &slots.slots {
assert!(s.to_slots(0).is_ok());
}
let slots = slots.to_slots(0);
assert_eq!(slots[..], range[..slots.len()]);
assert_eq!(sz, slots.len())
}
} | rust_cleaned_test_functions.jsonl/116106 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 549
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20682,
54161,
30728,
22644,
9698,
368,
341,
286,
990,
10382,
486,
49,
968,
280,
286,
369,
716,
304,
220,
15,
496,
16,
15,
341,
310,
1077,
5206,
2088,
25,
11312,
27,
19877,
29,
284,
7486,
0,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
#[test]
fn test_wmi_services () {
let reader: Box<dyn WmiServicesIface> = Box::new(Test{});
let test_services = &WmiServices::get_specific_ex(reader.borrow())[0];
assert_eq!(test_services.accept_pause, "false");
assert_eq!(test_services.accept_stop, "true");
assert_eq!(test_services.caption, "Windows Push Notifications User Service_10b2b340");
assert_eq!(test_services.creation_class_name, "Win32_Service");
assert_eq!(test_services.description, "do something");
assert_eq!(test_services.desktop_interact, "false");
assert_eq!(test_services.display_name, "Windows Push Notifications User Service_10b2b340");
assert_eq!(test_services.error_control, "Ignore");
assert_eq!(test_services.exit_code, 0);
assert_eq!(test_services.name, "WpnUserService_10b2b340");
assert_eq!(test_services.path_name, "C:\\WINDOWS\\system32\\svchost.exe -k UnistackSvcGroup");
assert_eq!(test_services.service_type, "Unknown");
assert_eq!(test_services.started, "true");
assert_eq!(test_services.start_mode, "Auto");
assert_eq!(test_services.start_name, "");
assert_eq!(test_services.state, "Running");
assert_eq!(test_services.status, "OK");
assert_eq!(test_services.system_creation_class_name, "Win32_ComputerSystem");
assert_eq!(test_services.system_name, "waka-waka");
} | rust_cleaned_test_functions.jsonl/103576 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 600
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1670,
8155,
39846,
1719,
341,
286,
1077,
6604,
25,
8261,
92846,
467,
8155,
11025,
40,
1564,
29,
284,
8261,
486,
931,
31159,
90,
2960,
286,
1077,
1273,
39846,
284,
609,
54,
8155,
11025,
486,
455,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_benchmarks() {
ExtBuilder::default().base_weight(5).build().execute_with(|| {
assert_ok!(test_benchmark_swap_currency::<Test>());
assert_ok!(test_benchmark_set_currency::<Test>());
assert_ok!(test_benchmark_add_currency::<Test>());
assert_ok!(test_benchmark_remove_currency::<Test>());
assert_ok!(test_benchmark_add_member::<Test>());
assert_ok!(test_benchmark_remove_member::<Test>());
});
} | rust_cleaned_test_functions.jsonl/27028 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 180
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
880,
19762,
15544,
368,
341,
197,
76605,
3297,
486,
2258,
1005,
3152,
15876,
7,
20,
568,
5834,
1005,
10257,
6615,
79453,
341,
298,
6948,
19817,
10297,
1944,
880,
39381,
40991,
34710,
27638,
2271,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_hotplug_timeout() {
#[derive(Debug)]
struct TestData<'a> {
param: &'a str,
result: Result<time::Duration>,
}
let tests = &[
TestData {
param: "",
result: Err(make_err(ERR_INVALID_HOTPLUG_TIMEOUT)),
},
TestData {
param: "agent.hotplug_timeout",
result: Err(make_err(ERR_INVALID_HOTPLUG_TIMEOUT)),
},
TestData {
param: "foo=bar",
result: Err(make_err(ERR_INVALID_HOTPLUG_TIMEOUT_KEY)),
},
TestData {
param: "agent.hotplug_timeot=1",
result: Err(make_err(ERR_INVALID_HOTPLUG_TIMEOUT_KEY)),
},
TestData {
param: "agent.hotplug_timeout=1",
result: Ok(time::Duration::from_secs(1)),
},
TestData {
param: "agent.hotplug_timeout=3",
result: Ok(time::Duration::from_secs(3)),
},
TestData {
param: "agent.hotplug_timeout=3600",
result: Ok(time::Duration::from_secs(3600)),
},
TestData {
param: "agent.hotplug_timeout=0",
result: Ok(time::Duration::from_secs(0)),
},
TestData {
param: "agent.hotplug_timeout=-1",
result: Err(make_err(ERR_INVALID_HOTPLUG_TIMEOUT_PARAM)),
},
TestData {
param: "agent.hotplug_timeout=4jbsdja",
result: Err(make_err(ERR_INVALID_HOTPLUG_TIMEOUT_PARAM)),
},
TestData {
param: "agent.hotplug_timeout=foo",
result: Err(make_err(ERR_INVALID_HOTPLUG_TIMEOUT_PARAM)),
},
TestData {
param: "agent.hotplug_timeout=j",
result: Err(make_err(ERR_INVALID_HOTPLUG_TIMEOUT_PARAM)),
},
];
for (i, d) in tests.iter().enumerate() {
let msg = format!("test[{}]: {:?}", i, d);
let result = get_hotplug_timeout(d.param);
let msg = format!("{}: result: {:?}", msg, result);
assert_result!(d.result, result, format!("{}", msg));
}
} | rust_cleaned_test_functions.jsonl/4049 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1395
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
33433,
47474,
20537,
368,
341,
286,
11506,
27098,
42618,
5563,
286,
2036,
93200,
18291,
64,
29,
341,
310,
1685,
25,
30136,
64,
607,
345,
310,
1102,
25,
5714,
27,
1678,
486,
12945,
12520,
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_serde_round_trip() {
// validate serde attribute working
let json = serde_json::to_string(&SerdeRoundtrip { a: 5, b: 5 }).unwrap();
assert_eq!("{\"a\":5}", json);
let result: SerdeRoundtrip = serde_json::from_str(&json).unwrap();
assert_eq!(result.a, 5);
assert_eq!(result.b, 0);
// validate bincode working
let bytes =
bincode::encode_to_vec(SerdeRoundtrip { a: 15, b: 15 }, bincode::config::standard())
.unwrap();
assert_eq!(bytes, &[15, 15]);
let (result, len): (SerdeRoundtrip, usize) =
bincode::decode_from_slice(&bytes, bincode::config::standard()).unwrap();
assert_eq!(result.a, 15);
assert_eq!(result.b, 15);
assert_eq!(len, 2);
} | rust_cleaned_test_functions.jsonl/124089 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 327
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
75861,
450,
29896,
63883,
368,
341,
262,
442,
9593,
61570,
7035,
3238,
198,
262,
1077,
2951,
284,
61570,
9455,
486,
983,
3904,
2099,
31745,
450,
27497,
32981,
314,
264,
25,
220,
20,
11,
293,
25,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_option() {
test_parse_ok(&[
("<a/>", Some("".to_string())),
("<a></a>", Some("".to_string())),
("<a> </a>", Some("".to_string())),
("<a>42</a>", Some("42".to_string())),
]);
} | rust_cleaned_test_functions.jsonl/54627 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 130
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9672,
368,
341,
262,
1273,
21039,
19817,
2099,
9640,
286,
90276,
64,
9685,
497,
4329,
445,
3263,
983,
3904,
73727,
286,
90276,
64,
1472,
64,
21156,
4329,
445,
3263,
983,
3904,
73727,
286,
90276,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_nmaximizer_custom_struct() {
let mut highs = NMaximizer::new(3);
highs.insert(CustomStruct {
value: 7i32,
dist: 5f64,
});
highs.insert(CustomStruct {
value: 5i32,
dist: 13f64,
});
highs.insert(CustomStruct {
value: 4i32,
dist: 3f64,
});
highs.insert(CustomStruct {
value: 6i32,
dist: 1f64,
});
highs.insert(CustomStruct {
value: 3i32,
dist: 20f64,
});
assert_eq!(
highs.get_maxima(),
vec![
CustomStruct {
value: 3i32,
dist: 20f64,
},
CustomStruct {
value: 5i32,
dist: 13f64,
},
CustomStruct {
value: 7i32,
dist: 5f64,
},
]
);
} | rust_cleaned_test_functions.jsonl/40402 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 683
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1089,
2810,
41699,
15875,
15126,
368,
341,
286,
1077,
5206,
53779,
284,
451,
5974,
41699,
486,
931,
7,
18,
317,
286,
53779,
7030,
3025,
1450,
9422,
341,
310,
897,
25,
220,
22,
72,
18,
17,
345,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_nice_api() {
let ctx = TestContext::new();
let mut con = ctx.connection();
assert_eq!(con.set("my_key", 42), Ok(()));
assert_eq!(con.get("my_key"), Ok(42));
let (k1, k2): (i32, i32) = redis::pipe()
.atomic()
.set("key_1", 42)
.ignore()
.set("key_2", 43)
.ignore()
.get("key_1")
.get("key_2")
.query(&mut con)
.unwrap();
assert_eq!(k1, 42);
assert_eq!(k2, 43);
} | rust_cleaned_test_functions.jsonl/108965 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 267
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1089,
558,
11697,
368,
341,
262,
1077,
5635,
284,
3393,
1972,
486,
931,
543,
262,
1077,
5206,
390,
284,
5635,
20310,
1428,
262,
2060,
10714,
10297,
443,
980,
445,
2408,
3097,
497,
220,
19,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_last() {
let a: VolAddress<i32> = unsafe { VolAddress::new(4) };
let i: VolIter<i32> = unsafe { a.iter_slots(2) };
assert_eq!(i.last(), Some(unsafe { VolAddress::new(4 + 2 * 4) }));
let mut i: VolIter<i32> = unsafe { a.iter_slots(2) };
i.next();
i.next();
assert_eq!(i.last(), None);
} | rust_cleaned_test_functions.jsonl/116633 | {
"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,
12195,
368,
341,
220,
1077,
264,
25,
10882,
4286,
21897,
18,
17,
29,
284,
19860,
314,
10882,
4286,
486,
931,
7,
19,
8,
2605,
220,
1077,
600,
25,
10882,
8537,
21897,
18,
17,
29,
284,
19860,
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_misused_facet_collector() {
let mut facet_collector = FacetCollector::for_field(Field(0));
facet_collector.add_facet(Facet::from("/country"));
facet_collector.add_facet(Facet::from("/country/europe"));
} | rust_cleaned_test_functions.jsonl/25606 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 114
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
717,
285,
2591,
41589,
295,
10211,
27669,
368,
341,
286,
1077,
5206,
44507,
10211,
27669,
284,
16945,
295,
53694,
486,
1958,
5013,
57788,
7,
15,
1106,
286,
44507,
10211,
27669,
1364,
41589,
295,
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_cmsg_len() {
for l in 0..128 {
unsafe {
assert_eq!(libc::CMSG_LEN(l) as usize, cmsg_len(l));
}
}
} | rust_cleaned_test_functions.jsonl/91465 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 120
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
666,
3236,
6043,
368,
341,
286,
369,
326,
304,
220,
15,
496,
16,
17,
23,
341,
310,
19860,
341,
394,
2060,
10714,
10297,
55576,
486,
34,
19575,
15536,
2333,
8,
438,
22301,
11,
272,
3236,
6043,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_encryption_crud() {
let db_name = format!("{}.sqlite3", string(8).as_str());
let temp_dir = tempdir().unwrap();
let db_folder = temp_dir.path().to_str().unwrap().to_string();
let db_path = format!("{}{}", db_folder, db_name);
embed_migrations!("./migrations");
let conn = SqliteConnection::establish(&db_path).unwrap_or_else(|_| panic!("Error connecting to {}", db_path));
embedded_migrations::run_with_output(&conn, &mut std::io::stdout()).expect("Migration failed");
conn.execute("PRAGMA foreign_keys = ON").unwrap();
let key = GenericArray::from_slice(b"an example very very secret key.");
let cipher = Aes256Gcm::new(key);
let inbound_tx = InboundTransaction {
tx_id: 1,
source_public_key: PublicKey::from_secret_key(&PrivateKey::random(&mut OsRng)),
amount: MicroTari::from(100),
receiver_protocol: ReceiverTransactionProtocol::new_placeholder(),
status: TransactionStatus::Pending,
message: "Yo!".to_string(),
timestamp: Utc::now().naive_utc(),
cancelled: false,
direct_send_success: false,
send_count: 0,
last_send_timestamp: None,
};
let mut inbound_tx_sql = InboundTransactionSql::try_from(inbound_tx.clone()).unwrap();
inbound_tx_sql.commit(&conn).unwrap();
inbound_tx_sql.encrypt(&cipher).unwrap();
inbound_tx_sql.update_encryption(&conn).unwrap();
let mut db_inbound_tx = InboundTransactionSql::find_by_cancelled(1, false, &conn).unwrap();
db_inbound_tx.decrypt(&cipher).unwrap();
let decrypted_inbound_tx = InboundTransaction::try_from(db_inbound_tx).unwrap();
assert_eq!(inbound_tx, decrypted_inbound_tx);
let outbound_tx = OutboundTransaction {
tx_id: 2u64,
destination_public_key: PublicKey::from_secret_key(&PrivateKey::random(&mut OsRng)),
amount: MicroTari::from(100),
fee: MicroTari::from(10),
sender_protocol: SenderTransactionProtocol::new_placeholder(),
status: TransactionStatus::Pending,
message: "Yo!".to_string(),
timestamp: Utc::now().naive_utc(),
cancelled: false,
direct_send_success: false,
send_count: 0,
last_send_timestamp: None,
};
let mut outbound_tx_sql = OutboundTransactionSql::try_from(outbound_tx.clone()).unwrap();
outbound_tx_sql.commit(&conn).unwrap();
outbound_tx_sql.encrypt(&cipher).unwrap();
outbound_tx_sql.update_encryption(&conn).unwrap();
let mut db_outbound_tx = OutboundTransactionSql::find_by_cancelled(2, false, &conn).unwrap();
db_outbound_tx.decrypt(&cipher).unwrap();
let decrypted_outbound_tx = OutboundTransaction::try_from(db_outbound_tx).unwrap();
assert_eq!(outbound_tx, decrypted_outbound_tx);
let completed_tx = CompletedTransaction {
tx_id: 3,
source_public_key: PublicKey::from_secret_key(&PrivateKey::random(&mut OsRng)),
destination_public_key: PublicKey::from_secret_key(&PrivateKey::random(&mut OsRng)),
amount: MicroTari::from(100),
fee: MicroTari::from(100),
transaction: Transaction::new(
vec![],
vec![],
vec![],
PrivateKey::random(&mut OsRng),
PrivateKey::random(&mut OsRng),
),
status: TransactionStatus::MinedUnconfirmed,
message: "Yo!".to_string(),
timestamp: Utc::now().naive_utc(),
cancelled: false,
direction: TransactionDirection::Unknown,
coinbase_block_height: None,
send_count: 0,
last_send_timestamp: None,
valid: true,
confirmations: None,
mined_height: None,
};
let mut completed_tx_sql = CompletedTransactionSql::try_from(completed_tx.clone()).unwrap();
completed_tx_sql.commit(&conn).unwrap();
completed_tx_sql.encrypt(&cipher).unwrap();
completed_tx_sql.update_encryption(&conn).unwrap();
let mut db_completed_tx = CompletedTransactionSql::find_by_cancelled(3, false, &conn).unwrap();
db_completed_tx.decrypt(&cipher).unwrap();
let decrypted_completed_tx = CompletedTransaction::try_from(db_completed_tx).unwrap();
assert_eq!(completed_tx, decrypted_completed_tx);
} | rust_cleaned_test_functions.jsonl/1822 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2096
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13781,
15597,
32331,
661,
368,
341,
286,
1077,
2927,
1269,
284,
3561,
17223,
46391,
37042,
18,
497,
914,
7,
23,
568,
300,
2895,
1423,
286,
1077,
2730,
4334,
284,
2730,
3741,
1005,
15454,
543,
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_webpush_notification() {
let payload = WebNotificationBuilder::new(
WebPushAlert {
action: "View",
title: "Hello",
body: "world",
},
&vec!["arg1"],
)
.build("device-token", Default::default())
.to_json_string()
.unwrap();
let expected_payload = json!({
"aps": {
"alert": {
"body": "world",
"action": "View",
"title": "Hello"
},
"url-args": ["arg1"]
}
})
.to_string();
assert_eq!(expected_payload, payload);
} | rust_cleaned_test_functions.jsonl/35556 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 438
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25960,
9077,
34296,
368,
341,
286,
1077,
7729,
284,
4895,
11196,
3297,
486,
931,
1006,
310,
4895,
16644,
9676,
341,
394,
1917,
25,
330,
851,
756,
394,
2265,
25,
330,
9707,
756,
394,
2487,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_searcher_1() {
let mut schema_builder = SchemaBuilder::default();
let text_field = schema_builder.add_text_field("text", TEXT);
let schema = schema_builder.build();
let index = Index::create_in_ram(schema);
{
// writing the segment
let mut index_writer = index.writer_with_num_threads(1, 40_000_000).unwrap();
{
let doc = doc!(text_field=>"af af af b");
index_writer.add_document(doc);
}
{
let doc = doc!(text_field=>"a b c");
index_writer.add_document(doc);
}
{
let doc = doc!(text_field=>"a b c d");
index_writer.add_document(doc);
}
index_writer.commit().unwrap();
}
{
index.load_searchers().unwrap();
let searcher = index.searcher();
let get_doc_ids = |terms: Vec<Term>| {
let query = BooleanQuery::new_multiterms_query(terms);
let mut collector = TestCollector::default();
assert!(searcher.search(&query, &mut collector).is_ok());
collector.docs()
};
{
assert_eq!(
get_doc_ids(vec![Term::from_field_text(text_field, "a")]),
vec![1, 2]
);
}
{
assert_eq!(
get_doc_ids(vec![Term::from_field_text(text_field, "af")]),
vec![0]
);
}
{
assert_eq!(
get_doc_ids(vec![Term::from_field_text(text_field, "b")]),
vec![0, 1, 2]
);
}
{
assert_eq!(
get_doc_ids(vec![Term::from_field_text(text_field, "c")]),
vec![1, 2]
);
}
{
assert_eq!(
get_doc_ids(vec![Term::from_field_text(text_field, "d")]),
vec![2]
);
}
{
assert_eq!(
get_doc_ids(vec![
Term::from_field_text(text_field, "b"),
Term::from_field_text(text_field, "a"),
]),
vec![0, 1, 2]
);
}
}
} | rust_cleaned_test_functions.jsonl/65781 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1575
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10716,
261,
62,
16,
368,
341,
286,
1077,
5206,
10802,
28532,
284,
12539,
3297,
486,
2258,
543,
286,
1077,
1467,
5013,
284,
10802,
28532,
1364,
4326,
5013,
445,
1318,
497,
15762,
317,
286,
1077,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_printf_user_group() {
let temp_dir = Builder::new().prefix("example").tempdir().unwrap();
let temp_dir_path = temp_dir.path().to_string_lossy();
let new_file_name = "newFile";
File::create(temp_dir.path().join(new_file_name)).expect("create temp file");
let uid = unsafe { uucore::libc::getuid() };
let user = uucore::entries::uid2usr(uid).unwrap_or(uid.to_string());
let gid = unsafe { uucore::libc::getgid() };
let group = uucore::entries::gid2grp(gid).unwrap_or(gid.to_string());
let file_info = get_dir_entry_for(&temp_dir_path, new_file_name);
let deps = FakeDependencies::new();
let matcher = Printf::new("%u %U %g %G").unwrap();
assert!(matcher.matches(&file_info, &mut deps.new_matcher_io()));
assert_eq!(
format!("{} {} {} {}", user, uid, group, gid),
deps.get_output_as_string()
);
} | rust_cleaned_test_functions.jsonl/69255 | {
"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,
21823,
3317,
6288,
368,
341,
286,
1077,
2730,
4334,
284,
20626,
486,
931,
1005,
11849,
445,
8687,
1827,
3888,
3741,
1005,
15454,
543,
286,
1077,
2730,
4334,
2638,
284,
2730,
4334,
3875,
1005,
983,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_generators() {
test(
concat!("function* f() {", " let x = 1;", " yield x;", "}"),
concat!("function* f() {", " let x;", " yield 1;", "}"),
);
test(
concat!("function* f(x) {", " let y = x++", " yield y;", "}"),
concat!("function* f(x) {", " yield x++;", "}"),
);
} | rust_cleaned_test_functions.jsonl/27735 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 174
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
71963,
2973,
368,
341,
262,
1273,
1006,
286,
33720,
17223,
1688,
9,
282,
368,
314,
497,
330,
220,
1077,
856,
284,
220,
16,
32503,
330,
220,
7540,
856,
32503,
80548,
4461,
286,
33720,
17223,
1688... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_max_commit_ts_error() {
let engine = TestEngineBuilder::new().build().unwrap();
let storage = TestStorageBuilder::<_, DummyLockManager>::from_engine_and_lock_mgr(
engine,
DummyLockManager {},
ApiVersion::V1,
)
.build()
.unwrap();
let cm = storage.get_concurrency_manager();
fail::cfg("after_prewrite_one_key", "sleep(500)").unwrap();
let (prewrite_tx, prewrite_rx) = channel();
storage
.sched_txn_command(
commands::Prewrite::new(
vec![
Mutation::make_put(Key::from_raw(b"k1"), b"v".to_vec()),
Mutation::make_put(Key::from_raw(b"k2"), b"v".to_vec()),
],
b"k1".to_vec(),
10.into(),
20000,
false,
2,
TimeStamp::default(),
100.into(),
Some(vec![b"k2".to_vec()]),
false,
AssertionLevel::Off,
Context::default(),
),
Box::new(move |res| {
prewrite_tx.send(res).unwrap();
}),
)
.unwrap();
thread::sleep(Duration::from_millis(200));
assert!(
cm.read_key_check(&Key::from_raw(b"k1"), |_| Err(()))
.is_err()
);
cm.update_max_ts(200.into());
let res = prewrite_rx.recv().unwrap().unwrap();
assert!(res.min_commit_ts.is_zero());
assert!(res.one_pc_commit_ts.is_zero());
// There should not be any memory lock left.
assert!(cm.read_range_check(None, None, |_, _| Err(())).is_ok());
let l1 = must_locked(&storage.get_engine(), b"k1", 10);
let l2 = must_locked(&storage.get_engine(), b"k2", 10);
assert!(l1.use_async_commit);
assert!(!l2.use_async_commit);
} | rust_cleaned_test_functions.jsonl/8370 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 992
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6345,
36346,
25023,
4096,
368,
341,
262,
1077,
4712,
284,
3393,
4571,
3297,
486,
931,
1005,
5834,
1005,
15454,
543,
262,
1077,
5819,
284,
3393,
5793,
3297,
27638,
6878,
50567,
11989,
2043,
6831,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_program_bpf_ro_account_modify() {
solana_logger::setup();
let GenesisConfigInfo {
genesis_config,
mint_keypair,
..
} = create_genesis_config(50);
let mut bank = Bank::new_for_tests(&genesis_config);
let (name, id, entrypoint) = solana_bpf_loader_program!();
bank.add_builtin(&name, &id, entrypoint);
let bank = Arc::new(bank);
let bank_client = BankClient::new_shared(&bank);
let program_id = load_bpf_program(
&bank_client,
&bpf_loader::id(),
&mint_keypair,
"solana_bpf_rust_ro_account_modify",
);
let argument_keypair = Keypair::new();
let account = AccountSharedData::new(42, 100, &program_id);
bank.store_account(&argument_keypair.pubkey(), &account);
let from_keypair = Keypair::new();
let account = AccountSharedData::new(84, 0, &system_program::id());
bank.store_account(&from_keypair.pubkey(), &account);
let mint_pubkey = mint_keypair.pubkey();
let account_metas = vec![
AccountMeta::new_readonly(argument_keypair.pubkey(), false),
AccountMeta::new_readonly(program_id, false),
];
let instruction = Instruction::new_with_bytes(program_id, &[0], account_metas.clone());
let message = Message::new(&[instruction], Some(&mint_pubkey));
let result = bank_client.send_and_confirm_message(&[&mint_keypair], message);
assert_eq!(
result.unwrap_err().unwrap(),
TransactionError::InstructionError(0, InstructionError::ReadonlyDataModified)
);
let instruction = Instruction::new_with_bytes(program_id, &[1], account_metas.clone());
let message = Message::new(&[instruction], Some(&mint_pubkey));
let result = bank_client.send_and_confirm_message(&[&mint_keypair], message);
assert_eq!(
result.unwrap_err().unwrap(),
TransactionError::InstructionError(0, InstructionError::ReadonlyDataModified)
);
let instruction = Instruction::new_with_bytes(program_id, &[2], account_metas.clone());
let message = Message::new(&[instruction], Some(&mint_pubkey));
let result = bank_client.send_and_confirm_message(&[&mint_keypair], message);
assert_eq!(
result.unwrap_err().unwrap(),
TransactionError::InstructionError(0, InstructionError::ReadonlyDataModified)
);
} | rust_cleaned_test_functions.jsonl/5760 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 904
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25096,
880,
15897,
26608,
13500,
57725,
368,
341,
262,
2048,
3362,
27413,
486,
15188,
1428,
262,
1077,
40788,
2648,
1731,
341,
286,
59366,
5332,
345,
286,
28337,
3097,
12670,
345,
286,
54538,
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_initable_through_ffi() {
unsafe {
let test = InitableTestType::new_uninit();
let test: *mut ffi::InitableTestType = test.as_ptr();
let mut error: *mut glib::ffi::GError = std::ptr::null_mut();
assert_ne!(0x123456789abcdef, ffi::initable_test_type_get_value(test));
let result = crate::ffi::g_initable_init(
test as *mut crate::ffi::GInitable,
std::ptr::null_mut(),
&mut error,
);
assert_eq!(glib::ffi::GTRUE, result);
assert_eq!(error, ptr::null_mut());
assert_eq!(0x123456789abcdef, ffi::initable_test_type_get_value(test));
}
} | rust_cleaned_test_functions.jsonl/602 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 390
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6137,
480,
87399,
62,
53799,
368,
341,
286,
19860,
341,
310,
1077,
1273,
284,
758,
15368,
2271,
929,
486,
931,
4907,
2327,
543,
310,
1077,
1273,
25,
353,
6984,
76956,
486,
3803,
480,
2271,
929,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_float_special_values() {
parse_equals("+inf ", f64::INFINITY);
parse_equals("-inf ", f64::NEG_INFINITY);
// Can't test two NaNs for equality with assert_eq
let value = parse_unwrap(parse_float, "nan ");
if let TextValue::Float(f) = value {
assert!(f.is_nan());
} else {
panic!("Expected NaN, but got: {:?}", value);
}
} | rust_cleaned_test_functions.jsonl/85900 | {
"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,
21039,
17586,
41629,
9146,
368,
341,
286,
4715,
61664,
34973,
13573,
3670,
282,
21,
19,
486,
687,
55990,
317,
286,
4715,
61664,
13645,
13573,
3670,
282,
21,
19,
486,
97127,
91110,
626,
286,
442,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_group_register() {
let mut state = GlobalReplicationState::default();
let label1 = new_label("zone", "label 1");
assert_eq!(None, state.group.register_store(1, vec![label1.clone()]));
let label2 = new_label("zone", "label 2");
assert_eq!(None, state.group.register_store(2, vec![label2.clone()]));
assert_eq!(state.group.group_id(0, 2), None);
let label3 = new_label("host", "label 3");
let label4 = new_label("host", "label 4");
state.group.register_store(3, vec![label1.clone(), label3]);
state.group.register_store(4, vec![label2, label4.clone()]);
for i in 1..=4 {
assert_eq!(None, state.group.group_id(0, i));
}
let mut status = new_status(1, "zone");
state.group.recalculate(&status);
assert_eq!(Some(2), state.group.group_id(1, 1));
assert_eq!(Some(1), state.group.group_id(1, 2));
assert_eq!(Some(2), state.group.group_id(1, 3));
assert_eq!(Some(1), state.group.group_id(1, 4));
assert_eq!(None, state.group.group_id(0, 1));
assert_eq!(Some(2), state.group.register_store(5, vec![label1, label4]));
assert_eq!(
Some(3),
state
.group
.register_store(6, vec![new_label("zone", "label 5")])
);
let gb = state.calculate_commit_group(1, &[new_peer(1, 1), new_peer(2, 2), new_peer(3, 3)]);
assert_eq!(*gb, vec![(1, 2), (2, 1), (3, 2)]);
// Switches back to majority will not clear group id.
status = ReplicationStatus::default();
state.set_status(status);
let gb = state.calculate_commit_group(1, &[new_peer(1, 1), new_peer(2, 2), new_peer(3, 3)]);
assert_eq!(*gb, vec![(1, 2), (2, 1), (3, 2)]);
status = new_status(3, "zone");
state.set_status(status);
let gb = state.calculate_commit_group(3, &[new_peer(1, 1), new_peer(2, 2), new_peer(3, 3)]);
assert_eq!(*gb, vec![(1, 2), (2, 1), (3, 2)]);
status = new_status(4, "host");
state.set_status(status);
let gb = state.calculate_commit_group(4, &[new_peer(1, 1), new_peer(2, 2), new_peer(3, 3)]);
assert_eq!(*gb, vec![(3, 2)]);
} | rust_cleaned_test_functions.jsonl/76848 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1121
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6288,
14000,
368,
341,
286,
1077,
5206,
1584,
284,
7962,
18327,
1693,
1397,
486,
2258,
543,
286,
1077,
2383,
16,
284,
501,
6106,
445,
8684,
497,
330,
1502,
220,
16,
797,
286,
2060,
10714,
10297,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_intact_distance_ring_buffer2() {
static BR:&'static[u8] = &[0x1b, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe3, 0xb4, 0x0d, 0x00, 0x00,
0x07, 0x5b, 0x26, 0x31, 0x40, 0x02, 0x00, 0xe0, 0x4e, 0x1b, 0x41, 0x80,
0x20, 0x50, 0x10, 0x24, 0x08, 0x06];
static OUT:&'static[u8] = b"leftdatadataleft";
assert_decompressed_input_matches_output(BR,
OUT,
65536,
65536);
} | rust_cleaned_test_functions.jsonl/26471 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 352
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4042,
531,
19464,
34683,
7776,
17,
368,
341,
220,
1099,
18803,
35218,
6,
1978,
21335,
23,
60,
284,
44590,
15,
87,
16,
65,
11,
220,
15,
87,
15,
69,
11,
220,
15,
87,
15,
15,
11,
220,
15,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_consistency_check() {
let path = TempDir::new("tikv-store-test").unwrap();
let db = new_engine(path.path().to_str().unwrap(), &[CF_DEFAULT, CF_RAFT], None).unwrap();
let db = Arc::new(db);
let mut region = Region::new();
region.mut_peers().push(Peer::new());
let (tx, rx) = mpsc::channel();
let mut runner = Runner::new(tx);
let mut digest = Digest::new(crc32::IEEE);
let kvs = vec![(b"k1", b"v1"), (b"k2", b"v2")];
for (k, v) in kvs {
let key = keys::data_key(k);
db.put(&key, v).unwrap();
// hash should contain all kvs
digest.write(&key);
digest.write(v);
}
// hash should also contains region state key.
digest.write(&keys::region_state_key(region.get_id()));
digest.write(b"");
let sum = digest.sum32();
runner.run(Task::ComputeHash {
index: 10,
region: region.clone(),
snap: Snapshot::new(Arc::clone(&db)),
});
let mut checksum_bytes = vec![];
checksum_bytes.write_u32::<BigEndian>(sum).unwrap();
let res = rx.recv_timeout(Duration::from_secs(3)).unwrap();
match res {
Msg::ComputeHashResult {
region_id,
index,
hash,
} => {
assert_eq!(region_id, region.get_id());
assert_eq!(index, 10);
assert_eq!(hash, checksum_bytes);
}
e => panic!("unexpected {:?}", e),
}
} | rust_cleaned_test_functions.jsonl/84194 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 850
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31971,
47094,
7200,
368,
341,
286,
1077,
1815,
284,
19944,
6184,
486,
931,
445,
83,
1579,
85,
33252,
16839,
1827,
15454,
543,
286,
1077,
2927,
284,
501,
24823,
5581,
3875,
1005,
983,
2895,
1005,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_hash() {
assert_eq!(hash(&[40, 20, 50, 30]), 3005002040);
} | rust_cleaned_test_functions.jsonl/35860 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 51
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8950,
368,
341,
286,
2060,
10714,
10297,
8296,
2099,
58,
19,
15,
11,
220,
17,
15,
11,
220,
20,
15,
11,
220,
18,
15,
9719,
220,
18,
15,
15,
20,
15,
15,
17,
15,
19,
15,
317,
262,
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 |
#[test]
fn test_canonicalize_idents_by_stripping_dot_git() {
let ident1 = ident(&url("https://github.com/PistonDevelopers/piston"));
let ident2 = ident(&url("https://github.com/PistonDevelopers/piston.git"));
assert_eq!(ident1, ident2);
} | rust_cleaned_test_functions.jsonl/74053 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 118
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
27421,
22391,
551,
842,
805,
3710,
1261,
461,
10732,
30941,
68801,
368,
341,
286,
1077,
3524,
16,
284,
3524,
2099,
1085,
445,
2428,
1110,
5204,
905,
16341,
58819,
20444,
388,
4322,
58819,
4010,
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_tabs_with_specifier_not_at_start() {
fn run_cmd(arg: &str, expected_prefix: &str, expected_suffix: &str) {
let expected_msg = format!(
"{} specifier not at start of number: {}",
expected_prefix.quote(),
expected_suffix.quote()
);
new_ucmd!().arg(arg).fails().stderr_contains(expected_msg);
}
run_cmd("--tabs=1/", "/", "/");
run_cmd("--tabs=1/2", "/", "/2");
run_cmd("--tabs=1+", "+", "+");
run_cmd("--tabs=1+2", "+", "+2");
} | rust_cleaned_test_functions.jsonl/121807 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 264
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
57953,
6615,
13594,
3049,
7913,
3752,
4906,
368,
341,
262,
5168,
1598,
11684,
9404,
25,
609,
495,
11,
3601,
13974,
25,
609,
495,
11,
3601,
37151,
25,
609,
495,
8,
341,
286,
1077,
3601,
6483,
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_binary_min_max_all_nulls() {
let a = BinaryArray::<i32>::from(&[None::<&[u8]>, None]);
assert_eq!(None, min_binary(&a));
assert_eq!(None, max_binary(&a));
} | rust_cleaned_test_functions.jsonl/112102 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 91
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31761,
7260,
6345,
5705,
15162,
82,
368,
341,
262,
1077,
264,
284,
17718,
1857,
27638,
72,
18,
17,
6831,
1499,
2099,
58,
4064,
27638,
5,
58,
84,
23,
60,
8066,
2240,
2558,
262,
2060,
10714,
102... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_fuzz() {
let loader_id = bpf_loader::id();
let program_id = Pubkey::new_unique();
// 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();
// Mangle the whole file
fuzz(
&elf,
1_000_000_000,
100,
0..elf.len(),
0..255,
|bytes: &mut [u8]| {
let mut program_account = AccountSharedData::new(1, 0, &loader_id);
program_account.set_data(bytes.to_vec());
program_account.set_executable(true);
process_instruction(
&loader_id,
&[],
&[],
vec![(program_id, program_account)],
Vec::new(),
Ok(()),
);
},
);
} | rust_cleaned_test_functions.jsonl/3082 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 586
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
761,
8889,
368,
341,
286,
1077,
16047,
842,
284,
293,
15897,
22139,
486,
307,
543,
286,
1077,
2025,
842,
284,
22611,
792,
486,
931,
21218,
1428,
286,
442,
4230,
2025,
2692,
198,
286,
1077,
5206,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_left_join() {
let s0 = Series::new("days", &[0, 1, 2, 3, 4]);
let s1 = Series::new("temp", &[22.1, 19.9, 7., 2., 3.]);
let temp = DataFrame::new(vec![s0, s1]).unwrap();
let s0 = Series::new("days", &[1, 2]);
let s1 = Series::new("rain", &[0.1, 0.2]);
let rain = DataFrame::new(vec![s0, s1]).unwrap();
let joined = temp.left_join(&rain, "days", "days").unwrap();
println!("{}", &joined);
assert_eq!(
(joined.column("rain").unwrap().sum::<f32>().unwrap() * 10.).round(),
3.
);
assert_eq!(joined.column("rain").unwrap().null_count(), 3);
// test join on utf8
let s0 = Series::new("days", &["mo", "tue", "wed", "thu", "fri"]);
let s1 = Series::new("temp", &[22.1, 19.9, 7., 2., 3.]);
let temp = DataFrame::new(vec![s0, s1]).unwrap();
let s0 = Series::new("days", &["tue", "wed"]);
let s1 = Series::new("rain", &[0.1, 0.2]);
let rain = DataFrame::new(vec![s0, s1]).unwrap();
let joined = temp.left_join(&rain, "days", "days").unwrap();
println!("{}", &joined);
assert_eq!(
(joined.column("rain").unwrap().sum::<f32>().unwrap() * 10.).round(),
3.
);
assert_eq!(joined.column("rain").unwrap().null_count(), 3);
} | rust_cleaned_test_functions.jsonl/4173 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 688
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9579,
31017,
368,
341,
286,
1077,
274,
15,
284,
11131,
486,
931,
445,
13778,
497,
44590,
15,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
2558,
286,
1077,
274,
16,
284,
11131,
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_handshake_message_finished() -> Result<()> {
let raw_finished = vec![
0x01, 0x01, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
];
let parsed_finished = HandshakeMessageFinished {
verify_data: raw_finished.clone(),
};
let mut reader = BufReader::new(raw_finished.as_slice());
let c = HandshakeMessageFinished::unmarshal(&mut reader)?;
assert_eq!(
c, parsed_finished,
"handshakeMessageFinished unmarshal: got {:?}, want {:?}",
c, parsed_finished
);
let mut raw = vec![];
{
let mut writer = BufWriter::<&mut Vec<u8>>::new(raw.as_mut());
c.marshal(&mut writer)?;
}
assert_eq!(
raw, raw_finished,
"handshakeMessageFinished marshal: got {:?}, want {:?}",
raw, raw_finished
);
Ok(())
} | rust_cleaned_test_functions.jsonl/81553 | {
"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,
23194,
29661,
6462,
56423,
368,
1464,
5714,
71698,
341,
262,
1077,
7112,
56423,
284,
7486,
90515,
286,
220,
15,
87,
15,
16,
11,
220,
15,
87,
15,
16,
11,
220,
15,
87,
15,
18,
11,
220,
15,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_complex() {
let style = Style::new(
r#"
background-color: black;
.with-class {
color: red;
}
@media screen and (max-width: 600px) {
color: yellow;
}
@supports (display: grid) {
display: grid;
}
header, footer {
border: 1px solid black;
@supports (max-width: 500px) {
@media screen and (max-width: 500px) {
display: flex;
}
}
}
"#,
)
.expect("Failed to create Style.");
assert_eq!(
style.get_style_str(),
format!(
r#".{style_name} {{
background-color: black;
}}
.{style_name} .with-class {{
color: red;
}}
@media screen and (max-width: 600px) {{
.{style_name} {{
color: yellow;
}}
}}
@supports (display: grid) {{
.{style_name} {{
display: grid;
}}
}}
.{style_name} header, .{style_name} footer {{
border: 1px solid black;
}}
@supports (max-width: 500px) {{
@media screen and (max-width: 500px) {{
.{style_name} header, .{style_name} footer {{
display: flex;
}}
}}
}}
"#,
style_name = style.get_class_name()
)
)
} | rust_cleaned_test_functions.jsonl/43945 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 889
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
41522,
368,
341,
286,
1077,
1707,
284,
11913,
486,
931,
1006,
310,
435,
2,
698,
394,
4004,
7889,
25,
3691,
280,
394,
659,
4197,
14800,
341,
503,
1894,
25,
2518,
280,
394,
456,
394,
569,
7399,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_rng_range() {
crate::init().unwrap();
let mut generator = Generator;
let min: u64 = 123;
let max: u64 = 9876;
for _ in 0..100 {
let n: u64 = generator.gen_range(min..max);
assert!(min <= n);
assert!(n < max);
}
} | rust_cleaned_test_functions.jsonl/64557 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 138
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
66849,
9698,
368,
341,
262,
17717,
486,
2327,
1005,
15454,
1428,
262,
1077,
5206,
13823,
284,
28358,
280,
262,
1077,
1308,
25,
575,
21,
19,
284,
220,
16,
17,
18,
280,
262,
1077,
1932,
25,
575,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_kill_partition_switch_threshold_progress() {
let max_switch_threshold_failure_pct = 1.0 - 2.0 * SWITCH_FORK_THRESHOLD;
let total_stake = 10_000;
// Kill `< max_failures_stake` of the validators
let max_failures_stake = (max_switch_threshold_failure_pct * total_stake as f64) as u64;
let failures_stake = max_failures_stake - 1;
let total_alive_stake = total_stake - failures_stake;
// once the partition resolves
let alive_stake_1 = total_alive_stake / 2;
let alive_stake_2 = total_alive_stake - alive_stake_1;
let bigger = std::cmp::max(alive_stake_1, alive_stake_2);
let smaller = std::cmp::min(alive_stake_1, alive_stake_2);
// At least one of the forks must have > SWITCH_FORK_THRESHOLD in order
// to guarantee switching proofs can be created. Make sure the other fork
// is <= SWITCH_FORK_THRESHOLD to make sure progress can be made. Caches
// 1) Not be able to generate a switching proof
assert!(
bigger as f64 / total_stake as f64 > SWITCH_FORK_THRESHOLD
&& smaller as f64 / total_stake as f64 <= SWITCH_FORK_THRESHOLD
);
let on_partition_start =
|_: &mut LocalCluster, _: &[Pubkey], _: Vec<ClusterValidatorInfo>, _: &mut ()| {};
let on_before_partition_resolved = |_: &mut LocalCluster, _: &mut ()| {};
let on_partition_resolved = |cluster: &mut LocalCluster, _: &mut ()| {
cluster.check_for_new_roots(16, "PARTITION_TEST", SocketAddrSpace::Unspecified);
};
run_kill_partition_switch_threshold(
&[&[(failures_stake as usize, 16)]],
&[
&[(alive_stake_1 as usize, 8)],
&[(alive_stake_2 as usize, 8)],
],
None,
None,
(),
on_partition_start,
on_before_partition_resolved,
on_partition_resolved,
);
} | rust_cleaned_test_functions.jsonl/31758 | {
"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,
73327,
43840,
27652,
21858,
27200,
368,
341,
262,
1077,
1932,
27652,
21858,
43618,
71512,
284,
220,
16,
13,
15,
481,
220,
17,
13,
15,
353,
72543,
1400,
10647,
44405,
280,
262,
1077,
2790,
1261,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_insert_conflicts() {
let mut m = HashMap::with_capacity(4);
assert!(m.insert(1, 2).is_none());
assert!(m.insert(5, 3).is_none());
assert!(m.insert(9, 4).is_none());
assert_eq!(*m.get(&9).unwrap(), 4);
assert_eq!(*m.get(&5).unwrap(), 3);
assert_eq!(*m.get(&1).unwrap(), 2);
} | rust_cleaned_test_functions.jsonl/8505 | {
"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,
17678,
16059,
56445,
368,
341,
286,
1077,
5206,
296,
284,
10528,
486,
4197,
35603,
7,
19,
317,
286,
2060,
10297,
76,
7030,
7,
16,
11,
220,
17,
568,
285,
31488,
1423,
286,
2060,
10297,
76,
7030... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_as_mut() {
unsafe {
let p: *mut isize = null_mut();
assert!(p.as_mut() == None);
let q: *mut isize = &mut 2;
assert!(q.as_mut().unwrap() == &mut 2);
// Lifetime inference
let mut u = 2isize;
{
let p = &mut u as *mut isize;
assert!(p.as_mut().unwrap() == &mut 2);
}
// Pointers to unsized types -- slices
let s: &mut [u8] = &mut [1, 2, 3];
let ms: *mut [u8] = s;
assert_eq!(ms.as_mut(), Some(&mut [1, 2, 3][..]));
let mz: *mut [u8] = &mut [];
assert_eq!(mz.as_mut(), Some(&mut [][..]));
let nms: *mut [u8] = null_mut::<[u8; 3]>();
assert_eq!(nms.as_mut(), None);
// Pointers to unsized types -- trait objects
let mi: *mut dyn ToString = &mut 3;
assert!(mi.as_mut().is_some());
let nmi: *mut dyn ToString = null_mut::<isize>();
assert!(nmi.as_mut().is_none());
}
} | rust_cleaned_test_functions.jsonl/18509 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 524
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11898,
29523,
368,
341,
262,
19860,
341,
286,
1077,
281,
25,
353,
6984,
91373,
284,
845,
29523,
543,
286,
2060,
10297,
79,
5357,
29523,
368,
621,
2240,
626,
286,
1077,
2804,
25,
353,
6984,
91373... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_format_php_version() {
let input = "7.3.8";
assert_eq!(format_php_version(input), "v7.3.8".to_string());
} | rust_cleaned_test_functions.jsonl/68255 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 77
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8955,
78547,
9438,
368,
341,
286,
1077,
1946,
284,
330,
22,
13,
18,
13,
23,
876,
286,
2060,
10714,
10297,
2243,
78547,
9438,
5384,
701,
330,
85,
22,
13,
18,
13,
23,
3263,
983,
3904,
1423,
26... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_append_from_set() {
let mut collection: OneOrSet<MockKeyU8> = OneOrSet::new_set((0..42).map(MockKeyU8).collect()).unwrap();
assert_eq!(collection.len(), 42);
// Appends to end.
collection.append(MockKeyU8(42));
let expected: OneOrSet<MockKeyU8> = OneOrSet::new_set((0..=42).map(MockKeyU8).collect()).unwrap();
assert_eq!(collection, expected);
assert_eq!(collection.len(), 43);
// Ignores duplicates.
for i in 0..=42 {
collection.append(MockKeyU8(i));
assert_eq!(collection, expected);
assert_eq!(collection.len(), 43);
}
} | rust_cleaned_test_functions.jsonl/5920 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 260
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26041,
5673,
2602,
368,
341,
262,
1077,
5206,
4426,
25,
3776,
2195,
1649,
27,
11571,
1592,
52,
23,
29,
284,
3776,
2195,
1649,
486,
931,
2602,
1188,
15,
496,
19,
17,
568,
2186,
66436,
1592,
52,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_serial_off() {
let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
let guest = Guest::new(Box::new(focal));
let mut child = GuestCommand::new(&guest)
.args(&["--cpus", "boot=1"])
.args(&["--memory", "size=512M"])
.args(&["--kernel", direct_kernel_boot_path().to_str().unwrap()])
.args(&["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
.default_disks()
.default_net()
.args(&["--serial", "off"])
.capture_output()
.spawn()
.unwrap();
let r = std::panic::catch_unwind(|| {
guest.wait_vm_boot(None).unwrap();
// Test that there is no ttyS0
assert_eq!(
guest
.ssh_command(GREP_SERIAL_IRQ_CMD)
.unwrap()
.trim()
.parse::<u32>()
.unwrap_or(1),
0
);
});
let _ = child.kill();
let output = child.wait_with_output().unwrap();
handle_child_output(r, &output);
} | rust_cleaned_test_functions.jsonl/26148 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 662
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25602,
13651,
368,
341,
286,
1077,
41099,
284,
34960,
47583,
2648,
486,
931,
7,
3788,
49533,
19121,
4708,
2389,
3904,
1423,
286,
1077,
8640,
284,
26215,
486,
931,
67758,
486,
931,
955,
3683,
1106,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_variance() {
let variance = |x: Pareto| x.variance().unwrap();
test_case(1.0, 3.0, 0.75, variance);
test_almost(10.0, 10.0, 125.0 / 81.0, 1e-13, variance);
} | rust_cleaned_test_functions.jsonl/18748 | {
"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,
77450,
368,
341,
286,
1077,
32273,
284,
760,
87,
25,
74185,
983,
91,
856,
19526,
5284,
1005,
15454,
543,
286,
1273,
19096,
7,
16,
13,
15,
11,
220,
18,
13,
15,
11,
220,
15,
13,
22,
20,
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_try_generate_state() {
let key_1 = key_pair::random();
let addr_1: H160 = digest::digest(&digest::SHA256, key_1.public_key().as_ref()).into();
let random_h256 = generate_random_hash();
let signed_coinbase_tran = generate_signed_coinbase_transaction(&key_1);
let content = Content::new_with_trans(&vec![signed_coinbase_tran.clone()]);
let header = generate_header(&random_h256, &content, 0, &random_h256);
let block = Block::new(header, content.clone());
let new_state = block.try_generate_state(&State::new());
if let Some(state) = new_state.clone() {
assert!(state.contains_key(&(signed_coinbase_tran.hash.clone(), 0)));
let value = state.get(&(signed_coinbase_tran.hash.clone(), 0)).unwrap().clone();
assert_eq!((COINBASE_REWARD, addr_1.clone()), value);
} else {
assert!(false);
}
let signed_coinbase_tran_2 = generate_signed_coinbase_transaction(&key_1);
let content = Content::new_with_trans(&vec![signed_coinbase_tran_2.clone()]);
let header = generate_header(&random_h256, &content, 0, &random_h256);
let block = Block::new(header, content.clone());
let state_2 = block.try_generate_state(&new_state.unwrap());
if let Some(state) = state_2.clone() {
assert!(state.contains_key(&(signed_coinbase_tran.hash.clone(), 0)));
let value = state.get(&(signed_coinbase_tran.hash.clone(), 0)).unwrap().clone();
assert_eq!((COINBASE_REWARD, addr_1.clone()), value);
assert!(state.contains_key(&(signed_coinbase_tran_2.hash.clone(), 0)));
let value = state.get(&(signed_coinbase_tran_2.hash.clone(), 0)).unwrap().clone();
assert_eq!((COINBASE_REWARD, addr_1.clone()), value);
} else {
assert!(false);
}
// correct
let signed_coinbase_tran_3 = generate_signed_coinbase_transaction(&key_1);
let random_h160 = generate_random_h160();
let txinput = TxInput {pre_hash: signed_coinbase_tran_2.hash.clone(), index: 0};
let txoutput_1 = TxOutput {rec_address: random_h160, val: COINBASE_REWARD-1};
let txoutput_2 = TxOutput {rec_address: random_h160, val: 1};
let valid_tran = generate_signed_transaction(&key_1, vec![txinput], vec![txoutput_1, txoutput_2]);
let content = Content::new_with_trans(&vec![signed_coinbase_tran_3.clone(), valid_tran.clone()]);
let header = generate_header(&random_h256, &content, 0, &random_h256);
let block = Block::new(header, content.clone());
let non_state = block.try_generate_state(&state_2.clone().unwrap());
if let Some(state) = non_state.clone() {
assert!(!state.contains_key(&(signed_coinbase_tran_2.hash.clone(), 0)));
assert!(state.contains_key(&(valid_tran.hash.clone(), 0)));
assert!(state.contains_key(&(valid_tran.hash.clone(), 1)));
let value = state.get(&(valid_tran.hash.clone(), 0)).unwrap().clone();
assert_eq!((COINBASE_REWARD-1, random_h160), value);
let value = state.get(&(valid_tran.hash.clone(), 1)).unwrap().clone();
assert_eq!((1, random_h160), value);
} else {
assert!(false);
}
// wrong: output is bigger than input
let signed_coinbase_tran = generate_signed_coinbase_transaction(&key_1);
let random_h160 = generate_random_h160();
let txinput = TxInput {pre_hash: signed_coinbase_tran_2.hash.clone(), index: 0};
let txoutput = TxOutput {rec_address: random_h160, val: COINBASE_REWARD+1};
let invalid_tran = generate_signed_transaction(&key_1, vec![txinput], vec![txoutput]);
let content = Content::new_with_trans(&vec![signed_coinbase_tran.clone(), invalid_tran.clone()]);
let header = generate_header(&random_h256, &content, 0, &random_h256);
let block = Block::new(header, content.clone());
let non_state = block.try_generate_state(&state_2.clone().unwrap());
if let Some(_) = non_state {
assert!(false);
}
// wrong public key
let key_2 = key_pair::random();
let signed_coinbase_tran = generate_signed_coinbase_transaction(&key_1);
let random_h160 = generate_random_h160();
let txinput = TxInput {pre_hash: signed_coinbase_tran_2.hash.clone(), index: 0};
let txoutput = TxOutput {rec_address: random_h160, val: COINBASE_REWARD};
let invalid_tran = generate_signed_transaction(&key_2, vec![txinput], vec![txoutput]); // wrong public key
let content = Content::new_with_trans(&vec![signed_coinbase_tran.clone(), invalid_tran.clone()]);
let header = generate_header(&random_h256, &content, 0, &random_h256);
let block = Block::new(header, content.clone());
let non_state = block.try_generate_state(&state_2.clone().unwrap());
if let Some(_) = non_state {
assert!(false);
}
// wrong pre_hash
let signed_coinbase_tran = generate_signed_coinbase_transaction(&key_1);
let random_h160 = generate_random_h160();
let txinput = TxInput {pre_hash: generate_random_hash(), index: 0};
let txoutput = TxOutput {rec_address: random_h160, val: COINBASE_REWARD};
let invalid_tran = generate_signed_transaction(&key_1, vec![txinput], vec![txoutput]);
let content = Content::new_with_trans(&vec![signed_coinbase_tran.clone(), invalid_tran.clone()]);
let header = generate_header(&random_h256, &content, 0, &random_h256);
let block = Block::new(header, content.clone());
let non_state = block.try_generate_state(&state_2.clone().unwrap());
if let Some(_) = non_state {
assert!(false);
}
} | rust_cleaned_test_functions.jsonl/18475 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2545
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
53283,
48851,
4387,
368,
341,
286,
1077,
1376,
62,
16,
284,
1376,
14445,
486,
11463,
543,
286,
1077,
10789,
62,
16,
25,
472,
16,
21,
15,
284,
20882,
486,
36339,
2099,
36339,
486,
33145,
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... | 7 |
#[test]
fn test_closest_to_zero() {
let input = "p=< 3,0,0>, v=< 2,0,0>, a=<-1,0,0>\n\
p=< 4,0,0>, v=< 0,0,0>, a=<-2,0,0>\n";
let particles = Particle::load_group(input);
assert_eq!(find_closest_to_zero(particles.iter()), Some(0));
} | rust_cleaned_test_functions.jsonl/41538 | {
"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,
12704,
267,
2346,
19359,
368,
341,
262,
1077,
1946,
284,
330,
79,
38698,
220,
18,
11,
15,
11,
15,
8066,
348,
38698,
220,
17,
11,
15,
11,
15,
8066,
264,
38698,
12,
16,
11,
15,
11,
15,
8449,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_crds_filter_default() {
let filter = CrdsFilter::default();
let mask = CrdsFilter::compute_mask(0, filter.mask_bits);
assert_eq!(filter.mask, mask);
let mut rng = thread_rng();
for _ in 0..10 {
let hash = solana_sdk::hash::new_rand(&mut rng);
assert!(filter.test_mask(&hash));
}
} | rust_cleaned_test_functions.jsonl/82266 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 188
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
32331,
5356,
8727,
9993,
368,
341,
286,
1077,
4051,
284,
4553,
5356,
5632,
486,
2258,
543,
286,
1077,
6911,
284,
4553,
5356,
5632,
486,
27706,
9999,
7,
15,
11,
4051,
35179,
20034,
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... | 2 |
#[test]
fn test_numerical_identifiers() {
let data = [
0x0c, 0x00, 0x59, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0c, 0x00, 0x1e, 0x00, 0x00, 0x00,
];
assert_eq!(
parse(&data[..]).unwrap().token_tape,
vec![BinaryToken::I32(89), BinaryToken::I32(30),]
);
} | rust_cleaned_test_functions.jsonl/109414 | {
"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,
99001,
938,
38399,
11836,
368,
341,
286,
1077,
821,
284,
2278,
310,
220,
15,
87,
15,
66,
11,
220,
15,
87,
15,
15,
11,
220,
15,
87,
20,
24,
11,
220,
15,
87,
15,
15,
11,
220,
15,
87,
15,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_product_update() {
get_setup();
let url = env::var("INTEGRATION_TEST_URL").unwrap_or("http://gridd:8080".to_string());
//run `grid product create`
let mut cmd_product_create = make_grid_command();
cmd_product_create
.arg("product")
.args(&["--url", &url])
.arg("create")
.args(&["--file", &PRODUCT_CREATE_FILE])
.args(&["--wait", "300000"]);
cmd_product_create.assert().success();
//run `grid product update`
let mut cmd_product_update = make_grid_command();
cmd_product_update
.arg("product")
.args(&["--url", &url])
.arg("update")
.args(&["--file", &PRODUCT_UPDATE_FILE])
.args(&["--wait", "300000"]);
cmd_product_update.assert().success();
} | rust_cleaned_test_functions.jsonl/55901 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 429
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9840,
8882,
368,
341,
286,
633,
21363,
543,
286,
1077,
2515,
284,
6105,
486,
947,
445,
687,
68003,
3495,
11641,
8000,
1827,
15454,
8734,
445,
1254,
1110,
901,
1772,
25,
23,
15,
23,
15,
3263,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_no_legacy_checksums() {
let config = r#"
[[package]]
name = "aho-corasick"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
"#;
let resolve = EncodableResolve::load_lock_string(Path::new("dummy"), config).unwrap();
assert_eq!(resolve.get_hashes_by_package_id().unwrap(), HashMap::new());
} | rust_cleaned_test_functions.jsonl/89396 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 203
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6536,
97555,
64038,
82,
368,
341,
262,
1077,
2193,
284,
435,
2,
698,
15505,
1722,
14288,
606,
284,
330,
28582,
45613,
300,
865,
698,
4366,
284,
330,
15,
13,
22,
13,
21,
698,
2427,
284,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_serde_roundtrip() {
::init().unwrap();
let mut buffer = Buffer::from_slice(vec![1, 2, 3, 4]);
{
let buffer = buffer.get_mut().unwrap();
buffer.set_pts(1.into());
buffer.set_offset(3);
buffer.set_offset_end(4);
buffer.set_duration(5.into());
buffer.set_flags(BufferFlags::LIVE | BufferFlags::DISCONT);
}
// Ron
let buffer_ser = ron::ser::to_string(&buffer).unwrap();
let buffer_de: Buffer = ron::de::from_str(buffer_ser.as_str()).unwrap();
assert_eq!(buffer_de.get_pts(), buffer.get_pts());
assert_eq!(buffer_de.get_dts(), buffer.get_dts());
assert_eq!(buffer_de.get_offset(), buffer.get_offset());
assert_eq!(buffer_de.get_offset_end(), buffer.get_offset_end());
assert_eq!(buffer_de.get_duration(), buffer.get_duration());
assert_eq!(buffer_de.get_flags(), buffer.get_flags());
{
let data = buffer_de.map_readable().unwrap();
assert_eq!(data.as_slice(), vec![1, 2, 3, 4].as_slice());
}
} | rust_cleaned_test_functions.jsonl/69951 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 553
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
75861,
450,
29896,
32981,
368,
341,
286,
3504,
2327,
1005,
15454,
1428,
286,
1077,
5206,
4147,
284,
10312,
486,
1499,
26488,
25592,
20703,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
2558,
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_call_hierarchy_in_same_fn() {
check_hierarchy(
r#"
//- /lib.rs
fn callee() {}
fn caller() {
call<|>ee();
callee();
}
"#,
"callee FN_DEF FileId(1) [0; 14) [3; 9)",
&["caller FN_DEF FileId(1) [15; 58) [18; 24) : [[33; 39), [47; 53)]"],
&[],
);
} | rust_cleaned_test_functions.jsonl/35202 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 284
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13429,
95043,
1243,
33574,
15246,
368,
341,
286,
1779,
95043,
1006,
310,
435,
2,
698,
310,
78406,
608,
2740,
25638,
198,
310,
5168,
94800,
368,
5613,
310,
5168,
19865,
368,
341,
394,
1618,
27,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_verification_report_with_pib() {
let report = VerificationReport {
sig: VerificationSignature::default(),
chain: Vec::default(),
http_body: String::from(IAS_WITH_PIB.trim()),
};
let data = VerificationReportData::try_from(&report)
.expect("Could not parse IAS verification report");
let timestamp = data.parse_timestamp().expect("failed parsing timestamp");
assert_eq!(timestamp.to_rfc3339(), "2019-06-19T22:11:17.616333+00:00");
} | rust_cleaned_test_functions.jsonl/55870 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 239
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
84245,
14813,
6615,
620,
579,
368,
341,
286,
1077,
1895,
284,
55473,
10361,
341,
310,
8366,
25,
55473,
25088,
486,
2258,
3148,
310,
8781,
25,
11312,
486,
2258,
3148,
310,
1758,
14114,
25,
923,
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_proposal_prevent_sleep() {
let mut cluster = new_node_cluster(0, 3);
configure_for_hibernate(&mut cluster);
cluster.run();
cluster.must_transfer_leader(1, new_peer(1, 1));
cluster.must_put(b"k1", b"v1");
must_get_equal(&cluster.get_engine(3), b"k1", b"v1");
// Wait till leader peer goes to sleep.
thread::sleep(
cluster.cfg.raft_store.raft_base_tick_interval.0
* 2
* cluster.cfg.raft_store.raft_election_timeout_ticks as u32,
);
cluster.add_send_filter(CloneFilterFactory(
RegionPacketFilter::new(1, 1).direction(Direction::Send),
));
let region = block_on(cluster.pd_client.get_region_by_id(1))
.unwrap()
.unwrap();
let put = new_put_cmd(b"k2", b"v2");
let mut req = new_request(1, region.get_region_epoch().clone(), vec![put], true);
req.mut_header().set_peer(new_peer(1, 1));
let _ = cluster.call_command(req, Duration::from_millis(10));
cluster.clear_send_filters();
must_get_equal(&cluster.get_engine(3), b"k2", b"v2");
assert_eq!(cluster.leader_of_region(1), Some(new_peer(1, 1)));
// Wait till leader peer goes to sleep.
thread::sleep(
cluster.cfg.raft_store.raft_base_tick_interval.0
* 2
* cluster.cfg.raft_store.raft_election_timeout_ticks as u32,
);
cluster.add_send_filter(CloneFilterFactory(
RegionPacketFilter::new(1, 1).direction(Direction::Send),
));
let mut request = new_request(
region.get_id(),
region.get_region_epoch().clone(),
vec![new_read_index_cmd()],
true,
);
request.mut_header().set_peer(new_peer(1, 1));
let (cb, rx) = make_cb(&request);
// send to peer 2
cluster
.sim
.rl()
.async_command_on_node(1, request, cb)
.unwrap();
thread::sleep(Duration::from_millis(10));
cluster.clear_send_filters();
let resp = rx.recv_timeout(Duration::from_secs(5)).unwrap();
assert!(
!resp.get_header().has_error(),
"{:?}",
resp.get_header().get_error()
);
// Wait till leader peer goes to sleep.
thread::sleep(
cluster.cfg.raft_store.raft_base_tick_interval.0
* 2
* cluster.cfg.raft_store.raft_election_timeout_ticks as u32,
);
cluster.add_send_filter(CloneFilterFactory(
RegionPacketFilter::new(1, 1).direction(Direction::Send),
));
let conf_change = new_change_peer_request(ConfChangeType::RemoveNode, new_peer(3, 3));
let mut admin_req = new_admin_request(1, ®ion.get_region_epoch(), conf_change);
admin_req.mut_header().set_peer(new_peer(1, 1));
let (cb, _rx) = make_cb(&admin_req);
cluster
.sim
.rl()
.async_command_on_node(1, admin_req, cb)
.unwrap();
thread::sleep(Duration::from_millis(10));
cluster.clear_send_filters();
cluster.pd_client.must_none_peer(1, new_peer(3, 3));
} | rust_cleaned_test_functions.jsonl/50286 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1361
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21663,
32556,
10442,
684,
49393,
368,
341,
262,
1077,
5206,
10652,
284,
501,
5084,
28441,
7,
15,
11,
220,
18,
317,
262,
14411,
5478,
1523,
18818,
2099,
6984,
10652,
317,
262,
10652,
7634,
543,
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_two_idents() {
parse_macro(
r#"
macro_rules! foo {
($ i:ident, $ j:ident) => {
fn foo() { let a = $ i; let b = $j; }
}
}
"#,
)
.assert_expand_items("foo! { foo, bar }", "fn foo () {let a = foo ; let b = bar ;}");
} | rust_cleaned_test_functions.jsonl/28723 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 180
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
23241,
842,
805,
368,
341,
262,
4715,
58810,
1006,
286,
435,
2,
698,
286,
18072,
21407,
0,
15229,
341,
310,
1711,
600,
25,
1713,
11,
400,
502,
25,
1713,
8,
589,
341,
394,
5168,
15229,
368,
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_split_messages_large() {
let value = CrdsValue::new_unsigned(CrdsData::LowestSlot(
0,
LowestSlot::new(Pubkey::default(), 0, 0),
));
test_split_messages(value);
} | rust_cleaned_test_functions.jsonl/11665 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 122
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17052,
23428,
45228,
368,
341,
286,
1077,
897,
284,
4553,
5356,
1130,
486,
931,
67830,
3025,
81,
5356,
1043,
486,
24187,
477,
19877,
1006,
310,
220,
15,
345,
310,
68530,
19877,
486,
931,
5304,
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 |
#[test]
fn test_option_debug_string_property() {
fn make_string_property(value: &str) -> Property {
Property::String("name".to_owned(), value.to_owned())
}
fn dbg<D: std::fmt::Debug>(d: D) -> String {
format!("{:?}", d)
}
// trivial ok
assert_matches!(
OptionDebugStringProperty::Some(AnyProperty).run(&make_string_property("Some()")),
Ok(())
);
assert_matches!(
OptionDebugStringProperty::<AnyProperty>::None.run(&make_string_property("None")),
Ok(())
);
// trivial err
assert_matches!(
OptionDebugStringProperty::Some(AnyProperty).run(&make_string_property("None")),
Err(_)
);
assert_matches!(
OptionDebugStringProperty::Some(AnyProperty).run(&make_string_property("Some(foo")),
Err(_)
);
assert_matches!(
OptionDebugStringProperty::<AnyProperty>::None.run(&make_string_property("Some()")),
Err(_)
);
// non-empty inner ok
assert_matches!(
OptionDebugStringProperty::Some(AnyProperty).run(&make_string_property("Some(value)")),
Ok(())
);
assert_matches!(
OptionDebugStringProperty::Some(dbg("string"))
.run(&make_string_property("Some(\"string\")")),
Ok(())
);
// non-empty inner err
assert_matches!(
OptionDebugStringProperty::Some(dbg("a")).run(&make_string_property("Some(\"b\")")),
Err(_)
);
} | rust_cleaned_test_functions.jsonl/37512 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 633
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9672,
15446,
3904,
16638,
368,
341,
262,
5168,
1281,
3904,
16638,
3679,
25,
609,
495,
8,
1464,
8655,
341,
286,
8655,
486,
703,
445,
606,
3263,
983,
51973,
1507,
897,
2389,
51973,
2398,
262,
555,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_greeting() {
let string = greeting("carol");
assert!(
string.contains("carol"),
"Greeting did not contain name, value was `{}`",
string
);
} | rust_cleaned_test_functions.jsonl/97299 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 121
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1889,
43632,
368,
341,
286,
1077,
914,
284,
42113,
445,
6918,
337,
797,
286,
2060,
33673,
310,
914,
8786,
445,
6918,
337,
4461,
310,
330,
38,
43632,
1521,
537,
6644,
829,
11,
897,
572,
53692,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_server_push_promise_frame_on_control_stream() {
test_wrong_frame_on_control_stream(&[0x5, 0x2, 0x1, 0x2]);
} | rust_cleaned_test_functions.jsonl/52185 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 72
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12015,
14218,
620,
5273,
8929,
4470,
13436,
12673,
368,
341,
286,
1273,
75198,
8929,
4470,
13436,
12673,
2099,
58,
15,
87,
20,
11,
220,
15,
87,
17,
11,
220,
15,
87,
16,
11,
220,
15,
87,
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 |
#[test]
fn test_decimal_offsets() {
// Test the case where offset != 0
let a = create_decimal_array(&[
Some(8_887_000_000),
None,
None,
Some(-8_887_000_000),
None,
None,
]);
let b = create_decimal_array(&[
None,
Some(8_887_000_000),
None,
None,
Some(15_887_000_000),
None,
None,
]);
let a_slice = a.slice(0, 3);
let b_slice = b.slice(1, 3);
test_equal(&a_slice, &b_slice, true);
let a_slice = a.slice(0, 5);
let b_slice = b.slice(1, 5);
test_equal(&a_slice, &b_slice, false);
let a_slice = a.slice(4, 1);
let b_slice = b.slice(5, 1);
test_equal(&a_slice, &b_slice, true);
let a_slice = a.slice(3, 3);
let b_slice = b.slice(4, 3);
test_equal(&a_slice, &b_slice, false);
let a_slice = a.slice(1, 3);
let b_slice = b.slice(2, 3);
test_equal(&a_slice, &b_slice, false);
let b = create_decimal_array(&[
None,
None,
None,
Some(-8_887_000_000),
Some(-3_000),
None,
]);
let a_slice = a.slice(1, 3);
let b_slice = b.slice(1, 3);
test_equal(&a_slice, &b_slice, true);
} | rust_cleaned_test_functions.jsonl/24224 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 829
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
74429,
56924,
368,
341,
286,
442,
3393,
279,
1142,
1380,
4347,
961,
220,
15,
198,
286,
1077,
264,
284,
1855,
74429,
3858,
2099,
9640,
310,
4329,
7,
23,
62,
23,
23,
22,
62,
15,
15,
15,
62,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_zinc_dict_comma_decode() {
let value: Value = from_str(r#"{a,b,c}"#).unwrap();
assert_eq!(
value,
Value::make_dict(dict! {"a"=> Value::Marker, "b"=> Value::Marker,"c"=> Value::Marker})
);
} | rust_cleaned_test_functions.jsonl/6388 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 122
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6415,
2840,
5243,
2965,
1728,
15227,
368,
341,
262,
1077,
897,
25,
5162,
284,
504,
2895,
2601,
2,
14129,
64,
8402,
10109,
9863,
2,
568,
15454,
543,
262,
2060,
10714,
33673,
286,
897,
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_byte_vec_message_as_ref_uci_message() {
let uci = ByteVecUciMessage::from(UciMessage::Uci);
let um: &UciMessage = uci.as_ref();
assert_eq!(*um, UciMessage::Uci);
} | rust_cleaned_test_functions.jsonl/19076 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 107
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19737,
13251,
6462,
11898,
7793,
62,
42409,
6462,
368,
341,
286,
1077,
575,
5855,
284,
10906,
10050,
52,
5855,
2052,
486,
1499,
12317,
5855,
2052,
486,
52,
5855,
317,
286,
1077,
4443,
25,
609,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_from_vecref() {
let r = &VecRef {
x: NotNan::new(0.0).unwrap(),
y: NotNan::new(1.0).unwrap(),
z: NotNan::new(2.0).unwrap(),
};
let v: Vec3 = r.into();
assert_eq!(0.0, v.x);
assert_eq!(1.0, v.y);
assert_eq!(2.0, v.z);
} | rust_cleaned_test_functions.jsonl/32875 | {
"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,
5673,
73285,
837,
69,
368,
341,
286,
1077,
435,
284,
609,
10050,
3945,
341,
310,
856,
25,
2806,
45,
276,
486,
931,
7,
15,
13,
15,
568,
15454,
3148,
310,
379,
25,
2806,
45,
276,
486,
931,
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_withdraw_lockup() {
let stake_pubkey = analog_sdk::pubkey::new_rand();
let custodian = analog_sdk::pubkey::new_rand();
let total_lamports = 100;
let stake_account = AccountSharedData::new_ref_data_with_space(
total_lamports,
&StakeState::Initialized(Meta {
lockup: Lockup {
unix_timestamp: 0,
epoch: 1,
custodian,
},
..Meta::auto(&stake_pubkey)
}),
std::mem::size_of::<StakeState>(),
&id(),
)
.expect("stake_account");
let to = analog_sdk::pubkey::new_rand();
let to_account = AccountSharedData::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 mut clock = Clock::default();
assert_eq!(
stake_keyed_account.withdraw(
total_lamports,
&to_keyed_account,
&clock,
&StakeHistory::default(),
&stake_keyed_account,
None,
true,
),
Err(StakeError::LockupInForce.into())
);
{
let custodian_account = AccountSharedData::new_ref(1, 0, &system_program::id());
let custodian_keyed_account = KeyedAccount::new(&custodian, true, &custodian_account);
assert_eq!(
stake_keyed_account.withdraw(
total_lamports,
&to_keyed_account,
&clock,
&StakeHistory::default(),
&stake_keyed_account,
Some(&custodian_keyed_account),
true,
),
Ok(())
);
}
// reset balance
stake_keyed_account
.account
.borrow_mut()
.set_lamports(total_lamports);
// lockup has expired
let to_keyed_account = KeyedAccount::new(&to, false, &to_account);
clock.epoch += 1;
assert_eq!(
stake_keyed_account.withdraw(
total_lamports,
&to_keyed_account,
&clock,
&StakeHistory::default(),
&stake_keyed_account,
None,
true,
),
Ok(())
);
assert_eq!(stake_keyed_account.state(), Ok(StakeState::Uninitialized));
} | rust_cleaned_test_functions.jsonl/15300 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1525
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6615,
7633,
9818,
454,
368,
341,
286,
1077,
18279,
34014,
792,
284,
23400,
61783,
486,
9585,
792,
486,
931,
33864,
543,
286,
1077,
16564,
63849,
284,
23400,
61783,
486,
9585,
792,
486,
931,
33864,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_accountsdb_add_root_many() {
let db = AccountsDB::new(Vec::new());
let mut pubkeys: Vec<Pubkey> = vec![];
create_account(&db, &mut pubkeys, 0, 100, 0, 0);
for _ in 1..100 {
let idx = thread_rng().gen_range(0, 99);
let ancestors = vec![(0, 0)].into_iter().collect();
let account = db.load_slow(&ancestors, &pubkeys[idx]).unwrap();
let mut default_account = Account::default();
default_account.lamports = (idx + 1) as u64;
assert_eq!((default_account, 0), account);
}
db.add_root(0);
// check that all the accounts appear with a new root
for _ in 1..100 {
let idx = thread_rng().gen_range(0, 99);
let ancestors = vec![(0, 0)].into_iter().collect();
let account0 = db.load_slow(&ancestors, &pubkeys[idx]).unwrap();
let ancestors = vec![(1, 1)].into_iter().collect();
let account1 = db.load_slow(&ancestors, &pubkeys[idx]).unwrap();
let mut default_account = Account::default();
default_account.lamports = (idx + 1) as u64;
assert_eq!(&default_account, &account0.0);
assert_eq!(&default_account, &account1.0);
}
} | rust_cleaned_test_functions.jsonl/33664 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 617
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
55665,
1999,
2891,
12993,
22101,
368,
341,
286,
1077,
2927,
284,
40655,
3506,
486,
931,
49923,
486,
931,
5231,
286,
1077,
5206,
6675,
10563,
25,
11312,
21604,
392,
792,
29,
284,
7486,
0,
15078,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_clean_stuck_transactions() {
let mut pool = setup_mempool().0;
for seq in 0..5 {
add_txn(&mut pool, TestTransaction::new(0, seq, 1)).unwrap();
}
let db_sequence_number = 10;
let txn = TestTransaction::new(0, db_sequence_number, 1).make_signed_transaction();
pool.add_txn(
txn,
0,
1,
db_sequence_number,
TimelineState::NotReady,
GovernanceRole::NonGovernanceRole,
);
let block = pool.get_block(10, HashSet::new());
assert_eq!(block.len(), 1);
assert_eq!(block[0].sequence_number(), 10);
} | rust_cleaned_test_functions.jsonl/80945 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 275
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19573,
1261,
1942,
68182,
368,
341,
262,
1077,
5206,
7314,
284,
6505,
717,
3262,
1749,
1005,
15,
280,
262,
369,
12981,
304,
220,
15,
496,
20,
341,
286,
912,
92299,
2099,
6984,
7314,
11,
3393,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_statsd_client_queuing_buffered_udp_sink_many_threaded() {
let client = new_queuing_buffered_udp_client("cadence");
run_arc_threaded_test(client, NUM_THREADS, NUM_ITERATIONS);
} | rust_cleaned_test_functions.jsonl/21896 | {
"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,
15381,
67,
8179,
47342,
7471,
7776,
291,
69432,
51567,
22101,
10814,
291,
368,
341,
262,
1077,
2943,
284,
501,
47342,
7471,
7776,
291,
69432,
8179,
445,
34455,
763,
797,
262,
1598,
62914,
10814,
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 |
#[test]
fn test_extend_new_tester() {
let mut my_tera = Tera::default();
let mut framework_tera = Tera::default();
framework_tera.register_tester("hello", |_: Option<&JsonValue>, _: &[JsonValue]| Ok(true));
my_tera.extend(&framework_tera).unwrap();
assert!(my_tera.testers.contains_key("hello"));
} | rust_cleaned_test_functions.jsonl/87555 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 155
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
70265,
5921,
4452,
261,
368,
341,
286,
1077,
5206,
847,
62,
50037,
284,
350,
2416,
486,
2258,
543,
286,
1077,
5206,
12626,
62,
50037,
284,
350,
2416,
486,
2258,
543,
286,
12626,
62,
50037,
9929,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ng() {
let calc = RpnCalculator::new(false);
assert!(calc.eval("").is_err());
assert!(calc.eval("1 1 1 +").is_err());
assert!(calc.eval("+ 1 1").is_err());
} | rust_cleaned_test_functions.jsonl/22175 | {
"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,
82102,
368,
341,
286,
1077,
10035,
284,
431,
19958,
55743,
486,
931,
3576,
317,
286,
2060,
10297,
26586,
31710,
80821,
285,
9266,
1423,
286,
2060,
10297,
26586,
31710,
445,
16,
220,
16,
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 |
#[test]
fn test_convert_polytype() {
let type_exp =
Parser::new("(A: T, B: S) => T where T: Addable, S: Divisible").parse_type_expression();
let got = convert_polytype(&type_exp, &mut sub::Substitution::default()).unwrap();
let mut vars = Vec::<types::Tvar>::new();
vars.push(types::Tvar(0));
vars.push(types::Tvar(1));
let mut cons = types::TvarKinds::new();
let mut kind_vector_1 = Vec::<types::Kind>::new();
kind_vector_1.push(types::Kind::Addable);
cons.insert(types::Tvar(0), kind_vector_1);
let mut kind_vector_2 = Vec::<types::Kind>::new();
kind_vector_2.push(types::Kind::Divisible);
cons.insert(types::Tvar(1), kind_vector_2);
let mut req = MonoTypeMap::new();
req.insert("A".to_string(), MonoType::BoundVar(Tvar(0)));
req.insert("B".to_string(), MonoType::BoundVar(Tvar(1)));
let expr = MonoType::from(types::Function {
req,
opt: MonoTypeMap::new(),
pipe: None,
retn: MonoType::BoundVar(Tvar(0)),
});
let want = types::PolyType { vars, cons, expr };
assert_eq!(want, got);
} | rust_cleaned_test_functions.jsonl/131391 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 574
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34910,
36133,
1313,
368,
341,
286,
1077,
943,
14214,
4035,
310,
21102,
486,
931,
31732,
32,
25,
350,
11,
425,
25,
328,
8,
589,
350,
1380,
350,
25,
2691,
480,
11,
328,
25,
8765,
23066,
1827,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_utctime() {
assert_writes::<UtcTime>(&[
(
UtcTime::new(Utc.ymd(1991, 5, 6).and_hms(23, 45, 40)).unwrap(),
b"\x17\x0d910506234540Z",
),
(
UtcTime::new(Utc.timestamp(0, 0)).unwrap(),
b"\x17\x0d700101000000Z",
),
(
UtcTime::new(Utc.timestamp(1258325776, 0)).unwrap(),
b"\x17\x0d091115225616Z",
),
]);
} | rust_cleaned_test_functions.jsonl/129896 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 350
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9165,
60363,
33600,
368,
341,
286,
2060,
1670,
23262,
27638,
97768,
1462,
44784,
9640,
310,
2399,
394,
547,
10413,
1462,
486,
931,
12317,
10413,
13,
1600,
67,
7,
16,
24,
24,
16,
11,
220,
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... | 1 |
#[test]
fn test_zip_nested_sideffectful() {
let mut xs = [0; 6];
let ys = [0; 4];
{
// test that it has the side effect nested inside enumerate
let it = xs.iter_mut().map(|x| *x = 1).enumerate().zip(&ys);
it.count();
}
assert_eq!(&xs, &[1, 1, 1, 1, 1, 0]);
} | rust_cleaned_test_functions.jsonl/8966 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 156
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
42131,
66279,
30862,
1705,
1262,
368,
341,
262,
1077,
5206,
11943,
284,
508,
15,
26,
220,
21,
935,
262,
1077,
31810,
284,
508,
15,
26,
220,
19,
4821,
262,
341,
286,
442,
1273,
429,
432,
702,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_row_insert_rope_at() {
let mut row = Row::new(30);
let rope = Rope::new(String::from("first"), 0);
let rope = rope.concat(Rope::new(String::from("second"), 0));
let rope = rope.concat(Rope::new(String::from("third"), 0));
row.insert_rope_at(5, rope);
assert_eq!(row.rope.unwrap().text(), " firstsecondthird ");
} | rust_cleaned_test_functions.jsonl/14031 | {
"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,
8530,
17678,
26608,
375,
3752,
368,
341,
286,
1077,
5206,
2802,
284,
10801,
486,
931,
7,
18,
15,
317,
286,
1077,
33420,
284,
97896,
486,
931,
2242,
486,
1499,
445,
3896,
3975,
220,
15,
317,
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_dynamic() {
let db = checked_memory_handle();
let sql = "BEGIN;
CREATE TABLE foo(x INTEGER, y TEXT);
INSERT INTO foo VALUES(4, \"hello\");
END;";
db.execute_batch(sql).unwrap();
db.query_row("SELECT * FROM foo", params![], |r| {
assert_eq!(2, r.column_count());
Ok(())
})
.unwrap();
} | rust_cleaned_test_functions.jsonl/25531 | {
"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,
45992,
368,
341,
310,
1077,
2927,
284,
10067,
19195,
10630,
543,
310,
1077,
5704,
284,
330,
37588,
280,
5180,
30776,
14363,
15229,
2075,
30381,
11,
379,
15762,
317,
5180,
39518,
12496,
15229,
14710,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_create_credential_def_fails_when_already_created() {
init!("ledger");
let (schema_id, _) = ::utils::libindy::anoncreds::tests::create_and_write_test_schema(::utils::constants::DEFAULT_SCHEMA_ATTRS);
let my_did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap();
let handle = create_new_credentialdef("1".to_string(),
"name".to_string(),
my_did.clone(),
schema_id.clone(),
"tag_1".to_string(),
r#"{"support_revocation":false}"#.to_string()).unwrap();
let rc = create_new_credentialdef("1".to_string(),
"name".to_string(),
my_did,
schema_id,
"tag_1".to_string(),
r#"{"support_revocation":false}"#.to_string());
assert_eq!(rc.unwrap_err().kind(), VcxErrorKind::CredDefAlreadyCreated);
} | rust_cleaned_test_functions.jsonl/64625 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 764
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8657,
666,
30320,
7844,
761,
6209,
47636,
80772,
27288,
368,
341,
286,
2930,
17223,
50704,
797,
286,
1077,
320,
17349,
842,
11,
27439,
284,
3504,
6031,
486,
2740,
48990,
486,
58910,
85734,
486,
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_all_can_be_set_true() {
let result = SubnetFeatures::from_str(
"ecdsa_signatures,canister_sandboxing,http_requests,bitcoin_testnet",
)
.unwrap();
assert_eq!(
result,
SubnetFeatures {
ecdsa_signatures: true,
canister_sandboxing: true,
http_requests: true,
bitcoin: Some(BitcoinFeature {
network: BitcoinNetwork::Testnet,
status: BitcoinFeatureStatus::Enabled
})
}
);
} | rust_cleaned_test_functions.jsonl/36343 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 338
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5705,
27421,
21263,
2602,
16082,
368,
341,
286,
1077,
1102,
284,
3719,
4711,
21336,
486,
1499,
2895,
1006,
310,
330,
757,
96780,
11172,
2789,
11,
4814,
1571,
643,
31536,
287,
11,
1254,
37216,
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_simple_table_manager() {
let manager = TableManager::new();
assert!(manager.add(-1, 100).is_err());
assert!(manager.add(0, 100).is_err());
for i in 1..=100 {
manager.add(i, i as TableId).unwrap();
}
assert_eq!(manager.size(), 100);
for i in 1..=100 {
assert_eq!(manager.get(i).unwrap(), Table::new(i, i as TableId));
}
for i in 100..110 {
assert_eq!(manager.get(i).unwrap(), Table::new(100, 100));
}
assert!(manager.add(50, 100).is_err());
let mut ans = Vec::new();
for i in 1..50 {
ans.push(i);
}
let table_ids = manager.gc(50).unwrap();
assert_eq!(table_ids, ans);
assert!(manager.gc(50).unwrap().is_empty());
assert!(manager.get(49).is_none());
ans.clear();
for i in 50..100 {
ans.push(i);
}
assert_eq!(manager.gc(100).unwrap(), ans);
assert_eq!(manager.size(), 1);
assert_eq!(manager.get(100).unwrap(), Table::new(100, 100));
} | rust_cleaned_test_functions.jsonl/28804 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 572
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
30015,
5237,
12144,
368,
341,
286,
1077,
6645,
284,
6633,
2043,
486,
931,
543,
286,
2060,
10297,
13297,
1364,
4080,
16,
11,
220,
16,
15,
15,
568,
285,
9266,
1423,
286,
2060,
10297,
13297,
1364,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
#[test]
fn test_t1b() {
init();
let result = t1b(0, 0, 3, 4, 72, 2, 2);
println!("{}", result.len());
println!("{:?}", result)
} | rust_cleaned_test_functions.jsonl/104708 | {
"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,
65,
368,
341,
286,
2930,
543,
286,
1077,
1102,
284,
259,
16,
65,
7,
15,
11,
220,
15,
11,
220,
18,
11,
220,
19,
11,
220,
22,
17,
11,
220,
17,
11,
220,
17,
317,
286,
13751,
7987... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_update_net_device() {
let mut vmm = create_vmm_object(InstanceState::Uninitialized);
let tbc_1mtps = TokenBucketConfig {
size: 1024 * 1024,
one_time_burst: None,
refill_time: 1000,
};
let tbc_2mtps = TokenBucketConfig {
size: 2 * 1024 * 1024,
one_time_burst: None,
refill_time: 1000,
};
vmm.insert_net_device(NetworkInterfaceConfig {
iface_id: String::from("1"),
host_dev_name: String::from("hostname4"),
guest_mac: None,
rx_rate_limiter: Some(RateLimiterConfig {
bandwidth: Some(tbc_1mtps),
ops: None,
}),
tx_rate_limiter: None,
allow_mmds_requests: false,
})
.unwrap();
vmm.update_net_device(NetworkInterfaceUpdateConfig {
iface_id: "1".to_string(),
rx_rate_limiter: Some(RateLimiterConfig {
bandwidth: None,
ops: Some(tbc_2mtps),
}),
tx_rate_limiter: Some(RateLimiterConfig {
bandwidth: None,
ops: Some(tbc_2mtps),
}),
})
.unwrap();
{
let nic_1: &mut NetworkInterfaceConfig = vmm
.device_configs
.network_interface
.iter_mut()
.next()
.unwrap();
// The RX bandwidth should be unaffected.
assert_eq!(nic_1.rx_rate_limiter.unwrap().bandwidth.unwrap(), tbc_1mtps);
// The RX ops should be set to 2mtps.
assert_eq!(nic_1.rx_rate_limiter.unwrap().ops.unwrap(), tbc_2mtps);
assert_eq!(nic_1.tx_rate_limiter.unwrap().bandwidth, None);
// The TX ops should be set to 2mtps.
assert_eq!(nic_1.tx_rate_limiter.unwrap().ops.unwrap(), tbc_2mtps);
}
assert!(vmm.init_guest_memory().is_ok());
assert!(vmm.setup_interrupt_controller().is_ok());
vmm.default_kernel_config(None);
vmm.init_mmio_device_manager();
vmm.attach_net_devices().unwrap();
vmm.set_instance_state(InstanceState::Running);
// The update should fail before device activation.
assert!(vmm
.update_net_device(NetworkInterfaceUpdateConfig {
iface_id: "1".to_string(),
rx_rate_limiter: None,
tx_rate_limiter: None,
})
.is_err());
// Activate the device
{
let device_manager = vmm.mmio_device_manager.as_ref().unwrap();
let bus_device_mutex = device_manager
.get_device(DeviceType::Virtio(TYPE_NET), "1")
.unwrap();
let bus_device = &mut *bus_device_mutex.lock().unwrap();
let mmio_device: &mut MmioDevice = bus_device
.as_mut_any()
.downcast_mut::<MmioDevice>()
.unwrap();
assert!(mmio_device
.device_mut()
.activate(
vmm.vm.memory().unwrap().clone(),
EventFd::new(libc::EFD_NONBLOCK).unwrap(),
Arc::new(AtomicUsize::new(0)),
vec![Queue::new(0), Queue::new(0)],
vec![
EventFd::new(libc::EFD_NONBLOCK).unwrap(),
EventFd::new(libc::EFD_NONBLOCK).unwrap()
],
)
.is_ok());
}
// the update should succeed after the device activation
vmm.update_net_device(NetworkInterfaceUpdateConfig {
iface_id: "1".to_string(),
rx_rate_limiter: Some(RateLimiterConfig {
bandwidth: Some(tbc_2mtps),
ops: None,
}),
tx_rate_limiter: Some(RateLimiterConfig {
bandwidth: Some(tbc_1mtps),
ops: None,
}),
})
.unwrap();
} | rust_cleaned_test_functions.jsonl/28142 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2297
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8882,
19722,
9204,
368,
341,
286,
1077,
5206,
348,
3821,
284,
1855,
2273,
3821,
5314,
7,
8846,
486,
1806,
36161,
626,
286,
1077,
259,
8904,
62,
16,
76,
96031,
284,
9660,
36018,
2648,
341,
310,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_packed_struct_can_derive_serialize() {
#[derive(Copy, Clone, Serialize)]
#[repr(packed, C)]
struct PackedC {
t: f32,
}
#[derive(Copy, Clone, Serialize)]
#[repr(C, packed)]
struct CPacked {
t: f32,
}
#[derive(Copy, Clone, Serialize)]
#[repr(C, packed(2))]
struct CPacked2 {
t: f32,
}
#[derive(Copy, Clone, Serialize)]
#[repr(packed(2), C)]
struct Packed2C {
t: f32,
}
} | rust_cleaned_test_functions.jsonl/56452 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 258
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
11191,
15126,
27421,
35345,
533,
88686,
368,
341,
262,
11506,
27098,
3025,
1266,
11,
27913,
11,
39900,
5563,
262,
11506,
30837,
1295,
11191,
11,
356,
5563,
262,
2036,
393,
11191,
34,
341,
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_make_command_line() {
fn test_wrapper(prog: &str, args: &[&str]) -> String {
let command_line = &make_command_line(OsStr::new(prog),
&args.iter()
.map(|a| OsString::from(a))
.collect::<Vec<OsString>>())
.unwrap();
String::from_utf16(command_line).unwrap()
}
assert_eq!(
test_wrapper("prog", &["aaa", "bbb", "ccc"]),
"\"prog\" aaa bbb ccc"
);
assert_eq!(
test_wrapper("C:\\Program Files\\blah\\blah.exe", &["aaa"]),
"\"C:\\Program Files\\blah\\blah.exe\" aaa"
);
assert_eq!(
test_wrapper("C:\\Program Files\\test", &["aa\"bb"]),
"\"C:\\Program Files\\test\" aa\\\"bb"
);
assert_eq!(
test_wrapper("echo", &["a b c"]),
"\"echo\" \"a b c\""
);
assert_eq!(
test_wrapper("echo", &["\" \\\" \\", "\\"]),
"\"echo\" \"\\\" \\\\\\\" \\\\\" \\"
);
assert_eq!(
test_wrapper("\u{03c0}\u{042f}\u{97f3}\u{00e6}\u{221e}", &[]),
"\"\u{03c0}\u{042f}\u{97f3}\u{00e6}\u{221e}\""
);
} | rust_cleaned_test_functions.jsonl/17125 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 865
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28230,
10811,
6528,
368,
341,
286,
5168,
1273,
23561,
80078,
25,
609,
495,
11,
2827,
25,
44590,
5,
495,
2467,
1464,
923,
341,
310,
1077,
3210,
6528,
284,
609,
6927,
10811,
6528,
19238,
82,
2580,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_extract_bytearray_to_array() {
let gil = Python::acquire_gil();
let py = gil.python();
let v: [u8; 3] = py
.eval("bytearray(b'abc')", None, None)
.unwrap()
.extract()
.unwrap();
assert!(&v == b"abc");
} | rust_cleaned_test_functions.jsonl/47429 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 180
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39123,
19737,
1653,
2346,
3858,
368,
341,
286,
1077,
342,
321,
284,
13027,
486,
580,
984,
1889,
321,
543,
286,
1077,
4510,
284,
342,
321,
43193,
543,
286,
1077,
348,
25,
508,
84,
23,
26,
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_parse_query_to_triming_spaces() {
test_parse_query_to_ast_helper(" abc", "\"abc\"");
test_parse_query_to_ast_helper("abc ", "\"abc\"");
test_parse_query_to_ast_helper("( a OR abc)", "(?\"a\" ?\"abc\")");
test_parse_query_to_ast_helper("(a OR abc)", "(?\"a\" ?\"abc\")");
test_parse_query_to_ast_helper("(a OR abc)", "(?\"a\" ?\"abc\")");
test_parse_query_to_ast_helper("a OR abc ", "(?\"a\" ?\"abc\")");
test_parse_query_to_ast_helper("(a OR abc )", "(?\"a\" ?\"abc\")");
test_parse_query_to_ast_helper("(a OR abc) ", "(?\"a\" ?\"abc\")");
} | rust_cleaned_test_functions.jsonl/64413 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 325
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
5738,
2346,
3547,
59076,
67883,
368,
341,
286,
1273,
21039,
5738,
2346,
48019,
10418,
445,
256,
39022,
497,
15898,
13683,
88385,
286,
1273,
21039,
5738,
2346,
48019,
10418,
445,
13683,
3670,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_int_divide_decimal_overflow() {
let test_cases = vec![
(Decimal::from(std::i64::MIN), Decimal::from(-1)),
(
Decimal::from(std::i64::MAX),
Decimal::from_bytes(b"0.1").unwrap().unwrap(),
),
];
for (lhs, rhs) in test_cases {
let output: Result<Option<Int>> = RpnFnScalarEvaluator::new()
.push_param(lhs)
.push_param(rhs)
.evaluate(ScalarFuncSig::IntDivideDecimal);
assert!(output.is_err(), "lhs={:?}, rhs={:?}", lhs, rhs);
}
} | rust_cleaned_test_functions.jsonl/5294 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 365
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4042,
16237,
577,
74429,
79073,
368,
341,
286,
1077,
1273,
41427,
284,
7486,
90515,
310,
320,
11269,
486,
1499,
5194,
486,
72,
21,
19,
486,
16413,
701,
26728,
486,
1499,
4080,
16,
6965,
310,
239... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_prewrite_rolledback_transaction() {
let engine = TestEngineBuilder::new().build().unwrap();
let cm = ConcurrencyManager::new(1.into());
let mut statistics = Statistics::default();
let k1 = b"k1";
let v1 = b"v1";
let v2 = b"v2";
// Test the write conflict path.
must_acquire_pessimistic_lock(&engine, k1, v1, 1, 1);
must_rollback(&engine, k1, 1, true);
must_prewrite_put(&engine, k1, v2, k1, 5);
must_commit(&engine, k1, 5, 6);
let prewrite_cmd = Prewrite::new(
vec![Mutation::make_put(Key::from_raw(k1), v1.to_vec())],
k1.to_vec(),
1.into(),
10,
false,
2,
2.into(),
10.into(),
Some(vec![]),
false,
AssertionLevel::Off,
Context::default(),
);
let context = WriteContext {
lock_mgr: &DummyLockManager {},
concurrency_manager: cm.clone(),
extra_op: ExtraOp::Noop,
statistics: &mut statistics,
async_apply_prewrite: false,
};
let snap = engine.snapshot(Default::default()).unwrap();
assert!(prewrite_cmd.cmd.process_write(snap, context).is_err());
// Test the pessimistic lock is not found path.
must_acquire_pessimistic_lock(&engine, k1, v1, 10, 10);
must_rollback(&engine, k1, 10, true);
must_acquire_pessimistic_lock(&engine, k1, v1, 15, 15);
let prewrite_cmd = PrewritePessimistic::with_defaults(
vec![(Mutation::make_put(Key::from_raw(k1), v1.to_vec()), true)],
k1.to_vec(),
10.into(),
10.into(),
);
let context = WriteContext {
lock_mgr: &DummyLockManager {},
concurrency_manager: cm,
extra_op: ExtraOp::Noop,
statistics: &mut statistics,
async_apply_prewrite: false,
};
let snap = engine.snapshot(Default::default()).unwrap();
assert!(prewrite_cmd.cmd.process_write(snap, context).is_err());
} | rust_cleaned_test_functions.jsonl/31434 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1101
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
52473,
62,
20947,
1419,
28884,
368,
341,
286,
1077,
4712,
284,
3393,
4571,
3297,
486,
931,
1005,
5834,
1005,
15454,
543,
286,
1077,
9961,
284,
1200,
15973,
2043,
486,
931,
7,
16,
39860,
142... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_string()
{
let mut cursor = Cursor::new(r#""This is a string" "Blaat\n" "$a""#);
let tokens: Vec<Token> = Lexer::new("")
.read(&mut cursor)
.expect("Lexing failed")
.collect();
assert_eq!(tokens, vec![
tok(TokenKind::Indent(0), 1, 1, 1, 1),
tok(TokenKind::StringLiteral("This is a string".into()), 1, 1, 1, 18),
tok(TokenKind::StringLiteral("Blaat\n".into()), 1, 20, 1, 28),
tok(TokenKind::StringLiteral("$a".into()), 1, 30, 1, 33),
tok(TokenKind::EOF, 2, 1, 2, 1),
]);
} | rust_cleaned_test_functions.jsonl/117357 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 344
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3904,
741,
262,
341,
286,
1077,
5206,
8128,
284,
28067,
486,
931,
2601,
2,
3014,
1986,
374,
264,
914,
1,
330,
33,
4260,
266,
1699,
1,
5201,
64,
3014,
2,
317,
286,
1077,
11211,
25,
11312,
834... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_0689_example_1() {
let nums = vec![1, 2, 1, 2, 6, 7, 5, 1];
let k = 2;
let result = vec![0, 3, 5];
assert_eq!(Solution::max_sum_of_three_subarrays(nums, k), result);
} | rust_cleaned_test_functions.jsonl/83462 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 125
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
15,
21,
23,
24,
39304,
62,
16,
368,
341,
286,
1077,
10307,
284,
7486,
20703,
16,
11,
220,
17,
11,
220,
16,
11,
220,
17,
11,
220,
21,
11,
220,
22,
11,
220,
20,
11,
220,
16,
935,
286... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_github_27() {
// https://github.com/chyh1990/yaml-rust/issues/27
let s = "&a";
let out = YamlLoader::load_from_str(&s).unwrap();
let doc = &out[0];
assert_eq!(doc.as_str().unwrap(), "");
} | rust_cleaned_test_functions.jsonl/1206 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 132
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1889,
3827,
62,
17,
22,
368,
341,
286,
442,
3703,
1110,
5204,
905,
21284,
73801,
16,
24,
24,
15,
26491,
9467,
3795,
590,
38745,
14,
17,
22,
198,
286,
1077,
274,
284,
13399,
64,
876,
286,
107... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_for_vec_attr_vec() {
let t = ForVecAttrVecTemplate {
v: vec![
ForVecAttrVec {
iterable: vec![1, 2],
},
ForVecAttrVec {
iterable: vec![3, 4],
},
ForVecAttrVec {
iterable: vec![5, 6],
},
],
};
assert_eq!(t.render().unwrap(), "1 2 3 4 5 6 ");
} | rust_cleaned_test_functions.jsonl/24298 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 270
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5478,
13251,
10422,
13251,
368,
341,
262,
1077,
259,
284,
1752,
10050,
13371,
10050,
7275,
341,
286,
348,
25,
7486,
90515,
310,
1752,
10050,
13371,
10050,
341,
394,
50834,
25,
7486,
20703,
16,
11,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_slave_fs_cache_send_failure() {
let (p1, p2) = UnixStream::pair().unwrap();
let fs_cache = SlaveFsCacheReq::from_stream(p1);
fs_cache.set_failed(libc::ECONNRESET);
fs_cache
.fs_slave_map(&VhostUserFSSlaveMsg::default(), &p2)
.unwrap_err();
fs_cache
.fs_slave_unmap(&VhostUserFSSlaveMsg::default())
.unwrap_err();
fs_cache.node().error = None;
} | rust_cleaned_test_functions.jsonl/123042 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 248
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
65320,
34470,
11529,
13565,
43618,
368,
341,
286,
1077,
320,
79,
16,
11,
281,
17,
8,
284,
46995,
3027,
486,
12670,
1005,
15454,
543,
286,
1077,
8619,
11529,
284,
59368,
48300,
8233,
27234,
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_load_store() {
let r = parse_and_eval(
r#"
block 0 {
r0 = 200;
*r0 = 42;
r1 = *r0;
exit(r1);
}"#,
).unwrap();
assert!(r == 42);
} | rust_cleaned_test_functions.jsonl/55931 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 201
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12411,
14809,
368,
341,
286,
1077,
435,
284,
4715,
8378,
21296,
1006,
310,
435,
2,
698,
310,
2504,
220,
15,
341,
394,
435,
15,
284,
220,
17,
15,
15,
280,
394,
353,
81,
15,
284,
220,
19,
17... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_acid_converts_to_string() {
assert_eq!(dna::RibonucleicAcid::new("AGC").as_slice(), "AGC");
assert_eq!(dna::RibonucleicAcid::new("CGA").as_slice(), "CGA");
} | rust_cleaned_test_functions.jsonl/36951 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 92
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14718,
307,
3382,
28163,
2346,
3904,
368,
341,
262,
2060,
10714,
10297,
92877,
486,
98884,
263,
22147,
292,
11654,
307,
486,
931,
445,
1890,
34,
1827,
300,
26488,
1507,
330,
1890,
34,
797,
262,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_genesis() {
// Test genesis and the next block
let genesis_block = Block::<i64>::make_genesis_block();
assert_eq!(genesis_block.height(), 0);
assert_eq!(genesis_block.parent_id(), HashValue::zero());
assert_ne!(genesis_block.id(), HashValue::zero());
assert!(genesis_block.is_genesis_block());
} | rust_cleaned_test_functions.jsonl/541 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 135
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16322,
13774,
368,
341,
262,
442,
3393,
59366,
323,
279,
1790,
2504,
198,
262,
1077,
59366,
7113,
284,
8362,
27638,
72,
21,
19,
6831,
6927,
16322,
13774,
7113,
543,
262,
2060,
10714,
10297,
77894,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_unknown_commands() {
let td: Vec<String> = vec!["asd +0".to_string()];
assert_eq!(
read_commands(&td),
Err(SimpleError::new("unknown command: asd"))
);
} | rust_cleaned_test_functions.jsonl/50505 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 120
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
57507,
44151,
368,
341,
286,
1077,
17941,
25,
11312,
3464,
29,
284,
7486,
0,
1183,
79102,
488,
15,
3263,
983,
3904,
368,
4821,
286,
2060,
10714,
33673,
310,
1349,
44151,
2099,
1296,
1326,
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 |
#[test]
fn test_push_str() {
let example = "hello";
let mut repr = Repr::new(example);
repr.push_str(" world!");
assert_eq!(repr.as_str(), "hello world!");
assert_eq!(repr.len(), 12);
} | rust_cleaned_test_functions.jsonl/14393 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 119
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14218,
2895,
368,
341,
286,
1077,
3110,
284,
330,
14990,
876,
286,
1077,
5206,
30636,
284,
1032,
649,
486,
931,
66203,
626,
286,
30636,
2552,
2895,
445,
1879,
57073,
286,
2060,
10714,
10297,
30837... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_new() {
gst::init().unwrap();
let info = VideoInfo::builder(crate::VideoFormat::I420, 320, 240)
.build()
.unwrap();
assert_eq!(info.format(), crate::VideoFormat::I420);
assert_eq!(info.width(), 320);
assert_eq!(info.height(), 240);
assert_eq!(info.size(), 320 * 240 + 2 * 160 * 120);
assert_eq!(info.multiview_mode(), crate::VideoMultiviewMode::None);
assert_eq!(&info.offset(), &[0, 320 * 240, 320 * 240 + 160 * 120]);
assert_eq!(&info.stride(), &[320, 160, 160]);
let offsets = [0, 640 * 240 + 16, 640 * 240 + 16 + 320 * 120 + 16];
let strides = [640, 320, 320];
let info = VideoInfo::builder(crate::VideoFormat::I420, 320, 240)
.offset(&offsets)
.stride(&strides)
.size(640 * 240 + 16 + 320 * 120 + 16 + 320 * 120 + 16)
.multiview_mode(crate::VideoMultiviewMode::SideBySide)
.build()
.unwrap();
assert_eq!(info.format(), crate::VideoFormat::I420);
assert_eq!(info.width(), 320);
assert_eq!(info.height(), 240);
assert_eq!(
info.size(),
640 * 240 + 16 + 320 * 120 + 16 + 320 * 120 + 16
);
assert_eq!(info.multiview_mode(), crate::VideoMultiviewMode::SideBySide);
assert_eq!(
&info.offset(),
&[0, 640 * 240 + 16, 640 * 240 + 16 + 320 * 120 + 16]
);
assert_eq!(&info.stride(), &[640, 320, 320]);
} | rust_cleaned_test_functions.jsonl/113669 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 752
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5921,
368,
341,
286,
43769,
486,
2327,
1005,
15454,
1428,
286,
1077,
3546,
284,
8354,
1731,
486,
17850,
54907,
486,
10724,
4061,
486,
40,
19,
17,
15,
11,
220,
18,
17,
15,
11,
220,
17,
19,
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_py03_evaluate_error0() {
pyo3::prepare_freethreaded_python();
Python::with_gil(|py| -> () {
let input_type = py.get_type::<BasisRotationInputWrapper>();
let input = input_type
.call1((3, false))
.unwrap()
.cast_as::<PyCell<BasisRotationInputWrapper>>()
.unwrap();
let tmp_vec: Vec<usize> = Vec::new();
let _ = input
.call_method1("add_pauli_product", ("ro", tmp_vec))
.unwrap();
let _ = input
.call_method1("add_pauli_product", ("ro", vec![0]))
.unwrap();
let _ = input
.call_method1("add_pauli_product", ("ro", vec![1, 2]))
.unwrap();
let _ = input
.call_method1("add_pauli_product", ("rx", vec![1, 2]))
.unwrap();
let mut circs: Vec<CircuitWrapper> = Vec::new();
circs.push(CircuitWrapper::new());
let br_type = py.get_type::<BasisRotationWrapper>();
let br = br_type
.call1((Some(CircuitWrapper::new()), circs.clone(), input))
.unwrap()
.cast_as::<PyCell<BasisRotationWrapper>>()
.unwrap();
let measured_registers: HashMap<String, BitOutputRegister> = HashMap::new();
let input2: HashMap<String, FloatOutputRegister> =
HashMap::<String, FloatOutputRegister>::new();
let input3: HashMap<String, ComplexOutputRegister> =
HashMap::<String, ComplexOutputRegister>::new();
let result = br.call_method1(
"evaluate",
(measured_registers, input2.clone(), input3.clone()),
);
assert!(result.is_err());
let input1: HashMap<String, Vec<Vec<usize>>> = HashMap::new();
let error = br.call_method1("evaluate", (input1, input2, input3));
assert!(error.is_err());
})
} | rust_cleaned_test_functions.jsonl/5780 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 937
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
40291,
15,
18,
2204,
19642,
4096,
15,
368,
341,
262,
4510,
78,
18,
486,
13609,
74179,
769,
878,
291,
55869,
1428,
262,
13027,
486,
4197,
1889,
321,
22428,
3288,
91,
1464,
1719,
341,
286,
1077,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_smoke_update() {
let mut rng = new_rng(70812476915813);
for _ in 0..2048 {
// use an odd length so we test the odd length logic
const BUF_LEN: usize = 31;
let buf: [u8; BUF_LEN] = rng.gen();
let mut c = Checksum::new();
c.add_bytes(&buf);
let (begin, end) = loop {
let begin = rng.gen::<usize>() % BUF_LEN;
let end = begin + (rng.gen::<usize>() % (BUF_LEN + 1 - begin));
// update requires that begin is even and end is either even
// or the end of the input
if begin % 2 == 0 && (end % 2 == 0 || end == BUF_LEN) {
break (begin, end);
}
};
let mut new_buf = buf;
for i in begin..end {
new_buf[i] = rng.gen();
}
let updated =
Checksum::update(c.checksum(), &buf[begin..end], &new_buf[begin..end]);
let from_scratch = {
let mut c = Checksum::new();
c.add_bytes(&new_buf);
c.checksum()
};
assert_eq!(updated, from_scratch);
}
} | rust_cleaned_test_functions.jsonl/15733 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 827
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15874,
4740,
8882,
368,
341,
310,
1077,
5206,
28422,
284,
501,
66849,
7,
22,
15,
23,
16,
17,
19,
22,
21,
24,
16,
20,
23,
16,
18,
626,
310,
369,
716,
304,
220,
15,
496,
17,
15,
19,
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... | 6 |
#[test]
fn test_polygon_extreme_x() {
// a diamond shape
let poly1 = polygon![
(x: 1.0, y: 0.0),
(x: 2.0, y: 1.0),
(x: 1.0, y: 2.0),
(x: 0.0, y: 1.0),
(x: 1.0, y: 0.0)
];
let min_x = polymax_naive_indices(point!(x: -1., y: 0.), &poly1).unwrap();
let correct = 3_usize;
assert_eq!(min_x, correct);
} | rust_cleaned_test_functions.jsonl/100476 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 265
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
73542,
9927,
9634,
3212,
368,
341,
286,
442,
264,
22205,
6083,
198,
286,
1077,
9861,
16,
284,
29372,
90515,
310,
320,
87,
25,
220,
16,
13,
15,
11,
379,
25,
220,
15,
13,
15,
1326,
310,
320,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.