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_restore() {
let temp_dir = TempDir::new().unwrap();
let temp_dir_str = format!("{}/", temp_dir.path().display());
let key_name_random = "test_restore_random".to_string();
let rand_opts = RandomOptions::new(key_name_random);
let name_counter = 0;
let key_orig =
crate::offline::random::create_key(&temp_dir_str, Network::Testnet, &rand_opts)
.unwrap();
let (key_name, name_counter) = (format!("{}", name_counter), name_counter + 1);
let restore_opts = RestoreOptions {
key_name,
nature: Nature::Xprv,
value: key_orig.key.xprv.to_string(),
qr_version: 14,
};
let key_restored =
crate::offline::restore::start(&temp_dir_str, Network::Testnet, &restore_opts).unwrap();
assert_eq!(key_orig.key.xprv, key_restored.key.xprv);
assert_eq!(key_orig.key.xpub, key_restored.key.xpub);
assert_ne!(key_orig.key.mnemonic, key_restored.key.mnemonic);
let (key_name, name_counter) = (format!("{}", name_counter), name_counter + 1);
let restore_opts = RestoreOptions {
key_name,
nature: Nature::Mnemonic,
value: key_orig.key.mnemonic.as_ref().unwrap().to_string(),
qr_version: 14,
};
let key_restored =
crate::offline::restore::start(&temp_dir_str, Network::Testnet, &restore_opts).unwrap();
assert_eq!(key_orig.key.xprv, key_restored.key.xprv);
assert_eq!(key_orig.key.xpub, key_restored.key.xpub);
assert_eq!(&key_orig.key.mnemonic, &key_restored.key.mnemonic);
// TODO add restore mnemonic
let (key_name, name_counter) = (format!("{}", name_counter), name_counter + 1);
let restore_opts = RestoreOptions {
key_name,
nature: Nature::Xprv,
value: "X".to_string(),
qr_version: 14,
};
let result = crate::offline::restore::start(&temp_dir_str, Network::Testnet, &restore_opts);
assert!(result.is_err());
let (key_name, _name_counter) = (format!("{}", name_counter), name_counter + 1);
let restore_opts = RestoreOptions {
key_name,
nature: Nature::Xprv,
value: key_orig.key.xpub.to_string(),
qr_version: 14,
};
let result = crate::offline::restore::start(&temp_dir_str, Network::Testnet, &restore_opts);
assert!(result.is_err());
} | rust_cleaned_test_functions.jsonl/73420 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1232
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62677,
368,
341,
286,
1077,
2730,
4334,
284,
19944,
6184,
486,
931,
1005,
15454,
543,
286,
1077,
2730,
4334,
2895,
284,
3561,
88928,
4472,
497,
2730,
4334,
3875,
1005,
5493,
1423,
286,
1077,
1376,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_admin_controlled_admin_can_peform_actions_when_paused() {
let (_master_account, contract) = init(CUSTODIAN_ADDRESS);
// 1st deposit call when unpaused - should succeed
let promises = call_deposit_with_proof(&contract, CONTRACT_ACC, PROOF_DATA_NEAR);
for p in promises.iter() {
assert!(p.is_some());
let p = p.as_ref().unwrap();
p.assert_success()
}
let withdraw_amount = 100;
let recipient_addr = validate_eth_address(RECIPIENT_ETH_ADDRESS);
// 1st withdraw call when unpaused - should succeed
let res = contract.call(
CONTRACT_ACC.parse().unwrap(),
"withdraw",
&WithdrawCallArgs {
recipient_address: recipient_addr,
amount: withdraw_amount,
}
.try_to_vec()
.unwrap(),
DEFAULT_GAS,
1,
);
res.assert_success();
let promises = res.promise_results();
for p in promises.iter() {
assert!(p.is_some());
let p = p.as_ref().unwrap();
p.assert_success()
}
// Pause deposit
let res = call_set_paused_flags(&contract, CONTRACT_ACC, PAUSE_DEPOSIT);
res.assert_success();
// NB: We can use `PROOF_DATA_ETH` this will be just a different proof but the same deposit
// method which should be paused
let promises = call_deposit_with_proof(&contract, CONTRACT_ACC, PROOF_DATA_ETH);
for p in promises.iter() {
assert!(p.is_some());
let p = p.as_ref().unwrap();
p.assert_success()
}
// Pause withdraw
let res = call_set_paused_flags(&contract, CONTRACT_ACC, PAUSE_WITHDRAW);
res.assert_success();
let res = contract.call(
CONTRACT_ACC.parse().unwrap(),
"withdraw",
&WithdrawCallArgs {
recipient_address: recipient_addr,
amount: withdraw_amount,
}
.try_to_vec()
.unwrap(),
DEFAULT_GAS,
1,
);
res.assert_success();
let promises = res.promise_results();
for p in promises.iter() {
assert!(p.is_some());
let p = p.as_ref().unwrap();
p.assert_success()
}
} | rust_cleaned_test_functions.jsonl/112877 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 974
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12207,
13436,
832,
12207,
27421,
36367,
627,
25368,
47636,
55475,
2591,
368,
341,
262,
1077,
5453,
13629,
13500,
11,
5116,
8,
284,
2930,
3025,
8553,
2069,
22002,
20135,
626,
262,
442,
220,
16,
267... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_binary_fixed_sized_offsets() {
let array =
FixedSizeBinaryArray::from(vec![vec![0, 0], vec![0, 1], vec![0, 2]]).data();
let array = array.slice(1, 2);
let arrays = vec![&array];
let mut mutable = MutableArrayData::new(arrays, false, 0);
mutable.extend(0, 1, 2);
mutable.extend(0, 0, 1);
let result = mutable.freeze();
let result = FixedSizeBinaryArray::from(Arc::new(result));
let expected = FixedSizeBinaryArray::from(vec![vec![0, 2], vec![0, 1]]);
assert_eq!(result, expected);
} | rust_cleaned_test_functions.jsonl/102350 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 295
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31761,
37839,
643,
1506,
56924,
368,
341,
286,
1077,
1334,
4035,
310,
20149,
1695,
21338,
1857,
486,
1499,
25592,
20703,
4083,
20703,
15,
11,
220,
15,
1125,
7486,
20703,
15,
11,
220,
16,
1125,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_extract_bytes() {
assert_eq!(extract_bytes("ábc", &[0..1]), "�".to_string());
assert_eq!(extract_bytes("ábc", &[0..2]), "á".to_string());
assert_eq!(extract_bytes("ábc", &[0..3]), "áb".to_string());
assert_eq!(extract_bytes("ábc", &[0..4]), "ábc".to_string());
assert_eq!(extract_bytes("ábc", &[3..4, 2..3]), "cb".to_string());
assert_eq!(extract_bytes("ábc", &[0..2, 5..6]), "á".to_string());
} | rust_cleaned_test_functions.jsonl/34701 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 239
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39123,
12524,
368,
341,
286,
2060,
10714,
10297,
23493,
12524,
445,
1953,
8904,
497,
44590,
15,
496,
16,
9719,
330,
5691,
3263,
983,
3904,
1423,
286,
2060,
10714,
10297,
23493,
12524,
445,
1953,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_serialize_struct() {
let the_struct = TestStruct {
vec: vec![233, 123, 0, 12],
integer: 4_242_424_242,
float: 1.2345,
};
let serialized = serialize(&the_struct).unwrap();
let deserialized: TestStruct = deserialize(&serialized).unwrap();
assert_eq!(deserialized, the_struct);
} | rust_cleaned_test_functions.jsonl/75004 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 185
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
88686,
15126,
368,
341,
286,
1077,
279,
15126,
284,
3393,
9422,
341,
310,
7486,
25,
7486,
20703,
17,
18,
18,
11,
220,
16,
17,
18,
11,
220,
15,
11,
220,
16,
17,
1259,
310,
7546,
25,
220,
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... | 1 |
#[test]
fn test_PoK_sig_with_incorrect_reveal_indices() {
let count_msgs = 5;
let params = Params::new("test".as_bytes());
let (vk, sk) = keygen(count_msgs, ¶ms);
let msgs = FieldElementVector::random(count_msgs);
let sig = Signature::new(msgs.as_slice(), &sk, ¶ms).unwrap();
let mut hs = HashSet::new();
hs.insert(count_msgs);
assert!(PoKOfSignature::init(&sig, &vk, ¶ms, msgs.as_slice(), None, hs).is_err());
let mut hs = HashSet::new();
hs.insert(count_msgs + 1);
assert!(PoKOfSignature::init(&sig, &vk, ¶ms, msgs.as_slice(), None, hs).is_err());
let mut hs = HashSet::new();
hs.insert(count_msgs - 1);
assert!(PoKOfSignature::init(&sig, &vk, ¶ms, msgs.as_slice(), None, hs).is_ok());
} | rust_cleaned_test_functions.jsonl/62470 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 403
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1088,
78,
42,
29252,
6615,
1243,
19928,
1288,
40611,
18333,
368,
341,
286,
1077,
1760,
20777,
284,
220,
20,
280,
286,
1077,
3628,
284,
34352,
486,
931,
445,
1944,
3263,
300,
12524,
1423,
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_serde_roundtrip() {
::init().unwrap();
macro_rules! test_roundrip(
($value:expr) => {
let value_ser = ron::ser::to_string(&$value).unwrap();
let value_de: GenericFormattedValue = ron::de::from_str(value_ser.as_str()).unwrap();
assert_eq!(value_de, $value);
}
);
test_roundrip!(GenericFormattedValue::Undefined(Undefined::from(42)));
test_roundrip!(GenericFormattedValue::Default(Default::from(42)));
test_roundrip!(GenericFormattedValue::Bytes(Bytes(Some(42))));
test_roundrip!(GenericFormattedValue::Time(ClockTime::from_nseconds(
42_123_456_789
)));
test_roundrip!(GenericFormattedValue::Buffers(Buffers::from(42)));
test_roundrip!(GenericFormattedValue::Percent(
Percent::try_from(0.42).unwrap()
));
test_roundrip!(GenericFormattedValue::Other(Format::Percent, 42));
test_roundrip!(GenericFormattedValue::Other(Format::__Unknown(7), 42));
} | rust_cleaned_test_functions.jsonl/21903 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 495
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
75861,
450,
29896,
32981,
368,
341,
286,
3504,
2327,
1005,
15454,
1428,
286,
18072,
21407,
0,
1273,
29896,
4561,
1006,
310,
1711,
957,
96011,
8,
589,
341,
394,
1077,
897,
75861,
284,
435,
263,
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_request_cookies() {
let req = TestRequest::default()
.append_header((header::COOKIE, "cookie1=value1"))
.append_header((header::COOKIE, "cookie2=value2"))
.to_http_request();
{
let cookies = req.cookies().unwrap();
assert_eq!(cookies.len(), 2);
assert_eq!(cookies[0].name(), "cookie1");
assert_eq!(cookies[0].value(), "value1");
assert_eq!(cookies[1].name(), "cookie2");
assert_eq!(cookies[1].value(), "value2");
}
let cookie = req.cookie("cookie1");
assert!(cookie.is_some());
let cookie = cookie.unwrap();
assert_eq!(cookie.name(), "cookie1");
assert_eq!(cookie.value(), "value1");
let cookie = req.cookie("cookie-unknown");
assert!(cookie.is_none());
} | rust_cleaned_test_functions.jsonl/39761 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 426
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7893,
94158,
368,
341,
286,
1077,
4232,
284,
3393,
1900,
486,
2258,
741,
310,
659,
5090,
8757,
1188,
2708,
486,
44796,
11,
330,
16236,
16,
46538,
16,
5455,
310,
659,
5090,
8757,
1188,
2708,
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_0297_example_2() {
let root = tree![];
let codec = Codec::new();
let data = codec.serialize(root.clone());
let result = codec.deserialize(data);
assert_eq!(root, result);
} | rust_cleaned_test_functions.jsonl/114939 | {
"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,
62,
15,
17,
24,
22,
39304,
62,
17,
368,
341,
286,
1077,
3704,
284,
4916,
0,
15078,
286,
1077,
34647,
284,
67077,
486,
931,
543,
286,
1077,
821,
284,
34647,
33969,
9206,
15997,
1423,
286,
1077,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_bool() {
let mut rng = crate::new();
const N: usize = 10000;
let mut results = [0i32; 2];
for _ in 0..N {
results[rng.coin_flip() as usize] += 1;
}
assert!((results[0] - results[1]).abs() < 1000, "Unbalanced coin flips!! heads = {}, tails = {} out of {} trails ", results[1], results[0], N);
} | rust_cleaned_test_functions.jsonl/85584 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 132
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
22159,
368,
341,
10217,
5206,
28422,
284,
17717,
486,
931,
543,
4777,
451,
25,
22301,
284,
220,
16,
15,
15,
15,
15,
401,
10217,
5206,
3059,
284,
508,
15,
72,
18,
17,
26,
220,
17,
935,
2023,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_to_spanner_array() {
let array = vec![0, 1, 2, 3, 4];
assert_eq!(
array.to_spanner().ok(),
Some(Value::Array(
Type::Int64,
vec![
Value::Int64(0),
Value::Int64(1),
Value::Int64(2),
Value::Int64(3),
Value::Int64(4)
]
))
);
let empty: Vec<u32> = vec![];
assert_eq!(
empty.to_spanner().ok(),
Some(Value::Array(Type::Int64, vec![]))
);
} | rust_cleaned_test_functions.jsonl/105723 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 408
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2346,
37382,
1194,
3858,
368,
341,
286,
1077,
1334,
284,
7486,
20703,
15,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
935,
286,
2060,
10714,
33673,
310,
1334,
2389,
37382,
1194,
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_fs_display() {
assert_eq!(
format!("{}", Fs::from_repr(FsRepr([0x5528efb9998a01a3, 0x5bd2add5cb357089, 0xc061fa6adb491f98, 0x70db9d143db03d9])).unwrap()),
"Fs(0x070db9d143db03d9c061fa6adb491f985bd2add5cb3570895528efb9998a01a3)".to_string()
);
assert_eq!(
format!("{}", Fs::from_repr(FsRepr([0xd674745e2717999e, 0xbeb1f52d3e96f338, 0x9c7ae147549482b9, 0x999706024530d22])).unwrap()),
"Fs(0x0999706024530d229c7ae147549482b9beb1f52d3e96f338d674745e2717999e)".to_string()
);
} | rust_cleaned_test_functions.jsonl/95522 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 320
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34470,
14825,
368,
341,
262,
2060,
10714,
33673,
286,
3561,
79878,
84619,
486,
1499,
68535,
7832,
82,
693,
649,
2561,
15,
87,
20,
20,
17,
23,
823,
65,
24,
24,
24,
23,
64,
15,
16,
64,
18,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_select_utxos_for_optimization_behavior_around_fee() {
// place.
{
let mut utxos = generate_utxos(6);
utxos[0].value = Mob::MINIMUM_FEE / 10;
utxos[1].value = Mob::MINIMUM_FEE / 10;
utxos[2].value = Mob::MINIMUM_FEE / 10;
utxos[3].value = Mob::MINIMUM_FEE / 10;
utxos[4].value = 200 * Mob::MINIMUM_FEE;
utxos[5].value = Mob::MINIMUM_FEE / 10;
assert!(
utxos[0].value + utxos[1].value + utxos[2].value + utxos[3].value + utxos[5].value
< Mob::MINIMUM_FEE
);
let result = TransactionsManager::<
ThickClient<HardcodedCredentialsProvider>,
MockFogPubkeyResolver,
>::select_utxos_for_optimization(
1000, &utxos, 100, Mob::ID, Mob::MINIMUM_FEE
);
assert!(result.is_err());
}
// will ltake place.
{
let mut utxos = generate_utxos(2);
utxos[0].value = Mob::MINIMUM_FEE;
utxos[1].value = 2000 * MILLIMOB_TO_PICOMOB;
let result = TransactionsManager::<
ThickClient<HardcodedCredentialsProvider>,
MockFogPubkeyResolver,
>::select_utxos_for_optimization(
1000, &utxos, 100, Mob::ID, Mob::MINIMUM_FEE
);
assert!(result.is_err());
}
{
let mut utxos = generate_utxos(4);
utxos[0].value = Mob::MINIMUM_FEE;
utxos[1].value = 208 * Mob::MINIMUM_FEE;
utxos[2].value = Mob::MINIMUM_FEE / 10;
utxos[3].value = Mob::MINIMUM_FEE / 5;
let selected_utxos = TransactionsManager::<
ThickClient<HardcodedCredentialsProvider>,
MockFogPubkeyResolver,
>::select_utxos_for_optimization(
1000, &utxos, 3, Mob::ID, Mob::MINIMUM_FEE
)
.unwrap();
// get excluded.
assert_eq!(
selected_utxos,
vec![utxos[3].clone(), utxos[0].clone(), utxos[1].clone()]
);
}
} | rust_cleaned_test_functions.jsonl/527 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1322
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13051,
60363,
87,
436,
5478,
15032,
65964,
74540,
62,
19454,
34305,
368,
341,
1789,
286,
442,
1992,
624,
286,
341,
310,
1077,
5206,
8621,
87,
436,
284,
6923,
60363,
87,
436,
7,
21,
626,
310,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_hash_index_expr() {
let tests = vec![
("{\"foo\": 5}[\"foo\"]", Some(Object::Int(5))),
("{\"foo\": 5}[\"bar\"]", Some(Object::Null)),
("let key = \"foo\"; {\"foo\": 5}[key]", Some(Object::Int(5))),
("{}[\"foo\"]", Some(Object::Null)),
("{5: 5}[5]", Some(Object::Int(5))),
("{true: 5}[true]", Some(Object::Int(5))),
("{false: 5}[false]", Some(Object::Int(5))),
];
for (input, expect) in tests {
assert_eq!(expect, eval(input));
}
} | rust_cleaned_test_functions.jsonl/12294 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 323
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8950,
3560,
21915,
368,
341,
286,
1077,
7032,
284,
7486,
90515,
310,
3489,
64238,
7975,
11693,
220,
20,
43389,
2105,
7975,
75104,
497,
4329,
12526,
486,
1072,
7,
20,
41749,
310,
3489,
64238,
7975,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_xdh_parsing() {
for test in wycheproof::xdh::TestName::all() {
let _kat = wycheproof::xdh::TestSet::load(test).unwrap();
}
} | rust_cleaned_test_functions.jsonl/5845 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 80
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3212,
30621,
620,
28598,
368,
341,
262,
369,
1273,
304,
289,
5641,
747,
75636,
486,
9703,
71,
486,
2271,
675,
486,
541,
368,
341,
286,
1077,
716,
33755,
284,
289,
5641,
747,
75636,
486,
9703,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_var_in_block1() {
test(
"function f(x) { if (true) {var y = x; y; y;} }",
"function f(x) { if (true) {var y; x; x;} }",
);
} | rust_cleaned_test_functions.jsonl/27708 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 95
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4612,
1243,
7113,
16,
368,
341,
262,
1273,
1006,
286,
330,
1688,
282,
2075,
8,
314,
421,
320,
1866,
8,
314,
947,
379,
284,
856,
26,
379,
26,
379,
30031,
335,
756,
286,
330,
1688,
282,
2075,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_propagation_failure() {
let writer = WriterId::new(1u8);
let model = &mut Model::new();
let a = model.new_bvar("a");
let b = model.new_bvar("b");
let mut sat = SatSolver::new(writer);
let a_or_b = vec![Lit::geq(a, 1), Lit::geq(b, 1)];
sat.add_clause(a_or_b);
sat.propagate(&mut model.state).unwrap();
assert_eq!(model.boolean_value_of(a), None);
assert_eq!(model.boolean_value_of(b), None);
model.state.set_ub(a, 0, Cause::Decision).unwrap();
model.state.set_ub(b, 0, Cause::Decision).unwrap();
assert_eq!(model.boolean_value_of(a), Some(false));
assert_eq!(model.boolean_value_of(b), Some(false));
assert!(sat.propagate(&mut model.state).is_err());
} | rust_cleaned_test_functions.jsonl/55206 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 393
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21663,
27137,
43618,
368,
341,
286,
1077,
6916,
284,
29404,
764,
486,
931,
7,
16,
84,
23,
317,
286,
1077,
1614,
284,
609,
6984,
4903,
486,
931,
543,
286,
1077,
264,
284,
1614,
4618,
880,
947,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_publish_dhcp_logs_success() {
let dhcp: Dhcp = Dhcp::default();
let kafka: Kafka = Kafka::default();
assert_eq!(publish_dhcp_logs(false, SERVICE_DISCOVERED,
dhcp, kafka), STREAM_SUCCESS);
} | rust_cleaned_test_functions.jsonl/13562 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 152
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
58779,
814,
62169,
42899,
18632,
368,
341,
286,
1077,
85787,
25,
43227,
4672,
284,
43227,
4672,
486,
2258,
543,
286,
1077,
67852,
25,
57025,
284,
57025,
486,
2258,
543,
286,
2060,
10714,
10297,
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 |
#[test]
fn test_create_routed_vlan_properties() {
let mut test_config = create_test_config_no_paths();
test_config.device_config = Some(build_full_config());
let rvi = RoutedVlan {
vlan_id: 2,
ipv4: Some(IpAddressConfig {
addresses: vec![IpAddress {
dhcp_client: Some(false),
cidr_address: Some(CidrAddress {
ip: NetIpAddr("192.168.0.1".parse().unwrap()),
prefix_length: 32,
}),
}],
dhcp_server: None,
}),
ipv6: None,
};
match test_config.create_routed_vlan_properties(&rvi) {
Ok(p) => {
assert_eq!(p.enabled, true);
assert_eq!(p.dhcp, lifmgr::Dhcp::None);
assert_eq!(
p.address_v4,
Some(LifIpAddr { address: "192.168.0.1".parse().unwrap(), prefix: 32 })
);
}
Err(e) => panic!("Got unexpected result: {:?}", e),
}
} | rust_cleaned_test_functions.jsonl/83826 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 679
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8657,
1710,
18533,
71296,
25158,
368,
341,
286,
1077,
5206,
1273,
5332,
284,
1855,
4452,
5332,
6536,
24152,
543,
286,
1273,
5332,
18355,
5332,
284,
4329,
43333,
16372,
5332,
1423,
286,
1077,
435,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_encode_fixed_header() {
let mut v = BytesMut::with_capacity(270);
let p = Packet::PingRequest;
assert_eq!(p.encoded_size(MAX_PACKET_SIZE), 0);
p.encode(&mut v, 0).unwrap();
assert_eq!(&v[..2], b"\xc0\x00".as_ref());
v.clear();
let p = Packet::Publish(Publish {
dup: true,
retain: true,
qos: QoS::ExactlyOnce,
topic: ByteString::from_static("topic"),
packet_id: Some(packet_id(0x4321)),
payload: (0..255).collect::<Vec<u8>>().into(),
properties: PublishProperties::default(),
});
assert_eq!(p.encoded_size(MAX_PACKET_SIZE), 265);
p.encode(&mut v, 265).unwrap();
assert_eq!(&v[..3], b"\x3d\x89\x02".as_ref());
} | rust_cleaned_test_functions.jsonl/93708 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 431
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11224,
37839,
8757,
368,
341,
286,
1077,
5206,
348,
284,
30024,
51440,
486,
4197,
35603,
7,
17,
22,
15,
317,
286,
1077,
281,
284,
28889,
486,
69883,
1900,
401,
286,
2060,
10714,
10297,
79,
13,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_cancel() {
set_logger_for_test();
let mut executor = fasync::Executor::new_with_fake_time().unwrap();
let (mut t, mut rcv) = TestContext::new();
// timer 1 and 2 are scheduled.
// timer 1 is going to be cancelled even before we allow the loop to
// run.
let time1 = nanos_from_now(1);
let time2 = nanos_from_now(2);
let time3 = nanos_from_now(5);
t.with_disp_sync(|d| {
assert!(d.schedule_timer(1, time1).is_none());
assert!(d.schedule_timer(2, time2).is_none());
assert_eq!(d.cancel_timer(&1).unwrap(), time1);
});
executor.set_fake_time(time2.0);
let r = run_in_executor(&mut executor, rcv.next()).unwrap();
t.with_disp_sync(|d| {
assert!(d.cancel_timer(&2).is_none());
});
// only event 2 should come out because 1 was cancelled:
assert_eq!(r, 2);
// event never gets fired:
t.with_disp_sync(|d| {
assert!(d.schedule_timer(3, time3).is_none());
});
executor.set_fake_time(time3.0);
let r = run_in_executor(&mut executor, rcv.next()).unwrap();
assert_eq!(r, 3);
} | rust_cleaned_test_functions.jsonl/52879 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 646
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28895,
368,
341,
286,
738,
27413,
5478,
4452,
543,
286,
1077,
5206,
31558,
284,
282,
7692,
486,
25255,
486,
931,
6615,
56881,
3009,
1005,
15454,
543,
286,
1077,
320,
6984,
259,
11,
5206,
10192,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_large_program() {
let mut prog = vec![0; ebpf::PROG_MAX_INSNS * ebpf::INSN_SIZE];
let mut add_insn = vec![0; ebpf::INSN_SIZE];
write_insn(&mut add_insn, 0, "mov64 r0, 0");
for insn in (0..(ebpf::PROG_MAX_INSNS - 1) * ebpf::INSN_SIZE).step_by(ebpf::INSN_SIZE) {
prog[insn..insn + ebpf::INSN_SIZE].copy_from_slice(&add_insn);
}
write_insn(&mut prog, ebpf::PROG_MAX_INSNS - 1, "exit");
{
// Test jumping to pc larger then i16
write_insn(&mut prog, ebpf::PROG_MAX_INSNS - 2, "ja 0x0");
let mut vm = EbpfVm::new(None).unwrap();
vm.set_program(&prog).unwrap();
assert_eq!(0, vm.execute_program(&mut [], &[], &[]).unwrap());
// reset program
write_insn(&mut prog, ebpf::PROG_MAX_INSNS - 2, "mov64 r0, 0");
}
{
// test program that is too large
prog.extend_from_slice(&assemble("exit").unwrap());
let mut vm = EbpfVm::new(None).unwrap();
vm.set_program(&prog).unwrap_err();
// reset program
prog.truncate(ebpf::PROG_MAX_INSNS * ebpf::INSN_SIZE);
}
{
// verify program still works
let mut vm = EbpfVm::new(None).unwrap();
vm.set_program(&prog).unwrap();
assert_eq!(0, vm.execute_program(&mut [], &[], &[]).unwrap());
}
} | rust_cleaned_test_functions.jsonl/15548 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 653
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
45228,
25096,
368,
341,
262,
1077,
5206,
29271,
284,
7486,
20703,
15,
26,
24463,
15897,
486,
9117,
38,
6806,
31650,
2448,
353,
24463,
15897,
486,
9557,
45,
4098,
935,
262,
1077,
5206,
912,
79799,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_ambiguous_parameter_field_declaration() {
use parser::translation_unit;
let env = &mut Env::new();
assert!(translation_unit(
r"
typedef int a;
int foo(int a* b) {}",
env
)
.is_err());
} | rust_cleaned_test_functions.jsonl/107571 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 141
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
90213,
24899,
5013,
77926,
368,
341,
262,
990,
6729,
486,
3053,
14832,
280,
262,
1077,
6105,
284,
609,
6984,
37039,
486,
931,
543,
1066,
262,
2060,
10297,
3053,
14832,
1006,
286,
435,
698,
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_trap_return() -> Result<()> {
let store = get_store(false);
let wat = r#"
(module
(func $hello (import "" "hello"))
(func (export "run") (call $hello))
)
"#;
let module = Module::new(&store, wat)?;
let hello_type = FunctionType::new(vec![], vec![]);
let hello_func = Function::new(&store, &hello_type, |_| Err(RuntimeError::new("test 123")));
let instance = Instance::new(
&module,
&imports! {
"" => {
"hello" => hello_func
}
},
)?;
let run_func = instance
.exports
.get_function("run")
.expect("expected function export");
let e = run_func.call(&[]).err().expect("error calling function");
assert_eq!(e.message(), "test 123");
Ok(())
} | rust_cleaned_test_functions.jsonl/38854 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 387
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
88536,
12511,
368,
1464,
5714,
71698,
341,
262,
1077,
3553,
284,
633,
14809,
3576,
317,
262,
1077,
29025,
284,
435,
2,
698,
286,
320,
4352,
198,
286,
320,
2830,
400,
14990,
320,
474,
1591,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_trima1() {
let mut candles = RandomCandles::default();
let mut ma = TestingMethod::new(1, &candles.first().close).unwrap();
candles.take(100).for_each(|x| {
assert_eq_float(x.close, ma.next(&x.close));
});
} | rust_cleaned_test_functions.jsonl/87170 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 104
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3547,
7523,
16,
368,
341,
197,
10217,
5206,
51205,
284,
10612,
34,
20125,
486,
2258,
1428,
197,
10217,
5206,
7491,
284,
26768,
3523,
486,
931,
7,
16,
11,
609,
66,
20125,
7389,
1005,
5552,
568,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_key_neighbors() {
let mut t = RbTree::<Vec<u8>, Vec<u8>>::new();
t.insert(vec![1], vec![10]);
t.insert(vec![3], vec![30]);
assert_eq!(t.left_neighbor(&[0u8][..]), None);
assert_eq!(t.left_neighbor(&[1u8][..]), None);
assert_eq!(t.left_neighbor(&[2u8][..]), Some(&[1u8][..]));
assert_eq!(t.left_neighbor(&[3u8][..]), Some(&[1u8][..]));
assert_eq!(t.left_neighbor(&[4u8][..]), Some(&[3u8][..]));
assert_eq!(t.right_neighbor(&[0u8][..]), Some(&[1u8][..]));
assert_eq!(t.right_neighbor(&[1u8][..]), Some(&[3u8][..]));
assert_eq!(t.right_neighbor(&[2u8][..]), Some(&[3u8][..]));
assert_eq!(t.right_neighbor(&[3u8][..]), None);
assert_eq!(t.right_neighbor(&[4u8][..]), None);
} | rust_cleaned_test_functions.jsonl/57902 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 394
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3097,
55925,
368,
341,
262,
1077,
5206,
259,
284,
431,
65,
6533,
27638,
10050,
34837,
23,
8066,
11312,
34837,
23,
77595,
931,
543,
262,
259,
7030,
25592,
20703,
16,
1125,
7486,
20703,
16,
15,
25... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_json_length() {
let cases = vec![
(None, None, None),
(None, Some(Datum::Null), None),
(Some(r#"{}"#), Some(Datum::Null), None),
(Some("null"), None, Some(1)),
(
Some(r#"{"a":{"a":1},"b":2}"#),
Some(Datum::Bytes(b"$".to_vec())),
Some(2),
),
(Some("1"), None, Some(1)),
(
Some(r#"{"a": [1, 2, {"aa": "xx"}]}"#),
Some(Datum::Bytes(b"$.*".to_vec())),
None,
),
(
Some(r#"{"a":{"a":1},"b":2}"#),
Some(Datum::Bytes(b"$".to_vec())),
Some(2),
),
// Tests with path expression
(
Some(r#"[1,2,[1,[5,[3]]]]"#),
Some(Datum::Bytes(b"$[2]".to_vec())),
Some(2),
),
(
Some(r#"[{"a":1}]"#),
Some(Datum::Bytes(b"$".to_vec())),
Some(1),
),
(
Some(r#"[{"a":1,"b":2}]"#),
Some(Datum::Bytes(b"$[0].a".to_vec())),
Some(1),
),
(
Some(r#"{"a":{"a":1},"b":2}"#),
Some(Datum::Bytes(b"$".to_vec())),
Some(2),
),
(
Some(r#"{"a":{"a":1},"b":2}"#),
Some(Datum::Bytes(b"$.a".to_vec())),
Some(1),
),
(
Some(r#"{"a":{"a":1},"b":2}"#),
Some(Datum::Bytes(b"$.a.a".to_vec())),
Some(1),
),
(
Some(r#"{"a": [1, 2, {"aa": "xx"}]}"#),
Some(Datum::Bytes(b"$.a[2].aa".to_vec())),
Some(1),
),
// Tests without path expression
(Some(r#"{}"#), None, Some(0)),
(Some(r#"{"a":1}"#), None, Some(1)),
(Some(r#"{"a":[1]}"#), None, Some(1)),
(Some(r#"{"b":2, "c":3}"#), None, Some(2)),
(Some(r#"[1]"#), None, Some(1)),
(Some(r#"[1,2]"#), None, Some(2)),
(Some(r#"[1,2,[1,3]]"#), None, Some(3)),
(Some(r#"[1,2,[1,[5,[3]]]]"#), None, Some(3)),
(Some(r#"[1,2,[1,[5,{"a":[2,3]}]]]"#), None, Some(3)),
(Some(r#"[{"a":1}]"#), None, Some(1)),
(Some(r#"[{"a":1,"b":2}]"#), None, Some(1)),
(Some(r#"[{"a":{"a":1},"b":2}]"#), None, Some(1)),
// Tests path expression contains any asterisk
(
Some(r#"{"a": [1, 2, {"aa": "xx"}]}"#),
Some(Datum::Bytes(b"$.*".to_vec())),
None,
),
(
Some(r#"{"a": [1, 2, {"aa": "xx"}]}"#),
Some(Datum::Bytes(b"$[*]".to_vec())),
None,
),
(
Some(r#"{"a": [1, 2, {"aa": "xx"}]}"#),
Some(Datum::Bytes(b"$**.a".to_vec())),
None,
),
// Tests path expression does not identify a section of the target document
(
Some(r#"{"a": [1, 2, {"aa": "xx"}]}"#),
Some(Datum::Bytes(b"$.c".to_vec())),
None,
),
(
Some(r#"{"a": [1, 2, {"aa": "xx"}]}"#),
Some(Datum::Bytes(b"$.a[3]".to_vec())),
None,
),
(
Some(r#"{"a": [1, 2, {"aa": "xx"}]}"#),
Some(Datum::Bytes(b"$.a[2].b".to_vec())),
None,
),
];
let mut ctx = EvalContext::default();
for (input, param, exp) in cases {
let json = datum_expr(match input {
None => Datum::Null,
Some(s) => Datum::Json(s.parse().unwrap()),
});
let op = if let Some(b) = param {
scalar_func_expr(ScalarFuncSig::JsonLengthSig, &[json, datum_expr(b)])
} else {
scalar_func_expr(ScalarFuncSig::JsonLengthSig, &[json])
};
let op = Expression::build(&mut ctx, op).unwrap();
let got = op.eval(&mut ctx, &[]).unwrap();
let exp = match exp {
None => Datum::Null,
Some(e) => Datum::I64(e),
};
assert_eq!(got, exp);
}
} | rust_cleaned_test_functions.jsonl/5031 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2943
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9455,
5118,
368,
341,
286,
1077,
5048,
284,
7486,
90515,
310,
320,
4064,
11,
2240,
11,
2240,
1326,
310,
320,
4064,
11,
4329,
5432,
26253,
486,
3280,
701,
2240,
1326,
310,
320,
8373,
2601,
55543,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_tile_from_lines() {
assert_eq!(
Tile::from_lines(vec![
"Tile 3079:".to_string(),
"#.#.#####.".to_string(),
".#..######".to_string(),
"..#.......".to_string(),
"######....".to_string(),
"####.#..#.".to_string(),
".#...#.##.".to_string(),
"#.#####.##".to_string(),
"..#.###...".to_string(),
"..#.......".to_string(),
"..#.###...".to_string()
]),
Tile::new(
3079,
vec![
vec![true, false, true, false, true, true, true, true, true, false],
vec![false, true, false, false, true, true, true, true, true, true],
vec![false, false, true, false, false, false, false, false, false, false],
vec![true, true, true, true, true, true, false, false, false, false],
vec![true, true, true, true, false, true, false, false, true, false],
vec![false, true, false, false, false, true, false, true, true, false],
vec![true, false, true, true, true, true, true, false, true, true],
vec![false, false, true, false, true, true, true, false, false, false],
vec![false, false, true, false, false, false, false, false, false, false],
vec![false, false, true, false, true, true, true, false, false, false]
],
hashset!(7, 2, 4, 4),
vec!(0b1010111110, 0b0100001000, 0b0010111000, 0b1001101000),
vec!(0b0111110101, 0b0001000010, 0b0001110100, 0b0001011001)
)
)
} | rust_cleaned_test_functions.jsonl/34529 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1007
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
29844,
5673,
18323,
368,
341,
286,
2060,
10714,
33673,
310,
20744,
486,
1499,
18323,
25592,
90515,
394,
330,
15628,
220,
18,
15,
22,
24,
95740,
983,
3904,
3148,
394,
5869,
43326,
13,
67331,
36911,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_malloc() {
let r = parse_and_eval(
r#"
block 0 {
r0 = malloc(10);
exit(r0);
}"#,
).unwrap();
assert!(r == 1);
} | rust_cleaned_test_functions.jsonl/55936 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 158
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
38303,
368,
341,
286,
1077,
435,
284,
4715,
8378,
21296,
1006,
310,
435,
2,
698,
310,
2504,
220,
15,
341,
394,
435,
15,
284,
15731,
7,
16,
15,
317,
394,
4869,
2601,
15,
317,
310,
335,
57676,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_display() {
let as_string = "attachment; filename*=UTF-8'en'%C2%A3%20and%20%E2%82%AC%20rates";
let a = HeaderValue::from_static(as_string);
let a: ContentDisposition = ContentDisposition::from_raw(&a).unwrap();
let display_rendered = format!("{}",a);
assert_eq!(as_string, display_rendered);
let a = HeaderValue::from_static("attachment; filename*=UTF-8''black%20and%20white.csv");
let a: ContentDisposition = ContentDisposition::from_raw(&a).unwrap();
let display_rendered = format!("{}",a);
assert_eq!("attachment; filename=\"black and white.csv\"".to_owned(), display_rendered);
let a = HeaderValue::from_static("attachment; filename=colourful.csv");
let a: ContentDisposition = ContentDisposition::from_raw(&a).unwrap();
let display_rendered = format!("{}",a);
assert_eq!("attachment; filename=\"colourful.csv\"".to_owned(), display_rendered);
} | rust_cleaned_test_functions.jsonl/18668 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 391
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14825,
368,
341,
286,
1077,
438,
3904,
284,
330,
21981,
26,
3899,
40008,
8561,
12,
23,
40801,
36165,
34,
17,
52585,
18,
4,
17,
15,
437,
4,
17,
15,
39798,
17,
4,
23,
17,
4,
1706,
4,
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... | 1 |
#[test]
fn test_window_post_two_partitions_smaller_2kib_base_8() -> Result<()> {
let sector_size = SECTOR_SIZE_2_KIB;
let sector_count = *WINDOW_POST_SECTOR_COUNT
.read()
.unwrap()
.get(§or_size)
.unwrap();
window_post::<SectorShape2KiB>(sector_size, 2 * sector_count - 1, sector_count)
} | rust_cleaned_test_functions.jsonl/6772 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 166
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12571,
6333,
23241,
99097,
15874,
13956,
62,
17,
74,
579,
7651,
62,
23,
368,
1464,
5714,
71698,
341,
262,
1077,
10486,
2368,
284,
5052,
26275,
4098,
62,
17,
10102,
3256,
280,
262,
1077,
10486,
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_merge_unsorted_index() {
let index = create_test_index(
Some(IndexSettings {
..Default::default()
}),
false,
);
let reader = index.reader().unwrap();
let searcher = reader.searcher();
assert_eq!(searcher.segment_readers().len(), 1);
let segment_reader = searcher.segment_readers().last().unwrap();
let searcher = index.reader().unwrap().searcher();
{
let my_text_field = index.schema().get_field("text_field").unwrap();
let do_search = |term: &str| {
let query = QueryParser::for_index(&index, vec![my_text_field])
.parse_query(term)
.unwrap();
let top_docs: Vec<(f32, DocAddress)> =
searcher.search(&query, &TopDocs::with_limit(3)).unwrap();
top_docs.iter().map(|el| el.1.doc_id).collect::<Vec<_>>()
};
assert_eq!(do_search("some"), vec![1]);
assert_eq!(do_search("blubber"), vec![3]);
assert_eq!(do_search("biggest"), vec![4]);
}
// postings file
{
let my_text_field = index.schema().get_field("text_field").unwrap();
let term_a = Term::from_field_text(my_text_field, "text");
let inverted_index = segment_reader.inverted_index(my_text_field).unwrap();
let mut postings = inverted_index
.read_postings(&term_a, IndexRecordOption::WithFreqsAndPositions)
.unwrap()
.unwrap();
assert_eq!(postings.doc_freq(), 2);
let fallback_bitset = DeleteBitSet::for_test(&[0], 100);
assert_eq!(
postings.doc_freq_given_deletes(
segment_reader
.delete_bitset()
.unwrap_or_else(|| &&fallback_bitset)
),
2
);
assert_eq!(postings.term_freq(), 1);
let mut output = vec![];
postings.positions(&mut output);
assert_eq!(output, vec![1]);
postings.advance();
assert_eq!(postings.term_freq(), 2);
postings.positions(&mut output);
assert_eq!(output, vec![1, 3]);
}
} | rust_cleaned_test_functions.jsonl/66291 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1269
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20888,
4907,
28298,
3560,
368,
341,
286,
1077,
1922,
284,
1855,
4452,
3560,
1006,
310,
4329,
45030,
6086,
341,
394,
5241,
3675,
486,
2258,
741,
310,
11973,
310,
895,
345,
286,
3475,
286,
1077,
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... | 3 |
#[test]
fn test_force_checkout_of_independently_added_blob() -> BitResult<()> {
BitRepo::with_minimal_repo(|repo| {
rm!(repo: "foo");
bit_commit_all!(repo);
touch!(repo: "foo" < "default foo contents");
bit_checkout!(repo: --force "HEAD^")?;
assert_eq!(cat!(repo: "foo"), "default foo contents");
Ok(())
})
} | rust_cleaned_test_functions.jsonl/62942 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 186
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
40739,
68186,
3575,
1243,
19510,
4402,
37653,
45908,
368,
1464,
6495,
2077,
71698,
341,
262,
6495,
25243,
486,
4197,
7260,
2861,
37784,
22428,
23476,
91,
341,
286,
18998,
10297,
23476,
25,
330,
7975... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_distance_to() {
let point = Point3d::new(3, 4, 12);
let expected = 13.0;
let result = ORIGIN_POINT.distance_to(&point);
assert!((result - expected).abs() < EPSILON);
} | rust_cleaned_test_functions.jsonl/37338 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 107
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19464,
2346,
368,
341,
286,
1077,
1459,
284,
5126,
18,
67,
486,
931,
7,
18,
11,
220,
19,
11,
220,
16,
17,
626,
286,
1077,
3601,
284,
220,
16,
18,
13,
15,
401,
286,
1077,
1102,
284,
2726,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_spoofed_stake_accounts() {
process_instruction_as_one_arg(
&instruction::initialize(
&spoofed_stake_state_pubkey(),
&Authorized::default(),
&Lockup::default(),
),
Err(InstructionError::InvalidAccountOwner),
);
process_instruction_as_one_arg(
&instruction::authorize(
&spoofed_stake_state_pubkey(),
&Pubkey::new_unique(),
&Pubkey::new_unique(),
StakeAuthorize::Staker,
None,
),
Err(InstructionError::InvalidAccountOwner),
);
process_instruction_as_one_arg(
&instruction::split(
&spoofed_stake_state_pubkey(),
&Pubkey::new_unique(),
100,
&Pubkey::new_unique(),
)[2],
Err(InstructionError::InvalidAccountOwner),
);
process_instruction_as_one_arg(
&instruction::split(
&Pubkey::new_unique(),
&Pubkey::new_unique(),
100,
&spoofed_stake_state_pubkey(),
)[2],
Err(InstructionError::IncorrectProgramId),
);
process_instruction_as_one_arg(
&instruction::merge(
&spoofed_stake_state_pubkey(),
&Pubkey::new_unique(),
&Pubkey::new_unique(),
)[0],
Err(InstructionError::InvalidAccountOwner),
);
process_instruction_as_one_arg(
&instruction::merge(
&Pubkey::new_unique(),
&spoofed_stake_state_pubkey(),
&Pubkey::new_unique(),
)[0],
Err(InstructionError::IncorrectProgramId),
);
process_instruction_as_one_arg(
&instruction::split_with_seed(
&spoofed_stake_state_pubkey(),
&Pubkey::new_unique(),
100,
&Pubkey::new_unique(),
&Pubkey::new_unique(),
"seed",
)[1],
Err(InstructionError::InvalidAccountOwner),
);
process_instruction_as_one_arg(
&instruction::delegate_stake(
&spoofed_stake_state_pubkey(),
&Pubkey::new_unique(),
&Pubkey::new_unique(),
),
Err(InstructionError::InvalidAccountOwner),
);
process_instruction_as_one_arg(
&instruction::withdraw(
&spoofed_stake_state_pubkey(),
&Pubkey::new_unique(),
&Pubkey::new_unique(),
100,
None,
),
Err(InstructionError::InvalidAccountOwner),
);
process_instruction_as_one_arg(
&instruction::deactivate_stake(&spoofed_stake_state_pubkey(), &Pubkey::new_unique()),
Err(InstructionError::InvalidAccountOwner),
);
process_instruction_as_one_arg(
&instruction::set_lockup(
&spoofed_stake_state_pubkey(),
&LockupArgs::default(),
&Pubkey::new_unique(),
),
Err(InstructionError::InvalidAccountOwner),
);
process_instruction_as_one_arg(
&instruction::deactivate_delinquent_stake(
&spoofed_stake_state_pubkey(),
&Pubkey::new_unique(),
&Pubkey::new_unique(),
),
Err(InstructionError::InvalidAccountOwner),
);
} | rust_cleaned_test_functions.jsonl/31631 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2072
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
643,
5368,
1055,
291,
1261,
726,
55665,
368,
341,
286,
1882,
54923,
11898,
11667,
6057,
1006,
310,
609,
54974,
486,
21641,
1006,
394,
609,
82859,
1055,
291,
1261,
726,
4387,
34014,
792,
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_merkle_tree_insert() {
let mut tree = TestSMT::new(3);
assert_eq!(tree.capacity(), 8);
tree.insert(0, 1);
println!("{:?}", tree);
assert_eq!(tree.root_hash(), 697516875);
tree.insert(0, 2);
println!("{:?}", tree);
assert_eq!(tree.root_hash(), 741131083);
tree.insert(3, 2);
assert_eq!(tree.root_hash(), 793215819);
} | rust_cleaned_test_functions.jsonl/88490 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 232
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
717,
16754,
273,
11663,
17678,
368,
341,
286,
1077,
5206,
4916,
284,
3393,
50,
8505,
486,
931,
7,
18,
626,
286,
2060,
10714,
10297,
9344,
59168,
1507,
220,
23,
626,
286,
4916,
7030,
7,
15,
11,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_add_tags() {
let (input, modification) = Modification::parse(argv!["+abc", "+def"]).unwrap();
assert_eq!(input.len(), 0);
assert_eq!(
modification,
Modification {
add_tags: set![tag!("abc"), tag!("def")],
..Default::default()
}
);
} | rust_cleaned_test_functions.jsonl/28811 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 196
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
16333,
368,
341,
286,
1077,
320,
1355,
11,
17030,
8,
284,
73855,
486,
6400,
15329,
0,
80128,
13683,
497,
6630,
750,
45014,
15454,
543,
286,
2060,
10714,
10297,
1355,
19406,
1507,
220,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_fp() {
let mut rng = test_rng();
let a: Fp = rng.gen();
let b: Fp = rng.gen();
field_test(a, b);
sqrt_field_test(a);
primefield_test::<Fp>();
} | rust_cleaned_test_functions.jsonl/92585 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 102
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34160,
368,
341,
262,
1077,
5206,
28422,
284,
1273,
66849,
543,
262,
1077,
264,
25,
434,
79,
284,
28422,
22822,
543,
262,
1077,
293,
25,
434,
79,
284,
28422,
22822,
543,
262,
2070,
4452,
2877,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_invalid_uncle_hash_case1() {
let (shared, chain1, chain2) = prepare();
let dummy_context = dummy_context(&shared);
// body has 1 uncles
let block = chain1
.last()
.cloned()
.unwrap()
.as_advanced_builder()
.uncles_count(1u32.pack())
.uncle(chain2.last().cloned().unwrap().as_uncle())
.build_unchecked();
let epoch = epoch(&shared, &chain1, chain1.len() - 2);
let uncle_verifier_context = UncleVerifierContext::new(&dummy_context, &epoch);
let verifier = UnclesVerifier::new(uncle_verifier_context, &block);
assert_eq!(
verifier.verify(),
Err(Error::Uncles(UnclesError::InvalidHash {
expected: H256::zero(),
actual: block.calc_uncles_hash()
}))
);
} | rust_cleaned_test_functions.jsonl/118898 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 373
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31433,
76576,
273,
8950,
19096,
16,
368,
341,
262,
1077,
320,
6100,
11,
8781,
16,
11,
8781,
17,
8,
284,
10549,
543,
262,
1077,
17292,
8467,
284,
17292,
8467,
2099,
6100,
626,
1066,
262,
442,
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_vote_process_instruction() {
solana_logger::setup();
let instructions = create_account(
&Pubkey::default(),
&Pubkey::default(),
&VoteInit::default(),
100,
);
assert_eq!(
process_instruction(&instructions[1]),
Err(InstructionError::InvalidAccountData),
);
assert_eq!(
process_instruction(&vote(
&Pubkey::default(),
&Pubkey::default(),
Vote::default(),
)),
Err(InstructionError::InvalidAccountData),
);
assert_eq!(
process_instruction(&vote_switch(
&Pubkey::default(),
&Pubkey::default(),
Vote::default(),
Hash::default(),
)),
Err(InstructionError::InvalidAccountData),
);
assert_eq!(
process_instruction(&authorize(
&Pubkey::default(),
&Pubkey::default(),
&Pubkey::default(),
VoteAuthorize::Voter,
)),
Err(InstructionError::InvalidAccountData),
);
assert_eq!(
process_instruction(&update_validator_identity(
&Pubkey::default(),
&Pubkey::default(),
&Pubkey::default(),
)),
Err(InstructionError::InvalidAccountData),
);
assert_eq!(
process_instruction(&update_commission(
&Pubkey::default(),
&Pubkey::default(),
0,
)),
Err(InstructionError::InvalidAccountData),
);
assert_eq!(
process_instruction(&withdraw(
&Pubkey::default(),
&Pubkey::default(),
0,
&Pubkey::default()
)),
Err(InstructionError::InvalidAccountData),
);
} | rust_cleaned_test_functions.jsonl/97474 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1126
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
54360,
11305,
54923,
368,
341,
286,
2048,
3362,
27413,
486,
15188,
543,
286,
1077,
11221,
284,
1855,
13500,
1006,
310,
609,
29162,
792,
486,
2258,
3148,
310,
609,
29162,
792,
486,
2258,
3148,
310,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_quality_item_fmt_q_0() {
// Custom value
let x = QualityItem{
item: EncodingExt("identity".to_owned()),
quality: Quality(0),
};
assert_eq!(x.to_string(), "identity; q=0");
} | rust_cleaned_test_functions.jsonl/65731 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 136
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
55074,
5634,
38128,
8976,
62,
15,
368,
341,
286,
442,
8406,
897,
198,
286,
1077,
856,
284,
17927,
1234,
515,
310,
1509,
25,
29330,
6756,
445,
16912,
3263,
983,
51973,
14702,
310,
4271,
25,
17927... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_bounds_on_fields_only() {
#![allow(dead_code)]
use std::marker::PhantomData;
struct NoDebug;
struct TemplatedType<T> {
_phantom: PhantomData<T>,
};
test_derive! {
custom_debug_derive {
struct WantDebug<T> {
foo: TemplatedType<T>,
bar: TemplatedType<NoDebug>,
needs_debug: T,
}
}
expands to {
#[allow(non_upper_case_globals)]
const _DERIVE_core_fmt_Debug_FOR_WantDebug: () = {
impl<T> ::core::fmt::Debug for WantDebug<T>
where
TemplatedType<T>: ::core::fmt::Debug,
T: ::core::fmt::Debug
{
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
WantDebug { foo: ref __binding_0, bar: ref __binding_1, needs_debug: ref __binding_2, } => {
let mut s = f.debug_struct("WantDebug");
s.field("foo", __binding_0);
s.field("bar", __binding_1);
s.field("needs_debug", __binding_2);
s.finish()
}
}
}
}
};
}
no_build
}
} | rust_cleaned_test_functions.jsonl/61114 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 920
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36878,
4470,
12132,
18410,
368,
341,
262,
671,
20703,
7183,
83207,
4136,
27771,
262,
990,
1460,
486,
27742,
486,
3357,
30002,
1043,
401,
262,
2036,
2308,
7939,
280,
262,
2036,
78810,
657,
929,
312... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_or_update_edges_update_error() {
// test that when an existing edge is added and EdgeDedupeStrategy is Error
let graph = get_basic_graph(None);
let new_edges = vec![Edge::with_weight("n1", "n3", &4.4)];
let graph = graph.add_or_update_edges(new_edges);
assert!(graph.is_err());
} | rust_cleaned_test_functions.jsonl/100461 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 158
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
8734,
8882,
28026,
8882,
4096,
368,
341,
286,
442,
1273,
429,
979,
458,
6350,
6821,
374,
3694,
323,
10349,
35,
55101,
375,
19816,
374,
4600,
198,
286,
1077,
4771,
284,
633,
34729,
14738,
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_enum_variant_from_module_2() {
test_rename(
r#"
mod foo {
pub struct Foo {
pub bar<|>: uint,
}
}
fn foo(f: foo::Foo) {
let _ = f.bar;
}
"#,
"baz",
r#"
mod foo {
pub struct Foo {
pub baz: uint,
}
}
fn foo(f: foo::Foo) {
let _ = f.baz;
}
"#,
);
} | rust_cleaned_test_functions.jsonl/58100 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 285
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31054,
46112,
5673,
10750,
62,
17,
368,
341,
286,
1273,
79399,
1006,
310,
435,
2,
698,
262,
1463,
15229,
341,
286,
6675,
2036,
33428,
341,
310,
6675,
3619,
27,
91,
26818,
2622,
345,
286,
456,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_cmd_arg_idx() {
let mut c = Cmd::new();
assert_eq!(c.arg_idx(0), None);
c.arg("SET");
assert_eq!(c.arg_idx(0), Some(&b"SET"[..]));
assert_eq!(c.arg_idx(1), None);
c.arg("foo").arg("42");
assert_eq!(c.arg_idx(1), Some(&b"foo"[..]));
assert_eq!(c.arg_idx(2), Some(&b"42"[..]));
assert_eq!(c.arg_idx(3), None);
assert_eq!(c.arg_idx(4), None);
} | rust_cleaned_test_functions.jsonl/2119 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 265
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11684,
6057,
7258,
368,
341,
286,
1077,
5206,
272,
284,
40210,
486,
931,
543,
286,
2060,
10714,
10297,
66,
21186,
7258,
7,
15,
701,
2240,
626,
286,
272,
21186,
445,
5884,
797,
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_read_write() {
// TOOD: Make this test more thorough
let mut memory_manager = MemoryManager::new();
let data: [u8; 4] = [1, 2, 3, 4];
let result: &[u8];
let mut i = 0;
memory_manager.write(0, &[1, 2, 3, 4]);
result = memory_manager.read(0, 4);
while i < 4 {
assert_eq!(data[i], result[i]);
i += 1;
}
} | rust_cleaned_test_functions.jsonl/96775 | {
"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,
6443,
9165,
368,
341,
286,
442,
5146,
2069,
25,
7405,
419,
1273,
803,
17423,
198,
286,
1077,
5206,
4938,
12144,
284,
13850,
2043,
486,
931,
543,
286,
1077,
821,
25,
508,
84,
23,
26,
220,
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... | 2 |
#[test]
fn test_simple_operator_lte_plaintext_to_string() {
let name1 = _random_vector(10);
let value1 = _random_string(10);
let query = Operator::Lte(
TagName::PlainTagName(name1.clone()),
TargetValue::Unencrypted(value1.clone())
);
let json = query.to_string();
let expected = format!(r#"{{"~{}":{{"$lte":"{}"}}}}"#, base64::encode(&name1), value1);
assert_eq!(json, expected);
} | rust_cleaned_test_functions.jsonl/11883 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 228
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
30015,
40594,
907,
665,
6317,
1641,
427,
2346,
3904,
368,
341,
286,
1077,
829,
16,
284,
716,
11463,
12247,
7,
16,
15,
317,
286,
1077,
897,
16,
284,
716,
11463,
3904,
7,
16,
15,
626,
286,
107... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_automatic_rollover() {
let mut t = spooled_tempfile(10);
let mut buf = Vec::new();
assert!(!t.is_rolled());
assert_eq!(t.seek(SeekFrom::Current(0)).unwrap(), 0);
assert_eq!(t.read_to_end(&mut buf).unwrap(), 0);
assert_eq!(buf.as_slice(), b"");
buf.clear();
assert_eq!(t.write(b"abcde").unwrap(), 5);
assert!(!t.is_rolled());
assert_eq!(t.seek(SeekFrom::Start(0)).unwrap(), 0);
assert_eq!(t.read_to_end(&mut buf).unwrap(), 5);
assert_eq!(buf.as_slice(), b"abcde");
assert_eq!(t.write(b"fghijklmno").unwrap(), 10);
assert_eq!(t.seek(SeekFrom::Current(0)).unwrap(), 15);
assert!(t.is_rolled());
} | rust_cleaned_test_functions.jsonl/115751 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 316
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
32808,
13487,
62,
43684,
423,
368,
341,
262,
1077,
5206,
259,
284,
978,
45073,
11771,
1192,
7,
16,
15,
317,
262,
1077,
5206,
6607,
284,
11312,
486,
931,
1428,
262,
2060,
0,
3471,
83,
2079,
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_normalize() {
assert!(Vector2::new(3.0f64, 4.0f64).normalize().approx_eq( &Vector2::new(3.0/5.0, 4.0/5.0) ));
assert!(Vector3::new(2.0f64, 3.0f64, 6.0f64).normalize().approx_eq( &Vector3::new(2.0/7.0, 3.0/7.0, 6.0/7.0) ));
assert!(Vector4::new(1.0f64, 2.0f64, 4.0f64, 10.0f64).normalize().approx_eq( &Vector4::new(1.0/11.0, 2.0/11.0, 4.0/11.0, 10.0/11.0) ));
} | rust_cleaned_test_functions.jsonl/5671 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 232
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
80807,
368,
341,
1066,
262,
2060,
10297,
3781,
17,
486,
931,
7,
18,
13,
15,
69,
21,
19,
11,
220,
19,
13,
15,
69,
21,
19,
568,
30590,
1005,
48053,
10714,
7,
609,
3781,
17,
486,
931,
7,
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_no_constructor_make_unique_ns() {
let hdr = indoc! {"
#include <stdint.h>
namespace B {
struct A {
uint32_t a;
};
}
"};
let rs = quote! {
ffi::B::A::make_unique();
};
run_test("", hdr, rs, &["B::A"], &[]);
} | rust_cleaned_test_functions.jsonl/9962 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 153
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6536,
66210,
28230,
21218,
34728,
368,
341,
262,
1077,
36615,
284,
1257,
509,
0,
314,
698,
262,
671,
997,
366,
31435,
860,
397,
262,
4473,
425,
341,
262,
2036,
362,
341,
286,
2622,
18,
17,
528... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_csv() {
let schema = Schema::new(vec![
Field::new("city", DataType::Utf8, false),
Field::new("lat", DataType::Float64, false),
Field::new("lng", DataType::Float64, false),
]);
let file = File::open("test/data/uk_cities.csv").unwrap();
let mut csv = Reader::new(file, Arc::new(schema), false, 1024, None);
let batch = csv.next().unwrap().unwrap();
assert_eq!(37, batch.num_rows());
assert_eq!(3, batch.num_columns());
// access data from a primitive array
let lat = batch
.column(1)
.as_any()
.downcast_ref::<Float64Array>()
.unwrap();
assert_eq!(57.653484, lat.value(0));
let city = batch
.column(0)
.as_any()
.downcast_ref::<BinaryArray>()
.unwrap();
let city_name: String = String::from_utf8(city.value(13).to_vec()).unwrap();
assert_eq!("Aberdeen, Aberdeen City, UK", city_name);
} | rust_cleaned_test_functions.jsonl/23951 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 540
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14020,
368,
341,
286,
1077,
10802,
284,
12539,
486,
931,
25592,
90515,
310,
8601,
486,
931,
445,
8926,
497,
33172,
486,
38980,
23,
11,
895,
1326,
310,
8601,
486,
931,
445,
5524,
497,
33172,
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_preimage_storage() {
// Simple test of payment preimage storage allowing no client-side storage to claim payments
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known()).0.contents.short_channel_id;
{
let (payment_hash, payment_secret) = nodes[1].node.create_inbound_payment(Some(100_000), 7200, 42);
let logger = test_utils::TestLogger::new();
let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph, &nodes[1].node.get_our_node_id(), Some(InvoiceFeatures::known()), None, &[], 100_000, TEST_FINAL_CLTV, &logger).unwrap();
nodes[0].node.send_payment(&route, payment_hash, &Some(payment_secret)).unwrap();
check_added_monitors!(nodes[0], 1);
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
let mut payment_event = SendEvent::from_event(events.pop().unwrap());
nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, false);
}
// Note that after leaving the above scope we have no knowledge of any arguments or return
// values from previous calls.
expect_pending_htlcs_forwardable!(nodes[1]);
let events = nodes[1].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
match events[0] {
Event::PaymentReceived { ref purpose, .. } => {
match &purpose {
PaymentPurpose::InvoicePayment { payment_preimage, user_payment_id, .. } => {
assert_eq!(*user_payment_id, 42);
claim_payment(&nodes[0], &[&nodes[1]], payment_preimage.unwrap());
},
_ => panic!("expected PaymentPurpose::InvoicePayment")
}
},
_ => panic!("Unexpected event"),
}
} | rust_cleaned_test_functions.jsonl/16953 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 778
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10442,
1805,
23310,
368,
341,
197,
322,
8993,
1273,
315,
8160,
855,
1805,
5819,
10693,
902,
2943,
24067,
5819,
311,
3717,
14173,
198,
10217,
26023,
1645,
18343,
82,
284,
1855,
45552,
1645,
18343,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_tokenizer_1number() {
let test_str = "4.2";
let tokens: Vec<Token> = Tokens::from_str(test_str).collect();
assert_eq!(tokens, vec![Token::Number(4.2)]);
} | rust_cleaned_test_functions.jsonl/109316 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 86
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6458,
3135,
62,
16,
4082,
368,
341,
262,
1077,
1273,
2895,
284,
330,
19,
13,
17,
876,
262,
1077,
11211,
25,
11312,
83416,
29,
284,
58166,
486,
1499,
2895,
8623,
2895,
568,
17384,
543,
262,
206... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_parsing_invalid_chars_at_eof() {
let mut parser = Parser::new();
parser.set_language(get_language("json")).unwrap();
let tree = parser.parse(b"\xdf", None).unwrap();
assert_eq!(tree.root_node().to_sexp(), "(ERROR (UNEXPECTED INVALID))");
} | rust_cleaned_test_functions.jsonl/15863 | {
"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,
620,
28598,
31433,
37418,
3752,
90792,
368,
341,
262,
1077,
5206,
6729,
284,
21102,
486,
931,
543,
262,
6729,
980,
29021,
5433,
29021,
445,
2236,
15197,
15454,
543,
262,
1077,
4916,
284,
6729,
463... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_from_into_traits() {
assert_ser_tokens(&EnumToU32::One, &[Token::Some, Token::U32(1)]);
assert_ser_tokens(&EnumToU32::Nothing, &[Token::None]);
assert_de_tokens(&EnumToU32::Two, &[Token::Some, Token::U32(2)]);
assert_ser_tokens(&StructFromEnum(Some(5)), &[Token::None]);
assert_ser_tokens(&StructFromEnum(None), &[Token::None]);
assert_de_tokens(&StructFromEnum(Some(2)), &[Token::Some, Token::U32(2)]);
assert_de_tokens(&TryFromU32::Two, &[Token::U32(2)]);
assert_de_tokens_error::<TryFromU32>(&[Token::U32(5)], "out of range");
} | rust_cleaned_test_functions.jsonl/59155 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 269
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5673,
45514,
39693,
368,
341,
262,
2060,
75861,
28838,
2099,
10766,
1249,
52,
18,
17,
486,
3966,
11,
44590,
3323,
486,
8373,
11,
9660,
486,
52,
18,
17,
7,
16,
41958,
262,
2060,
75861,
28838,
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_vld1q_u8() {
unsafe {
let a: [u8; 16] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
let e = transmute(a);
let r = vld1q_u8(transmute(&a));
assert!(cmp_arm(r, e));
}
} | rust_cleaned_test_functions.jsonl/33016 | {
"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,
2273,
507,
16,
80,
7300,
23,
368,
341,
286,
19860,
341,
310,
1077,
264,
25,
508,
84,
23,
26,
220,
16,
21,
60,
284,
508,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11,
220,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_match_quality() {
let matcher = ClangdMatcher::default();
// case
assert_order(&matcher, "monad", &["monad", "Monad", "mONAD"]);
// initials
assert_order(&matcher, "ab", &["ab", "aoo_boo", "acb"]);
assert_order(&matcher, "CC", &["CamelCase", "camelCase", "camelcase"]);
assert_order(&matcher, "cC", &["camelCase", "CamelCase", "camelcase"]);
assert_order(
&matcher,
"cc",
&[
"camel case",
"camelCase",
"camelcase",
"CamelCase",
"camel ace",
],
);
assert_order(
&matcher,
"Da.Te",
&["Data.Text", "Data.Text.Lazy", "Data.Aeson.Encoding.text"],
);
assert_order(&matcher, "foobar.h", &["foobar.h", "foo/bar.h"]);
// prefix
assert_order(&matcher, "is", &["isIEEE", "inSuf"]);
// shorter
assert_order(&matcher, "ma", &["map", "many", "maximum"]);
assert_order(&matcher, "print", &["printf", "sprintf"]);
assert_order(&matcher, "ast", &["ast", "AST", "INT_FAST16_MAX"]);
assert_order(&matcher, "Int", &["int", "INT", "PRINT"]);
} | rust_cleaned_test_functions.jsonl/17185 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 703
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10708,
55074,
368,
341,
286,
1077,
36052,
284,
2435,
524,
67,
37554,
486,
2258,
543,
286,
442,
1142,
198,
286,
2060,
7869,
2099,
70826,
11,
330,
1645,
329,
497,
609,
1183,
1645,
329,
497,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_request_parse_host_header_and_absolute_uri() {
let mut hyper_request = HttpRequest::new(Body::empty());
*hyper_request.method_mut() = Method::GET;
*hyper_request.uri_mut() = "http://my-host-uri/path".parse().unwrap();
hyper_request
.headers_mut()
.insert(headers::HOST, "my-host-header".parse().unwrap());
let iron_request = Request::from_http(hyper_request, None, &Protocol::http())
.expect("A valid Iron request");
assert_eq!(iron_request.url.host(), Domain("my-host-uri"));
} | rust_cleaned_test_functions.jsonl/73134 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 256
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7893,
21039,
12848,
8757,
8378,
50874,
15572,
368,
341,
286,
1077,
5206,
17071,
7893,
284,
44049,
486,
931,
5349,
1076,
486,
3194,
1423,
286,
353,
68192,
7893,
12908,
29523,
368,
284,
6730,
486,
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_on_pong() {
let frames = vec![HttpFrame::PingFrame(PingFrame::new_ack(123))];
let mut conn = HttpConnection::new(HttpScheme::Http);
let mut session = TestSession::new();
let mut frame_provider = MockReceiveFrame::new(frames);
conn.handle_next_frame(&mut frame_provider, &mut session).unwrap();
assert_eq!(session.pongs, vec![123]);
assert_eq!(session.pings, vec![]);
} | rust_cleaned_test_functions.jsonl/131345 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 194
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4470,
62,
59102,
368,
341,
286,
1077,
14087,
284,
7486,
20703,
2905,
4369,
486,
69883,
4369,
5304,
287,
4369,
486,
931,
48447,
7,
16,
17,
18,
81956,
286,
1077,
5206,
4534,
284,
4823,
4526,
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_zero_division() {
type LengthCm = Length<f32, Cm>;
let length: LengthCm = Length::new(5.0);
let length_zero: LengthCm = Length::zero();
let result = length / length_zero;
let expected: Scale<f32, Cm, Cm> = Scale::new(INFINITY);
assert_eq!(result, expected);
} | rust_cleaned_test_functions.jsonl/50595 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 155
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19359,
16237,
1816,
368,
341,
286,
943,
17287,
34,
76,
284,
17287,
63895,
18,
17,
11,
356,
76,
10133,
286,
1077,
3084,
25,
17287,
34,
76,
284,
17287,
486,
931,
7,
20,
13,
15,
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_player2_palces_stone_at_3_12_and_player1_takes_the_turn() {
ExtBuilder::build().execute_with(|| {
let alice_pair = account_pair("Alice");
let bob_pair = account_pair("Bob");
let (players, players_pair)
= get_sorted_peer(alice_pair, bob_pair);
let initiate_request = AppInitiateRequest {
nonce: 0,
players: players.clone(),
timeout: 2,
min_stone_offchain: 5,
max_stone_onchain: 5,
};
assert_ok!(SingleGomoku::app_initiate(
Origin::signed(players[0]),
initiate_request.clone())
);
let session_id = SingleGomoku::get_session_id(initiate_request.nonce, initiate_request.players.clone());
// place stone
place_stone(session_id, players.clone(), players_pair);
let settle_finalized_time = SingleGomoku::get_settle_finalized_time(session_id).unwrap();
System::set_block_number(settle_finalized_time + 1);
assert_ok!(
SingleGomoku::update_by_action(
Origin::signed(players[1]),
session_id,
vec![3, 12]
)
);
let turn = SingleGomoku::get_state(session_id, 0).unwrap();
assert_eq!(turn, vec![1]);
})
} | rust_cleaned_test_functions.jsonl/78908 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 680
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15524,
17,
73310,
1603,
1261,
603,
3752,
62,
18,
62,
16,
17,
8378,
15524,
16,
528,
2050,
16068,
37274,
368,
341,
262,
9447,
3297,
486,
5834,
1005,
10257,
6615,
79453,
341,
286,
1077,
70433,
1444... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_parse_valid_csi_xterm_mouse() {
let mut map = HashMap::<_, _>::from_iter(IntoIter::new([
(
"[<0;65;8;M",
Event::Mouse(MouseEvent::Press(MouseButton::Left, 65, 8)),
),
(
"[<1;5;2;M",
Event::Mouse(MouseEvent::Press(MouseButton::Middle, 5, 2)),
),
(
"[<2;65;8;M",
Event::Mouse(MouseEvent::Press(MouseButton::Right, 65, 8)),
),
(
"[<64;65;8;M",
Event::Mouse(MouseEvent::Press(MouseButton::WheelUp, 65, 8)),
),
(
"[<65;82;1;M",
Event::Mouse(MouseEvent::Press(MouseButton::WheelDown, 82, 1)),
),
("[<3;65;8;m", Event::Mouse(MouseEvent::Release(65, 8))),
("[<32;113;234;m", Event::Mouse(MouseEvent::Hold(113, 234))),
]));
let item = b'\x1B';
test_parse_event(item, &mut map);
} | rust_cleaned_test_functions.jsonl/122257 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 617
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
8337,
666,
6321,
3212,
4991,
39203,
368,
341,
286,
1077,
5206,
2415,
284,
10528,
27638,
6878,
716,
6831,
1499,
11723,
24123,
78,
8537,
486,
931,
8956,
310,
2399,
394,
10545,
27,
15,
26,
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_mod_str() {
let mut args = Parsed::new();
args.flg = vec!['u'];
assert_eq!(mod_str("upper-case", &args), "UPPER-CASE");
args.flg = vec!['u', 'a'];
args.app = String::from("-case");
assert_eq!(mod_str("upper", &args), "UPPER-CASE");
args.flg = vec!['u', 'i', 'r'];
args.app = String::new();
args.ins = String::from("upper");
assert_eq!(mod_str("-case", &args), "UPPER-CASE");
args.flg = vec!['l'];
assert_eq!(mod_str("Ho lA.LaY", &args), "ho_la.lay");
args.flg = vec!['r', 'u'];
assert_eq!(mod_str("Ho lA.LaY", &args), "HO_LA.LAY");
assert_eq!(mod_str("u'e&pª\".lay", &args), "UEP.LAY");
assert_eq!(mod_str("バンドメイド", &args), "バンドメイド");
assert_eq!(mod_str("ぽ\u{3000}", &args), "ぽ_");
} | rust_cleaned_test_functions.jsonl/27506 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 466
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7480,
2895,
368,
341,
286,
1077,
5206,
2827,
284,
393,
18112,
486,
931,
543,
286,
2827,
8103,
70,
284,
7486,
0,
677,
84,
3860,
286,
2060,
10714,
10297,
2593,
2895,
445,
13574,
38485,
497,
609,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_from_option() {
let config: Value = Value::String(String::from("S"));
assert_eq!(<Option<&str>>::from_config(&config).unwrap(), Some("S"));
} | rust_cleaned_test_functions.jsonl/8248 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 82
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5673,
9672,
368,
341,
286,
1077,
2193,
25,
5162,
284,
5162,
486,
703,
2242,
486,
1499,
445,
50,
4010,
286,
2060,
10714,
10297,
27,
5341,
52244,
495,
77595,
1499,
5332,
2099,
1676,
568,
15454,
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 |
#[test]
fn test_indices_iter_f_size_hint() {
let dim = (3, 4);
let mut it = indices_iter_f(dim);
let mut len = dim.0 * dim.1;
assert_eq!(it.len(), len);
while let Some(_) = it.next() {
len -= 1;
assert_eq!(it.len(), len);
}
assert_eq!(len, 0);
} | rust_cleaned_test_functions.jsonl/33889 | {
"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,
18333,
11723,
761,
2368,
45825,
368,
341,
286,
1077,
5103,
284,
320,
18,
11,
220,
19,
317,
286,
1077,
5206,
432,
284,
14937,
11723,
761,
36902,
317,
286,
1077,
5206,
2422,
284,
5103,
13,
15,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_iter() {
let mut coll = NonEmptyVec::new('g');
coll.push('a');
coll.push('l');
coll.push('h');
coll.push('b');
let mut iter = coll.iter();
assert_eq!(iter.next(), Some(&'g'));
assert_eq!(iter.next(), Some(&'a'));
assert_eq!(iter.next(), Some(&'l'));
assert_eq!(iter.next(), Some(&'h'));
assert_eq!(iter.next(), Some(&'b'));
assert_eq!(iter.next(), None);
} | rust_cleaned_test_functions.jsonl/67657 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 249
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11723,
368,
341,
286,
1077,
5206,
4530,
284,
11581,
3522,
10050,
486,
931,
492,
70,
1157,
286,
4530,
2552,
492,
64,
1157,
286,
4530,
2552,
492,
75,
1157,
286,
4530,
2552,
492,
71,
1157,
286,
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_dial_disconnect() {
::diem_logger::Logger::init_for_testing();
let runtime = ::tokio::runtime::Runtime::new().unwrap();
// Create a list of ordered PeerIds so we can ensure how PeerIds will be compared.
let ids = ordered_peer_ids(2);
let (mut peer_manager, _request_tx, _connection_reqs_tx, _hello_rx, mut conn_status_rx) =
build_test_peer_manager(runtime.handle().clone(), ids[1]);
let test = async move {
let (outbound, _inbound) = build_test_connection();
// Trigger add_peer function PeerManager.
peer_manager.add_peer(create_connection(
outbound,
ids[0],
NetworkAddress::mock(),
ConnectionOrigin::Outbound,
ConnectionId::from(0),
));
// Expect NewPeer notification from PeerManager.
let conn_notif = conn_status_rx.next().await.unwrap();
assert!(matches!(conn_notif, ConnectionNotification::NewPeer(_, _)));
// Send DisconnectPeer request to PeerManager.
let (disconnect_resp_tx, disconnect_resp_rx) = oneshot::channel();
peer_manager
.handle_connection_request(ConnectionRequest::DisconnectPeer(
ids[0],
disconnect_resp_tx,
))
.await;
// Send disconnected event from Peer to PeerManaager
let event = TransportNotification::Disconnected(
ConnectionMetadata::new(
ids[0],
ConnectionId::from(0),
NetworkAddress::mock(),
ConnectionOrigin::Outbound,
MessagingProtocolVersion::V1,
[TEST_PROTOCOL].iter().into(),
PeerRole::Unknown,
),
DisconnectReason::Requested,
);
peer_manager.handle_connection_event(event);
// Expect LostPeer notification from PeerManager.
let conn_notif = conn_status_rx.next().await.unwrap();
assert!(matches!(
conn_notif,
ConnectionNotification::LostPeer(_, _, _)
));
// Sender of disconnect request should receive acknowledgement once connection is closed.
disconnect_resp_rx.await.unwrap().unwrap();
};
runtime.block_on(test);
} | rust_cleaned_test_functions.jsonl/38534 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1024
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
814,
530,
67972,
368,
341,
262,
3504,
8579,
336,
27413,
486,
7395,
486,
2327,
5478,
70962,
543,
262,
1077,
15592,
284,
3504,
29594,
815,
486,
22255,
486,
15123,
486,
931,
1005,
15454,
1428,
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_greater_my_semver() {
let my = Version::new("5.1.2").unwrap();
let other = Version::new("3.12.99").unwrap();
assert_eq!(my.partial_cmp(&other), Some(Ordering::Greater));
assert_ne!(my, other);
} | rust_cleaned_test_functions.jsonl/54504 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 122
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
97994,
35686,
30442,
423,
368,
341,
286,
1077,
847,
284,
6079,
486,
931,
445,
20,
13,
16,
13,
17,
1827,
15454,
543,
286,
1077,
1008,
284,
6079,
486,
931,
445,
18,
13,
16,
17,
13,
24,
24,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_dont_fold_mixed_object_and_array_spread() {
fold_same("x = [...{}]");
fold_same("x = {...[]}");
fold("x = [a, ...[...{}]]", "x = [a, ...{}]");
fold("x = {a, ...{...[]}}", "x = {a, ...[]}");
} | rust_cleaned_test_functions.jsonl/122201 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 120
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
814,
544,
61187,
717,
3286,
5314,
8378,
3858,
10123,
878,
368,
341,
262,
11555,
33574,
445,
87,
284,
16303,
6257,
37389,
262,
11555,
33574,
445,
87,
284,
14916,
1294,
20305,
262,
11555,
445,
87,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_method_this_binding_3() {
check_output_default(
"class Foo {\n
init(x) {\n\
this.x = x;\n\
}\n\
getX() {\n\
return this.x;\n\
}\n\
}\n\
\n\
var foo = Foo(42);
print foo.getX();",
"42",
)
} | rust_cleaned_test_functions.jsonl/111854 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 288
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9032,
24868,
60815,
62,
18,
368,
341,
286,
1779,
7645,
9993,
1006,
310,
330,
1040,
33428,
28152,
77,
198,
2290,
2930,
2075,
8,
28152,
77,
5661,
338,
419,
1993,
284,
856,
17882,
77,
5661,
2290,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_build_remappings() {
use super::*;
let root = dunce::canonicalize("./test-data/test-contract-remappings").unwrap();
let paths = ProjectPathsConfig::builder()
.root(&root)
.sources(root.join("src"))
.lib(root.join("lib"))
.build()
.unwrap();
let project = Project::builder().no_artifacts().paths(paths).ephemeral().build().unwrap();
let compiled = project.compile().unwrap();
assert!(!compiled.has_compiler_errors());
let contracts = compiled.output().contracts;
assert_eq!(contracts.keys().count(), 2);
} | rust_cleaned_test_functions.jsonl/25400 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 296
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20801,
19194,
23036,
368,
341,
286,
990,
2256,
79304,
286,
1077,
3704,
284,
49016,
346,
486,
77942,
551,
13988,
1944,
13945,
12697,
14859,
2144,
12,
1826,
23036,
1827,
15454,
543,
286,
1077,
12716,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_param_taggypar() {
test_parameterized::<Taggypar<int>>(Onepar::<int>(1),
Twopar::<int>(1, 2),
Threepar::<int>(1, 2, 3),
Twopar::<int>(17, 42));
} | rust_cleaned_test_functions.jsonl/26213 | {
"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,
4090,
9372,
70,
1082,
277,
368,
341,
286,
1273,
24899,
1506,
27638,
5668,
70,
1082,
277,
4159,
25526,
1925,
11584,
27638,
396,
2235,
16,
1326,
3344,
11753,
453,
277,
27638,
396,
2235,
16,
11,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_async_ring_buffer() {
let ring_buffer = Arc::new(RingBuffer::new(32960));
let mut reader = RingBufferReader::new(ring_buffer.clone());
let mut writer = RingBufferWriter::new(ring_buffer.clone());
let t1 = thread::spawn(move ||{
let handle = task::spawn(async move {
let mut length = 0 as usize;
let mut contents: Vec<u8> = Vec::with_capacity(16096);
contents.resize(16096, 0);
loop {
match reader.read(&mut contents).await {
Ok(size) => {
if size > 0 {
length += size;
} else {
break;
}
},
Err(e) => {
panic!("read err = {}", e);
},
}
}
println!("length = {}", length);
});
task::block_on(handle);
});
let t2 = thread::spawn(move ||{
let handle = task::spawn(async move {
let mut length = 0 as usize;
let mut contents: Vec<u8> = Vec::new();
contents.put("warning: unused std::result::Result that must be used warning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be usedwarning: unused std::result::Result that must be used".as_bytes());
for i in 0..1024 as usize {
match writer.write_all(&mut contents).await {
Ok(()) => {
length += contents.len();
},
Err(e) => {
panic!("write err = {} index = {}", e, i);
},
}
}
println!("length = {}", length);
});
task::block_on(handle);
});
t1.join().unwrap();
t2.join().unwrap();
} | rust_cleaned_test_functions.jsonl/22913 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1286
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28346,
34683,
7776,
368,
341,
262,
1077,
10058,
7776,
284,
19689,
486,
931,
2785,
287,
4095,
486,
931,
7,
18,
17,
24,
21,
15,
1106,
1066,
262,
1077,
5206,
6604,
284,
21525,
4095,
5062,
486,
93... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_rebuild() {
let flag = NumberFormat::CSHARP7_LITERAL;
let rebuilt = flag.rebuild().decimal_point(b',').build().unwrap();
assert_eq!(flag.digit_separator(), b'_');
assert_eq!(rebuilt.digit_separator(), b'_');
assert_eq!(rebuilt.flags(), flag.flags());
assert_eq!(flag.decimal_point(), b'.');
assert_eq!(rebuilt.decimal_point(), b',');
} | rust_cleaned_test_functions.jsonl/70031 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 194
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1288,
5834,
368,
341,
286,
1077,
5181,
284,
5624,
4061,
486,
6412,
39,
42793,
22,
78047,
280,
286,
1077,
59585,
284,
5181,
1327,
5834,
1005,
23289,
6085,
1883,
516,
1823,
5834,
1005,
15454,
543,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 GenesisBlockInfo {
genesis_block,
mint_keypair: alice,
..
} = create_genesis_block(10_000);
let bob_pubkey = Pubkey::new_rand();
let bank = Bank::new(&genesis_block);
let arc_bank = Arc::new(bank);
let blockhash = arc_bank.last_blockhash();
let session = create_session();
let mut io = PubSubHandler::default();
let rpc = RpcSolPubSubImpl::default();
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 =
format!(r#"{{"jsonrpc":"2.0","id":1,"method":"signatureUnsubscribe","params":[0]}}"#);
let res = io.handle_request_sync(&req, session.clone());
let expected = format!(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 =
format!(r#"{{"jsonrpc":"2.0","id":1,"method":"signatureUnsubscribe","params":[1]}}"#);
let res = io.handle_request_sync(&req, session.clone());
let expected = format!(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/103081 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 841
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39859,
4907,
9384,
368,
341,
286,
1077,
40788,
4713,
1731,
341,
310,
59366,
7113,
345,
310,
28337,
3097,
12670,
25,
70433,
345,
310,
54538,
286,
335,
284,
1855,
16322,
13774,
7113,
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_gelf_decoder_bad_timestamp() {
let msg = r#"{"timestamp": "a string not a timestamp", "host": "anhostname"}"#;
let _res = GelfDecoder.decode(&msg).unwrap();
} | rust_cleaned_test_functions.jsonl/7192 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 92
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1889,
490,
49843,
34199,
23073,
368,
341,
286,
1077,
3750,
284,
435,
55543,
4913,
13035,
788,
330,
64,
914,
537,
264,
11441,
497,
330,
3790,
788,
330,
276,
27806,
9207,
57676,
280,
286,
1077,
71... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_factor() {
fn factor(n: uint) -> BigUint {
let mut f: BigUint = One::one();
for i in range(2, n + 1) {
f = f * FromPrimitive::from_uint(i).unwrap();
}
return f;
}
fn check(n: uint, s: &str) {
let n = factor(n);
let ans = match FromStrRadix::from_str_radix(s, 10) {
Some(x) => x, None => fail!()
};
assert_eq!(n, ans);
}
check(3, "6");
check(10, "3628800");
check(20, "2432902008176640000");
check(30, "265252859812191058636308480000000");
} | rust_cleaned_test_functions.jsonl/96912 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 416
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18588,
368,
341,
286,
5168,
8168,
1445,
25,
2622,
8,
1464,
6164,
21570,
341,
310,
1077,
5206,
282,
25,
6164,
21570,
284,
3776,
486,
603,
543,
310,
369,
600,
304,
2088,
7,
17,
11,
308,
488,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_forkpty() {
use nix::unistd::ForkResult::*;
use nix::sys::signal::*;
use nix::sys::wait::wait;
let _m0 = crate::PTSNAME_MTX.lock();
// forkpty spawns a child process
let _m1 = crate::FORK_MTX.lock();
let string = "naninani\n";
let echoed_string = "naninani\r\n";
let pty = unsafe {
forkpty(None, None).unwrap()
};
match pty.fork_result {
Child => {
write(STDOUT_FILENO, string.as_bytes()).unwrap();
pause(); // we need the child to stay alive until the parent calls read
unsafe { _exit(0); }
},
Parent { child } => {
let mut buf = [0u8; 10];
assert!(child.as_raw() > 0);
crate::read_exact(pty.master, &mut buf);
kill(child, SIGTERM).unwrap();
wait().unwrap(); // keep other tests using generic wait from getting our child
assert_eq!(&buf, echoed_string.as_bytes());
close(pty.master).unwrap();
},
}
} | rust_cleaned_test_functions.jsonl/72584 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 498
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
761,
669,
1595,
368,
341,
262,
990,
308,
941,
486,
27483,
486,
37,
669,
2077,
56162,
262,
990,
308,
941,
486,
7791,
486,
26622,
56162,
262,
990,
308,
941,
486,
7791,
486,
11489,
486,
11489,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_serialize_fail_packet_too_long_ipv4() {
let ser = (&[0; (1 << 16) - HEADER_BYTES][..]).into_serializer().encapsulate(
UdpPacketBuilder::new(TEST_SRC_IPV4, TEST_DST_IPV4, None, NonZeroU16::new(1).unwrap()),
);
let _ = ser.serialize_vec_outer();
} | rust_cleaned_test_functions.jsonl/112492 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 158
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
88686,
22121,
21078,
2346,
78,
17799,
49378,
19,
368,
341,
286,
1077,
1420,
284,
15899,
58,
15,
26,
320,
16,
1115,
220,
16,
21,
8,
481,
39665,
40705,
1457,
496,
10697,
18122,
67441,
1005,
954,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_eval_flag_satisfied_prereq() {
let mut store = TestStore::new();
let flag = store.flag("flagWithSatisfiedPrereq").unwrap().clone();
let alice = User::with_key("alice").build();
let bob = User::with_key("bob").build();
let detail = evaluate(&store, &flag, &alice, None);
asserting!("alice should pass prereq and see fallthrough")
.that(&detail.value)
.contains_value(&Bool(true));
let detail = evaluate(&store, &flag, &bob, None);
asserting!("bob should see prereq failed due to target")
.that(&detail.value)
.contains_value(&Bool(false));
assert_that!(detail.reason).is_equal_to(Reason::PrerequisiteFailed {
prerequisite_key: "prereq".to_string(),
});
// prerequisite off
store.update_flag("prereq", |flag| (flag.on = false));
for user in vec![&alice, &bob] {
let detail = evaluate(&store, &flag, user, None);
assert_that!(detail.value).contains_value(&Bool(false));
assert_that!(detail.reason).is_equal_to(&Reason::PrerequisiteFailed {
prerequisite_key: "prereq".to_string(),
});
}
} | rust_cleaned_test_functions.jsonl/133346 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 562
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21296,
10933,
643,
46265,
5294,
485,
80,
368,
341,
286,
1077,
5206,
3553,
284,
3393,
6093,
486,
931,
543,
286,
1077,
5181,
284,
3553,
41230,
445,
9903,
2354,
50,
46265,
3533,
485,
80,
1827,
1545... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_ended_chain() {
let xs = [1, 2, 3, 4, 5];
let ys = [7, 9, 11];
let mut it = xs.iter().chain(&ys).rev();
assert_eq!(it.next().unwrap(), &11);
assert_eq!(it.next().unwrap(), &9);
assert_eq!(it.next_back().unwrap(), &1);
assert_eq!(it.next_back().unwrap(), &2);
assert_eq!(it.next_back().unwrap(), &3);
assert_eq!(it.next_back().unwrap(), &4);
assert_eq!(it.next_back().unwrap(), &5);
assert_eq!(it.next_back().unwrap(), &7);
assert_eq!(it.next_back(), None);
struct CrazyIterator(bool);
impl CrazyIterator { fn new() -> CrazyIterator { CrazyIterator(false) } }
impl Iterator for CrazyIterator {
type Item = i32;
fn next(&mut self) -> Option<i32> {
if self.0 { Some(99) } else { self.0 = true; None }
}
}
impl DoubleEndedIterator for CrazyIterator {
fn next_back(&mut self) -> Option<i32> {
self.next()
}
}
assert_eq!(CrazyIterator::new().chain(0..10).rev().last(), Some(0));
assert!((0..10).chain(CrazyIterator::new()).rev().any(|i| i == 0));
} | rust_cleaned_test_functions.jsonl/25947 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 513
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
24598,
62,
2883,
30583,
368,
341,
262,
1077,
11943,
284,
508,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
935,
262,
1077,
31810,
284,
508,
22,
11,
220,
24,
11,
220,
16,
16,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_simple_text() {
let expected_attr_value = AttrValue::from_primitive("my text");
let widget = WidgetUse::simple_text(expected_attr_value.clone());
assert_eq!(
widget,
WidgetUse {
name: "label".to_owned(),
children: Vec::new(),
attrs: hashmap! { AttrName("text".to_owned()) => expected_attr_value},
..WidgetUse::default()
},
);
} | rust_cleaned_test_functions.jsonl/80195 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 252
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
30015,
4326,
368,
341,
286,
1077,
3601,
10422,
3142,
284,
50943,
1130,
486,
1499,
84087,
445,
2408,
1467,
797,
286,
1077,
9086,
284,
12980,
10253,
486,
22944,
4326,
15253,
10422,
3142,
15997,
1423,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_sysconf_unsupported() {
// we test.
let open_max = sysconf(SysconfVar::_XOPEN_CRYPT);
assert!(open_max.expect("sysconf failed").is_none())
} | rust_cleaned_test_functions.jsonl/9002 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 88
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20344,
6135,
4907,
18216,
368,
341,
9401,
262,
442,
582,
1273,
624,
262,
1077,
1787,
6345,
284,
5708,
6135,
3759,
1047,
6135,
3962,
13541,
55,
30933,
920,
40755,
317,
262,
2060,
10297,
2508,
6345,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_var_part_of_expr_stmt() {
check_assist(
extract_variable,
"
fn foo() {
$01$0 + 1;
}",
"
fn foo() {
let $0var_name = 1;
var_name + 1;
}",
);
} | rust_cleaned_test_functions.jsonl/132831 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 148
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39123,
4612,
10495,
3575,
21915,
21824,
368,
341,
286,
1779,
12083,
380,
1006,
310,
8649,
14635,
345,
310,
6228,
8822,
15229,
368,
341,
262,
400,
15,
16,
3,
15,
488,
220,
16,
280,
24375,
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_iterate_string_vec() {
let words = vec!["hello", "world"];
let capitalized_words: Vec<String> = words.iter().map(|a| {
capitalize_first(&a)
}).collect();
assert_eq!(capitalized_words, ["Hello", "World"]);
} | rust_cleaned_test_functions.jsonl/48143 | {
"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,
11723,
349,
3904,
13251,
368,
341,
286,
1077,
4244,
284,
7486,
0,
1183,
14990,
497,
330,
14615,
6332,
286,
1077,
97321,
18981,
25,
11312,
3464,
29,
284,
4244,
19471,
1005,
2186,
22428,
64,
91,
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_process_invalid_directory() {
let inspector = &Inspector::new();
process_file(&PathBuf::from("/i_dont_exist"), inspector.root());
assert_data_tree!(
inspector,
root: contains {
read_error: AnyProperty,
write_error: AnyProperty,
});
} | rust_cleaned_test_functions.jsonl/29241 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 159
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11305,
31433,
14846,
368,
341,
286,
1077,
44725,
284,
609,
46230,
486,
931,
543,
286,
1882,
2458,
2099,
1820,
15064,
486,
1499,
4283,
72,
814,
544,
35906,
3975,
44725,
12576,
1423,
286,
2060,
1769... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_hinter_empty() {
let data_model = test_model();
let dispatcher = Arc::new(RwLock::new(ControllerDispatcher::new(data_model)));
let helper = ScrutinyHelper::new(dispatcher);
let result = helper.complete("", 0).unwrap();
assert_eq!(result.1.len(), BuiltinCommand::commands().len());
} | rust_cleaned_test_functions.jsonl/76575 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 147
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1523,
2245,
15124,
368,
341,
286,
1077,
821,
5047,
284,
1273,
5047,
543,
286,
1077,
38799,
284,
19689,
486,
931,
2785,
86,
11989,
486,
931,
95482,
21839,
486,
931,
2592,
5047,
4945,
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... | 1 |
#[test]
fn test_decode_mux_command_empty_buf() {
let empty_buf = [];
assert_matches!(MuxCommand::decode(&empty_buf[..]), Err(FrameParseError::BufferTooSmall));
} | rust_cleaned_test_functions.jsonl/107768 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 84
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15227,
80363,
10811,
15124,
10363,
368,
341,
286,
1077,
4287,
10363,
284,
5907,
286,
2060,
38344,
10297,
44,
2200,
4062,
486,
18196,
2099,
3194,
10363,
95874,
9719,
15495,
91008,
14463,
1454,
486,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_journal_skip_fields() {
if !ensure_journald_socket() {
return;
}
let mut map: HashMap<&str, &str> = HashMap::new();
let priority = format!("{}", u8::from(Priority::Warning));
map.insert("TEST_JOURNALD_LOG3", "result");
map.insert("PRIORITY", &priority);
map.insert("MESSAGE", "Duplicate value");
journal_send(Priority::Info, "Test Skip Fields", map.iter()).unwrap()
} | rust_cleaned_test_functions.jsonl/39387 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 221
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
85075,
44830,
12132,
368,
341,
286,
421,
753,
27289,
5374,
3431,
4747,
19555,
368,
341,
310,
470,
280,
286,
555,
286,
1077,
5206,
2415,
25,
10528,
52244,
495,
11,
609,
495,
29,
284,
10528,
486,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_match_histograms() {
fn match_to_zebra_histogram(image: &GrayImage) -> GrayImage {
let zebra = load_input_image("zebra.png").to_luma();
imageproc::contrast::match_histogram(image, &zebra)
}
compare_to_truth_grayscale("elephant.png", "elephant_matched.png", match_to_zebra_histogram);
} | rust_cleaned_test_functions.jsonl/20073 | {
"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,
10708,
68564,
82,
368,
341,
262,
5168,
2432,
2346,
62,
2986,
14383,
68564,
10075,
25,
609,
28174,
1906,
8,
1464,
23366,
1906,
341,
286,
1077,
1147,
50213,
284,
2795,
5898,
4954,
445,
2986,
14383,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_keywords_inside_block() {
check(
r"fn quux() { if true { $0 } }",
expect![[r#"
kw unsafe
kw fn
kw const
kw type
kw impl
kw extern
kw use
kw trait
kw static
kw mod
kw match
kw while
kw while let
kw loop
kw if
kw if let
kw for
kw true
kw false
kw let
kw return
kw self
kw super
kw crate
"#]],
);
} | rust_cleaned_test_functions.jsonl/22463 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 565
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
51354,
72860,
7113,
368,
341,
286,
1779,
1006,
310,
435,
1,
8822,
922,
2200,
368,
314,
421,
830,
314,
400,
15,
335,
335,
756,
310,
1720,
0,
15505,
81,
2,
698,
394,
29525,
19860,
198,
394,
29... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_state_migration() {
let mut deps = mock_dependencies(20, &[]);
let mut legacy_state_store = state_old_store(&mut deps.storage);
legacy_state_store
.save(&LegacyState {
contract_addr: CanonicalAddr::default(),
poll_count: 0,
total_share: Uint128::zero(),
total_deposit: Uint128::zero(),
})
.unwrap();
migrate_state(&mut deps.storage).unwrap();
let state: State = state_read(&deps.storage).load().unwrap();
assert_eq!(
state,
State {
contract_addr: CanonicalAddr::default(),
poll_count: 0,
total_share: Uint128::zero(),
total_deposit: Uint128::zero(),
pending_voting_rewards: Uint128::zero(),
}
)
} | rust_cleaned_test_functions.jsonl/44521 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 482
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4387,
90373,
368,
341,
286,
1077,
5206,
48178,
284,
7860,
71841,
7,
17,
15,
11,
609,
56703,
286,
1077,
5206,
19588,
4387,
14809,
284,
1584,
21108,
14809,
2099,
6984,
48178,
22403,
317,
286,
19588,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_identical_squares() {
// Two identical sub paths. It is pretty much the worst type of input for
// the tessellator as far as I know.
let mut builder = Path::builder();
builder.begin(point(0.0, 0.0));
builder.line_to(point(1.0, 0.0));
builder.line_to(point(1.0, 1.0));
builder.line_to(point(0.0, 1.0));
builder.end(true);
builder.begin(point(0.0, 0.0));
builder.line_to(point(1.0, 0.0));
builder.line_to(point(1.0, 1.0));
builder.line_to(point(0.0, 1.0));
builder.end(true);
let path = builder.build();
test_path(path.as_slice());
} | rust_cleaned_test_functions.jsonl/102433 | {
"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,
38399,
938,
643,
40856,
368,
341,
262,
442,
9043,
19516,
1186,
12716,
13,
1084,
374,
5020,
1753,
279,
11785,
943,
315,
1946,
369,
198,
262,
442,
279,
79830,
613,
850,
438,
3041,
438,
358,
1414,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_public_ip_addr_tcp_unreachable() {
solana_logger::setup();
let ip_addr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
let (_server_port, (server_udp_socket, _server_tcp_listener)) =
bind_common_in_range(ip_addr, (3200, 3250)).unwrap();
// make the socket unreachable by not running the ip echo server!
let server_ip_echo_addr = server_udp_socket.local_addr().unwrap();
let (correct_client_port, (_client_udp_socket, client_tcp_listener)) =
bind_common_in_range(ip_addr, (3200, 3250)).unwrap();
assert!(!do_verify_reachable_ports(
&server_ip_echo_addr,
vec![(correct_client_port, client_tcp_listener)],
&[],
2,
3,
));
} | rust_cleaned_test_functions.jsonl/43716 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 401
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
27074,
10385,
7387,
45562,
4907,
46550,
368,
341,
286,
2048,
3362,
27413,
486,
15188,
543,
286,
1077,
5997,
7387,
284,
35033,
13986,
486,
53,
19,
8972,
30168,
19,
13986,
486,
931,
7,
15,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_scalar_multiplication() {
let c = 33.249539;
let p = Point1::from(27.6189);
let expected = Point1::from(p.x * c);
let result = p * c;
assert_eq!(result, expected);
} | rust_cleaned_test_functions.jsonl/4524 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 120
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
41652,
91802,
1693,
368,
341,
286,
1077,
272,
284,
220,
18,
18,
13,
17,
19,
24,
20,
18,
24,
26,
715,
286,
1077,
281,
284,
5126,
16,
486,
1499,
7,
17,
22,
13,
21,
16,
23,
24,
317,
286,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_newtype_variant() {
#[derive(Debug, PartialEq, Valuable, Serialize)]
enum E {
V(u8),
}
assert_ser_eq!(
E::V(0),
&[
Token::NewtypeVariant {
name: "E",
variant: "V"
},
Token::U8(0)
]
);
} | rust_cleaned_test_functions.jsonl/44213 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 211
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5921,
1313,
46112,
368,
341,
262,
11506,
27098,
42618,
11,
55039,
11,
4104,
13128,
11,
39900,
5563,
262,
7618,
468,
341,
286,
647,
8154,
23,
1326,
262,
555,
262,
2060,
75861,
10714,
33673,
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_send() {
use std::{fmt::Display, sync::mpsc, thread};
let mut stack: DynStack<dyn Display + Send> = DynStack::new();
dyn_push!(stack, String::from("1"));
let (sender, receiver) = mpsc::channel();
thread::spawn(move || {
dyn_push!(stack, String::from("2"));
sender.send(stack).unwrap();
});
let stack = receiver.recv().unwrap();
assert_eq!(stack.len(), 2);
assert_eq!(stack[0].to_string(), "1");
assert_eq!(stack[1].to_string(), "2");
} | rust_cleaned_test_functions.jsonl/21301 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 222
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13565,
368,
341,
262,
990,
1460,
22964,
12501,
486,
7020,
11,
12811,
486,
1307,
2388,
11,
4516,
2315,
262,
1077,
5206,
5611,
25,
43938,
4336,
92846,
10623,
488,
11000,
29,
284,
43938,
4336,
486,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_prune_shreds() {
use {
crate::serve_repair::ShredRepairType,
std::net::{IpAddr, Ipv4Addr},
};
solana_logger::setup();
let (common, coding) = Shredder::new_coding_shred_header(
5, // slot
5, // index
5, // fec_set_index
6, // num_data_shreds
6, // num_coding_shreds
4, // position
0, // version
);
let shred = Shred::new_empty_from_header(common, DataShredHeader::default(), coding);
let mut shreds = vec![shred.clone(), shred.clone(), shred];
let _from_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
let repair_meta = RepairMeta {
_from_addr,
nonce: 0,
};
let outstanding_requests = Arc::new(RwLock::new(OutstandingShredRepairs::default()));
let repair_type = ShredRepairType::Orphan(9);
let nonce = outstanding_requests
.write()
.unwrap()
.add_request(repair_type, timestamp());
let repair_meta1 = RepairMeta { _from_addr, nonce };
let mut repair_infos = vec![None, Some(repair_meta), Some(repair_meta1)];
prune_shreds_invalid_repair(&mut shreds, &mut repair_infos, &outstanding_requests);
assert_eq!(repair_infos.len(), 2);
assert!(repair_infos[0].is_none());
assert_eq!(repair_infos[1].as_ref().unwrap().nonce, nonce);
} | rust_cleaned_test_functions.jsonl/59860 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 752
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5294,
2886,
3712,
53369,
368,
341,
286,
990,
341,
310,
17717,
486,
13267,
1288,
12670,
486,
2016,
1151,
98386,
929,
345,
310,
1460,
486,
4711,
22964,
23378,
13986,
11,
358,
30168,
19,
13986,
1583,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_lif_manager_get_inexisting() {
let mut lm = LIFManager::new();
let l = LIF::new(
3,
LIFType::LAN,
"lan1",
PortId::from(0),
vec![PortId::from(1), PortId::from(2)],
0,
None,
)
.unwrap();
lm.add_lif(&l).unwrap();
lm.add_lif(
&LIF::new(3, LIFType::LAN, "lan2", PortId::from(0), vec![PortId::from(3)], 0, None)
.unwrap(),
)
.unwrap();
lm.add_lif(
&LIF::new(3, LIFType::WAN, "wan", PortId::from(0), vec![PortId::from(4)], 0, None)
.unwrap(),
)
.unwrap();
// Look for an entry that we know doesn't exist.
let got = lm.lif(&std::u128::MAX);
assert_eq!(got, None)
} | rust_cleaned_test_functions.jsonl/81916 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 507
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
907,
333,
12144,
3062,
1243,
36895,
368,
341,
286,
1077,
5206,
40238,
284,
444,
2773,
2043,
486,
931,
543,
286,
1077,
326,
284,
444,
2773,
486,
931,
1006,
310,
220,
18,
345,
310,
444,
2773,
92... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_inflation_fixed() {
let inflation = Inflation::new_fixed(0.001);
for year in &[0.1, 0.5, 1.0, DEFAULT_FOUNDATION_TERM, 100.0] {
assert_eq!(inflation.total(*year), 0.001);
}
} | rust_cleaned_test_functions.jsonl/19629 | {
"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,
1243,
64149,
37839,
368,
341,
286,
1077,
24527,
284,
758,
64149,
486,
931,
37839,
7,
15,
13,
15,
15,
16,
317,
286,
369,
1042,
304,
44590,
15,
13,
16,
11,
220,
15,
13,
20,
11,
220,
16,
13,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.