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_is_diagnosable() {
let mut document_cache = DocumentCache::default();
let specifier = resolve_url("file:///a/file.ts").unwrap();
assert!(!document_cache.is_diagnosable(&specifier));
document_cache.open(
specifier.clone(),
1,
LanguageId::TypeScript,
"console.log(\"hello world\");\n",
);
assert!(document_cache.is_diagnosable(&specifier));
let specifier =
resolve_url("asset:///lib.es2015.symbol.wellknown.d.ts").unwrap();
assert!(document_cache.is_diagnosable(&specifier));
let specifier = resolve_url("data:application/typescript;base64,ZXhwb3J0IGNvbnN0IGEgPSAiYSI7CgpleHBvcnQgZW51bSBBIHsKICBBLAogIEIsCiAgQywKfQo=").unwrap();
assert!(document_cache.is_diagnosable(&specifier));
let specifier = resolve_url("data:application/json;base64,ZXhwb3J0IGNvbnN0IGEgPSAiYSI7CgpleHBvcnQgZW51bSBBIHsKICBBLAogIEIsCiAgQywKfQo=").unwrap();
assert!(!document_cache.is_diagnosable(&specifier));
} | rust_cleaned_test_functions.jsonl/56716 | {
"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,
6892,
29477,
3246,
436,
480,
368,
341,
262,
1077,
5206,
2197,
11529,
284,
11789,
8233,
486,
2258,
543,
262,
1077,
97616,
284,
8830,
2903,
445,
1192,
60896,
64,
23903,
21288,
1827,
15454,
543,
262,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_insert_into_inline_table() {
given(r#"
a = {a=2, c = 3}
b = {}"#
).running(|root| {
{
let a = root.entry("a");
let a = as_inline_table!(a);
assert_eq!(a.len(), 2);
assert!(a.contains_key("a") && a.get("c").is_some());
a.get_or_insert("b", 42);
assert_eq!(a.len(), 3);
a.fmt();
}
let b = root.entry("b");
let b = as_inline_table!(b);
assert!(b.is_empty());
b.get_or_insert("'hello'", "world");
assert_eq!(b.len(), 1);
b.fmt()
}).produces(r#"
a = { a = 2, c = 3, b = 42 }
b = { 'hello' = "world" }
"#
);
} | rust_cleaned_test_functions.jsonl/36887 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 434
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17678,
45514,
41871,
5237,
368,
341,
262,
2661,
2601,
2,
698,
286,
264,
284,
314,
64,
28,
17,
11,
220,
272,
284,
220,
18,
532,
286,
293,
284,
4687,
1,
4956,
262,
7457,
27173,
22428,
2888,
91... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_output_csv() {
let resource_input = "./resources/testing/valid_assessments.csv";
let tmp_file = assert_fs::NamedTempFile::new("outfile.csv").unwrap();
let export = Export {
from: resource_input.into(),
to: tmp_file.path().into(),
format: OutputFormat::Csv,
};
export.exec().unwrap();
let reviews: Vec<AdvisorReview> = csv::load_data_from_csv::<_, b','>(&tmp_file).unwrap();
assert_eq!(reviews.len(), 1);
} | rust_cleaned_test_functions.jsonl/96734 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 245
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7645,
14020,
368,
341,
286,
1077,
5101,
5898,
284,
5924,
12745,
28801,
14,
1891,
12083,
433,
1368,
11219,
876,
286,
1077,
4174,
2458,
284,
2060,
34470,
486,
15810,
12151,
1703,
486,
931,
445,
5962... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_mut() {
let mut point = Point3::new(1.0, -4.0, 12.0);
point[0] *= 2.0;
point[1] /= -2.0;
point[2] -= 2.0;
assert_approx_eq!(point[0], 2.0);
assert_approx_eq!(point[1], 2.0);
assert_approx_eq!(point[2], 10.0);
} | rust_cleaned_test_functions.jsonl/131711 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 180
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3560,
29523,
368,
341,
286,
1077,
5206,
1459,
284,
5126,
18,
486,
931,
7,
16,
13,
15,
11,
481,
19,
13,
15,
11,
220,
16,
17,
13,
15,
626,
286,
1459,
58,
15,
60,
11404,
220,
17,
13,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_no_panic_on_format_snippet_and_format_code_block() {
// even when we cannot parse the given snippet.
let snippet = "let";
assert!(format_snippet(snippet, &Config::default()).is_none());
assert!(format_code_block(snippet, &Config::default()).is_none());
} | rust_cleaned_test_functions.jsonl/18556 | {
"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,
6536,
620,
31270,
4470,
8955,
28022,
21581,
8378,
8955,
4136,
7113,
368,
341,
1789,
286,
442,
1496,
979,
582,
4157,
4715,
279,
2661,
43065,
624,
286,
1077,
43065,
284,
330,
1149,
876,
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_function_call_expression_two_args() {
assert_expression!(
"CheckProperty(42, \"age\")",
Expression::func(
"CheckProperty",
vec![42.as_lit_expr(1, 21), "age".as_lit_expr(1, 25)]
)
);
} | rust_cleaned_test_functions.jsonl/102647 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 200
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9174,
13429,
28068,
23241,
8384,
368,
341,
310,
2060,
28068,
33673,
394,
330,
3973,
3052,
7,
19,
17,
11,
7245,
424,
62705,
756,
394,
16378,
486,
2830,
1006,
503,
330,
3973,
3052,
756,
503,
7486,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_match_pattern_hashtag_list_inside_tuple()
{
let mut t = Inferator::new("burritos");
let tvar =
Type::Tuple(Struple(vec![(None, Type::Var(Lstr::Sref("Taco")))]));
let ilistpatt = list::cons(
Val::Hashtag(Lstr::Sref("leema")),
Val::Id(Lstr::Sref("tail")),
);
let listpatt = Val::Tuple(Struple(vec![(None, ilistpatt)]));
let ts = TypeSet::new();
t.match_pattern(&ts, &listpatt, &tvar, 14).unwrap();
let exp = Type::Tuple(Struple(vec![(
None,
Type::StrictList(Box::new(Type::Hashtag)),
)]));
assert_eq!(exp, t.inferred_type(&tvar));
} | rust_cleaned_test_functions.jsonl/15075 | {
"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,
10708,
21260,
21778,
34311,
2019,
72860,
21773,
741,
262,
341,
286,
1077,
5206,
259,
284,
62658,
850,
486,
931,
445,
11240,
94012,
797,
286,
1077,
259,
947,
4035,
310,
3990,
486,
28681,
92084,
606... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_convert_predicate_empty() {
let rpc_predicate = RPCPredicate { root: None };
let res = PredicateBuilder::default().rpc_predicate(Some(rpc_predicate));
let expected_error = "Unexpected empty predicate: Node";
let actual_error = res.unwrap_err().to_string();
assert!(
actual_error.contains(expected_error),
"expected '{}' not found in '{}'",
expected_error,
actual_error
);
} | rust_cleaned_test_functions.jsonl/79152 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 227
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34910,
97474,
15124,
368,
341,
286,
1077,
35596,
97474,
284,
34008,
36329,
314,
3704,
25,
2240,
3634,
286,
1077,
592,
284,
49827,
3297,
486,
2258,
1005,
29414,
97474,
65405,
2601,
3992,
97474,
3237,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_extract_address_hash_scriptsig() {
let raw_tx = "0100000001c15041a06deb6b3818b022fac558da4ce2097f0860c8f642105bbad9d29be02a010000006c493046022100cfd2a2d332b29adce119c55a9fadd3c073332024b7e272513e51623ca15993480221009b482d7f7b4d479aff62bdcdaea54667737d56f8d4d63dd03ec3ef651ed9a25401210325f8b039a11861659c9bf03f43fc4ea055f3a71cd60c7b1fd474ab578f9977faffffffff0290d94000000000001976a9148ed243a7be26080a1a8cf96b53270665f1b8dd2388ac4083086b000000001976a9147e7d94d0ddc21d83bfbcfc7798e4547edf0832aa88ac00000000";
let tx_bytes = hex::decode(&raw_tx).unwrap();
let transaction = parse_transaction(&tx_bytes).unwrap();
let address = Address::P2PKH(H160([
126, 125, 148, 208, 221, 194, 29, 131, 191, 188, 252, 119, 152, 228, 84, 126, 223, 8, 50, 170,
]));
let extr_address = extract_address_hash_scriptsig(&transaction.inputs[0].script).unwrap();
assert_eq!(&extr_address, &address);
} | rust_cleaned_test_functions.jsonl/132199 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 475
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39123,
6744,
8950,
14660,
21339,
368,
341,
286,
1077,
7112,
17805,
284,
330,
15,
16,
15,
15,
15,
15,
15,
15,
15,
16,
66,
16,
20,
15,
19,
16,
64,
15,
21,
37935,
21,
65,
18,
23,
16,
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_collect_accounts() {
let keypair0 = Keypair::new();
let keypair1 = Keypair::new();
let pubkey = Pubkey::new_rand();
let instructions = vec![CompiledInstruction::new(2, &(), vec![0, 1])];
let message = Message::new_with_compiled_instructions(
1,
0,
2,
vec![keypair0.pubkey(), pubkey, native_loader::id()],
Hash::default(),
instructions,
);
let tx0 = Transaction::new(&[&keypair0], message, Hash::default());
let instructions = vec![CompiledInstruction::new(2, &(), vec![0, 1])];
let message = Message::new_with_compiled_instructions(
1,
0,
2,
vec![keypair1.pubkey(), pubkey, native_loader::id()],
Hash::default(),
instructions,
);
let tx1 = Transaction::new(&[&keypair1], message, Hash::default());
let txs = vec![tx0, tx1];
let loaders = vec![Ok(()), Ok(())];
let account0 = Account::new(1, 0, &Pubkey::default());
let account1 = Account::new(2, 0, &Pubkey::default());
let account2 = Account::new(3, 0, &Pubkey::default());
let instruction_accounts0 = vec![account0, account2.clone()];
let instruction_loaders0 = vec![];
let instruction_credits0 = vec![0, 2];
let loaded0 = Ok((
instruction_accounts0,
instruction_loaders0,
instruction_credits0,
));
let instruction_accounts1 = vec![account1, account2.clone()];
let instruction_loaders1 = vec![];
let instruction_credits1 = vec![0, 3];
let loaded1 = Ok((
instruction_accounts1,
instruction_loaders1,
instruction_credits1,
));
let mut loaded = vec![loaded0, loaded1];
let accounts = Accounts::new(None);
{
let mut credit_only_locks = accounts.credit_only_account_locks.write().unwrap();
let credit_only_locks = credit_only_locks.as_mut().unwrap();
credit_only_locks.insert(
pubkey,
CreditOnlyLock {
credits: AtomicU64::new(0),
lock_count: Mutex::new(1),
},
);
}
let collected_accounts = accounts.collect_accounts(&txs, &loaders, &mut loaded);
assert_eq!(collected_accounts.len(), 3);
assert!(collected_accounts.contains_key(&keypair0.pubkey()));
assert!(collected_accounts.contains_key(&keypair1.pubkey()));
assert!(collected_accounts.contains_key(&pubkey));
let credit_debit_account0 = collected_accounts.get(&keypair0.pubkey()).unwrap();
assert_eq!(credit_debit_account0.1, true);
let credit_debit_account1 = collected_accounts.get(&keypair1.pubkey()).unwrap();
assert_eq!(credit_debit_account1.1, true);
let credit_only_account = collected_accounts.get(&pubkey).unwrap();
assert_eq!(credit_only_account.1, false);
// Ensure credit_only_lock reflects credits from both accounts: 2 + 3 = 5
let credit_only_locks = accounts.credit_only_account_locks.read().unwrap();
let credit_only_locks = credit_only_locks.as_ref().unwrap();
assert_eq!(
credit_only_locks
.get(&pubkey)
.unwrap()
.credits
.load(Ordering::Relaxed),
5
);
} | rust_cleaned_test_functions.jsonl/104356 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1695
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
68140,
55665,
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,
95116,
284,
22611,
792,
486... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_is_normal() {
let a = Complex::new(0f64, f64::NAN);
let b = Complex::new(2f64, f64::INFINITY);
assert!(!a.is_normal());
assert!(!b.is_normal());
assert!(_1_1i.is_normal());
} | rust_cleaned_test_functions.jsonl/105668 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 131
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6892,
13973,
368,
341,
286,
1077,
264,
284,
22096,
486,
931,
7,
15,
69,
21,
19,
11,
282,
21,
19,
486,
45,
1093,
317,
286,
1077,
293,
284,
22096,
486,
931,
7,
17,
69,
21,
19,
11,
282,
21,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_consensus_serialization() {
let example_key = TendermintKey::ConsensusKey(
PublicKey::from_raw_ed25519(&hex::decode_upper(EXAMPLE_CONSENSUS_KEY).unwrap())
.unwrap(),
);
assert_eq!(
example_key.to_bech32("cosmosvalconspub"),
"cosmosvalconspub1zcjduepqfgjuveq2raetnjt4xwpffm63kmguxv2chdhvhf5lhslmtgeunh8qmf7exk"
);
} | rust_cleaned_test_functions.jsonl/31558 | {
"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,
31971,
13626,
25602,
2022,
368,
341,
286,
1077,
3110,
3097,
284,
93867,
67791,
1592,
486,
15220,
13626,
1592,
1006,
310,
70280,
486,
1499,
16067,
32370,
17,
20,
20,
16,
24,
2099,
17308,
486,
18196... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_part1() {
let input = include_str!("../tests.txt");
let (numbers, mut boards) = crate::parse(input);
assert_eq!(4512, part1(&numbers, &mut boards));
} | rust_cleaned_test_functions.jsonl/3402 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 93
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10495,
16,
368,
341,
286,
1077,
1946,
284,
2924,
2895,
17223,
1244,
23841,
3909,
797,
286,
1077,
320,
37378,
11,
5206,
20490,
8,
284,
17717,
486,
6400,
5384,
626,
286,
2060,
10714,
10297,
19,
20... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_partition_checkpoint() {
let pckpt = part_ckpt!("table_1", "partition_1", {1 => (10, 20), 2 => (5, 15)});
assert_eq!(pckpt.table_name(), "table_1");
assert_eq!(pckpt.partition_key(), "partition_1");
assert_eq!(
pckpt.sequencer_numbers(1).unwrap(),
MinMaxSequence { min: 10, max: 20 }
);
assert_eq!(
pckpt.sequencer_numbers(2).unwrap(),
MinMaxSequence { min: 5, max: 15 }
);
assert!(pckpt.sequencer_numbers(3).is_none());
assert_eq!(pckpt.sequencer_ids(), vec![1, 2]);
assert_eq!(
pckpt,
part_ckpt!("table_1", "partition_1", {1 => (10, 20), 2 => (5, 15)})
);
} | rust_cleaned_test_functions.jsonl/6750 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 411
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
43840,
55208,
368,
341,
286,
1077,
281,
68175,
284,
949,
62,
68175,
17223,
2005,
62,
16,
497,
330,
40998,
62,
16,
497,
314,
16,
589,
320,
16,
15,
11,
220,
17,
15,
701,
220,
17,
589,
320,
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_poh_recorder_reset_clears_cache() {
let ledger_path = get_tmp_ledger_path!();
{
let blockstore = Blockstore::open(&ledger_path)
.expect("Expected to be able to open database ledger");
let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(2);
let bank0 = Arc::new(Bank::new_for_tests(&genesis_config));
let (mut poh_recorder, _entry_receiver, _record_receiver) = PohRecorder::new(
0,
Hash::default(),
bank0.clone(),
Some((4, 4)),
DEFAULT_TICKS_PER_SLOT,
&Pubkey::default(),
&Arc::new(blockstore),
&Arc::new(LeaderScheduleCache::default()),
&Arc::new(PohConfig::default()),
Arc::new(AtomicBool::default()),
);
poh_recorder.tick();
assert_eq!(poh_recorder.tick_cache.len(), 1);
poh_recorder.reset(bank0, Some((4, 4)));
assert_eq!(poh_recorder.tick_cache.len(), 0);
}
Blockstore::destroy(&ledger_path).unwrap();
} | rust_cleaned_test_functions.jsonl/106260 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 623
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
2267,
7080,
1358,
18983,
21811,
82,
11529,
368,
341,
286,
1077,
46933,
2638,
284,
633,
16125,
38367,
1389,
2638,
0,
543,
286,
341,
310,
1077,
2504,
4314,
284,
8362,
4314,
486,
2508,
2099,
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_chain_handler_error() {
test_chain(
// Error in handler
(vec![Fine, Fine, Fine], Prob, vec![Prob, Prob, Prob]),
(vec![Fine, Fine, Fine], Fine, vec![Prob, Prob, Prob]),
);
} | rust_cleaned_test_functions.jsonl/39005 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 108
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
30583,
10183,
4096,
368,
341,
262,
1273,
30583,
1006,
286,
442,
4600,
304,
7013,
198,
286,
320,
4083,
20703,
63716,
11,
30153,
11,
30153,
1125,
25627,
11,
7486,
20703,
36980,
11,
25627,
11,
25627,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_mount_fs_type_from_file() {
#[derive(Debug)]
struct TestData<'a> {
// Create file with the specified contents
contents: &'a str,
mount_point: &'a str,
// else assume no error.
error_contains: &'a str,
// successful return value
fs_type: &'a str,
}
let dir = tempdir().expect("failed to create tmpdir");
let tests = &[
TestData {
contents: "",
mount_point: "",
error_contains: "Invalid mount point",
fs_type: "",
},
TestData {
contents: "foo",
mount_point: "",
error_contains: "Invalid mount point",
fs_type: "",
},
TestData {
contents: "foo",
mount_point: "/",
error_contains: "failed to find FS type for mount point /",
fs_type: "",
},
TestData {
// contents missing fields
contents: "device /dev/mapper/root mounted on /",
mount_point: "/",
error_contains: "failed to find FS type for mount point /",
fs_type: "",
},
TestData {
contents: "device /dev/mapper/root mounted on / with fstype ext4",
mount_point: "/",
error_contains: "",
fs_type: "ext4",
},
];
let enoent_file_path = dir.path().join("enoent");
let enoent_filename = enoent_file_path
.to_str()
.expect("failed to create enoent filename");
for (i, mp) in ["/", "/somewhere", "/tmp", enoent_filename]
.iter()
.enumerate()
{
let msg = format!("missing mount file test[{}] with mountpoint: {}", i, mp);
let result = get_mount_fs_type_from_file("", mp);
let err = result.unwrap_err();
let msg = format!("{}: error: {}", msg, err);
assert!(
format!("{}", err).contains("No such file or directory"),
"{}",
msg
);
}
for (i, d) in tests.iter().enumerate() {
let msg = format!("test[{}]: {:?}", i, d);
let file_path = dir.path().join("mount_stats");
let filename = file_path
.to_str()
.unwrap_or_else(|| panic!("{}: failed to create filename", msg));
let mut file =
File::create(filename).unwrap_or_else(|_| panic!("{}: failed to create file", msg));
file.write_all(d.contents.as_bytes())
.unwrap_or_else(|_| panic!("{}: failed to write file contents", msg));
let result = get_mount_fs_type_from_file(filename, d.mount_point);
// add more details if an assertion fails
let msg = format!("{}: result: {:?}", msg, result);
if d.error_contains.is_empty() {
let fs_type = result.unwrap();
assert!(d.fs_type == fs_type, "{}", msg);
continue;
}
let error_msg = format!("{}", result.unwrap_err());
assert!(error_msg.contains(d.error_contains), "{}", msg);
}
} | rust_cleaned_test_functions.jsonl/32169 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1891
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
57593,
34470,
1819,
5673,
2458,
368,
341,
286,
11506,
27098,
42618,
5563,
286,
2036,
93200,
18291,
64,
29,
341,
310,
442,
4230,
1034,
448,
279,
5189,
8794,
18574,
310,
8794,
25,
30136,
64,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_download_sst_with_key_rewrite_ts_default() {
// performs the download.
let importer_dir = tempfile::tempdir().unwrap();
let importer = SSTImporter::new(&importer_dir, None).unwrap();
// creates a sample SST file.
let (_ext_sst_dir, backend, meta) = create_sample_external_sst_file_txn_default().unwrap();
let sst_writer = create_sst_writer_with_db(&importer, &meta).unwrap();
let _ = importer
.download::<TestEngine>(
&meta,
&backend,
"sample_default.sst",
&new_rewrite_rule(b"", b"", 16),
Limiter::new(INFINITY),
sst_writer,
)
.unwrap()
.unwrap();
// verifies that the file is saved to the correct place.
let sst_file_path = importer.dir.join(&meta).unwrap().save;
assert!(sst_file_path.is_file());
// verifies the SST content is correct.
let sst_reader = new_sst_reader(sst_file_path.to_str().unwrap());
sst_reader.verify_checksum().unwrap();
let mut iter = sst_reader.iter();
iter.seek(SeekKey::Start).unwrap();
assert_eq!(
collect(iter),
vec![
(get_encoded_key(b"t123_r01", 16), b"abc".to_vec()),
(get_encoded_key(b"t123_r04", 16), b"xyz".to_vec()),
(get_encoded_key(b"t123_r07", 16), b"pqrst".to_vec()),
]
);
} | rust_cleaned_test_functions.jsonl/4964 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 806
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
35939,
643,
267,
6615,
3097,
74052,
25023,
9993,
368,
341,
286,
442,
26674,
279,
4139,
624,
286,
1077,
62561,
4334,
284,
54819,
486,
3888,
3741,
1005,
15454,
543,
286,
1077,
62561,
284,
91416,
772... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_result_from_ffi_result_ok() {
let ffi_res = FfiResult::Ok(util::into_raw(123));
let res = Fallible::from(ffi_res);
assert_eq!(res, Ok(123));
} | rust_cleaned_test_functions.jsonl/31442 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 99
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5287,
5673,
62,
53799,
5287,
19817,
368,
341,
286,
1077,
76956,
4918,
284,
434,
9983,
2077,
486,
11578,
67811,
486,
18122,
16067,
7,
16,
17,
18,
1106,
286,
1077,
592,
284,
14785,
1238,
486,
1499... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_const_evaluator_now() {
let ts_nanos = 1599566400000000000i64;
let time = chrono::Utc.timestamp_nanos(ts_nanos);
let ts_string = "2020-09-08T12:05:00+00:00";
test_evaluate_with_start_time(now_expr(), lit_timestamp_nano(ts_nanos), &time);
let expr = cast_to_int64_expr(now_expr()) + lit(100);
test_evaluate_with_start_time(expr, lit(ts_nanos + 100), &time);
let expr = cast_to_int64_expr(now_expr())
.lt(cast_to_int64_expr(to_timestamp_expr(ts_string)) + lit(50000));
test_evaluate_with_start_time(expr, lit(true), &time);
} | rust_cleaned_test_functions.jsonl/19691 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 327
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13610,
21296,
45162,
20813,
368,
341,
286,
1077,
10591,
1089,
43605,
284,
220,
16,
20,
24,
24,
20,
21,
21,
19,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
72,
21,
19,
280,
286,
1077,
882... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_submodule_contains_untracked_content() {
let config = integration_test_utils::make_config_from_args(&[]);
let output =
integration_test_utils::run_delta(SUBMODULE_CONTAINS_UNTRACKED_CONTENT_INPUT, &config);
let output = strip_ansi_codes(&output);
assert!(output.contains("\nSubmodule x/y/z contains untracked content\n"));
} | rust_cleaned_test_functions.jsonl/70050 | {
"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,
5228,
4352,
63598,
4907,
58381,
7495,
368,
341,
286,
1077,
2193,
284,
17590,
4452,
17309,
486,
6927,
5332,
5673,
8384,
2099,
56703,
286,
1077,
2550,
4035,
310,
17590,
4452,
17309,
486,
6108,
26710,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_touch_set_date() {
let (at, mut ucmd) = at_and_ucmd!();
let file = "test_touch_set_date";
ucmd.args(&["-d", "Thu Jan 01 12:34:00 2015", file])
.succeeds()
.no_stderr();
assert!(at.file_exists(file));
let start_of_year = str_to_filetime("%Y%m%d%H%M", "201501011234");
let (atime, mtime) = get_file_times(&at, file);
assert_eq!(atime, mtime);
assert_eq!(atime, start_of_year);
assert_eq!(mtime, start_of_year);
} | rust_cleaned_test_functions.jsonl/41032 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 241
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
60840,
2602,
4164,
368,
341,
262,
1077,
320,
266,
11,
5206,
575,
8710,
8,
284,
518,
8378,
68887,
2277,
0,
543,
262,
1077,
1034,
284,
330,
1944,
60840,
2602,
4164,
3302,
262,
575,
8710,
16365,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_skip_var_octet_string() {
let tests: &[(Vec<u8>, usize)] = &[
(ZERO_LENGTH_VARSTR.clone(), 1),
(ONE_BYTE_VARSTR.clone(), 2),
(TWO_BYTE_VARSTR.clone(), 3),
(SIZE_128_VARSTR.clone(), SIZE_128_VARSTR.len()),
(SIZE_5678_VARSTR.clone(), SIZE_5678_VARSTR.len()),
];
for (buffer, offset) in tests {
let mut reader = &buffer[..];
assert!(reader.skip_var_octet_string().is_ok());
assert_eq!(reader.len(), buffer.len() - *offset);
}
assert_eq!(
(&[][..]).skip_var_octet_string().unwrap_err().kind(),
ErrorKind::UnexpectedEof,
);
assert_eq!(
(&LENGTH_TOO_HIGH_VARSTR.clone()[..])
.skip_var_octet_string()
.unwrap_err()
.kind(),
ErrorKind::UnexpectedEof,
);
} | rust_cleaned_test_functions.jsonl/14911 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 537
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
44830,
4612,
70135,
295,
3904,
368,
341,
286,
1077,
7032,
25,
609,
9697,
10050,
34837,
23,
8066,
22301,
7252,
284,
609,
9640,
310,
320,
73956,
15023,
25750,
6666,
15997,
1507,
220,
16,
1326,
310,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_base_url() {
let url = Gravatar::new("email@example.com").image_url();
assert_eq!(
url.as_str(),
"https://secure.gravatar.com/avatar/5658ffccee7f0ebfda2b226238b1eb6e"
);
} | rust_cleaned_test_functions.jsonl/61375 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 115
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7651,
2903,
368,
341,
262,
1077,
2515,
284,
2825,
11962,
486,
931,
445,
2332,
35487,
905,
1827,
1805,
2903,
543,
262,
2060,
10714,
33673,
286,
2515,
5357,
2895,
3148,
286,
330,
2428,
1110,
25132,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_signature_unsubscribe() {
let GenesisConfigInfo {
genesis_config,
mint_keypair: alice,
..
} = create_genesis_config(10_000);
let bob_pubkey = Pubkey::new_rand();
let bank = Bank::new(&genesis_config);
let blockhash = bank.last_blockhash();
let bank_forks = Arc::new(RwLock::new(BankForks::new(bank)));
let session = create_session();
let mut io = PubSubHandler::default();
let rpc = RpcSolPubSubImpl::default_with_bank_forks(bank_forks);
io.extend_with(rpc.to_delegate());
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"signatureSubscribe","params":["{}"]}}"#,
tx.signatures[0].to_string()
);
let _res = io.handle_request_sync(&req, session.clone());
let req = r#"{"jsonrpc":"2.0","id":1,"method":"signatureUnsubscribe","params":[0]}"#;
let res = io.handle_request_sync(&req, session.clone());
let expected = r#"{"jsonrpc":"2.0","result":true,"id":1}"#;
let expected: Response = serde_json::from_str(&expected).unwrap();
let result: Response = serde_json::from_str(&res.unwrap()).unwrap();
assert_eq!(expected, result);
// Test bad parameter
let req = r#"{"jsonrpc":"2.0","id":1,"method":"signatureUnsubscribe","params":[1]}"#;
let res = io.handle_request_sync(&req, session);
let expected = r#"{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid Request: Subscription id does not exist"},"id":1}"#;
let expected: Response = serde_json::from_str(&expected).unwrap();
let result: Response = serde_json::from_str(&res.unwrap()).unwrap();
assert_eq!(expected, result);
} | rust_cleaned_test_functions.jsonl/16577 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 816
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39859,
4907,
9384,
368,
341,
286,
1077,
40788,
2648,
1731,
341,
310,
59366,
5332,
345,
310,
28337,
3097,
12670,
25,
70433,
345,
310,
54538,
286,
335,
284,
1855,
16322,
13774,
5332,
7,
16,
15,
62... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_value() {
let mut mock = Mock::default();
let mut ctx = mock.create_ctx();
let x = ctx.value::<u64>("module.TestKey").get();
assert_eq!(x, None);
ctx.value::<u64>("module.TestKey").set(42);
let y = ctx.value::<u64>("module.TestKey").get();
assert_eq!(y, Some(&42u64));
let z = ctx.value::<u64>("module.TestKey").take();
assert_eq!(z, Some(42u64));
let y = ctx.value::<u64>("module.TestKey").get();
assert_eq!(y, None);
} | rust_cleaned_test_functions.jsonl/105375 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 272
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3142,
368,
341,
286,
1077,
5206,
7860,
284,
14563,
486,
2258,
543,
286,
1077,
5206,
5635,
284,
7860,
2520,
15147,
1428,
286,
1077,
856,
284,
5635,
2824,
27638,
84,
21,
19,
13211,
4352,
8787,
159... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_event_time_format() {
let timespec = Timespec::new(1494245571, 0);
let time = time::at(timespec);
let event_time = EventTime::new(time);
let mut buf = vec![];
let _ = event_time
.serialize(&mut Serializer::new(&mut buf))
.unwrap();
assert_eq!(
vec![0xc4, 0x0a, 0xd7, 0x00, 0x59, 0x10, 0x60, 0xc3, 0x00, 0x00, 0x00, 0x00],
buf
);
} | rust_cleaned_test_functions.jsonl/50367 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 259
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6748,
3009,
8955,
368,
341,
286,
1077,
71156,
284,
8523,
992,
486,
931,
7,
16,
19,
24,
19,
17,
19,
20,
20,
22,
16,
11,
220,
15,
317,
286,
1077,
882,
284,
882,
486,
266,
61118,
992,
317,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_version_parse() {
use super::Component::*;
assert_eq!(Version("v0.4.1-28-gfba00d7")
.components().collect::<Vec<_>>(),
[Numeric(0), Numeric(4), Numeric(1),
Numeric(28), String("gfba00d7")]);
assert_eq!(Version("v0.4.1+trusty1")
.components().collect::<Vec<_>>(),
[Numeric(0), Numeric(4), Numeric(1)]);
} | rust_cleaned_test_functions.jsonl/15850 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 231
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9438,
21039,
368,
341,
286,
990,
2256,
486,
2189,
56162,
286,
2060,
10714,
10297,
5637,
445,
85,
15,
13,
19,
13,
16,
12,
17,
23,
2371,
69,
4645,
15,
15,
67,
22,
1138,
310,
659,
5149,
1005,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_addr_iter_single() {
let localhost = SocketAddr::from((IpAddr::from(Ipv4Addr::LOCALHOST), 8080));
let mut iter = AddrsIter::One(localhost);
assert_eq!(iter.next(), Some(localhost));
assert_eq!(iter.next(), None);
let mut iter = AddrsIter::None;
assert_eq!(iter.next(), None);
} | rust_cleaned_test_functions.jsonl/32859 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 163
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7387,
11723,
19487,
368,
341,
286,
1077,
47422,
284,
20954,
13986,
486,
1499,
1188,
23378,
13986,
486,
1499,
8972,
30168,
19,
13986,
486,
39081,
28687,
701,
220,
23,
15,
23,
15,
3237,
286,
1077,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_normal_ops() {
let mut vm: VimMachine<KeyEvent> = VimMachine::default();
let mut ctx = VimContext::default();
let mov = mv!(MoveType::WordBegin(WordStyle::Little, MoveDir1D::Next));
ctx.action.operation = EditAction::Yank;
vm.input_key(key!('y'));
vm.input_key(key!('w'));
assert_pop2!(vm, mov, ctx);
assert_eq!(vm.mode(), VimMode::Normal);
ctx.action.operation = EditAction::Format;
vm.input_key(key!('g'));
vm.input_key(key!('q'));
vm.input_key(key!('w'));
assert_pop2!(vm, mov, ctx);
assert_eq!(vm.mode(), VimMode::Normal);
ctx.action.operation = EditAction::ChangeCase(Case::Lower);
vm.input_key(key!('g'));
vm.input_key(key!('u'));
vm.input_key(key!('w'));
assert_pop2!(vm, mov, ctx);
assert_eq!(vm.mode(), VimMode::Normal);
ctx.action.operation = EditAction::ChangeCase(Case::Upper);
vm.input_key(key!('g'));
vm.input_key(key!('U'));
vm.input_key(key!('w'));
assert_pop2!(vm, mov, ctx);
assert_eq!(vm.mode(), VimMode::Normal);
ctx.action.operation = EditAction::ChangeCase(Case::Toggle);
vm.input_key(key!('g'));
vm.input_key(key!('~'));
vm.input_key(key!('w'));
assert_pop2!(vm, mov, ctx);
assert_eq!(vm.mode(), VimMode::Normal);
ctx.action.operation = EditAction::Indent(IndentChange::Auto);
vm.input_key(key!('='));
vm.input_key(key!('w'));
assert_pop2!(vm, mov, ctx);
assert_eq!(vm.mode(), VimMode::Normal);
ctx.action.operation = EditAction::Indent(IndentChange::Decrease(Count::Exact(1)));
vm.input_key(key!('<'));
vm.input_key(key!('w'));
assert_pop2!(vm, mov, ctx);
assert_eq!(vm.mode(), VimMode::Normal);
ctx.action.operation = EditAction::Indent(IndentChange::Increase(Count::Exact(1)));
vm.input_key(key!('>'));
vm.input_key(key!('w'));
assert_pop2!(vm, mov, ctx);
assert_eq!(vm.mode(), VimMode::Normal);
let mov = range!(RangeType::Word(WordStyle::Little));
ctx.action.operation = EditAction::Format;
vm.input_key(key!('g'));
vm.input_key(key!('w'));
vm.input_key(key!('a'));
vm.input_key(key!('w'));
assert_pop2!(vm, mov, ctx);
assert_eq!(vm.mode(), VimMode::Normal);
ctx.action.operation = EditAction::Motion;
let op = EditAction::Join(true);
let lines = rangeop!(op, RangeType::Line);
vm.input_key(key!('J'));
assert_pop2!(vm, lines, ctx);
assert_eq!(vm.mode(), VimMode::Normal);
let op = EditAction::Join(false);
let lines = rangeop!(op, RangeType::Line);
vm.input_key(key!('g'));
vm.input_key(key!('J'));
assert_pop2!(vm, lines, ctx);
assert_eq!(vm.mode(), VimMode::Normal);
let col = MoveType::Column(MoveDir1D::Next, false);
vm.input_key(key!('~'));
assert_pop1!(vm, mvop!(EditAction::ChangeCase(Case::Toggle), col), ctx);
assert_pop2!(vm, mvop!(EditAction::Motion, col), ctx);
assert_eq!(vm.mode(), VimMode::Normal);
let op = EditAction::Replace(false);
let mov = mvop!(op, MoveType::Column(MoveDir1D::Next, false));
ctx.action.replace = Some('A'.into());
ctx.action.any = Some(key!('A'));
vm.input_key(key!('r'));
vm.input_key(key!('A'));
assert_pop2!(vm, mov, ctx);
assert_eq!(vm.mode(), VimMode::Normal);
ctx.action.replace = None;
ctx.action.any = None;
let op = EditAction::ChangeNumber(NumberChange::IncreaseOne);
let mov = mvop!(op, MoveType::LinePos(MovePosition::End));
vm.input_key(ctl!('a'));
assert_pop2!(vm, mov, ctx);
assert_eq!(vm.mode(), VimMode::Normal);
let op = EditAction::ChangeNumber(NumberChange::DecreaseOne);
let mov = mvop!(op, MoveType::LinePos(MovePosition::End));
vm.input_key(ctl!('x'));
assert_pop2!(vm, mov, ctx);
assert_eq!(vm.mode(), VimMode::Normal);
} | rust_cleaned_test_functions.jsonl/74572 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2050
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13973,
21959,
368,
341,
286,
1077,
5206,
10995,
25,
94484,
21605,
42003,
1556,
29,
284,
94484,
21605,
486,
2258,
543,
286,
1077,
5206,
5635,
284,
94484,
1972,
486,
2258,
1428,
286,
1077,
1974,
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_header_serialised_length() {
let nonce = vec![1,2,3,4,5];
let salt = _get_test_salt();
let header = Header::new(1, "TEST_ENCRYPTION_METHOD", &nonce, salt);
let serialised_header = header.serialise().unwrap();
assert_eq!(serialised_header.len(), 2 + 12 + 2 + "TEST_ENCRYPTION_METHOD".len() + 2 + 5 + 2 + 32 + 32);
} | rust_cleaned_test_functions.jsonl/106122 | {
"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,
8757,
25602,
4056,
5118,
368,
341,
286,
1077,
39676,
284,
7486,
20703,
16,
11,
17,
11,
18,
11,
19,
11,
20,
935,
286,
1077,
12021,
284,
716,
455,
4452,
92280,
543,
286,
1077,
4247,
284,
12104,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_tracee_died() -> Result<()> {
let cmd = Command::new("true");
let mut tracer = Ptracer::new();
let mut child = tracer.spawn(cmd)?;
let mut died = false;
while let Some(tracee) = tracer.wait()? {
child.kill()?;
if let Err(err) = tracer.restart(tracee, Restart::Continue) {
assert_matches!(err, Error::TraceeDied { .. });
assert!(err.tracee_died());
let regs = tracee.registers();
assert!(regs.is_err());
if let Err(err) = regs {
assert_matches!(err, Error::TraceeDied { .. });
assert!(err.tracee_died());
} else {
unreachable!();
}
died = true;
}
}
assert!(died);
Ok(())
} | rust_cleaned_test_functions.jsonl/92935 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 429
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
23575,
68,
814,
1122,
368,
1464,
5714,
71698,
341,
262,
1077,
5439,
284,
7348,
486,
931,
445,
1866,
3071,
262,
1077,
5206,
64306,
284,
46409,
9584,
486,
931,
543,
262,
1077,
5206,
1682,
284,
643... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
#[test]
fn test_bounds_new_valid() {
let b = Bounds::new(-2.0, 2.0);
assert_eq!(b.a, -2.0);
assert_eq!(b.b, 2.0);
let b = Bounds::new(2.0, 2.0);
assert_eq!(b.a, 2.0);
assert_eq!(b.b, 2.0);
} | rust_cleaned_test_functions.jsonl/7148 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 160
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36878,
5921,
8337,
368,
341,
286,
1077,
293,
284,
69130,
486,
931,
4080,
17,
13,
15,
11,
220,
17,
13,
15,
317,
286,
2060,
10714,
10297,
65,
5849,
11,
481,
17,
13,
15,
317,
286,
2060,
10714,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ecdsa_adaptor_signature_encrypt_no_aux_rand() {
test_ecdsa_adaptor_signature_helper(|msg, sk, adaptor, _| {
EcdsaAdaptorSignature::encrypt_no_aux_rand(&SECP256K1, msg, sk, adaptor)
})
} | rust_cleaned_test_functions.jsonl/62233 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 124
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36844,
96780,
10027,
32657,
39859,
66593,
6536,
30468,
33864,
368,
341,
286,
1273,
36844,
96780,
10027,
32657,
39859,
10418,
22428,
3236,
11,
1901,
11,
91941,
11,
85137,
341,
310,
468,
4385,
9081,
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_decode() {
assert_eq!("a,c", DictionaryBuilder::decode("a\\u002cc"));
assert_eq!("a,c", DictionaryBuilder::decode("a\\u{002c}c"));
assert_eq!("a𠮟c", DictionaryBuilder::decode("a\\u{20b9f}c"));
} | rust_cleaned_test_functions.jsonl/134076 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 110
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15227,
368,
341,
262,
2060,
10714,
17223,
64,
10109,
497,
10466,
3297,
486,
18196,
445,
64,
3422,
84,
15,
15,
17,
638,
4010,
262,
2060,
10714,
17223,
64,
10109,
497,
10466,
3297,
486,
18196,
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_projects() {
let file_name: &str = "data/projects_test.txt";
remove_file(file_name.to_string());
let mut all_projects = fetch_all_projects(file_name.to_string(), &String::new());
println!("{:#?}", all_projects);
let test_project = Project::create(
&mut all_projects,
"test",
"Test Project",
"This is a test project.",
"/api/v1/projects",
);
assert_eq!(test_project, Ok(()));
let test_project2 = Project::create(
&mut all_projects,
"test ",
"Test Project",
"This is a test project.",
"/api/v1/projects",
);
assert_eq!(
test_project2,
Err(String::from("Error: new_id contains an invalid character"))
);
let test_project2 = Project::create(
&mut all_projects,
"test2",
"Test *** Project",
"This is a test project.",
"/api/v1/projects",
);
assert_eq!(
test_project2,
Err(String::from("Error: name contains an invalid character"))
);
let test_project2 = Project::create(
&mut all_projects,
"test2",
"Test Project",
"This is a test project.",
"/api/v1/projects-",
);
assert_eq!(
test_project2,
Err(String::from(
"Error: api_path contains an invalid character"
))
);
let test_project2 = Project::create(
&mut all_projects,
"test2",
"Test Project",
"This is a test project.",
"/api/v1/Projects",
);
assert_eq!(
test_project2,
Err(String::from(
"Error: api_path should not contain uppercase alphabetical character(s)"
))
);
let test_project2 = Project::create(
&mut all_projects,
"test",
"Test Project",
"This is a test project.",
"/api/v1/projects",
);
assert_eq!(
test_project2,
Err(String::from("Error: id is already in use"))
);
let test_project2 = Project::create(
&mut all_projects,
"test2",
"Test Project",
"This is a test project.",
"/api/v1/projects",
);
assert_eq!(
test_project2,
Err(String::from("Error: api_path is already in use"))
);
let test_project2 = Project::create(
&mut all_projects,
"test2",
"Test Project",
"This is a test project;",
"/api/v1/projects2",
);
assert_eq!(
test_project2,
Err(String::from(
"Error: description contains an invalid character"
))
);
let test_project2 = Project::create(
&mut all_projects,
"test2",
"Test Project",
"This is a new test project.",
"/api/v1/projects2",
);
assert_eq!(test_project2, Ok(()));
let test2_id = String::from("test2");
let test_project3 = Project::update_name(&mut all_projects, &test2_id, "Test Project 3");
assert_eq!(test_project3, Ok(()));
let test_project3 = Project::update_description(
&mut all_projects,
&test2_id,
"This is a new test project (3).",
);
assert_eq!(test_project3, Ok(()));
let test_project3 = Project::update_api_path(&mut all_projects, &test2_id, "/api/v1/projects3");
assert_eq!(test_project3, Ok(()));
let test_project3 = Project::update_id(&mut all_projects, &test2_id, "test3");
assert_eq!(test_project3, Ok(()));
save_all_projects(&all_projects, String::from(file_name), &String::new());
} | rust_cleaned_test_functions.jsonl/50011 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1640
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
58774,
368,
341,
262,
1077,
1034,
1269,
25,
609,
495,
284,
330,
691,
39606,
4452,
3909,
876,
262,
4057,
2458,
4866,
1269,
2389,
3904,
5231,
262,
1077,
5206,
678,
58774,
284,
7807,
5705,
58774,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_string_to_pattern_untagged_value() {
let a_pattern = r"[a-zA-Z0-9 ]";
assert_eq!(
a_pattern.to_pattern_untagged_value(),
UntaggedValue::glob_pattern(a_pattern)
);
} | rust_cleaned_test_functions.jsonl/124320 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 129
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3904,
2346,
21260,
62,
3850,
96476,
3142,
368,
341,
286,
1077,
264,
21260,
284,
435,
36864,
64,
21088,
11171,
15,
12,
24,
2279,
876,
286,
2060,
10714,
33673,
310,
264,
21260,
2389,
21260,
62,
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 |
#[test]
fn test_mime_fmt() {
let mime = TEXT_PLAIN;
assert_eq!(mime.to_string(), "text/plain");
let mime = TEXT_PLAIN_UTF_8;
assert_eq!(mime.to_string(), "text/plain; charset=utf-8");
} | rust_cleaned_test_functions.jsonl/99125 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 121
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
83624,
38128,
368,
341,
286,
1077,
45270,
284,
15762,
11082,
6836,
280,
286,
2060,
10714,
10297,
49588,
2389,
3904,
1507,
330,
1318,
36971,
797,
286,
1077,
45270,
284,
15762,
11082,
6836,
55061,
62,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_combine_vecs() {
let v1 = vec![1, 2, 3];
let v2 = vec![4, 5];
let mut v3 = combine_vecs(v1, v2);
assert_eq!(Some(1), v3.next());
assert_eq!(Some(2), v3.next());
assert_eq!(Some(3), v3.next());
assert_eq!(Some(4), v3.next());
assert_eq!(Some(5), v3.next());
assert_eq!(None, v3.next());
} | rust_cleaned_test_functions.jsonl/83602 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 220
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
72374,
13251,
82,
368,
341,
286,
1077,
348,
16,
284,
7486,
20703,
16,
11,
220,
17,
11,
220,
18,
935,
286,
1077,
348,
17,
284,
7486,
20703,
19,
11,
220,
20,
935,
286,
1077,
5206,
348,
18,
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_decrypt_small() {
let expected_plaintext = b"Hello, world!";
let key_data = get_key_data();
let expected_sender = key_data.alice_public;
let recipient = key_data.bob_private;
let ciphertext = encrypt_small();
let mut plaintext = Vec::new();
let sender_public = decrypt(
&mut ciphertext.as_slice(),
&mut plaintext,
&recipient,
AsymFileFormat::V1,
)
.unwrap();
assert_eq!(&expected_plaintext[..], plaintext.as_slice());
assert_eq!(expected_sender.as_bytes(), sender_public.as_bytes());
} | rust_cleaned_test_functions.jsonl/37917 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 308
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
80764,
31966,
368,
341,
286,
1077,
3601,
6317,
1641,
427,
284,
293,
1,
9707,
11,
1879,
26782,
286,
1077,
1376,
1769,
284,
633,
3097,
1769,
543,
286,
1077,
3601,
54356,
284,
1376,
1769,
12168,
55... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_character() {
let mut lexer = Cursor::new("#\\a");
assert_eq!(lexer.get_token(), Some(Token::new(Character, 3)));
let mut lexer = Cursor::new("#\\");
assert_eq!(lexer.get_token(), None);
let mut lexer = Cursor::new("#\\newline");
assert_eq!(lexer.get_token(), Some(Token::new(Character, 9)));
} | rust_cleaned_test_functions.jsonl/25327 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 174
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
40988,
368,
341,
286,
1077,
5206,
53259,
284,
28067,
486,
931,
3584,
3422,
64,
797,
286,
2060,
10714,
10297,
38815,
670,
6458,
1507,
4329,
38584,
486,
931,
71119,
11,
220,
18,
22525,
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_empty_tags_removed() {
let mut event = Annotated::new(Event {
tags: Annotated::new(Tags(PairList(vec![
Annotated::new(TagEntry(
Annotated::new("".to_string()),
Annotated::new("foo".to_string()),
)),
Annotated::new(TagEntry(
Annotated::new("foo".to_string()),
Annotated::new("".to_string()),
)),
Annotated::new(TagEntry(
Annotated::new("something".to_string()),
Annotated::new("else".to_string()),
)),
]))),
..Event::default()
});
let mut processor = NormalizeProcessor::default();
process_value(&mut event, &mut processor, ProcessingState::root()).unwrap();
let tags = event.value().unwrap().tags.value().unwrap();
assert_eq!(tags.len(), 2);
assert_eq!(
tags.get(0).unwrap(),
&Annotated::from_error(Error::nonempty(), None)
)
} | rust_cleaned_test_functions.jsonl/14094 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 501
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15124,
16333,
68248,
368,
341,
262,
1077,
5206,
1538,
284,
1527,
87029,
486,
931,
30469,
341,
286,
9492,
25,
1527,
87029,
486,
931,
4140,
2032,
5304,
1310,
852,
25592,
90515,
310,
1527,
87029,
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_max_dot_product() {
let test_cases = vec![
(vec![-3,-8,3,-10,1,3,9],vec![9,2,3,7,-9,1,-8,5,-1,-1],200),
(vec![2,1,-2,5], vec![3,0,-6], 18),
(vec![3, -2], vec![2,-6,7], 21),
(vec![-1,-1],vec![1,1], -1),
];
for (nums1, nums2, expect) in test_cases {
assert_eq!(Solution::max_dot_product(nums1.clone(), nums2.clone()), expect, "nums1: {:?}, nums2: {:?}", nums1, nums2);
}
} | rust_cleaned_test_functions.jsonl/64730 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 303
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6345,
30941,
9840,
368,
341,
286,
1077,
1273,
41427,
284,
7486,
90515,
310,
320,
4083,
0,
7609,
18,
4999,
23,
11,
18,
4999,
16,
15,
11,
16,
11,
18,
11,
24,
1125,
4083,
20703,
24,
11,
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... | 2 |
#[test]
fn test_is_nan() {
assert!(!_1_1i.is_nan());
let a = Complex::new(f64::NAN, f64::NAN);
assert!(a.is_nan());
} | rust_cleaned_test_functions.jsonl/105664 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 90
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6892,
73936,
368,
341,
286,
2060,
0,
67097,
16,
62,
16,
72,
2079,
73936,
1423,
286,
1077,
264,
284,
22096,
486,
931,
955,
21,
19,
486,
45,
1093,
11,
282,
21,
19,
486,
45,
1093,
317,
286,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_pitch_yaw_roll_pos_1() {
check_euler(Euler {
x: Rad(1f32),
y: Rad(1f32),
z: Rad(1f32),
});
} | rust_cleaned_test_functions.jsonl/38251 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 117
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
51959,
80183,
57578,
6479,
62,
16,
368,
341,
286,
1779,
2204,
8479,
10722,
8479,
341,
310,
856,
25,
20605,
7,
16,
69,
18,
17,
1326,
310,
379,
25,
20605,
7,
16,
69,
18,
17,
1326,
310,
1147,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_bit_set_cmp() {
let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100010]));
let b = BitSet::from_bit_vec(BitVec::from_bytes(&[0b00000000]));
let c = BitSet::new();
assert_eq!(a.cmp(&b), Greater);
assert_eq!(a.cmp(&c), Greater);
assert_eq!(b.cmp(&a), Less);
assert_eq!(b.cmp(&c), Equal);
assert_eq!(c.cmp(&a), Less);
assert_eq!(c.cmp(&b), Equal);
} | rust_cleaned_test_functions.jsonl/76237 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 238
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13996,
2602,
35193,
368,
341,
286,
1077,
264,
284,
57227,
486,
1499,
13996,
13251,
68653,
10050,
486,
1499,
12524,
2099,
58,
15,
65,
16,
15,
16,
15,
15,
15,
16,
15,
14382,
286,
1077,
293,
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_poll_async_immediate_ops() {
run_in_task(|| {
let (mut isolate, dispatch_count) = setup(Mode::AsyncImmediate);
js_check(isolate.execute(
"setup2.js",
r#"
let nrecv = 0;
Deno.core.setAsyncHandler((buf) => {
nrecv++;
});
"#,
));
assert_eq!(dispatch_count.load(Ordering::Relaxed), 0);
js_check(isolate.execute(
"check1.js",
r#"
assert(nrecv == 0);
let control = new Uint8Array([42]);
Deno.core.send(control);
assert(nrecv == 0);
"#,
));
assert_eq!(dispatch_count.load(Ordering::Relaxed), 1);
assert_eq!(Async::Ready(()), isolate.poll().unwrap());
assert_eq!(dispatch_count.load(Ordering::Relaxed), 1);
js_check(isolate.execute(
"check2.js",
r#"
assert(nrecv == 1);
Deno.core.send(control);
assert(nrecv == 1);
"#,
));
assert_eq!(dispatch_count.load(Ordering::Relaxed), 2);
assert_eq!(Async::Ready(()), isolate.poll().unwrap());
js_check(isolate.execute("check3.js", "assert(nrecv == 2)"));
assert_eq!(dispatch_count.load(Ordering::Relaxed), 2);
assert_eq!(Async::Ready(()), isolate.poll().unwrap());
});
} | rust_cleaned_test_functions.jsonl/93569 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 661
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
40002,
28346,
17895,
14636,
21959,
368,
341,
262,
1598,
1243,
12184,
79453,
341,
414,
1077,
320,
6984,
42123,
11,
6845,
3180,
8,
284,
6505,
3189,
534,
486,
6525,
52734,
626,
414,
6994,
7200,
82669... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_established_bad_seq() {
let mut s = socket_established();
// Data outside of receive window.
send!(s, TcpRepr {
seq_number: REMOTE_SEQ + 1 + 256,
ack_number: Some(LOCAL_SEQ + 1),
..SEND_TEMPL
}, Ok(Some(TcpRepr {
seq_number: LOCAL_SEQ + 1,
ack_number: Some(REMOTE_SEQ + 1),
..RECV_TEMPL
})));
assert_eq!(s.remote_seq_no, REMOTE_SEQ + 1);
} | rust_cleaned_test_functions.jsonl/1727 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 275
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18583,
5102,
291,
34199,
14486,
368,
341,
286,
1077,
5206,
274,
284,
7575,
18583,
5102,
291,
543,
286,
442,
2885,
4889,
315,
5258,
3241,
624,
286,
3624,
10297,
82,
11,
64876,
693,
649,
341,
310,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_addition() {
let mut tmp = LARGEST;
tmp += &LARGEST;
assert_eq!(
tmp,
Scalar([
0xfffffffeffffffff,
0x53bda402fffe5bfe,
0x3339d80809a1d805,
0x73eda753299d7d48
])
);
let mut tmp = LARGEST;
tmp += &Scalar([1, 0, 0, 0]);
assert_eq!(tmp, Scalar::zero());
} | rust_cleaned_test_functions.jsonl/90467 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 224
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
680,
368,
341,
262,
1077,
5206,
4174,
284,
444,
7581,
5177,
280,
262,
4174,
1421,
609,
43,
7581,
5177,
401,
262,
2060,
10714,
33673,
286,
4174,
345,
286,
35176,
8956,
310,
220,
15,
68247,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_spqlios_poly_mul_1024() {
let mut plan = FFTPlan::new(1024);
let mut rng = rand::thread_rng();
for _i in 0..100 {
let mut a = [0u32; 1024];
let mut b = [0u32; 1024];
a.iter_mut().for_each(|e| *e = rng.gen::<u32>());
b.iter_mut()
.for_each(|e| *e = rng.gen::<u32>() % params::trgsw_lv1::BG as u32);
let spqlios_res = plan.spqlios.poly_mul_1024(&a, &b);
let res = poly_mul(&a.to_vec(), &b.to_vec());
for i in 0..1024 {
let diff = res[i] as i32 - spqlios_res[i] as i32;
assert!(diff < 2 && diff > -2);
}
}
} | rust_cleaned_test_functions.jsonl/109567 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 419
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10123,
6905,
436,
36133,
24944,
62,
16,
15,
17,
19,
368,
341,
286,
1077,
5206,
3119,
284,
60036,
20485,
486,
931,
7,
16,
15,
17,
19,
317,
286,
1077,
5206,
28422,
284,
10382,
486,
4528,
66849,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_register_int_counter_vec() {
use crate::Registry;
use std::collections::HashMap;
let opts = opts!("test_opts_int_counter_vec_1", "help");
let res = register_int_counter_vec!(opts, &["a", "b"]);
assert!(res.is_ok());
let res = register_int_counter_vec!("test_opts_int_counter_vec_2", "help", &["a", "b"]);
assert!(res.is_ok());
let opts = opts!("test_opts_int_counter_vec_3", "help",);
let res = register_int_counter_vec!(opts, &["a", "b"],);
assert!(res.is_ok());
let res = register_int_counter_vec!("test_opts_int_counter_vec_4", "help", &["a", "b"],);
assert!(res.is_ok());
let mut labels = HashMap::new();
labels.insert("mykey".to_string(), "myvalue".to_string());
let custom_registry = Registry::new_custom(Some("myprefix".to_string()), Some(labels)).unwrap();
let opts = opts!("test_opts_int_counter_vec_1", "help");
let res = register_int_counter_vec_with_registry!(opts, &["a", "b"], custom_registry);
assert!(res.is_ok());
let res = register_int_counter_vec_with_registry!(
"test_opts_int_counter_vec_2",
"help",
&["a", "b"],
custom_registry
);
assert!(res.is_ok());
let opts = opts!("test_opts_int_counter_vec_3", "help");
let res = register_int_counter_vec_with_registry!(opts, &["a", "b"], custom_registry,);
assert!(res.is_ok());
let res = register_int_counter_vec_with_registry!(
"test_opts_int_counter_vec_4",
"help",
&["a", "b"],
custom_registry,
);
assert!(res.is_ok());
} | rust_cleaned_test_functions.jsonl/86368 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 715
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14000,
4042,
15730,
13251,
368,
341,
262,
990,
17717,
486,
15603,
280,
262,
990,
1460,
486,
51137,
486,
18497,
401,
262,
1077,
12185,
284,
12185,
17223,
1944,
32354,
4042,
15730,
13251,
62,
16,
49... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_stemming_filter() {
assert_eq!(
vec![
"d".to_string(),
"e".to_string(),
"f".to_string(),
"g".to_string(),
],
helper("a b c d e f g")
);
} | rust_cleaned_test_functions.jsonl/33311 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 189
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1261,
336,
5311,
8727,
368,
341,
286,
2060,
10714,
33673,
310,
7486,
90515,
394,
330,
67,
3263,
983,
3904,
3148,
394,
330,
68,
3263,
983,
3904,
3148,
394,
330,
69,
3263,
983,
3904,
3148,
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... | 1 |
#[test]
fn test_doc_comment_of_items() {
let file = SourceFile::parse(
r#"
//! doc
// non-doc
mod foo {}
"#,
)
.ok()
.unwrap();
let module = file.syntax().descendants().find_map(Module::cast).unwrap();
assert_eq!("doc", module.doc_comment_text().unwrap());
} | rust_cleaned_test_functions.jsonl/50910 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 160
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18869,
17638,
3575,
12134,
368,
341,
262,
1077,
1034,
284,
8748,
1703,
486,
6400,
1006,
286,
435,
2,
698,
286,
17664,
4629,
198,
286,
442,
2477,
11527,
198,
286,
1463,
15229,
5613,
286,
5869,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_nanosecond() {
assert_eq!(nanosecond("nanoseconds"), Ok(("", "nanoseconds")));
assert_eq!(nanosecond("nanosecond"), Ok(("", "nanosecond")));
assert_eq!(nanosecond("ns"), Ok(("", "ns")));
} | rust_cleaned_test_functions.jsonl/71149 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 131
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
73936,
960,
1297,
368,
341,
310,
2060,
10714,
10297,
18759,
960,
1297,
445,
18759,
75889,
3975,
7622,
7,
19814,
330,
18759,
75889,
17621,
310,
2060,
10714,
10297,
18759,
960,
1297,
445,
18759,
960,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_insert_soa() {
let name = Name::from_str("example.com.").unwrap();
let record_type = RecordType::SOA;
let mut rr_set = RecordSet::new(&name, record_type, 0);
let insert = Record::new()
.set_name(name.clone())
.set_ttl(3600)
.set_rr_type(RecordType::SOA)
.set_dns_class(DNSClass::IN)
.set_rdata(RData::SOA(SOA::new(
Name::from_str("sns.dns.icann.org.").unwrap(),
Name::from_str("noc.dns.icann.org.").unwrap(),
2015082403,
7200,
3600,
1209600,
3600,
)))
.clone();
let same_serial = Record::new()
.set_name(name.clone())
.set_ttl(3600)
.set_rr_type(RecordType::SOA)
.set_dns_class(DNSClass::IN)
.set_rdata(RData::SOA(SOA::new(
Name::from_str("sns.dns.icann.net.").unwrap(),
Name::from_str("noc.dns.icann.net.").unwrap(),
2015082403,
7200,
3600,
1209600,
3600,
)))
.clone();
let new_serial = Record::new()
.set_name(name.clone())
.set_ttl(3600)
.set_rr_type(RecordType::SOA)
.set_dns_class(DNSClass::IN)
.set_rdata(RData::SOA(SOA::new(
Name::from_str("sns.dns.icann.net.").unwrap(),
Name::from_str("noc.dns.icann.net.").unwrap(),
2015082404,
7200,
3600,
1209600,
3600,
)))
.clone();
assert!(rr_set.insert(insert.clone(), 0));
assert!(rr_set.records_without_rrsigs().any(|ref x| x == &&insert));
// same serial number
assert!(!rr_set.insert(same_serial.clone(), 0));
assert!(rr_set.records_without_rrsigs().any(|ref x| x == &&insert));
assert!(!rr_set
.records_without_rrsigs()
.any(|ref x| x == &&same_serial));
assert!(rr_set.insert(new_serial.clone(), 0));
assert!(!rr_set.insert(same_serial.clone(), 0));
assert!(!rr_set.insert(insert.clone(), 0));
assert!(rr_set
.records_without_rrsigs()
.any(|ref x| x == &&new_serial));
assert!(!rr_set.records_without_rrsigs().any(|ref x| x == &&insert));
assert!(!rr_set
.records_without_rrsigs()
.any(|ref x| x == &&same_serial));
} | rust_cleaned_test_functions.jsonl/119978 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1542
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17678,
643,
19533,
368,
341,
286,
1077,
829,
284,
3988,
486,
1499,
2895,
445,
8687,
905,
98401,
15454,
543,
286,
1077,
3255,
1819,
284,
13583,
929,
486,
13880,
32,
280,
286,
1077,
5206,
34393,
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... | 7 |
#[test]
fn test_nnz_zip_iter() {
let vec1 = test_vec1();
let vec2 = test_vec2();
let mut iter = vec1.iter().nnz_zip(vec2.iter());
assert_eq!(iter.next().unwrap(), (0, &0., &0.5));
assert_eq!(iter.next().unwrap(), (4, &4., &4.5));
assert_eq!(iter.next().unwrap(), (7, &7., &7.5));
assert!(iter.next().is_none());
} | rust_cleaned_test_functions.jsonl/3966 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 200
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1089,
50824,
42131,
11723,
368,
341,
286,
1077,
7486,
16,
284,
1273,
13251,
16,
543,
286,
1077,
7486,
17,
284,
1273,
13251,
17,
543,
286,
1077,
5206,
5367,
284,
7486,
16,
19471,
1005,
7370,
89,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_cli_get_config_unknown_field_json() {
let json = r#"{
"unknown": "unknown"
}"#;
let mut tmpfile = NamedTempFile::new().expect("Failed to create tmp file");
writeln!(tmpfile, "{}", json).expect("Failed to write to tmp file");
let cli = Cli {
config: tmpfile.path().to_owned(),
verbose: true,
};
let result = cli.get_config();
let config = result.unwrap();
let expected_config = Config::default();
assert_eq!(config, expected_config);
} | rust_cleaned_test_functions.jsonl/115807 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 271
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
47147,
3062,
5332,
57507,
5013,
9455,
368,
341,
286,
1077,
2951,
284,
435,
55543,
515,
310,
330,
16088,
788,
330,
16088,
698,
286,
335,
57676,
401,
286,
1077,
5206,
4174,
1192,
284,
40459,
12151,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_enums() {
test_enum16::<ProtocolVersion>(ProtocolVersion::SSLv2, ProtocolVersion::TLSv1_3);
test_enum8::<HashAlgorithm>(HashAlgorithm::NONE, HashAlgorithm::SHA512);
test_enum8::<SignatureAlgorithm>(SignatureAlgorithm::Anonymous, SignatureAlgorithm::ECDSA);
test_enum8::<ClientCertificateType>(
ClientCertificateType::RSASign,
ClientCertificateType::ECDSAFixedECDH,
);
test_enum8::<Compression>(Compression::Null, Compression::LSZ);
test_enum8::<ContentType>(ContentType::ChangeCipherSpec, ContentType::Heartbeat);
test_enum8::<HandshakeType>(HandshakeType::HelloRequest, HandshakeType::MessageHash);
test_enum8::<AlertLevel>(AlertLevel::Warning, AlertLevel::Fatal);
test_enum8::<AlertDescription>(
AlertDescription::CloseNotify,
AlertDescription::NoApplicationProtocol,
);
test_enum8::<HeartbeatMessageType>(
HeartbeatMessageType::Request,
HeartbeatMessageType::Response,
);
test_enum16::<ExtensionType>(ExtensionType::ServerName, ExtensionType::RenegotiationInfo);
test_enum8::<ServerNameType>(ServerNameType::HostName, ServerNameType::HostName);
test_enum16::<NamedCurve>(
NamedCurve::sect163k1,
NamedCurve::arbitrary_explicit_char2_curves,
);
test_enum16::<NamedGroup>(NamedGroup::secp256r1, NamedGroup::FFDHE8192);
test_enum16::<CipherSuite>(
CipherSuite::TLS_NULL_WITH_NULL_NULL,
CipherSuite::SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA,
);
test_enum8::<ECPointFormat>(
ECPointFormat::Uncompressed,
ECPointFormat::ANSIX962CompressedChar2,
);
test_enum8::<HeartbeatMode>(
HeartbeatMode::PeerAllowedToSend,
HeartbeatMode::PeerNotAllowedToSend,
);
test_enum8::<ECCurveType>(ECCurveType::ExplicitPrime, ECCurveType::NamedCurve);
test_enum16::<SignatureScheme>(SignatureScheme::RSA_PKCS1_SHA1, SignatureScheme::ED448);
test_enum8::<PSKKeyExchangeMode>(PSKKeyExchangeMode::PSK_KE, PSKKeyExchangeMode::PSK_DHE_KE);
test_enum8::<KeyUpdateRequest>(
KeyUpdateRequest::UpdateNotRequested,
KeyUpdateRequest::UpdateRequested,
);
test_enum8::<CertificateStatusType>(CertificateStatusType::OCSP, CertificateStatusType::OCSP);
} | rust_cleaned_test_functions.jsonl/54855 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 910
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6205,
6237,
368,
341,
262,
1273,
31054,
16,
21,
27638,
20689,
5637,
2235,
20689,
5637,
486,
22594,
85,
17,
11,
24572,
5637,
486,
45439,
85,
16,
62,
18,
317,
262,
1273,
31054,
23,
27638,
6370,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_emit_jcc_unsigned_less_or_equal() {
let mut buf = MacroAssembler::new();
let lbl = buf.create_label();
emit_jcc(&mut buf, CondCode::UnsignedLessEq, lbl);
emit_nop(&mut buf);
buf.bind_label(lbl);
assert_eq!(vec![0x0f, 0x86, 1, 0, 0, 0, 0x90], buf.data());
} | rust_cleaned_test_functions.jsonl/85434 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 173
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
69082,
5374,
638,
67830,
50747,
8734,
11478,
368,
341,
286,
1077,
5206,
6607,
284,
53317,
77858,
486,
931,
543,
286,
1077,
16421,
284,
6607,
2520,
6106,
543,
286,
16691,
5374,
638,
2099,
6984,
660... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_next() {
let mut atr = AverageTrueRange::new(3).unwrap();
let bar1 = Bar::new().high(10).low(7.5).close(9);
let bar2 = Bar::new().high(11).low(9).close(9.5);
let bar3 = Bar::new().high(9).low(5).close(8);
assert_eq!(atr.next(&bar1), 2.5);
assert_eq!(atr.next(&bar2), 2.25);
assert_eq!(atr.next(&bar3), 3.375);
} | rust_cleaned_test_functions.jsonl/23547 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 209
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11257,
368,
341,
286,
1077,
5206,
29570,
284,
23565,
2514,
6046,
486,
931,
7,
18,
568,
15454,
1428,
286,
1077,
3619,
16,
284,
4716,
486,
931,
1005,
11892,
7,
16,
15,
568,
10303,
7,
22,
13,
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_empty_body() {
::init_log();
// empty body contains closing boundary only
let mut body: &[u8] = b"--boundary--";
let ref mut buf = String::new();
let mut reader = BoundaryReader::from_reader(&mut body, BOUNDARY);
debug!("Consume 1");
assert_eq!(reader.consume_boundary().unwrap(), false);
debug!("Read 1");
let _ = reader.read_to_string(buf).unwrap();
assert_eq!(buf, "");
buf.clear();
debug!("Consume 2");
assert_eq!(reader.consume_boundary().unwrap(), false);
} | rust_cleaned_test_functions.jsonl/80589 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 270
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15124,
14114,
368,
341,
286,
3504,
2327,
5224,
1428,
286,
442,
4287,
2487,
5610,
15316,
18732,
1172,
198,
286,
1077,
5206,
2487,
25,
44590,
84,
23,
60,
284,
293,
74757,
65180,
313,
3302,
286,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_drain_fused() {
let mut list: VecList<i32> = VecList::new();
list.push_back(0);
let mut drain = list.drain();
assert_eq!(drain.next(), Some(0));
assert_eq!(drain.next(), None);
assert_eq!(drain.next(), None);
assert_eq!(drain.next(), None);
} | rust_cleaned_test_functions.jsonl/11488 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 165
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26680,
466,
761,
2591,
368,
341,
286,
1077,
5206,
1140,
25,
11312,
852,
21897,
18,
17,
29,
284,
11312,
852,
486,
931,
543,
286,
1140,
2552,
3895,
7,
15,
317,
286,
1077,
5206,
23727,
284,
1140,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_protoentry_all_supported_single_protocol_single_version() {
let protocol: UnvalidatedProtoEntry = "Cons=1".parse().unwrap();
let unsupported: Option<UnvalidatedProtoEntry> = protocol.all_supported();
assert_eq!(true, unsupported.is_none());
} | rust_cleaned_test_functions.jsonl/5151 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 113
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
37689,
4085,
5705,
57885,
19487,
34880,
19487,
9438,
368,
341,
286,
1077,
11507,
25,
1230,
59590,
31549,
5874,
284,
330,
15220,
28,
16,
3263,
6400,
1005,
15454,
543,
286,
1077,
40409,
25,
6959,
27... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_override_works_with_default() {
let toml = r#"
use_small_heuristics = "Default"
array_width = 20
attr_fn_like_width = 40
chain_width = 20
fn_call_width = 90
single_line_if_else_max_width = 40
struct_lit_width = 30
struct_variant_width = 34
"#;
let config = Config::from_toml(toml, Path::new("")).unwrap();
assert_eq!(config.array_width(), 20);
assert_eq!(config.attr_fn_like_width(), 40);
assert_eq!(config.chain_width(), 20);
assert_eq!(config.fn_call_width(), 90);
assert_eq!(config.single_line_if_else_max_width(), 40);
assert_eq!(config.struct_lit_width(), 30);
assert_eq!(config.struct_variant_width(), 34);
} | rust_cleaned_test_functions.jsonl/130648 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 488
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
48576,
11498,
82,
6615,
9993,
368,
341,
310,
1077,
311,
1014,
284,
435,
2,
698,
394,
990,
31966,
41876,
324,
5589,
284,
330,
3675,
698,
394,
1334,
7927,
284,
220,
17,
15,
198,
394,
6376,
15246... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parser_bytestring() {
let line = ".byte \"foo bar baz\"";
let stmt = parse_statement(line).expect("failed to parse statement");
let printed = format!("{}", stmt);
assert_eq!(".byte \"foo bar baz\"", printed.trim());
} | rust_cleaned_test_functions.jsonl/77742 | {
"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,
18517,
3710,
1944,
12640,
368,
341,
286,
1077,
1555,
284,
5933,
3782,
7245,
7975,
3619,
50247,
95349,
286,
1077,
20020,
284,
4715,
37404,
8797,
568,
17119,
445,
16091,
311,
4715,
5114,
797,
286,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_ecdsa_p256() {
generic_test(
confg_toml(),
"tests/named_test_configs/dnssec/ecdsa_p256.pem",
KeyFormat::Pem,
Algorithm::ECDSAP256SHA256,
);
} | rust_cleaned_test_functions.jsonl/110028 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 115
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36844,
96780,
620,
17,
20,
21,
368,
341,
262,
13954,
4452,
1006,
286,
2335,
70,
528,
316,
75,
3148,
286,
330,
23841,
9612,
3606,
4452,
59150,
3446,
4412,
5024,
73058,
96780,
620,
17,
20,
21,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_int_lit() {
match int_lit().easy_parse("$1234") {
Ok((num, _)) => assert_eq!(num, 1234i16),
Err(_) => assert!(false),
}
match int_lit().easy_parse("-$1234") {
Ok((num, _)) => assert_eq!(num, -1234i16),
Err(_) => assert!(false),
}
/* Overflow */
match int_lit().easy_parse("$1234343298473984") {
Ok(_) => assert!(false),
Err(_) => {}
}
match int_lit().easy_parse("-$1234343298473984") {
Ok(_) => assert!(false),
Err(_) => {}
}
} | rust_cleaned_test_functions.jsonl/103367 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 351
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4042,
98399,
368,
341,
286,
2432,
526,
98399,
1005,
45022,
21039,
20912,
16,
17,
18,
19,
899,
341,
310,
7622,
1188,
2413,
11,
716,
593,
589,
2060,
10714,
10297,
2413,
11,
220,
16,
17,
18,
19,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
#[test]
fn test_from_str_without_assembly() -> Result<(), ParseError> {
let s = r#"##fileformat=VCFv4.3
#CHROM POS ID REF ALT QUAL FILTER INFO
"#;
let header = parse(s)?;
assert!(header.assembly().is_none());
Ok(())
} | rust_cleaned_test_functions.jsonl/62671 | {
"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,
5673,
2895,
39904,
11898,
5642,
368,
1464,
5714,
68843,
14775,
1454,
29,
341,
286,
1077,
274,
284,
435,
55543,
565,
1192,
2243,
28,
53,
9650,
85,
19,
13,
18,
198,
2,
2149,
3361,
197,
17456,
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... | 2 |
#[test]
fn test_extend2() {
let cmd = RelayCmd::EXTEND2;
assert_eq!(Into::<u8>::into(cmd), 14_u8);
// TODO: test one with more link specifiers.
let body =
"02
00 06 7F0000011388
02 14 03479E93EBF3FF2C58C1C9DBF2DE9DE9C2801B3E
0002 0054
03479E93EBF3FF2C58C1C9DBF2DE9DE9C2801B3E36A3E0BDB1F1A10579820243DD2E228B902940EB49EF842646E3926768C28410074BEE50A535116D657C6BFB7E5114119DC69F05DF907EF62002EA782B0A357F";
let handshake = hex::decode("03479E93EBF3FF2C58C1C9DBF2DE9DE9C2801B3E36A3E0BDB1F1A10579820243DD2E228B902940EB49EF842646E3926768C28410074BEE50A535116D657C6BFB7E5114119DC69F05DF907EF62002EA782B0A357F").unwrap();
let rsa =
RsaIdentity::from_bytes(&hex::decode("03479E93EBF3FF2C58C1C9DBF2DE9DE9C2801B3E").unwrap())
.unwrap();
let addr = "127.0.0.1:5000".parse::<SocketAddr>().unwrap();
let ls = vec![addr.into(), rsa.into()];
msg(
cmd,
body,
&msg::Extend2::new(ls, 2, handshake.clone()).into(),
);
let message = decode(cmd, &unhex(body)[..]).unwrap();
if let msg::RelayMsg::Extend2(message) = message {
assert_eq!(message.handshake_type(), 2);
assert_eq!(message.handshake(), &handshake[..]);
} else {
panic!("that wasn't an extend2");
}
} | rust_cleaned_test_functions.jsonl/66343 | {
"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,
70265,
17,
368,
341,
262,
1077,
5439,
284,
46172,
15613,
486,
5722,
4689,
17,
280,
262,
2060,
10714,
10297,
26591,
27638,
84,
23,
6831,
18122,
14160,
701,
220,
16,
19,
7300,
23,
626,
262,
442,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_add_fixed_dim_error_fixed_dim_with_zero_size() {
const DIM_NAME: &str = "dim_1";
const DIM_SIZE: usize = 0;
let mut data_set = DataSet::new();
assert_eq!(0, data_set.num_dims());
assert_eq!(false, data_set.has_dim(DIM_NAME));
assert_eq!(None, data_set.dim_size(DIM_NAME));
assert_eq!(None, data_set.dim_type(DIM_NAME));
assert_eq!(
InvalidDataSet::FixedDimensionWithZeroSize(String::from(DIM_NAME)),
data_set.add_fixed_dim(DIM_NAME, DIM_SIZE).unwrap_err()
);
assert_eq!(0, data_set.num_dims());
assert_eq!(false, data_set.has_dim(DIM_NAME));
assert_eq!(None, data_set.dim_size(DIM_NAME));
assert_eq!(None, data_set.dim_type(DIM_NAME));
} | rust_cleaned_test_functions.jsonl/40523 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 434
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
37839,
10791,
4096,
37839,
10791,
6615,
19359,
2368,
368,
1476,
262,
733,
50859,
4708,
25,
609,
495,
284,
330,
12927,
62,
16,
876,
262,
733,
50859,
4098,
25,
22301,
284,
220,
15,
401,
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_concat_primitive_arrays() -> Result<()> {
let arr = concat(&[
&PrimitiveArray::<Int64Type>::from(vec![
Some(-1),
Some(-1),
Some(2),
None,
None,
]),
&PrimitiveArray::<Int64Type>::from(vec![
Some(101),
Some(102),
Some(103),
None,
]),
&PrimitiveArray::<Int64Type>::from(vec![Some(256), Some(512), Some(1024)]),
])?;
let expected_output = Arc::new(PrimitiveArray::<Int64Type>::from(vec![
Some(-1),
Some(-1),
Some(2),
None,
None,
Some(101),
Some(102),
Some(103),
None,
Some(256),
Some(512),
Some(1024),
])) as ArrayRef;
assert_eq!(&arr, &expected_output);
Ok(())
} | rust_cleaned_test_functions.jsonl/25089 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 622
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
57478,
84087,
68983,
368,
1464,
5714,
71698,
341,
286,
1077,
2890,
284,
33720,
2099,
9640,
310,
609,
33313,
1857,
27638,
1072,
21,
19,
929,
6831,
1499,
25592,
90515,
394,
4329,
4080,
16,
1326,
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... | 2 |
#[test]
fn test_double_spend_inputs() {
let (tx1, _, _) = tx!(MicroTari(5_000), fee: MicroTari(50), inputs: 1, outputs: 1);
const INPUT_AMOUNT: MicroTari = MicroTari(5_000);
let (tx2, inputs, _) = tx!(INPUT_AMOUNT, fee: MicroTari(20), inputs: 1, outputs: 1);
let test_params = TestParams::new();
let mut stx_builder = SenderTransactionProtocol::builder(0);
stx_builder
.with_lock_height(0)
.with_fee_per_gram(20.into())
.with_offset(Default::default())
.with_private_nonce(test_params.nonce.clone())
.with_change_secret(test_params.change_key.clone());
// Double spend the input from tx2 in tx3
let double_spend_utxo = tx2.body.inputs().first().unwrap().clone();
let double_spend_input = inputs.first().unwrap().clone();
let estimated_fee = Fee::calculate(20.into(), 1, 1, 1);
let utxo = UnblindedOutput::new(INPUT_AMOUNT - estimated_fee, test_params.spend_key.clone(), None);
stx_builder
.with_input(double_spend_utxo, double_spend_input)
.with_output(utxo);
let factories = CryptoFactories::default();
let mut stx_protocol = stx_builder.build::<HashDigest>(&factories).unwrap();
stx_protocol.finalize(KernelFeatures::empty(), &factories).unwrap();
let tx3 = stx_protocol.get_transaction().unwrap().clone();
let tx1 = Arc::new(tx1);
let tx2 = Arc::new(tx2);
let tx3 = Arc::new(tx3);
let mut unconfirmed_pool = UnconfirmedPool::new(UnconfirmedPoolConfig {
storage_capacity: 4,
weight_tx_skip_count: 3,
});
unconfirmed_pool
.insert_txs(vec![tx1.clone(), tx2.clone(), tx3.clone()])
.unwrap();
assert_eq!(unconfirmed_pool.len(), 3);
let desired_weight = tx1.calculate_weight() + tx2.calculate_weight() + tx3.calculate_weight() + 1000;
let selected_txs = unconfirmed_pool.highest_priority_txs(desired_weight).unwrap();
assert!(selected_txs.contains(&tx1));
// Whether tx2 or tx3 is selected is non-deterministic
assert!(selected_txs.contains(&tx2) ^ selected_txs.contains(&tx3));
assert_eq!(selected_txs.len(), 2);
} | rust_cleaned_test_functions.jsonl/131751 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1048
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
24598,
643,
3740,
28557,
368,
341,
286,
1077,
320,
3998,
16,
11,
8358,
27439,
284,
9854,
10297,
34609,
51,
2780,
7,
20,
62,
15,
15,
15,
701,
11060,
25,
18157,
51,
2780,
7,
20,
15,
701,
11127... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_that_cpp_code_compiles_and_demo_runs() {
let registry = get_starcoin_registry();
let abis = get_stdlib_script_abis();
let dir = tempdir().unwrap();
let installer = serdegen::cpp::Installer::new(dir.path().to_path_buf());
// lcs_installer
let config = serdegen::CodeGeneratorConfig::new("starcoin_types".to_string())
.with_encodings(vec![serdegen::Encoding::Bcs, serdegen::Encoding::Bincode]);
installer.install_module(&config, ®istry).unwrap();
let abi_installer = buildgen::cpp::Installer::new(dir.path().to_path_buf());
abi_installer
.install_transaction_builders("starcoin_stdlib", &abis)
.unwrap();
std::fs::copy(
"examples/cpp/stdlib_demo.cpp",
dir.path().join("stdlib_demo.cpp"),
)
.unwrap();
let status = Command::new("clang++")
.arg("--std=c++17")
.arg("-g")
.arg(dir.path().join("starcoin_stdlib.cpp"))
.arg(dir.path().join("stdlib_demo.cpp"))
.arg("-o")
.arg(dir.path().join("stdlib_demo"))
.status()
.unwrap();
assert!(status.success());
let output = Command::new(dir.path().join("stdlib_demo"))
.output()
.unwrap();
assert!(output.status.success());
assert_eq!(std::str::from_utf8(&output.stdout).unwrap(), OUTPUT);
} | rust_cleaned_test_functions.jsonl/73567 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 621
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
70197,
59686,
4136,
18177,
3658,
8378,
47830,
67352,
368,
341,
262,
1077,
19424,
284,
633,
31681,
7160,
50650,
543,
262,
1077,
668,
285,
284,
633,
15656,
2740,
14660,
62,
15367,
543,
262,
1077,
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_slice_from() {
let vec: &[int] = &[1, 2, 3, 4];
assert_eq!(vec[0..], vec);
let b: &[int] = &[3, 4];
assert_eq!(vec[2..], b);
let b: &[int] = &[];
assert_eq!(vec[4..], b);
} | rust_cleaned_test_functions.jsonl/31829 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 151
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26488,
5673,
368,
341,
286,
1077,
7486,
25,
44590,
396,
60,
284,
44590,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
935,
286,
2060,
10714,
10297,
4083,
58,
15,
496,
1125,
7486,
317,
286,
1077... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_redc() {
let a = u256h!("0548c135e26faa9c977fb2eda057b54b2e0baa9a77a0be7c80278f4f03462d4c");
let b = u256h!("024385f6bebc1c496e09955db534ef4b1eaff9a78e27d4093cfa8f7c8f886f6b");
let c = u256h!("012e440f0965e7029c218b64f1010006b5c4ba8b1497c4174a32fec025c197bc");
assert_eq!(redc_inline::<PrimeField>(&a, &b), c);
} | rust_cleaned_test_functions.jsonl/52049 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 225
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26058,
66,
368,
341,
286,
1077,
264,
284,
575,
17,
20,
21,
71,
17223,
15,
20,
19,
23,
66,
16,
18,
20,
68,
17,
21,
3632,
64,
24,
66,
24,
22,
22,
10798,
17,
13830,
15,
20,
22,
65,
20,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_which_all() {
let f = TestFixture::new();
let actual = _which_all(&f, BIN_NAME)
.unwrap()
.map(|c| c.unwrap())
.collect::<Vec<_>>();
let mut expected = f
.bins
.iter()
.map(|p| p.canonicalize().unwrap())
.collect::<Vec<_>>();
#[cfg(windows)]
{
expected.retain(|p| p.extension().map(|ext| ext == "exe" || ext == "cmd") == Some(true));
}
#[cfg(not(windows))]
{
expected.retain(|p| p.file_name().unwrap() == BIN_NAME);
}
assert_eq!(actual, expected);
} | rust_cleaned_test_functions.jsonl/13401 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 303
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
8206,
5705,
368,
341,
262,
1077,
282,
284,
3393,
18930,
486,
931,
543,
262,
1077,
5042,
284,
716,
8206,
5705,
2099,
69,
11,
82609,
4708,
340,
286,
659,
15454,
741,
286,
659,
2186,
22428,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_modpow_big() {
let b = BigInt::from_str_radix(super::BIG_B, 16).unwrap();
let e = BigInt::from_str_radix(super::BIG_E, 16).unwrap();
let m = BigInt::from_str_radix(super::BIG_M, 16).unwrap();
let r = BigInt::from_str_radix(super::BIG_R, 16).unwrap();
check_modpow(b, e, m, r);
} | rust_cleaned_test_functions.jsonl/16018 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 180
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7480,
21743,
36386,
368,
341,
286,
1077,
293,
284,
62608,
486,
1499,
2895,
39764,
941,
56040,
486,
67017,
1668,
11,
220,
16,
21,
568,
15454,
543,
286,
1077,
384,
284,
62608,
486,
1499,
2895,
397... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_function_with_unnamed_parameters() {
let ir = ir_from_cc("int f(int, int);").unwrap();
assert_ir_matches!(
ir,
quote! {
Func {
name: "f", ...
mangled_name: "_Z1fii", ...
params: [
FuncParam {
... identifier: "__param_0", ...
},
FuncParam {
... identifier: "__param_1", ...
},
], ...
}
}
);
} | rust_cleaned_test_functions.jsonl/37152 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 371
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9174,
6615,
4907,
30245,
18263,
368,
341,
262,
1077,
6216,
284,
6216,
5673,
28955,
445,
396,
282,
1548,
11,
526,
1215,
1827,
15454,
543,
262,
2060,
51433,
38344,
33673,
286,
6216,
345,
286,
12641,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_function_call_4() {
let input = vec![Token::Ident("f".to_string()),
Token::LParen,
Token::Integer(1),
Token::Comma,
Token::LParen,
Token::Integer(2),
Token::Plus,
Token::Integer(3),
Token::RParen,
Token::RParen];
let stmt = parse(&input).unwrap();
assert_eq!(stmt,
Stmt::Eval(Expr::FunCall("f".to_string(),
Box::new(vec![integer_expr(1),
Expr::Plus(integer_expr(2).boxed(), integer_expr(3).boxed())]))));
} | rust_cleaned_test_functions.jsonl/55684 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 519
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
9174,
13429,
62,
19,
368,
341,
1789,
286,
1077,
1946,
284,
7486,
20703,
3323,
486,
28301,
445,
69,
3263,
983,
3904,
14702,
5108,
9660,
486,
12567,
9151,
345,
5108,
9660,
486,
3486,
7,
16,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_iskoola() {
run_test(
&TEST_DATA,
"harfbuzz/good-iskoola.si",
"sinhala/iskpota.ttf",
&[JOINER_GLYPH_INDEX],
2110,
);
} | rust_cleaned_test_functions.jsonl/91191 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 214
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
3187,
45980,
368,
341,
394,
1598,
4452,
1006,
503,
609,
10033,
7896,
345,
503,
330,
12982,
10798,
8889,
4846,
1386,
12,
3187,
45980,
91132,
756,
503,
330,
15940,
71,
6053,
14,
3187,
79,
6089... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_mag_from_declination() {
// verify that the output of mag_field_from_declination_inclination matches expected from NOAA
for i in 0..ALL_SAMPLE_CITIES.len() {
let (estimated, expected) = gen_mag_comparison_pair(&ALL_SAMPLE_CITIES[i]);
assert_approx_eq!(estimated[0], expected[0], 2.0e-6);
assert_approx_eq!(estimated[1], expected[1], 2.0e-6);
assert_approx_eq!(estimated[2], expected[2], 2.0e-6);
}
} | rust_cleaned_test_functions.jsonl/18364 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 238
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
48310,
5673,
35814,
2554,
368,
341,
286,
442,
10146,
429,
279,
2550,
315,
4878,
5013,
5673,
35814,
2554,
1243,
564,
2554,
9071,
3601,
504,
85648,
271,
286,
369,
600,
304,
220,
15,
496,
3919,
414... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_object_store_url() {
let listing = ListingTableUrl::parse("file:///").unwrap();
let store = listing.object_store();
assert_eq!(store.as_str(), "file:///");
let file = ObjectStoreUrl::parse("file://").unwrap();
assert_eq!(file.as_str(), "file:///");
let listing = ListingTableUrl::parse("s3://bucket/").unwrap();
let store = listing.object_store();
assert_eq!(store.as_str(), "s3://bucket/");
let url = ObjectStoreUrl::parse("s3://bucket").unwrap();
assert_eq!(url.as_str(), "s3://bucket/");
let url = ObjectStoreUrl::parse("s3://username:password@host:123").unwrap();
assert_eq!(url.as_str(), "s3://username:password@host:123/");
let err = ObjectStoreUrl::parse("s3://bucket:invalid").unwrap_err();
assert_eq!(err.to_string(), "External error: invalid port number");
let err = ObjectStoreUrl::parse("s3://bucket?").unwrap_err();
assert_eq!(err.to_string(), "Execution error: ObjectStoreUrl must only contain scheme and authority, got: ?");
let err = ObjectStoreUrl::parse("s3://bucket?foo=bar").unwrap_err();
assert_eq!(err.to_string(), "Execution error: ObjectStoreUrl must only contain scheme and authority, got: ?foo=bar");
let err = ObjectStoreUrl::parse("s3://host:123/foo").unwrap_err();
assert_eq!(err.to_string(), "Execution error: ObjectStoreUrl must only contain scheme and authority, got: /foo");
let err =
ObjectStoreUrl::parse("s3://username:password@host:123/foo").unwrap_err();
assert_eq!(err.to_string(), "Execution error: ObjectStoreUrl must only contain scheme and authority, got: /foo");
} | rust_cleaned_test_functions.jsonl/96527 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 682
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5314,
14809,
2903,
368,
341,
286,
1077,
14838,
284,
38764,
2556,
2864,
486,
6400,
445,
1192,
60896,
1827,
15454,
543,
286,
1077,
3553,
284,
14838,
6035,
14809,
543,
286,
2060,
10714,
10297,
4314,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_array() {
mod zerocopy {
pub use crate::*;
}
#[derive(FromBytes, AsBytes)]
#[repr(C)]
struct Foo {
a: [u16; 33],
}
let foo = Foo { a: [0xFFFF; 33] };
let expected = [0xFFu8; 66];
assert_eq!(foo.as_bytes(), &expected[..]);
} | rust_cleaned_test_functions.jsonl/18904 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 213
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3858,
368,
341,
1789,
286,
1463,
76178,
509,
1266,
341,
310,
6675,
990,
17717,
56162,
286,
456,
286,
11506,
27098,
7,
3830,
7078,
11,
1634,
7078,
5563,
286,
11506,
30837,
3025,
5563,
286,
2036,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_is_unicast_in_subnet() {
// Valid unicast in subnet
assert!(Ipv4Addr::new([1, 2, 3, 4])
.is_unicast_in_subnet(&Subnet::new(Ipv4Addr::new([1, 2, 0, 0]), 16).unwrap()));
assert!(Ipv6Addr::new([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
.is_unicast_in_subnet(
&Subnet::new(Ipv6Addr::new([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 64)
.unwrap()
));
// Unspecified address
assert!(!Ipv4::UNSPECIFIED_ADDRESS
.is_unicast_in_subnet(&Subnet::new(Ipv4::UNSPECIFIED_ADDRESS, 16).unwrap()));
assert!(!Ipv6::UNSPECIFIED_ADDRESS
.is_unicast_in_subnet(&Subnet::new(Ipv6::UNSPECIFIED_ADDRESS, 64).unwrap()));
// The "31- or 32-bit prefix" exception doesn't apply to the unspecified
assert!(!Ipv4::UNSPECIFIED_ADDRESS
.is_unicast_in_subnet(&Subnet::new(Ipv4::UNSPECIFIED_ADDRESS, 31).unwrap()));
assert!(!Ipv4::UNSPECIFIED_ADDRESS
.is_unicast_in_subnet(&Subnet::new(Ipv4::UNSPECIFIED_ADDRESS, 32).unwrap()));
assert!(!Ipv4Addr::new([1, 2, 0, 0])
.is_unicast_in_subnet(&Subnet::new(Ipv4Addr::new([1, 2, 0, 0]), 16).unwrap()));
assert!(Ipv4Addr::new([1, 2, 3, 0])
.is_unicast_in_subnet(&Subnet::new(Ipv4Addr::new([1, 2, 3, 0]), 31).unwrap()));
assert!(Ipv4Addr::new([1, 2, 3, 0])
.is_unicast_in_subnet(&Subnet::new(Ipv4Addr::new([1, 2, 3, 0]), 32).unwrap()));
assert!(!Ipv4::GLOBAL_BROADCAST_ADDRESS
.into_addr()
.is_unicast_in_subnet(&Subnet::new(Ipv4Addr::new([128, 0, 0, 0]), 1).unwrap()));
assert!(!Ipv4Addr::new([1, 2, 255, 255])
.is_unicast_in_subnet(&Subnet::new(Ipv4Addr::new([1, 2, 0, 0]), 16).unwrap()));
assert!(Ipv4Addr::new([1, 2, 255, 255])
.is_unicast_in_subnet(&Subnet::new(Ipv4Addr::new([1, 2, 255, 254]), 31).unwrap()));
assert!(Ipv4Addr::new([1, 2, 255, 255])
.is_unicast_in_subnet(&Subnet::new(Ipv4Addr::new([1, 2, 255, 255]), 32).unwrap()));
// Multicast
assert!(!Ipv4Addr::new([224, 0, 0, 1]).is_unicast_in_subnet(&Ipv4::MULTICAST_SUBNET));
assert!(!Ipv6Addr::new([0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
.is_unicast_in_subnet(&Ipv6::MULTICAST_SUBNET));
assert!(!Ipv4Addr::new([240, 0, 0, 1]).is_unicast_in_subnet(&Ipv4::CLASS_E_SUBNET));
} | rust_cleaned_test_functions.jsonl/59636 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1466
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6892,
62,
3525,
559,
1243,
95681,
368,
341,
286,
442,
7818,
650,
35446,
304,
51457,
198,
286,
2060,
10297,
80656,
19,
13986,
486,
931,
2561,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
2546,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_is_pointer() {
assert_eq!(is_pointer(VALUE_F_PTR_OBJ), true);
assert_eq!(is_pointer(VALUE_F_SYM_STR), false);
assert_eq!(is_pointer(VALUE_F_SYM_OBJ), false);
assert_eq!(is_pointer(VALUE_T_PTR_STR), true);
assert_eq!(is_pointer(VALUE_T_PTR_OBJ), true);
assert_eq!(is_pointer(VALUE_T_SYM_STR), false);
assert_eq!(is_pointer(VALUE_T_SYM_OBJ), false);
} | rust_cleaned_test_functions.jsonl/109923 | {
"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,
6892,
21425,
368,
341,
197,
6948,
10714,
10297,
285,
21425,
98893,
1400,
20657,
27559,
701,
830,
317,
197,
6948,
10714,
10297,
285,
21425,
98893,
1400,
82933,
7159,
701,
895,
317,
197,
6948,
10714,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_boring_error() {
let _ = CStackWrapper::cbs_with_temp_buffer(&[], |cbs| {
should_fail(
CHeapWrapper::evp_parse_public_key(cbs),
"boringssl::EVP_parse_public_key",
"public key routines:OPENSSL_internal:DECODE_ERROR",
);
});
} | rust_cleaned_test_functions.jsonl/105167 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 191
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
880,
5503,
4096,
368,
341,
286,
1077,
716,
284,
356,
4336,
11542,
486,
66,
1279,
6615,
11771,
7776,
2099,
12995,
760,
66,
1279,
91,
341,
310,
1265,
22121,
1006,
394,
356,
27909,
11542,
486,
5120... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_arrays() {
let dict = sample_dict("abcd");
let keys = dict.keys_array();
assert_eq!(keys.len(), 1);
autoreleasepool(|pool| {
assert_eq!(keys[0].as_str(pool), "abcd");
});
} | rust_cleaned_test_functions.jsonl/108473 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 154
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
68983,
368,
341,
286,
1077,
6451,
284,
6077,
5243,
445,
68644,
3071,
286,
1077,
6894,
284,
6451,
9123,
3858,
543,
286,
2060,
10714,
10297,
10563,
19406,
1507,
220,
16,
317,
286,
74566,
10285,
2242... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_from_raw_unsized() {
use std::fmt::Display;
use std::string::ToString;
let rc: Rc<str> = Rc::from("foo");
let ptr = Rc::into_raw(rc.clone());
let rc2 = unsafe { Rc::from_raw(ptr) };
assert_eq!(unsafe { &*ptr }, "foo");
assert_eq!(rc, rc2);
let rc: Rc<dyn Display> = Rc::new(123);
let ptr = Rc::into_raw(rc.clone());
let rc2 = unsafe { Rc::from_raw(ptr) };
assert_eq!(unsafe { &*ptr }.to_string(), "123");
assert_eq!(rc2.to_string(), "123");
} | rust_cleaned_test_functions.jsonl/40037 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 244
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
45514,
5673,
16067,
4907,
82,
1506,
368,
341,
262,
990,
1460,
486,
12501,
486,
7020,
280,
262,
990,
1460,
486,
917,
486,
5870,
401,
262,
1077,
10192,
25,
81463,
27,
495,
29,
284,
81463,
486,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_create_date_time() {
let tz = Tz::Zulu;
let column =
Vec::column_from::<ArcColumnWrapper>(vec![tz.ymd(2016, 10, 22).and_hms(12, 0, 0)]);
assert_eq!(format!("{}", column.at(0)), "2016-10-22 12:00:00");
} | rust_cleaned_test_functions.jsonl/126824 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 142
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8657,
4164,
3009,
368,
341,
286,
1077,
42528,
284,
350,
89,
486,
57,
24411,
280,
286,
1077,
3250,
4035,
310,
11312,
486,
6229,
5673,
27638,
36809,
2933,
11542,
2235,
4083,
20703,
37592,
13,
1600,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_intern_key_split() {
let key1 = InternalKey {
key: "10outer_keys/inner_key".to_owned(),
};
let (outer, inner) = key1.split();
assert_eq!(outer, "outer_keys".to_owned());
assert_eq!(inner.expect("should contain inner key"), "inner_key".to_owned());
let key2 = InternalKey {
key: "05outer/inner_key".to_owned(),
};
let (outer, inner) = key2.split();
assert_eq!(outer, "outer".to_owned());
assert_eq!(inner.expect("should contain inner key"), "inner_key".to_owned());
let key3 = InternalKey {
key: "05outer".to_owned(),
};
let (outer, inner) = key3.split();
assert_eq!(outer, "outer".to_owned());
assert!(inner.is_none());
} | rust_cleaned_test_functions.jsonl/90779 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 383
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4042,
932,
3097,
17052,
368,
341,
286,
1077,
1376,
16,
284,
15412,
1592,
341,
310,
1376,
25,
330,
16,
15,
2676,
12631,
14,
4382,
3097,
3263,
983,
51973,
3148,
286,
2605,
286,
1077,
320,
2676,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_space_token() {
match space_token('h').easy_parse(" h ") {
Ok((tok, _)) => assert_eq!(tok, 'h'),
Err(_) => assert!(false),
}
} | rust_cleaned_test_functions.jsonl/103362 | {
"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,
14663,
6458,
368,
341,
286,
2432,
3550,
6458,
492,
71,
1823,
45022,
21039,
445,
256,
305,
220,
12310,
341,
310,
7622,
1188,
29594,
11,
716,
593,
589,
2060,
10714,
10297,
29594,
11,
364,
71,
3299... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_info_response() {
let (sender_name, sender_key) = get_key_pair();
let transfer = Transfer {
sender: sender_name,
recipient: Address::Primary(dbg_addr(0x20)),
amount: Amount::from(5),
sequence_number: SequenceNumber::new(),
user_data: UserData::default(),
};
let order = TransferOrder::new(transfer, &sender_key);
let (auth_name, auth_key) = get_key_pair();
let vote = SignedTransferOrder::new(order.clone(), auth_name, &auth_key);
let mut cert = CertifiedTransferOrder {
value: order,
signatures: Vec::new(),
};
for _ in 0..3 {
let (authority_name, authority_key) = get_key_pair();
let sig = Signature::new(&cert.value, &authority_key);
cert.signatures.push((authority_name, sig));
}
let resp1 = AccountInfoResponse {
sender: dbg_addr(0x20),
balance: Balance::from(50),
next_sequence_number: SequenceNumber::new(),
pending_confirmation: None,
requested_certificate: None,
requested_received_transfers: Vec::new(),
};
let resp2 = AccountInfoResponse {
sender: dbg_addr(0x20),
balance: Balance::from(50),
next_sequence_number: SequenceNumber::new(),
pending_confirmation: Some(vote.clone()),
requested_certificate: None,
requested_received_transfers: Vec::new(),
};
let resp3 = AccountInfoResponse {
sender: dbg_addr(0x20),
balance: Balance::from(50),
next_sequence_number: SequenceNumber::new(),
pending_confirmation: None,
requested_certificate: Some(cert.clone()),
requested_received_transfers: Vec::new(),
};
let resp4 = AccountInfoResponse {
sender: dbg_addr(0x20),
balance: Balance::from(50),
next_sequence_number: SequenceNumber::new(),
pending_confirmation: Some(vote),
requested_certificate: Some(cert),
requested_received_transfers: Vec::new(),
};
for resp in [resp1, resp2, resp3, resp4].iter() {
let buf = serialize_info_response(&resp);
let result = deserialize_message(buf.as_slice());
assert!(result.is_ok());
if let SerializedMessage::InfoResp(o) = result.unwrap() {
assert!(*o == *resp);
} else {
panic!()
}
}
} | rust_cleaned_test_functions.jsonl/99649 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1010
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3109,
9655,
368,
341,
262,
1077,
320,
11644,
1269,
11,
4646,
3097,
8,
284,
633,
3097,
14445,
543,
262,
1077,
8317,
284,
23200,
341,
286,
4646,
25,
4646,
1269,
345,
286,
21713,
25,
9177,
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... | 4 |
#[test]
fn test_api_deposit() {
let denom: Denomination = Denomination::from_str("TEST").unwrap();
let mut mock = mock::Mock::default();
let mut ctx = mock.create_ctx();
let mut meta = Metadata {
..Default::default()
};
let genesis = Default::default();
Module::<Accounts, Consensus>::init_or_migrate(&mut ctx, &mut meta, genesis);
let nonce = 123;
let tx = transaction::Transaction {
version: 1,
call: transaction::Call {
format: transaction::CallFormat::Plain,
method: "consensus.Deposit".to_owned(),
body: cbor::to_value(Deposit {
// separate `to` account to make sure everything is hooked up to the right places.
to: Some(keys::bob::address()),
amount: BaseUnits::new(1_000, denom.clone()),
}),
},
auth_info: transaction::AuthInfo {
signer_info: vec![transaction::SignerInfo::new_sigspec(
keys::alice::sigspec(),
nonce,
)],
fee: transaction::Fee {
amount: Default::default(),
gas: 1000,
consensus_messages: 1,
},
},
};
let hook = ctx.with_tx(0, tx, |mut tx_ctx, call| {
Module::<Accounts, Consensus>::tx_deposit(
&mut tx_ctx,
cbor::from_value(call.body).unwrap(),
)
.expect("deposit tx should succeed");
let (_, mut msgs) = tx_ctx.commit();
assert_eq!(1, msgs.len(), "one message should be emitted");
let (msg, hook) = msgs.pop().unwrap();
assert_eq!(
Message::Staking(Versioned::new(
0,
StakingMessage::Withdraw(staking::Withdraw {
from: keys::alice::address().into(),
amount: 1_000u128.into(),
})
)),
msg,
"emitted message should match"
);
assert_eq!(
CONSENSUS_WITHDRAW_HANDLER.to_string(),
hook.hook_name,
"emitted hook should match"
);
hook
});
// Simulate the message being processed and make sure withdrawal is successfully completed.
let me = Default::default();
Module::<Accounts, Consensus>::message_result_withdraw(
&mut ctx,
me,
cbor::from_value(hook.payload).unwrap(),
);
// Ensure runtime balance is updated.
let balance = Accounts::get_balance(
ctx.runtime_state(),
test::keys::bob::address(),
denom.clone(),
)
.unwrap();
assert_eq!(balance, 1_000u128, "deposited balance should be minted");
let total_supplies = Accounts::get_total_supplies(ctx.runtime_state()).unwrap();
assert_eq!(total_supplies.len(), 1);
assert_eq!(
total_supplies[&denom], 1_000u128,
"deposited balance should be minted"
);
// Make sure events were emitted.
let (etags, _) = ctx.commit();
let tags = etags.into_tags();
assert_eq!(tags.len(), 2, "deposit and mint events should be emitted");
assert_eq!(tags[0].key, b"accounts\x00\x00\x00\x03");
assert_eq!(tags[1].key, b"consensus_accounts\x00\x00\x00\x01");
// Decode deposit event.
#[derive(Debug, cbor::Decode)]
struct DepositEvent {
from: Address,
nonce: u64,
to: Address,
amount: token::BaseUnits,
#[cbor(optional)]
error: Option<types::ConsensusError>,
}
let mut events: Vec<DepositEvent> = cbor::from_slice(&tags[1].value).unwrap();
assert_eq!(events.len(), 1);
let event = events.pop().unwrap();
assert_eq!(event.from, keys::alice::address());
assert_eq!(event.nonce, nonce);
assert_eq!(event.to, keys::bob::address());
assert_eq!(event.amount.amount(), 1_000);
assert_eq!(event.amount.denomination(), &denom);
assert_eq!(event.error, None);
} | rust_cleaned_test_functions.jsonl/52595 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1877
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11697,
85798,
368,
341,
262,
1077,
49744,
25,
9774,
80380,
284,
9774,
80380,
486,
1499,
2895,
445,
10033,
1827,
15454,
543,
262,
1077,
5206,
7860,
284,
7860,
486,
11571,
486,
2258,
543,
262,
1077,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_event_chain_functions() {
::init().unwrap();
let pad = ::Pad::new(Some("sink"), ::PadDirection::Sink);
let events = Arc::new(Mutex::new(Vec::new()));
let events_clone = events.clone();
pad.set_event_function(move |_, _, event| {
let mut events = events_clone.lock().unwrap();
events.push(event);
true
});
let buffers = Arc::new(Mutex::new(Vec::new()));
let buffers_clone = buffers.clone();
pad.set_chain_function(move |_, _, buffer| {
let mut buffers = buffers_clone.lock().unwrap();
buffers.push(buffer);
Ok(FlowSuccess::Ok)
});
pad.set_active(true).unwrap();
assert!(pad.send_event(::Event::new_stream_start("test").build()));
let segment = ::FormattedSegment::<::ClockTime>::new();
assert!(pad.send_event(::Event::new_segment(segment.as_ref()).build()));
assert_eq!(pad.chain(::Buffer::new()), Ok(FlowSuccess::Ok));
let events = events.lock().unwrap();
let buffers = buffers.lock().unwrap();
assert_eq!(events.len(), 2);
assert_eq!(buffers.len(), 1);
match events[0].view() {
::EventView::StreamStart(..) => (),
_ => unreachable!(),
}
match events[1].view() {
::EventView::Segment(..) => (),
_ => unreachable!(),
}
} | rust_cleaned_test_functions.jsonl/126039 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 690
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6748,
30583,
31708,
368,
341,
286,
3504,
2327,
1005,
15454,
1428,
286,
1077,
11016,
284,
3504,
13731,
486,
931,
65405,
445,
66738,
3975,
3504,
13731,
9268,
486,
45094,
626,
286,
1077,
4357,
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... | 3 |
#[test]
fn test_legal_moves_banmen_with_gin_nari_7_squares_sente() {
test_legal_moves_banmen_with_kin_7_squares_sente_impl(SGinN)
} | rust_cleaned_test_functions.jsonl/81301 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 72
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
82324,
45390,
880,
276,
5676,
6615,
1889,
258,
1089,
2780,
62,
22,
643,
40856,
643,
6817,
368,
972,
18185,
82324,
45390,
880,
276,
5676,
6615,
4698,
258,
62,
22,
643,
40856,
643,
6817,
21007,
37... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_iterate() {
let mut m = HashMap::with_capacity(4);
for i in 0..32 {
assert!(m.insert(i, i * 2).is_none());
}
assert_eq!(m.len(), 32);
let observed = AtomicUsize::new(0);
m.par_iter().for_each(|(k, v)| {
assert_eq!(*v, *k * 2);
observed.fetch_or(1 << *k, Ordering::Relaxed);
});
assert_eq!(observed.into_inner(), 0xFFFF_FFFF);
} | rust_cleaned_test_functions.jsonl/45213 | {
"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,
11723,
349,
368,
341,
286,
1077,
5206,
296,
284,
10528,
486,
4197,
35603,
7,
19,
317,
286,
369,
600,
304,
220,
15,
496,
18,
17,
341,
310,
2060,
10297,
76,
7030,
1956,
11,
600,
353,
220,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_validate_xml_body() {
let expected = r#"<a>
hello123
</a>"#;
let actual = "<a>hello123</a>";
validate_body(&actual, expected, MediaType::Xml).expect("inputs match as XML");
let expected = r#"<a>
hello123
</a>"#;
let actual = "<a>hello124</a>";
validate_body(&actual, expected, MediaType::Xml).expect_err("inputs are different");
} | rust_cleaned_test_functions.jsonl/12138 | {
"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,
42681,
23855,
14114,
368,
341,
286,
1077,
3601,
284,
435,
2,
22476,
64,
397,
286,
23811,
16,
17,
18,
198,
286,
690,
64,
9877,
2,
280,
286,
1077,
5042,
284,
4055,
64,
29,
14990,
16,
17,
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_nested_ifs() {
let template = compile(
"{{ if boolean }}Hi, {{ if null }}there!{{ else }}Hello!{{ endif }}{{ endif }}",
);
let context = context();
let template_registry = other_templates();
let formatter_registry = formatters();
let string = template
.render(&context, &template_registry, &formatter_registry)
.unwrap();
assert_eq!("Hi, Hello!", &string);
} | rust_cleaned_test_functions.jsonl/2381 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 225
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
66279,
11119,
82,
368,
972,
286,
1077,
3811,
284,
19192,
7805,
310,
47219,
421,
2710,
3869,
13048,
11,
5867,
421,
845,
3869,
18532,
0,
2979,
770,
3869,
9707,
0,
2979,
12330,
3869,
2979,
12330,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_input_handler_left_event() {
let mut app = App::default();
app.input = str_to_vec_char("My text");
let input_len = app.input.len().try_into().unwrap();
app.input_idx = app.input.len();
app.input_cursor_position = input_len;
handler(Key::Left, &mut app);
assert_eq!(app.input_cursor_position, input_len - 1);
handler(Key::Left, &mut app);
assert_eq!(app.input_cursor_position, input_len - 2);
handler(Key::Left, &mut app);
assert_eq!(app.input_cursor_position, input_len - 3);
handler(Key::Ctrl('b'), &mut app);
assert_eq!(app.input_cursor_position, input_len - 4);
handler(Key::Ctrl('b'), &mut app);
assert_eq!(app.input_cursor_position, input_len - 5);
// Pretend to smash the left event to test the we have no out-of-bounds crash
for _ in 0..20 {
handler(Key::Left, &mut app);
}
assert_eq!(app.input_cursor_position, 0);
} | rust_cleaned_test_functions.jsonl/5102 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 384
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5898,
10183,
9579,
6748,
368,
341,
262,
1077,
5206,
906,
284,
1845,
486,
2258,
1428,
262,
906,
10046,
284,
607,
2346,
13251,
9232,
445,
5050,
1467,
797,
262,
1077,
1946,
6043,
284,
906,
10046,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_record_schema_with_currently_parsing_schema_named_enum() {
let schema = Schema::parse_str(
r#"
{
"type" : "record",
"name" : "record",
"fields" : [
{
"type" : "enum",
"name" : "enum",
"symbols": ["one", "two", "three"]
},
{ "name" : "next", "type" : "enum" }
]
}
"#,
)
.unwrap();
let mut lookup = HashMap::new();
lookup.insert("enum".to_owned(), 0);
lookup.insert("next".to_owned(), 1);
let expected = Schema::Record {
name: Name {
name: "record".to_owned(),
namespace: None,
aliases: None,
},
doc: None,
fields: vec![
RecordField {
name: "enum".to_string(),
doc: None,
default: None,
schema: Schema::Enum {
name: Name {
name: "enum".to_owned(),
namespace: None,
aliases: None,
},
doc: None,
symbols: vec!["one".to_string(), "two".to_string(), "three".to_string()],
},
order: RecordFieldOrder::Ascending,
position: 0,
},
RecordField {
name: "next".to_string(),
doc: None,
default: None,
schema: Schema::Enum {
name: Name {
name: "enum".to_owned(),
namespace: None,
aliases: None,
},
doc: None,
symbols: vec!["one".to_string(), "two".to_string(), "three".to_string()],
},
order: RecordFieldOrder::Ascending,
position: 1,
},
],
lookup,
};
assert_eq!(schema, expected);
let canonical_form = &schema.canonical_form();
let expected = r#"{"name":"record","type":"record","fields":[{"name":"enum","type":{"name":"enum","type":"enum","symbols":["one","two","three"]}},{"name":"next","type":{"name":"enum","type":"enum","symbols":["one","two","three"]}}]}"#;
assert_eq!(canonical_form, &expected);
} | rust_cleaned_test_functions.jsonl/116696 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1635
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14192,
25371,
6615,
11080,
398,
620,
28598,
25371,
71834,
31054,
368,
341,
286,
1077,
10802,
284,
12539,
486,
6400,
2895,
1006,
310,
435,
2,
698,
310,
341,
1060,
330,
1313,
1,
549,
330,
8548,
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... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.