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_message_serialization() {
let value = 11 as i32;
let msg = Message::new(value);
let serialized = bincode::serialize(&msg).expect("Couldn't serialize.");
let deserialized: Message =
bincode::deserialize(&serialized).expect("Couldn't deserialize.");
let read_guard = deserialized.data.content.read().unwrap();
match &*read_guard {
MessageContent::Local(_) => panic!("Expected a Remote variant."),
MessageContent::Remote(_) => {
drop(read_guard);
match deserialized.content_as::<i32>() {
None => panic!("Could not cast content."),
Some(v) => assert_eq!(value, *v),
}
}
}
} | rust_cleaned_test_functions.jsonl/122615 | {
"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,
6462,
25602,
2022,
368,
341,
286,
1077,
897,
284,
220,
16,
16,
438,
600,
18,
17,
280,
286,
1077,
3750,
284,
4856,
486,
931,
3679,
317,
286,
1077,
32916,
284,
9544,
1851,
486,
24166,
2099,
3236... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_bits() -> Result<()> {
let bits: Bits = "128".parse()?;
let number: BigUint = bits.into();
assert_eq!(
"340282366920938463463374607431768211456",
format!("{}", number)
);
Ok(())
} | rust_cleaned_test_functions.jsonl/39501 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 149
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20034,
368,
1464,
5714,
71698,
341,
286,
1077,
9472,
25,
49457,
284,
330,
16,
17,
23,
3263,
6400,
94136,
286,
1077,
1372,
25,
6164,
21570,
284,
9472,
39860,
543,
286,
2060,
10714,
33673,
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... | 2 |
#[test]
fn test_concurrent_2_gc() {
use std::thread::spawn;
let t: Vec<_> = (0..100)
.into_iter()
.map(|i| {
spawn(move || {
let v: Vec<_> = (0..100)
.into_iter()
.map(|_| spawn(move || STR_POOL.intern(i.to_string(), Arc::from)))
.collect();
for b in v.into_iter() {
assert_eq!(b.join().unwrap().get(), i.to_string());
}
})
})
.zip((0..100).into_iter().map(|_| {
spawn(move || {
let v: Vec<_> = (0..100)
.into_iter()
.map(|_| {
spawn(move || {
STR_POOL.collect_garbage();
})
})
.collect();
for r in v.into_iter() {
assert!(r.join().is_ok());
}
})
}))
.collect();
for (a, b) in t.into_iter() {
assert!(a.join().is_ok());
assert!(b.join().is_ok());
}
} | rust_cleaned_test_functions.jsonl/38598 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 890
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3382,
3231,
62,
17,
49423,
368,
341,
286,
990,
1460,
486,
4528,
486,
46087,
401,
286,
1077,
259,
25,
11312,
32399,
29,
284,
320,
15,
496,
16,
15,
15,
340,
310,
659,
18122,
11723,
741,
310,
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... | 8 |
#[test]
fn test_parse_data_format_error() {
let packet =
hex::decode("000055aa00000000000000070000003b00000001332e33d504910232d355a59ed1f6ed1f4a816a1e8e30ed09987c020ae45d72c70592bb233c79c43a5b9ae49b6ead38725deb520000aa55").unwrap();
let expected = Message {
command: Some(CommandType::Control),
payload: "data format error".as_bytes().to_owned(),
seq_nr: Some(0),
ret_code: Some(1),
};
let mp = MessageParser::create("3.3", None).unwrap();
let (buf, messages) = mp.parse_messages(&packet).unwrap();
assert_eq!(messages[0], expected);
assert_eq!(buf, &[] as &[u8]);
} | rust_cleaned_test_functions.jsonl/39164 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 342
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
1769,
8955,
4096,
368,
341,
286,
1077,
10151,
4035,
310,
12371,
486,
18196,
445,
15,
15,
15,
15,
20,
20,
5305,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
22,
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_saturating_sub() {
let length1: Length<u8, Mm> = Length::new(5);
let length2: Length<u8, Mm> = Length::new(10);
let result = length1.saturating_sub(length2);
assert_eq!(result.get(), 0);
} | rust_cleaned_test_functions.jsonl/50582 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 122
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
643,
2628,
1095,
5228,
368,
341,
286,
1077,
3084,
16,
25,
17287,
34837,
23,
11,
386,
76,
29,
284,
17287,
486,
931,
7,
20,
317,
286,
1077,
3084,
17,
25,
17287,
34837,
23,
11,
386,
76,
29,
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_write_metadata_table_with_segment() {
let m = RWTFMetadata::new(None, Some(TrackType::Segment(0x42)));
let mut buf = vec![];
let written = m.write(&mut buf);
assert!(written.is_ok());
let expected_head = &[0x02, // 2 table entries
0x01, // entry #1 is of type created_at
0x08, // entry data is 8 bytes
0x00];
let expected_tail = &[0x00, // entry #2 is of type track_type
0x05, // entry data is 5 bytes
0x00,
0x02, // TrackType::Segment
0x42, // the segment id
0x00,
0x00,
0x00];
test_buf(&buf, expected_head, expected_tail);
} | rust_cleaned_test_functions.jsonl/51230 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 561
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9165,
22220,
5237,
6615,
28061,
368,
341,
286,
1077,
296,
284,
46206,
10808,
14610,
486,
931,
26717,
11,
4329,
7,
15667,
929,
486,
21086,
7,
15,
87,
19,
17,
22525,
286,
1077,
5206,
6607,
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_content_sha1hex_none() {
let value: ContentSha1Hex = convert_bser_value(Value::Null);
assert_eq!(value, ContentSha1Hex::None);
} | rust_cleaned_test_functions.jsonl/25482 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 81
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7495,
48836,
16,
17308,
31488,
368,
341,
286,
1077,
897,
25,
8883,
62316,
16,
20335,
284,
5508,
880,
799,
3142,
25346,
486,
3280,
317,
286,
2060,
10714,
10297,
957,
11,
8883,
62316,
16,
20335,
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 |
#[test]
fn test_convert_function() {
let b = ast::BaseNode::default();
let pkg = ast::Package {
base: b.clone(),
path: "path".to_string(),
package: "main".to_string(),
files: vec![ast::File {
base: b.clone(),
name: "foo.flux".to_string(),
metadata: String::new(),
package: None,
imports: Vec::new(),
body: vec![
ast::Statement::Variable(Box::new(ast::VariableAssgn {
base: b.clone(),
id: ast::Identifier {
base: b.clone(),
name: "f".to_string(),
},
init: ast::Expression::Function(Box::new(ast::FunctionExpr {
base: b.clone(),
lparen: None,
params: vec![
ast::Property {
base: b.clone(),
key: ast::PropertyKey::Identifier(ast::Identifier {
base: b.clone(),
name: "a".to_string(),
}),
separator: None,
value: None,
comma: None,
},
ast::Property {
base: b.clone(),
key: ast::PropertyKey::Identifier(ast::Identifier {
base: b.clone(),
name: "b".to_string(),
}),
separator: None,
value: None,
comma: None,
},
],
rparen: None,
arrow: None,
body: ast::FunctionBody::Expr(ast::Expression::Binary(Box::new(
ast::BinaryExpr {
base: b.clone(),
operator: ast::Operator::AdditionOperator,
left: ast::Expression::Identifier(ast::Identifier {
base: b.clone(),
name: "a".to_string(),
}),
right: ast::Expression::Identifier(ast::Identifier {
base: b.clone(),
name: "b".to_string(),
}),
},
))),
})),
})),
ast::Statement::Expr(Box::new(ast::ExprStmt {
base: b.clone(),
expression: ast::Expression::Call(Box::new(ast::CallExpr {
base: b.clone(),
callee: ast::Expression::Identifier(ast::Identifier {
base: b.clone(),
name: "f".to_string(),
}),
lparen: None,
arguments: vec![ast::Expression::Object(Box::new(ast::ObjectExpr {
base: b.clone(),
lbrace: None,
with: None,
properties: vec![
ast::Property {
base: b.clone(),
key: ast::PropertyKey::Identifier(ast::Identifier {
base: b.clone(),
name: "a".to_string(),
}),
separator: None,
value: Some(ast::Expression::Integer(ast::IntegerLit {
base: b.clone(),
value: 2,
})),
comma: None,
},
ast::Property {
base: b.clone(),
key: ast::PropertyKey::Identifier(ast::Identifier {
base: b.clone(),
name: "b".to_string(),
}),
separator: None,
value: Some(ast::Expression::Integer(ast::IntegerLit {
base: b.clone(),
value: 3,
})),
comma: None,
},
],
rbrace: None,
}))],
rparen: None,
})),
})),
],
eof: None,
}],
};
let want = Package {
loc: b.location.clone(),
package: "main".to_string(),
files: vec![File {
loc: b.location.clone(),
package: None,
imports: Vec::new(),
body: vec![
Statement::Variable(Box::new(VariableAssgn::new(
Identifier {
loc: b.location.clone(),
name: "f".to_string(),
},
Expression::Function(Box::new(FunctionExpr {
loc: b.location.clone(),
typ: type_info(),
params: vec![
FunctionParameter {
loc: b.location.clone(),
is_pipe: false,
key: Identifier {
loc: b.location.clone(),
name: "a".to_string(),
},
default: None,
},
FunctionParameter {
loc: b.location.clone(),
is_pipe: false,
key: Identifier {
loc: b.location.clone(),
name: "b".to_string(),
},
default: None,
},
],
body: Block::Return(ReturnStmt {
loc: b.location.clone(),
argument: Expression::Binary(Box::new(BinaryExpr {
loc: b.location.clone(),
typ: type_info(),
operator: ast::Operator::AdditionOperator,
left: Expression::Identifier(IdentifierExpr {
loc: b.location.clone(),
typ: type_info(),
name: "a".to_string(),
}),
right: Expression::Identifier(IdentifierExpr {
loc: b.location.clone(),
typ: type_info(),
name: "b".to_string(),
}),
})),
}),
})),
b.location.clone(),
))),
Statement::Expr(ExprStmt {
loc: b.location.clone(),
expression: Expression::Call(Box::new(CallExpr {
loc: b.location.clone(),
typ: type_info(),
pipe: None,
callee: Expression::Identifier(IdentifierExpr {
loc: b.location.clone(),
typ: type_info(),
name: "f".to_string(),
}),
arguments: vec![
Property {
loc: b.location.clone(),
key: Identifier {
loc: b.location.clone(),
name: "a".to_string(),
},
value: Expression::Integer(IntegerLit {
loc: b.location.clone(),
value: 2,
}),
},
Property {
loc: b.location.clone(),
key: Identifier {
loc: b.location.clone(),
name: "b".to_string(),
},
value: Expression::Integer(IntegerLit {
loc: b.location.clone(),
value: 3,
}),
},
],
})),
}),
],
}],
};
let got = test_convert(pkg).unwrap();
assert_eq!(want, got);
} | rust_cleaned_test_functions.jsonl/30446 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 7774
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34910,
9174,
368,
341,
286,
1077,
293,
284,
11763,
486,
3978,
1955,
486,
2258,
543,
286,
1077,
24793,
284,
11763,
486,
13100,
341,
310,
2331,
25,
293,
15997,
3148,
310,
1815,
25,
330,
2343,
3263... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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() {
let settings = Settings::new();
let v1: u32 = 1;
let v2: f32 = 1.0;
let vt1 = TypeId::of::<u32>();
let vt2 = TypeId::of::<f32>();
let mut values = settings.settings.write();
values.insert(vt1, Box::new(v1.clone()));
values.insert(vt2, Box::new(v2.clone()));
unsafe {
settings.settings.force_unlock_write();
}
let r1 = settings.get::<u32>();
let r2 = settings.get::<f32>();
assert_eq!(v1, r1);
assert_eq!(v2, r2);
} | rust_cleaned_test_functions.jsonl/29876 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 309
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
368,
341,
286,
1077,
5003,
284,
11296,
486,
931,
1428,
286,
1077,
348,
16,
25,
575,
18,
17,
284,
220,
16,
280,
286,
1077,
348,
17,
25,
282,
18,
17,
284,
220,
16,
13,
15,
280,
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_sample_slice_boundaries() {
let empty: &[u8] = &[];
let mut r = ::test::rng(402);
// sample 0 items
assert_eq!(&sample_slice(&mut r, empty, 0)[..], [0u8; 0]);
assert_eq!(&sample_slice(&mut r, &[42, 2, 42], 0)[..], [0u8; 0]);
// sample 1 item
assert_eq!(&sample_slice(&mut r, &[42], 1)[..], [42]);
let v = sample_slice(&mut r, &[1, 42], 1)[0];
assert!(v == 1 || v == 42);
// sample "all" the items
let v = sample_slice(&mut r, &[42, 133], 2);
assert!(&v[..] == [42, 133] || v[..] == [133, 42]);
assert_eq!(&sample_indices_inplace(&mut r, 0, 0)[..], [0usize; 0]);
assert_eq!(&sample_indices_inplace(&mut r, 1, 0)[..], [0usize; 0]);
assert_eq!(&sample_indices_inplace(&mut r, 1, 1)[..], [0]);
assert_eq!(&sample_indices_cache(&mut r, 0, 0)[..], [0usize; 0]);
assert_eq!(&sample_indices_cache(&mut r, 1, 0)[..], [0usize; 0]);
assert_eq!(&sample_indices_cache(&mut r, 1, 1)[..], [0]);
// Make sure lucky 777's aren't lucky
let slice = &[42, 777];
let mut num_42 = 0;
let total = 1000;
for _ in 0..total {
let v = sample_slice(&mut r, slice, 1);
assert_eq!(v.len(), 1);
let v = v[0];
assert!(v == 42 || v == 777);
if v == 42 {
num_42 += 1;
}
}
let ratio_42 = num_42 as f64 / 1000 as f64;
assert!(0.4 <= ratio_42 || ratio_42 <= 0.6, "{}", ratio_42);
} | rust_cleaned_test_functions.jsonl/69734 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 814
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17491,
26488,
19447,
5431,
368,
341,
286,
1077,
4287,
25,
44590,
84,
23,
60,
284,
609,
40901,
286,
1077,
5206,
435,
284,
3504,
1944,
486,
69890,
7,
19,
15,
17,
626,
286,
442,
6077,
220,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
#[test]
fn test_search_query_spaces_and_stuff() {
let query = SearchQuery {
query: "test??? wow".to_string(),
types: vec![SearchType::Album],
limit: 5,
offset: 0,
};
assert_eq!(
query.into_query_string(),
"type=album&q=test+wow&offset=0&limit=5&market=from_token"
);
} | rust_cleaned_test_functions.jsonl/52793 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 211
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10716,
5738,
67883,
8378,
95396,
368,
341,
286,
1077,
3239,
284,
7542,
2859,
341,
310,
3239,
25,
330,
1944,
33015,
35665,
3263,
983,
3904,
3148,
310,
4494,
25,
7486,
20703,
5890,
929,
486,
32378,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_empty_message() {
let (mut connected_peer, mut remote_peer) = setup_peers();
let message: Vec<u8> = vec![];
let encrypted_message = connected_peer.encrypt_buf(&message).unwrap();
assert_eq!(encrypted_message.len(), 2 + 16 + 16);
let decrypted_message = remote_peer
.decrypt_single_message(Some(&encrypted_message))
.unwrap()
.unwrap();
assert_eq!(decrypted_message, Vec::<u8>::new());
} | rust_cleaned_test_functions.jsonl/39154 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 225
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15124,
6462,
368,
341,
286,
1077,
320,
6984,
8433,
45159,
11,
5206,
8699,
45159,
8,
284,
6505,
36367,
388,
1428,
286,
1077,
1943,
25,
11312,
34837,
23,
29,
284,
7486,
0,
15078,
286,
1077,
24455,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_macros_conv() {
let mut conv_map = parse(
SourceId::none(),
r#"
mod swig_foreign_types_map {
#![swig_foreigner_type="byte"]
#![swig_rust_type="jbyte"]
#![swig_foreigner_type="short"]
#![swig_rust_type="jshort"]
}
#[swig_code = "let {to_var}: {to_var_type} = <{to_var_type}>::swig_from({from_var}, env);"]
trait SwigFrom<T> {
fn swig_from(T, env: *mut JNIEnv) -> Self;
}
impl SwigFrom<u8> for jshort {
fn swig_from(x: u8, _: *mut JNIEnv) -> Self {
x as jshort
}
}
#[allow(unused_macros)]
#[swig_generic_arg = "T"]
#[swig_generic_arg = "E"]
#[swig_from = "Result<T, E>"]
#[swig_to = "T"]
#[swig_code = "let {to_var}: {to_var_type} = jni_unpack_return!({from_var}, env);"]
macro_rules! jni_unpack_return {
($result_value:expr, $default_value:expr, $env:ident) => {
{
let ret = match $result_value {
Ok(x) => x,
Err(msg) => {
jni_throw_exception($env, &msg);
return $default_value;
}
};
ret
}
}
}
"#,
64,
FxHashMap::default(),
)
.unwrap();
let foo_ty = conv_map.find_or_alloc_rust_type(&parse_type! { Foo }, SourceId::none());
let result_foo_str_ty = conv_map
.find_or_alloc_rust_type(&parse_type! { Result<Foo, String> }, SourceId::none());
let (_, code) = conv_map
.convert_rust_types(
result_foo_str_ty.to_idx(),
foo_ty.to_idx(),
"a0",
"a1",
"jlong",
invalid_src_id_span(),
)
.unwrap();
assert_eq!(
r#" let a1: Foo = jni_unpack_return!(a0, env);
"#,
code
);
let result_u8_str_ty = conv_map
.find_or_alloc_rust_type(&parse_type! { Result<u8, &'static str> }, SourceId::none());
let jshort_ty = conv_map.find_or_alloc_rust_type(&parse_type! { jshort }, SourceId::none());
let (_, code) = conv_map
.convert_rust_types(
result_u8_str_ty.to_idx(),
jshort_ty.to_idx(),
"a0",
"a1",
"jlong",
invalid_src_id_span(),
)
.unwrap();
assert_eq!(
r#" let a1: u8 = jni_unpack_return!(a0, env);
let a1: jshort = <jshort>::swig_from(a1, env);
"#,
code
);
} | rust_cleaned_test_functions.jsonl/18737 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1489
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
85904,
22716,
368,
341,
286,
1077,
5206,
5686,
5376,
284,
4715,
1006,
310,
8748,
764,
486,
6697,
3148,
310,
435,
2,
698,
2593,
2021,
343,
78983,
9763,
5376,
341,
262,
671,
20703,
2280,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_args_multiplexed_connection() {
let ctx = TestContext::new();
block_on_all(async move {
ctx.multiplexed_async_connection()
.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/75331 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 284
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8384,
91802,
2571,
291,
15866,
368,
341,
262,
1077,
5635,
284,
3393,
1972,
486,
931,
543,
262,
2504,
4470,
5705,
18285,
3271,
341,
286,
5635,
744,
9845,
2571,
291,
28346,
15866,
741,
310,
659,
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_dataspace_null() -> Result<()> {
let space = Dataspace::try_new(Extents::Null)?;
assert_eq!(space.ndim(), 0);
assert_eq!(space.shape(), vec![]);
assert_eq!(space.maxdims(), vec![]);
assert_eq!(space.size(), 0);
assert!(space.is_null());
assert_eq!(space.extents()?, Extents::Null);
Ok(())
} | rust_cleaned_test_functions.jsonl/101070 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 191
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
46530,
1306,
15162,
368,
1464,
5714,
71698,
341,
286,
1077,
3550,
284,
422,
19346,
1306,
486,
1539,
5921,
7,
6756,
805,
486,
3280,
40007,
286,
2060,
10714,
10297,
8746,
80939,
1507,
220,
15,
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... | 3 |
#[test]
fn test_deserialize_unknown_root_config() {
let value = toml::toml! {
unknown_key = "foo"
};
let deserializer = ValueDeserializer::new(&value);
let result = StarshipRootConfig::deserialize(deserializer).unwrap_err();
assert_eq!(
format!("{}", result),
"Error in 'StarshipRoot' at 'unknown_key': Unknown key"
);
} | rust_cleaned_test_functions.jsonl/67386 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 197
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15768,
9050,
57507,
12993,
5332,
368,
341,
286,
1077,
897,
284,
311,
1014,
486,
37401,
75,
0,
341,
310,
9788,
3097,
284,
330,
7975,
698,
286,
2605,
286,
1077,
939,
41939,
284,
5162,
80097,
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_feat_aggregation_without_group_by() -> Result<()> {
setup_test_logger();
let source_input = gen_source_input();
let test_source = ForeignSource::new().unwrap();
let test_sink = ForeignSink::start().unwrap();
let ddls = vec![
"
CREATE SOURCE STREAM source_trade (
ts TIMESTAMP NOT NULL ROWTIME,
ticker TEXT NOT NULL,
amount INTEGER NOT NULL
);
"
.to_string(),
"
CREATE SINK STREAM sink_avg_all (
avg_amount FLOAT NOT NULL
);
"
.to_string(),
"
CREATE PUMP avg_all AS
INSERT INTO sink_avg_all (avg_amount)
SELECT STREAM
AVG(source_trade.amount) AS avg_amount
FROM source_trade
FIXED WINDOW DURATION_SECS(10), DURATION_SECS(0);
"
.to_string(),
format!(
"
CREATE SINK WRITER tcp_sink_trade FOR sink_avg_all
TYPE NET_CLIENT OPTIONS (
PROTOCOL 'TCP',
REMOTE_HOST '{remote_host}',
REMOTE_PORT '{remote_port}'
);
",
remote_host = test_sink.host_ip(),
remote_port = test_sink.port()
),
format!(
"
CREATE SOURCE READER tcp_trade FOR source_trade
TYPE NET_CLIENT OPTIONS (
PROTOCOL 'TCP',
REMOTE_HOST '{remote_host}',
REMOTE_PORT '{remote_port}'
);
",
remote_host = test_source.host_ip(),
remote_port = test_source.port()
),
];
let sink_received = run_and_drain(
&ddls,
ForeignSourceInput::new_fifo_batch(source_input),
test_source,
&test_sink,
);
assert_eq!(sink_received.len(), 2);
assert_eq!(
sink_received[0]["avg_amount"].as_f64().unwrap().round() as i32,
20,
);
assert_eq!(
sink_received[1]["avg_amount"].as_f64().unwrap().round() as i32,
50,
);
Ok(())
} | rust_cleaned_test_functions.jsonl/117007 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1092
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
46753,
20587,
34442,
39904,
6288,
3710,
368,
1464,
5714,
71698,
341,
262,
6505,
4452,
27413,
1428,
262,
1077,
2530,
5898,
284,
4081,
10347,
5898,
1428,
262,
1077,
1273,
10347,
284,
19078,
3608,
486,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_is_descendant() {
let v1 = Value::from((1, 2, 3));
let v2 = Value::from((1, 2, v1.clone()));
let v3 = Value::from((1, 2, v2.clone()));
assert!(v3.is_descendant_value(&v2));
assert!(v3.is_descendant_value(&v1));
assert!(v3.is_descendant_value(&v3));
assert!(v2.is_descendant_value(&v1));
assert!(v2.is_descendant_value(&v2));
assert!(!v2.is_descendant_value(&v3));
assert!(v1.is_descendant_value(&v1));
assert!(!v1.is_descendant_value(&v2));
assert!(!v1.is_descendant_value(&v3));
} | rust_cleaned_test_functions.jsonl/62159 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 318
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6892,
10986,
20372,
368,
341,
286,
1077,
348,
16,
284,
5162,
486,
1499,
1188,
16,
11,
220,
17,
11,
220,
18,
1106,
286,
1077,
348,
17,
284,
5162,
486,
1499,
1188,
16,
11,
220,
17,
11,
348,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_inx_d_rollover() {
let mut state = State8080::empty_state();
state.memory = vec![0x13];
state.d = 0x38;
state.e = 0xff;
emulate_8080_op(&mut state);
assert_eq!(state.d, 0x39);
assert_eq!(state.e, 0x00);
} | rust_cleaned_test_functions.jsonl/7752 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 157
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1243,
87,
814,
62,
43684,
423,
368,
341,
286,
1077,
5206,
1584,
284,
3234,
23,
15,
23,
15,
486,
3194,
4387,
543,
286,
1584,
36611,
284,
7486,
20703,
15,
87,
16,
18,
935,
286,
1584,
950,
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_program_with_tests() {
let content = b"// Start of the program
// Another comment
/>> 1: [1 2]
/>> 2: [2 4]
/<< 1: [-1 -2]
Node #1
==========
IN:1 -> 1
---------
MOV <1, >1
---------
1 -> #2:2
=======
// End comment, to conclude
";
let res = program(content);
let nodes = vec![(
Node::new_node("1"),
vec![InputMapping {
from: Port::new(Node::In, 1.into()),
to: 1.into(),
}],
vec![OutputMapping {
from: 1.into(),
to: Port::named_port(&"2", 2.into()),
}],
vec![Operation::MOV(
ValuePointer::INPUT(1.into()),
ValuePointer::OUTPUT(1.into()),
)],
)];
let test_cases = Some(
TestCase::default()
.input_into(1.into(), vec![1, 2])
.input_into(2.into(), vec![2, 4])
.output_from(1.into(), vec![-1, -2]),
);
assert_full_result(res, (nodes, test_cases));
} | rust_cleaned_test_functions.jsonl/90803 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 610
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25096,
6615,
32509,
368,
341,
286,
1077,
2213,
284,
293,
1,
322,
5145,
315,
279,
2025,
198,
322,
13293,
3980,
198,
14,
2452,
220,
16,
25,
508,
16,
220,
17,
921,
14,
2452,
220,
17,
25,
508,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_total_ord() {
let c = &[1, 2, 3];
[1, 2, 3, 4][..].cmp(c) == Greater;
let c = &[1, 2, 3, 4];
[1, 2, 3][..].cmp(c) == Less;
let c = &[1, 2, 3, 6];
[1, 2, 3, 4][..].cmp(c) == Equal;
let c = &[1, 2, 3, 4, 5, 6];
[1, 2, 3, 4, 5, 5, 5, 5][..].cmp(c) == Less;
let c = &[1, 2, 3, 4];
[2, 2][..].cmp(c) == Greater;
} | rust_cleaned_test_functions.jsonl/111414 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 263
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10784,
67324,
368,
341,
286,
1077,
272,
284,
44590,
16,
11,
220,
17,
11,
220,
18,
935,
286,
508,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
1457,
496,
936,
7293,
1337,
8,
621,
32281,
280,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_scoped_coil() {
let (_s, cfg) = start_dummy_server_with_cfg();
let mut trans = Transport::new_with_cfg("127.0.0.1", cfg).unwrap();
{
let mut auto = ScopedCoil::new(&mut trans, 0, CoilDropFunction::On).unwrap();
assert_eq!(auto.mut_transport().read_coils(0, 1).unwrap(),
vec![Coil::Off]);
}
assert_eq!(trans.read_coils(0, 1).unwrap(), vec![Coil::On]);
{
let mut auto = ScopedCoil::new(&mut trans, 0, CoilDropFunction::Off).unwrap();
assert_eq!(auto.mut_transport().read_coils(0, 1).unwrap(),
vec![Coil::On]);
}
assert_eq!(trans.read_coils(0, 1).unwrap(), vec![Coil::Off]);
{
let mut auto = ScopedCoil::new(&mut trans, 0, CoilDropFunction::Toggle).unwrap();
assert_eq!(auto.mut_transport().read_coils(0, 1).unwrap(),
vec![Coil::Off]);
}
assert_eq!(trans.read_coils(0, 1).unwrap(), vec![Coil::On]);
{
let mut auto = ScopedCoil::new(&mut trans, 0, CoilDropFunction::Toggle).unwrap();
assert_eq!(auto.mut_transport().read_coils(0, 1).unwrap(),
vec![Coil::On]);
}
assert_eq!(trans.read_coils(0, 1).unwrap(), vec![Coil::Off]);
// coil address 1
{
let mut auto = ScopedCoil::new(&mut trans, 1, CoilDropFunction::Toggle).unwrap();
assert_eq!(auto.mut_transport().read_coils(1, 1).unwrap(),
vec![Coil::Off]);
}
assert_eq!(trans.read_coils(1, 1).unwrap(), vec![Coil::On]);
} | rust_cleaned_test_functions.jsonl/46845 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 887
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13171,
16367,
11393,
321,
368,
341,
286,
1077,
5453,
82,
11,
13286,
8,
284,
1191,
60321,
12015,
6615,
18343,
543,
286,
1077,
5206,
1356,
284,
16742,
486,
931,
6615,
18343,
445,
16,
17,
22,
13,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_split_check() {
let path = Builder::new().prefix("test-raftstore").tempdir().unwrap();
let path_str = path.path().to_str().unwrap();
let db_opts = DBOptions::new();
let cfs_opts = ALL_CFS
.iter()
.map(|cf| {
let mut cf_opts = ColumnFamilyOptions::new();
let f = Box::new(RangePropertiesCollectorFactory::default());
cf_opts.add_table_properties_collector_factory("tikv.size-collector", f);
CFOptions::new(cf, cf_opts)
})
.collect();
let engine = Arc::new(new_engine_opt(path_str, db_opts, cfs_opts).unwrap());
let mut region = Region::default();
region.set_id(1);
region.mut_peers().push(Peer::default());
region.mut_region_epoch().set_version(2);
region.mut_region_epoch().set_conf_ver(5);
let (tx, rx) = mpsc::sync_channel(100);
let mut cfg = Config::default();
cfg.region_max_size = ReadableSize(BUCKET_NUMBER_LIMIT as u64);
let mut runnable = SplitCheckRunner::new(
engine.c().clone(),
tx.clone(),
CoprocessorHost::new(tx),
cfg,
);
// so split key will be z0005
let cf_handle = engine.cf_handle(CF_DEFAULT).unwrap();
for i in 0..11 {
let k = format!("{:04}", i).into_bytes();
let k = keys::data_key(Key::from_raw(&k).as_encoded());
engine.put_cf(cf_handle, &k, &k).unwrap();
// Flush for every key so that we can know the exact middle key.
engine.flush_cf(cf_handle, true).unwrap();
}
runnable.run(SplitCheckTask::split_check(
region.clone(),
false,
CheckPolicy::Scan,
));
let split_key = Key::from_raw(b"0005");
must_split_at(&rx, ®ion, vec![split_key.clone().into_encoded()]);
runnable.run(SplitCheckTask::split_check(
region.clone(),
false,
CheckPolicy::Approximate,
));
must_split_at(&rx, ®ion, vec![split_key.into_encoded()]);
} | rust_cleaned_test_functions.jsonl/43994 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1094
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17052,
7200,
368,
341,
286,
1077,
1815,
284,
20626,
486,
931,
1005,
11849,
445,
1944,
12,
2944,
4314,
1827,
3888,
3741,
1005,
15454,
543,
286,
1077,
1815,
2895,
284,
1815,
3875,
1005,
983,
2895,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_expand_rule() {
// assert_err(
assert_err(
"($($i:ident);*) => ($i)",
"foo!{a}",
ExpandError::BindingError(String::from(
"expected simple binding, found nested binding `i`",
)),
);
assert_err("($i) => ($i)", "foo!{a}", ExpandError::UnexpectedToken);
assert_err("($i:) => ($i)", "foo!{a}", ExpandError::UnexpectedToken);
// FIXME:
} | rust_cleaned_test_functions.jsonl/28816 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 300
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
67875,
21124,
368,
341,
1789,
286,
442,
2060,
9266,
1006,
73363,
23459,
286,
2060,
9266,
1006,
310,
330,
699,
699,
72,
25,
1713,
1215,
3764,
589,
1711,
72,
15752,
310,
330,
7975,
0,
90,
64,
24... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_duplicate_toolchains() {
let db = Database::temp().unwrap();
let config = Config::default();
let ctx = ActionsCtx::new(&db, &config);
crate::crates::lists::setup_test_lists(&db, &config).unwrap();
// Ensure an experiment with duplicate toolchains can't be created
let err = CreateExperiment {
name: "foo".to_string(),
toolchains: [MAIN_TOOLCHAIN.clone(), MAIN_TOOLCHAIN.clone()],
mode: Mode::BuildAndTest,
crates: CrateSelect::Local,
cap_lints: CapLints::Forbid,
priority: 0,
github_issue: None,
ignore_blacklist: false,
assign: None,
requirement: None,
}
.apply(&ctx)
.unwrap_err();
assert_eq!(
err.downcast_ref(),
Some(&ExperimentError::DuplicateToolchains)
);
} | rust_cleaned_test_functions.jsonl/74501 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 454
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
70434,
22785,
58358,
368,
341,
286,
1077,
2927,
284,
9994,
486,
3888,
1005,
15454,
543,
286,
1077,
2193,
284,
5532,
486,
2258,
543,
286,
1077,
5635,
284,
26722,
23684,
486,
931,
2099,
1999,
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_read_libpostal_contained_overrides() {
let yaml = r#"---
admin_level:
"2": "country"
"4": "state"
"5": "state_district"
"6": "state_district"
"8": "city"
"9": "suburb"
overrides:
contained_by:
relation:
# Luxembourg City
"407489":
admin_level:
"9": "city_district""#;
let deserialized_levels = read_libpostal_yaml(&yaml).expect("invalid yaml");
assert_eq!(
deserialized_levels
.type_by_level
.get(&"2".to_string())
.unwrap(),
&ZoneType::Country
);
assert_eq!(
deserialized_levels
.overrides
.contained_by
.get(&"relation:407489".to_string())
.unwrap()
.type_by_level
.get(&"9".to_string())
.unwrap(),
&ZoneType::CityDistrict
);
} | rust_cleaned_test_functions.jsonl/72910 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 651
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
16142,
33170,
10260,
2627,
15431,
18245,
368,
341,
286,
1077,
32246,
284,
435,
55543,
10952,
262,
3986,
8274,
510,
286,
330,
17,
788,
330,
11141,
698,
286,
330,
19,
788,
330,
2454,
698,
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_many_n_m() {
init();
let p = elm_ref(b'a').of_many_n_m(1, 2).collect() + end();
let r = p.parse_as_result(b"");
assert!(r.is_err());
let (a, _) = p.parse_as_result(b"a").unwrap();
assert_eq!(a, vec![b'a']);
let (a, _) = p.parse_as_result(b"aa").unwrap();
assert_eq!(a, vec![b'a', b'a']);
let r = p.parse_as_result(b"aaa");
assert!(r.is_err());
} | rust_cleaned_test_functions.jsonl/16790 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 220
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
22101,
1089,
717,
368,
341,
262,
2930,
543,
262,
1077,
281,
284,
42205,
7793,
1883,
25184,
1823,
1055,
22101,
1089,
717,
7,
16,
11,
220,
17,
568,
17384,
368,
488,
835,
1428,
262,
1077,
435,
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_carol_escrows_to_bob_transfers_to_alice() {
// Acting as carol
testing_env!(get_context(carol()));
let total_supply = 1_000_000_000_000_000u128;
let mut contract = FunToken::new(carol(), total_supply.to_string()).unwrap();
assert_eq!(contract.get_total_supply(), total_supply.to_string());
let allowance = total_supply / 3;
let transfer_amount = allowance / 3;
contract.set_allowance(bob(), format!("{}", allowance)).unwrap();
assert_eq!(contract.get_allowance(carol(), bob()), format!("{}", allowance));
// Acting as bob now
testing_env!(get_context(bob()));
contract.transfer_from(carol(), alice(), transfer_amount.to_string()).unwrap();
assert_eq!(
contract.get_total_balance(carol()),
(total_supply - transfer_amount).to_string()
);
assert_eq!(contract.get_unlocked_balance(alice()), transfer_amount.to_string());
assert_eq!(
contract.get_allowance(carol(), bob()),
format!("{}", allowance - transfer_amount)
);
} | rust_cleaned_test_functions.jsonl/74525 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 507
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26616,
337,
92196,
1811,
2346,
880,
674,
7965,
49793,
2346,
8418,
558,
368,
341,
286,
442,
72689,
438,
1803,
337,
198,
286,
7497,
15879,
10297,
455,
8467,
42078,
337,
7392,
286,
1077,
2790,
65630,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_125() {
assert_eq!(Solution::is_palindrome(121), true);
assert_eq!(Solution::is_palindrome(-121), false);
assert_eq!(Solution::is_palindrome(10), false);
} | rust_cleaned_test_functions.jsonl/133302 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 97
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
16,
17,
20,
368,
341,
286,
2060,
10714,
10297,
36842,
486,
285,
73310,
36058,
7,
16,
17,
16,
701,
830,
317,
286,
2060,
10714,
10297,
36842,
486,
285,
73310,
36058,
4080,
16,
17,
16,
701,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_established_send() {
let mut s = socket_established();
// First roundtrip after establishing.
s.send_slice(b"abcdef").unwrap();
recv!(s, [TcpRepr {
seq_number: LOCAL_SEQ + 1,
ack_number: Some(REMOTE_SEQ + 1),
payload: &b"abcdef"[..],
..RECV_TEMPL
}]);
assert_eq!(s.tx_buffer.len(), 6);
send!(s, TcpRepr {
seq_number: REMOTE_SEQ + 1,
ack_number: Some(LOCAL_SEQ + 1 + 6),
..SEND_TEMPL
});
assert_eq!(s.tx_buffer.len(), 0);
// Second roundtrip.
s.send_slice(b"foobar").unwrap();
recv!(s, [TcpRepr {
seq_number: LOCAL_SEQ + 1 + 6,
ack_number: Some(REMOTE_SEQ + 1),
payload: &b"foobar"[..],
..RECV_TEMPL
}]);
send!(s, TcpRepr {
seq_number: REMOTE_SEQ + 1,
ack_number: Some(LOCAL_SEQ + 1 + 6 + 6),
..SEND_TEMPL
});
assert_eq!(s.tx_buffer.len(), 0);
} | rust_cleaned_test_functions.jsonl/1721 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 627
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18583,
5102,
291,
13565,
368,
341,
286,
1077,
5206,
274,
284,
7575,
18583,
5102,
291,
543,
286,
442,
5512,
4778,
32981,
1283,
30592,
624,
286,
274,
5219,
26488,
1883,
1,
41202,
1827,
15454,
543,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_inline_let_bind_literal_expr() {
check_assist(
inline_local_variable,
r"
fn bar(a: usize) {}
fn foo() {
let a$0 = 1;
a + 1;
if a > 10 {
}
while a > 10 {
}
let b = a * 10;
bar(a);
}",
r"
fn bar(a: usize) {}
fn foo() {
1 + 1;
if 1 > 10 {
}
while 1 > 10 {
}
let b = 1 * 10;
bar(1);
}",
);
} | rust_cleaned_test_functions.jsonl/3221 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 256
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
41871,
62,
1149,
27461,
34100,
21915,
368,
341,
286,
1779,
12083,
380,
1006,
310,
7381,
13564,
14635,
345,
310,
435,
698,
8822,
3619,
2877,
25,
22301,
8,
5613,
8822,
15229,
368,
341,
262,
1077,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_find_last() {
let inputs = vec![
("key1", 5),
("key3", 1),
("key5", 2),
("key7", 4),
("key9", 3),
];
let skl = construct_skl_from_nodes(inputs);
let last = skl.find_last();
unsafe {
assert_eq!((*last).key(), "key9".as_bytes());
}
} | rust_cleaned_test_functions.jsonl/15460 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 229
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21814,
12195,
368,
341,
286,
1077,
11127,
284,
7486,
90515,
310,
3489,
792,
16,
497,
220,
20,
1326,
310,
3489,
792,
18,
497,
220,
16,
1326,
310,
3489,
792,
20,
497,
220,
17,
1326,
310,
3489,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_dynamic_honey_badger_random_delivery_silent() {
let new_adversary = |_: usize, _: usize, _| SilentAdversary::new(MessageScheduler::Random);
test_dynamic_honey_badger_different_sizes(new_adversary, 10);
} | rust_cleaned_test_functions.jsonl/66065 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 100
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
45992,
1523,
2534,
34199,
1389,
22644,
50562,
643,
68414,
368,
341,
262,
1077,
501,
10027,
3004,
658,
284,
760,
23211,
22301,
11,
58536,
22301,
11,
85137,
59455,
2589,
3004,
658,
486,
931,
29359,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_char_table() {
for (i, &v) in URI_CHARS.iter().enumerate() {
if v != 0 {
assert_eq!(i, v as usize);
}
}
} | rust_cleaned_test_functions.jsonl/29063 | {
"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,
9232,
5237,
368,
341,
262,
369,
320,
72,
11,
609,
85,
8,
304,
16020,
82319,
19471,
1005,
76569,
368,
341,
286,
421,
348,
961,
220,
15,
341,
310,
2060,
10714,
10297,
72,
11,
348,
438,
22301,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_is_captured_generic() {
assert_eq!(
is_captured_generic("$__captured$reifiedgeneric$function$1"),
Some((true, 1))
);
assert_eq!(
is_captured_generic("$__captured$reifiedgeneric$class$1"),
Some((false, 1))
);
assert_eq!(is_captured_generic("function$1"), None);
assert_eq!(
is_captured_generic("$__captured$reifiedgeneric$function1"),
None
);
} | rust_cleaned_test_functions.jsonl/77581 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 319
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6892,
666,
80228,
41232,
368,
341,
310,
2060,
10714,
33673,
394,
374,
666,
80228,
41232,
20912,
563,
43203,
3073,
3,
265,
1870,
35787,
3,
1688,
3,
16,
4461,
394,
4329,
1188,
1866,
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... | 1 |
#[test]
fn test_bivar_poly_to_from_bytes_large_degree() {
let mut rng = rand::thread_rng();
let degree = 9; // TODO pick a less magic value here
let bi_poly = BivarPoly::random(degree, &mut rng);
let bi_poly_bytes = bi_poly.to_bytes();
let dp1 = degree + 1;
let sum = dp1 * (dp1 + 1) / 2;
let expected_size = sum * SK_SIZE;
assert_eq!(bi_poly_bytes.len(), expected_size);
} | rust_cleaned_test_functions.jsonl/49480 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 214
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
880,
56398,
36133,
2346,
5673,
12524,
45228,
49524,
368,
341,
286,
1077,
5206,
28422,
284,
10382,
486,
4528,
66849,
543,
286,
1077,
8381,
284,
220,
24,
26,
442,
5343,
3735,
264,
2686,
10963,
897,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_pdf() {
let f = |arg: f64| move |x: Gamma| x.pdf(arg);
let test = [
((1.0, 0.1), 1.0, 0.090483741803595961836995),
((1.0, 0.1), 10.0, 0.036787944117144234201693),
((1.0, 1.0), 1.0, 0.367879441171442321595523),
((1.0, 1.0), 10.0, 0.000045399929762484851535),
((10.0, 10.0), 1.0, 1.251100357211332989847649),
((10.0, 10.0), 10.0, 1.025153212086870580621609e-30),
((10.0, 1.0), 1.0, 0.000001013777119630297402),
((10.0, 1.0), 10.0, 0.125110035721133298984764),
];
for &(arg, x, res) in test.iter() {
test_case(arg, res, f(x));
}
//TODO: test special
//TODO: test special
} | rust_cleaned_test_functions.jsonl/39877 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 480
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39948,
368,
341,
286,
1077,
282,
284,
760,
858,
25,
282,
21,
19,
91,
3271,
760,
87,
25,
57682,
91,
856,
15995,
9404,
317,
286,
1077,
1273,
284,
2278,
310,
1781,
16,
13,
15,
11,
220,
15,
13... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_slice_out_of_range_positive() {
let arr = [10000, 256, 1000];
assert!(Color::try_from(&arr[..]).is_err());
} | rust_cleaned_test_functions.jsonl/11978 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 73
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26488,
6068,
3575,
9698,
54160,
368,
341,
286,
1077,
2890,
284,
508,
16,
15,
15,
15,
15,
11,
220,
17,
20,
21,
11,
220,
16,
15,
15,
15,
935,
286,
2060,
10297,
1636,
486,
1539,
5673,
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 |
#[test]
fn test_build_crds_filter() {
let mut rng = thread_rng();
let thread_pool = ThreadPoolBuilder::new().build().unwrap();
let crds_gossip_pull = CrdsGossipPull::default();
let mut crds = Crds::default();
let keypairs: Vec<_> = repeat_with(Keypair::new).take(10_000).collect();
let mut num_inserts = 0;
for _ in 0..40_000 {
let keypair = keypairs.choose(&mut rng).unwrap();
let value = CrdsValue::new_rand(&mut rng, Some(keypair));
if crds.insert(value, rng.gen()).is_ok() {
num_inserts += 1;
}
}
assert!(num_inserts > 30_000, "num inserts: {}", num_inserts);
let filters = crds_gossip_pull.build_crds_filters(&thread_pool, &crds, MAX_BLOOM_SIZE);
assert_eq!(filters.len(), MIN_NUM_BLOOM_FILTERS.max(32));
let purged: Vec<_> = thread_pool.install(|| crds.purged().collect());
let hash_values: Vec<_> = crds.values().map(|v| v.value_hash).chain(purged).collect();
assert_eq!(hash_values.len(), 40_000);
let mut false_positives = 0;
for hash_value in hash_values {
let mut num_hits = 0;
for filter in &filters {
if filter.test_mask(&hash_value) {
num_hits += 1;
assert!(filter.contains(&hash_value));
assert!(filter.filter.contains(&hash_value));
} else if filter.filter.contains(&hash_value) {
false_positives += 1;
}
}
assert_eq!(num_hits, 1);
}
assert!(false_positives < 150_000, "fp: {}", false_positives);
} | rust_cleaned_test_functions.jsonl/112071 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 869
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20801,
32331,
5356,
8727,
368,
341,
286,
1077,
5206,
28422,
284,
4516,
66849,
543,
286,
1077,
4516,
15709,
284,
72716,
3297,
486,
931,
1005,
5834,
1005,
15454,
543,
286,
1077,
1560,
5356,
1889,
41... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
#[test]
fn test_encrypt_decrypt_correctness() {
let ElGamalKeypair { public, secret } = ElGamalKeypair::new_rand();
let amount: u32 = 57;
let ciphertext = ElGamal::encrypt(&public, amount);
let expected_instance = DiscreteLog {
generator: *G,
target: Scalar::from(amount) * &(*G),
};
assert_eq!(expected_instance, ElGamal::decrypt(&secret, &ciphertext));
assert_eq!(
57_u32,
secret
.decrypt_u32_online(&ciphertext, &(*DECODE_U32_PRECOMPUTATION_FOR_G))
.unwrap()
);
} | rust_cleaned_test_functions.jsonl/36649 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 316
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
66593,
80764,
31550,
2090,
368,
341,
286,
1077,
3984,
78884,
278,
6608,
1082,
1310,
314,
584,
11,
6234,
335,
284,
3984,
78884,
278,
6608,
1082,
1310,
486,
931,
33864,
543,
286,
1077,
3311,
25,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_custom_markov() {
let mut boxed_markov = markov::Chain::new();
let name_generator: &mut dyn NameGenerator = &mut boxed_markov as &mut dyn NameGenerator;
name_generator.feed("aabdc".to_string());
let mut markov = markov::Chain::new();
markov.feed("aabdc".chars().collect::<Vec<char>>());
let name_size = 4;
let first_name = name_generator.generate(name_size);
let second_name: String = markov.generate().into_iter().take(name_size).collect();
assert_eq!(boxed_markov, markov);
assert_eq!(first_name.len(), second_name.len());
} | rust_cleaned_test_functions.jsonl/114713 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 283
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15875,
18924,
859,
368,
341,
286,
1077,
5206,
73664,
18924,
859,
284,
1868,
859,
486,
18837,
486,
931,
1428,
286,
1077,
829,
25813,
25,
609,
6984,
31070,
3988,
12561,
284,
609,
6984,
73664,
18924,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_peer_connected_successfully() {
let mut pdb = get_db();
let random_peer = PeerId::random();
let (n_in, n_out) = (10, 20);
for _ in 0..n_in {
pdb.connect_ingoing(&random_peer);
}
for _ in 0..n_out {
pdb.connect_outgoing(&random_peer);
}
// the peer is known
let peer_info = pdb.peer_info(&random_peer);
assert!(peer_info.is_some());
// this is the only peer
assert_eq!(pdb.peers().count(), 1);
// the peer has the default reputation
assert_eq!(pdb.reputation(&random_peer), DEFAULT_REPUTATION);
assert_eq!(pdb.n_dc, 0);
assert!(peer_info.unwrap().connection_status.is_connected());
assert_eq!(
peer_info.unwrap().connection_status.connections(),
(n_in, n_out)
);
} | rust_cleaned_test_functions.jsonl/55880 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 450
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
45159,
43276,
18632,
3641,
368,
341,
286,
1077,
5206,
47984,
284,
633,
8685,
543,
286,
1077,
4194,
45159,
284,
45147,
764,
486,
11463,
1428,
286,
1077,
320,
77,
1243,
11,
308,
6068,
8,
284,
320,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_new_device_success() {
let mut mock_nzxt_device_handle = setup_mocks();
// Mock the successful read of the device info.
mock_nzxt_device_handle
.expect_read_interrupt()
.returning(|_, _, _| Ok(READ_LENGTH as usize));
let mock_nzxt_device = NZXTDevice::new(&mut mock_nzxt_device_handle, 90);
assert!(mock_nzxt_device.is_ok());
} | rust_cleaned_test_functions.jsonl/78158 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 195
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5921,
9204,
18632,
368,
341,
286,
1077,
5206,
7860,
1089,
89,
2252,
9204,
10630,
284,
6505,
717,
25183,
1428,
286,
442,
14563,
279,
6849,
1349,
315,
279,
3671,
3546,
624,
286,
7860,
1089,
89,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_execute() {
let inputs: Vec<Instruction> = to_string_vector("test_inputs/day_8_part_1.txt")
.unwrap()
.into_iter()
.map(|s| Instruction::new(&s))
.collect();
let mut registers: HashMap<String, isize> = HashMap::new();
inputs[0].execute(&mut registers);
assert!(registers.is_empty());
inputs[1].execute(&mut registers);
assert_eq!(registers.get(&String::from("a")), Some(&1));
assert_eq!(registers.get(&String::from("b")), None);
assert_eq!(registers.get(&String::from("c")), None);
inputs[2].execute(&mut registers);
assert_eq!(registers.get(&String::from("a")), Some(&1));
assert_eq!(registers.get(&String::from("b")), None);
assert_eq!(registers.get(&String::from("c")), Some(&10));
inputs[3].execute(&mut registers);
assert_eq!(registers.get(&String::from("a")), Some(&1));
assert_eq!(registers.get(&String::from("b")), None);
assert_eq!(registers.get(&String::from("c")), Some(&-10));
} | rust_cleaned_test_functions.jsonl/89914 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 498
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
44329,
368,
341,
286,
1077,
11127,
25,
11312,
27,
16664,
29,
284,
311,
3904,
12247,
445,
1944,
28557,
44739,
62,
23,
10495,
62,
16,
3909,
1138,
310,
659,
15454,
741,
310,
659,
18122,
11723,
741,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_merge_from_program_without_runner() {
let mut some =
document(json!({ "program": { "binary": "bin/hello_world", "runner": "elf" } }));
// fxbug.dev/79951: merging with a document that doesn't have a runner doesn't override the
// runner that we already have assigned.
let mut other = document(json!({ "program": {} }));
some.merge_from(&mut other, &Path::new("some/path")).unwrap();
let expected =
document(json!({ "program": { "binary": "bin/hello_world", "runner": "elf" } }));
assert_eq!(some.program, expected.program);
} | rust_cleaned_test_functions.jsonl/34913 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 257
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20888,
5673,
25096,
39904,
54828,
368,
341,
286,
1077,
5206,
1045,
4035,
310,
2197,
9304,
0,
2306,
330,
14906,
788,
314,
330,
25891,
788,
330,
6863,
7530,
4791,
31792,
497,
330,
41736,
788,
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_arg_parser_flags() -> clap::Result<()> {
let app = parse_args();
let config = Configuration::from(app.get_matches_from_safe(vec!["test", "-r", "-c"])?);
assert_eq!(config.recursive, true);
assert_eq!(config.compact_output, true);
assert_eq!(config.paths.len(), 0);
assert_eq!(config.use_stdin, false);
Ok(())
} | rust_cleaned_test_functions.jsonl/89795 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 185
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6057,
18517,
14130,
368,
1464,
89577,
486,
2077,
71698,
341,
286,
1077,
906,
284,
4715,
8384,
543,
286,
1077,
2193,
284,
12221,
486,
1499,
11462,
670,
38344,
5673,
34067,
25592,
0,
1183,
1944,
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_install_help() {
let (_, mut ucmd) = at_and_ucmd!();
assert!(ucmd
.arg("--help")
.succeeds()
.no_stderr()
.stdout
.contains("Options:"));
} | rust_cleaned_test_functions.jsonl/124403 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 120
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34245,
26926,
368,
341,
262,
1077,
39464,
5206,
575,
8710,
8,
284,
518,
8378,
68887,
2277,
0,
1428,
262,
2060,
10297,
1754,
2277,
198,
286,
659,
858,
21549,
8653,
1138,
286,
659,
82,
29264,
82,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_undefined_fn() {
let stmt = Stmt::Expr(fn_call("f", vec![*literal(1f64)]));
assert_eq!(
interpret(stmt),
Err(CalcError::UndefinedFn(String::from("f")))
);
} | rust_cleaned_test_functions.jsonl/103403 | {
"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,
62,
9614,
15246,
368,
341,
286,
1077,
20020,
284,
97023,
486,
16041,
24008,
13429,
445,
69,
497,
7486,
20703,
9,
35785,
7,
16,
69,
21,
19,
7252,
3237,
286,
2060,
10714,
33673,
310,
14198,
47895,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_debug_raft_log() {
let (cluster, debug_client, store_id) = must_new_cluster_and_debug_client();
// Put some data.
let engine = cluster.get_raft_engine(store_id);
let (region_id, log_index) = (200, 200);
let key = keys::raft_log_key(region_id, log_index);
let mut entry = eraftpb::Entry::new();
entry.set_term(1);
entry.set_index(1);
entry.set_entry_type(eraftpb::EntryType::EntryNormal);
entry.set_data(vec![42]);
engine.put_msg(&key, &entry).unwrap();
assert_eq!(
engine.get_msg::<eraftpb::Entry>(&key).unwrap().unwrap(),
entry
);
// Debug raft_log
let mut req = debugpb::RaftLogRequest::new();
req.set_region_id(region_id);
req.set_log_index(log_index);
let resp = debug_client.raft_log(&req).unwrap();
assert_ne!(resp.get_entry(), &eraftpb::Entry::new());
let mut req = debugpb::RaftLogRequest::new();
req.set_region_id(region_id + 1);
req.set_log_index(region_id + 1);
match debug_client.raft_log(&req).unwrap_err() {
Error::RpcFailure(status) => {
assert_eq!(status.status, RpcStatusCode::NotFound);
}
_ => panic!("expect NotFound"),
}
} | rust_cleaned_test_functions.jsonl/8802 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 530
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15446,
62,
2944,
5224,
368,
341,
262,
1077,
320,
18855,
11,
7390,
8179,
11,
3553,
842,
8,
284,
1969,
5921,
28441,
8378,
15446,
8179,
1428,
262,
442,
10224,
1045,
821,
624,
262,
1077,
4712,
284,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_rotation_between_axis_vectors_vector2() {
let vector1: Unit<Vector2<f64>> = Unit::from_value(Vector2::unit_y());
let vector2: Unit<Vector2<f64>> = Unit::from_value(Vector2::unit_x());
let rotation = Rotation2::rotation_between_axis(&vector1, &vector2);
let vector = Vector2::unit_y();
let expected = Vector2::unit_x();
let result = rotation.rotate_vector(&vector);
assert!(relative_eq!(result, expected, epsilon = 1e-8));
} | rust_cleaned_test_functions.jsonl/70474 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 215
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
44813,
48302,
23567,
49158,
12247,
17,
368,
341,
286,
1077,
4621,
16,
25,
7954,
42195,
17,
63895,
21,
19,
2452,
284,
7954,
486,
1499,
3142,
20258,
17,
486,
3843,
4178,
1423,
286,
1077,
4621,
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_extension_successful_with_minimal_json_response() {
use self::colorful_extension::*;
let client = ColorfulClient::new(
ClientId::new("aaa".to_string()),
Some(ClientSecret::new("bbb".to_string())),
AuthUrl::new("https://example.com/auth".to_string()).unwrap(),
Some(TokenUrl::new("https://example.com/token".to_string()).unwrap()),
);
let token = client
.exchange_code(AuthorizationCode::new("ccc".to_string()))
.request(mock_http_client(
vec![
(ACCEPT, "application/json"),
(CONTENT_TYPE, "application/x-www-form-urlencoded"),
(AUTHORIZATION, "Basic YWFhOmJiYg=="),
],
"grant_type=authorization_code&code=ccc",
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\": \"green\", \"height\": 10}"
.to_string()
.into_bytes(),
},
))
.unwrap();
assert_eq!("12/34", token.access_token().secret());
assert_eq!(ColorfulTokenType::Green, *token.token_type());
assert_eq!(None, token.expires_in());
assert!(token.refresh_token().is_none());
assert_eq!(None, token.extra_fields().shape());
assert_eq!(10, token.extra_fields().height());
// Ensure that serialization produces an equivalent JSON value.
let serialized_json = serde_json::to_string(&token).unwrap();
assert_eq!(
"{\"access_token\":\"12/34\",\"token_type\":\"green\",\"height\":10}".to_string(),
serialized_json
);
let deserialized_token =
serde_json::from_str::<ColorfulTokenResponse>(&serialized_json).unwrap();
assert_token_eq(&token, &deserialized_token);
} | rust_cleaned_test_functions.jsonl/18609 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 975
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31035,
92951,
6615,
7260,
2861,
9455,
9655,
368,
341,
262,
990,
656,
486,
3423,
1262,
31035,
56162,
262,
1077,
2943,
284,
3478,
1262,
2959,
486,
931,
1006,
286,
8423,
764,
486,
931,
445,
32646,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_default_completions() {
let w = default_wordlist(2);
let c = w.get_completions("ar");
assert_eq!(c.len(), 2);
assert!(c.contains(&String::from("article-")));
assert!(c.contains(&String::from("armistice-")));
let c = w.get_completions("armis");
assert_eq!(c.len(), 1);
assert!(c.contains(&String::from("armistice-")));
let c = w.get_completions("armistice-");
assert_eq!(c.len(), 256);
let c = w.get_completions("armistice-ba");
assert_eq!(
c,
vec![
"armistice-baboon",
"armistice-backfield",
"armistice-backward",
"armistice-banjo",
]
);
let w = default_wordlist(3);
let c = w.get_completions("armistice-ba");
assert_eq!(
c,
vec![
"armistice-baboon-",
"armistice-backfield-",
"armistice-backward-",
"armistice-banjo-",
]
);
let w = default_wordlist(4);
let c = w.get_completions("armistice-baboon");
assert_eq!(c, vec!["armistice-baboon-"]);
} | rust_cleaned_test_functions.jsonl/132787 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 711
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9993,
2965,
10819,
908,
368,
341,
286,
1077,
289,
284,
1638,
13533,
1607,
7,
17,
317,
286,
1077,
272,
284,
289,
670,
2965,
10819,
908,
445,
277,
797,
286,
2060,
10714,
10297,
66,
19406,
1507,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_from_str() -> Result<(), ParseError> {
use alternate_bases::Allele;
use reference_bases::Base;
let s = "chr1\t13\tnd0\tATCG\tA\t5.8\tPASS\tSVTYPE=DEL";
let record: Record = s.parse()?;
assert!(matches!(record.chromosome(), Chromosome::Name(name) if name == "chr1"));
assert_eq!(record.position(), 13);
assert_eq!(**record.ids(), [String::from("nd0")]);
let reference_bases = [Base::A, Base::T, Base::C, Base::G];
assert_eq!(&record.reference_bases()[..], &reference_bases[..]);
let alternate_bases = [Allele::Bases(vec![Base::A])];
assert_eq!(&record.alternate_bases()[..], &alternate_bases[..]);
assert_eq!(*record.quality_score(), Some(5.8));
assert_eq!(record.filter_status(), &FilterStatus::Pass);
assert_eq!(record.info().len(), 1);
assert!(record.format().is_none());
assert!(record.genotypes().is_empty());
Ok(())
} | rust_cleaned_test_functions.jsonl/116553 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 461
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5673,
2895,
368,
1464,
5714,
68843,
14775,
1454,
29,
341,
286,
990,
24609,
96290,
486,
70451,
273,
280,
286,
990,
5785,
96290,
486,
3978,
401,
286,
1077,
274,
284,
330,
16789,
16,
4955,
16,
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... | 3 |
#[test]
fn test_builtin_functions() {
let tests = vec![
("len(\"\")", Object::Int(0)),
("len(\"four\")", Object::Int(4)),
("len(\"hello world\")", Object::Int(11)),
(
"len(1)",
Object::Error(String::from("argument to `len` not supported, got INTEGER")),
),
(
"len(\"one\", \"two\")",
Object::Error(String::from(
"wrong number of arguments: 1 expected but got 2",
)),
),
];
for (input, result) in tests {
assert_eq!(eval(input), result);
}
} | rust_cleaned_test_functions.jsonl/84237 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 313
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
73829,
31708,
368,
341,
262,
1077,
7032,
284,
7486,
90515,
286,
3489,
2892,
7,
22245,
899,
497,
3002,
486,
1072,
7,
15,
6965,
286,
3489,
2892,
36014,
34024,
62705,
497,
3002,
486,
1072,
7,
19,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_logging_duration_too_short() {
let mut runner = Runner::new();
// Attempt to start logging with an interval of 100ms but a duration of 50ms. The request
// should fail as the logging session would not produce any samples.
let mut query = runner.proxy.start_logging(
"test",
&mut vec![&mut Metric::CpuLoad(CpuLoad { interval_ms: 100 })].into_iter(),
50,
false,
false,
);
assert_matches!(
runner.executor.run_until_stalled(&mut query),
Poll::Ready(Ok(Err(fmetrics::MetricsLoggerError::InvalidSamplingInterval)))
);
// Check client node is not added in Inspect.
assert_data_tree!(
runner.inspector,
root: {
MetricsLogger: {}
}
);
} | rust_cleaned_test_functions.jsonl/66697 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 419
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
59982,
25454,
2346,
78,
16673,
368,
341,
286,
1077,
5206,
22259,
284,
44946,
486,
931,
1428,
286,
442,
43517,
311,
1191,
8392,
448,
458,
9873,
315,
220,
16,
15,
15,
1011,
714,
264,
8090,
315,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_criteria_scan_passes() {
let mut passing_criteria = ScanDir {
dir_files: &vec![PathBuf::from("package.json")],
files: &["package.json"],
extensions: &["js"],
folders: &["node_modules"],
};
assert_eq!(passing_criteria.scan(), true);
} | rust_cleaned_test_functions.jsonl/36955 | {
"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,
80990,
28857,
15464,
288,
368,
341,
286,
1077,
5206,
12299,
80990,
284,
31108,
6184,
341,
310,
5419,
10931,
25,
609,
4083,
20703,
1820,
15064,
486,
1499,
445,
1722,
4323,
899,
1259,
310,
3542,
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_safe_checkout_blob_to_tree_with_locally_modified_blob() -> BitResult<()> {
BitRepo::with_minimal_repo(|repo| {
modify!(repo: "foo");
let target = commit! {
foo {
bar < "bar contents"
}
};
bit_checkout!(repo: &rev!(target)).unwrap_err().try_into_checkout_conflict()?;
Ok(())
})
} | rust_cleaned_test_functions.jsonl/62972 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 211
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34067,
68186,
45908,
2346,
11663,
6615,
13400,
745,
37749,
45908,
368,
1464,
6495,
2077,
71698,
341,
262,
6495,
25243,
486,
4197,
7260,
2861,
37784,
22428,
23476,
91,
341,
286,
5602,
10297,
23476,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_start_client_connections_succeeds() {
let mut test_values = test_setup();
// Start client connections
let start_fut = test_values.iface_manager.start_client_connections();
pin_mut!(start_fut);
assert_variant!(test_values.exec.run_until_stalled(&mut start_fut), Poll::Pending);
// Verify that the service sees the request.
let next_message = test_values.receiver.next();
pin_mut!(next_message);
assert_variant!(
test_values.exec.run_until_stalled(&mut next_message),
Poll::Ready(Some(IfaceManagerRequest::StartClientConnections(StartClientConnectionsRequest{
responder
}))) => {
responder.send(Ok(())).expect("failed sending stop client connections response");
}
);
// Verify that the client side gets the response.
assert_variant!(test_values.exec.run_until_stalled(&mut start_fut), Poll::Ready(Ok(())));
} | rust_cleaned_test_functions.jsonl/59191 | {
"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,
4906,
8179,
56402,
643,
29264,
82,
368,
341,
286,
1077,
5206,
1273,
9146,
284,
1273,
21363,
1428,
286,
442,
5145,
2943,
13234,
198,
286,
1077,
1191,
761,
332,
284,
1273,
9146,
35431,
578,
12144,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_mem_reader() {
let mut reader = MemReader::new(vec!(0, 1, 2, 3, 4, 5, 6, 7));
let mut buf = [];
assert_eq!(reader.read(buf), Ok(0));
assert_eq!(reader.tell(), Ok(0));
let mut buf = [0];
assert_eq!(reader.read(buf), Ok(1));
assert_eq!(reader.tell(), Ok(1));
assert_eq!(buf.as_slice(), &[0]);
let mut buf = [0, ..4];
assert_eq!(reader.read(buf), Ok(4));
assert_eq!(reader.tell(), Ok(5));
assert_eq!(buf.as_slice(), &[1, 2, 3, 4]);
assert_eq!(reader.read(buf), Ok(3));
assert_eq!(buf.slice(0, 3), &[5, 6, 7]);
assert!(reader.read(buf).is_err());
let mut reader = MemReader::new(vec!(0, 1, 2, 3, 4, 5, 6, 7));
assert_eq!(reader.read_until(3).unwrap(), vec!(0, 1, 2, 3));
assert_eq!(reader.read_until(3).unwrap(), vec!(4, 5, 6, 7));
assert!(reader.read(buf).is_err());
} | rust_cleaned_test_functions.jsonl/31077 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 490
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12976,
22306,
368,
341,
286,
1077,
5206,
6604,
284,
13550,
5062,
486,
931,
25592,
10297,
15,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11,
220,
21,
11,
220,
22,
1106... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_cmp_reg_reg() {
assert_emit!(0x44, 0x39, 0xf8; emit_cmp_reg_reg(0, R15, RAX));
assert_emit!(0x41, 0x39, 0xdf; emit_cmp_reg_reg(0, RBX, R15));
assert_emit!(0x39, 0xd8; emit_cmp_reg_reg(0, RBX, RAX));
assert_emit!(0x4C, 0x39, 0xf8; emit_cmp_reg_reg(1, R15, RAX));
assert_emit!(0x49, 0x39, 0xdf; emit_cmp_reg_reg(1, RBX, R15));
assert_emit!(0x48, 0x39, 0xd8; emit_cmp_reg_reg(1, RBX, RAX));
} | rust_cleaned_test_functions.jsonl/85455 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 275
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
35193,
4920,
4920,
368,
341,
286,
2060,
69082,
10297,
15,
87,
19,
19,
11,
220,
15,
87,
18,
24,
11,
220,
15,
5848,
23,
26,
16691,
35193,
4920,
4920,
7,
15,
11,
431,
16,
20,
11,
431,
2954,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_pointer_with_pointer_ending_labels() {
let mut bytes: Vec<u8> = Vec::with_capacity(512);
let first = Name::from_str("ra.rb.rc").unwrap();
let second = Name::from_str("ra.rc").unwrap();
let third = Name::from_str("ra.rc").unwrap();
{
let mut e = BinEncoder::new(&mut bytes);
first.emit(&mut e).unwrap();
assert_eq!(e.len(), 10);
second.emit(&mut e).unwrap();
// +5 with the first +3 being the text form of "ra" and +2 for the pointer to "rc".
assert_eq!(e.len(), 15);
third.emit(&mut e).unwrap();
assert_eq!(e.len(), 17);
}
// now read them back
let mut d = BinDecoder::new(&bytes);
let r_test = Name::read(&mut d).unwrap();
assert_eq!(first, r_test);
let r_test = Name::read(&mut d).unwrap();
assert_eq!(second, r_test);
let r_test = Name::read(&mut d).unwrap();
assert_eq!(third, r_test);
} | rust_cleaned_test_functions.jsonl/38205 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 522
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21425,
6615,
21425,
62,
2459,
14547,
368,
341,
286,
1077,
5206,
5820,
25,
11312,
34837,
23,
29,
284,
11312,
486,
4197,
35603,
7,
20,
16,
17,
626,
286,
1077,
1156,
284,
3988,
486,
1499,
2895,
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_fmt() {
let mut f1 = FlagVec::from_str("-0-\t#__1 \n--\r+* +!").unwrap();
assert_eq!(f1.is_set(0), false);
assert_eq!(f1.is_set(1), false);
assert_eq!(f1.is_set(2), false);
assert_eq!(f1.is_set(3), true);
assert_eq!(f1.is_set(4), false);
assert_eq!(f1.is_set(5), false);
assert_eq!(f1.is_set(6), true);
assert_eq!(f1.is_set(7), false);
assert_eq!(f1.is_set(8), false);
assert_eq!(f1.is_set(9), true);
assert_eq!(f1.is_set(10), true);
assert_eq!(f1.is_set(11), true);
assert_eq!(f1.is_set(12), false);
assert_eq!(f1.capacity(), 16);
assert_eq!(format!("{}", f1), "---+--+--+++----");
assert_eq!(format!("{:#}", f1), "___#__#__###____");
assert_eq!(format!("{:?}", f1), "0001001001110000");
assert_eq!(format!("{:x}", f1), "480e");
assert_eq!(format!("{:X}", f1), "480E");
assert_eq!(format!("{:b}", f1), "0100100000001110");
assert_eq!(format!("{:o}", f1), "110016");
f1.enlarge(22);
assert_eq!(format!("{}", f1), "---+--+--+++------------");
assert_eq!(format!("{:#}", f1), "___#__#__###____");
assert_eq!(format!("{:?}", f1), "000100100111000000000000");
assert_eq!(format!("{:#?}", f1), "flags:0001001001110000");
assert_eq!(format!("{:#x}", f1), "0x480e");
assert_eq!(format!("{:#X}", f1), "0x480E");
assert_eq!(format!("{:#b}", f1), "0b0100100000001110");
assert_eq!(format!("{:#o}", f1), "0o110016");
} | rust_cleaned_test_functions.jsonl/24805 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 871
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
38128,
368,
341,
286,
1077,
5206,
282,
16,
284,
22666,
10050,
486,
1499,
2895,
13645,
15,
30529,
83,
44087,
16,
1124,
77,
313,
59,
81,
10,
9,
488,
0,
1827,
15454,
543,
286,
2060,
10714,
10297,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_invalid_chunk_from_bytes() {
let data_length: u32 = 42;
let chunk_type = "RuSt".as_bytes();
let message_bytes = "This is where your secret message will be!".as_bytes();
let crc: u32 = 2882656333;
let chunk_data: Vec<u8> = data_length
.to_be_bytes()
.iter()
.chain(chunk_type.iter())
.chain(message_bytes.iter())
.chain(crc.to_be_bytes().iter())
.copied()
.collect();
let chunk = Chunk::try_from(chunk_data.as_ref());
assert!(chunk.is_err());
} | rust_cleaned_test_functions.jsonl/95805 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 317
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31433,
30539,
5673,
12524,
368,
341,
286,
1077,
821,
5118,
25,
575,
18,
17,
284,
220,
19,
17,
280,
286,
1077,
11879,
1819,
284,
330,
98625,
623,
3263,
300,
12524,
543,
286,
1077,
1943,
12524,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_simple_with_whitespaces() {
assert_template_result!(r#" worked "#, r#" {{ test }} "#, v!({"test": "worked"}));
assert_template_result!(
r#" worked wonderfully "#,
r#" {{ test }} "#,
v!({"test": "worked wonderfully"}),
);
} | rust_cleaned_test_functions.jsonl/72877 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 134
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
30015,
6615,
36225,
3611,
27338,
368,
341,
262,
2060,
8693,
5287,
10297,
81,
55543,
220,
6439,
220,
5869,
11,
435,
55543,
220,
5867,
1273,
3869,
220,
5869,
11,
348,
0,
16864,
1944,
788,
330,
701... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_verify_config_missing_signatures_any_of() {
// build verification config:
let signatures_any_of: Vec<Signature> = vec![
generic_issuer("https://github.com/login/oauth", "user1@provider.com"),
generic_issuer("https://github.com/login/oauth", "user2@provider.com"),
generic_issuer("https://github.com/login/oauth", "user3@provider.com"),
];
let verification_config = LatestVerificationConfig {
all_of: None,
any_of: Some(AnyOf {
minimum_matches: 2,
signatures: signatures_any_of,
}),
};
// build trusted layers:
let trusted_layers: Vec<SignatureLayer> = vec![signature_layer(
"https://github.com/login/oauth",
"user1@provider.com",
)];
let error = verify_signatures_against_config(&verification_config, &trusted_layers);
assert!(error.is_err());
let expected_msg = r#"Image verification failed: minimum number of signatures not reached: needed 2, got 1
The following constraints were not satisfied:
---
kind: genericIssuer
issuer: "https://github.com/login/oauth"
subject:
equal: user2@provider.com
annotations: ~
---
kind: genericIssuer
issuer: "https://github.com/login/oauth"
subject:
equal: user3@provider.com
annotations: ~
"#;
assert_eq!(error.unwrap_err().to_string(), expected_msg);
} | rust_cleaned_test_functions.jsonl/68179 | {
"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,
35638,
5332,
40447,
11172,
2789,
37248,
3575,
368,
341,
286,
442,
1936,
22901,
2193,
510,
286,
1077,
32628,
37248,
3575,
25,
11312,
27,
25088,
29,
284,
7486,
90515,
310,
13954,
62,
66817,
445,
242... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_remove_factors() {
for n in 2..200 {
let factors = PrimeFactors::compute(n);
for i in 0..=factors.get_power_of_two() {
if let Some(removed_factors) = factors
.clone()
.remove_factors(PrimeFactor { value: 2, count: i })
{
assert_eq!(removed_factors.get_product(), factors.get_product() >> i);
assert_internally_consistent(&removed_factors);
} else {
assert!(n.is_power_of_two());
assert!(i == factors.get_power_of_two());
}
}
}
} | rust_cleaned_test_functions.jsonl/33861 | {
"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,
18193,
73040,
368,
341,
1789,
286,
369,
308,
304,
220,
17,
496,
17,
15,
15,
341,
310,
1077,
9363,
284,
12518,
97769,
486,
27706,
1445,
626,
310,
369,
600,
304,
220,
15,
496,
28,
69,
21161,
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... | 4 |
#[test]
fn test_parsing_empty_valued_set_statement() {
let statement = get_statement!("SET MY_KEY");
assert_eq!(
statement,
Statement {
stype: StatementType::Fail,
key: None,
value: None
}
);
} | rust_cleaned_test_functions.jsonl/104588 | {
"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,
620,
28598,
15124,
6189,
3260,
2602,
37404,
368,
341,
310,
1077,
5114,
284,
633,
37404,
17223,
5884,
18224,
6600,
797,
310,
2060,
10714,
33673,
394,
5114,
345,
394,
21756,
341,
503,
357,
499,
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 |
#[test]
fn test_pop() {
let mut data = String::from_str("ประเทศไทย中华b¢€𤭢");
assert_eq!(data.pop().unwrap(), '𤭢'); // 4 bytes
assert_eq!(dunwrap(), '€'); // 3 bytes
assert_eq!(datwrap(), '¢'); // 2 bytes
assert_eq!(datarap(), 'b'); // 1 bytes
assert_eq!(datarap(), '华');
assert_eq!(data, "ประเทศไทย中");
} | rust_cleaned_test_functions.jsonl/53 | {
"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,
17061,
368,
341,
286,
1077,
5206,
821,
284,
923,
486,
1499,
2895,
445,
130391,
100849,
65,
56394,
15056,
101877,
255,
95,
797,
286,
2060,
10714,
10297,
691,
8288,
1005,
15454,
1507,
364,
101877,
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_is_cluster_nodes() {
let combos = [
//nodes
(b"cluster", b"nodes" as &[u8]),
(b"CLUSTER", b"NODES" as &[u8]),
(b"cluster", b"NODES" as &[u8]),
(b"CLUSTER", b"nodes" as &[u8]),
// replicas
(b"cluster", b"replicas" as &[u8]),
(b"CLUSTER", b"REPLICAS" as &[u8]),
(b"cluster", b"replicas" as &[u8]),
(b"CLUSTER", b"replicas" as &[u8]),
];
for combo in combos {
let frame = Frame::Redis(RedisFrame::Array(vec![
RedisFrame::BulkString(Bytes::from_static(combo.0)),
RedisFrame::BulkString(Bytes::from_static(combo.1)),
]));
assert!(is_cluster_nodes(&frame));
}
let frame = Frame::Redis(RedisFrame::Array(vec![
RedisFrame::BulkString(Bytes::from_static(b"GET")),
RedisFrame::BulkString(Bytes::from_static(b"key1")),
]));
assert!(!is_cluster_nodes(&frame));
} | rust_cleaned_test_functions.jsonl/119985 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 598
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6892,
28441,
14896,
368,
341,
286,
1077,
70133,
284,
2278,
310,
442,
20008,
198,
310,
320,
65,
1,
18855,
497,
293,
1,
20008,
1,
438,
44590,
84,
23,
17036,
310,
320,
65,
1,
3140,
46009,
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_regeneration() {
let setting_type = SettingType::Unknown;
let mut executor =
fasync::TestExecutor::new_with_fake_time().expect("Failed to create executor");
async fn run_once(setting_type: SettingType) -> (oneshot::Receiver<()>, TestEnvironment) {
let (done_tx, done_rx) = oneshot::channel();
let environment =
TestEnvironmentBuilder::new(setting_type).set_done_tx(Some(done_tx)).build().await;
// Send initial request.
assert!(
get_response(
environment
.service_client
.message(
HandlerPayload::Request(Request::Get).into(),
Audience::Address(service::Address::Handler(setting_type)),
)
.send()
)
.await
.is_some(),
"response should have been received"
);
// Ensure the handler was only created once.
assert_eq!(1, environment.handler_factory.lock().await.get_request_count(setting_type));
// The subsequent teardown should happen here.
(done_rx, environment)
}
let environment_fut = run_once(setting_type);
futures::pin_mut!(environment_fut);
let (done_rx, mut environment) =
if let Poll::Ready(output) = executor.run_until_stalled(&mut environment_fut) {
output
} else {
panic!("initial call stalled");
};
executor.wake_next_timer();
futures::pin_mut!(done_rx);
matches::assert_matches!(executor.run_until_stalled(&mut done_rx), Poll::Ready(Ok(_)));
let mut hit_teardown = false;
loop {
let state_fut = environment.setting_handler_rx.next();
futures::pin_mut!(state_fut);
let state = if let Poll::Ready(state) = executor.run_until_stalled(&mut state_fut) {
state
} else {
panic!("getting next state stalled");
};
match state {
Some(State::Teardown) => {
hit_teardown = true;
break;
}
None => break,
_ => {}
}
}
assert!(hit_teardown, "Handler should have torn down");
async fn complete(mut environment: TestEnvironment, setting_type: SettingType) {
drop(environment.setting_handler);
// end will return none.
assert!(
environment.setting_handler_rx.next().await.is_none(),
"There should be no more states after teardown"
);
let (handler_messenger, handler_receptor) =
environment.handler_factory.lock().await.create(setting_type).await;
let (state_tx, _) = futures::channel::mpsc::unbounded::<State>();
let _handler = SettingHandler::create(
handler_messenger,
handler_receptor,
environment.proxy_handler_signature,
setting_type,
state_tx,
None,
);
// Send followup request.
assert!(
get_response(
environment
.service_client
.message(
HandlerPayload::Request(Request::Get).into(),
Audience::Address(service::Address::Handler(setting_type)),
)
.send()
)
.await
.is_some(),
"response should have been received"
);
// Check that the handler was re-generated.
assert_eq!(2, environment.handler_factory.lock().await.get_request_count(setting_type));
}
let complete_fut = complete(environment, setting_type);
futures::pin_mut!(complete_fut);
assert_eq!(executor.run_until_stalled(&mut complete_fut), Poll::Ready(()));
} | rust_cleaned_test_functions.jsonl/89526 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1844
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
74820,
368,
341,
262,
1077,
6243,
1819,
284,
20037,
929,
486,
13790,
401,
262,
1077,
5206,
31558,
4035,
286,
282,
7692,
486,
2271,
25255,
486,
931,
6615,
56881,
3009,
1005,
17119,
445,
9408,
311,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_options() {
let alignment = size2(8, 16);
let mut atlas = AtlasAllocator::with_options(
size2(2000, 1000),
&AllocatorOptions {
alignment,
vertical_shelves: true,
num_columns: 1,
},
);
assert!(atlas.is_empty());
assert_eq!(atlas.allocated_space(), 0);
let a1 = atlas.allocate(size2(20, 30)).unwrap();
let a2 = atlas.allocate(size2(30, 40)).unwrap();
let a3 = atlas.allocate(size2(20, 30)).unwrap();
assert!(a1.id != a2.id);
assert!(a1.id != a3.id);
assert!(!atlas.is_empty());
for id in &atlas {
assert!(id == a1 || id == a2 || id == a3);
}
assert_eq!(a1.rectangle.min.x % alignment.width, 0);
assert_eq!(a1.rectangle.min.y % alignment.height, 0);
assert_eq!(a2.rectangle.min.x % alignment.width, 0);
assert_eq!(a2.rectangle.min.y % alignment.height, 0);
assert_eq!(a3.rectangle.min.x % alignment.width, 0);
assert_eq!(a3.rectangle.min.y % alignment.height, 0);
assert!(a1.rectangle.size().width >= 20);
assert!(a1.rectangle.size().height >= 30);
assert!(a2.rectangle.size().width >= 30);
assert!(a2.rectangle.size().height >= 40);
assert!(a3.rectangle.size().width >= 20);
assert!(a3.rectangle.size().height >= 30);
atlas.deallocate(a1.id);
atlas.deallocate(a2.id);
atlas.deallocate(a3.id);
assert!(atlas.is_empty());
assert_eq!(atlas.allocated_space(), 0);
} | rust_cleaned_test_functions.jsonl/26803 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 694
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8743,
368,
341,
262,
1077,
17189,
284,
1379,
17,
7,
23,
11,
220,
16,
21,
626,
262,
1077,
5206,
60932,
284,
42343,
42730,
486,
4197,
8743,
1006,
286,
1379,
17,
7,
17,
15,
15,
15,
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... | 4 |
#[test]
fn test_gga_south_west() {
let mut nmea = Nmea::new();
nmea.parse("$GPGGA,092750.000,5321.6802,S,00630.3372,W,1,8,1.03,61.7,M,55.2,M,,*6B")
.unwrap();
assert_eq!(nmea.latitude().unwrap(), -(53. + 21.6802 / 60.));
assert_eq!(nmea.longitude().unwrap(), -(6. + 30.3372 / 60.));
} | rust_cleaned_test_functions.jsonl/65853 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 200
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1889,
6743,
643,
2898,
1670,
477,
368,
341,
286,
1077,
5206,
308,
2660,
64,
284,
451,
2660,
64,
486,
931,
543,
286,
308,
2660,
64,
4632,
20912,
38,
11383,
16128,
11,
15,
24,
17,
22,
20,
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_stdin_show_all() {
for same_param in vec!["-A", "--show-all"] {
new_ucmd!()
.args(&[same_param])
.pipe_in("\t\0\n")
.succeeds()
.stdout_only("^I^@$\n");
}
} | rust_cleaned_test_functions.jsonl/90935 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 153
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15656,
258,
15267,
5705,
368,
341,
262,
369,
1852,
4090,
304,
7486,
0,
1183,
12,
32,
497,
14482,
3445,
22346,
1341,
341,
286,
501,
68887,
2277,
0,
741,
310,
659,
2116,
2099,
58,
24063,
4090,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_valid_url_scheme() {
expect_ok!(UrlScheme, "fuch.sia-pkg+0");
expect_ok!(UrlScheme, &format!("{}", repeat("f").take(100).collect::<String>()));
} | rust_cleaned_test_functions.jsonl/98671 | {
"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,
8337,
2903,
53293,
368,
341,
286,
1720,
19817,
10297,
2864,
28906,
11,
330,
69,
1387,
514,
685,
2268,
7351,
10,
15,
797,
286,
1720,
19817,
10297,
2864,
28906,
11,
609,
2243,
79878,
13153,
445,
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 |
#[test]
fn test_bad() {
use crate::types::policy::PolicyError;
use crate::Pos;
fn check(fname: &str, e: &Error) {
let content = read_bad(fname);
let res = Microdesc::parse(&content);
assert!(res.is_err());
assert_eq!(&res.err().unwrap(), e);
}
check(
"wrong-start",
&EK::WrongStartingToken
.with_msg("family")
.at_pos(Pos::from_line(1, 1)),
);
check(
"bogus-policy",
&EK::BadPolicy
.at_pos(Pos::from_line(9, 1))
.with_source(PolicyError::InvalidPort),
);
} | rust_cleaned_test_functions.jsonl/73582 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 400
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34199,
368,
341,
286,
990,
17717,
486,
9242,
486,
34790,
486,
13825,
1454,
280,
286,
990,
17717,
486,
4859,
280,
286,
5168,
1779,
32326,
25,
609,
495,
11,
384,
25,
609,
1454,
8,
341,
310,
1077... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_filenames_with_spaces() {
let config = integration_test_utils::make_config_from_args(&[]);
let output =
integration_test_utils::run_delta(GIT_DIFF_NO_INDEX_FILENAMES_WITH_SPACES, &config);
let output = strip_ansi_codes(&output);
assert!(output.contains("a b ⟶ c d\n"));
} | rust_cleaned_test_functions.jsonl/70117 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 164
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
80632,
6615,
67883,
368,
341,
286,
1077,
2193,
284,
17590,
4452,
17309,
486,
6927,
5332,
5673,
8384,
2099,
56703,
286,
1077,
2550,
4035,
310,
17590,
4452,
17309,
486,
6108,
26710,
6699,
952,
53984,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_lin_reg_const() {
for i in 2..255 {
let input = (i as ValueType + 56.0) / 16.3251;
let mut method = TestingMethod::new(i, input).unwrap();
let output = method.next(input);
test_const_float(&mut method, input, output);
}
} | rust_cleaned_test_functions.jsonl/69752 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 111
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
24606,
4920,
13610,
368,
341,
197,
2023,
600,
304,
220,
17,
496,
17,
20,
20,
341,
298,
10217,
1946,
284,
320,
72,
438,
55545,
488,
220,
20,
21,
13,
15,
8,
608,
220,
16,
21,
13,
18,
17,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_config() {
let output = "{\"config\": \"some config data here\"}";
let o: Result<Config, serde_json::error::Error> = serde_json::from_str(output);
assert!(o.is_ok());
} | rust_cleaned_test_functions.jsonl/56070 | {
"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,
5332,
368,
341,
286,
1077,
2550,
284,
54734,
1676,
11693,
7245,
14689,
2193,
821,
1588,
2105,
26259,
286,
1077,
297,
25,
5714,
27,
2648,
11,
61570,
9455,
486,
841,
486,
1454,
29,
284,
61570,
945... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_rpc_get_max_slots() {
test_basic_slot("getMaxRetransmitSlot", 42);
test_basic_slot("getMaxShredInsertSlot", 43);
} | rust_cleaned_test_functions.jsonl/3048 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 76
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
60799,
3062,
6345,
54161,
368,
341,
286,
1273,
34729,
27563,
445,
455,
5974,
12020,
33389,
1763,
19877,
497,
220,
19,
17,
317,
286,
1273,
34729,
27563,
445,
455,
5974,
2016,
1151,
13780,
19877,
49... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_0013() {
assert_eq!(Solution::roman_to_int("III".to_string()), 3);
assert_eq!(Solution::roman_to_int("IV".to_string()), 4);
assert_eq!(Solution::roman_to_int("IX".to_string()), 9);
assert_eq!(Solution::roman_to_int("MCMXCIV".to_string()), 1994);
assert_eq!(Solution::roman_to_int("DCXXI".to_string()), 621);
} | rust_cleaned_test_functions.jsonl/120499 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 179
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
15,
15,
16,
18,
368,
341,
286,
2060,
10714,
10297,
36842,
486,
62014,
2346,
4042,
445,
22615,
3263,
983,
3904,
11858,
220,
18,
317,
286,
2060,
10714,
10297,
36842,
486,
62014,
2346,
4042,
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... | 1 |
#[test]
fn test_nested_list_json_arrays() {
let c_field = Field::new(
"c",
DataType::Struct(vec![Field::new("d", DataType::Utf8, true)]),
true,
);
let a_struct_field = Field::new(
"a",
DataType::Struct(vec![
Field::new("b", DataType::Boolean, true),
c_field.clone(),
]),
true,
);
let a_field =
Field::new("a", DataType::List(Box::new(a_struct_field.clone())), true);
let schema = Arc::new(Schema::new(vec![a_field.clone()]));
let builder = ReaderBuilder::new().with_schema(schema).with_batch_size(64);
let json_content = r#"
{"a": [{"b": true, "c": {"d": "a_text"}}, {"b": false, "c": {"d": "b_text"}}]}
{"a": [{"b": false, "c": null}]}
{"a": [{"b": true, "c": {"d": "c_text"}}, {"b": null, "c": {"d": "d_text"}}, {"b": true, "c": {"d": null}}]}
{"a": null}
{"a": []}
{"a": [null]}
"#;
let mut reader = builder.build(Cursor::new(json_content)).unwrap();
// build expected output
let d = StringArray::from(vec![
Some("a_text"),
Some("b_text"),
None,
Some("c_text"),
Some("d_text"),
None,
None,
]);
let c = ArrayDataBuilder::new(c_field.data_type().clone())
.len(7)
.add_child_data(d.data().clone())
.null_bit_buffer(Buffer::from(vec![0b00111011]))
.build()
.unwrap();
let b = BooleanArray::from(vec![
Some(true),
Some(false),
Some(false),
Some(true),
None,
Some(true),
None,
]);
let a = ArrayDataBuilder::new(a_struct_field.data_type().clone())
.len(7)
.add_child_data(b.data().clone())
.add_child_data(c.clone())
.null_bit_buffer(Buffer::from(vec![0b00111111]))
.build()
.unwrap();
let a_list = ArrayDataBuilder::new(a_field.data_type().clone())
.len(6)
.add_buffer(Buffer::from_slice_ref(&[0i32, 2, 3, 6, 6, 6, 7]))
.add_child_data(a)
.null_bit_buffer(Buffer::from(vec![0b00110111]))
.build()
.unwrap();
let expected = make_array(a_list);
// compare `a` with result from json reader
let batch = reader.next().unwrap().unwrap();
let read = batch.column(0);
assert_eq!(read.len(), 6);
let read: &ListArray = read.as_any().downcast_ref::<ListArray>().unwrap();
let expected = expected.as_any().downcast_ref::<ListArray>().unwrap();
assert_eq!(
read.data().buffers()[0],
Buffer::from_slice_ref(&[0i32, 2, 3, 6, 6, 6, 7])
);
// compare list null buffers
assert_eq!(read.data().null_buffer(), expected.data().null_buffer());
// build struct from list
let struct_values = read.values();
let struct_array: &StructArray = struct_values
.as_any()
.downcast_ref::<StructArray>()
.unwrap();
let expected_struct_values = expected.values();
let expected_struct_array = expected_struct_values
.as_any()
.downcast_ref::<StructArray>()
.unwrap();
assert_eq!(7, struct_array.len());
assert_eq!(1, struct_array.null_count());
assert_eq!(7, expected_struct_array.len());
assert_eq!(1, expected_struct_array.null_count());
// test struct's nulls
assert_eq!(
struct_array.data().null_buffer(),
expected_struct_array.data().null_buffer()
);
// test struct's fields
let read_b = struct_array.column(0);
assert_eq!(b.data_ref(), read_b.data_ref());
let read_c = struct_array.column(1);
assert_eq!(&c, read_c.data_ref());
let read_c: &StructArray = read_c.as_any().downcast_ref::<StructArray>().unwrap();
let read_d = read_c.column(0);
assert_eq!(d.data_ref(), read_d.data_ref());
assert_eq!(read.data_ref(), expected.data_ref());
} | rust_cleaned_test_functions.jsonl/22596 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2242
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
66279,
2019,
9455,
68983,
368,
341,
286,
1077,
272,
5013,
284,
8601,
486,
931,
1006,
310,
330,
66,
756,
310,
33172,
486,
9422,
25592,
20703,
1877,
486,
931,
445,
67,
497,
33172,
486,
38980,
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_rtc_read_write_and_event() {
let intr_evt = EventFd::new(libc::EFD_NONBLOCK).unwrap();
let mut rtc = Rtc::new(Arc::new(Box::new(TestInterrupt::new(
intr_evt.try_clone().unwrap(),
))));
let mut data = [0; 4];
// Read and write to the MR register.
write_le_u32(&mut data, 123);
rtc.write(LEGACY_RTC_MAPPED_IO_START, RTCMR, &mut data);
rtc.read(LEGACY_RTC_MAPPED_IO_START, RTCMR, &mut data);
let v = read_le_u32(&data);
assert_eq!(v, 123);
// Read and write to the LR register.
let v = get_time(ClockType::Real);
write_le_u32(&mut data, (v / NANOS_PER_SECOND) as u32);
let previous_now_before = rtc.previous_now;
rtc.write(LEGACY_RTC_MAPPED_IO_START, RTCLR, &mut data);
assert!(rtc.previous_now > previous_now_before);
rtc.read(LEGACY_RTC_MAPPED_IO_START, RTCLR, &mut data);
let v_read = read_le_u32(&data);
assert_eq!((v / NANOS_PER_SECOND) as u32, v_read);
// Read and write to IMSC register.
// Test with non zero value.
let non_zero = 1;
write_le_u32(&mut data, non_zero);
rtc.write(LEGACY_RTC_MAPPED_IO_START, RTCIMSC, &mut data);
// The interrupt line should be on.
assert!(rtc.interrupt.notifier(0).unwrap().read().unwrap() == 1);
rtc.read(LEGACY_RTC_MAPPED_IO_START, RTCIMSC, &mut data);
let v = read_le_u32(&data);
assert_eq!(non_zero & 1, v);
// Now test with 0.
write_le_u32(&mut data, 0);
rtc.write(LEGACY_RTC_MAPPED_IO_START, RTCIMSC, &mut data);
rtc.read(LEGACY_RTC_MAPPED_IO_START, RTCIMSC, &mut data);
let v = read_le_u32(&data);
assert_eq!(0, v);
// Read and write to the ICR register.
write_le_u32(&mut data, 1);
rtc.write(LEGACY_RTC_MAPPED_IO_START, RTCICR, &mut data);
// The interrupt line should be on.
assert!(rtc.interrupt.notifier(0).unwrap().read().unwrap() > 1);
let v_before = read_le_u32(&data);
rtc.read(LEGACY_RTC_MAPPED_IO_START, RTCICR, &mut data);
let v = read_le_u32(&data);
assert_eq!(v, v_before);
// Attempts to turn off the RTC should not go through.
write_le_u32(&mut data, 0);
rtc.write(LEGACY_RTC_MAPPED_IO_START, RTCCR, &mut data);
rtc.read(LEGACY_RTC_MAPPED_IO_START, RTCCR, &mut data);
let v = read_le_u32(&data);
assert_eq!(v, 1);
// Attempts to write beyond the writable space. Using here the space used to read
// the CID and PID from.
write_le_u32(&mut data, 0);
rtc.write(LEGACY_RTC_MAPPED_IO_START, AMBA_ID_LOW, &mut data);
let mut data = [0; 4];
rtc.read(LEGACY_RTC_MAPPED_IO_START, AMBA_ID_LOW, &mut data);
let index = AMBA_ID_LOW + 3;
assert_eq!(data[0], PL031_ID[((index - AMBA_ID_LOW) >> 2) as usize]);
} | rust_cleaned_test_functions.jsonl/130818 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1543
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1710,
10413,
6443,
9165,
8378,
6748,
368,
341,
286,
1077,
10582,
60019,
284,
3665,
74476,
486,
931,
44828,
66,
486,
36,
14596,
22128,
39964,
568,
15454,
1428,
286,
1077,
5206,
71842,
284,
431,
104... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_deserialize_envelope_empty_item_newline() {
// With terminating newline after item payload
let bytes = Bytes::from(
"\
{\"event_id\":\"9ec79c33ec9942ab8353589fcb2e04dc\",\"dsn\":\"https://e12d836b15bb49d7bbf99e64295d995b:@sentry.io/42\"}\n\
{\"type\":\"attachment\",\"length\":0}\n\
\n\
{\"type\":\"attachment\",\"length\":0}\n\
",
);
let envelope = Envelope::parse_bytes(bytes).unwrap();
assert_eq!(envelope.len(), 2);
let items: Vec<_> = envelope.items().collect();
assert_eq!(items[0].len(), 0);
assert_eq!(items[1].len(), 0);
} | rust_cleaned_test_functions.jsonl/103611 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 362
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15768,
9050,
6205,
18853,
15124,
5634,
5921,
1056,
368,
341,
286,
442,
3085,
70581,
39027,
1283,
1509,
7729,
198,
286,
1077,
5820,
284,
30024,
486,
1499,
1006,
310,
93317,
1797,
314,
2105,
3087,
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_native_libs_tracking_hash_different_order() {
let mut v1 = Options::default();
let mut v2 = Options::default();
let mut v3 = Options::default();
// Reference
v1.libs = vec![
(String::from("a"), None, Some(cstore::NativeStatic)),
(String::from("b"), None, Some(cstore::NativeFramework)),
(String::from("c"), None, Some(cstore::NativeUnknown)),
];
v2.libs = vec![
(String::from("b"), None, Some(cstore::NativeFramework)),
(String::from("a"), None, Some(cstore::NativeStatic)),
(String::from("c"), None, Some(cstore::NativeUnknown)),
];
v3.libs = vec![
(String::from("c"), None, Some(cstore::NativeUnknown)),
(String::from("a"), None, Some(cstore::NativeStatic)),
(String::from("b"), None, Some(cstore::NativeFramework)),
];
assert!(v1.dep_tracking_hash() == v2.dep_tracking_hash());
assert!(v1.dep_tracking_hash() == v3.dep_tracking_hash());
assert!(v2.dep_tracking_hash() == v3.dep_tracking_hash());
// Check clone
assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
} | rust_cleaned_test_functions.jsonl/31997 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 529
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
44494,
16142,
82,
66105,
8950,
82741,
7869,
368,
341,
262,
1077,
5206,
348,
16,
284,
14566,
486,
2258,
543,
262,
1077,
5206,
348,
17,
284,
14566,
486,
2258,
543,
262,
1077,
5206,
348,
18,
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_transparent_tuple_error_message() {
Python::with_gil(|py| {
let tup: PyObject = 1.into_py(py);
let tup = TransparentTuple::extract(tup.as_ref(py));
assert!(tup.is_err());
assert_eq!(
extract_traceback(py, tup.unwrap_err()),
"TypeError: failed to extract inner field of TransparentTuple: 'int' object \
cannot be converted to 'PyString'",
);
});
} | rust_cleaned_test_functions.jsonl/59476 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 216
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7965,
3765,
21773,
4096,
6462,
368,
341,
262,
13027,
486,
4197,
1889,
321,
22428,
3288,
91,
341,
286,
1077,
57385,
25,
15891,
284,
220,
16,
39860,
40291,
46827,
317,
286,
1077,
57385,
284,
89868,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_check_ts_conflict_rc_check_ts() {
let k1 = Key::from_raw(b"k1");
let mut lock = Lock::new(
LockType::Put,
vec![],
100.into(),
3,
None,
100.into(),
1,
TimeStamp::zero(),
);
let empty = Default::default();
// Ignore locks that occurs in the `bypass_locks` set.
Lock::check_ts_conflict_rc_check_ts(
Cow::Borrowed(&lock),
&k1,
50.into(),
&TsSet::from_u64s(vec![100]),
)
.unwrap();
// Ignore locks if the lock type are Pessimistic or Lock.
lock.lock_type = LockType::Pessimistic;
Lock::check_ts_conflict_rc_check_ts(Cow::Borrowed(&lock), &k1, 50.into(), &empty).unwrap();
lock.lock_type = LockType::Lock;
Lock::check_ts_conflict_rc_check_ts(Cow::Borrowed(&lock), &k1, 50.into(), &empty).unwrap();
// Report error even if read ts is less than the lock version.
lock.lock_type = LockType::Put;
Lock::check_ts_conflict_rc_check_ts(Cow::Borrowed(&lock), &k1, 50.into(), &empty)
.unwrap_err();
Lock::check_ts_conflict_rc_check_ts(Cow::Borrowed(&lock), &k1, 110.into(), &empty)
.unwrap_err();
// Report error if for other lock types.
lock.lock_type = LockType::Delete;
Lock::check_ts_conflict_rc_check_ts(Cow::Borrowed(&lock), &k1, 50.into(), &empty)
.unwrap_err();
} | rust_cleaned_test_functions.jsonl/71662 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 776
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7200,
25023,
16059,
21242,
30299,
7200,
25023,
368,
341,
286,
1077,
595,
16,
284,
5309,
486,
1499,
16067,
1883,
62911,
16,
797,
286,
1077,
5206,
5296,
284,
15701,
486,
931,
1006,
310,
15701,
929,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_valid_to_tpml_digest_conversion() {
let pcr_selection_list_1 = PcrSelectionListBuilder::new()
.with_selection(
HashingAlgorithm::Sha256,
&[
PcrSlot::Slot0,
PcrSlot::Slot1,
PcrSlot::Slot2,
PcrSlot::Slot3,
PcrSlot::Slot4,
PcrSlot::Slot5,
PcrSlot::Slot6,
PcrSlot::Slot7,
],
)
.build()
.expect("Failed to create PcrSelectionList 1");
let mut pcr_digest_list_1 = DigestList::new();
for i in 0u8..8u8 {
let value: [u8; 1] = [i];
pcr_digest_list_1
.add(Digest::try_from(&value[..]).expect("Failed to create digest value"))
.expect("Failed to add value to digest");
}
let pcr_selection_list_2 = PcrSelectionListBuilder::new()
.with_selection(
HashingAlgorithm::Sha256,
&[
PcrSlot::Slot8,
PcrSlot::Slot9,
PcrSlot::Slot10,
PcrSlot::Slot11,
PcrSlot::Slot12,
PcrSlot::Slot13,
PcrSlot::Slot14,
PcrSlot::Slot15,
],
)
.build()
.expect("Failed to create PcrSelectionList 2");
let mut pcr_digest_list_2 = DigestList::new();
for i in 8u8..16u8 {
let value: [u8; 1] = [i];
pcr_digest_list_2
.add(Digest::try_from(&value[..]).expect("Failed to create digest value"))
.expect("Failed to add value to digest");
}
let mut pcr_data = PcrData::new();
pcr_data
.add(&pcr_selection_list_1, &pcr_digest_list_1)
.expect("Failed to add selection and digests nr1");
pcr_data
.add(&pcr_selection_list_2, &pcr_digest_list_2)
.expect("Failed to add selection and digests nr2");
let tpml_digests: Vec<TPML_DIGEST> = pcr_data.into();
assert_eq!(
tpml_digests.len(),
2,
"PcrData did not convert into 2 TPML_DIGEST items as expected"
);
for (tpml_digest, count) in tpml_digests.iter().zip(0u8..2u8) {
assert_eq!(
tpml_digest.count as usize,
DigestList::MAX_SIZE,
"The converted digest list did not contain expected number of elements"
);
for (tpm2b_digest, value) in tpml_digest.digests.iter().zip(8 * count..8 * (count + 1)) {
assert_eq!(
tpm2b_digest.size, 1,
"The converted digest did not contain expected number of bytes"
);
assert_eq!(
tpm2b_digest.buffer[0], value,
"The converted digest did not contain expected values"
);
}
}
} | rust_cleaned_test_functions.jsonl/16365 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1528
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8337,
2346,
55191,
1014,
52994,
64132,
368,
341,
262,
1077,
281,
5082,
23672,
2019,
62,
16,
284,
393,
5082,
11177,
852,
3297,
486,
931,
741,
286,
659,
4197,
23672,
1006,
310,
6531,
287,
27847,
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... | 5 |
#[test]
fn test_parse_body() {
let body = "0.01 0.02 0.03 2/38 23618";
assert_eq!(
LoadClient::parse_body(body.to_string()),
LoadInfo {
load_1m: 0.01f32,
load_5m: 0.02f32,
load_15m: 0.03f32,
total_procs: 38u32,
}
)
} | rust_cleaned_test_functions.jsonl/93882 | {
"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,
21039,
14114,
368,
341,
286,
1077,
2487,
284,
330,
15,
13,
15,
16,
220,
15,
13,
15,
17,
220,
15,
13,
15,
18,
220,
17,
14,
18,
23,
220,
17,
18,
21,
16,
23,
876,
286,
2060,
10714,
33673,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_asteroids_from_str() {
let input = "
.#..#
.....
#####
....#
...##
";
let expected = vec_to_set(vec![
(1, 0), (4, 0),
(0, 2), (1, 2), (2, 2), (3, 2), (4, 2),
(4, 3),
(3, 4), (4, 4)
]);
assert_eq!(asteroids_from_str(input), expected);
} | rust_cleaned_test_functions.jsonl/46221 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 155
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
2300,
16960,
5673,
2895,
368,
341,
10217,
1946,
284,
6228,
197,
197,
43326,
496,
4956,
197,
197,
1934,
624,
197,
197,
77344,
197,
197,
1934,
4956,
197,
197,
1112,
22614,
197,
876,
10217,
360... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_subv_assign() {
let mut a = [1.2, 1.3, 1.4];
let b = [1.3, 1.5, 2.4];
a.subv_assign(&b);
let a_expected: [f64; 3] = [-0.1, -0.2, -1.0];
for i in 0..a.len() {
assert_approx_eq!(a[i], a_expected[i]);
}
} | rust_cleaned_test_functions.jsonl/66748 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 185
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5228,
85,
20688,
368,
341,
286,
1077,
5206,
264,
284,
508,
16,
13,
17,
11,
220,
16,
13,
18,
11,
220,
16,
13,
19,
935,
286,
1077,
293,
284,
508,
16,
13,
18,
11,
220,
16,
13,
20,
11,
220... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_bubble_sort() {
let mut v = vec![15, 6, 8, 10, 1, 3, 2, 0, -10, 4, -5];
bubble_sort(&mut v);
assert_eq!(v, vec![-10, -5, 0, 1, 2, 3, 4, 6, 8, 10, 15]);
} | rust_cleaned_test_functions.jsonl/122399 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 121
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
880,
14600,
18435,
368,
341,
286,
1077,
5206,
348,
284,
7486,
20703,
16,
20,
11,
220,
21,
11,
220,
23,
11,
220,
16,
15,
11,
220,
16,
11,
220,
18,
11,
220,
17,
11,
220,
15,
11,
481,
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_get_scalar_path() {
let c = make();
assert_eq!(c.get("place.favorite").ok(), Some(false));
assert_eq!(
c.get("place.creator.name").ok(),
Some("John Smith".to_string())
);
} | rust_cleaned_test_functions.jsonl/39924 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 108
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
41652,
2638,
368,
341,
262,
1077,
272,
284,
1281,
1428,
262,
2060,
10714,
10297,
66,
670,
445,
2007,
91464,
1827,
562,
1507,
4329,
3576,
1106,
262,
2060,
10714,
33673,
286,
272,
670,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_width() {
let mut res = scan("01123fe071 432", "{2d}{3d}{4x}{2d} {3d}");
assert_eq!(res.next().unwrap(), "01");
assert_eq!(res.next().unwrap(), "123");
assert_eq!(res.next().unwrap(), "fe07");
assert_eq!(res.next().unwrap(), "1");
assert_eq!(res.next().unwrap(), "432");
} | rust_cleaned_test_functions.jsonl/50247 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 150
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7927,
368,
341,
262,
1077,
5206,
592,
284,
8569,
445,
15,
16,
16,
17,
18,
1859,
15,
22,
16,
220,
19,
18,
17,
497,
13868,
17,
67,
15170,
18,
67,
15170,
19,
87,
15170,
17,
67,
92,
314,
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_bloom_filter_membership() {
let mut rng = AesRng::new();
let n = 1000;
let nhashes = 3;
let mut filter = BloomFilter::new(n, nhashes);
for _ in 0..128 {
let x = rng.gen::<Block>();
filter.insert(&x);
assert!(filter.contains(&x));
}
assert_eq!(
filter,
BloomFilter::from_bytes(&filter.as_bytes(), n, nhashes)
);
} | rust_cleaned_test_functions.jsonl/128706 | {
"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,
880,
18474,
8727,
84635,
368,
341,
286,
1077,
5206,
28422,
284,
362,
288,
49,
968,
486,
931,
543,
286,
1077,
308,
284,
220,
16,
15,
15,
15,
280,
286,
1077,
308,
8296,
288,
284,
220,
18,
280,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_vec_list_reserve() {
let mut list: VecList<i32> = VecList::new();
assert_eq!(list.capacity(), 0);
list.reserve(10);
let capacity = list.capacity();
assert!(capacity >= 10);
list.reserve(5);
assert_eq!(list.capacity(), capacity);
} | rust_cleaned_test_functions.jsonl/11549 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 149
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13251,
2019,
89591,
368,
341,
286,
1077,
5206,
1140,
25,
11312,
852,
21897,
18,
17,
29,
284,
11312,
852,
486,
931,
543,
286,
2060,
10714,
10297,
1607,
59168,
1507,
220,
15,
626,
286,
1140,
48520... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_nirmala() {
run_test(
&TEST_DATA,
"harfbuzz/good-nirmala.te",
"indic/Nirmala.ttf",
&[JOINER_GLYPH_INDEX],
5,
);
} | rust_cleaned_test_functions.jsonl/91177 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 214
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1089,
2853,
6053,
368,
341,
394,
1598,
4452,
1006,
503,
609,
10033,
7896,
345,
503,
330,
12982,
10798,
8889,
4846,
1386,
5279,
2853,
6053,
31853,
756,
503,
330,
85084,
20290,
2853,
6053,
45192,
75... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_regex_literal_continue_backslash() {
// backslash as second char
assert_parse_success!(
regex_literal,
"/a\\a/",
RegExpLiteral {
pattern: "a\\a".to_string(),
flags: String::new(),
}
);
} | rust_cleaned_test_functions.jsonl/66459 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 147
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
41832,
34100,
75297,
3895,
50256,
368,
341,
262,
442,
1182,
50256,
438,
2086,
1161,
198,
262,
2060,
21039,
18632,
33673,
286,
20180,
34100,
345,
286,
3521,
64,
3422,
64,
35075,
286,
28487,
17350,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_compile_with_dup_signer_mismatch() {
let program_id = Pubkey::new_unique();
let id0 = Pubkey::new_unique();
let compiled_keys = CompiledKeys::compile(
&[Instruction::new_with_bincode(
program_id,
&0,
vec![AccountMeta::new(id0, false), AccountMeta::new(id0, true)],
)],
None,
);
// Ensure the dup writable key is a signer
assert_eq!(
compiled_keys,
CompiledKeys {
payer: None,
key_meta_map: BTreeMap::from([
(id0, (KeyFlags::SIGNER | KeyFlags::WRITABLE).into()),
(program_id, KeyFlags::INVOKED.into()),
]),
}
);
} | rust_cleaned_test_functions.jsonl/52063 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 465
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
74170,
6615,
51932,
11172,
261,
717,
24976,
368,
341,
286,
1077,
2025,
842,
284,
22611,
792,
486,
931,
21218,
543,
286,
1077,
877,
15,
284,
22611,
792,
486,
931,
21218,
543,
286,
1077,
19697,
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... | 1 |
#[test]
fn test_append_jnit_report() {
let mut doc = initialise_junit_report().unwrap();
let mut testsuites = doc.get_root_element().expect("No root element");
create_junit_report(&mut doc, &mut testsuites, vec![]).unwrap();
let random_chars = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap()
.as_millis()
.to_string();
let random_filename = &format!(
"{}/{}.xml",
std::env::temp_dir().to_str().expect("No temp dir?"),
random_chars
);
write_junit_report_with(PathBuf::from(random_filename), &doc).expect("Saving report");
assert_eq!(
"0".to_string(),
testsuites.get_attribute("tests").expect("tests attribute")
);
assert_eq!(0, testsuites.get_child_nodes().len());
let parser = Parser::default();
let mut doc2 = parser
.parse_string(std::fs::read_to_string(PathBuf::from(random_filename)).unwrap())
.unwrap();
let reports = make_reports();
let mut testsuites = doc2
.get_root_element()
.expect("Failed to find root element for existing junit report");
create_junit_report(&mut doc2, &mut testsuites, reports.clone())
.expect("Could not create junit report for append test");
doc2.save_file(random_filename).unwrap();
let new_ts = doc2.get_root_element().unwrap();
let test_count = new_ts.get_attribute("tests").expect("tests attribute");
assert_eq!(reports.len().to_string(), test_count);
let new_tc = new_ts.get_child_elements();
assert_eq!(reports.len(), new_tc.len());
} | rust_cleaned_test_functions.jsonl/54761 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 806
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26041,
5374,
44068,
14813,
368,
341,
286,
1077,
5206,
4629,
284,
66166,
5374,
3843,
14813,
1005,
15454,
543,
286,
1077,
5206,
7032,
3083,
288,
284,
4629,
670,
12993,
7894,
1005,
17119,
445,
2753,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_factors_of_u64_max() {
// Factors of u64::MAX are the only ones for which
// dividing u64::MAX and u64::MAX - 1 yields different
let factors = [3, 5, 17, 257, 641, 65537, 6700417];
assert_eq!(factors.iter().product::<u64>(), u64::MAX);
for d in factors.iter().copied() {
check(d);
}
} | rust_cleaned_test_functions.jsonl/65997 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 196
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
73040,
3575,
7300,
21,
19,
6345,
368,
341,
286,
442,
67218,
315,
575,
21,
19,
486,
10586,
525,
279,
1172,
6174,
369,
892,
198,
286,
442,
49702,
575,
21,
19,
486,
10586,
323,
575,
21,
19,
486... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.