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_basic_enum() {
let basic_enum = quote! {
enum Basic {
A,
B,
C,
D
}
};
match syn::parse2::<DeriveInput>(basic_enum) {
Ok(mut input) => {
assert!(derive_avro_schema(&mut input).is_ok())
}
Err(error) => panic!(
"Failed to parse as derive input when it should be able to. Error: {:?}",
error
),
};
} | rust_cleaned_test_functions.jsonl/110870 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 335
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34729,
31054,
368,
341,
286,
1077,
6770,
31054,
284,
12641,
0,
341,
310,
7618,
14625,
341,
394,
362,
345,
394,
425,
345,
394,
356,
345,
394,
422,
198,
310,
456,
286,
2605,
286,
2432,
6782,
486... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_plain_decode_byte_array() {
let data = vec![
ByteArray::new(ByteBufferPtr::new(String::from("hellp").into_bytes())),
ByteArray::new(ByteBufferPtr::new(String::from("parquet").into_bytes())),
];
let data_bytes = ByteArrayType::to_byte_array(&data[..]);
let mut buffer = vec![ByteArray::default(); 2];
test_plain_decode::<ByteArrayType>(
ByteBufferPtr::new(data_bytes),
2,
-1,
&mut buffer[..],
&data[..],
);
} | rust_cleaned_test_functions.jsonl/113127 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 198
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
41015,
15227,
19737,
3858,
368,
341,
197,
10217,
821,
284,
7486,
90515,
298,
197,
18394,
486,
931,
55823,
4095,
5348,
486,
931,
2242,
486,
1499,
445,
56095,
79,
1827,
18122,
12524,
73727,
298,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parse_enum() {
test_parse_ok(vec![
("\"Dog\"", Animal::Dog),
(" \"Dog\" ", Animal::Dog),
(
"{\"Frog\":[\"Henry\",[]]}",
Animal::Frog("Henry".to_string(), vec![]),
),
(
" { \"Frog\": [ \"Henry\" , [ 349, 102 ] ] } ",
Animal::Frog("Henry".to_string(), vec![349, 102]),
),
(
"{\"Cat\": {\"age\": 5, \"name\": \"Kate\"}}",
Animal::Cat {
age: 5,
name: "Kate".to_string(),
},
),
(
" { \"Cat\" : { \"age\" : 5 , \"name\" : \"Kate\" } } ",
Animal::Cat {
age: 5,
name: "Kate".to_string(),
},
),
(
" { \"AntHive\" : [\"Bob\", \"Stuart\"] } ",
Animal::AntHive(vec!["Bob".to_string(), "Stuart".to_string()]),
),
]);
test_parse_unusual_ok(vec![
("{\"Dog\":null}", Animal::Dog),
(" { \"Dog\" : null } ", Animal::Dog),
]);
test_parse_ok(vec![(
concat!(
"{",
" \"a\": \"Dog\",",
" \"b\": {\"Frog\":[\"Henry\", []]}",
"}"
),
treemap!(
"a".to_string() => Animal::Dog,
"b".to_string() => Animal::Frog("Henry".to_string(), vec![])
),
)]);
} | rust_cleaned_test_functions.jsonl/29844 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 822
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
31054,
368,
341,
262,
1273,
21039,
19817,
25592,
90515,
286,
3489,
2105,
48940,
55853,
21292,
486,
48940,
1326,
286,
3489,
7245,
48940,
2105,
3670,
21292,
486,
48940,
1326,
286,
2399,
310,
54... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_pagparams_parsing() {
#[derive(Debug, Deserialize, Serialize)]
struct MyScanParams {
the_field: String,
only_good: Option<String>,
how_many: u32,
really: bool,
}
#[derive(Debug, Deserialize)]
#[allow(dead_code)]
struct MyOptionalScanParams {
the_field: Option<String>,
only_good: Option<String>,
how_many: Option<i32>,
for_reals: Option<bool>,
}
#[derive(Debug, Serialize, Deserialize)]
struct MyPageSelector {
the_page: u8,
}
/*
* "First page" cases
*/
fn parse_as_first_page<T: DeserializeOwned + Debug>(
querystring: &str,
) -> (T, Option<NonZeroU32>) {
let pagparams: PaginationParams<T, MyPageSelector> =
serde_urlencoded::from_str(querystring).unwrap();
let limit = pagparams.limit;
let scan_params = match pagparams.page {
WhichPage::Next(..) => panic!("expected first page"),
WhichPage::First(x) => x,
};
(scan_params, limit)
}
let (scan, limit) = parse_as_first_page::<MyScanParams>(
"the_field=name&only_good=true&how_many=42&really=false",
);
assert_eq!(scan.the_field, "name".to_string());
assert_eq!(scan.only_good, Some("true".to_string()));
assert_eq!(scan.how_many, 42);
assert_eq!(scan.really, false);
assert_eq!(limit, None);
let (scan, limit) = parse_as_first_page::<MyScanParams>(
"the_field=&only_good=false&how_many=42&really=false",
);
assert_eq!(scan.the_field, "".to_string());
assert_eq!(scan.only_good, Some("false".to_string()));
assert_eq!(scan.how_many, 42);
assert_eq!(scan.really, false);
assert_eq!(limit, None);
let (scan, limit) = parse_as_first_page::<MyScanParams>(
"the_field=name&limit=3&how_many=42&really=false",
);
assert_eq!(scan.the_field, "name".to_string());
assert_eq!(scan.only_good, None);
assert_eq!(scan.how_many, 42);
assert_eq!(scan.really, false);
assert_eq!(limit.unwrap().get(), 3);
/* empty query string when all parameters are optional */
let (scan, limit) = parse_as_first_page::<MyOptionalScanParams>("");
assert_eq!(scan.the_field, None);
assert_eq!(scan.only_good, None);
assert_eq!(limit, None);
/* extra parameters are fine */
let (scan, limit) = parse_as_first_page::<MyOptionalScanParams>(
"the_field=name&limit=17&boomtown=okc&how_many=42",
);
assert_eq!(scan.the_field, Some("name".to_string()));
assert_eq!(scan.only_good, None);
assert_eq!(scan.how_many, Some(42));
assert_eq!(limit.unwrap().get(), 17);
fn parse_as_error(querystring: &str) -> serde_urlencoded::de::Error {
serde_urlencoded::from_str::<
PaginationParams<MyScanParams, MyPageSelector>,
>(querystring)
.unwrap_err()
}
parse_as_error("");
parse_as_error("the_field=name&limit=0");
parse_as_error("the_field=name&limit=-3");
parse_as_error("the_field=name&limit=abcd");
parse_as_error("page_token=q");
/*
* "Next page" cases
*/
fn parse_as_next_page(
querystring: &str,
) -> (MyPageSelector, Option<NonZeroU32>) {
let pagparams: PaginationParams<MyScanParams, MyPageSelector> =
serde_urlencoded::from_str(querystring).unwrap();
let limit = pagparams.limit;
let page_selector = match pagparams.page {
WhichPage::Next(x) => x,
WhichPage::First(_) => panic!("expected next page"),
};
(page_selector, limit)
}
/* basic case */
let token = serialize_page_token(&MyPageSelector {
the_page: 123,
})
.unwrap();
let (page_selector, limit) =
parse_as_next_page(&format!("page_token={}", token));
assert_eq!(page_selector.the_page, 123);
assert_eq!(limit, None);
/* limit is also accepted */
let (page_selector, limit) =
parse_as_next_page(&format!("page_token={}&limit=12", token));
assert_eq!(page_selector.the_page, 123);
assert_eq!(limit.unwrap().get(), 12);
/*
* Having parameters appropriate to the scan params doesn't change the
* way this is interpreted.
*/
let (page_selector, limit) = parse_as_next_page(&format!(
"the_field=name&page_token={}&limit=3",
token
));
assert_eq!(page_selector.the_page, 123);
assert_eq!(limit.unwrap().get(), 3);
parse_as_error(&format!("page_token={}&limit=0", token));
parse_as_error(&format!("page_token={}&limit=-3", token));
#[derive(Debug, Deserialize)]
#[allow(dead_code)]
struct SketchyScanParams {
page_token: String,
}
let pagparams: PaginationParams<SketchyScanParams, MyPageSelector> =
serde_urlencoded::from_str(&format!("page_token={}", token))
.unwrap();
assert_eq!(pagparams.limit, None);
match &pagparams.page {
WhichPage::First(..) => {
panic!("expected NextPage even with page_token in ScanParams")
}
WhichPage::Next(p) => {
assert_eq!(p.the_page, 123);
}
}
} | rust_cleaned_test_functions.jsonl/16568 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2974
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
51003,
3519,
620,
28598,
368,
341,
286,
11506,
27098,
42618,
11,
48440,
11,
39900,
5563,
286,
2036,
3017,
26570,
4870,
341,
310,
279,
5013,
25,
923,
345,
310,
1172,
44781,
25,
6959,
3464,
12520,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_mld_integration_fallback_from_idle() {
let (mut ctx, dev_id) = setup_simple_test_environment();
mld_join_group(&mut ctx, dev_id, MulticastAddr::new(GROUP_ADDR).unwrap());
assert_eq!(ctx.dispatcher.frames_sent().len(), 1);
assert!(testutil::trigger_next_timer(&mut ctx));
assert_eq!(ctx.dispatcher.frames_sent().len(), 2);
receive_mld_query(&mut ctx, dev_id, Duration::from_secs(10));
let group_state = ctx
.state
.ip
.get_mld_state_mut(dev_id.id())
.groups
.get(&MulticastAddr::new(GROUP_ADDR).unwrap())
.unwrap();
match group_state.get_inner() {
MemberState::Delaying(_) => {}
_ => panic!("Wrong State!"),
}
assert!(testutil::trigger_next_timer(&mut ctx));
assert_eq!(ctx.dispatcher.frames_sent().len(), 3);
// The frames are all reports.
for (_, frame) in ctx.dispatcher.frames_sent() {
ensure_frame(&frame, 131, GROUP_ADDR, GROUP_ADDR);
}
} | rust_cleaned_test_functions.jsonl/123215 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 552
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
717,
507,
90250,
761,
3420,
5673,
47810,
368,
341,
286,
1077,
320,
6984,
5635,
11,
3483,
842,
8,
284,
6505,
30015,
4452,
51774,
543,
286,
296,
507,
31017,
6288,
2099,
6984,
5635,
11,
3483,
842,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_check_condition() {
let focus = MockFocus {
accepted_conditions: &["foo", "bar"],
};
let test_cases = [
("foo", true),
("bar", true),
("!foo", false),
("!bar", false),
("foo || bar", true),
("foo || !bar", true),
("!foo || bar", true),
("foo && bar", true),
("foo && !bar", false),
("!foo && bar", false),
("foo && bar || baz", true),
("foo && bar && baz", false),
("foo && bar && !baz", true),
];
for (condition, should_accept) in test_cases.into_iter() {
assert_eq!(
should_accept,
KeyPressData::check_condition(condition, &focus),
"Condition check failed. Condition: {condition}. Expected result: {should_accept}",
);
}
} | rust_cleaned_test_functions.jsonl/51719 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 499
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7200,
27656,
368,
341,
286,
1077,
5244,
284,
14563,
13819,
341,
310,
11666,
54099,
25,
609,
1183,
7975,
497,
330,
2257,
8097,
286,
3634,
286,
1077,
1273,
41427,
284,
2278,
310,
3489,
7975,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_extract_path_decode() {
let mut router = Router::<()>::default();
router.register_resource(Resource::new(ResourceDef::new("/{value}/")));
macro_rules! test_single_value {
($value:expr, $expected:expr) => {
{
let req = TestRequest::with_uri($value).finish();
let info = router.recognize(&req, &(), 0);
let req = req.with_route_info(info);
assert_eq!(*Path::<String>::from_request(&req, &PathConfig::default()).unwrap(), $expected);
}
}
}
test_single_value!("/%25/", "%");
test_single_value!("/%40%C2%A3%24%25%5E%26%2B%3D/", "@£$%^&+=");
test_single_value!("/%2B/", "+");
test_single_value!("/%252B/", "%2B");
test_single_value!("/%2F/", "/");
test_single_value!("/%252F/", "%2F");
test_single_value!("/http%3A%2F%2Flocalhost%3A80%2Ffoo/", "http://localhost:80/foo");
test_single_value!("/%2Fvar%2Flog%2Fsyslog/", "/var/log/syslog");
test_single_value!(
"/http%3A%2F%2Flocalhost%3A80%2Ffile%2F%252Fvar%252Flog%252Fsyslog/",
"http://localhost:80/file/%2Fvar%2Flog%2Fsyslog"
);
let req = TestRequest::with_uri("/%25/7/?id=test").finish();
let mut router = Router::<()>::default();
router.register_resource(Resource::new(ResourceDef::new("/{key}/{value}/")));
let info = router.recognize(&req, &(), 0);
let req = req.with_route_info(info);
let s = Path::<Test2>::from_request(&req, &PathConfig::default()).unwrap();
assert_eq!(s.key, "%");
assert_eq!(s.value, 7);
let s = Path::<(String, String)>::from_request(&req, &PathConfig::default()).unwrap();
assert_eq!(s.0, "%");
assert_eq!(s.1, "7");
} | rust_cleaned_test_functions.jsonl/46189 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 968
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39123,
2638,
15227,
368,
341,
286,
1077,
5206,
9273,
284,
10554,
27638,
368,
6831,
2258,
543,
286,
9273,
9929,
17962,
40071,
486,
931,
40071,
2620,
486,
931,
65871,
957,
4472,
74385,
286,
18072,
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_qualify_path_fn_trait_notation() {
check_assist(
add_missing_impl_members,
r#"
mod foo {
pub trait Fn<Args> { type Output; }
trait Foo { fn foo(&self, bar: dyn Fn(u32) -> i32); }
}
struct S;
impl foo::Foo for S { <|> }"#,
r#"
mod foo {
pub trait Fn<Args> { type Output; }
trait Foo { fn foo(&self, bar: dyn Fn(u32) -> i32); }
}
struct S;
impl foo::Foo for S {
fn foo(&self, bar: dyn Fn(u32) -> i32) {
${0:todo!()}
}
}"#,
);
} | rust_cleaned_test_functions.jsonl/110449 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 276
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
64391,
1437,
2638,
15246,
78491,
7913,
367,
368,
341,
286,
1779,
12083,
380,
1006,
310,
912,
40447,
21007,
30397,
345,
310,
435,
2,
698,
2593,
15229,
341,
262,
6675,
17567,
50182,
27,
4117,
29,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_pileup() {
let (_, _, seqs, quals, _) = gold();
let mut bam = Reader::from_path(&"test/test.bam")
.ok()
.expect("Error opening file.");
let pileups = bam.pileup();
for pileup in pileups.take(26) {
let _pileup = pileup.expect("Expected successful pileup.");
let pos = _pileup.pos() as usize;
assert_eq!(_pileup.depth(), 6);
assert!(_pileup.tid() == 0);
for (i, a) in _pileup.alignments().enumerate() {
assert_eq!(a.indel(), pileup::Indel::None);
let qpos = a.qpos().unwrap();
assert_eq!(qpos, pos - 1);
assert_eq!(a.record().seq()[qpos], seqs[i][qpos]);
assert_eq!(a.record().qual()[qpos], quals[i][qpos] - 33);
}
}
} | rust_cleaned_test_functions.jsonl/34033 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 482
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
457,
454,
368,
341,
286,
1077,
39464,
8358,
12981,
82,
11,
922,
1127,
11,
27439,
284,
6623,
1428,
286,
1077,
5206,
41304,
284,
25166,
486,
1499,
2638,
2099,
1,
1944,
12697,
71804,
1138,
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... | 3 |
#[test]
fn test_raft_client_reconnect() {
let msg_count = Arc::new(AtomicUsize::new(0));
let batch_msg_count = Arc::new(AtomicUsize::new(0));
let service = MockKvForRaft::new(Arc::clone(&msg_count), Arc::clone(&batch_msg_count), true);
let (mut mock_server, port) = create_mock_server(service, 60100, 60200).unwrap();
let (tx, rx) = mpsc::channel();
let (significant_msg_sender, _significant_msg_receiver) = mpsc::channel();
let router = TestRaftStoreRouter::new(tx, significant_msg_sender);
let mut raft_client = get_raft_client(router, StaticResolver::new(port));
(0..50).for_each(|_| raft_client.send(RaftMessage::default()).unwrap());
raft_client.flush();
check_msg_count(500, &msg_count, 50);
// `send` should be pending after the mock server stopped.
mock_server.shutdown();
drop(mock_server);
rx.recv_timeout(Duration::from_secs(3)).unwrap();
for _ in 0..100 {
raft_client.send(RaftMessage::default()).unwrap();
}
raft_client.flush();
rx.recv_timeout(Duration::from_secs(3)).unwrap();
// `send` should success after the mock server restarted.
let service = MockKvForRaft::new(Arc::clone(&msg_count), batch_msg_count, true);
let mock_server = create_mock_server_on(service, port);
(0..50).for_each(|_| raft_client.send(RaftMessage::default()).unwrap());
raft_client.flush();
check_msg_count(3000, &msg_count, 100);
drop(mock_server);
} | rust_cleaned_test_functions.jsonl/37840 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 575
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
2944,
8179,
1288,
6459,
368,
341,
262,
1077,
3750,
3180,
284,
19689,
486,
931,
7,
65857,
52,
2141,
486,
931,
7,
15,
1106,
262,
1077,
7162,
6483,
3180,
284,
19689,
486,
931,
7,
65857,
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_toposort() {
let mut gr = Graph::<_, _>::new();
let a = gr.add_node("A");
let b = gr.add_node("B");
let c = gr.add_node("C");
let d = gr.add_node("D");
let e = gr.add_node("E");
let f = gr.add_node("F");
let g = gr.add_node("G");
gr.extend_with_edges(&[
(a, b, 7.),
(a, d, 5.),
(d, b, 9.),
(b, c, 8.),
(b, e, 7.),
(c, e, 5.),
(d, e, 15.),
(d, f, 6.),
(f, e, 8.),
(f, g, 11.),
(e, g, 9.),
]);
// add a disjoint part
let h = gr.add_node("H");
let i = gr.add_node("I");
let j = gr.add_node("J");
gr.add_edge(h, i, 1.);
gr.add_edge(h, j, 3.);
gr.add_edge(i, j, 1.);
let order = petgraph::algo::toposort(&gr, None).unwrap();
println!("{:?}", order);
assert_eq!(order.len(), gr.node_count());
assert_is_topo_order(&gr, &order);
} | rust_cleaned_test_functions.jsonl/46748 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 512
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10426,
436,
371,
368,
341,
262,
1077,
5206,
1081,
284,
12165,
27638,
6878,
716,
6831,
931,
543,
262,
1077,
264,
284,
1081,
1364,
5084,
445,
32,
797,
262,
1077,
293,
284,
1081,
1364,
5084,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_server_down_peers_without_hibernate_regions() {
let mut cluster = new_server_cluster(0, 5);
cluster.cfg.raft_store.hibernate_regions = false;
test_down_peers(&mut cluster);
} | rust_cleaned_test_functions.jsonl/50370 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 89
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12015,
13998,
36367,
388,
39904,
1523,
18818,
58035,
368,
341,
262,
1077,
5206,
10652,
284,
501,
12015,
28441,
7,
15,
11,
220,
20,
317,
262,
10652,
30481,
13,
2944,
14809,
28881,
58035,
284,
895,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_handle_redeem() {
let (init_result, mut deps) = init_helper_with_config(
vec![InitialBalance {
address: HumanAddr("butler".to_string()),
amount: Uint128(5000),
}],
false,
true,
false,
false,
1000,
);
assert!(
init_result.is_ok(),
"Init failed: {}",
init_result.err().unwrap()
);
let (init_result_no_reserve, mut deps_no_reserve) = init_helper_with_config(
vec![InitialBalance {
address: HumanAddr("butler".to_string()),
amount: Uint128(5000),
}],
false,
true,
false,
false,
0,
);
assert!(
init_result_no_reserve.is_ok(),
"Init failed: {}",
init_result_no_reserve.err().unwrap()
);
let (init_result_for_failure, mut deps_for_failure) = init_helper(vec![InitialBalance {
address: HumanAddr("butler".to_string()),
amount: Uint128(5000),
}]);
assert!(
init_result_for_failure.is_ok(),
"Init failed: {}",
init_result_for_failure.err().unwrap()
);
// test when redeem disabled
let handle_msg = HandleMsg::Redeem {
amount: Uint128(1000),
denom: None,
padding: None,
};
let handle_result = handle(&mut deps_for_failure, mock_env("butler", &[]), handle_msg);
let error = extract_error_msg(handle_result);
assert!(error.contains("Redeem functionality is not enabled for this token."));
// try to redeem when contract has 0 balance
let handle_msg = HandleMsg::Redeem {
amount: Uint128(1000),
denom: None,
padding: None,
};
let handle_result = handle(&mut deps_no_reserve, mock_env("butler", &[]), handle_msg);
let error = extract_error_msg(handle_result);
assert!(error.contains(
"You are trying to redeem for more SCRT than the token has in its deposit reserve."
));
let handle_msg = HandleMsg::Redeem {
amount: Uint128(1000),
denom: None,
padding: None,
};
let handle_result = handle(&mut deps, mock_env("butler", &[]), handle_msg);
assert!(
handle_result.is_ok(),
"handle() failed: {}",
handle_result.err().unwrap()
);
let balances = ReadonlyBalances::from_storage(&deps.storage);
let canonical = deps
.api
.canonical_address(&HumanAddr("butler".to_string()))
.unwrap();
assert_eq!(balances.account_amount(&canonical), 4000)
} | rust_cleaned_test_functions.jsonl/69615 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1484
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10630,
1288,
450,
336,
368,
341,
286,
1077,
320,
2327,
5287,
11,
5206,
48178,
8,
284,
2930,
10418,
6615,
5332,
1006,
310,
7486,
20703,
6341,
21190,
341,
394,
2621,
25,
11097,
13986,
445,
8088,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parents() {
let parent = Parent::new(Some(32),String::from("William"), Some(String::from("Logan")), String::from("Porter"));
} | rust_cleaned_test_functions.jsonl/97304 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 65
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
81719,
368,
341,
286,
1077,
2681,
284,
17022,
486,
931,
65405,
7,
18,
17,
701,
703,
486,
1499,
445,
44787,
3975,
4329,
2242,
486,
1499,
445,
2201,
276,
35674,
923,
486,
1499,
445,
7084,
261,
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 |
#[test]
fn test_basic_small() {
let mut map = BTreeMap::new();
assert_eq!(map.remove(&1), None);
assert_eq!(map.len(), 0);
assert_eq!(map.get(&1), None);
assert_eq!(map.get_mut(&1), None);
assert_eq!(map.first_key_value(), None);
assert_eq!(map.last_key_value(), None);
assert_eq!(map.keys().count(), 0);
assert_eq!(map.values().count(), 0);
assert_eq!(map.range(..).next(), None);
assert_eq!(map.range(..1).next(), None);
assert_eq!(map.range(1..).next(), None);
assert_eq!(map.range(1..=1).next(), None);
assert_eq!(map.range(1..2).next(), None);
assert_eq!(map.insert(1, 1), None);
// 1 key-value pair:
assert_eq!(map.len(), 1);
assert_eq!(map.get(&1), Some(&1));
assert_eq!(map.get_mut(&1), Some(&mut 1));
assert_eq!(map.first_key_value(), Some((&1, &1)));
assert_eq!(map.last_key_value(), Some((&1, &1)));
assert_eq!(map.keys().collect::<Vec<_>>(), vec![&1]);
assert_eq!(map.values().collect::<Vec<_>>(), vec![&1]);
assert_eq!(map.insert(1, 2), Some(1));
assert_eq!(map.len(), 1);
assert_eq!(map.get(&1), Some(&2));
assert_eq!(map.get_mut(&1), Some(&mut 2));
assert_eq!(map.first_key_value(), Some((&1, &2)));
assert_eq!(map.last_key_value(), Some((&1, &2)));
assert_eq!(map.keys().collect::<Vec<_>>(), vec![&1]);
assert_eq!(map.values().collect::<Vec<_>>(), vec![&2]);
assert_eq!(map.insert(2, 4), None);
// 2 key-value pairs:
assert_eq!(map.len(), 2);
assert_eq!(map.get(&2), Some(&4));
assert_eq!(map.get_mut(&2), Some(&mut 4));
assert_eq!(map.first_key_value(), Some((&1, &2)));
assert_eq!(map.last_key_value(), Some((&2, &4)));
assert_eq!(map.keys().collect::<Vec<_>>(), vec![&1, &2]);
assert_eq!(map.values().collect::<Vec<_>>(), vec![&2, &4]);
assert_eq!(map.remove(&1), Some(2));
// 1 key-value pair:
assert_eq!(map.len(), 1);
assert_eq!(map.get(&1), None);
assert_eq!(map.get_mut(&1), None);
assert_eq!(map.get(&2), Some(&4));
assert_eq!(map.get_mut(&2), Some(&mut 4));
assert_eq!(map.first_key_value(), Some((&2, &4)));
assert_eq!(map.last_key_value(), Some((&2, &4)));
assert_eq!(map.keys().collect::<Vec<_>>(), vec![&2]);
assert_eq!(map.values().collect::<Vec<_>>(), vec![&4]);
assert_eq!(map.remove(&2), Some(4));
assert_eq!(map.len(), 0);
assert_eq!(map.get(&1), None);
assert_eq!(map.get_mut(&1), None);
assert_eq!(map.first_key_value(), None);
assert_eq!(map.last_key_value(), None);
assert_eq!(map.keys().count(), 0);
assert_eq!(map.values().count(), 0);
assert_eq!(map.range(..).next(), None);
assert_eq!(map.range(..1).next(), None);
assert_eq!(map.range(1..).next(), None);
assert_eq!(map.range(1..=1).next(), None);
assert_eq!(map.range(1..2).next(), None);
assert_eq!(map.remove(&1), None);
} | rust_cleaned_test_functions.jsonl/56331 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1357
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34729,
31966,
368,
341,
262,
1077,
5206,
2415,
284,
425,
6533,
2227,
486,
931,
543,
1066,
262,
2060,
10714,
10297,
2186,
4850,
2099,
16,
701,
2240,
317,
262,
2060,
10714,
10297,
2186,
19406,
1507,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_delta_bit_packed_int32_empty() {
let data = vec![vec![0; 0]];
test_delta_bit_packed_decode::<Int32Type>(data);
} | rust_cleaned_test_functions.jsonl/38518 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 81
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26710,
13996,
620,
11191,
4042,
18,
17,
15124,
368,
341,
286,
1077,
821,
284,
7486,
20703,
4083,
20703,
15,
26,
220,
15,
13204,
286,
1273,
26710,
13996,
620,
11191,
15227,
27638,
1072,
18,
17,
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 |
#[test]
fn test_subscribe() {
delay();
let s = Subscribe {
_type: SubscribeCmd::Subscribe,
product_ids: vec!["BTC-USD".to_string()],
channels: vec![
Channel::Name(ChannelType::Heartbeat),
Channel::WithProduct {
name: ChannelType::Level2,
product_ids: vec!["BTC-USD".to_string()],
},
],
auth: None,
};
let str = serde_json::to_string(&s).unwrap();
assert_eq!(
str,
r#"{"type":"subscribe","product_ids":["BTC-USD"],"channels":["heartbeat",{"name":"level2","product_ids":["BTC-USD"]}]}"#
);
} | rust_cleaned_test_functions.jsonl/118780 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 391
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
88935,
368,
341,
286,
7626,
543,
286,
1077,
274,
284,
27270,
341,
310,
716,
1313,
25,
27270,
15613,
486,
28573,
345,
310,
1985,
8077,
25,
7486,
0,
1183,
59118,
12,
26749,
3263,
983,
3904,
73845,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_roundtrip() {
assert_eq!(
QueryOutputFormat::from_str(&QueryOutputFormat::Pretty.to_string()).unwrap(),
QueryOutputFormat::Pretty
);
assert_eq!(
QueryOutputFormat::from_str(&QueryOutputFormat::Csv.to_string()).unwrap(),
QueryOutputFormat::Csv
);
assert_eq!(
QueryOutputFormat::from_str(&QueryOutputFormat::Json.to_string()).unwrap(),
QueryOutputFormat::Json
);
} | rust_cleaned_test_functions.jsonl/76594 | {
"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,
5673,
29896,
32981,
368,
341,
286,
2060,
10714,
33673,
310,
11361,
5097,
4061,
486,
1499,
2895,
2099,
2859,
5097,
4061,
486,
51940,
2389,
3904,
6011,
15454,
3148,
310,
11361,
5097,
4061,
486,
51940,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_replacement() {
let (genesis_config, _mint_keypair) = create_genesis_config(0);
let mut bank = Bank::new_for_tests(&genesis_config);
// Setup original program account
let old_address = Pubkey::new_unique();
let new_address = Pubkey::new_unique();
bank.store_account_and_update_capitalization(
&old_address,
&AccountSharedData::from(Account {
lamports: 100,
..Account::default()
}),
);
assert_eq!(bank.get_balance(&old_address), 100);
// Setup new program account
let new_program_account = AccountSharedData::from(Account {
lamports: 123,
..Account::default()
});
bank.store_account_and_update_capitalization(&new_address, &new_program_account);
assert_eq!(bank.get_balance(&new_address), 123);
let original_capitalization = bank.capitalization();
bank.replace_program_account(&old_address, &new_address, "bank-apply_program_replacement");
// New program account is now empty
assert_eq!(bank.get_balance(&new_address), 0);
// Old program account holds the new program account
assert_eq!(bank.get_account(&old_address), Some(new_program_account));
// Lamports in the old token account were burnt
assert_eq!(bank.capitalization(), original_capitalization - 100);
} | rust_cleaned_test_functions.jsonl/28971 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 606
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25096,
1288,
16101,
368,
341,
286,
1077,
320,
77894,
5332,
11,
716,
67791,
3097,
12670,
8,
284,
1855,
16322,
13774,
5332,
7,
15,
317,
286,
1077,
5206,
6073,
284,
8547,
486,
931,
5478,
32509,
209... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_into() {
let raw_pk: [u8; PUBLIC_KEY_SIZE] = [
0x79, 0xce, 0xd, 0xe0, 0x43, 0x33, 0x4a, 0xec, 0xe0, 0x8b, 0x7b, 0xb5, 0x61, 0xbc,
0xe7, 0xc1, 0xd4, 0x69, 0xc3, 0x44, 0x26, 0xec, 0xef, 0xc0, 0x72, 0xa, 0x52, 0x4d,
0x37, 0x32, 0xef, 0xed,
];
let want = PublicKey::Ed25519(signatory::ed25519::PublicKey::new(raw_pk));
let pk = PubKeyResponse {
pub_key_ed25519: vec![
0x79, 0xce, 0xd, 0xe0, 0x43, 0x33, 0x4a, 0xec, 0xe0, 0x8b, 0x7b, 0xb5, 0x61, 0xbc,
0xe7, 0xc1, 0xd4, 0x69, 0xc3, 0x44, 0x26, 0xec, 0xef, 0xc0, 0x72, 0xa, 0x52, 0x4d,
0x37, 0x32, 0xef, 0xed,
],
};
let orig = pk.clone();
let got: PublicKey = pk.into();
assert_eq!(got, want);
// and back:
let round_trip_pk: PubKeyResponse = got.into();
assert_eq!(round_trip_pk, orig);
} | rust_cleaned_test_functions.jsonl/80376 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 607
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
45514,
368,
341,
286,
1077,
7112,
33321,
25,
508,
84,
23,
26,
31416,
6600,
4098,
60,
284,
2278,
310,
220,
15,
87,
22,
24,
11,
220,
15,
55963,
11,
220,
15,
9703,
11,
220,
15,
8371,
15,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_demote_program_write_locks() {
let keypair0 = Keypair::new();
let keypair1 = Keypair::new();
let keypair2 = Keypair::new();
let keypair3 = Keypair::new();
let account0 = AccountSharedData::new(1, 0, &Pubkey::default());
let account1 = AccountSharedData::new(2, 0, &Pubkey::default());
let account2 = AccountSharedData::new(3, 0, &Pubkey::default());
let account3 = AccountSharedData::new(4, 0, &Pubkey::default());
let accounts = Accounts::new_with_config_for_tests(
Vec::new(),
&ClusterType::Development,
AccountSecondaryIndexes::default(),
false,
AccountShrinkThreshold::default(),
);
accounts.store_slow_uncached(0, &keypair0.pubkey(), &account0);
accounts.store_slow_uncached(0, &keypair1.pubkey(), &account1);
accounts.store_slow_uncached(0, &keypair2.pubkey(), &account2);
accounts.store_slow_uncached(0, &keypair3.pubkey(), &account3);
let instructions = vec![CompiledInstruction::new(2, &(), vec![0, 1])];
let message = Message::new_with_compiled_instructions(
1,
0,
0, // All accounts marked as writable
vec![keypair0.pubkey(), keypair1.pubkey(), native_loader::id()],
Hash::default(),
instructions,
);
let tx = new_sanitized_tx(&[&keypair0], message, Hash::default());
let results0 = accounts.lock_accounts([tx].iter(), &FeatureSet::all_enabled());
assert!(results0[0].is_ok());
// Instruction program-id account demoted to readonly
assert_eq!(
*accounts
.account_locks
.lock()
.unwrap()
.readonly_locks
.get(&native_loader::id())
.unwrap(),
1
);
// Non-program accounts remain writable
assert!(accounts
.account_locks
.lock()
.unwrap()
.write_locks
.contains(&keypair0.pubkey()));
assert!(accounts
.account_locks
.lock()
.unwrap()
.write_locks
.contains(&keypair1.pubkey()));
} | rust_cleaned_test_functions.jsonl/13221 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1135
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
69403,
1272,
25096,
9165,
9818,
82,
368,
341,
286,
1077,
1376,
12670,
15,
284,
6569,
1082,
1310,
486,
931,
543,
286,
1077,
1376,
12670,
16,
284,
6569,
1082,
1310,
486,
931,
543,
286,
1077,
1376,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_address_in_range() {
let f1 = TempFile::new().unwrap().into_file();
f1.set_len(0x400).unwrap();
let f2 = TempFile::new().unwrap().into_file();
f2.set_len(0x400).unwrap();
let start_addr1 = GuestAddress(0x0);
let start_addr2 = GuestAddress(0x800);
let guest_mem =
GuestMemoryMmap::from_ranges(&[(start_addr1, 0x400), (start_addr2, 0x400)]).unwrap();
let guest_mem_backed_by_file = GuestMemoryMmap::from_ranges_with_files(&[
(start_addr1, 0x400, Some(FileOffset::new(f1, 0))),
(start_addr2, 0x400, Some(FileOffset::new(f2, 0))),
])
.unwrap();
let guest_mem_list = vec![guest_mem, guest_mem_backed_by_file];
for guest_mem in guest_mem_list.iter() {
assert!(guest_mem.address_in_range(GuestAddress(0x200)));
assert!(!guest_mem.address_in_range(GuestAddress(0x600)));
assert!(guest_mem.address_in_range(GuestAddress(0xa00)));
assert!(!guest_mem.address_in_range(GuestAddress(0xc00)));
}
} | rust_cleaned_test_functions.jsonl/63917 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 547
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6744,
1243,
9698,
368,
341,
286,
1077,
282,
16,
284,
19944,
1703,
486,
931,
1005,
15454,
1005,
18122,
2458,
543,
286,
282,
16,
980,
6043,
7,
15,
87,
19,
15,
15,
568,
15454,
543,
286,
1077,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_serialization() {
let summary = Summary::parse(SERIALIZED_SUMMARY).expect("from_str succeeded");
let summary2 = Summary::parse(SUMMARY2).expect("from_str succeeded");
let diff = summary.diff(&summary2);
let to_serialize = &diff;
static EXPECTED_JSON: &str = r#"{"target-packages":{"changed":[{"name":"dep","version":"0.4.3","crates-io":true,"change":"added","status":"direct","features":["std"]},{"name":"dep","version":"0.5.0","crates-io":true,"change":"added","status":"transitive","features":["std"]},{"name":"foo","version":"1.2.3","workspace-path":"foo","change":"modified","old-version":null,"old-source":null,"old-status":null,"new-status":"initial","added-features":["feature2"],"removed-features":[],"unchanged-features":["default","feature1"]},{"name":"dep","version":"0.4.2","crates-io":true,"change":"removed","old-status":"direct","old-features":["std"]}],"unchanged":[{"name":"no-changes","version":"1.5.3","crates-io":true,"status":"transitive","features":["default"]}]},"host-packages":{"changed":[{"name":"local-dep","version":"2.0.0","path":"../local-dep-2","change":"added","status":"transitive","features":[]},{"name":"bar","version":"0.2.0","workspace-path":"dir/bar","change":"modified","old-version":"0.1.0","old-source":null,"old-status":"workspace","new-status":"initial","added-features":[],"removed-features":[],"unchanged-features":["default","feature2"]},{"name":"local-dep","version":"1.1.2","path":"../local-dep","change":"modified","old-version":null,"old-source":null,"old-status":null,"new-status":"transitive","added-features":["dep-feature"],"removed-features":[],"unchanged-features":[]}]}}"#;
let j = serde_json::to_string(&to_serialize).expect("should serialize");
println!("json output: {}", j);
assert_eq!(j, EXPECTED_JSON);
static EXPECTED_TOML: &str = r#"[[target-packages.changed]]
name = "dep"
version = "0.4.3"
crates-io = true
change = "added"
status = "direct"
features = ["std"]
[[target-packages.changed]]
name = "dep"
version = "0.5.0"
crates-io = true
change = "added"
status = "transitive"
features = ["std"]
[[target-packages.changed]]
name = "foo"
version = "1.2.3"
workspace-path = "foo"
change = "modified"
new-status = "initial"
added-features = ["feature2"]
removed-features = []
unchanged-features = ["default", "feature1"]
[[target-packages.changed]]
name = "dep"
version = "0.4.2"
crates-io = true
change = "removed"
old-status = "direct"
old-features = ["std"]
[[target-packages.unchanged]]
name = "no-changes"
version = "1.5.3"
crates-io = true
status = "transitive"
features = ["default"]
[[host-packages.changed]]
name = "local-dep"
version = "2.0.0"
path = "../local-dep-2"
change = "added"
status = "transitive"
features = []
[[host-packages.changed]]
name = "bar"
version = "0.2.0"
workspace-path = "dir/bar"
change = "modified"
old-version = "0.1.0"
old-status = "workspace"
new-status = "initial"
added-features = []
removed-features = []
unchanged-features = ["default", "feature2"]
[[host-packages.changed]]
name = "local-dep"
version = "1.1.2"
path = "../local-dep"
change = "modified"
new-status = "transitive"
added-features = ["dep-feature"]
removed-features = []
unchanged-features = []
"#;
let toml_out = toml::to_string(&to_serialize).expect("should serialize");
println!("toml output: {}", toml_out);
assert_eq!(toml_out, EXPECTED_TOML);
let parsed = toml_out
.parse::<toml::Value>()
.expect("deserialization from value should work");
println!("parsed output: {:?}", parsed);
} | rust_cleaned_test_functions.jsonl/10247 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1257
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25602,
2022,
368,
341,
262,
1077,
12126,
284,
21517,
486,
6400,
3759,
640,
88727,
50369,
48870,
568,
17119,
445,
1499,
2895,
25331,
797,
262,
1077,
12126,
17,
284,
21517,
486,
6400,
3759,
2794,
48... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_inbound_substream_closed() {
let mut rt = Runtime::new().unwrap();
let (_ds_requests_tx, mut ds_notifs_rx, mut peer_mgr_notifs_tx, _peer_mgr_reqs_rx) =
start_direct_send_actor(rt.executor());
let peer_id = PeerId::random();
let (dialer_substream, listener_substream) = MemorySocket::new_pair();
// The dialer sends a message to the listener.
let f_substream = async move {
let mut dialer_substream =
Framed::new(dialer_substream.compat(), UviBytes::default()).sink_compat();
dialer_substream
.send(Bytes::from_static(MESSAGE_1))
.await
.unwrap();
// close the substream on the dialer side
drop(dialer_substream);
};
// Fake the listener NetworkProvider
let f_network_provider = async move {
peer_mgr_notifs_tx
.send(PeerManagerNotification::NewInboundSubstream(
peer_id,
NegotiatedSubstream {
protocol: ProtocolId::from_static(&PROTOCOL_1[..]),
substream: listener_substream,
},
))
.await
.unwrap();
expect_network_provider_recv_message(&mut ds_notifs_rx, peer_id, PROTOCOL_1, MESSAGE_1)
.await;
};
rt.spawn(f_substream.boxed().unit_error().compat());
rt.block_on(f_network_provider.boxed().unit_error().compat())
.unwrap();
} | rust_cleaned_test_functions.jsonl/81947 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 713
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1243,
10891,
5228,
4027,
44697,
368,
341,
262,
1077,
5206,
16677,
284,
10954,
486,
931,
1005,
15454,
1428,
262,
1077,
5453,
5356,
37216,
17805,
11,
5206,
11472,
7913,
21835,
24330,
11,
5206,
14397,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_state_key_prefix() {
let address1 = AccountAddress::new([12u8; AccountAddress::LENGTH]);
let address2 = AccountAddress::new([22u8; AccountAddress::LENGTH]);
let key1 = StateKey::AccessPath(AccessPath::new(address1, b"state_key".to_vec()));
let key2 = StateKey::AccessPath(AccessPath::new(address2, b"state_key".to_vec()));
let account1_key_prefx = StateKeyPrefix::new(StateKeyTag::AccessPath, address1.to_vec());
let account2_key_prefx = StateKeyPrefix::new(StateKeyTag::AccessPath, address2.to_vec());
assert!(account1_key_prefx.is_prefix(&key1).unwrap());
assert!(account2_key_prefx.is_prefix(&key2).unwrap());
assert!(!account1_key_prefx.is_prefix(&key2).unwrap());
assert!(!account2_key_prefx.is_prefix(&key1).unwrap());
} | rust_cleaned_test_functions.jsonl/78451 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 348
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4387,
3097,
13974,
368,
341,
286,
1077,
2621,
16,
284,
8615,
4286,
486,
931,
2561,
16,
17,
84,
23,
26,
8615,
4286,
486,
65981,
2558,
286,
1077,
2621,
17,
284,
8615,
4286,
486,
931,
2561,
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_fast_retransmit_duplicate_detection_with_data() {
let mut s = socket_established();
s.send_slice(b"abc").unwrap(); // This is lost
recv!(s, time 1000, Ok(TcpRepr {
seq_number: LOCAL_SEQ + 1,
ack_number: Some(REMOTE_SEQ + 1),
payload: &b"abc"[..],
..RECV_TEMPL
}));
// Normal ACK of previously recieved segment
send!(s, TcpRepr {
seq_number: REMOTE_SEQ + 1,
ack_number: Some(LOCAL_SEQ + 1),
..SEND_TEMPL
});
// First duplicate
send!(s, TcpRepr {
seq_number: REMOTE_SEQ + 1,
ack_number: Some(LOCAL_SEQ + 1),
..SEND_TEMPL
});
// Second duplicate
send!(s, TcpRepr {
seq_number: REMOTE_SEQ + 1,
ack_number: Some(LOCAL_SEQ + 1),
..SEND_TEMPL
});
assert_eq!(s.local_rx_dup_acks, 2,
"duplicate ACK counter is not set");
// as a duplicate ACK and should reset the duplicate ACK count
send!(s, TcpRepr {
seq_number: REMOTE_SEQ + 1,
ack_number: Some(LOCAL_SEQ + 1),
payload: &b"xxxxxx"[..],
..SEND_TEMPL
});
recv!(s, [TcpRepr {
seq_number: LOCAL_SEQ + 1 + 3,
ack_number: Some(REMOTE_SEQ + 1 + 6),
window_len: 58,
..RECV_TEMPL
}]);
assert_eq!(s.local_rx_dup_acks, 0,
"duplicate ACK counter is not reset when reciving data");
} | rust_cleaned_test_functions.jsonl/91893 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 909
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
35743,
1288,
1458,
1763,
70434,
57505,
6615,
1769,
368,
341,
286,
1077,
5206,
274,
284,
7575,
18583,
5102,
291,
1428,
286,
274,
5219,
26488,
1883,
1,
13683,
1827,
15454,
2129,
442,
1096,
374,
5558... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_validate_circuit_too_many_allowed_nodes() {
let state = setup_splinter_state();
let peer_connector = setup_peer_connector();
let orchestrator = setup_orchestrator();
// set up key registry
let mut key_registry = StorageKeyRegistry::new("memory".to_string()).unwrap();
let key_info = KeyInfo::builder(b"test_signer_a".to_vec(), "node_a".to_string()).build();
key_registry.save_key(key_info).unwrap();
let admin_shared = AdminServiceShared::new(
"node_a".into(),
orchestrator,
peer_connector,
Box::new(MockAuthInquisitor),
state,
Box::new(HashVerifier),
Box::new(key_registry),
Box::new(AllowAllKeyPermissionManager),
"memory",
)
.unwrap();
let mut circuit = setup_test_circuit();
let mut service_bad = SplinterService::new();
service_bad.set_service_id("service_b".to_string());
service_bad.set_service_type("type_a".to_string());
service_bad.set_allowed_nodes(RepeatedField::from_vec(vec![
"node_b".to_string(),
"extra".to_string(),
]));
circuit.set_roster(RepeatedField::from_vec(vec![service_bad]));
if let Ok(_) = admin_shared.validate_create_circuit(&circuit, b"test_signer_a", "node_a") {
panic!("Should have been invalid due to service having too many allowed nodes");
}
} | rust_cleaned_test_functions.jsonl/124170 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 697
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
42681,
666,
37268,
2346,
78,
22101,
42155,
14896,
368,
341,
286,
1077,
1584,
284,
6505,
643,
500,
2245,
4387,
543,
286,
1077,
14397,
76393,
284,
6505,
45159,
76393,
543,
286,
1077,
65128,
850,
284... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_cast_range_i8_min() {
assert_eq!(i8::min_value.to_int(), Some(i8::min_value as int));
assert_eq!(i8::min_value.to_i8(), Some(i8::min_value as i8));
assert_eq!(i8::min_value.to_i16(), Some(i8::min_value as i16));
assert_eq!(i8::min_value.to_i32(), Some(i8::min_value as i32));
assert_eq!(i8::min_value.to_i64(), Some(i8::min_value as i64));
assert_eq!(i8::min_value.to_uint(), None);
assert_eq!(i8::min_value.to_u8(), None);
assert_eq!(i8::min_value.to_u16(), None);
assert_eq!(i8::min_value.to_u32(), None);
assert_eq!(i8::min_value.to_u64(), None);
} | rust_cleaned_test_functions.jsonl/12446 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 357
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5303,
9698,
5318,
23,
7260,
368,
341,
286,
2060,
10714,
10297,
72,
23,
486,
1065,
3142,
2389,
4042,
1507,
220,
4329,
1956,
23,
486,
1065,
3142,
438,
526,
1106,
286,
2060,
10714,
10297,
72,
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_time_format() {
let t = NaiveTime::from_hms_nano(3, 5, 7, 98765432);
assert_eq!(t.format("%H,%k,%I,%l,%P,%p").to_string(), "03, 3,03, 3,am,AM");
assert_eq!(t.format("%M").to_string(), "05");
assert_eq!(t.format("%S,%f,%.f").to_string(), "07,098765432,.098765432");
assert_eq!(t.format("%.3f,%.6f,%.9f").to_string(), ".098,.098765,.098765432");
assert_eq!(t.format("%R").to_string(), "03:05");
assert_eq!(t.format("%T,%X").to_string(), "03:05:07,03:05:07");
assert_eq!(t.format("%r").to_string(), "03:05:07 AM");
assert_eq!(t.format("%t%n%%%n%t").to_string(), "\t\n%\n\t");
let t = NaiveTime::from_hms_micro(3, 5, 7, 432100);
assert_eq!(t.format("%S,%f,%.f").to_string(), "07,432100000,.432100");
assert_eq!(t.format("%.3f,%.6f,%.9f").to_string(), ".432,.432100,.432100000");
let t = NaiveTime::from_hms_milli(3, 5, 7, 210);
assert_eq!(t.format("%S,%f,%.f").to_string(), "07,210000000,.210");
assert_eq!(t.format("%.3f,%.6f,%.9f").to_string(), ".210,.210000,.210000000");
let t = NaiveTime::from_hms(3, 5, 7);
assert_eq!(t.format("%S,%f,%.f").to_string(), "07,000000000,");
assert_eq!(t.format("%.3f,%.6f,%.9f").to_string(), ".000,.000000,.000000000");
// corner cases
assert_eq!(NaiveTime::from_hms(13, 57, 9).format("%r").to_string(), "01:57:09 PM");
assert_eq!(NaiveTime::from_hms_milli(23, 59, 59, 1_000).format("%X").to_string(),
"23:59:60");
} | rust_cleaned_test_functions.jsonl/57982 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 826
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3009,
8955,
368,
341,
286,
1077,
259,
284,
12812,
533,
1462,
486,
1499,
1523,
1011,
1089,
5652,
7,
18,
11,
220,
20,
11,
220,
22,
11,
220,
24,
23,
22,
21,
20,
19,
18,
17,
317,
286,
2060,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_report_min_resolved_ts() {
fail::cfg("mock_tick_interval", "return(0)").unwrap();
fail::cfg("mock_collect_tick_interval", "return(0)").unwrap();
fail::cfg("mock_min_resolved_ts_interval", "return(0)").unwrap();
let mut suite = TestSuite::new(1);
let region = suite.cluster.get_region(&[]);
let ts1 = suite.cluster.pd_client.get_min_resolved_ts();
// Prewrite
let (k, v) = (b"k1", b"v");
let start_ts = block_on(suite.cluster.pd_client.get_tso()).unwrap();
let mut mutation = Mutation::default();
mutation.set_op(Op::Put);
mutation.key = k.to_vec();
mutation.value = v.to_vec();
suite.must_kv_prewrite(region.id, vec![mutation], k.to_vec(), start_ts);
// Commit
let commit_ts = block_on(suite.cluster.pd_client.get_tso()).unwrap();
suite.must_kv_commit(region.id, vec![k.to_vec()], start_ts, commit_ts);
sleep_ms(100);
let ts3 = suite.cluster.pd_client.get_min_resolved_ts();
let unapplied_ts = block_on(suite.cluster.pd_client.get_tso()).unwrap();
assert!(ts3 > ts1);
assert!(TimeStamp::new(ts3) > commit_ts);
assert!(TimeStamp::new(ts3) < unapplied_ts);
fail::remove("mock_tick_interval");
fail::remove("mock_collect_tick_interval");
fail::remove("mock_min_resolved_ts_interval");
suite.stop();
} | rust_cleaned_test_functions.jsonl/117185 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 582
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14813,
7260,
4918,
8731,
25023,
368,
341,
262,
3690,
486,
14072,
445,
16712,
43612,
20541,
497,
330,
689,
7,
15,
63554,
15454,
543,
262,
3690,
486,
14072,
445,
16712,
68140,
43612,
20541,
497,
330... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_vhost_user_net_existing_tap() {
test_vhost_user_net(
Some("vunet-tap0"),
2,
Some(&prepare_vhost_user_net_daemon),
false,
false,
)
} | rust_cleaned_test_functions.jsonl/23970 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 179
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2273,
3790,
3317,
19722,
62630,
528,
391,
368,
341,
310,
1273,
2273,
3790,
3317,
19722,
1006,
394,
4329,
445,
85,
359,
295,
2385,
391,
15,
4461,
394,
220,
17,
345,
394,
4329,
2099,
13609,
2273,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_aes_siv_key_template() {
tink_daead::init();
let test_cases = vec![("AES256_SIV", tink_daead::aes_siv_key_template())];
for (name, template) in test_cases {
let want = tink_tests::key_template_proto("daead", name).unwrap();
assert_eq!(want, template);
// Check that the same template is registered under the same name.
let generator = tink_core::registry::get_template_generator(name).unwrap();
let registered = generator();
assert_eq!(registered, template);
assert!(test_encrypt_decrypt(&template).is_ok());
}
} | rust_cleaned_test_functions.jsonl/113343 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 247
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
90958,
643,
344,
3097,
8693,
368,
341,
262,
90584,
47070,
3149,
486,
2327,
543,
262,
1077,
1273,
41427,
284,
7486,
20703,
445,
69168,
17,
20,
21,
1098,
3090,
497,
90584,
47070,
3149,
486,
76584,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_voter_registration() {
let (vote_pubkey, vote_account) = create_test_account();
let vote_state: VoteState = StateMut::<VoteStateVersions>::state(&*vote_account.borrow())
.unwrap()
.convert_to_current();
assert_eq!(vote_state.authorized_voters.len(), 1);
assert_eq!(
*vote_state.authorized_voters.first().unwrap().1,
vote_pubkey
);
assert!(vote_state.votes.is_empty());
} | rust_cleaned_test_functions.jsonl/6085 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 237
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2273,
25392,
49101,
368,
341,
286,
1077,
320,
29358,
34014,
792,
11,
6910,
13500,
8,
284,
1855,
4452,
13500,
1428,
286,
1077,
6910,
4387,
25,
34034,
1397,
284,
3234,
51440,
27638,
41412,
1397,
690... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_clone_is_new() {
numid!(@CloneIsNew struct Test);
let t = Test::new();
assert_ne!(t, t.clone());
let tt = Test::create_lower(0);
assert_ne!(tt, tt.clone());
} | rust_cleaned_test_functions.jsonl/10272 | {
"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,
54742,
6892,
5921,
368,
341,
286,
1629,
307,
0,
5957,
37677,
3872,
3564,
2036,
3393,
317,
286,
1077,
259,
284,
3393,
486,
931,
543,
286,
2060,
13925,
10297,
83,
11,
259,
15997,
1423,
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 |
#[test]
fn test_create_tx_both_non_witness_utxo_and_witness_utxo() {
let (wallet, _, _) =
get_funded_wallet("wsh(pk(cVpPVruEDdmutPzisEsYvtST1usBR3ntr8pXSyt6D2YYqXRyPcFW))");
let addr = wallet.get_new_address().unwrap();
let (psbt, _) = wallet
.create_tx(
TxBuilder::new()
.set_single_recipient(addr.script_pubkey())
.drain_wallet()
.force_non_witness_utxo(),
)
.unwrap();
assert!(psbt.inputs[0].non_witness_utxo.is_some());
assert!(psbt.inputs[0].witness_utxo.is_some());
} | rust_cleaned_test_functions.jsonl/11344 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 386
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8657,
17805,
88819,
21637,
1670,
8091,
60363,
40822,
8378,
1670,
8091,
60363,
40822,
368,
341,
286,
1077,
320,
35735,
11,
8358,
27439,
4035,
310,
633,
761,
36053,
62308,
445,
86,
927,
39928,
1337,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parsing_zero_word_count() {
let mut v = ZERO_BOUND_HEADER.to_vec();
v.append(&mut vec![0x00, 0x00, 0x00, 0x00]); // OpNop with word count 0
let mut c = RetainingConsumer::new();
let p = Parser::new(&v, &mut c);
// The first instruction starts at byte offset 20.
assert_matches!(p.parse(), Err(State::WordCountZero(20, 1)));
} | rust_cleaned_test_functions.jsonl/85736 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 184
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
28598,
19359,
13533,
3180,
368,
341,
286,
1077,
5206,
348,
284,
54593,
73644,
20330,
2389,
13251,
543,
286,
348,
2057,
2099,
6984,
7486,
20703,
15,
87,
15,
15,
11,
220,
15,
87,
15,
15,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_downcast_trait_object() {
trait T<'a>: Tid<'a> {}
#[derive(Tid)]
struct S<'a>(&'a str);
impl<'a> T<'a> for S<'a> {}
let s = String::from("xx");
let orig = S(&s);
let to = &orig as &dyn T;
let downcasted = to.downcast_ref::<S>().unwrap();
assert_eq!(orig.0, downcasted.0);
} | rust_cleaned_test_functions.jsonl/16590 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 170
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13998,
3829,
78491,
5314,
368,
341,
262,
17567,
350,
18291,
64,
26818,
350,
307,
18291,
64,
29,
5613,
262,
11506,
27098,
4140,
307,
5563,
262,
2036,
328,
18291,
64,
44784,
6,
64,
607,
317,
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... | 2 |
#[test]
fn test_lookup_namespace_uri() {
let xml = xml("x", "http://foo.com");
assert!(xml.lookup_namespace_uri("y").is_none());
assert_eq!(xml.lookup_namespace_uri("x").unwrap(), "http://foo.com");
} | rust_cleaned_test_functions.jsonl/33772 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 112
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
27464,
41571,
15572,
368,
341,
286,
1077,
8396,
284,
8396,
445,
87,
497,
330,
1254,
1110,
7975,
905,
797,
286,
2060,
10297,
6455,
39937,
41571,
15572,
445,
88,
1827,
285,
31488,
1423,
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 |
#[test]
fn test_scans_escaped_strings() {
let mut scanner = Scanner::new(
"<?php
$a = 'aa\\'a';
$b = \"d\\\"dd\";
",
);
scanner.scan().unwrap();
assert_eq!(
token_list!(scanner.tokens),
"<?php $a = 'aa\\'a' ; $b = \"d\\\"dd\" ; "
);
} | rust_cleaned_test_functions.jsonl/52949 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 218
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13171,
596,
62,
65826,
33500,
368,
341,
286,
1077,
5206,
20775,
284,
17170,
486,
931,
1006,
310,
40271,
1208,
198,
310,
400,
64,
284,
364,
5305,
3422,
6,
64,
1010,
310,
400,
65,
284,
7245,
67,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_load_by_program_slot() {
let accounts = Accounts::new(Vec::new(), &ClusterType::Development);
// Load accounts owned by various programs into AccountsDB
let pubkey0 = solana_sdk::pubkey::new_rand();
let account0 = Account::new(1, 0, &Pubkey::new(&[2; 32]));
accounts.store_slow(0, &pubkey0, &account0);
let pubkey1 = solana_sdk::pubkey::new_rand();
let account1 = Account::new(1, 0, &Pubkey::new(&[2; 32]));
accounts.store_slow(0, &pubkey1, &account1);
let pubkey2 = solana_sdk::pubkey::new_rand();
let account2 = Account::new(1, 0, &Pubkey::new(&[3; 32]));
accounts.store_slow(0, &pubkey2, &account2);
let loaded = accounts.load_by_program_slot(0, Some(&Pubkey::new(&[2; 32])));
assert_eq!(loaded.len(), 2);
let loaded = accounts.load_by_program_slot(0, Some(&Pubkey::new(&[3; 32])));
assert_eq!(loaded, vec![(pubkey2, account2)]);
let loaded = accounts.load_by_program_slot(0, Some(&Pubkey::new(&[4; 32])));
assert_eq!(loaded, vec![]);
} | rust_cleaned_test_functions.jsonl/82602 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 498
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12411,
3710,
25096,
27563,
368,
341,
286,
1077,
9618,
284,
40655,
486,
931,
49923,
486,
931,
1507,
609,
28678,
929,
486,
39419,
626,
286,
442,
8893,
9618,
12938,
553,
5257,
7468,
1119,
40655,
3506... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_put_response() {
#[derive(Apiv2Schema, serde::Serialize)]
struct Person {
first_name: String,
last_name: String,
}
#[api_v2_errors(code = 400, description = "Bad request", code = 404, description = "Not found")]
#[derive(Debug, thiserror::Error)]
enum PersonError {
#[error("unexpected error")]
Unexpected,
}
impl ResponseError for PersonError {
fn status_code(&self) -> StatusCode {
StatusCode::INTERNAL_SERVER_ERROR
}
}
#[api_v2_operation]
#[put("/")]
async fn put_person(_: HttpRequest) -> Result<PutResponse<Person>, JsonError<PersonError>> {
Err(JsonError::from(PersonError::Unexpected))
}
let (tx, rx) = std::sync::mpsc::channel();
App::new()
.wrap_api()
.service(put_person)
.with_raw_json_spec(move |app, json| {
let json_spec = format!("{}", json);
tx.send(json_spec).unwrap();
app
});
let json_spec = rx.recv().unwrap();
assert_eq!(
r##"{"definitions":{"Person":{"properties":{"first_name":{"type":"string"},"last_name":{"type":"string"}},"required":["first_name","last_name"],"type":"object"}},"info":{"title":"","version":""},"paths":{"/":{"put":{"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/Person"}},"201":{"description":"Created","schema":{"$ref":"#/definitions/Person"}},"400":{"description":"Bad request"},"404":{"description":"Not found"}}}}},"swagger":"2.0"}"##,
json_spec
);
} | rust_cleaned_test_functions.jsonl/87613 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 651
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15557,
9655,
368,
341,
262,
11506,
27098,
4346,
79,
344,
17,
8632,
11,
61570,
486,
15680,
5563,
262,
2036,
7357,
341,
286,
1156,
1269,
25,
923,
345,
286,
1537,
1269,
25,
923,
345,
262,
555,
26... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_argsiter() {
static ARGS: [(ArgInfo, u8); 7] = [
flag!("-bar", 1),
take_arg!("-foo", String, Separated, 2),
flag!("-fuga", 3),
take_arg!("-hoge", Path, Concatenated, 4),
flag!("-plop", 5),
take_arg!("-qux", String, CanBeSeparated('='), 6),
flag!("-zorglub", 7),
];
let args = [
"-nomatch",
"-foo",
"value",
"-hoge",
"value", // -hoge doesn't take a separate value
"-hoge=value", // = is not recognized as a separator
"-hogevalue",
"-zorglub",
"-qux",
"value",
"-plop",
"-quxbar", // -quxbar is not -qux with a value of bar
"-qux=value",
];
let iter = ArgsIter::new(args.into_iter().map(OsString::from), &ARGS[..]);
let expected = vec![
ArgumentItem {
arg: arg!(UnknownFlag("-nomatch")),
data: None,
},
ArgumentItem {
arg: arg!(WithValue("-foo", String("value"), Separated)),
data: Some(2),
},
ArgumentItem {
arg: arg!(WithValue("-hoge", PathVal(""), Concatenated)),
data: Some(4),
},
ArgumentItem {
arg: arg!(Raw("value")),
data: None,
},
ArgumentItem {
arg: arg!(WithValue("-hoge", PathVal("=value"), Concatenated)),
data: Some(4),
},
ArgumentItem {
arg: arg!(WithValue("-hoge", PathVal("value"), Concatenated)),
data: Some(4),
},
ArgumentItem {
arg: arg!(Flag("-zorglub")),
data: Some(7),
},
ArgumentItem {
arg: arg!(WithValue("-qux", String("value"), CanBeConcatenated('='))),
data: Some(6),
},
ArgumentItem {
arg: arg!(Flag("-plop")),
data: Some(5),
},
ArgumentItem {
arg: arg!(UnknownFlag("-quxbar")),
data: None,
},
ArgumentItem {
arg: arg!(WithValue("-qux", String("value"), CanBeSeparated('='))),
data: Some(6),
},
];
match diff_with(iter, expected, |ref a, ref b| {
assert_eq!(a, b);
true
}) {
None => {}
Some(Diff::FirstMismatch(_, _, _)) => unreachable!(),
Some(Diff::Shorter(_, i)) => assert_eq!(i.collect::<Vec<_>>(), vec![]),
Some(Diff::Longer(_, i)) => {
assert_eq!(Vec::<ArgumentItem<u8>>::new(), i.collect::<Vec<_>>())
}
}
} | rust_cleaned_test_functions.jsonl/108773 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1726
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8384,
2015,
368,
341,
286,
1099,
84149,
25,
17826,
2735,
1731,
11,
575,
23,
1215,
220,
22,
60,
284,
2278,
310,
5181,
0,
13645,
2257,
497,
220,
16,
1326,
310,
1896,
6057,
0,
13645,
7975,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_query_conversion_no_resource_type() {
let sr = meta_search::SearchRequest {
key: Some("key".to_string()),
resource_type: None,
conditions: vec![meta_search::FieldQuery {
key: "fancy_key".to_owned(),
query: "\"fancy_value\"".to_owned(),
}],
pagination: None,
};
let spec: SearchSpec = sr.try_into().unwrap();
let query = spec.filter;
let expected = mongodb::bson::doc! {
"key": "key",
"metadata.fancy_key" : "fancy_value"
};
assert_eq!(super::DEFAULT_PAGE, spec.page);
assert_eq!(super::DEFAULT_PAGE_SIZE, spec.page_size);
assert_eq!(expected, query);
} | rust_cleaned_test_functions.jsonl/113861 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 397
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5738,
64132,
6536,
17962,
1819,
368,
341,
286,
1077,
18962,
284,
8823,
10716,
486,
5890,
1900,
341,
310,
1376,
25,
4329,
445,
792,
3263,
983,
3904,
14702,
310,
5101,
1819,
25,
2240,
345,
310,
46... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_map_macro() {
let m = map!{1=>"1",2=>"2"};
match m.get(&1) {
Some(&i) if i == "1" => (),
_ => assert!(false),
}
} | rust_cleaned_test_functions.jsonl/105361 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 100
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5376,
58810,
368,
341,
262,
1077,
296,
284,
2415,
0,
90,
16,
44488,
16,
497,
17,
44488,
17,
26690,
1066,
262,
2432,
296,
670,
2099,
16,
8,
341,
286,
4329,
2099,
72,
8,
421,
600,
621,
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
] | 3 |
#[test]
fn test_range_with_prefix_wrapover() {
let mut storage = MockStorage::new();
let prefix = to_length_prefixed(b"f\xff\xff");
let other_prefix = to_length_prefixed(b"f\xff\x44");
// set some values in this range
set_with_prefix(&mut storage, &prefix, b"bar", b"none");
set_with_prefix(&mut storage, &prefix, b"snowy", b"day");
// set some values outside this range
set_with_prefix(&mut storage, &other_prefix, b"moon", b"buggy");
// ensure we get proper result from prefixed_range iterator
let iter = range_with_prefix(&storage, &prefix, None, None, Order::Descending);
let elements: Vec<Pair> = iter.collect();
assert_eq!(
elements,
vec![
(b"snowy".to_vec(), b"day".to_vec()),
(b"bar".to_vec(), b"none".to_vec()),
]
);
} | rust_cleaned_test_functions.jsonl/83834 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 435
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9698,
6615,
13974,
38550,
1975,
368,
341,
286,
1077,
5206,
5819,
284,
14563,
5793,
486,
931,
543,
1789,
286,
1077,
9252,
284,
311,
5118,
43331,
3286,
1883,
96171,
86977,
86977,
797,
286,
1077,
100... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_msg(){
let reference_1 = Package::Msg(MessagePackage{
key: "SOME KEY".to_string(),
payload: vec![1, 2, 3, 4, 5],
});
let reference_2 = Package::Msg(MessagePackage{
key: "".to_string(),
payload: vec![],
});
let result: Vec<u8> = reference_1.clone().into();
match Package::try_from(result){
Ok(result) => {
assert_eq!(reference_1, result)
}
Err(_) => {assert!(false, "Unexpected error")}
}
let result: Vec<u8> = reference_2.clone().into();
match Package::try_from(result){
Ok(result) => {
assert_eq!(reference_2, result)
}
Err(_) => {assert!(false, "Unexpected error")}
}
} | rust_cleaned_test_functions.jsonl/124207 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 441
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6483,
3032,
286,
1077,
5785,
62,
16,
284,
16906,
486,
6611,
29359,
13100,
515,
310,
1376,
25,
330,
50,
11408,
12013,
3263,
983,
3904,
3148,
310,
7729,
25,
7486,
20703,
16,
11,
220,
17,
11,
220... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_sys_errno() {
let eperm = errno::Errno(1);
let err = ErrorKind::Sys(eperm);
assert!(err.description().contains("syscall failed"));
assert!(format!("{}", err).contains("Operation not permitted"));
} | rust_cleaned_test_functions.jsonl/24662 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 96
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20344,
37363,
368,
341,
262,
1077,
384,
19913,
284,
26955,
486,
7747,
2152,
7,
16,
317,
262,
1077,
1848,
284,
4600,
10629,
486,
32792,
2026,
19913,
317,
262,
2060,
10297,
615,
13178,
1005,
13372,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_metadata_tf1x_simple_value() {
let md = pb::SummaryMetadata {
plugin_data: Some(PluginData {
plugin_name: "ignored_plugin".to_string(),
content: Bytes::from_static(b"ignored_content"),
..Default::default()
}),
..Default::default()
};
let v = SummaryValue(Box::new(Value::SimpleValue(0.125)));
let result = v.initial_metadata(Some(md));
assert_eq!(
*result,
pb::SummaryMetadata {
plugin_data: Some(PluginData {
plugin_name: plugin_names::SCALARS.to_string(),
..Default::default()
}),
data_class: pb::DataClass::Scalar.into(),
..Default::default()
}
);
} | rust_cleaned_test_functions.jsonl/6191 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 555
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
22220,
47719,
16,
87,
30015,
3142,
368,
341,
310,
1077,
10688,
284,
17310,
486,
19237,
14610,
341,
394,
9006,
1769,
25,
4329,
7,
11546,
1043,
341,
503,
9006,
1269,
25,
330,
58471,
23110,
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_instance_lookup() {
// be the only thing we should permit
qext(&mut Polar::new(), "new a(x: 1).x = 1", values![1], 1);
} | rust_cleaned_test_functions.jsonl/97622 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 70
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11904,
27464,
368,
341,
1066,
262,
442,
387,
279,
1172,
3166,
582,
1265,
11549,
198,
262,
2804,
427,
2099,
6984,
55896,
486,
931,
1507,
330,
931,
264,
2075,
25,
220,
16,
568,
87,
284,
220,
16,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_sign_and_verify_message_tsig_reject_keyname() {
let (mut question, signer) = get_message_and_signer();
let other_name: Name = Name::from_ascii("other_name").unwrap();
let mut signature = question.take_signature().remove(0);
signature.set_name(other_name);
question.add_tsig(signature);
assert!(signer
.verify_message_byte(None, &question.to_bytes().unwrap(), true)
.is_err());
} | rust_cleaned_test_functions.jsonl/36502 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 218
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11172,
8378,
35638,
6462,
528,
21339,
1288,
583,
3097,
606,
368,
341,
286,
1077,
320,
6984,
3405,
11,
70039,
8,
284,
633,
6462,
8378,
11172,
261,
1428,
286,
1077,
1008,
1269,
25,
3988,
284,
3988... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_node_check_merged_message() {
let mut cluster = new_node_cluster(0, 4);
configure_for_merge(&mut cluster);
let pd_client = Arc::clone(&cluster.pd_client);
pd_client.disable_default_operator();
cluster.run_conf_change();
cluster.must_put(b"k1", b"v1");
cluster.must_put(b"k3", b"v3");
// test if orphan merging peer will be gc
let mut region = pd_client.get_region(b"k2").unwrap();
pd_client.must_add_peer(region.get_id(), new_peer(2, 2));
cluster.must_split(®ion, b"k2");
let mut left = pd_client.get_region(b"k1").unwrap();
pd_client.must_add_peer(left.get_id(), new_peer(3, 3));
let mut right = pd_client.get_region(b"k2").unwrap();
cluster.add_send_filter(CloneFilterFactory(RegionPacketFilter::new(
right.get_id(),
3,
)));
pd_client.must_add_peer(right.get_id(), new_peer(3, 10));
let left_on_store1 = find_peer(&left, 1).unwrap().to_owned();
cluster.must_transfer_leader(left.get_id(), left_on_store1);
pd_client.must_merge(left.get_id(), right.get_id());
region = pd_client.get_region(b"k2").unwrap();
must_get_none(&cluster.get_engine(3), b"k3");
must_get_equal(&cluster.get_engine(3), b"k1", b"v1");
let region_on_store3 = find_peer(®ion, 3).unwrap().to_owned();
pd_client.must_remove_peer(region.get_id(), region_on_store3);
must_get_none(&cluster.get_engine(3), b"k1");
cluster.clear_send_filters();
pd_client.must_add_peer(region.get_id(), new_peer(3, 11));
// test if stale peer before conf removal is destroyed automatically
region = pd_client.get_region(b"k1").unwrap();
cluster.must_split(®ion, b"k2");
left = pd_client.get_region(b"k1").unwrap();
right = pd_client.get_region(b"k2").unwrap();
pd_client.must_add_peer(left.get_id(), new_peer(4, 4));
must_get_equal(&cluster.get_engine(4), b"k1", b"v1");
cluster.add_send_filter(IsolationFilterFactory::new(4));
pd_client.must_remove_peer(left.get_id(), new_peer(4, 4));
pd_client.must_merge(left.get_id(), right.get_id());
cluster.clear_send_filters();
must_get_none(&cluster.get_engine(4), b"k1");
// test gc work under complicated situation.
cluster.must_put(b"k5", b"v5");
region = pd_client.get_region(b"k2").unwrap();
cluster.must_split(®ion, b"k2");
region = pd_client.get_region(b"k4").unwrap();
cluster.must_split(®ion, b"k4");
left = pd_client.get_region(b"k1").unwrap();
let middle = pd_client.get_region(b"k3").unwrap();
let middle_on_store1 = find_peer(&middle, 1).unwrap().to_owned();
cluster.must_transfer_leader(middle.get_id(), middle_on_store1);
right = pd_client.get_region(b"k5").unwrap();
let left_on_store3 = find_peer(&left, 3).unwrap().to_owned();
pd_client.must_remove_peer(left.get_id(), left_on_store3);
must_get_none(&cluster.get_engine(3), b"k1");
cluster.add_send_filter(IsolationFilterFactory::new(3));
left = pd_client.get_region(b"k1").unwrap();
pd_client.must_add_peer(left.get_id(), new_peer(3, 5));
left = pd_client.get_region(b"k1").unwrap();
pd_client.must_merge(middle.get_id(), left.get_id());
pd_client.must_merge(right.get_id(), left.get_id());
cluster.must_delete(b"k3");
cluster.must_delete(b"k5");
cluster.must_put(b"k4", b"v4");
cluster.clear_send_filters();
let engine3 = cluster.get_engine(3);
must_get_equal(&engine3, b"k1", b"v1");
must_get_equal(&engine3, b"k4", b"v4");
must_get_none(&engine3, b"k3");
must_get_none(&engine3, b"v5");
} | rust_cleaned_test_functions.jsonl/27246 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1564
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5084,
7200,
90702,
6462,
368,
341,
262,
1077,
5206,
10652,
284,
501,
5084,
28441,
7,
15,
11,
220,
19,
317,
262,
14411,
5478,
20888,
2099,
6984,
10652,
317,
262,
1077,
7744,
8179,
284,
19689,
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_decode_identifiers() {
let mut decoder = Decoder::new(from_str("null").unwrap());
let v: () = Decodable::decode(&mut decoder).unwrap();
assert_eq!(v, ());
let mut decoder = Decoder::new(from_str("true").unwrap());
let v: bool = Decodable::decode(&mut decoder).unwrap();
assert_eq!(v, true);
let mut decoder = Decoder::new(from_str("false").unwrap());
let v: bool = Decodable::decode(&mut decoder).unwrap();
assert_eq!(v, false);
} | rust_cleaned_test_functions.jsonl/111027 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 235
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15227,
38399,
11836,
368,
341,
286,
1077,
5206,
24551,
284,
50472,
486,
931,
17016,
2895,
445,
2921,
1827,
15454,
1423,
286,
1077,
348,
25,
1719,
284,
3714,
69129,
486,
18196,
2099,
6984,
24551,
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_show_line_number() {
let mut pane = gen_pane!(OpenOptions::new().write(true).open("/dev/null").unwrap());
pane.show_line_number(true);
assert_eq!(pane.show_linenumber, true);
pane.show_line_number(false);
assert_eq!(pane.show_linenumber, false);
} | rust_cleaned_test_functions.jsonl/1685 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 147
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15267,
6528,
5500,
368,
341,
286,
1077,
5206,
37322,
284,
4081,
620,
2145,
10297,
5002,
3798,
486,
931,
1005,
4934,
3715,
568,
2508,
4283,
3583,
19293,
1827,
15454,
1423,
286,
37322,
5460,
6528,
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_rand_new_with_seed() {
let tests = vec![
(0, 0.15522042769493574, 0.620881741513388),
(1, 0.40540353712197724, 0.8716141803857071),
(-1, 0.9050373219931845, 0.37014932126752037),
(9223372036854775807, 0.9050373219931845, 0.37014932126752037),
];
for (seed, exp1, exp2) in tests {
let mut rand = MySQLRng::new_with_seed(seed);
let res1 = rand.gen();
assert_eq!(res1, exp1);
let res2 = rand.gen();
assert_eq!(res2, exp2);
}
} | rust_cleaned_test_functions.jsonl/9511 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 345
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
33864,
5921,
6615,
33809,
368,
341,
286,
1077,
7032,
284,
7486,
90515,
310,
320,
15,
11,
220,
15,
13,
16,
20,
20,
17,
17,
15,
19,
17,
22,
21,
24,
19,
24,
18,
20,
22,
19,
11,
220,
15,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_mp4() {
let format = FileFormat::from_file("fixtures/video/sample.mp4").unwrap();
assert_eq!(format, FileFormat::Mpeg4Part14Video);
} | rust_cleaned_test_functions.jsonl/115188 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 68
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39898,
19,
368,
341,
262,
1077,
3561,
284,
2887,
4061,
486,
1499,
2458,
445,
45247,
41303,
69851,
16870,
19,
1827,
15454,
543,
262,
2060,
10714,
10297,
2243,
11,
2887,
4061,
486,
44,
10311,
19,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_rb_node() {
let parent_node = Rc::new(RefCell::new(RBTreeNode {
label: Label::from_str("com").unwrap(),
rr_sets: Default::default(),
parent: None,
subtree: None,
}));
let node = Rc::new(RefCell::new(RBTreeNode {
label: Label::from_str("baidu").unwrap(),
rr_sets: Default::default(),
parent: None,
subtree: None,
}));
node.deref().borrow_mut().parent = Some(Rc::downgrade(&parent_node));
let mut child = RBTreeNode {
label: Label::from_str("www").unwrap(),
rr_sets: Default::default(),
parent: None,
subtree: None,
};
child.parent = Some(Rc::downgrade(&node));
assert_eq!(child.get_name().to_string(), "www.baidu.com.".to_owned());
let node = RBTreeNode {
label: Label::root(),
rr_sets: Default::default(),
parent: None,
subtree: None,
};
assert_eq!(node.get_name().to_string(), ".".to_owned());
} | rust_cleaned_test_functions.jsonl/29050 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 580
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
68544,
5084,
368,
341,
286,
1077,
2681,
5084,
284,
81463,
486,
931,
7,
3945,
3599,
486,
931,
2785,
33,
26597,
341,
310,
2383,
25,
9402,
486,
1499,
2895,
445,
874,
1827,
15454,
3148,
310,
34393,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_play() {
let mut sudoku = create_sudoku(TEST_VALUES);
assert_eq!(sudoku.play(0, 10), PlayResult::InvalidInput);
assert_eq!(sudoku.play(100, 0), PlayResult::InvalidInput);
assert_eq!(sudoku.play(0, 7), PlayResult::InvalidMove);
assert_eq!(sudoku.play(0, 4), PlayResult::Ok);
assert_eq!(sudoku.grid[0].unwrap().get(), 4);
assert_eq!(sudoku.play(0, 0), PlayResult::Ok);
assert_eq!(sudoku.grid[0], None);
} | rust_cleaned_test_functions.jsonl/58576 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 242
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
22144,
368,
341,
286,
1077,
5206,
90809,
284,
1855,
643,
68302,
50320,
58662,
626,
286,
2060,
10714,
10297,
82,
68302,
12972,
7,
15,
11,
220,
16,
15,
701,
7054,
2077,
486,
7928,
2505,
317,
286,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_add() {
let num0 = Number::new("[[[[4,3],4],4],[7,[[8,4],9]]]");
let num1 = Number::new("[1,1]");
let result = num0.add(num1);
assert_eq!(result, Number::new("[[[[0,7],4],[[7,8],[6,0]]],[8,1]]"));
} | rust_cleaned_test_functions.jsonl/100424 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 143
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
368,
341,
286,
1077,
1629,
15,
284,
5624,
486,
931,
10937,
15505,
58,
19,
11,
18,
1125,
19,
1125,
19,
14955,
22,
11,
15505,
23,
11,
19,
1125,
24,
5053,
37389,
286,
1077,
1629,
16,
284,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_protocol_state_chain_epoch_slot() {
let mut c: ProtocolStateChain = ProtocolStateChain(vec![]);
let mut b0: ProtocolState = Default::default();
b0.body.consensus_state.blockchain_length = Length(0);
b0.body.consensus_state.curr_global_slot = GlobalSlot {
slot_number: GlobalSlotNumber(0),
slots_per_epoch: Length(1000),
};
c.push(b0).unwrap();
let epoch_slot = c.epoch_slot();
assert_eq!(epoch_slot, Some(0));
let mut b1: ProtocolState = Default::default();
b1.body.consensus_state.blockchain_length = Length(1);
b1.body.consensus_state.curr_global_slot = GlobalSlot {
slot_number: GlobalSlotNumber(1),
slots_per_epoch: Length(1000),
};
c.push(b1).unwrap();
let epoch_slot = c.epoch_slot();
assert_eq!(epoch_slot, Some(1));
let mut b2: ProtocolState = Default::default();
b2.body.consensus_state.blockchain_length = Length(2);
b2.body.consensus_state.curr_global_slot = GlobalSlot {
slot_number: GlobalSlotNumber(1002),
slots_per_epoch: Length(1000),
};
c.push(b2).unwrap();
let epoch_slot = c.epoch_slot();
assert_eq!(epoch_slot, Some(2));
} | rust_cleaned_test_functions.jsonl/16444 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 624
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34880,
4387,
30583,
20682,
27563,
368,
341,
286,
1077,
5206,
272,
25,
24572,
1397,
18837,
284,
24572,
1397,
18837,
25592,
0,
1294,
626,
286,
1077,
5206,
293,
15,
25,
24572,
1397,
284,
7899,
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_add_essential_files() {
let _ = env_logger::try_init();
let options = DocBuilderOptions::from_prefix(PathBuf::from("../cratesfyi-prefix"));
let docbuilder = DocBuilder::new(options);
docbuilder.add_essential_files().unwrap();
} | rust_cleaned_test_functions.jsonl/31380 | {
"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,
2891,
62,
48482,
10931,
368,
341,
286,
1077,
716,
284,
6105,
27413,
486,
1539,
6137,
543,
286,
1077,
2606,
284,
21709,
3297,
3798,
486,
1499,
13974,
33030,
15064,
486,
1499,
17409,
5082,
973,
3059... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_add_get_proposals() {
let pool = create_connection_pool_and_migrate();
let store = DieselAdminServiceStore::new(pool);
let proposal = create_proposal();
store
.add_proposal(proposal.clone())
.expect("Unable to add circuit proposal");
let fetched_proposal = store
.get_proposal("WBKLF-BBBBB")
.expect("Unable to get proposal")
.expect("Got None when expecting proposal");
assert_eq!(proposal, fetched_proposal);
} | rust_cleaned_test_functions.jsonl/564 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 250
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
3062,
21663,
85975,
368,
341,
286,
1077,
7314,
284,
1855,
15866,
15709,
8378,
717,
34479,
1428,
286,
1077,
3553,
284,
53794,
7210,
1860,
6093,
486,
931,
41838,
626,
286,
1077,
13734,
284,
18... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_eval_unary_function_raw_column() {
#[rpn_fn(nullable)]
fn foo(v: Option<&i64>) -> Result<Option<i64>> {
Ok(Some(v.unwrap() + 5))
}
let mut ctx = EvalContext::default();
let mut columns = LazyBatchColumnVec::from(vec![{
let mut col = LazyBatchColumn::raw_with_capacity(3);
let mut datum_raw = Vec::new();
datum_raw
.write_datum(&mut ctx, &[Datum::I64(-5)], false)
.unwrap();
col.mut_raw().push(&datum_raw);
let mut datum_raw = Vec::new();
datum_raw
.write_datum(&mut ctx, &[Datum::I64(-7)], false)
.unwrap();
col.mut_raw().push(&datum_raw);
let mut datum_raw = Vec::new();
datum_raw
.write_datum(&mut ctx, &[Datum::I64(3)], false)
.unwrap();
col.mut_raw().push(&datum_raw);
col
}]);
let schema = &[FieldTypeTp::LongLong.into()];
let exp = RpnExpressionBuilder::new_for_test()
.push_column_ref_for_test(0)
.push_fn_call_for_test(foo_fn_meta(), 1, FieldTypeTp::LongLong)
.build_for_test();
let mut ctx = EvalContext::default();
let result = exp.eval(&mut ctx, schema, &mut columns, &[2, 0, 1], 3);
let val = result.unwrap();
assert!(val.is_vector());
assert_eq!(
val.vector_value().unwrap().as_ref().to_int_vec(),
[Some(8), Some(0), Some(-2)]
);
assert_eq!(val.vector_value().unwrap().logical_rows(), &[0, 1, 2]);
assert_eq!(val.field_type().as_accessor().tp(), FieldTypeTp::LongLong);
} | rust_cleaned_test_functions.jsonl/92664 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 947
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21296,
4907,
658,
9174,
16067,
8744,
368,
341,
394,
11506,
81,
19958,
15246,
34885,
5563,
286,
5168,
15229,
3747,
25,
6959,
52244,
72,
21,
19,
9231,
1464,
5714,
94150,
21897,
21,
19,
2452,
341,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parse_material_set_should_parse_correct_specular_exponents() {
let tests = test_cases();
for test in tests.iter() {
let mut parser = Parser::new(&test.data);
let result = parser.parse_mtlset().unwrap();
for (result_material, expected_material)
in result.materials.iter().zip(test.expected.materials.iter()) {
assert_eq!(result_material.specular_exponent, expected_material.specular_exponent);
}
}
} | rust_cleaned_test_functions.jsonl/53123 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 204
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
33884,
2602,
43378,
21039,
31550,
13594,
1276,
2702,
2700,
368,
341,
262,
1077,
7032,
284,
1273,
41427,
1428,
262,
369,
1273,
304,
7032,
19471,
368,
341,
286,
1077,
5206,
6729,
284,
21102,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_leader_transfer_remove_node() -> Result<()> {
let l = default_logger();
let mut nt = Network::new(vec![None, None, None], &l);
nt.send(vec![new_message(1, 1, MessageType::MsgHup, 0)]);
nt.ignore(MessageType::MsgTimeoutNow);
// The lead_transferee is removed when leadship transferring.
nt.send(vec![new_message(3, 1, MessageType::MsgTransferLeader, 0)]);
assert_eq!(nt.peers[&1].lead_transferee.unwrap(), 3);
nt.peers
.get_mut(&1)
.unwrap()
.apply_conf_change(&remove_node(3))?;
check_leader_transfer_state(&nt.peers[&1], StateRole::Leader, 1);
Ok(())
} | rust_cleaned_test_functions.jsonl/19168 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 282
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
79991,
35403,
18193,
5084,
368,
1464,
5714,
71698,
341,
262,
1077,
326,
284,
1638,
27413,
543,
262,
1077,
5206,
31412,
284,
8141,
486,
931,
25592,
20703,
4064,
11,
2240,
11,
2240,
1125,
609,
75,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_look_at_lh() {
let direction = Vector3::new(1.0, 1.0, 1.0).normalize();
let up = Vector3::unit_y();
let unit_z = Vector3::unit_z();
let look_at = Matrix3x3::look_at_lh(&direction, &up);
let expected = unit_z;
let result = look_at * direction;
assert!(relative_eq!(result, expected, epsilon = 1e-7));
} | rust_cleaned_test_functions.jsonl/129068 | {
"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,
24271,
3752,
907,
71,
368,
341,
286,
1077,
5106,
284,
4196,
18,
486,
931,
7,
16,
13,
15,
11,
220,
16,
13,
15,
11,
220,
16,
13,
15,
568,
30590,
543,
286,
1077,
705,
284,
4196,
18,
486,
38... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_same_size() {
let haystack = "111 a 111b";
let needle = "111 a 1 1b";
search_test!(haystack, needle, None);
} | rust_cleaned_test_functions.jsonl/19387 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 81
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
33574,
2368,
368,
341,
286,
1077,
88447,
284,
330,
16,
16,
16,
264,
220,
16,
16,
16,
65,
876,
286,
1077,
30309,
284,
330,
16,
16,
16,
264,
220,
16,
220,
16,
65,
876,
286,
2711,
4452,
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 |
#[test]
fn test_comment_multi_line_5() {
let code = r#";();"#;
let tokenization_result = tokenize(code);
let tokens = tokenization_result.unwrap();
assert_eq_code_and_tokens_length(code, &tokens);
assert!(tokens.len() == 1);
let token = &tokens[0];
assert!(token.id == TokenId::CommentMultiLine);
assert!(token.index == 0);
assert!(token.length == 4);
} | rust_cleaned_test_functions.jsonl/116456 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 207
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17638,
25133,
6528,
62,
20,
368,
341,
286,
1077,
2038,
284,
435,
2,
5123,
2129,
57676,
401,
286,
1077,
3950,
2022,
5287,
284,
77651,
15842,
317,
286,
1077,
11211,
284,
3950,
2022,
5287,
55395,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_i32() -> Result<()> {
let array = Int32Array::from(vec![1, 2]);
let cmp = build_compare(&array, &array)?;
assert_eq!(Ordering::Less, (cmp)(0, 1));
Ok(())
} | rust_cleaned_test_functions.jsonl/7134 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 111
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5318,
18,
17,
368,
1464,
5714,
71698,
341,
286,
1077,
1334,
284,
1333,
18,
17,
1857,
486,
1499,
25592,
20703,
16,
11,
220,
17,
10149,
286,
1077,
26089,
284,
1936,
32235,
2099,
1653,
11,
609,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_index_data() {
let mut foo = dummy_team("foo");
foo.kind = TeamKind::WorkingGroup;
let data = Data::dummy(vec![foo, dummy_team("bar")]);
let res = data.index_data().unwrap();
assert_eq!(res.teams.len(), 1);
assert_eq!(res.teams[0].url, "teams/bar");
assert_eq!(res.teams[0].team.name, "bar");
assert_eq!(res.wgs.len(), 1);
assert_eq!(res.wgs[0].url, "wgs/foo");
assert_eq!(res.wgs[0].team.name, "foo");
} | rust_cleaned_test_functions.jsonl/33045 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 262
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3560,
1769,
368,
341,
286,
1077,
5206,
15229,
284,
17292,
26532,
445,
7975,
797,
286,
15229,
36632,
284,
7909,
10629,
486,
33978,
2808,
280,
286,
1077,
821,
284,
2885,
486,
31390,
25592,
20703,
79... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_clear_ip_cache() {
let keypair = Keypair::new();
let mut drone = Drone::new(keypair, None, None);
let ip = "127.0.0.1".parse().expect("create IpAddr from string");
assert_eq!(drone.ip_cache.len(), 0);
drone.add_ip_to_cache(ip);
assert_eq!(drone.ip_cache.len(), 1);
drone.clear_ip_cache();
assert_eq!(drone.ip_cache.len(), 0);
assert!(drone.ip_cache.is_empty());
} | rust_cleaned_test_functions.jsonl/123513 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 229
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21811,
10385,
11529,
368,
341,
286,
1077,
1376,
12670,
284,
6569,
1082,
1310,
486,
931,
543,
286,
1077,
5206,
26713,
284,
73481,
486,
931,
4857,
12670,
11,
2240,
11,
2240,
317,
286,
1077,
5997,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_get_block_with_depth_commitment() {
// Build BlockCommitmentCache with votes at depths 0 and 1 for 2 slots
let mut cache0 = BlockCommitment::default();
cache0.increase_confirmation_stake(1, 15);
cache0.increase_confirmation_stake(2, 25);
let mut cache1 = BlockCommitment::default();
cache1.increase_confirmation_stake(1, 10);
cache1.increase_confirmation_stake(2, 20);
let mut block_commitment = HashMap::new();
block_commitment.entry(0).or_insert(cache0.clone());
block_commitment.entry(1).or_insert(cache1.clone());
let block_commitment_cache = BlockCommitmentCache::new(block_commitment, 50);
// Neither slot has rooted votes
assert_eq!(
block_commitment_cache.get_rooted_block_with_commitment(0.1),
None
);
// Neither slot meets the minimum level of commitment 0.6 at depth 1
assert_eq!(
block_commitment_cache.get_block_with_depth_commitment(1, 0.6),
None
);
// Only slot 0 meets the minimum level of commitment 0.5 at depth 1
assert_eq!(
block_commitment_cache.get_block_with_depth_commitment(1, 0.5),
Some(0)
);
assert_eq!(
block_commitment_cache.get_block_with_depth_commitment(1, 0.4),
Some(1)
);
assert_eq!(
block_commitment_cache.get_block_with_depth_commitment(0, 0.6),
Some(1)
);
// Neither slot meets the minimum level of commitment 0.9 at depth 0
assert_eq!(
block_commitment_cache.get_block_with_depth_commitment(0, 0.9),
None
);
} | rust_cleaned_test_functions.jsonl/65256 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 831
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
7113,
6615,
19061,
36346,
478,
368,
341,
286,
442,
7854,
8362,
33441,
478,
8233,
448,
12684,
518,
42857,
220,
15,
323,
220,
16,
369,
220,
17,
15711,
198,
286,
1077,
5206,
6500,
15,
284,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_wifi() {
let dev = LinuxIPLinkInterface {
ifname: "wlp3s0".to_string(),
link_type: "ether".to_string(),
operstate: OperState::UP,
flags: vec![],
};
assert![WifiLinuxIPLinkInterface::try_from(dev.clone()).is_ok()];
assert![!WiredLinuxIPLinkInterface::try_from(dev).is_ok()];
} | rust_cleaned_test_functions.jsonl/33475 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 197
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
71495,
368,
341,
286,
1077,
3483,
284,
14340,
40,
2916,
766,
5051,
341,
310,
421,
606,
25,
330,
86,
13545,
18,
82,
15,
3263,
983,
3904,
3148,
310,
2656,
1819,
25,
330,
2723,
3263,
983,
3904,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_eq() {
let mut n: ImmutSList<u8> = list_from(&[]);
let mut m = list_from(&[]);
assert!(n == m);
n = n.append(1);
assert!(n != m);
m = m.append(1);
assert!(n == m);
let n = list_from(&[2,3,4]);
let m = list_from(&[1,2,3]);
assert!(n != m);
} | rust_cleaned_test_functions.jsonl/64464 | {
"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,
10714,
368,
341,
286,
1077,
5206,
308,
25,
2362,
6984,
50,
852,
34837,
23,
29,
284,
1140,
5673,
2099,
56703,
286,
1077,
5206,
296,
284,
1140,
5673,
2099,
56703,
286,
2060,
10297,
77,
621,
296,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_woff2_transformed_hmtx_table() {
with_woff2_hmtx_table("tests/fonts/woff2/roundtrip-hmtx-lsb-001.woff2", |hmtx| {
// The expected values were determined as follows:
// then examining the TTX file:
// <hmtx>
// <mtx name=".notdef" width="4708" lsb="0"/>
// <mtx name="space" width="4719" lsb="0"/>
// <mtx name="F" width="1536" lsb="205"/>
// <mtx name="P" width="1536" lsb="205"/>
// </hmtx>
// woff2_decompress is part of https://github.com/google/woff2
let expected = vec![
LongHorMetric {
advance_width: 4708,
lsb: 0,
},
LongHorMetric {
advance_width: 4719,
lsb: 0,
},
LongHorMetric {
advance_width: 1536,
lsb: 205,
},
LongHorMetric {
advance_width: 1536,
lsb: 205,
},
];
let h_metrics: Vec<_> = hmtx.h_metrics.iter().collect();
let left_side_bearings: Vec<_> = hmtx.left_side_bearings.iter().collect();
assert_eq!(h_metrics, expected);
assert_eq!(left_side_bearings, vec![0, 0, 205, 205]);
});
} | rust_cleaned_test_functions.jsonl/40132 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 749
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
68585,
17,
18449,
291,
1523,
90310,
5237,
368,
341,
262,
448,
62,
68585,
17,
1523,
90310,
5237,
445,
23841,
60667,
14,
68585,
17,
14,
1049,
32981,
2832,
90310,
2852,
16892,
12,
15,
15,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_first_1() {
let elem: Element = XML.parse().unwrap();
let sub1 = super::find_subnodes(&elem, "Containers");
assert_eq!(1, sub1.len());
let sub2 = super::find_subnodes(&sub1[0], "Container");
assert_eq!(2, sub2.len());
} | rust_cleaned_test_functions.jsonl/124948 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 140
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12978,
62,
16,
368,
341,
286,
1077,
11750,
25,
8543,
284,
11874,
4632,
1005,
15454,
1428,
286,
1077,
1186,
16,
284,
2256,
486,
3903,
5228,
20008,
2099,
18871,
11,
330,
74632,
797,
286,
2060,
107... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_drain_size_hint() {
let mut list = VecList::new();
list.push_back(0);
list.push_back(1);
list.push_back(-1);
list.push_back(2);
list.push_back(-2);
let mut drain = list.drain();
assert_eq!(drain.size_hint(), (5, Some(5)));
drain.next();
assert_eq!(drain.size_hint(), (4, Some(4)));
drain.next();
assert_eq!(drain.size_hint(), (3, Some(3)));
drain.next();
assert_eq!(drain.size_hint(), (2, Some(2)));
drain.next();
assert_eq!(drain.size_hint(), (1, Some(1)));
drain.next();
assert_eq!(drain.size_hint(), (0, Some(0)));
} | rust_cleaned_test_functions.jsonl/11489 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 376
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26680,
466,
2368,
45825,
368,
341,
286,
1077,
5206,
1140,
284,
11312,
852,
486,
931,
543,
286,
1140,
2552,
3895,
7,
15,
317,
286,
1140,
2552,
3895,
7,
16,
317,
286,
1140,
2552,
3895,
4080,
16,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_fq_negate() {
{
let mut a = Fq::zero();
a.negate();
assert!(a.is_zero());
}
let mut rng = XorShiftRng::from_seed([
0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06,
0xbc, 0xe5,
]);
for _ in 0..1000 {
let mut a = Fq::random(&mut rng);
let mut b = a;
b.negate();
a.add_assign(&b);
assert!(a.is_zero());
}
} | rust_cleaned_test_functions.jsonl/2330 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 366
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
761,
80,
28209,
349,
368,
341,
286,
341,
310,
1077,
5206,
264,
284,
434,
80,
486,
14154,
543,
310,
264,
79219,
349,
1428,
310,
2060,
10297,
64,
2079,
19359,
1423,
286,
555,
286,
1077,
5206,
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... | 2 |
#[test]
fn test_error_record() {
let expected = vec![
1, 0, 0, 0, 255, 255, 255, 255, 10, 0, 0, 0, 69, 114, 114, 111, 114, 32,
32, 32,
];
let err_record = ErrorRecord {
promise_id: 1,
arg: -1,
error_code: 10,
error_message: "Error".to_string().as_bytes().to_owned(),
};
let buf: Buf = err_record.into();
assert_eq!(buf, expected.into_boxed_slice());
} | rust_cleaned_test_functions.jsonl/97340 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 177
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4096,
14192,
368,
341,
220,
1077,
3601,
284,
7486,
90515,
262,
220,
16,
11,
220,
15,
11,
220,
15,
11,
220,
15,
11,
220,
17,
20,
20,
11,
220,
17,
20,
20,
11,
220,
17,
20,
20,
11,
220,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_keywords_in_match_arm() {
check(
r#"
fn quux() -> i32 {
match () { () => $0 }
}
"#,
expect![[r#"
kw match
kw while
kw while let
kw loop
kw if
kw if let
kw for
kw unsafe
kw return
"#]],
);
} | rust_cleaned_test_functions.jsonl/17380 | {
"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,
51354,
1243,
10708,
34680,
368,
341,
286,
1779,
1006,
310,
435,
2,
698,
8822,
922,
2200,
368,
1464,
600,
18,
17,
341,
262,
2432,
1719,
314,
1719,
589,
400,
15,
456,
532,
57676,
345,
310,
1720,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_gc_purged_slot() {
let key = Keypair::new();
let index = AccountsIndex::<bool>::default_for_tests();
let mut gc = Vec::new();
index.upsert(
0,
&key.pubkey(),
&Pubkey::default(),
&[],
&AccountSecondaryIndexes::default(),
true,
&mut gc,
UPSERT_PREVIOUS_SLOT_ENTRY_WAS_CACHED_FALSE,
);
assert!(gc.is_empty());
index.upsert(
1,
&key.pubkey(),
&Pubkey::default(),
&[],
&AccountSecondaryIndexes::default(),
false,
&mut gc,
UPSERT_PREVIOUS_SLOT_ENTRY_WAS_CACHED_FALSE,
);
index.upsert(
2,
&key.pubkey(),
&Pubkey::default(),
&[],
&AccountSecondaryIndexes::default(),
true,
&mut gc,
UPSERT_PREVIOUS_SLOT_ENTRY_WAS_CACHED_FALSE,
);
index.upsert(
3,
&key.pubkey(),
&Pubkey::default(),
&[],
&AccountSecondaryIndexes::default(),
true,
&mut gc,
UPSERT_PREVIOUS_SLOT_ENTRY_WAS_CACHED_FALSE,
);
index.add_root(0, false);
index.add_root(1, false);
index.add_root(3, false);
index.upsert(
4,
&key.pubkey(),
&Pubkey::default(),
&[],
&AccountSecondaryIndexes::default(),
true,
&mut gc,
UPSERT_PREVIOUS_SLOT_ENTRY_WAS_CACHED_FALSE,
);
// previous updates within the same slot
assert_eq!(gc, vec![]);
let (list, idx) = index.get(&key.pubkey(), None, None).unwrap();
assert_eq!(list.slot_list()[idx], (3, true));
let mut num = 0;
let mut found_key = false;
index.unchecked_scan_accounts(
"",
&Ancestors::default(),
|pubkey, _index| {
if pubkey == &key.pubkey() {
found_key = true;
assert_eq!(_index, (&true, 3));
};
num += 1
},
COLLECT_ALL_UNSORTED_FALSE,
);
assert_eq!(num, 1);
assert!(found_key);
} | rust_cleaned_test_functions.jsonl/99734 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1431
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8882,
49423,
620,
324,
3556,
27563,
368,
341,
286,
1077,
1376,
284,
6569,
1082,
1310,
486,
931,
543,
286,
1077,
1922,
284,
40655,
1552,
27638,
2641,
6831,
2258,
5478,
32509,
543,
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... | 2 |
#[test]
fn test_parse_currency_prefix() {
use Currency;
assert_eq!("bc".parse::<Currency>(), Ok(Currency::Bitcoin));
assert_eq!("tb".parse::<Currency>(), Ok(Currency::BitcoinTestnet));
assert_eq!("bcrt".parse::<Currency>(), Ok(Currency::Regtest));
assert_eq!("sb".parse::<Currency>(), Ok(Currency::Simnet));
assert_eq!("tbs".parse::<Currency>(), Ok(Currency::Signet));
assert_eq!("something_else".parse::<Currency>(), Err(ParseError::UnknownCurrency))
} | rust_cleaned_test_functions.jsonl/123242 | {
"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,
21039,
34710,
13974,
368,
341,
197,
41819,
28453,
401,
197,
6948,
10714,
17223,
8904,
3263,
6400,
27638,
26321,
39019,
7622,
3025,
5088,
486,
48287,
1106,
197,
6948,
10714,
17223,
18387,
3263,
6400,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_iterations_without_errors() {
let it: PageIterator<u64, u64> = PageIterator::new(
Box::new(|key, limit| {
let start = key.unwrap_or(0);
Ok(Page {
items: (start..start + limit).collect(),
next_page_key: if start + limit >= 20 {
None
} else {
Some(start + limit)
},
})
}),
10,
);
let mut it_counter = 0;
for element in it {
element.unwrap();
it_counter += 1;
}
assert_eq!(20, it_counter);
} | rust_cleaned_test_functions.jsonl/114314 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 432
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
55607,
39904,
20196,
368,
341,
286,
1077,
432,
25,
5755,
11951,
34837,
21,
19,
11,
575,
21,
19,
29,
284,
5755,
11951,
486,
931,
1006,
310,
8261,
486,
931,
22428,
792,
11,
3930,
91,
341,
394,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_iterator_rev_nth() {
let v: &[_] = &[0, 1, 2, 3, 4];
for i in 0..v.len() {
assert_eq!(v.iter().rev().nth(i).unwrap(), &v[v.len() - 1 - i]);
}
assert_eq!(v.iter().rev().nth(v.len()), None);
} | rust_cleaned_test_functions.jsonl/54112 | {
"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,
13491,
38082,
78342,
368,
341,
262,
1077,
348,
25,
609,
13496,
60,
284,
44590,
15,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
935,
262,
369,
600,
304,
220,
15,
496,
85,
19406,
368... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_write_headers_orig_case_empty_value() {
let mut headers = HeaderMap::new();
let name = http::header::HeaderName::from_static("x-empty");
headers.insert(&name, "".parse().expect("parse empty"));
let mut orig_cases = HeaderCaseMap::default();
orig_cases.insert(name, Bytes::from_static(b"X-EmptY"));
let mut dst = Vec::new();
super::write_headers_original_case(&headers, &orig_cases, &mut dst, false);
assert_eq!(
dst, b"X-EmptY:\r\n",
"there should be no space between the colon and CRLF"
);
} | rust_cleaned_test_functions.jsonl/7674 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 273
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9165,
26719,
35328,
19096,
15124,
3142,
368,
341,
286,
1077,
5206,
7102,
284,
12104,
2227,
486,
931,
543,
286,
1077,
829,
284,
1758,
486,
2708,
486,
4047,
675,
486,
1499,
25360,
445,
87,
39433,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_bad_slice() {
let s = Secp256k1::new();
assert_eq!(Signature::from_der(&s, &[0; constants::MAX_SIGNATURE_SIZE + 1]),
Err(InvalidSignature));
assert_eq!(Signature::from_der(&s, &[0; constants::MAX_SIGNATURE_SIZE]),
Err(InvalidSignature));
assert_eq!(Message::from_slice(&[0; constants::MESSAGE_SIZE - 1]),
Err(InvalidMessage));
assert_eq!(Message::from_slice(&[0; constants::MESSAGE_SIZE + 1]),
Err(InvalidMessage));
assert!(Message::from_slice(&[0; constants::MESSAGE_SIZE]).is_ok());
} | rust_cleaned_test_functions.jsonl/13556 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 312
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34199,
26488,
368,
341,
286,
1077,
274,
284,
4520,
79,
17,
20,
21,
74,
16,
486,
931,
543,
286,
2060,
10714,
10297,
25088,
486,
1499,
35345,
2099,
82,
11,
44590,
15,
26,
18021,
486,
10586,
7375... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_index_sequences() {
let reader = IndexedReader::new(io::Cursor::new(FASTA_FILE), FAI_FILE).unwrap();
let sequences = reader.index.sequences();
assert_eq!(sequences.len(), 2);
assert_eq!(
sequences[0],
Sequence {
name: "id".into(),
len: 52,
}
);
assert_eq!(
sequences[1],
Sequence {
name: "id2".into(),
len: 40,
}
);
} | rust_cleaned_test_functions.jsonl/62828 | {
"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,
3560,
58732,
368,
341,
286,
1077,
6604,
284,
8008,
17120,
486,
931,
37258,
486,
14543,
486,
931,
7,
59206,
32,
8087,
701,
15008,
40,
8087,
568,
15454,
1428,
286,
1077,
23700,
284,
6604,
5154,
45... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_arrow_multi_left() {
let text = "And It tilted Its vanes and ennobled Its spires ->";
let text: Vec<_> = text.split_whitespace().collect();
let (a, b) = parse_arrow(&text).unwrap();
assert_eq!(a, &text[..text.len() - 1]);
assert!(b.is_empty());
} | rust_cleaned_test_functions.jsonl/65979 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 147
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
46566,
25133,
9579,
368,
341,
286,
1077,
1467,
284,
330,
3036,
1084,
85917,
11445,
5242,
288,
323,
662,
55023,
832,
11445,
978,
3861,
1464,
876,
286,
1077,
1467,
25,
11312,
32399,
29,
284,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_build_request_json() {
let test_request = RpcRequest::GetAccountInfo;
let request = test_request.build_request_json(
1,
Some(json!("deadbeefXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNHhx")),
);
assert_eq!(request["method"], "getAccountInfo");
assert_eq!(
request["params"],
json!(vec!["deadbeefXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNHhx"])
);
let test_request = RpcRequest::GetBalance;
let request = test_request.build_request_json(
1,
Some(json!("deadbeefXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNHhx")),
);
assert_eq!(request["method"], "getBalance");
let test_request = RpcRequest::GetFinality;
let request = test_request.build_request_json(1, None);
assert_eq!(request["method"], "getFinality");
assert_eq!(request["params"], json!(null));
let test_request = RpcRequest::GetLastId;
let request = test_request.build_request_json(1, None);
assert_eq!(request["method"], "getLastId");
let test_request = RpcRequest::GetTransactionCount;
let request = test_request.build_request_json(1, None);
assert_eq!(request["method"], "getTransactionCount");
let test_request = RpcRequest::RequestAirdrop;
let request = test_request.build_request_json(1, None);
assert_eq!(request["method"], "requestAirdrop");
let test_request = RpcRequest::SendTransaction;
let request = test_request.build_request_json(1, None);
assert_eq!(request["method"], "sendTransaction");
} | rust_cleaned_test_functions.jsonl/82110 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 746
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20801,
7893,
9455,
368,
341,
286,
1077,
1273,
7893,
284,
79961,
1900,
486,
1949,
7365,
1731,
280,
286,
1077,
1681,
284,
1273,
7893,
13239,
7893,
9455,
1006,
310,
220,
16,
345,
310,
4329,
9304,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_var() -> Result<()> {
let var = Var::new("local".to_string(), Type::null(), Span::null());
let text = as_text(var.clone());
assert!(text.contains("%local"));
Ok(())
} | rust_cleaned_test_functions.jsonl/110961 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 106
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4612,
368,
1464,
5714,
71698,
341,
286,
1077,
762,
284,
8735,
486,
931,
445,
2438,
3263,
983,
3904,
1507,
3990,
486,
2921,
1507,
11903,
486,
2921,
1423,
286,
1077,
1467,
284,
438,
4326,
7537,
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 |
#[test]
fn test_split_with_intersections() {
// This is a reduced test case that was showing a bug where duplicate intersections
// inconsistent state when insert_edge was called.
let mut builder = Path::builder();
builder.begin(point(-21.004179, -71.57515));
builder.line_to(point(-21.927473, -70.94977));
builder.line_to(point(-23.024633, -70.68942));
builder.end(true);
builder.begin(point(16.036617, -27.254852));
builder.line_to(point(-62.83691, -117.69249));
builder.line_to(point(38.646027, -46.973236));
builder.end(true);
let path = builder.build();
test_path(path.as_slice());
} | rust_cleaned_test_functions.jsonl/102417 | {
"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,
17052,
6615,
15318,
24661,
368,
341,
262,
442,
1096,
374,
264,
11046,
1273,
1142,
429,
572,
9027,
264,
9876,
1380,
22513,
64257,
7213,
262,
442,
39140,
1584,
979,
5656,
17932,
572,
2598,
382,
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_exclude_ip_v4_mapped_ip_v6_not_supported() {
let filter = Filter {
exclude_private_ips: true,
exclude_link_local_ips: true,
..Filter::default()
};
assert!(!filter.is_excluded(&website(V6_MAPPED_V4_PRIVATE_CLASS_A)));
assert!(!filter.is_excluded(&website(V6_MAPPED_V4_LINK_LOCAL)));
} | rust_cleaned_test_functions.jsonl/65573 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 210
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
88668,
10385,
2273,
19,
91933,
10385,
2273,
21,
7913,
57885,
368,
341,
286,
1077,
4051,
284,
12339,
341,
310,
21687,
26249,
71074,
25,
830,
345,
310,
21687,
7233,
13564,
71074,
25,
830,
345,
310,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_decode_fps_copy() {
let src = [
11, 12, 13,
21, 22, 23,
31, 32, 33 ];
let expected = [
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 11, 11, 12, 12, 13, 13,
0, 0, 11, 11, 12, 12, 13, 13,
0, 0, 21, 21, 22, 22, 23, 23,
0, 0, 21, 21, 22, 22, 23, 23,
0, 0, 31, 31, 32, 32, 33, 33,
0, 0, 31, 31, 32, 32, 33, 33,
0, 0, 0, 0, 0, 0, 0, 0 ];
const SCREEN_W: usize = 8;
const SCREEN_H: usize = 8;
let mut buf = [0; SCREEN_W * SCREEN_H];
let mut pal = [0; 3 * 256];
let res = decode_fps_copy(&src, 3, 3,
&mut RasterMut::with_offset(2, 1, 6, 6, SCREEN_W, &mut buf, &mut pal));
assert!(res.is_ok());
assert_eq!(&buf[..], &expected[..]);
} | rust_cleaned_test_functions.jsonl/104180 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 525
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15227,
65163,
16096,
368,
341,
286,
1077,
2286,
284,
2278,
310,
220,
16,
16,
11,
220,
16,
17,
11,
220,
16,
18,
345,
310,
220,
17,
16,
11,
220,
17,
17,
11,
220,
17,
18,
345,
310,
220,
18,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_scalar_mul1() {
let base_point = Secp256r1Point::generator();
let int: Secp256r1Scalar = ECScalar::from(&BigInt::from(1));
let test = base_point * int;
assert_eq!(
test.x_coor().unwrap().to_hex(),
"6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296".to_lowercase()
);
assert_eq!(
test.y_coor().unwrap().to_hex(),
"4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5".to_lowercase()
);
} | rust_cleaned_test_functions.jsonl/12367 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 320
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
41652,
24944,
16,
368,
341,
286,
1077,
2331,
6085,
284,
4520,
79,
17,
20,
21,
81,
16,
2609,
486,
35851,
543,
286,
1077,
526,
25,
4520,
79,
17,
20,
21,
81,
16,
20639,
284,
20633,
20639,
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_read_object() {
assert_eq!(from_str("{"), Err(SyntaxError(EOFWhileParsingObject, 1, 2)));
assert_eq!(from_str("{ "), Err(SyntaxError(EOFWhileParsingObject, 1, 3)));
assert_eq!(from_str("{1"), Err(SyntaxError(KeyMustBeAString, 1, 2)));
assert_eq!(from_str("{ \"a\""), Err(SyntaxError(EOFWhileParsingObject, 1, 6)));
assert_eq!(from_str("{\"a\""), Err(SyntaxError(EOFWhileParsingObject, 1, 5)));
assert_eq!(from_str("{\"a\" "), Err(SyntaxError(EOFWhileParsingObject, 1, 6)));
assert_eq!(from_str("{\"a\" 1"), Err(SyntaxError(ExpectedColon, 1, 6)));
assert_eq!(from_str("{\"a\":"), Err(SyntaxError(EOFWhileParsingValue, 1, 6)));
assert_eq!(from_str("{\"a\":1"), Err(SyntaxError(EOFWhileParsingObject, 1, 7)));
assert_eq!(from_str("{\"a\":1 1"), Err(SyntaxError(InvalidSyntax, 1, 8)));
assert_eq!(from_str("{\"a\":1,"), Err(SyntaxError(EOFWhileParsingObject, 1, 8)));
assert_eq!(from_str("{}").unwrap(), mk_object(&[]));
assert_eq!(from_str("{\"a\": 3}").unwrap(),
mk_object(&[("a".into_string(), U64(3))]));
assert_eq!(from_str(
"{ \"a\": null, \"b\" : true }").unwrap(),
mk_object(&[
("a".into_string(), Null),
("b".into_string(), Boolean(true))]));
assert_eq!(from_str("\n{ \"a\": null, \"b\" : true }\n").unwrap(),
mk_object(&[
("a".into_string(), Null),
("b".into_string(), Boolean(true))]));
assert_eq!(from_str(
"{\"a\" : 1.0 ,\"b\": [ true ]}").unwrap(),
mk_object(&[
("a".into_string(), F64(1.0)),
("b".into_string(), Array(vec![Boolean(true)]))
]));
assert_eq!(from_str(
"{\
\"a\": 1.0, \
\"b\": [\
true,\
\"foo\\nbar\", \
{ \"c\": {\"d\": null} } \
]\
}").unwrap(),
mk_object(&[
("a".into_string(), F64(1.0)),
("b".into_string(), Array(vec![
Boolean(true),
String("foo\nbar".into_string()),
mk_object(&[
("c".into_string(), mk_object(&[("d".into_string(), Null)]))
])
]))
]));
} | rust_cleaned_test_functions.jsonl/6552 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1644
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
5314,
368,
341,
286,
2060,
10714,
10297,
1499,
2895,
13976,
3975,
981,
15495,
93549,
1454,
7,
23483,
7983,
68839,
1190,
11,
220,
16,
11,
220,
17,
4945,
286,
2060,
10714,
10297,
1499,
2895,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_remove_aux() {
let mut bam = Reader::from_path(&Path::new("test/test.bam"))
.ok()
.expect("Error opening file.");
for record in bam.records() {
let mut rec = record.expect("Expected valid record");
if rec.aux(b"XS").is_some() {
rec.remove_aux(b"XS");
}
if rec.aux(b"YT").is_some() {
rec.remove_aux(b"YT");
}
rec.remove_aux(b"ab");
assert_eq!(rec.aux(b"XS"), None);
assert_eq!(rec.aux(b"YT"), None);
}
} | rust_cleaned_test_functions.jsonl/34029 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 355
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18193,
30468,
368,
341,
286,
1077,
5206,
41304,
284,
25166,
486,
1499,
2638,
2099,
1820,
486,
931,
445,
1944,
12697,
71804,
5455,
310,
659,
562,
741,
310,
659,
17119,
445,
1454,
8568,
1034,
30458,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_serialize() {
let method = Method::AES128GCM;
let serialized_method = serde_json::to_string(&method).unwrap();
assert_eq!(serialized_method, r#""aes-128-gcm""#);
let method = Method::AES256GCM;
let serialized_method = serde_json::to_string(&method).unwrap();
assert_eq!(serialized_method, r#""aes-256-gcm""#);
let method = Method::ChaCha20IETFPoly1305;
let serialized_method = serde_json::to_string(&method).unwrap();
assert_eq!(serialized_method, r#""chacha20-ietf-poly1305""#);
} | rust_cleaned_test_functions.jsonl/551 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 266
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
88686,
368,
341,
286,
1077,
1714,
284,
6730,
486,
69168,
16,
17,
23,
38,
9985,
280,
286,
1077,
32916,
9032,
284,
61570,
9455,
486,
983,
3904,
2099,
4393,
568,
15454,
543,
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... | 1 |
#[test]
fn test_min_by() {
let xs: &[isize] = &[-3, 0, 1, 5, -10];
assert_eq!(*xs.iter().min_by(|x, y| x.abs().cmp(&y.abs())).unwrap(), 0);
} | rust_cleaned_test_functions.jsonl/25938 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 87
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7260,
3710,
368,
341,
262,
1077,
11943,
25,
44590,
285,
551,
60,
284,
609,
7609,
18,
11,
220,
15,
11,
220,
16,
11,
220,
20,
11,
481,
16,
15,
935,
262,
2060,
10714,
0,
4071,
18561,
19471,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_vec3_cmp() {
assert!(!Vec3Mask::default().any());
assert!(!Vec3Mask::default().all());
assert_eq!(Vec3Mask::default().bitmask(), 0x0);
let a = vec3(-1.0, -1.0, -1.0);
let b = vec3(1.0, 1.0, 1.0);
let c = vec3(-1.0, -1.0, 1.0);
let d = vec3(1.0, -1.0, -1.0);
assert_eq!(a.cmplt(a).bitmask(), 0x0);
assert_eq!(a.cmplt(b).bitmask(), 0x7);
assert_eq!(a.cmplt(c).bitmask(), 0x4);
assert_eq!(c.cmple(a).bitmask(), 0x3);
assert_eq!(a.cmplt(d).bitmask(), 0x1);
assert!(a.cmplt(b).all());
assert!(a.cmplt(c).any());
assert!(a.cmple(b).all());
assert!(a.cmple(a).all());
assert!(b.cmpgt(a).all());
assert!(b.cmpge(a).all());
assert!(b.cmpge(b).all());
assert!(!(a.cmpge(c).all()));
assert!(c.cmple(c).all());
assert!(c.cmpge(c).all());
} | rust_cleaned_test_functions.jsonl/48591 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 456
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13251,
18,
35193,
368,
341,
262,
2060,
0,
3471,
10050,
18,
12686,
486,
2258,
1005,
3767,
1423,
262,
2060,
0,
3471,
10050,
18,
12686,
486,
2258,
1005,
541,
1423,
262,
2060,
10714,
10297,
10050,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_swap_front_back_remove() {
fn test(back: bool) {
let mut tester = FixedVecDeque::<[usize; 16]>::new();
let usable_cap = tester.capacity();
let final_len = usable_cap / 2;
for len in 0..final_len {
let expected: FixedVecDeque<[usize; 16]> = if back {
(0..len).collect()
} else {
(0..len).rev().collect()
};
for tail_pos in 0..usable_cap {
tester.head = tail_pos;
tester.len = 0;
if back {
for i in 0..len * 2 {
*tester.push_front() = i;
}
for i in 0..len {
assert_eq!(tester.swap_remove_back(i), Some(&mut (len * 2 - 1 - i)));
}
} else {
for i in 0..len * 2 {
*tester.push_back() = i;
}
for i in 0..len {
let idx = tester.len() - 1 - i;
assert_eq!(tester.swap_remove_front(idx), Some(&mut (len * 2 - 1 - i)));
}
}
assert_eq!(tester, expected);
}
}
}
test(true);
test(false);
} | rust_cleaned_test_functions.jsonl/3290 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 981
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
40991,
22926,
3895,
18193,
368,
341,
286,
5168,
1273,
58092,
25,
1807,
8,
341,
310,
1077,
5206,
37111,
284,
20149,
10050,
73891,
27638,
58,
51878,
26,
220,
16,
21,
60,
6831,
931,
543,
310,
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... | 9 |
#[test]
fn test_timetz() {
// TIMETZ - 15:12:34-05
assert_eq!(
[0xd0u8, 0x97, 0x01, 0x80, 0xf0, 0x79, 0xf0, 0x10],
_timetz(15, 12, 34, -5).to_le_bytes()
)
} | rust_cleaned_test_functions.jsonl/13421 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 143
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
29087,
42189,
368,
341,
286,
442,
17742,
1348,
57,
481,
220,
16,
20,
25,
16,
17,
25,
18,
19,
12,
15,
20,
198,
286,
2060,
10714,
33673,
310,
508,
15,
9703,
15,
84,
23,
11,
220,
15,
87,
24... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.