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_simple_succinct_sonic() {
use crate::pairing::ff::{Field, PrimeField};
use crate::pairing::{Engine, CurveAffine, CurveProjective};
use crate::pairing::bls12_381::{Bls12, Fr};
use std::time::{Instant};
use crate::sonic::srs::SRS;
use crate::sonic::cs::{Circuit, ConstraintSystem, LinearCombination};
struct MyCircuit;
impl<E: Engine> Circuit<E> for MyCircuit {
fn synthesize<CS: ConstraintSystem<E>>(&self, cs: &mut CS) -> Result<(), SynthesisError> {
let (a, b, c) = cs.multiply(|| {
Ok((
E::Fr::from_str("10").unwrap(),
E::Fr::from_str("20").unwrap(),
E::Fr::from_str("200").unwrap(),
))
})?;
cs.enforce_zero(LinearCombination::zero() + (Coeff::Full(E::Fr::from_str("2").unwrap()), a) - b);
cs.enforce_zero(LinearCombination::zero() + (Coeff::Full(E::Fr::from_str("20").unwrap()), a) - c);
cs.enforce_zero(LinearCombination::zero() + (Coeff::Full(E::Fr::from_str("10").unwrap()), b) - c);
// Ok((
Ok(())
}
}
let srs_x = Fr::from_str("23923").unwrap();
let srs_alpha = Fr::from_str("23728792").unwrap();
println!("making srs");
let start = Instant::now();
let srs = SRS::<Bls12>::new(100, srs_x, srs_alpha);
println!("done in {:?}", start.elapsed());
{
use rand::{XorShiftRng, SeedableRng, Rand, Rng};
let _rng = &mut XorShiftRng::from_seed([0x3dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);
use crate::sonic::sonic::Basic;
use crate::sonic::sonic::AdaptorCircuit;
use crate::sonic::helped::prover::{create_advice_on_srs, create_proof_on_srs};
use crate::sonic::helped::{MultiVerifier, get_circuit_parameters_for_succinct_sonic};
use crate::sonic::helped::helper::{create_aggregate_on_srs};
use crate::sonic::sonic::Permutation3;
use crate::sonic::unhelped::permutation_structure::*;
let z: Fr = Fr::from_str("2").unwrap();
let y: Fr = Fr::one();
let perm_structure = create_permutation_structure::<Bls12, _>(&MyCircuit);
let (non_permuted_coeffs, permutations) = perm_structure.create_permutation_vectors();
println!("Non-permuted = {:?}", non_permuted_coeffs[0]);
println!("Permutation = {:?}", permutations[0]);
println!("N = {}, Q = {}", perm_structure.n, perm_structure.q);
let n = perm_structure.n;
let szy = {
let mut tmp = SxEval::<Bls12>::new(y, n);
Permutation3::synthesize(&mut tmp, &MyCircuit).unwrap(); // TODO
tmp.finalize(z)
};
let naive_s1 = {
let mut res = Fr::zero();
for j in 0..permutations.len() {
for i in 0..non_permuted_coeffs[j].len() {
let sigma_i = permutations[j][i];
let coeff_i = non_permuted_coeffs[j][i];
// let coeff_sigma_i = non_permuted_coeffs[j][sigma_i - 1];
let y_power = y.pow([sigma_i as u64]);
let x_power = z.pow([(i+1) as u64]);
// let mut result = coeff_sigma_i;
let mut result = coeff_i;
result.mul_assign(&y_power);
result.mul_assign(&x_power);
res.add_assign(&result);
}
}
res
};
println!("Naive s1 = {}", naive_s1);
let signature = perm_structure.make_signature(y, z, &srs);
let s2 = S2Eval::new(perm_structure.n);
let s2 = s2.evaluate(z, y, &srs);
let mut s2_value = s2.c_value;
s2_value.add_assign(&s2.d_value);
let mut expected_s2_value = Fr::zero();
let y_inv = y.inverse().unwrap();
let mut p1 = y;
p1.add_assign(&y_inv);
p1.mul_assign(&z);
expected_s2_value.add_assign(&p1);
let mut t0 = y;
t0.square();
let mut t1 = y_inv;
t1.square();
let mut p2 = t0;
p2.add_assign(&t1);
p2.mul_assign(&z);
p2.mul_assign(&z);
expected_s2_value.add_assign(&p2);
let z_n = z.pow([n as u64]);
let z_n_plus_1_inv = z.pow([(n + 1) as u64]).inverse().unwrap();
let y_n = y.pow([n as u64]);
assert!(expected_s2_value == s2_value);
s2_value.mul_assign(&z_n);
let mut s1 = signature.perm_argument_proof.s_zy;
println!("S1 = {}", s1);
s1.mul_assign(&z_n_plus_1_inv);
s1.mul_assign(&y_n);
s1.sub_assign(&s2_value);
let mut naive_s1 = naive_s1;
naive_s1.mul_assign(&z_n_plus_1_inv);
naive_s1.mul_assign(&y_n);
naive_s1.sub_assign(&s2_value);
println!("S1(?) = {}", naive_s1);
assert_eq!(s1, szy);
}
} | rust_cleaned_test_functions.jsonl/751 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2815
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
30015,
70758,
7800,
643,
14011,
368,
341,
262,
990,
17717,
486,
12670,
287,
486,
542,
22964,
1877,
11,
12518,
1877,
2440,
262,
990,
17717,
486,
12670,
287,
22964,
4571,
11,
53677,
25841,
482,
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... | 3 |
#[test]
fn test_wire_size_basic_types() {
assert_eq!((42 as u8).wire_size(), 1);
assert_eq!((42 as u32).wire_size(), 4);
assert_eq!((42 as i32).wire_size(), 4);
assert_eq!((42 as u64).wire_size(), 8);
assert_eq!((42 as i64).wire_size(), 8);
assert_eq!((42_f32).wire_size(), 4);
assert_eq!((42_f64).wire_size(), 8);
assert_eq!(String::from("test!").wire_size(), 4 + 5 + 3);
let mut b = Bytes::new();
assert_eq!(b.wire_size(), 0);
let b = BytesMut::new().freeze();
assert_eq!(b.wire_size(), 0);
let b = BytesMut::from("test!").freeze();
assert_eq!(b.wire_size(), 5);
let b: &[u8] = &[1, 2, 3, 4];
assert_eq!(b.wire_size(), 4);
let b: &[u8] = &[1, 2, 3, 4, 5];
assert_eq!(b.wire_size(), 8); // Padded
} | rust_cleaned_test_functions.jsonl/38920 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 539
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
75206,
2368,
34729,
9763,
368,
341,
310,
2060,
10714,
0,
1188,
19,
17,
438,
575,
23,
568,
35531,
2368,
1507,
220,
16,
317,
310,
2060,
10714,
0,
1188,
19,
17,
438,
575,
18,
17,
568,
35531,
23... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ns_new_with_defaults() {
let ns = MmdsNetworkStack::new_with_defaults(None);
assert_eq!(ns.mac_addr, MacAddr::parse_str(DEFAULT_MAC_ADDR).unwrap());
assert_eq!(ns.ipv4_addr, Ipv4Addr::from(DEFAULT_IPV4_ADDR));
let ns = MmdsNetworkStack::new_with_defaults(Some(Ipv4Addr::LOCALHOST));
assert_eq!(ns.mac_addr, MacAddr::parse_str(DEFAULT_MAC_ADDR).unwrap());
assert_eq!(ns.ipv4_addr, Ipv4Addr::LOCALHOST);
} | rust_cleaned_test_functions.jsonl/47949 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 242
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34728,
5921,
6615,
42290,
368,
341,
286,
1077,
12268,
284,
386,
2277,
82,
12320,
4336,
486,
931,
6615,
42290,
26717,
317,
286,
2060,
10714,
10297,
4412,
61825,
7387,
11,
7401,
13986,
486,
6400,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_hint_from_value_and_back() {
for value in 0..243 {
let hint = Hints::from(value);
println!("{} = {}", hint, value);
assert_eq!(value, Hints::from(value).value());
}
} | rust_cleaned_test_functions.jsonl/57277 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 106
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
45825,
5673,
3142,
8378,
3895,
368,
341,
262,
369,
897,
304,
220,
15,
496,
17,
19,
18,
341,
286,
1077,
13012,
284,
472,
21042,
486,
1499,
3679,
317,
286,
13751,
17223,
6257,
284,
24689,
13012,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_runnables_doc_test() {
let (analysis, pos) = analysis_and_position(
r#"
//- /lib.rs
<|> //empty
fn main() {}
/// ```
/// let x = 5;
/// ```
fn foo() {}
"#,
);
let runnables = analysis.runnables(pos.file_id).unwrap();
assert_debug_snapshot!(&runnables,
@r###"
[
Runnable {
range: 1..21,
kind: Bin,
cfg_exprs: [],
},
Runnable {
range: 22..64,
kind: DocTest {
test_id: Path(
"foo",
),
},
cfg_exprs: [],
},
]
"###
);
} | rust_cleaned_test_functions.jsonl/115128 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 557
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14007,
77,
4788,
18869,
4452,
368,
341,
286,
1077,
320,
34484,
11,
1133,
8,
284,
6358,
8378,
9661,
1006,
310,
435,
2,
698,
286,
78406,
608,
2740,
25638,
198,
286,
82639,
29,
442,
3194,
198,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_chunks_sign() {
use randombytes::randombytes;
let (pk, sk) = gen_keypair();
let mut creation_state = State::init();
let mut validator_state = State::init();
for i in 0..64usize {
let chunk = randombytes(i);
creation_state.update(&chunk);
validator_state.update(&chunk);
}
let sig = creation_state.finalize(&sk);
assert!(validator_state.verify(&sig, &pk));
} | rust_cleaned_test_functions.jsonl/11407 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 233
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
65470,
11172,
368,
341,
286,
990,
4194,
9651,
486,
11463,
9651,
280,
286,
1077,
320,
20819,
11,
1901,
8,
284,
4081,
3097,
12670,
543,
286,
1077,
5206,
9688,
4387,
284,
3234,
486,
2327,
543,
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... | 2 |
#[test]
fn test_include_bytes_expand() {
check(
r#"
#[rustc_builtin_macro]
macro_rules! include_bytes {
($file:expr) => {{ /* compiler built-in */ }};
($file:expr,) => {{ /* compiler built-in */ }};
}
fn main() { include_bytes("foo"); }
"#,
expect![[r##"
#[rustc_builtin_macro]
macro_rules! include_bytes {
($file:expr) => {{ /* compiler built-in */ }};
($file:expr,) => {{ /* compiler built-in */ }};
}
fn main() { include_bytes("foo"); }
"##]],
);
} | rust_cleaned_test_functions.jsonl/59820 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 219
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
37878,
12524,
67875,
368,
341,
262,
1779,
1006,
286,
435,
2,
698,
13353,
35788,
66,
73829,
58810,
921,
32606,
21407,
0,
2924,
12524,
341,
262,
1711,
1192,
96011,
8,
589,
5867,
1391,
19415,
5798,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_filter_vertex_prop_has_key() {
let mut has_key_compare = message::LogicalCompare::new();
has_key_compare.set_prop_id(PROP_KEY);
has_key_compare.set_compare(message::CompareType::EQ);
let mut value_k = Value::new();
value_k.set_str_value("age".to_owned());
value_k.set_value_type(VariantType::VT_STRING);
has_key_compare.set_value(value_k);
has_key_compare.set_field_type(VariantType::VT_STRING);
let mut has_val_compare = message::LogicalCompare::new();
has_val_compare.set_prop_id(PROP_VALUE);
has_val_compare.set_compare(message::CompareType::EQ);
let mut value_v = Value::new();
value_v.set_int_value(30);
value_v.set_value_type(VariantType::VT_INT);
has_val_compare.set_value(value_v);
has_val_compare.set_field_type(VariantType::VT_INT);
let schema = build_modern_mock_schema();
let age_id = schema.get_prop_id("age").unwrap();
let compare_list = vec![has_key_compare, has_val_compare];
let filter_manager = FilterManager::new(&compare_list, Arc::new(LocalGraphSchema::new(Arc::new(schema))));
let mut p1 = RawMessage::new(RawMessageType::PROP);
p1.set_id(IdMessage::new(0, age_id as i64));
p1.set_value(ValuePayload::Int(30));
let v1_flag = filter_manager.filter_message(&p1);
assert_eq!(true, v1_flag);
let mut p2 = RawMessage::new(RawMessageType::PROP);
p2.set_id(IdMessage::new(0, age_id as i64));
p2.set_value(ValuePayload::Int(35));
let v2_flag = filter_manager.filter_message(&p2);
assert_eq!(false, v2_flag);
} | rust_cleaned_test_functions.jsonl/43856 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 790
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8727,
26611,
21663,
21778,
3097,
368,
341,
286,
1077,
5206,
702,
3097,
32235,
284,
1943,
486,
64312,
27374,
486,
931,
543,
286,
702,
3097,
32235,
980,
21663,
842,
5304,
19272,
6600,
317,
286,
702,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_contains() {
let mut mask = SigSet::empty();
mask.add(SIGUSR1);
assert!(mask.contains(SIGUSR1));
assert!(!mask.contains(SIGUSR2));
let all = SigSet::all();
assert!(all.contains(SIGUSR1));
assert!(all.contains(SIGUSR2));
} | rust_cleaned_test_functions.jsonl/8923 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 163
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
63598,
368,
341,
286,
1077,
5206,
6911,
284,
41560,
1649,
486,
3194,
543,
286,
6911,
1364,
52516,
49558,
16,
626,
286,
2060,
10297,
11258,
8786,
52516,
49558,
16,
1106,
286,
2060,
0,
3471,
11258,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_vec3mask_eq() {
let a = Vec3Mask::new(true, false, true);
let b = Vec3Mask::new(true, false, true);
let c = Vec3Mask::new(false, true, true);
assert_eq!(a, b);
assert_eq!(b, a);
assert_ne!(a, c);
assert_ne!(b, c);
assert!(a > c);
assert!(c < a);
} | rust_cleaned_test_functions.jsonl/75052 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 154
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13251,
18,
11258,
10714,
368,
341,
262,
1077,
264,
284,
11312,
18,
12686,
486,
931,
3715,
11,
895,
11,
830,
317,
262,
1077,
293,
284,
11312,
18,
12686,
486,
931,
3715,
11,
895,
11,
830,
317,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_read_fasttext() {
let f = File::open("testdata/fasttext.bin").unwrap();
let mut reader = BufReader::new(f);
let embeddings = Embeddings::read_fasttext(&mut reader).unwrap();
let results = embeddings.word_similarity("über", 3).unwrap();
assert_eq!(results[0].word, "auf");
assert_abs_diff_eq!(*results[0].similarity, 0.568513, epsilon = 1e-6);
assert_eq!(results[1].word, "vor");
assert_abs_diff_eq!(*results[1].similarity, 0.551551, epsilon = 1e-6);
assert_eq!(results[2].word, "durch");
assert_abs_diff_eq!(*results[2].similarity, 0.547349, epsilon = 1e-6);
} | rust_cleaned_test_functions.jsonl/28569 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 312
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
35743,
1318,
368,
341,
286,
1077,
282,
284,
2887,
486,
2508,
445,
92425,
92351,
1318,
29394,
1827,
15454,
543,
286,
1077,
5206,
6604,
284,
69013,
5062,
486,
931,
955,
317,
286,
1077,
70547,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_zero_date() -> Result<()> {
let mut ctx = EvalContext::from(TimeEnv {
no_zero_date: true,
..TimeEnv::default()
});
let _ = Time::parse_datetime(&mut ctx, "0000-00-00 00:00:00", 0, false)?;
assert!(ctx.warnings.warning_cnt > 0);
// Enable both NO_ZERO_DATE and STRICT_MODE.
let mut ctx = EvalContext::from(TimeEnv {
no_zero_date: true,
strict_mode: true,
..TimeEnv::default()
});
assert!(Time::parse_datetime(&mut ctx, "0000-00-00 00:00:00", 0, false).is_err());
let mut ctx = EvalContext::from(TimeEnv {
no_zero_date: true,
strict_mode: true,
ignore_truncate: true,
..TimeEnv::default()
});
assert_eq!(
"0000-00-00 00:00:00",
Time::parse_datetime(&mut ctx, "0000-00-00 00:00:00", 0, false)?.to_string()
);
assert!(ctx.warnings.warning_cnt > 0);
let cases = vec![
"2019-12-31 24:23:22",
"2019-12-31 23:60:22",
"2019-12-31 23:24:60",
];
for case in cases {
let mut ctx = EvalContext::from(TimeEnv {
no_zero_date: true,
strict_mode: true,
..TimeEnv::default()
});
assert!(Time::parse_datetime(&mut ctx, case, 0, false).is_err());
}
Ok(())
} | rust_cleaned_test_functions.jsonl/40462 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 872
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6536,
19359,
4164,
368,
1464,
5714,
71698,
341,
1789,
286,
1077,
5206,
5635,
284,
58239,
1972,
486,
1499,
36968,
14359,
341,
310,
902,
19359,
4164,
25,
830,
345,
310,
5241,
1462,
14359,
486,
2258,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
#[test]
fn test_search_file_abs_path() {
let sf = SearchFile::new(
"/Users/cary/src/xsearch/rust/rssearch/src".to_string(),
"searcher.rs".to_string(),
FileType::Code,
);
assert_eq!(
sf.filepath(),
"/Users/cary/src/xsearch/rust/rssearch/src/searcher.rs"
);
} | rust_cleaned_test_functions.jsonl/113975 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 204
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10716,
2458,
31170,
2638,
368,
341,
286,
1077,
13124,
284,
7542,
1703,
486,
931,
1006,
310,
3521,
7137,
2899,
658,
13437,
10776,
1836,
7382,
590,
91885,
1836,
13437,
3263,
983,
3904,
3148,
310,
33... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_autowired_batch() {
let mut worker = Builder::new("test-worker-batch").batch_size(10).create();
let (tx, rx) = mpsc::channel();
worker.start(StepRunner { ch: tx }).unwrap();
for _ in 0..20 {
worker.schedule(50).unwrap();
}
worker.stop().unwrap().join().unwrap();
for _ in 0..20 {
rx.recv_timeout(Duration::from_secs(3)).unwrap();
}
assert_eq!(rx.recv().unwrap(), 0);
} | rust_cleaned_test_functions.jsonl/84781 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 245
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
32808,
363,
2690,
14534,
368,
341,
286,
1077,
5206,
11864,
284,
20626,
486,
931,
445,
1944,
65516,
1455,
754,
1827,
14049,
2368,
7,
16,
15,
568,
3182,
543,
286,
1077,
320,
3998,
11,
19111,
8,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_indexed_path() {
let text = "{ foo.0.bar }";
let instructions = compile(text).unwrap();
assert_eq!(1, instructions.len());
assert_eq!(
&Value(vec![
PathStep::Name("foo"),
PathStep::Index("0", 0),
PathStep::Name("bar")
]),
&instructions[0]
);
} | rust_cleaned_test_functions.jsonl/18171 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 237
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3560,
291,
2638,
368,
972,
286,
1077,
1467,
284,
13868,
15229,
13,
15,
22001,
335,
3534,
286,
1077,
11221,
284,
19192,
7235,
568,
15454,
1647,
286,
2060,
10714,
10297,
16,
11,
11221,
19406,
6201,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_unchanged_ranges_insert_in_middle() {
assert_eq!(
unchanged_ranges(
b"a b b c",
b"a b X b c",
&[0..1, 2..3, 4..5, 6..7],
&[0..1, 2..3, 4..5, 6..7, 8..9],
),
vec![(0..1, 0..1), (2..3, 2..3), (4..5, 6..7), (6..7, 8..9)]
);
} | rust_cleaned_test_functions.jsonl/89249 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 254
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
3185,
3726,
58748,
17678,
1243,
62580,
368,
341,
286,
2060,
10714,
33673,
310,
34857,
58748,
1006,
394,
293,
56693,
293,
293,
272,
756,
394,
293,
56693,
293,
1599,
293,
272,
756,
394,
44590,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_response_for_ticker() {
let mock_transport = MockRequest::new(
"{\"status\":\"success\",\"data\":[{\"high\":\"6888\",\"volume\":\"13.03\",\"low\":\"6303\",\"ask\":\"6887\",\"timestamp\":\"2017-08-2915:44:17.267526\",\"bid\":\"6416\",\"last_price\":\"6610\",\"market\":\"ETHARS\"}]}",
"",
);
let api = Api::<MockRequest>::new(API_KEY, SECRET_KEY, Box::new(mock_transport));
let expected = json!({
"status":"success","data":[{"high":"6888","volume":"13.03","low":"6303","ask":"6887","timestamp":"2017-08-2915:44:17.267526","bid":"6416","last_price":"6610","market":"ETHARS"}]
});
let mut ticker_params = HashMap::new();
ticker_params.insert("market".to_string(), "ETHARS".to_string());
let resp = api
.get_edge::<TickerResponse>("ticker", ticker_params, true)
.unwrap();
assert_eq!(
resp.status, expected["status"],
"Los estados de la petición no coinciden: Valor de la respuesta {:?} Valor esperado: {:?}",
resp, expected
);
for it in 1..resp.data.len() {
assert_eq!(
resp.data[it].high, expected["data"][it]["high"],
"Los mercados no coinciden: Valor respondido {:?} Valor esperado: {:?}",
resp, expected
);
}
} | rust_cleaned_test_functions.jsonl/75229 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 673
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9655,
5478,
528,
5215,
368,
341,
286,
1077,
7860,
46398,
284,
14563,
1900,
486,
931,
1006,
310,
54734,
2829,
23488,
5630,
34333,
691,
59,
8899,
64238,
11892,
23488,
21,
23,
23,
23,
34333,
25060,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_decompression() {
use std::vec::Vec;
for sz in [600_usize, 1024, 6000, 65000, 650000].iter() {
let mut orig: Vec<u8> = Vec::with_capacity(*sz);
unsafe {
orig.set_len(*sz);
{
//it's sort of randomized data
orig[0] = 1;
orig[*sz / 4] = 4;
orig[*sz / 2] = 7;
orig[*sz * 2 / 3] = 10;
orig[*sz - 1] = 1;
}
let bz = LZ4_compressBound(*sz as c_int) as usize;
let mut comp: Vec<u8> = Vec::with_capacity(bz);
comp.set_len(bz);
let code = LZ4_compress_default(
orig.as_ptr() as *const c_char,
comp.as_mut_ptr() as *mut c_char,
(orig.len()) as i32,
(bz) as i32,
);
assert!(code > 0);
//size of compressed data
println!(
"orig {}; compressed {}; in buf len {}",
*sz,
code as usize,
comp.len()
);
//compressed size
let cz = code as usize;
let mut buf: Vec<u8> = Vec::with_capacity(*sz);
buf.set_len(*sz);
let code = LZ4_decompress_safe(
comp.as_ptr() as *const c_char,
buf.as_mut_ptr() as *mut c_char,
cz as i32,
*sz as i32,
);
assert!(code > 0);
let cz = code as usize;
assert_eq!(cz, *sz);
assert_eq!(&orig[0..*sz], &buf[0..cz]);
}
}
} | rust_cleaned_test_functions.jsonl/34956 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1220
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2259,
83192,
368,
341,
286,
990,
1460,
486,
4083,
486,
10050,
280,
23459,
286,
369,
10038,
304,
508,
21,
15,
15,
11306,
551,
11,
220,
16,
15,
17,
19,
11,
220,
21,
15,
15,
15,
11,
220,
21,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_consistency_check() {
let path = Builder::new().prefix("tikv-store-test").tempdir().unwrap();
let db = new_engine(
path.path().to_str().unwrap(),
None,
&[CF_DEFAULT, CF_RAFT],
None,
)
.unwrap();
let mut region = Region::default();
region.mut_peers().push(Peer::default());
let (tx, rx) = mpsc::sync_channel(100);
let mut host = CoprocessorHost::<RocksEngine>::new(tx.clone());
host.registry.register_consistency_check_observer(
100,
BoxConsistencyCheckObserver::new(RawConsistencyCheckObserver::default()),
);
let mut runner = Runner::new(tx, host);
let mut digest = crc32fast::Hasher::new();
let kvs = vec![(b"k1", b"v1"), (b"k2", b"v2")];
for (k, v) in kvs {
let key = keys::data_key(k);
db.put(&key, v).unwrap();
// hash should contain all kvs
digest.update(&key);
digest.update(v);
}
// hash should also contains region state key.
digest.update(&keys::region_state_key(region.get_id()));
let sum = digest.finalize();
runner.run(Task::<RocksSnapshot>::ComputeHash {
index: 10,
context: vec![ConsistencyCheckMethod::Raw as u8],
region: region.clone(),
snap: db.snapshot(),
});
let mut checksum_bytes = vec![];
checksum_bytes.write_u32::<BigEndian>(sum).unwrap();
let res = rx.recv_timeout(Duration::from_secs(3)).unwrap();
match res {
(
region_id,
CasualMessage::ComputeHashResult {
index,
hash,
context,
},
) => {
assert_eq!(region_id, region.get_id());
assert_eq!(index, 10);
assert_eq!(context, vec![0]);
assert_eq!(hash, checksum_bytes);
}
e => panic!("unexpected {:?}", e),
}
} | rust_cleaned_test_functions.jsonl/18719 | {
"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,
31971,
47094,
7200,
368,
341,
286,
1077,
1815,
284,
20626,
486,
931,
1005,
11849,
445,
83,
1579,
85,
33252,
16839,
1827,
3888,
3741,
1005,
15454,
543,
286,
1077,
2927,
284,
501,
24823,
1006,
310,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_uint_from_sub_no_panic() {
assert_eq!(
Uint256::from(1u32).sub(Uint256::from(1u8)),
Uint256::from(0u32)
);
} | rust_cleaned_test_functions.jsonl/118515 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 89
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15807,
5673,
5228,
6536,
620,
31270,
368,
341,
262,
2060,
10714,
33673,
286,
27883,
17,
20,
21,
486,
1499,
7,
16,
84,
18,
17,
568,
1966,
12317,
396,
17,
20,
21,
486,
1499,
7,
16,
84,
23,
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 |
#[test]
fn test_problem() {
{
let mut problem = Problem::new(5, 3);
problem.set_clue(ClueLoc::Top, 1, Clue(1));
let field = Field::from_problem(&problem);
assert_eq!(field.cand[P(0, 1)], Cand(2));
assert_eq!(field.cand[P(4, 1)], Cand(5));
}
} | rust_cleaned_test_functions.jsonl/72396 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 183
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
60139,
368,
341,
286,
341,
310,
1077,
5206,
3491,
284,
22079,
486,
931,
7,
20,
11,
220,
18,
317,
310,
3491,
980,
6794,
361,
43644,
361,
9152,
486,
5366,
11,
220,
16,
11,
2435,
361,
7,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_reaction_without_member() {
let expected = Reaction {
channel_id: ChannelId(2),
emoji: ReactionType::Unicode {
name: "🙂".to_owned(),
},
guild_id: None,
member: None,
message_id: MessageId(3),
user_id: UserId(4),
};
serde_test::assert_tokens(
&expected,
&[
Token::Struct {
name: "Reaction",
len: 6,
},
Token::Str("channel_id"),
Token::NewtypeStruct { name: "ChannelId" },
Token::Str("2"),
Token::Str("emoji"),
Token::Struct {
name: "ReactionType",
len: 1,
},
Token::Str("name"),
Token::Str("🙂"),
Token::StructEnd,
Token::Str("guild_id"),
Token::None,
Token::Str("member"),
Token::None,
Token::Str("message_id"),
Token::NewtypeStruct { name: "MessageId" },
Token::Str("3"),
Token::Str("user_id"),
Token::NewtypeStruct { name: "UserId" },
Token::Str("4"),
Token::StructEnd,
],
);
} | rust_cleaned_test_functions.jsonl/10392 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 873
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
96631,
39904,
19388,
368,
341,
286,
1077,
3601,
284,
66841,
341,
310,
5496,
842,
25,
13434,
764,
7,
17,
1326,
310,
42365,
25,
66841,
929,
486,
33920,
341,
394,
829,
25,
330,
145080,
3263,
983,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_cp_parents() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.arg("--parents")
.arg(TEST_COPY_FROM_FOLDER_FILE)
.arg(TEST_COPY_TO_FOLDER)
.succeeds();
assert_eq!(
at.read(&format!(
"{}/{}",
TEST_COPY_TO_FOLDER, TEST_COPY_FROM_FOLDER_FILE
)),
"Hello, World!\n"
);
} | rust_cleaned_test_functions.jsonl/21267 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 230
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39811,
81719,
368,
341,
262,
1077,
320,
266,
11,
5206,
575,
8710,
8,
284,
518,
8378,
68887,
2277,
0,
1428,
262,
575,
8710,
21186,
21549,
25456,
1138,
286,
659,
858,
50320,
35556,
27108,
33637,
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_stream_instant() {
let a = StreamInstant::new(2, 0);
let b = StreamInstant::new(-2, 0);
let min = StreamInstant::new(std::i64::MIN, 0);
let max = StreamInstant::new(std::i64::MAX, 0);
assert_eq!(
a.sub(Duration::from_secs(1)),
Some(StreamInstant::new(1, 0))
);
assert_eq!(
a.sub(Duration::from_secs(2)),
Some(StreamInstant::new(0, 0))
);
assert_eq!(
a.sub(Duration::from_secs(3)),
Some(StreamInstant::new(-1, 0))
);
assert_eq!(min.sub(Duration::from_secs(1)), None);
assert_eq!(
b.add(Duration::from_secs(1)),
Some(StreamInstant::new(-1, 0))
);
assert_eq!(
b.add(Duration::from_secs(2)),
Some(StreamInstant::new(0, 0))
);
assert_eq!(
b.add(Duration::from_secs(3)),
Some(StreamInstant::new(1, 0))
);
assert_eq!(max.add(Duration::from_secs(1)), None);
} | rust_cleaned_test_functions.jsonl/32481 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 468
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12673,
1243,
4706,
368,
341,
262,
1077,
264,
284,
9203,
30340,
486,
931,
7,
17,
11,
220,
15,
317,
262,
1077,
293,
284,
9203,
30340,
486,
931,
4080,
17,
11,
220,
15,
317,
262,
1077,
1308,
284... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_assert_setup() {
// Defaults
{
let tmpdir = assert_setup!();
assert_dir!(&tmpdir);
assert_eq!(&tmpdir, &PathBuf::from(TEST_TEMP_DIR).mash("test_assert_setup"));
assert_remove_all!(&tmpdir);
}
// Alternate func name
{
let func_name = "test_assert_setup_alt_func";
let tmpdir = assert_setup!(&func_name);
assert_dir!(&tmpdir);
assert_eq!(&tmpdir, &PathBuf::from(TEST_TEMP_DIR).mash(&func_name));
assert_remove_all!(&tmpdir);
}
// Alternate temp dir name and func name
{
let root = "tests/temp/test_assert_setup_dir";
let func_name = "test_assert_setup_alt_func";
let tmpdir = assert_setup!(&root, &func_name);
assert_dir!(&tmpdir);
assert_eq!(&tmpdir, &PathBuf::from(&root).mash(&func_name));
assert_remove_all!(&root);
}
} | rust_cleaned_test_functions.jsonl/92820 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 523
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16553,
21363,
368,
341,
286,
442,
35990,
198,
286,
341,
310,
1077,
4174,
3741,
284,
2060,
21363,
0,
543,
310,
2060,
4334,
0,
2099,
5173,
3741,
317,
310,
2060,
10714,
0,
2099,
5173,
3741,
11,
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... | 1 |
#[test]
fn test_start_not_a_number() {
let model =
"a";
match DFAReader::new_from_string(model) {
Err(DFAReaderError::Parse(_,line)) => assert!(line == 1),
_ => assert!(false, "Parse expected."),
}
} | rust_cleaned_test_functions.jsonl/47826 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 145
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4906,
7913,
4306,
5500,
368,
341,
286,
1077,
1614,
4035,
310,
330,
64,
876,
286,
2432,
93631,
5062,
486,
931,
5673,
3904,
7635,
8,
341,
310,
15495,
5432,
3627,
5062,
1454,
486,
14463,
41117,
105... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_realm_get_from() -> Result<()> {
let mut m = Message::new();
let v = "realm".to_owned();
m.add(ATTR_REALM, v.as_bytes());
m.write_header();
let mut m2 = Message {
raw: Vec::with_capacity(256),
..Default::default()
};
let result = TextAttribute::get_from_as(&m2, ATTR_REALM);
if let Err(err) = result {
assert_eq!(
Error::ErrAttributeNotFound,
err,
"GetFrom should return {}, got: {}",
Error::ErrAttributeNotFound,
err
);
} else {
assert!(false, "Expected error, but got ok");
}
let mut reader = BufReader::new(m.raw.as_slice());
m2.read_from(&mut reader)?;
let r = TextAttribute::get_from_as(&m, ATTR_REALM)?;
assert_eq!(r.to_string(), v, "Expected {}, got {}.", v, r);
let (r_attr, ok) = m.attributes.get(ATTR_REALM);
assert!(ok, "realm attribute should be found");
let s = r_attr.to_string();
assert!(s.starts_with("REALM:"), "bad string representation {}", s);
Ok(())
} | rust_cleaned_test_functions.jsonl/57158 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 504
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1288,
7673,
3062,
5673,
368,
1464,
5714,
71698,
341,
262,
1077,
5206,
296,
284,
4856,
486,
931,
543,
262,
1077,
348,
284,
330,
69897,
3263,
983,
51973,
543,
262,
296,
1364,
7,
27880,
30111,
44,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
#[test]
fn test_case_part_2_easy() {
let input = "acedgfb cdfbe gcdfa fbcad dab cefabd cdfgeb eafb cagedb ab | cdfeb fcadb cdfeb cdbaf\n";
assert_eq!(5353, part2(input).unwrap())
} | rust_cleaned_test_functions.jsonl/119557 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 110
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19096,
10495,
62,
17,
59091,
368,
341,
286,
1077,
1946,
284,
330,
4435,
70,
10798,
272,
2940,
1371,
22122,
97549,
282,
8904,
329,
82768,
272,
823,
85920,
272,
2940,
42153,
384,
96834,
272,
3279,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_aggregate() {
let ip_nets = make_ipnet_vec![
"10.0.0.0/24", "10.0.1.0/24", "10.0.1.1/24", "10.0.1.2/24",
"10.0.2.0/24",
"10.1.0.0/24", "10.1.1.0/24",
"192.168.0.0/24", "192.168.1.0/24", "192.168.2.0/24", "192.168.3.0/24",
"fd00::/32", "fd00:1::/32",
"fd00:2::/32",
];
let ip_aggs = make_ipnet_vec![
"10.0.0.0/23",
"10.0.2.0/24",
"10.1.0.0/23",
"192.168.0.0/22",
"fd00::/31",
"fd00:2::/32",
];
let ipv4_nets: Vec<Ipv4Net> = ip_nets.iter().filter_map(|p| if let IpNet::V4(x) = *p { Some(x) } else { None }).collect();
let ipv4_aggs: Vec<Ipv4Net> = ip_aggs.iter().filter_map(|p| if let IpNet::V4(x) = *p { Some(x) } else { None }).collect();
let ipv6_nets: Vec<Ipv6Net> = ip_nets.iter().filter_map(|p| if let IpNet::V6(x) = *p { Some(x) } else { None }).collect();
let ipv6_aggs: Vec<Ipv6Net> = ip_aggs.iter().filter_map(|p| if let IpNet::V6(x) = *p { Some(x) } else { None }).collect();
assert_eq!(IpNet::aggregate(&ip_nets), ip_aggs);
assert_eq!(Ipv4Net::aggregate(&ipv4_nets), ipv4_aggs);
assert_eq!(Ipv6Net::aggregate(&ipv6_nets), ipv6_aggs);
} | rust_cleaned_test_functions.jsonl/6885 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 793
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20587,
14240,
368,
341,
286,
1077,
5997,
1089,
1415,
284,
1281,
10385,
4711,
13251,
90515,
310,
330,
16,
15,
13,
15,
13,
15,
13,
15,
14,
17,
19,
497,
330,
16,
15,
13,
15,
13,
16,
13,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
#[test]
fn test_ipv6_duplicate_solicited_node_address() {
// Test that we still receive packets destined to a solicited-node multicast address of an
// the same solicited-node multicast address.
let config = Ipv6::DUMMY_CONFIG;
let mut ctx = DummyEventDispatcherBuilder::default().build::<DummyEventDispatcher>();
let device =
ctx.state_mut().add_ethernet_device(config.local_mac, Ipv6::MINIMUM_LINK_MTU.into());
crate::device::initialize_device(&mut ctx, device);
let ip1 =
SpecifiedAddr::new(Ipv6Addr::new([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1]))
.unwrap();
let ip2 =
SpecifiedAddr::new(Ipv6Addr::new([0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1]))
.unwrap();
let from_ip = Ipv6Addr::new([0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 1]);
// ip1 and ip2 are not equal but their solicited node addresses are the same.
assert_ne!(ip1, ip2);
assert_eq!(ip1.to_solicited_node_address(), ip2.to_solicited_node_address());
let sn_addr = ip1.to_solicited_node_address().get();
let addr_sub1 = AddrSubnet::new(ip1.get(), 64).unwrap();
let addr_sub2 = AddrSubnet::new(ip2.get(), 64).unwrap();
assert_eq!(get_counter_val(&mut ctx, "dispatch_receive_ip_packet"), 0);
// Add ip1 to the device.
// Should get packets destined for the solicited node address and ip1.
crate::device::add_ip_addr_subnet(&mut ctx, device, addr_sub1).unwrap();
receive_simple_ip_packet_test(&mut ctx, device, from_ip, ip1.get(), 1);
receive_simple_ip_packet_test(&mut ctx, device, from_ip, ip2.get(), 1);
receive_simple_ip_packet_test(&mut ctx, device, from_ip, sn_addr, 2);
// Add ip2 to the device.
crate::device::add_ip_addr_subnet(&mut ctx, device, addr_sub2).unwrap();
receive_simple_ip_packet_test(&mut ctx, device, from_ip, ip1.get(), 3);
receive_simple_ip_packet_test(&mut ctx, device, from_ip, ip2.get(), 4);
receive_simple_ip_packet_test(&mut ctx, device, from_ip, sn_addr, 5);
// Remove ip1 from the device.
// Should get packets destined for the solicited node address and ip2.
crate::device::del_ip_addr(&mut ctx, device, &ip1).unwrap();
receive_simple_ip_packet_test(&mut ctx, device, from_ip, ip1.get(), 5);
receive_simple_ip_packet_test(&mut ctx, device, from_ip, ip2.get(), 6);
receive_simple_ip_packet_test(&mut ctx, device, from_ip, sn_addr, 7);
} | rust_cleaned_test_functions.jsonl/114203 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1250
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
49378,
21,
70434,
643,
91104,
5084,
6744,
368,
341,
1789,
286,
442,
3393,
429,
582,
2058,
5258,
27035,
50587,
311,
264,
29744,
1608,
39054,
79534,
2621,
315,
458,
8945,
286,
442,
279,
1852,
29744,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_account_transaction() {
let (mock_db, client, mut runtime) = create_database_client_and_runtime();
for (acc, blob) in mock_db.all_accounts.iter() {
let ar = AccountResource::try_from(blob).unwrap();
for seq in 1..ar.sequence_number() {
let mut batch = JsonRpcBatch::default();
batch.add_get_account_transaction_request(*acc, seq, true);
let result = execute_batch_and_get_first_response(&client, &mut runtime, batch);
let tx_view = TransactionView::optional_from_response(result)
.unwrap()
.expect("Transaction didn't exists!");
let (expected_tx, expected_status) = mock_db
.all_txns
.iter()
.find_map(|(t, status)| {
if let Ok(x) = t.as_signed_user_txn() {
if x.sender() == *acc && x.sequence_number() == seq {
assert_eq!(tx_view.hash, t.hash().to_hex());
return Some((x, status));
}
}
None
})
.expect("Couldn't find tx");
// Check we returned correct events
let expected_events = mock_db
.events
.iter()
.filter(|(ev, _)| *ev == tx_view.version)
.map(|(_, e)| e)
.collect::<Vec<_>>();
assert_eq!(tx_view.events.len(), expected_events.len());
// check VM status
assert_eq!(tx_view.vm_status, VMStatusView::from(expected_status));
for (i, event_view) in tx_view.events.iter().enumerate() {
let expected_event = expected_events.get(i).expect("Expected event didn't find");
assert_eq!(event_view.sequence_number, expected_event.sequence_number());
assert_eq!(event_view.transaction_version, tx_view.version);
assert_eq!(
event_view.key.0,
BytesView::from(expected_event.key().as_bytes()).0
);
// TODO: check event_data
}
let tx_data_view = tx_view.transaction;
// Always user transaction
match tx_data_view {
TransactionDataView::UserTransaction {
sender,
sequence_number,
script_hash,
..
} => {
assert_eq!(acc.to_string(), sender);
assert_eq!(seq, sequence_number);
if let TransactionPayload::Script(s) = expected_tx.payload() {
assert_eq!(script_hash, HashValue::sha3_256_of(s.code()).to_hex());
}
}
_ => panic!("wrong type"),
}
}
}
} | rust_cleaned_test_functions.jsonl/4632 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1619
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
13500,
28884,
368,
341,
262,
1077,
320,
16712,
8685,
11,
2943,
11,
5206,
15592,
8,
284,
1855,
27341,
8179,
8378,
33232,
1428,
262,
369,
320,
4475,
11,
23404,
8,
304,
7860,
8685,
7670,
5566... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
#[test]
fn test_args_multiplexed_connection() {
let ctx = TestContext::new();
block_on_all_using_async_std(async move {
ctx.multiplexed_async_connection_async_std()
.and_then(|con| {
let cmds = (0..100).map(move |i| test_cmd(&con, i));
future::try_join_all(cmds).map_ok(|results| {
assert_eq!(results.len(), 100);
})
})
.map_err(|err| panic!("{}", err))
.await
})
.unwrap();
} | rust_cleaned_test_functions.jsonl/105563 | {
"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,
8384,
91802,
2571,
291,
15866,
368,
341,
262,
1077,
5635,
284,
3393,
1972,
486,
931,
543,
262,
2504,
4470,
5705,
75180,
28346,
15656,
18285,
3271,
341,
286,
5635,
744,
9845,
2571,
291,
28346,
1586... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_push_error_panic_uninitialized() {
let state = MockBufferSharedState::uninitialized();
let error = "foo".to_string().into();
state.push_error(error, 0);
} | rust_cleaned_test_functions.jsonl/53066 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 89
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4387,
14218,
4096,
620,
31270,
4907,
36161,
368,
341,
286,
1077,
1584,
284,
14563,
4095,
16997,
1397,
486,
359,
36161,
543,
286,
1077,
1465,
284,
330,
7975,
3263,
983,
3904,
1005,
18122,
543,
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 |
#[test]
fn test_product() {
let ua_parser = UserAgentParser::from_path("uap-core/regexes.yaml").unwrap();
let yaml = fs::read_to_string("uap-core/tests/test_ua.yaml").unwrap();
let yamls = YamlLoader::load_from_str(&yaml).unwrap();
let yaml = &yamls[0];
let test_cases = yaml
.as_hash()
.unwrap()
.get(&Yaml::String("test_cases".to_string()))
.unwrap()
.as_vec()
.unwrap();
let yaml_user_agent_string = Yaml::String("user_agent_string".to_string());
let yaml_family = Yaml::String("family".to_string());
let yaml_major = Yaml::String("major".to_string());
let yaml_minor = Yaml::String("minor".to_string());
let yaml_patch = Yaml::String("patch".to_string());
for test_case in test_cases {
let test_case = test_case.as_hash().unwrap();
let user_agent = test_case.get(&yaml_user_agent_string).unwrap().as_str().unwrap();
let name = test_case.get(&yaml_family).unwrap().as_str().map(Cow::from);
let major = test_case.get(&yaml_major).unwrap().as_str().map(Cow::from);
let minor = test_case.get(&yaml_minor).unwrap().as_str().map(Cow::from);
let patch = test_case.get(&yaml_patch).unwrap().as_str().map(Cow::from);
let product = ua_parser.parse_product(user_agent);
assert_eq!(name, product.name);
assert_eq!(major, product.major);
assert_eq!(minor, product.minor);
assert_eq!(patch, product.patch);
}
} | rust_cleaned_test_functions.jsonl/111010 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 661
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9840,
368,
341,
262,
1077,
45559,
18517,
284,
2657,
16810,
6570,
486,
1499,
2638,
445,
84,
391,
23460,
14,
26387,
288,
33406,
1827,
15454,
1428,
262,
1077,
32246,
284,
8619,
486,
878,
2346,
3904,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_exchange_code_successful_with_pkce_and_extension() {
let client = new_client()
.set_auth_type(AuthType::BasicAuth)
.set_redirect_uri(RedirectUrl::new("https://redirect/here".to_string()).unwrap());
let token = client
.exchange_code(AuthorizationCode::new("ccc".to_string()))
.set_pkce_verifier(PkceCodeVerifier::new(
"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk".to_string(),
))
.add_extra_param("foo", "bar")
.request(mock_http_client(
vec![
(ACCEPT, "application/json"),
(CONTENT_TYPE, "application/x-www-form-urlencoded"),
(AUTHORIZATION, "Basic YWFhOmJiYg=="),
],
"grant_type=authorization_code\
&code=ccc\
&code_verifier=dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk\
&redirect_uri=https%3A%2F%2Fredirect%2Fhere\
&foo=bar",
None,
HttpResponse {
status_code: StatusCode::OK,
headers: vec![(
CONTENT_TYPE,
HeaderValue::from_str("application/json").unwrap(),
)]
.into_iter()
.collect(),
body: "{\
\"access_token\": \"12/34\", \
\"token_type\": \"bearer\", \
\"scope\": \"read write\"\
}"
.to_string()
.into_bytes(),
},
))
.unwrap();
assert_eq!("12/34", token.access_token().secret());
assert_eq!(BasicTokenType::Bearer, *token.token_type());
assert_eq!(
Some(&vec![
Scope::new("read".to_string()),
Scope::new("write".to_string()),
]),
token.scopes()
);
assert_eq!(None, token.expires_in());
assert!(token.refresh_token().is_none());
} | rust_cleaned_test_functions.jsonl/18601 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1127
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
59212,
4136,
92951,
6615,
33321,
346,
8378,
31035,
368,
341,
262,
1077,
2943,
284,
501,
8179,
741,
286,
659,
746,
14014,
1819,
37640,
929,
486,
15944,
5087,
340,
286,
659,
746,
30043,
15572,
2785,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_collections() {
// List
let value = json!([1, 2, "3"]);
let result = deserializer_v1(&value).expect("Failed to deserialize a List");
assert_eq!(
result,
GValue::List(
vec![
GValue::Int64(1),
GValue::Int64(2),
GValue::String(String::from("3")),
]
.into()
)
);
// Map
let value = json!({
"a": 1,
"b": "marko"
});
let result = deserializer_v1(&value).expect("Failed to deserialize a Map");
let mut map = HashMap::new();
map.insert(String::from("a"), GValue::Int64(1));
map.insert(String::from("b"), GValue::String(String::from("marko")));
assert_eq!(result, GValue::from(map));
} | rust_cleaned_test_functions.jsonl/115553 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 493
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
89742,
368,
341,
286,
442,
1759,
198,
286,
1077,
897,
284,
2951,
0,
2561,
16,
11,
220,
17,
11,
330,
18,
55919,
286,
1077,
1102,
284,
939,
41939,
2273,
16,
2099,
957,
568,
17119,
445,
9408,
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_big5_decode() {
// Empty
decode_big5(b"", &"");
// ASCII
decode_big5(&[0x61u8, 0x62u8], &"\u{0061}\u{0062}");
// Edge cases
decode_big5(&[0x87u8, 0x40u8], &"\u{43F0}");
decode_big5(&[0xFEu8, 0xFEu8], &"\u{79D4}");
decode_big5(&[0xFEu8, 0xFDu8], &"\u{2910D}");
decode_big5(&[0x88u8, 0x62u8], &"\u{00CA}\u{0304}");
decode_big5(&[0x88u8, 0x64u8], &"\u{00CA}\u{030C}");
decode_big5(&[0x88u8, 0x66u8], &"\u{00CA}");
decode_big5(&[0x88u8, 0xA3u8], &"\u{00EA}\u{0304}");
decode_big5(&[0x88u8, 0xA5u8], &"\u{00EA}\u{030C}");
decode_big5(&[0x88u8, 0xA7u8], &"\u{00EA}");
decode_big5(&[0x99u8, 0xD4u8], &"\u{8991}");
decode_big5(&[0x99u8, 0xD5u8], &"\u{27967}");
decode_big5(&[0x99u8, 0xD6u8], &"\u{8A29}");
// Edge cases surrounded with ASCII
decode_big5(
&[0x61u8, 0x87u8, 0x40u8, 0x62u8],
&"\u{0061}\u{43F0}\u{0062}",
);
decode_big5(
&[0x61u8, 0xFEu8, 0xFEu8, 0x62u8],
&"\u{0061}\u{79D4}\u{0062}",
);
decode_big5(
&[0x61u8, 0xFEu8, 0xFDu8, 0x62u8],
&"\u{0061}\u{2910D}\u{0062}",
);
decode_big5(
&[0x61u8, 0x88u8, 0x62u8, 0x62u8],
&"\u{0061}\u{00CA}\u{0304}\u{0062}",
);
decode_big5(
&[0x61u8, 0x88u8, 0x64u8, 0x62u8],
&"\u{0061}\u{00CA}\u{030C}\u{0062}",
);
decode_big5(
&[0x61u8, 0x88u8, 0x66u8, 0x62u8],
&"\u{0061}\u{00CA}\u{0062}",
);
decode_big5(
&[0x61u8, 0x88u8, 0xA3u8, 0x62u8],
&"\u{0061}\u{00EA}\u{0304}\u{0062}",
);
decode_big5(
&[0x61u8, 0x88u8, 0xA5u8, 0x62u8],
&"\u{0061}\u{00EA}\u{030C}\u{0062}",
);
decode_big5(
&[0x61u8, 0x88u8, 0xA7u8, 0x62u8],
&"\u{0061}\u{00EA}\u{0062}",
);
decode_big5(
&[0x61u8, 0x99u8, 0xD4u8, 0x62u8],
&"\u{0061}\u{8991}\u{0062}",
);
decode_big5(
&[0x61u8, 0x99u8, 0xD5u8, 0x62u8],
&"\u{0061}\u{27967}\u{0062}",
);
decode_big5(
&[0x61u8, 0x99u8, 0xD6u8, 0x62u8],
&"\u{0061}\u{8A29}\u{0062}",
);
// Bad sequences
decode_big5(&[0x80u8, 0x61u8], &"\u{FFFD}\u{0061}");
decode_big5(&[0xFFu8, 0x61u8], &"\u{FFFD}\u{0061}");
decode_big5(&[0xFEu8, 0x39u8], &"\u{FFFD}\u{0039}");
decode_big5(&[0x87u8, 0x66u8], &"\u{FFFD}\u{0066}");
decode_big5(&[0x81u8, 0x40u8], &"\u{FFFD}\u{0040}");
decode_big5(&[0x61u8, 0x81u8], &"\u{0061}\u{FFFD}");
} | rust_cleaned_test_functions.jsonl/20629 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1953
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36386,
20,
15227,
368,
341,
286,
442,
22228,
198,
286,
16895,
36386,
20,
1883,
56323,
609,
3014,
626,
286,
442,
39316,
198,
286,
16895,
36386,
20,
2099,
58,
15,
87,
21,
16,
84,
23,
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_bench_tps_bank_client() {
let (genesis_config, id) = create_genesis_config(10_000);
let bank = Bank::new_for_tests(&genesis_config);
let client = Arc::new(BankClient::new(bank));
let config = Config {
id,
tx_count: 10,
duration: Duration::from_secs(5),
..Config::default()
};
let keypair_count = config.tx_count * config.keypair_multiplier;
let keypairs =
generate_and_fund_keypairs(client.clone(), None, &config.id, keypair_count, 20)
.unwrap();
do_bench_tps(client, config, keypairs);
} | rust_cleaned_test_functions.jsonl/10465 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 322
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
880,
19762,
528,
1690,
35733,
8179,
368,
341,
286,
1077,
320,
77894,
5332,
11,
877,
8,
284,
1855,
16322,
13774,
5332,
7,
16,
15,
62,
15,
15,
15,
317,
286,
1077,
6073,
284,
8547,
486,
931,
54... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_aabb_intersects_ray() {
let a = AABB::new(vec3(-1.0, -1.0, -1.0), Vec3::ONE);
assert_eq!(
a.intersects_ray(vec3(10.0, 10.0, 10.0), vec3(0.0, 1.0, 0.0)),
-1.0
);
assert_eq!(
a.intersects_ray(vec3(10.0, 0.0, 0.0), vec3(-1.0, 0.0, 0.0)),
9.0
);
} | rust_cleaned_test_functions.jsonl/95799 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 243
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4306,
12523,
15318,
54429,
72690,
368,
341,
286,
1077,
264,
284,
88580,
486,
931,
25592,
18,
4080,
16,
13,
15,
11,
481,
16,
13,
15,
11,
481,
16,
13,
15,
701,
11312,
18,
486,
5225,
626,
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_into() {
let raw_pk: [u8; PUBLIC_KEY_LENGTH] = [
0xaf, 0xf3, 0x94, 0xc5, 0xb7, 0x5c, 0xfb, 0xd, 0xd9, 0x28, 0xe5, 0x8a, 0x92, 0xdd,
0x76, 0x55, 0x2b, 0x2e, 0x8d, 0x19, 0x6f, 0xe9, 0x12, 0x14, 0x50, 0x80, 0x6b, 0xd0,
0xd9, 0x3f, 0xd0, 0xcb,
];
let want = PublicKey::Ed25519(Ed25519::from_bytes(&raw_pk).unwrap());
let pk = PubKeyResponse {
pub_key_ed25519: vec![
0xaf, 0xf3, 0x94, 0xc5, 0xb7, 0x5c, 0xfb, 0xd, 0xd9, 0x28, 0xe5, 0x8a, 0x92, 0xdd,
0x76, 0x55, 0x2b, 0x2e, 0x8d, 0x19, 0x6f, 0xe9, 0x12, 0x14, 0x50, 0x80, 0x6b, 0xd0,
0xd9, 0x3f, 0xd0, 0xcb,
],
};
let orig = pk.clone();
let got: PublicKey = pk.try_into().unwrap();
assert_eq!(got, want);
// and back:
let round_trip_pk: PubKeyResponse = got.into();
assert_eq!(round_trip_pk, orig);
} | rust_cleaned_test_functions.jsonl/22293 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 622
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
45514,
368,
341,
286,
1077,
7112,
33321,
25,
508,
84,
23,
26,
31416,
6600,
15023,
60,
284,
2278,
310,
220,
15,
54795,
11,
220,
15,
5848,
18,
11,
220,
15,
87,
24,
19,
11,
220,
15,
8148,
20,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_raft_log_sort() {
let tbls = vec![
(1, 1, 1, 2, Ordering::Less),
(2, 1, 1, 2, Ordering::Greater),
(1, 1, 1, 1, Ordering::Equal),
];
for (lid, l_log_id, rid, r_log_id, order) in tbls {
let lhs = raft_log_key(lid, l_log_id);
let rhs = raft_log_key(rid, r_log_id);
assert_eq!(lhs.partial_cmp(&rhs), Some(order));
}
} | rust_cleaned_test_functions.jsonl/44169 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 266
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
2944,
5224,
18435,
368,
341,
286,
1077,
21173,
82,
284,
7486,
90515,
310,
320,
16,
11,
220,
16,
11,
220,
16,
11,
220,
17,
11,
68621,
486,
27451,
1326,
310,
320,
17,
11,
220,
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... | 2 |
#[test]
fn test_projective_group() {
let a = rand::random();
let b = rand::random();
for _i in 0..100 {
group_test::<EdwardsProjective>(a, b);
}
} | rust_cleaned_test_functions.jsonl/128403 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 83
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16352,
533,
6288,
368,
341,
262,
1077,
264,
284,
10382,
486,
11463,
543,
262,
1077,
293,
284,
10382,
486,
11463,
543,
262,
369,
716,
72,
304,
220,
15,
496,
16,
15,
15,
341,
286,
1874,
4452,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_bytes_to_bits_tuple_ok3() {
assert!(add_bytes_to_bits_tuple::<u64>((5, 0), 0x4000000000000001) == (7, 8));
} | rust_cleaned_test_functions.jsonl/51860 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 78
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
12524,
2346,
20034,
21773,
19817,
18,
368,
341,
286,
2060,
10297,
718,
12524,
2346,
20034,
21773,
27638,
84,
21,
19,
47453,
20,
11,
220,
15,
701,
220,
15,
87,
19,
15,
15,
15,
15,
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_bls381() {
let (n, t) = (5, 3);
// create the private key polynomial
let private_poly = Poly::<<SigScheme as Scheme>::Private>::new(t - 1);
// Evaluate it at `n` points to generate the shares
let shares = (0..n)
.map(|i| {
let eval = private_poly.eval(i as Idx);
Share {
index: eval.index,
private: eval.value,
}
})
.collect::<Vec<_>>();
// Get the public polynomial
let public_poly = private_poly.commit();
let threshold_public_key = public_poly.public_key();
// Generate the partial signatures
let msg = b"hello";
let partials = shares
.iter()
.map(|s| SigScheme::partial_sign(s, &msg[..]).unwrap())
.collect::<Vec<_>>();
// each partial sig can be partially verified against the public polynomial
partials.iter().for_each(|partial| {
SigScheme::partial_verify(&public_poly, &msg[..], &partial).unwrap();
});
// generate the threshold sig
let threshold_sig = SigScheme::aggregate(t, &partials).unwrap();
println!("{:#?}", threshold_sig);
SigScheme::verify(&threshold_public_key, &msg[..], &threshold_sig).unwrap();
println!("finish.")
} | rust_cleaned_test_functions.jsonl/110893 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 676
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
880,
4730,
18,
23,
16,
368,
341,
286,
1077,
320,
77,
11,
259,
8,
284,
320,
20,
11,
220,
18,
317,
286,
442,
1855,
279,
869,
1376,
47311,
198,
286,
1077,
869,
36133,
284,
18767,
486,
2442,
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_root_mean_squared_error_grayscale() {
let left = gray_image!(
1, 2, 3;
4, 5, 6);
let right = gray_image!(
8, 4, 7;
6, 9, 1);
let rms = root_mean_squared_error(&left, &right);
let expected = (114f64 / 6f64).sqrt();
assert_eq!(rms, expected);
} | rust_cleaned_test_functions.jsonl/38568 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 204
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12993,
16933,
54641,
4096,
15682,
50348,
368,
341,
286,
1077,
2115,
284,
17545,
4954,
33673,
310,
220,
16,
11,
220,
17,
11,
220,
18,
280,
310,
220,
19,
11,
220,
20,
11,
220,
21,
626,
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_prevote_with_split_vote() {
setup_for_test();
let peers = (1..=3).map(|id| {
let mut raft = new_test_raft_with_prevote(id, vec![1, 2, 3], 10, 1, new_storage(), true);
raft.become_follower(1, INVALID_ID);
Some(raft)
});
let mut network = Network::new(peers.collect());
network.send(vec![new_message(1, 1, MessageType::MsgHup, 0)]);
network.isolate(1);
network.send(vec![
new_message(2, 2, MessageType::MsgHup, 0),
new_message(3, 3, MessageType::MsgHup, 0),
]);
// check whether the term values are expected
assert_eq!(network.peers[&2].term, 3, "peer 2 term",);
assert_eq!(network.peers[&3].term, 3, "peer 3 term",);
// check state
assert_eq!(
network.peers[&2].state,
StateRole::Candidate,
"peer 2 state",
);
assert_eq!(
network.peers[&3].state,
StateRole::Candidate,
"peer 3 state",
);
// node 2 election timeout first
network.send(vec![new_message(2, 2, MessageType::MsgHup, 0)]);
// check whether the term values are expected
assert_eq!(network.peers[&2].term, 4, "peer 2 term",);
assert_eq!(network.peers[&3].term, 4, "peer 3 term",);
// check state
assert_eq!(network.peers[&2].state, StateRole::Leader, "peer 2 state",);
assert_eq!(network.peers[&3].state, StateRole::Follower, "peer 3 state",);
} | rust_cleaned_test_functions.jsonl/107192 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 633
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25566,
1272,
6615,
17052,
54360,
368,
341,
262,
6505,
5478,
4452,
543,
262,
1077,
25029,
284,
320,
16,
496,
28,
18,
568,
2186,
22428,
307,
91,
341,
286,
1077,
5206,
52455,
284,
501,
4452,
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_best_common_ancestors() -> BitResult<()> {
BitRepo::with_empty_repo(|repo| {
let mut dag = DagBuilder::default();
let [a, b, c, d, e, f, g, h, i, j] = dag.mk_nodes();
dag.add_parents([
(j, i),
(i, e),
(i, c),
(c, b),
(b, a),
(e, d),
(f, e),
(h, g),
(g, d),
(d, b),
]);
let commit_oids = dag.apply_to_repo(repo)?;
let a = commit_oids[&h];
let b = commit_oids[&j];
let merge_base = repo.merge_base(a, b)?.unwrap();
assert_eq!(merge_base.oid(), commit_oids[&d]);
Ok(())
})
} | rust_cleaned_test_functions.jsonl/94146 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 433
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
33101,
21107,
62,
681,
267,
1087,
368,
1464,
6495,
2077,
71698,
341,
262,
6495,
25243,
486,
4197,
15124,
37784,
22428,
23476,
91,
341,
286,
1077,
5206,
28069,
284,
77027,
3297,
486,
2258,
543,
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... | 3 |
#[test]
fn test_none_as_empty_string() {
#[serde_as]
#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct S(#[serde_as(as = "NoneAsEmptyString")] Option<String>);
is_equal(S(None), expect![[r#""""#]]);
is_equal(S(Some("Hello".to_string())), expect![[r#""Hello""#]]);
#[serde_as]
#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct SRc(#[serde_as(as = "NoneAsEmptyString")] Option<Rc<str>>);
is_equal(SRc(None), expect![[r#""""#]]);
is_equal(SRc(Some("Hello".into())), expect![[r#""Hello""#]]);
#[serde_as]
#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct SArc(#[serde_as(as = "NoneAsEmptyString")] Option<Arc<str>>);
is_equal(SArc(None), expect![[r#""""#]]);
is_equal(SArc(Some("Hello".into())), expect![[r#""Hello""#]]);
#[serde_as]
#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct SBox(#[serde_as(as = "NoneAsEmptyString")] Option<Box<str>>);
is_equal(SBox(None), expect![[r#""""#]]);
is_equal(SBox(Some("Hello".into())), expect![[r#""Hello""#]]);
} | rust_cleaned_test_functions.jsonl/105397 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 487
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31488,
11898,
15124,
3904,
368,
341,
262,
11506,
47024,
11898,
921,
262,
11506,
27098,
42618,
11,
39900,
11,
48440,
11,
55039,
5563,
262,
2036,
328,
7,
13353,
47024,
11898,
36951,
284,
330,
4064,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_kill_partition_switch_threshold_no_progress() {
let max_switch_threshold_failure_pct = 1.0 - 2.0 * SWITCH_FORK_THRESHOLD;
let total_stake = 10_000;
let max_failures_stake = (max_switch_threshold_failure_pct * total_stake as f64) as u64;
let failures_stake = max_failures_stake;
let total_alive_stake = total_stake - failures_stake;
let alive_stake_1 = total_alive_stake / 2;
let alive_stake_2 = total_alive_stake - alive_stake_1;
// Check that no new roots were set 400 slots after partition resolves (gives time
// for lockouts built during partition to resolve and gives validators an opportunity
// to try and switch forks)
let on_partition_start =
|_: &mut LocalCluster, _: &[Pubkey], _: Vec<ClusterValidatorInfo>, _: &mut ()| {};
let on_before_partition_resolved = |_: &mut LocalCluster, _: &mut ()| {};
let on_partition_resolved = |cluster: &mut LocalCluster, _: &mut ()| {
cluster.check_no_new_roots(400, "PARTITION_TEST", SocketAddrSpace::Unspecified);
};
run_kill_partition_switch_threshold(
&[&[(failures_stake as usize, 16)]],
&[
&[(alive_stake_1 as usize, 8)],
&[(alive_stake_2 as usize, 8)],
],
None,
None,
(),
on_partition_start,
on_before_partition_resolved,
on_partition_resolved,
);
} | rust_cleaned_test_functions.jsonl/31757 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 624
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
73327,
43840,
27652,
21858,
6536,
27200,
368,
341,
262,
1077,
1932,
27652,
21858,
43618,
71512,
284,
220,
16,
13,
15,
481,
220,
17,
13,
15,
353,
72543,
1400,
10647,
44405,
280,
262,
1077,
2790,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_vec_list_push_back() {
let mut list = VecList::new();
list.push_back(0);
assert_eq!(list.back(), Some(&0));
list.push_back(1);
assert_eq!(list.back(), Some(&1));
list.push_back(2);
assert_eq!(list.back(), Some(&2));
} | rust_cleaned_test_functions.jsonl/11546 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 156
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13251,
2019,
14218,
3895,
368,
341,
286,
1077,
5206,
1140,
284,
11312,
852,
486,
931,
543,
286,
1140,
2552,
3895,
7,
15,
317,
286,
2060,
10714,
10297,
1607,
7335,
1507,
4329,
2099,
15,
1106,
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_evaluation_line_to_path_evaluation() {
assert_eq!(
parse_evaluation_line("evaluating file '/nix/store/zqxha3ax0w771jf25qdblakka83660gr-source/lib/systems/for-meta.nix'"),
LogDatum::Source(PathBuf::from("/nix/store/zqxha3ax0w771jf25qdblakka83660gr-source/lib/systems/for-meta.nix"))
);
assert_eq!(
parse_evaluation_line("copied source '/nix/store/zqxha3ax0w771jf25qdblakka83660gr-source/pkgs/stdenv/generic/default-builder.sh' -> '/nix/store/9krlzvny65gdc8s7kpb6lkx8cd02c25b-default-builder.sh'"),
LogDatum::Source(PathBuf::from("/nix/store/zqxha3ax0w771jf25qdblakka83660gr-source/pkgs/stdenv/generic/default-builder.sh"))
);
assert_eq!(
parse_evaluation_line(
"trace: lorri read: '/home/grahamc/projects/grahamc/lorri/nix/nixpkgs.json'"
),
LogDatum::Source(PathBuf::from(
"/home/grahamc/projects/grahamc/lorri/nix/nixpkgs.json"
))
);
assert_eq!(
parse_evaluation_line("trace: lorri attribute: 'shell' -> '/nix/store/q3ngidzvincycjjvlilf1z6vj1w4wnas-lorri.drv'"),
LogDatum::AttrDrv(String::from("shell"), PathBuf::from("/nix/store/q3ngidzvincycjjvlilf1z6vj1w4wnas-lorri.drv"))
);
assert_eq!(
parse_evaluation_line(
"downloading 'https://static.rust-lang.org/dist/channel-rust-stable.toml'..."
),
LogDatum::Text(String::from(
"downloading 'https://static.rust-lang.org/dist/channel-rust-stable.toml'..."
))
);
} | rust_cleaned_test_functions.jsonl/8377 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 894
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
86505,
6528,
2346,
2638,
86505,
368,
341,
286,
2060,
10714,
33673,
310,
4715,
86505,
6528,
445,
14170,
53543,
1034,
3353,
77,
941,
31320,
31082,
88735,
4223,
18,
706,
15,
86,
22,
22,
16,
96423,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_multinomial() {
macro_rules! check_binomial {
($t:ty, $k:expr) => { {
let n: $t = $k.iter().fold(0, |acc, &x| acc + x);
let k: &[$t] = $k;
assert_eq!(k.len(), 2);
assert_eq!(multinomial(k), binomial(n, k[0]));
} }
}
check_binomial!(u8, &[4, 5]);
check_binomial!(i8, &[4, 5]);
check_binomial!(u16, &[2, 98]);
check_binomial!(u16, &[4, 10]);
check_binomial!(i16, &[2, 98]);
check_binomial!(i16, &[4, 10]);
check_binomial!(u32, &[2, 98]);
check_binomial!(u32, &[11, 24]);
check_binomial!(u32, &[4, 10]);
check_binomial!(i32, &[2, 98]);
check_binomial!(i32, &[11, 24]);
check_binomial!(i32, &[4, 10]);
check_binomial!(u64, &[2, 98]);
check_binomial!(u64, &[11, 24]);
check_binomial!(u64, &[4, 10]);
check_binomial!(i64, &[2, 98]);
check_binomial!(i64, &[11, 24]);
check_binomial!(i64, &[4, 10]);
macro_rules! check_multinomial {
($t:ty, $k:expr, $r:expr) => { {
let k: &[$t] = $k;
let expected: $t = $r;
assert_eq!(multinomial(k), expected);
} }
}
check_multinomial!(u8, &[2, 1, 2], 30);
check_multinomial!(u8, &[2, 3, 0], 10);
check_multinomial!(i8, &[2, 1, 2], 30);
check_multinomial!(i8, &[2, 3, 0], 10);
check_multinomial!(u16, &[2, 1, 2], 30);
check_multinomial!(u16, &[2, 3, 0], 10);
check_multinomial!(i16, &[2, 1, 2], 30);
check_multinomial!(i16, &[2, 3, 0], 10);
check_multinomial!(u32, &[2, 1, 2], 30);
check_multinomial!(u32, &[2, 3, 0], 10);
check_multinomial!(i32, &[2, 1, 2], 30);
check_multinomial!(i32, &[2, 3, 0], 10);
check_multinomial!(u64, &[2, 1, 2], 30);
check_multinomial!(u64, &[2, 3, 0], 10);
check_multinomial!(i64, &[2, 1, 2], 30);
check_multinomial!(i64, &[2, 3, 0], 10);
check_multinomial!(u64, &[], 1);
check_multinomial!(u64, &[0], 1);
check_multinomial!(u64, &[12345], 1);
} | rust_cleaned_test_functions.jsonl/5340 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1098
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26290,
258,
20855,
368,
341,
262,
18072,
21407,
0,
1779,
21816,
20855,
341,
286,
1711,
83,
25,
1881,
11,
400,
74,
96011,
8,
589,
314,
341,
310,
1077,
308,
25,
400,
83,
284,
400,
74,
19471,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parse_material_set() {
let tests = test_cases();
for test in tests.iter() {
let mut parser = Parser::new(&test.data);
let result = parser.parse_mtlset().unwrap();
assert_eq!(result, test.expected);
}
} | rust_cleaned_test_functions.jsonl/53115 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 118
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
33884,
2602,
368,
341,
262,
1077,
7032,
284,
1273,
41427,
543,
1066,
262,
369,
1273,
304,
7032,
19471,
368,
341,
286,
1077,
5206,
6729,
284,
21102,
486,
931,
2099,
1944,
2196,
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... | 2 |
#[test]
fn test_column_i64() {
let fields = vec![
field_type(types::TINY),
field_type(types::SHORT),
field_type(types::INT24),
field_type(types::LONG),
field_type(types::LONG_LONG),
field_type(types::YEAR),
];
let data = vec![
Datum::Null,
Datum::I64(-1),
Datum::I64(12),
Datum::I64(1024),
];
for field in &fields {
let mut column = Column::new(field, data.len());
for v in &data {
column.append_datum(v).unwrap();
}
for (id, expect) in data.iter().enumerate() {
let get = column.get_datum(id, field).unwrap();
assert_eq!(&get, expect);
}
}
} | rust_cleaned_test_functions.jsonl/69572 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 485
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8744,
5318,
21,
19,
368,
341,
286,
1077,
5043,
284,
7486,
90515,
310,
2070,
1819,
52613,
486,
51,
64953,
1326,
310,
2070,
1819,
52613,
486,
87918,
1326,
310,
2070,
1819,
52613,
486,
3221,
17,
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... | 4 |
#[test]
fn test_parse_errors_obsolete() {
assert_eq!(obsolete("-5n"), Some(Err(ParseError::Syntax)));
assert_eq!(obsolete("-5c5"), Some(Err(ParseError::Syntax)));
} | rust_cleaned_test_functions.jsonl/32885 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 94
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
20196,
36322,
27246,
368,
341,
286,
2060,
10714,
10297,
55015,
13645,
20,
77,
3975,
4329,
7,
7747,
71812,
1454,
486,
33890,
4945,
286,
2060,
10714,
10297,
55015,
13645,
20,
66,
20,
3975,
43... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_json_coord_encode() {
let value = Value::make_coord(Coord {
lat: 45.0,
long: 23.0,
});
let json = serde_json::to_string(&value);
assert_eq!(json.unwrap(), r#"{"_kind":"coord","lat":45.0,"lng":23.0}"#);
} | rust_cleaned_test_functions.jsonl/589 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 129
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9455,
30096,
11224,
368,
341,
262,
1077,
897,
284,
5162,
486,
6927,
30096,
3025,
81437,
341,
286,
6844,
25,
220,
19,
20,
13,
15,
345,
286,
1293,
25,
220,
17,
18,
13,
15,
345,
262,
3011,
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_host_name_for() {
#[cfg(target_os = "linux")]
{
std::assert_eq!(host_name_for("id"), "id");
std::assert_eq!(host_name_for("groups"), "groups");
std::assert_eq!(host_name_for("who"), "who");
}
#[cfg(not(target_os = "linux"))]
{
std::assert_eq!(host_name_for("id"), "gid");
std::assert_eq!(host_name_for("groups"), "ggroups");
std::assert_eq!(host_name_for("who"), "gwho");
std::assert_eq!(host_name_for("gid"), "gid");
std::assert_eq!(host_name_for("ggroups"), "ggroups");
std::assert_eq!(host_name_for("gwho"), "gwho");
}
} | rust_cleaned_test_functions.jsonl/12805 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 396
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12848,
1269,
5478,
368,
341,
286,
11506,
14072,
8637,
29387,
284,
330,
14210,
5422,
286,
341,
310,
1460,
486,
2207,
10714,
10297,
3790,
1269,
5478,
445,
307,
3975,
330,
307,
797,
310,
1460,
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_convert_predicate_good() {
let (comparison, expected_expr) = make_host_comparison();
let rpc_predicate = RPCPredicate {
root: Some(comparison),
};
let predicate = PredicateBuilder::default()
.rpc_predicate(Some(rpc_predicate))
.expect("successfully converting predicate")
.build();
let converted_expr = &predicate.exprs;
assert_eq!(
&expected_expr, converted_expr,
"expected '{:#?}' doesn't match actual '{:#?}'",
expected_expr, converted_expr
);
} | rust_cleaned_test_functions.jsonl/79153 | {
"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,
34910,
97474,
44781,
368,
341,
286,
1077,
320,
54705,
11,
3601,
21915,
8,
284,
1281,
12848,
90797,
1428,
286,
1077,
35596,
97474,
284,
34008,
36329,
341,
310,
3704,
25,
4329,
14094,
35542,
1326,
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_literal() {
assert!(literal(b"{3}\r\n123").is_ok());
assert!(literal(b"{3}\r\n1\x003").is_err());
let (rem, val) = literal(b"{3}\r\n123xxx").unwrap();
assert_eq!(rem, b"xxx");
assert_eq!(val, LiteralRef::from_bytes(b"123").unwrap());
} | rust_cleaned_test_functions.jsonl/78686 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 162
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34100,
368,
341,
286,
2060,
10297,
35785,
1883,
14129,
18,
11035,
81,
1699,
16,
17,
18,
1827,
285,
19817,
1423,
286,
2060,
10297,
35785,
1883,
14129,
18,
11035,
81,
1699,
16,
3462,
15,
15,
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_guild_create_channels_have_guild_ids() {
let channels = Vec::from([GuildChannel::Text(TextChannel {
id: ChannelId(111),
guild_id: None,
kind: ChannelType::GuildText,
last_message_id: None,
last_pin_timestamp: None,
name: "guild channel with no guild id".to_owned(),
nsfw: true,
permission_overwrites: Vec::new(),
parent_id: None,
position: 1,
rate_limit_per_user: None,
topic: None,
})]);
let guild = Guild {
id: GuildId(123),
afk_channel_id: None,
afk_timeout: 300,
application_id: None,
banner: None,
channels,
default_message_notifications: DefaultMessageNotificationLevel::Mentions,
description: None,
discovery_splash: None,
emojis: Vec::new(),
explicit_content_filter: ExplicitContentFilter::AllMembers,
features: vec![],
icon: None,
joined_at: Some("".to_owned()),
large: false,
max_members: Some(50),
max_presences: Some(100),
member_count: Some(25),
members: Vec::new(),
mfa_level: MfaLevel::Elevated,
name: "this is a guild".to_owned(),
nsfw: false,
owner: Some(false),
owner_id: UserId(456),
permissions: Some(Permissions::SEND_MESSAGES),
preferred_locale: "en-GB".to_owned(),
premium_subscription_count: Some(0),
premium_tier: PremiumTier::None,
presences: Vec::new(),
region: "us-east".to_owned(),
roles: Vec::new(),
splash: None,
system_channel_id: None,
system_channel_flags: SystemChannelFlags::SUPPRESS_JOIN_NOTIFICATIONS,
rules_channel_id: None,
unavailable: false,
verification_level: VerificationLevel::VeryHigh,
voice_states: Vec::new(),
vanity_url_code: None,
widget_channel_id: None,
widget_enabled: None,
max_video_channel_users: None,
approximate_member_count: None,
approximate_presence_count: None,
};
let cache = InMemoryCache::new();
cache.cache_guild(guild);
let channel = cache.guild_channel(ChannelId(111)).unwrap();
// correct value.
match *channel {
GuildChannel::Text(ref c) => {
assert_eq!(Some(GuildId(123)), c.guild_id);
}
_ => panic!("{:?}", channel),
}
} | rust_cleaned_test_functions.jsonl/86438 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1446
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1889,
1498,
8657,
19291,
67301,
1889,
1498,
8077,
368,
341,
286,
1077,
11744,
284,
11312,
486,
1499,
2561,
72574,
9629,
486,
1178,
34082,
9629,
341,
310,
877,
25,
13434,
764,
7,
16,
16,
16,
1326... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_spmm_csr() {
{
let a = DMatrix::from_row_slice(2, 2, &[1, 0, 0, 3]);
let b = DMatrix::from_row_slice(2, 1, &[3, -1]);
let c = DMatrix::from_row_slice(2, 1, &[1, 1]);
let a = CsrMatrix::from(&a);
let b = CsrMatrix::from(&b);
let mut c = CsrMatrix::from(&c);
let alpha = 1;
let beta = 0;
spmm_csr(beta, &mut c, alpha, &a, &b).unwrap();
let expected = DMatrix::from_row_slice(2, 1, &[3, -3]);
let expected = CsrMatrix::from(&expected);
assert_eq!(c, expected);
assert_eq!(c.nnz(), 2);
}
{
let a = DMatrix::from_row_slice(3, 2, &[1, 0, 0, 0, 2, 0]);
let b = DMatrix::from_row_slice(2, 3, &[3, 0, 1, -1, 1, 0]);
let c = DMatrix::from_row_slice(3, 3, &[3, 0, 1, -3, 3, 0, 6, 0, 2]);
let a = CsrMatrix::from(&a);
let b = CsrMatrix::from(&b);
let mut c = CsrMatrix::from(&c);
let alpha = 2;
let beta = 2;
spmm_csr(beta, &mut c, alpha, &a, &b).unwrap();
let expected = DMatrix::from_row_slice(3, 3, &[12, 0, 4, -6, 6, 0, 24, 0, 8]);
let expected = CsrMatrix::from(&expected);
assert_eq!(c, expected);
assert_eq!(c.nnz(), 6);
}
// Minimal example found by proptest
{
let c_offsets = vec![0, 0, 3];
let c_indices = vec![0, 1, 2];
let c_values = vec![0, 0, 0];
let mut c = CsrMatrix::from_csr_data(2, 3, c_offsets, c_indices, c_values);
let a_offsets = vec![0, 0, 2];
let a_indices = vec![0, 1];
let a_values = vec![8, 5];
let a = CsrMatrix::from_csr_data(2, 2, a_offsets, a_indices, a_values);
let b_offsets = vec![0, 0, 3];
let b_indices = vec![0, 1, 2];
let b_values = vec![0, 0, -1];
let b = CsrMatrix::from_csr_data(2, 3, b_offsets, b_indices, b_values);
let alpha = 3;
let beta = 2;
spmm_csr(beta, &mut c, alpha, &a, &b).unwrap();
let expected_offsets = vec![0, 0, 3];
let expected_indices = vec![0, 1, 2];
let expected_values = vec![0, 0, -15];
let expected = CsrMatrix::from_csr_data(2, 3, expected_offsets, expected_indices, expected_values);
assert_eq!(c, expected);
}
{
let a = DMatrix::from_row_slice(4, 5, &[1, 3, 0, 0, 4, 0, -5, 0, 0, 0, 0, 0, 0, 0, 0, 1, -2, 0, 0, 2]);
let b = DMatrix::from_row_slice(5, 3, &[2, 0, 1, 0, 0, 5, -1, 0, 0, 0, -4, 0, 1, 3, 1]);
let c = DMatrix::from_row_slice(4, 3, &[2, 1, 3, 0, 0, 1, 0, 0, 0, 2, 1, 3]);
let a = CsrMatrix::from(&a);
let b = CsrMatrix::from(&b);
let mut c = CsrMatrix::from(&c);
let alpha = 2;
let beta = 3;
spmm_csr(beta, &mut c, alpha, &a, &b).unwrap();
let expected = DMatrix::from_row_slice(4, 3, &[18, 27, 49, 0, 0, -47, 0, 0, 0, 14, 15, -5]);
let expected = CsrMatrix::from(&expected);
assert_eq!(c, expected);
assert_eq!(c.nnz(), 7);
}
} | rust_cleaned_test_functions.jsonl/33878 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1627
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10123,
3821,
666,
15094,
368,
341,
262,
341,
286,
1077,
264,
284,
422,
6689,
486,
1499,
8530,
26488,
7,
17,
11,
220,
17,
11,
44590,
16,
11,
220,
15,
11,
220,
15,
11,
220,
18,
2558,
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_parse_arguments_explicit_dep_target() {
let args =
stringvec!["-c", "foo.c", "-MT", "depfile", "-fabc", "-MF", "file", "-o", "foo.o"];
let ParsedArguments {
input,
language,
outputs,
dependency_args,
msvc_show_includes,
common_args,
..
} = match parse_arguments_(args, false) {
CompilerArguments::Ok(args) => args,
o => panic!("Got unexpected parse result: {:?}", o),
};
assert_eq!(Some("foo.c"), input.to_str());
assert_eq!(Language::C, language);
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.o")));
assert_eq!(ovec!["-MF", "file"], dependency_args);
assert_eq!(ovec!["-fabc"], common_args);
assert!(!msvc_show_includes);
} | rust_cleaned_test_functions.jsonl/17749 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 443
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
43433,
14214,
6026,
49258,
11123,
368,
341,
286,
1077,
2827,
4035,
310,
914,
4083,
0,
1183,
12,
66,
497,
330,
7975,
520,
497,
6523,
8505,
497,
330,
14891,
1192,
497,
6523,
69,
13683,
497,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_double_underscores_fn_namespace() {
let hdr = indoc! {"
namespace __B {
inline void a() {}
};
"};
run_test_ex(
"",
hdr,
quote! {},
quote! { generate_all!() },
None,
None,
None,
);
} | rust_cleaned_test_functions.jsonl/9878 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 167
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
24598,
62,
31009,
7701,
15246,
41571,
368,
341,
262,
1077,
36615,
284,
1257,
509,
0,
314,
698,
262,
4473,
1304,
33,
341,
286,
7381,
737,
264,
368,
5613,
262,
2605,
262,
330,
2440,
262,
1598,
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_get_paths() {
let user_cfg = "/data/my/user.cfg";
let factory_cfg = "/data/my/factory.cfg";
let device_schema = "/data/my/device_schema.cfg";
let test_config = create_test_config(user_cfg, factory_cfg, device_schema);
assert_eq!(test_config.device_config.is_none(), true);
assert_eq!(test_config.user_config_path(), Path::new(user_cfg));
assert_eq!(test_config.factory_config_path(), Path::new(factory_cfg));
assert_eq!(test_config.device_schema_path(), Path::new(device_schema));
assert_eq!(test_config.startup_path(), Path::new(""));
} | rust_cleaned_test_functions.jsonl/83803 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 280
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
24152,
368,
341,
286,
1077,
1196,
18343,
284,
3521,
691,
34198,
11739,
30481,
876,
286,
1077,
8633,
18343,
284,
3521,
691,
34198,
6663,
2919,
30481,
876,
286,
1077,
3671,
25371,
284,
3521,
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... | 1 |
#[test]
fn test_write_padded() {
let mut data: Vec<u8> = vec![255u8; 151];
let buf = Vec::new();
let mut cursor = Cursor::new(buf);
let written = write_padded(&mut data[..].as_ref(), &mut cursor).unwrap();
let padded = cursor.into_inner();
assert_eq!(written, 151);
assert_eq!(
padded.len(),
FR32_PADDING_MAP.transform_byte_offset(151, true)
);
assert_eq!(&padded[0..31], &data[0..31]);
assert_eq!(padded[31], 0b0011_1111);
assert_eq!(padded[32], 0b1111_1111);
assert_eq!(&padded[33..63], vec![255u8; 30].as_slice());
assert_eq!(padded[63], 0b0011_1111);
assert_eq!(padded.into_boxed_slice(), bit_vec_padding(data));
} | rust_cleaned_test_functions.jsonl/32994 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 386
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9165,
620,
16828,
368,
341,
286,
1077,
5206,
821,
25,
11312,
34837,
23,
29,
284,
7486,
20703,
17,
20,
20,
84,
23,
26,
220,
16,
20,
16,
935,
286,
1077,
6607,
284,
11312,
486,
931,
543,
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_headers_split_field() {
let mut buf = BytesMut::from("GET /test HTTP/1.1\r\n");
let mut reader = MessageDecoder::<Request>::default();
assert! { reader.decode(&mut buf).unwrap().is_none() }
buf.extend(b"t");
assert! { reader.decode(&mut buf).unwrap().is_none() }
buf.extend(b"es");
assert! { reader.decode(&mut buf).unwrap().is_none() }
buf.extend(b"t: value\r\n\r\n");
let (req, _) = reader.decode(&mut buf).unwrap().unwrap();
assert_eq!(req.version(), Version::HTTP_11);
assert_eq!(*req.method(), Method::GET);
assert_eq!(req.path(), "/test");
assert_eq!(
req.headers()
.get(HeaderName::try_from("test").unwrap())
.unwrap()
.as_bytes(),
b"value"
);
} | rust_cleaned_test_functions.jsonl/22263 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 440
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26719,
17052,
5013,
368,
341,
286,
1077,
5206,
6607,
284,
30024,
51440,
486,
1499,
445,
3806,
608,
1944,
10130,
14,
16,
13,
16,
12016,
1699,
3071,
286,
1077,
5206,
6604,
284,
4856,
20732,
27638,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_bl_t1() {
// BL -130
assert_eq!(decode_32(0xf7ffffbf), Instruction::BL { imm32: -130 });
// BL -5694
assert_eq!(decode_32(0xf7fefce1), Instruction::BL { imm32: -5694 });
} | rust_cleaned_test_functions.jsonl/64789 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 105
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15227,
13141,
528,
16,
368,
341,
262,
442,
14850,
481,
16,
18,
15,
198,
262,
2060,
10714,
10297,
18196,
62,
18,
17,
7,
15,
5848,
22,
7238,
13233,
701,
29051,
486,
9389,
314,
4893,
18,
17,
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_bond() {
let b: Bond = Bond { kind: purr::feature::BondKind::Aromatic, kind_value: 5, tid: 3, is_breaking_symmetry: false };
assert_eq!(b.fixed_hash_value(), 50);
} | rust_cleaned_test_functions.jsonl/69018 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 96
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
880,
2111,
368,
341,
286,
1077,
293,
25,
23618,
284,
23618,
314,
3093,
25,
3999,
81,
486,
12753,
486,
89844,
10629,
486,
32,
98766,
11,
3093,
3142,
25,
220,
20,
11,
13112,
25,
220,
18,
11,
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_failed_pending_batch() {
let _guard = super::setup_fail();
let mut suite = TestSuite::new(3);
let incremental_scan_fp = "before_schedule_incremental_scan";
fail::cfg(incremental_scan_fp, "pause").unwrap();
let region = suite.cluster.get_region(&[]);
let mut req = ChangeDataRequest::default();
req.region_id = region.get_id();
req.set_region_epoch(region.get_region_epoch().clone());
let (event_feed_wrap, receive_event) = new_event_feed(&suite.cdc_cli, &req);
// Split region.
suite.cluster.must_split(®ion, b"k0");
// Wait for receiving split cmd.
sleep_ms(200);
fail::remove(incremental_scan_fp);
let event = receive_event(false);
match event {
Event_oneof_event::Entries(es) => {
assert!(es.entries.len() == 1, "{:?}", es);
let e = &es.entries[0];
assert_eq!(e.get_type(), EventLogType::Initialized, "{:?}", es);
}
_ => panic!("unknown event"),
}
let event = receive_event(false);
match event {
Event_oneof_event::Error(err) => {
assert!(err.has_epoch_not_match(), "{:?}", err);
}
_ => panic!("unknown event"),
}
// Try to subscribe region again.
let region = suite.cluster.get_region(b"k0");
// Ensure it is old region.
assert_eq!(req.get_region_id(), region.get_id());
req.set_region_epoch(region.get_region_epoch().clone());
let event_feed2 = suite.cdc_cli.event_feed(&req).unwrap();
event_feed_wrap.as_ref().replace(Some(event_feed2));
let event = receive_event(false);
match event {
Event_oneof_event::Entries(es) => {
assert!(es.entries.len() == 1, "{:?}", es);
let e = &es.entries[0];
assert_eq!(e.get_type(), EventLogType::Initialized, "{:?}", es);
}
_ => panic!("unknown event"),
}
event_feed_wrap.as_ref().replace(None);
suite.stop();
} | rust_cleaned_test_functions.jsonl/3784 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 862
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
35060,
37861,
14534,
368,
341,
262,
1077,
716,
26098,
284,
2256,
486,
15188,
22121,
543,
262,
1077,
5206,
16182,
284,
3393,
28000,
486,
931,
7,
18,
626,
262,
1077,
52299,
28857,
34160,
284,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
#[test]
fn test_get_credential_intervals_from_proof_req() {
let proof_req = json!({
"nonce": "123432421212",
"name": "proof_req_1",
"version": "0.1",
"requested_attributes": {
"address1_1": {
"name": "address1",
"non_revoked": {"from": 123, "to": 456}
},
"zip_2": { "name": "zip" }
},
"requested_predicates": {},
"non_revoked": {"from": 098, "to": 123}
});
let proof_req: ProofRequestData = serde_json::from_value(proof_req).unwrap();
// Attribute not found in proof req
assert_eq!(_get_revocation_interval("not here", &proof_req).unwrap_err().kind(), VcxErrorKind::InvalidProofCredentialData);
// attribute interval overrides proof request interval
let interval = Some(NonRevokedInterval { from: Some(123), to: Some(456) });
assert_eq!(_get_revocation_interval("address1_1", &proof_req).unwrap(), interval);
let interval = Some(NonRevokedInterval { from: Some(098), to: Some(123) });
assert_eq!(_get_revocation_interval("zip_2", &proof_req).unwrap(), interval);
// No interval provided for attribute or proof req
assert_eq!(_get_revocation_interval("address1_1", &proof_req_no_interval()).unwrap(), None);
} | rust_cleaned_test_functions.jsonl/106037 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 660
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
666,
30320,
90807,
5673,
86757,
17644,
368,
341,
286,
1077,
11064,
17644,
284,
2951,
0,
2262,
310,
330,
39593,
788,
330,
16,
17,
18,
19,
18,
17,
19,
17,
16,
17,
16,
17,
756,
310,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_str_components() {
macro_rules! t(
(s: $path:expr, $exp:expr) => (
{
let path = Path::new($path);
let comps = path.str_components().map(|x|x.unwrap())
.collect::<Vec<&str>>();
let exp: &[&str] = $exp;
assert_eq!(comps.as_slice(), exp);
let comps = path.str_components().rev().map(|x|x.unwrap())
.collect::<Vec<&str>>();
let exp = exp.iter().rev().map(|&x|x).collect::<Vec<&str>>();
assert_eq!(comps, exp);
}
);
)
t!(s: b"a\\b\\c", ["a", "b", "c"]);
t!(s: "a\\b\\c", ["a", "b", "c"]);
t!(s: "a\\b\\d", ["a", "b", "d"]);
t!(s: "a\\b\\cd", ["a", "b", "cd"]);
t!(s: "\\a\\b\\c", ["a", "b", "c"]);
t!(s: "a", ["a"]);
t!(s: "\\a", ["a"]);
t!(s: "\\", []);
t!(s: ".", ["."]);
t!(s: "..", [".."]);
t!(s: "..\\..", ["..", ".."]);
t!(s: "..\\..\\foo", ["..", "..", "foo"]);
t!(s: "C:foo\\bar", ["foo", "bar"]);
t!(s: "C:foo", ["foo"]);
t!(s: "C:", []);
t!(s: "C:\\foo\\bar", ["foo", "bar"]);
t!(s: "C:\\foo", ["foo"]);
t!(s: "C:\\", []);
t!(s: "\\\\server\\share\\foo\\bar", ["foo", "bar"]);
t!(s: "\\\\server\\share\\foo", ["foo"]);
t!(s: "\\\\server\\share", []);
t!(s: "\\\\?\\foo\\bar\\baz", ["bar", "baz"]);
t!(s: "\\\\?\\foo\\bar", ["bar"]);
t!(s: "\\\\?\\foo", []);
t!(s: "\\\\?\\", []);
t!(s: "\\\\?\\a\\b", ["b"]);
t!(s: "\\\\?\\a\\b\\", ["b"]);
t!(s: "\\\\?\\foo\\bar\\\\baz", ["bar", "", "baz"]);
t!(s: "\\\\?\\C:\\foo\\bar", ["foo", "bar"]);
t!(s: "\\\\?\\C:\\foo", ["foo"]);
t!(s: "\\\\?\\C:\\", []);
t!(s: "\\\\?\\C:\\foo\\", ["foo"]);
t!(s: "\\\\?\\UNC\\server\\share\\foo\\bar", ["foo", "bar"]);
t!(s: "\\\\?\\UNC\\server\\share\\foo", ["foo"]);
t!(s: "\\\\?\\UNC\\server\\share", []);
t!(s: "\\\\.\\foo\\bar\\baz", ["bar", "baz"]);
t!(s: "\\\\.\\foo\\bar", ["bar"]);
t!(s: "\\\\.\\foo", []);
} | rust_cleaned_test_functions.jsonl/102784 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1442
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2895,
23258,
368,
341,
286,
18072,
21407,
0,
259,
1006,
310,
320,
82,
25,
400,
2343,
96011,
11,
400,
4580,
96011,
8,
589,
2399,
394,
341,
503,
1077,
1815,
284,
7933,
486,
931,
699,
2343,
317,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_finalize_run_with_pass() {
let env = ConfigSpec::new_with_pass();
env::set_var(DEFAULT_MASTER_PASS_ENV_VAR, "some passphrase");
env.copy_node_config_to_output(0);
let node_config = env.output_node_config(0);
env.command("finalize")
.with_arg(env.output_private_config(0))
.with_arg(&node_config)
.with_arg("--public-configs")
.with_args(env.expected_pub_configs())
.run()
.unwrap();
assert_config_files_eq(&node_config, env.expected_node_config_file(0));
let feedback = env
.command("run")
.with_named_arg("-c", &node_config)
.with_named_arg("-d", env.output_dir().join("foo"))
.with_named_arg("--master-key-pass", "env")
.run();
assert!(is_run_node_config(feedback.unwrap()));
} | rust_cleaned_test_functions.jsonl/97980 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 381
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
70616,
14007,
6615,
15464,
368,
341,
262,
1077,
6105,
284,
5532,
8327,
486,
931,
6615,
15464,
1428,
262,
6105,
486,
746,
4612,
43175,
47068,
34351,
22027,
25750,
11,
330,
14689,
75493,
797,
262,
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... | 1 |
#[test]
fn test_subscription() {
let oracle = 1;
let alice = 2;
let bob = 3;
new_test_ext().execute_with(|| {
Timestamp::set_timestamp(1600438152000);
assert_ok!(RWS::set_oracle(Origin::root(), oracle));
let call = Call::from(datalog::Call::record("true".into()));
assert_eq!(RWS::quota(alice), None);
assert_err!(
RWS::call(Origin::signed(bob), alice, call.clone().into()),
Error::<Runtime>::NoSubscription,
);
assert_ok!(RWS::set_subscription(Origin::signed(alice), vec![bob]));
assert_err!(
RWS::call(Origin::signed(bob), alice, call.clone().into()),
Error::<Runtime>::NoQuota,
);
assert_ok!(RWS::set_bandwidth(
Origin::signed(oracle),
alice,
Perbill::from_percent(1),
),);
assert_eq!(RWS::quota(alice), None);
assert_ok!(RWS::call(Origin::signed(bob), alice, call.clone().into()));
assert_eq!(RWS::quota(alice), Some((1600438152000, 0)));
})
} | rust_cleaned_test_functions.jsonl/101698 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 648
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
59838,
368,
341,
286,
1077,
52741,
284,
220,
16,
280,
286,
1077,
70433,
284,
220,
17,
280,
286,
1077,
35192,
284,
220,
18,
401,
286,
501,
4452,
9927,
1005,
10257,
6615,
79453,
341,
310,
32758,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_from_vec_vec_value() {
let vvv = vec![
vec![value!(11), value!("Jacob"), value!("A"), value!(10)],
vec![value!(21), value!("Sam"), value!("A"), value!(9)],
vec![value!(31), value!("James"), value!("A"), value!(9)],
];
let df = Fabrix::from_row_values(vvv, None, false);
assert!(df.is_ok());
let df = df.unwrap();
assert!(df.shape() == (3, 4));
} | rust_cleaned_test_functions.jsonl/38860 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 241
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5673,
13251,
13251,
3142,
368,
341,
286,
1077,
348,
33075,
284,
7486,
90515,
310,
7486,
20703,
957,
10297,
16,
16,
701,
897,
17223,
94167,
3975,
897,
17223,
32,
3975,
897,
10297,
16,
15,
30749,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_len() {
let mut bv = BitVec::new(0);
assert_eq!(bv.len(), 0);
bv.push(true);
assert_eq!(bv.len(), 1);
} | rust_cleaned_test_functions.jsonl/128606 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 98
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6043,
368,
341,
286,
1077,
5206,
56937,
284,
6495,
10050,
486,
931,
7,
15,
626,
286,
2060,
10714,
10297,
54929,
19406,
1507,
220,
15,
626,
286,
56937,
2552,
3715,
317,
286,
2060,
10714,
10297,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_dashmap_secondary_index() {
let (key_start, key_end, secondary_indexes) = create_dashmap_secondary_index_state();
let index = AccountsIndex::<bool>::default_for_tests();
for token_id in [inline_spl_token::id(), inline_spl_token_2022::id()] {
run_test_spl_token_secondary_indexes(
&token_id,
&index,
&index.spl_token_mint_index,
key_start,
key_end,
&secondary_indexes,
);
}
} | rust_cleaned_test_functions.jsonl/71349 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 297
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
84585,
2186,
77759,
3560,
368,
341,
286,
1077,
320,
792,
4906,
11,
1376,
6213,
11,
14246,
50161,
8,
284,
1855,
84585,
2186,
77759,
3560,
4387,
543,
286,
1077,
1922,
284,
40655,
1552,
27638,
2641,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_default_is_initial_digit_value() {
// Given:
let actual = Counter::default();
// Then:
let expected = Counter::from(vec![UINT_MIN]);
assert_eq!(expected, actual);
} | rust_cleaned_test_functions.jsonl/79502 | {
"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,
9993,
6892,
15809,
48403,
3142,
368,
341,
310,
442,
16246,
510,
310,
1077,
5042,
284,
19735,
486,
2258,
1428,
310,
442,
5005,
510,
310,
1077,
3601,
284,
19735,
486,
1499,
25592,
20703,
25712,
1182... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_ls_long_ctime() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
at.touch("test-long-ctime-1");
for arg in &["-c", "--time=ctime", "--time=status"] {
let result = scene.ucmd().arg("-l").arg(arg).succeeds();
#[cfg(unix)]
result.stdout_contains(":");
#[cfg(not(unix))]
result.stdout_contains("???");
}
} | rust_cleaned_test_functions.jsonl/71206 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 212
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
53174,
17799,
26134,
545,
368,
341,
262,
1077,
6109,
284,
3393,
54031,
486,
931,
67811,
1269,
0,
1423,
262,
1077,
518,
284,
609,
22483,
67785,
18513,
401,
262,
518,
42129,
445,
1944,
23791,
12,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_empty_tuple() {
assert_eq!((), ());
assert_eq!(().partial_cmp(&()), Some(Ordering::Equal));
assert_eq!(().cmp(&()), Ordering::Equal);
assert_eq!(Default::<()>::default(), ());
} | rust_cleaned_test_functions.jsonl/123994 | {
"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,
15124,
21773,
368,
341,
262,
2060,
10714,
10297,
1507,
49323,
262,
2060,
10714,
10297,
1005,
37420,
35193,
2099,
11858,
4329,
39692,
287,
486,
2993,
1106,
262,
2060,
10714,
10297,
1005,
7293,
2099,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_bad_index() {
let map: TypedHandleMap<Foobar> = TypedHandleMap::new();
assert_eq!(
map.get(TypedHandle::<Foobar>::from_raw_parts(
100,
2,
map.as_untyped_map().map_id()
)),
None
);
} | rust_cleaned_test_functions.jsonl/15923 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 199
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34199,
3560,
368,
341,
286,
1077,
2415,
25,
50554,
6999,
2227,
30499,
78,
31393,
29,
284,
50554,
6999,
2227,
486,
931,
543,
286,
2060,
10714,
33673,
310,
2415,
670,
4140,
32501,
6999,
27638,
91879... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_valid_inputs() {
let ip = NetworkAddress::from_str("/ip4/127.0.0.1/tcp/1234").unwrap();
let dns = NetworkAddress::from_str("/dns4/localhost/tcp/1234").unwrap();
validate_address("ip", &ip).expect("IP failed to validate");
validate_address("dns", &dns).expect("DNS failed to validate");
} | rust_cleaned_test_functions.jsonl/80839 | {
"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,
8337,
28557,
368,
341,
286,
1077,
5997,
284,
8141,
4286,
486,
1499,
2895,
4283,
573,
19,
14,
16,
17,
22,
13,
15,
13,
15,
13,
16,
95958,
14,
16,
17,
18,
19,
1827,
15454,
543,
286,
1077,
440... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_field_to_bytes(){
let fields = DefinitionFields::new();
let expiration: Vec<u8> = fields.field_to_bytes("Expiration".to_string(),Value::from(595640108)).unwrap();
assert_eq!(expiration, [42, 35, 128, 191, 44]);
} | rust_cleaned_test_functions.jsonl/15173 | {
"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,
5013,
2346,
12524,
3032,
414,
1077,
5043,
284,
19709,
8941,
486,
931,
543,
414,
1077,
31692,
25,
11312,
34837,
23,
29,
284,
5043,
16454,
2346,
12524,
445,
66301,
3263,
983,
3904,
1507,
1130,
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_plain_scalar_starting_with_indicators_in_flow() {
character= "{a: :b}";
let mut p = Scanner::new(s.chars());
next!(p, StreamStart(..));
next!(p, FlowMappingStart);
next!(p, Key);
next_scalar!(p, TScalarStyle::Plain, "a");
next!(p, Value);
next_scalar!(p, TScalarStyle::Plain, ":b");
next!(p, FlowMappingEnd);
next!(p, StreamEnd);
end!(p);
let s = "{a: ?b}";
let mut p = Scanner::new(s.chars());
next!(p, StreamStart(..));
next!(p, FlowMappingStart);
next!(p, Key);
next_scalar!(p, TScalarStyle::Plain, "a");
next!(p, Value);
next_scalar!(p, TScalarStyle::Plain, "?b");
next!(p, FlowMappingEnd);
next!(p, StreamEnd);
end!(p);
} | rust_cleaned_test_functions.jsonl/91013 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 469
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
41015,
41652,
4906,
287,
6615,
9122,
42052,
1243,
27441,
368,
341,
1789,
286,
3668,
28,
13868,
64,
25,
549,
65,
26259,
286,
1077,
5206,
281,
284,
17170,
486,
931,
1141,
85062,
1423,
286,
1790,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_adj_list() {
let mut graph = Graph::new(4, 4);
graph.add_edge(0, 1);
graph.add_edge(1, 2);
graph.add_edge(1, 3);
graph.add_edge(3, 0);
let adj: Vec<(usize, usize)> = graph.adj_list(1).collect();
assert_eq!(adj, vec![(2, 3), (1, 2)]);
} | rust_cleaned_test_functions.jsonl/789 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 177
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
42559,
2019,
368,
341,
286,
1077,
5206,
4771,
284,
12165,
486,
931,
7,
19,
11,
220,
19,
317,
286,
4771,
1364,
17932,
7,
15,
11,
220,
16,
317,
286,
4771,
1364,
17932,
7,
16,
11,
220,
17,
31... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_query_matches_with_alternatives_under_fields() {
allocations::record(|| {
let language = get_language("javascript");
let query = Query::new(
language,
r#"
(assignment_expression
left: [
(identifier) @variable
(member_expression property: (property_identifier) @variable)
])
"#,
)
.unwrap();
assert_query_matches(
language,
&query,
"
a = b;
b = c.d;
e.f = g;
h.i = j.k;
",
&[
(0, vec![("variable", "a")]),
(0, vec![("variable", "b")]),
(0, vec![("variable", "f")]),
(0, vec![("variable", "i")]),
],
);
});
} | rust_cleaned_test_functions.jsonl/25170 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 550
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5738,
38344,
6615,
79728,
5859,
58228,
12132,
368,
341,
262,
69642,
486,
8548,
79453,
341,
286,
1077,
4128,
284,
633,
29021,
445,
14073,
797,
286,
1077,
3239,
284,
11361,
486,
931,
1006,
310,
4128... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_bool() -> Result<()> {
let b = Basic {
b: true,
b2: false,
..Default::default()
};
// serialize it and assert that it serializes correctly
let s = String::from_utf8(serialize(&b).to_vec()).unwrap();
// Assert that deserialize builts the exact same struct
assert_eq!(b, deserialize(s).unwrap());
Ok(())
} | rust_cleaned_test_functions.jsonl/122580 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 162
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
22159,
368,
1464,
5714,
71698,
341,
262,
1077,
293,
284,
14625,
341,
286,
293,
25,
830,
345,
286,
293,
17,
25,
895,
345,
286,
5241,
3675,
486,
2258,
741,
262,
2605,
262,
442,
24235,
432,
323,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ota_update_channel_config_new() {
assert_eq!(
OtaUpdateChannelConfig::new("channel", "tuf").unwrap(),
OtaUpdateChannelConfig {
channel_name: "channel".to_string(),
tuf_config_name: "tuf".to_string(),
}
);
} | rust_cleaned_test_functions.jsonl/43613 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 170
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
6089,
8882,
14571,
5332,
5921,
368,
341,
286,
2060,
10714,
33673,
310,
506,
2565,
4289,
9629,
2648,
486,
931,
445,
10119,
497,
330,
83,
1704,
1827,
15454,
3148,
310,
506,
2565,
4289,
9629,
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_mut_rchunks_exact_0() {
let mut v = [1, 2, 3, 4];
let _it = v.rchunks_exact_mut(0);
} | rust_cleaned_test_functions.jsonl/12933 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 66
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
29523,
1710,
84263,
71084,
62,
15,
368,
341,
262,
1077,
5206,
348,
284,
508,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
935,
262,
1077,
716,
275,
284,
348,
1746,
84263,
71084,
29523,
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 |
#[test]
fn test_map() {
assert_eq!(
Val::Map(hashmap! {
"xxx".to_owned() => Val::Int(123),
"yyy".to_owned() => Val::Float(3.14),
})
.type_of(),
Type::Map(hashmap! {
"xxx".to_owned() => Type::Int,
"yyy".to_owned() => Type::Float,
})
);
} | rust_cleaned_test_functions.jsonl/113308 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 247
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5376,
368,
341,
286,
2060,
10714,
33673,
310,
4104,
486,
2227,
27580,
2186,
0,
341,
394,
330,
24048,
3263,
983,
51973,
368,
589,
4104,
486,
1072,
7,
16,
17,
18,
1326,
394,
330,
39319,
3263,
98... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_add_name_again() {
CustomerTestFramework::default()
.given(vec![
CustomerEvent::NameAdded(NameAdded {
changed_name: "John Doe".to_string()
})
])
.when(AddCustomerName { changed_name: "John Doe".to_string() })
.then_expect_error("a name has already been added for this customer");
} | rust_cleaned_test_functions.jsonl/100168 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 208
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
1269,
62427,
368,
341,
286,
12277,
2271,
14837,
486,
2258,
741,
310,
659,
41968,
25592,
90515,
394,
12277,
1556,
486,
675,
19337,
21182,
19337,
341,
503,
5497,
1269,
25,
330,
13079,
49628,
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_no_detection_of_rejected_wpa1_or_wpa2_credentials() {
let failure = ConnectFailure::ScanFailure(fidl_mlme::ScanResultCode::InternalError);
assert!(!failure.likely_due_to_credential_rejected());
let failure = ConnectFailure::AssociationFailure(AssociationFailure {
bss_protection: BssProtection::Wpa2Personal,
code: fidl_ieee80211::StatusCode::RefusedUnauthenticatedAccessNotSupported,
});
assert!(!failure.likely_due_to_credential_rejected());
} | rust_cleaned_test_functions.jsonl/33061 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 223
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6536,
57505,
3575,
1288,
28303,
1670,
6595,
16,
8734,
1670,
6595,
17,
47396,
368,
341,
286,
1077,
7901,
284,
13015,
17507,
486,
26570,
17507,
40556,
75,
76567,
2660,
486,
26570,
2077,
2078,
486,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_michelso_std() {
let result = get_actual_result("test_csvs/Michelso.csv", "stddev");
assert_abs_diff_eq!(result, 0.0790105478190518, epsilon = stddev_epsilon());
} | rust_cleaned_test_functions.jsonl/80540 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 89
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
717,
90240,
704,
15656,
368,
341,
262,
1077,
1102,
284,
633,
40149,
5287,
445,
1944,
14020,
82,
10270,
90240,
704,
11219,
497,
330,
1834,
3583,
797,
262,
2060,
31170,
15850,
10714,
10297,
1382,
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_parse_matching_fields() {
let re = Regex::new(",").unwrap();
// bytes:3 3 3 3
assert_eq!(
super::parse_matching_fields(
&re,
&"中,华,人,民,E,F",
&vec![Single(2), Single(4), Single(-1), Single(-7)]
),
vec![(4, 8), (12, 16), (18, 19)]
);
assert_eq!(
super::parse_matching_fields(&re, &"中,华,人,民,E,F", &vec![LeftInf(3), LeftInf(-6), LeftInf(-7)]),
vec![(0, 12), (0, 4)]
);
assert_eq!(
super::parse_matching_fields(
&re,
&"中,华,人,民,E,F",
&vec![RightInf(5), RightInf(-2), RightInf(-1), RightInf(7)]
),
vec![(16, 19), (16, 19), (18, 19)]
);
assert_eq!(
super::parse_matching_fields(
&re,
&"中,华,人,民,E,F",
&vec![Both(3, 3), Both(-8, 2), Both(6, 10), Both(-8, -5)]
),
vec![(8, 12), (0, 8), (18, 19), (0, 8)]
);
} | rust_cleaned_test_functions.jsonl/82620 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 719
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
70763,
12132,
368,
341,
1789,
286,
1077,
312,
284,
26146,
486,
931,
47503,
568,
15454,
1428,
286,
442,
5820,
25,
18,
220,
220,
18,
220,
220,
18,
220,
18,
198,
688,
2060,
10714,
33673,
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_and_with_multiple_like_to_string() {
let name1 = _random_vector(10);
let value1 = _random_string(10);
let name2 = _random_vector(10);
let value2 = _random_string(10);
let name3 = _random_vector(10);
let value3 = _random_string(10);
let query = Operator::And(
vec![
Operator::Like(
TagName::PlainTagName(name1.clone()),
TargetValue::Unencrypted(value1.clone())
),
Operator::Like(
TagName::PlainTagName(name2.clone()),
TargetValue::Unencrypted(value2.clone())
),
Operator::Like(
TagName::PlainTagName(name3.clone()),
TargetValue::Unencrypted(value3.clone())
),
]
);
let json = query.to_string();
let expected = format!(r#"{{"$and":[{{"~{}":{{"$like":"{}"}}}},{{"~{}":{{"$like":"{}"}}}},{{"~{}":{{"$like":"{}"}}}}]}}"#,
base64::encode(&name1), value1,
base64::encode(&name2), value2,
base64::encode(&name3), value3
);
assert_eq!(json, expected);
} | rust_cleaned_test_functions.jsonl/11904 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 747
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8378,
6615,
45233,
25535,
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,
317,
286,
1077,
829,
17,
284... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_roundtrip() {
let stuff1 = MyStuff {
data: MyStuffType::Ver1 { x: 2.5, y: 2.5 },
};
let data_bytes = serde_cbor::to_vec(&stuff1).unwrap();
let stuff2 = serde_cbor::from_slice(&data_bytes).unwrap();
assert_eq!(stuff1, stuff2);
} | rust_cleaned_test_functions.jsonl/60474 | {
"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,
29896,
32981,
368,
341,
286,
1077,
6259,
16,
284,
3017,
86622,
341,
310,
821,
25,
3017,
86622,
929,
486,
10141,
16,
314,
856,
25,
220,
17,
13,
20,
11,
379,
25,
220,
17,
13,
20,
1153,
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_fetch_has_value_sync() {
let fetcher = TestFileFetcher::new();
let en_us: LanguageIdentifier = "en-US".parse().unwrap();
let path = FTL_RESOURCE_PRESENT;
let path_missing = FTL_RESOURCE_MISSING;
let fs1 = fetcher.get_test_file_source("toolkit", vec![en_us.clone()], "toolkit/{locale}/");
assert_eq!(fs1.has_file(&en_us, path), None);
assert!(fs1.fetch_file_sync(&en_us, path, false).is_some());
assert_eq!(fs1.has_file(&en_us, path), Some(true));
assert_eq!(fs1.has_file(&en_us, path_missing), None);
assert!(fs1.fetch_file_sync(&en_us, path_missing, false).is_none());
assert_eq!(fs1.has_file(&en_us, path_missing), Some(false));
} | rust_cleaned_test_functions.jsonl/133059 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 306
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11803,
21778,
3142,
23008,
368,
341,
262,
1077,
7807,
261,
284,
3393,
1703,
97492,
486,
931,
543,
262,
1077,
662,
11306,
25,
11434,
8714,
284,
330,
268,
32340,
3263,
6400,
1005,
15454,
543,
262,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_versionize_union_with_array() {
#[derive(Versionize)]
union TestUnion {
a: [u32; SIZE],
b: [u8; dummy_mod::SIZE],
}
impl Default for TestUnion {
fn default() -> Self {
TestUnion { a: [3; SIZE] }
}
}
impl Debug for TestUnion {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
unsafe { write!(f, "{{ a: {:?}, b: {:?} }}", self.a, self.b) }
}
}
let test_union = TestUnion { a: [1; SIZE] };
let mut mem = vec![0; 4096];
let version_map = VersionMap::new();
test_union
.serialize(&mut mem.as_mut_slice(), &version_map, 1)
.unwrap();
let restored_test_union = TestUnion::deserialize(&mut mem.as_slice(), &version_map, 1).unwrap();
unsafe {
assert_eq!(restored_test_union.a, test_union.a);
assert_eq!(restored_test_union.b, test_union.b);
}
} | rust_cleaned_test_functions.jsonl/11259 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 441
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9438,
551,
51621,
6615,
3858,
368,
341,
262,
11506,
27098,
7,
5637,
551,
5563,
262,
11300,
3393,
32658,
341,
286,
264,
25,
508,
84,
18,
17,
26,
25341,
1259,
286,
293,
25,
508,
84,
23,
26,
17... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_bytes_basics() -> std::io::Result<()> {
task::block_on(async move {
let raw: Vec<u8> = vec![0, 1, 2, 3, 4, 5, 6, 7, 8];
let source: io::Cursor<Vec<u8>> = io::Cursor::new(raw.clone());
let mut s = source.bytes();
let mut result = Vec::new();
while let Some(byte) = s.next().await {
result.push(byte?);
}
assert_eq!(result, raw);
Ok(())
})
} | rust_cleaned_test_functions.jsonl/109639 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 292
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12524,
880,
67981,
368,
1464,
1460,
486,
815,
486,
2077,
71698,
341,
286,
3383,
486,
4574,
4470,
18285,
3271,
341,
310,
1077,
7112,
25,
11312,
34837,
23,
29,
284,
7486,
20703,
15,
11,
220,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_directory_writable_succeeds_if_writable() {
let temp_dir = TempDir::new("writable").expect("could not create tempdir");
let path = temp_dir.into_path();
test_directory_writable("test", &path).expect("could not write to directory");
} | rust_cleaned_test_functions.jsonl/80499 | {
"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,
14846,
1670,
22533,
643,
29264,
82,
11119,
1670,
22533,
368,
341,
286,
1077,
2730,
4334,
284,
19944,
6184,
486,
931,
445,
86,
22533,
1827,
17119,
445,
28077,
537,
1855,
2730,
3741,
797,
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_fail_unclosed_array_with_comment() {
let src_data = b"(test) [\\comment]";
assert!(yass_parser::parse(yass_parser::ParserLimits::unlimited(), src_data).is_err());
} | rust_cleaned_test_functions.jsonl/126504 | {
"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,
22121,
76576,
9259,
3858,
6615,
17638,
368,
341,
262,
1077,
2286,
1769,
284,
293,
29209,
1944,
8,
508,
3422,
6182,
59757,
262,
2060,
10297,
88,
395,
18517,
486,
6400,
7021,
395,
18517,
486,
6570,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.