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_bls12_377_fq() {
use crate::fields::bls12_377::Fq;
for _ in 0..ITERATIONS {
let a: Fq = rand::random();
let b: Fq = rand::random();
field_test(a, b);
primefield_test::<Fq>();
sqrt_field_test(a);
}
} | rust_cleaned_test_functions.jsonl/27339 | {
"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,
880,
4730,
16,
17,
62,
18,
22,
22,
761,
80,
368,
341,
262,
990,
17717,
486,
9007,
486,
2024,
82,
16,
17,
62,
18,
22,
22,
486,
37,
80,
401,
262,
369,
716,
304,
220,
15,
496,
24733,
21792,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_collisions_query() {
// Query shouldn't affect things when unranked.
assert!(unranked_route_collisions(&["/hello?<foo>", "/hello"]));
assert!(unranked_route_collisions(&["/<a>?foo=bar", "/hello?foo=bar&cat=fat"]));
assert!(unranked_route_collisions(&["/<a>?foo=bar", "/hello?foo=bar&cat=fat"]));
assert!(unranked_route_collisions(&["/<a>", "/<b>?<foo>"]));
assert!(unranked_route_collisions(&["/hello/bob?a=b", "/hello/<b>?d=e"]));
assert!(unranked_route_collisions(&["/<foo>?a=b", "/foo?d=e"]));
assert!(unranked_route_collisions(&["/<foo>?a=b&<c>", "/<foo>?d=e&<c>"]));
assert!(unranked_route_collisions(&["/<foo>?a=b&<c>", "/<foo>?d=e"]));
} | rust_cleaned_test_functions.jsonl/26085 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 360
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
43597,
6805,
5738,
368,
341,
286,
442,
11361,
13133,
944,
7802,
2513,
979,
650,
13129,
291,
624,
286,
2060,
10297,
359,
13129,
291,
28109,
43597,
6805,
2099,
1183,
14,
14990,
75414,
7975,
21156,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_cnot_c2t0_of_3_bits() {
let p = Default::default();
let a = Complex::new(1.0, 0.0);
let b = Complex::new(0.0, 1.0);
let mut v = StateVector::from_complex_bases(vec![p, p, p, p, a, b, a, b]);
v.cnot(2, 0);
assert_eq!(
v,
StateVector::from_complex_bases(vec!(p, p, p, p, b, a, b, a))
);
} | rust_cleaned_test_functions.jsonl/21350 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 230
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
666,
1921,
666,
17,
83,
15,
3575,
62,
18,
20034,
368,
341,
286,
1077,
281,
284,
7899,
486,
2258,
543,
286,
1077,
264,
284,
22096,
486,
931,
7,
16,
13,
15,
11,
220,
15,
13,
15,
317,
286,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_pessimistic_rollback() {
let engine = TestEngineBuilder::new().build().unwrap();
let k = b"k1";
let v = b"v1";
// Normal
must_acquire_pessimistic_lock(&engine, k, k, 1, 1);
must_pessimistic_locked(&engine, k, 1, 1);
must_pessimistic_rollback(&engine, k, 1, 1);
must_unlocked(&engine, k);
must_get_commit_ts_none(&engine, k, 1);
// Pessimistic rollback is idempotent
must_pessimistic_rollback(&engine, k, 1, 1);
must_unlocked(&engine, k);
must_get_commit_ts_none(&engine, k, 1);
// Succeed if the lock doesn't exist.
must_pessimistic_rollback(&engine, k, 2, 2);
// Do nothing if meets other transaction's pessimistic lock
must_acquire_pessimistic_lock(&engine, k, k, 2, 3);
must_pessimistic_rollback(&engine, k, 1, 1);
must_pessimistic_rollback(&engine, k, 1, 2);
must_pessimistic_rollback(&engine, k, 1, 3);
must_pessimistic_rollback(&engine, k, 1, 4);
must_pessimistic_rollback(&engine, k, 3, 3);
must_pessimistic_rollback(&engine, k, 4, 4);
// Succeed if for_update_ts is larger; do nothing if for_update_ts is smaller.
must_pessimistic_locked(&engine, k, 2, 3);
must_pessimistic_rollback(&engine, k, 2, 2);
must_pessimistic_locked(&engine, k, 2, 3);
must_pessimistic_rollback(&engine, k, 2, 4);
must_unlocked(&engine, k);
// Do nothing if rollbacks a non-pessimistic lock.
must_prewrite_put(&engine, k, v, k, 3);
must_locked(&engine, k, 3);
must_pessimistic_rollback(&engine, k, 3, 3);
must_locked(&engine, k, 3);
// Do nothing if meets other transaction's optimistic lock
must_pessimistic_rollback(&engine, k, 2, 2);
must_pessimistic_rollback(&engine, k, 2, 3);
must_pessimistic_rollback(&engine, k, 2, 4);
must_pessimistic_rollback(&engine, k, 4, 4);
must_locked(&engine, k, 3);
// Do nothing if committed
must_commit(&engine, k, 3, 4);
must_unlocked(&engine, k);
must_get_commit_ts(&engine, k, 3, 4);
must_pessimistic_rollback(&engine, k, 3, 3);
must_pessimistic_rollback(&engine, k, 3, 4);
must_pessimistic_rollback(&engine, k, 3, 5);
} | rust_cleaned_test_functions.jsonl/61102 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1075
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
66733,
4532,
62,
33559,
368,
341,
286,
1077,
4712,
284,
3393,
4571,
3297,
486,
931,
1005,
5834,
1005,
15454,
1428,
286,
1077,
595,
284,
293,
62911,
16,
876,
286,
1077,
348,
284,
293,
1,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_hash_nonce() {
let mut rng = thread_rng();
let mut nonce: u16 = 0;
for i in 1..10 {
let mut val = vec![0u8; i * 32];
rng.fill(&mut val[..]);
let _n = rng.gen_biguint(1024);
let mut h = nonce_hash::<_, Blake2b>(nonce, &val, None);
while h == None {
nonce = nonce + 1;
h = nonce_hash::<_, Blake2b>(nonce, &val, None);
}
assert!(verify_nonce_hash(&h.unwrap()));
}
} | rust_cleaned_test_functions.jsonl/49435 | {
"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,
8950,
48508,
368,
341,
286,
1077,
5206,
28422,
284,
4516,
66849,
543,
286,
1077,
5206,
39676,
25,
575,
16,
21,
284,
220,
15,
280,
286,
369,
600,
304,
220,
16,
496,
16,
15,
341,
310,
1077,
52... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_add_histograms_simple() {
assert_eq!(
add_vecs(vec![vec![1, 0, 3], vec![11, 2, 3], vec![0, 0, 1]], 3),
vec![12, 2, 7]
)
} | rust_cleaned_test_functions.jsonl/125919 | {
"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,
2891,
68564,
82,
30015,
368,
341,
286,
2060,
10714,
33673,
310,
912,
13251,
82,
25592,
20703,
4083,
20703,
16,
11,
220,
15,
11,
220,
18,
1125,
7486,
20703,
16,
16,
11,
220,
17,
11,
220,
18,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_log_connect_stats_select_network_failure() {
let connect_stats = ConnectStats {
result: SelectNetworkFailure::NoCompatibleNetwork.into(),
..fake_connect_stats()
};
let expected_metrics_subset = hashset! {
metrics::CONNECTION_RESULT_METRIC_ID,
metrics::CONNECTION_FAILURE_METRIC_ID,
metrics::NETWORK_SELECTION_FAILURE_METRIC_ID,
};
test_metric_subset(&connect_stats, expected_metrics_subset, hashset! {});
} | rust_cleaned_test_functions.jsonl/14744 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 247
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5224,
15720,
15381,
13051,
20966,
43618,
368,
341,
286,
1077,
4564,
15381,
284,
13015,
16635,
341,
310,
1102,
25,
8427,
12320,
17507,
486,
2753,
29161,
12320,
39860,
3148,
310,
5241,
30570,
15720,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_boolean_buffer_builder_unset_first_bit() {
let mut buffer = BooleanBufferBuilder::new(4);
buffer.append(true);
buffer.append(true);
buffer.append(false);
buffer.append(true);
buffer.set_bit(0, false);
assert_eq!(buffer.len(), 4);
assert_eq!(buffer.finish().as_slice(), &[0b1010_u8]);
} | rust_cleaned_test_functions.jsonl/87772 | {
"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,
46642,
7776,
28532,
98109,
12978,
13996,
368,
341,
286,
1077,
5206,
4147,
284,
6992,
4095,
3297,
486,
931,
7,
19,
317,
286,
4147,
2057,
3715,
317,
286,
4147,
2057,
3715,
317,
286,
4147,
2057,
35... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_transform_one_value() {
let input = input_from(&[(1, vec!['A'])]);
let expected = expected_from(&[('a', 1)]);
assert_eq!(expected, etl::transform(&input));
} | rust_cleaned_test_functions.jsonl/19630 | {
"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,
18449,
11667,
3142,
368,
341,
262,
1077,
1946,
284,
1946,
5673,
2099,
9697,
16,
11,
7486,
0,
677,
32,
5078,
10149,
262,
1077,
3601,
284,
3601,
5673,
2099,
58,
492,
64,
516,
220,
16,
7252,
626,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_event_stream() {
use futures::stream::iter;
let stream = EventStream::from(iter(vec![Event::data("foo")]));
assert_eq!(stream.into_string().replace(":\n\n", ""), "data:foo\n\n");
let stream = EventStream::from(iter(vec![Event::data("a"), Event::data("b")]));
assert_eq!(stream.into_string().replace(":\n\n", ""), "data:a\n\ndata:b\n\n");
let stream = EventStream::from(iter(vec![
Event::data("a\nb"),
Event::data("b"),
Event::data("c\n\nd"),
Event::data("e"),
]));
assert_eq!(stream.into_string().replace(":\n\n", ""),
"data:a\ndata:b\n\ndata:b\n\ndata:c\ndata:\ndata:d\n\ndata:e\n\n");
} | rust_cleaned_test_functions.jsonl/52161 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 395
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6748,
12673,
368,
341,
286,
990,
36823,
486,
4027,
486,
2015,
401,
286,
1077,
4269,
284,
3665,
3027,
486,
1499,
27070,
25592,
20703,
1556,
486,
691,
445,
7975,
899,
14382,
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_1() {
let inp = "5483143223
2745854711
5264556173
6141336146
6357385478
4167524645
2176841721
6882881134
4846848554
5283751526";
let parsed = input_generator(inp);
assert_eq!(solve_part1(&parsed), 1656);
} | rust_cleaned_test_functions.jsonl/131634 | {
"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,
16,
368,
341,
286,
1077,
32344,
284,
330,
20,
19,
23,
18,
16,
19,
18,
17,
17,
18,
198,
17,
22,
19,
20,
23,
20,
19,
22,
16,
16,
198,
20,
17,
21,
19,
20,
20,
21,
16,
22,
18,
198,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_epoch() {
let fun = Epoch::new(5, EpochUnit::Second);
let query = Query::from(fun);
let serialized = serde_json::to_value(&query).unwrap();
let expected = json!({
"epoch": 5,
"unit": "second"
});
assert_eq!(expected, serialized);
} | rust_cleaned_test_functions.jsonl/14353 | {
"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,
20682,
368,
341,
286,
1077,
2464,
284,
87379,
486,
931,
7,
20,
11,
87379,
4562,
486,
15666,
626,
286,
1077,
3239,
284,
11361,
486,
1499,
71868,
317,
286,
1077,
32916,
284,
61570,
9455,
486,
983,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_take_until_match() {
assert_eq!(take_until("pooltest", 'l'), ("poo", "ltest"));
assert_eq!(take_until("pooltest", 'f'), ("pooltest", ""));
assert_eq!(take_until("", 'k'),("",""));
assert_eq!(take_until("🥺test🥺okok", '🥺'),("","🥺test🥺okok"));
assert_eq!(take_until("test🥺okok", '🥺'),("test","🥺okok"));
assert_eq!(take_until("test🥺", '🥺'),("test","🥺"));
} | rust_cleaned_test_functions.jsonl/44008 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 205
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
73261,
44352,
10708,
368,
341,
262,
2060,
10714,
10297,
22769,
44352,
445,
10285,
1944,
497,
364,
75,
4567,
3489,
79,
2624,
497,
330,
75,
1944,
4010,
262,
2060,
10714,
10297,
22769,
44352,
445,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_callback_remove_itself() {
let dialog = Dialog::new();
let dialog2 = dialog.clone();
let token = Rc::new(RefCell::new(None));
let token2: Rc<RefCell<Option<ShowCallbackToken>>> = token.clone();
*token.borrow_mut() = Some(dialog.show_event().add(move |_| {
dialog2.show_event().remove(token2.borrow_mut().take().unwrap());
CallbackAction::Close
}));
drop(token);
dialog.show_xy(ScreenPosition::Center, ScreenPosition::Center).expect("could not show dialog");
main_loop();
} | rust_cleaned_test_functions.jsonl/124024 | {
"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,
12519,
18193,
14631,
721,
368,
341,
262,
1077,
7254,
284,
13393,
486,
931,
543,
262,
1077,
7254,
17,
284,
7254,
15997,
543,
262,
1077,
3950,
284,
81463,
486,
931,
7,
3945,
3599,
486,
931,
26717,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_scan_with_key_only() {
let db_config = crate::config::DbConfig {
titan: TitanDBConfig {
enabled: true,
..Default::default()
},
..Default::default()
};
let engine = {
let path = "".to_owned();
let cfs = ALL_CFS.to_vec();
let cfg_rocksdb = db_config;
let cache = BlockCacheConfig::default().build_shared_cache();
let cfs_opts = vec![
CFOptions::new(
CF_DEFAULT,
cfg_rocksdb.defaultcf.build_opt(&cache, None, false),
),
CFOptions::new(CF_LOCK, cfg_rocksdb.lockcf.build_opt(&cache)),
CFOptions::new(CF_WRITE, cfg_rocksdb.writecf.build_opt(&cache, None)),
CFOptions::new(CF_RAFT, cfg_rocksdb.raftcf.build_opt(&cache)),
];
RocksEngine::new(
&path,
&cfs,
Some(cfs_opts),
cache.is_some(),
None, /*io_rate_limiter*/
)
}
.unwrap();
let storage = TestStorageBuilder::<_, DummyLockManager>::from_engine_and_lock_mgr(
engine,
DummyLockManager {},
)
.build()
.unwrap();
let (tx, rx) = channel();
storage
.sched_txn_command(
commands::Prewrite::with_defaults(
vec![
Mutation::Put((Key::from_raw(b"a"), b"aa".to_vec())),
Mutation::Put((Key::from_raw(b"b"), b"bb".to_vec())),
Mutation::Put((Key::from_raw(b"c"), b"cc".to_vec())),
],
b"a".to_vec(),
1.into(),
),
expect_ok_callback(tx.clone(), 0),
)
.unwrap();
rx.recv().unwrap();
// Forward
expect_multi_values(
vec![None, None, None],
block_on(storage.scan(
Context::default(),
Key::from_raw(b"\x00"),
None,
1000,
0,
5.into(),
true,
false,
))
.unwrap(),
);
// Backward
expect_multi_values(
vec![None, None, None],
block_on(storage.scan(
Context::default(),
Key::from_raw(b"\xff"),
None,
1000,
0,
5.into(),
true,
true,
))
.unwrap(),
);
// Forward with bound
expect_multi_values(
vec![None, None],
block_on(storage.scan(
Context::default(),
Key::from_raw(b"\x00"),
Some(Key::from_raw(b"c")),
1000,
0,
5.into(),
true,
false,
))
.unwrap(),
);
// Backward with bound
expect_multi_values(
vec![None, None],
block_on(storage.scan(
Context::default(),
Key::from_raw(b"\xff"),
Some(Key::from_raw(b"b")),
1000,
0,
5.into(),
true,
true,
))
.unwrap(),
);
// Forward with limit
expect_multi_values(
vec![None, None],
block_on(storage.scan(
Context::default(),
Key::from_raw(b"\x00"),
None,
2,
0,
5.into(),
true,
false,
))
.unwrap(),
);
// Backward with limit
expect_multi_values(
vec![None, None],
block_on(storage.scan(
Context::default(),
Key::from_raw(b"\xff"),
None,
2,
0,
5.into(),
true,
true,
))
.unwrap(),
);
storage
.sched_txn_command(
commands::Commit::new(
vec![
Key::from_raw(b"a"),
Key::from_raw(b"b"),
Key::from_raw(b"c"),
],
1.into(),
2.into(),
Context::default(),
),
expect_ok_callback(tx, 1),
)
.unwrap();
rx.recv().unwrap();
// Forward
expect_multi_values(
vec![
Some((b"a".to_vec(), vec![])),
Some((b"b".to_vec(), vec![])),
Some((b"c".to_vec(), vec![])),
],
block_on(storage.scan(
Context::default(),
Key::from_raw(b"\x00"),
None,
1000,
0,
5.into(),
true,
false,
))
.unwrap(),
);
// Backward
expect_multi_values(
vec![
Some((b"c".to_vec(), vec![])),
Some((b"b".to_vec(), vec![])),
Some((b"a".to_vec(), vec![])),
],
block_on(storage.scan(
Context::default(),
Key::from_raw(b"\xff"),
None,
1000,
0,
5.into(),
true,
true,
))
.unwrap(),
);
// Forward with bound
expect_multi_values(
vec![Some((b"a".to_vec(), vec![])), Some((b"b".to_vec(), vec![]))],
block_on(storage.scan(
Context::default(),
Key::from_raw(b"\x00"),
Some(Key::from_raw(b"c")),
1000,
0,
5.into(),
true,
false,
))
.unwrap(),
);
// Backward with bound
expect_multi_values(
vec![Some((b"c".to_vec(), vec![])), Some((b"b".to_vec(), vec![]))],
block_on(storage.scan(
Context::default(),
Key::from_raw(b"\xff"),
Some(Key::from_raw(b"b")),
1000,
0,
5.into(),
true,
true,
))
.unwrap(),
);
// Forward with limit
expect_multi_values(
vec![Some((b"a".to_vec(), vec![])), Some((b"b".to_vec(), vec![]))],
block_on(storage.scan(
Context::default(),
Key::from_raw(b"\x00"),
None,
2,
0,
5.into(),
true,
false,
))
.unwrap(),
);
// Backward with limit
expect_multi_values(
vec![Some((b"c".to_vec(), vec![])), Some((b"b".to_vec(), vec![]))],
block_on(storage.scan(
Context::default(),
Key::from_raw(b"\xff"),
None,
2,
0,
5.into(),
true,
true,
))
.unwrap(),
);
} | rust_cleaned_test_functions.jsonl/2075 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 5032
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28857,
6615,
3097,
18410,
368,
341,
286,
1077,
2927,
5332,
284,
17717,
486,
1676,
486,
7994,
2648,
341,
310,
85512,
25,
27447,
3506,
2648,
341,
394,
8970,
25,
830,
345,
394,
5241,
3675,
486,
225... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_string_boolean_comparison() {
fold_same("'' + x == !y");
fold_same("'' + x <= !y");
fold("'' + x === !y", "false");
} | rust_cleaned_test_functions.jsonl/122157 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 72
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3904,
46642,
90797,
368,
341,
262,
11555,
33574,
445,
4605,
488,
856,
621,
753,
88,
797,
262,
11555,
33574,
445,
4605,
488,
856,
2651,
753,
88,
797,
262,
11555,
445,
4605,
488,
856,
2049,
753,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_escape_default() {
fn string(c: char) -> String {
let iter: String = c.escape_default().collect();
let disp: String = c.escape_default().to_string();
assert_eq!(iter, disp);
iter
}
assert_eq!(string('\n'), "\\n");
assert_eq!(string('\r'), "\\r");
assert_eq!(string('\''), "\\'");
assert_eq!(string('"'), "\\\"");
assert_eq!(string(' '), " ");
assert_eq!(string('a'), "a");
assert_eq!(string('~'), "~");
assert_eq!(string('é'), "\\u{e9}");
assert_eq!(string('\x00'), "\\u{0}");
assert_eq!(string('\x1f'), "\\u{1f}");
assert_eq!(string('\x7f'), "\\u{7f}");
assert_eq!(string('\u{80}'), "\\u{80}");
assert_eq!(string('\u{ff}'), "\\u{ff}");
assert_eq!(string('\u{11b}'), "\\u{11b}");
assert_eq!(string('\u{1d4b6}'), "\\u{1d4b6}");
assert_eq!(string('\u{200b}'), "\\u{200b}"); // zero width space
assert_eq!(string('\u{e000}'), "\\u{e000}"); // private use 1
assert_eq!(string('\u{100000}'), "\\u{100000}"); // private use 2
} | rust_cleaned_test_functions.jsonl/109587 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 516
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21832,
9993,
368,
341,
262,
5168,
914,
1337,
25,
1161,
8,
1464,
923,
341,
286,
1077,
5367,
25,
923,
284,
272,
57081,
9993,
1005,
17384,
543,
286,
1077,
12965,
25,
923,
284,
272,
57081,
9993,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_no_stderr_fail() {
let res = CmdResult {
tmpd: None,
code: None,
success: true,
stdout: "".into(),
stderr: "asdfsadfa".into(),
};
res.no_stderr();
} | rust_cleaned_test_functions.jsonl/74682 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 161
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6536,
93033,
22121,
368,
341,
286,
1077,
592,
284,
40210,
2077,
341,
310,
4174,
67,
25,
2240,
345,
310,
2038,
25,
2240,
345,
310,
2393,
25,
830,
345,
310,
20075,
25,
44907,
18122,
3148,
310,
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 |
#[test]
fn test_ping_pong() {
/// A simple enum used as test messages.
#[derive(Serialize, Deserialize)]
pub enum PingPong {
Ping(Aid),
Pong,
}
async fn ping(_: (), context: Context, message: Message) -> ActorResult<()> {
if let Some(msg) = message.content_as::<PingPong>() {
match &*msg {
PingPong::Pong => {
context.system.trigger_shutdown();
Ok(Status::done(()))
}
_ => Err("Unexpected message".to_string().into()),
}
} else if let Some(msg) = message.content_as::<SystemMsg>() {
// Start messages happen only once so we keep them last.
match &*msg {
SystemMsg::Start => {
// Now we will spawn a new actor to handle our pong and send to it.
let pong_aid = context.system.spawn().with((), pong)?;
pong_aid.send_new(PingPong::Ping(context.aid.clone()))?;
Ok(Status::done(()))
}
_ => Ok(Status::done(())),
}
} else {
Ok(Status::done(()))
}
}
async fn pong(_: (), _: Context, message: Message) -> ActorResult<()> {
if let Some(msg) = message.content_as::<PingPong>() {
match &*msg {
PingPong::Ping(from) => {
from.send_new(PingPong::Pong)?;
Ok(Status::done(()))
}
_ => Err("Unexpected message".into()),
}
} else {
Ok(Status::done(()))
}
}
let system = ActorSystem::create(ActorSystemConfig::default().thread_pool_size(2));
system.spawn().with((), ping).unwrap();
system.await_shutdown(None);
} | rust_cleaned_test_functions.jsonl/1277 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1147
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
71661,
62,
59102,
368,
341,
286,
1048,
362,
4285,
7618,
1483,
438,
1273,
6605,
624,
286,
11506,
27098,
3759,
9050,
11,
48440,
5563,
286,
6675,
7618,
48657,
47,
644,
341,
310,
48657,
4346,
307,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_ignore_derive_macro_without_input() {
check_assist_not_applicable(
add_custom_impl,
"
#[derive(<|>)]
struct Foo {}
",
)
} | rust_cleaned_test_functions.jsonl/8177 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 118
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
58493,
35345,
533,
58810,
39904,
5898,
368,
341,
286,
1779,
12083,
380,
7913,
8191,
46114,
1006,
310,
912,
15875,
21007,
345,
310,
6228,
13353,
27098,
22726,
91,
29,
5563,
1235,
33428,
5613,
310,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_get_dupfixed() {
let dir = TempDir::new("test").unwrap();
let env = Environment::new().open(dir.path()).unwrap();
let db = env.create_db(None, DatabaseFlags::DUP_SORT | DatabaseFlags::DUP_FIXED).unwrap();
let mut txn = env.begin_rw_txn().unwrap();
txn.put(db, b"key1", b"val1", WriteFlags::empty()).unwrap();
txn.put(db, b"key1", b"val2", WriteFlags::empty()).unwrap();
txn.put(db, b"key1", b"val3", WriteFlags::empty()).unwrap();
txn.put(db, b"key2", b"val4", WriteFlags::empty()).unwrap();
txn.put(db, b"key2", b"val5", WriteFlags::empty()).unwrap();
txn.put(db, b"key2", b"val6", WriteFlags::empty()).unwrap();
let cursor = txn.open_ro_cursor(db).unwrap();
assert_eq!((Some(&b"key1"[..]), &b"val1"[..]), cursor.get(None, None, MDB_FIRST).unwrap());
assert_eq!((None, &b"val1val2val3"[..]), cursor.get(None, None, MDB_GET_MULTIPLE).unwrap());
assert!(cursor.get(None, None, MDB_NEXT_MULTIPLE).is_err());
} | rust_cleaned_test_functions.jsonl/15134 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 497
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
51932,
22021,
368,
341,
286,
1077,
5419,
284,
19944,
6184,
486,
931,
445,
1944,
1827,
15454,
543,
286,
1077,
6105,
284,
11586,
486,
931,
1005,
2508,
14161,
3875,
6011,
15454,
543,
286,
1077,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_write_shutdown() {
init();
let mut poll = Poll::new().unwrap();
let listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap();
let addr = listener.local_addr().unwrap();
let interests = Interests::READABLE | Interests::WRITABLE;
let client = TcpStream::connect(addr).unwrap();
poll.registry()
.register(&client, Token(0), interests)
.unwrap();
let (socket, _) = listener.accept().unwrap();
wait!(poll, is_writable, false);
let mut events = Events::with_capacity(16);
// Polling should not have any events
poll.poll(&mut events, Some(Duration::from_millis(100)))
.unwrap();
let next = events.iter().next();
assert!(next.is_none());
println!("SHUTTING DOWN");
socket.shutdown(Shutdown::Write).unwrap();
wait!(poll, is_readable, true);
} | rust_cleaned_test_functions.jsonl/63284 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 338
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9165,
54804,
368,
341,
262,
2930,
1428,
262,
1077,
5206,
7085,
284,
24385,
486,
931,
1005,
15454,
1428,
262,
1077,
11446,
284,
1460,
486,
4711,
486,
77536,
2743,
486,
7666,
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_flatten_grammar() {
let result = flatten_variable(Variable {
name: "test".to_string(),
kind: VariableType::Named,
rule: Rule::seq(vec![
Rule::non_terminal(1),
Rule::prec_left(
Precedence::Integer(101),
Rule::seq(vec![
Rule::non_terminal(2),
Rule::choice(vec![
Rule::prec_right(
Precedence::Integer(102),
Rule::seq(vec![Rule::non_terminal(3), Rule::non_terminal(4)]),
),
Rule::non_terminal(5),
]),
Rule::non_terminal(6),
]),
),
Rule::non_terminal(7),
]),
})
.unwrap();
assert_eq!(
result.productions,
vec![
Production {
dynamic_precedence: 0,
steps: vec![
ProductionStep::new(Symbol::non_terminal(1)),
ProductionStep::new(Symbol::non_terminal(2))
.with_prec(Precedence::Integer(101), Some(Associativity::Left)),
ProductionStep::new(Symbol::non_terminal(3))
.with_prec(Precedence::Integer(102), Some(Associativity::Right)),
ProductionStep::new(Symbol::non_terminal(4))
.with_prec(Precedence::Integer(101), Some(Associativity::Left)),
ProductionStep::new(Symbol::non_terminal(6)),
ProductionStep::new(Symbol::non_terminal(7)),
]
},
Production {
dynamic_precedence: 0,
steps: vec![
ProductionStep::new(Symbol::non_terminal(1)),
ProductionStep::new(Symbol::non_terminal(2))
.with_prec(Precedence::Integer(101), Some(Associativity::Left)),
ProductionStep::new(Symbol::non_terminal(5))
.with_prec(Precedence::Integer(101), Some(Associativity::Left)),
ProductionStep::new(Symbol::non_terminal(6)),
ProductionStep::new(Symbol::non_terminal(7)),
]
},
]
);
} | rust_cleaned_test_functions.jsonl/122533 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1594
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5081,
14456,
62,
41094,
368,
341,
286,
1077,
1102,
284,
45343,
14635,
7,
7827,
341,
310,
829,
25,
330,
1944,
3263,
983,
3904,
3148,
310,
3093,
25,
12407,
929,
486,
15810,
345,
310,
5912,
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... | 1 |
#[test]
fn test_with_long_header_option() {
let test_file_path = "test_one_page.log";
let expected_test_file_path = "test_one_page_header.log.expected";
let mut scenario = new_ucmd!();
let value = file_last_modified_time(&scenario, test_file_path);
let header = "new file";
scenario
.args(&["--header=new file", test_file_path])
.succeeds()
.stdout_is_templated_fixture(
expected_test_file_path,
&[("{last_modified_time}", &value), ("{header}", header)],
);
new_ucmd!()
.args(&["-h", header, test_file_path])
.succeeds()
.stdout_is_templated_fixture(
expected_test_file_path,
&[("{last_modified_time}", &value), ("{header}", header)],
);
} | rust_cleaned_test_functions.jsonl/103042 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 378
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6615,
17799,
8757,
9672,
368,
341,
262,
1077,
1273,
2458,
2638,
284,
330,
1944,
11667,
6129,
1665,
876,
262,
1077,
3601,
4452,
2458,
2638,
284,
330,
1944,
11667,
6129,
8757,
1665,
56835,
876,
262,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_iterator_rev_nth_back() {
let v: &[_] = &[0, 1, 2, 3, 4];
for i in 0..v.len() {
assert_eq!(v.iter().rev().nth_back(i).unwrap(), &v[i]);
}
assert_eq!(v.iter().rev().nth_back(v.len()), None);
} | rust_cleaned_test_functions.jsonl/54111 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 129
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13491,
38082,
78342,
3895,
368,
341,
262,
1077,
348,
25,
609,
13496,
60,
284,
44590,
15,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
935,
262,
369,
600,
304,
220,
15,
496,
85,
1940... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_block_doc_comment_3() {
with_default_session_globals(|| {
let comment = "\n let a: *i32;\n *a = 5;\n";
let stripped = beautify_doc_string(Symbol::intern(comment));
assert_eq!(stripped, " let a: *i32;\n *a = 5;");
})
} | rust_cleaned_test_functions.jsonl/120753 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 133
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7113,
18869,
17638,
62,
18,
368,
341,
262,
448,
9993,
12316,
58775,
79453,
341,
286,
1077,
3980,
284,
2917,
77,
1077,
264,
25,
353,
72,
18,
17,
17882,
77,
353,
64,
284,
220,
20,
17882,
77,
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... | 2 |
#[test]
fn test_decode() {
for decode_param in vec!["-d", "--decode"] {
let input = "JBSWY3DPFQQFO33SNRSCC===\n";
new_ucmd!()
.arg(decode_param)
.pipe_in(input)
.succeeds()
.stdout_only("Hello, World!");
}
} | rust_cleaned_test_functions.jsonl/39844 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 170
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15227,
368,
341,
262,
369,
16895,
4090,
304,
7486,
0,
1183,
12,
67,
497,
14482,
18196,
1341,
341,
286,
1077,
1946,
284,
330,
41,
7347,
54,
56,
18,
10298,
37,
48026,
3788,
18,
18,
18966,
49,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_decode() {
assert_eq!(
decode(
vec![FeString { max_size: 26 }],
expression! { 42 },
AbiDecodeLocation::Calldata
)[0]
.to_string(),
"abi_decode_string26_calldata(42, 0)"
)
} | rust_cleaned_test_functions.jsonl/37439 | {
"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,
15227,
368,
341,
286,
2060,
10714,
33673,
310,
16895,
1006,
394,
7486,
20703,
6123,
703,
314,
1932,
2368,
25,
220,
17,
21,
29043,
394,
7493,
0,
314,
220,
19,
17,
1153,
394,
3680,
72,
32564,
47... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_normal_use_case() {
let address = hex::decode("d8b934580fcE35a11B58C6D73aDeE468a2833fa8").unwrap();
let address: [u8; 20] = address.try_into().unwrap();
let input = vec![
SolidityDataType::NumberWithShift(U256::from(3838), TakeLastXBytes(24)),
SolidityDataType::Number(U256::from(4001)),
SolidityDataType::String("this-is-a-sample-string"),
SolidityDataType::Address(Address::from(address)),
SolidityDataType::Number(U256::from(1)),
];
let (_bytes, hash) = abi::encode_packed(&input);
let hash = format!("0x{:}", hash);
let expected = "0x000efe0000000000000000000000000000000000000000000000000000000000000fa1746869732d69732d612d73616d706c652d737472696e67d8b934580fce35a11b58c6d73adee468a2833fa80000000000000000000000000000000000000000000000000000000000000001";
assert_eq!(hash, expected);
} | rust_cleaned_test_functions.jsonl/52421 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 407
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13973,
15951,
19096,
368,
341,
286,
1077,
2621,
284,
12371,
486,
18196,
445,
67,
23,
65,
24,
18,
19,
20,
23,
15,
8316,
36,
18,
20,
64,
16,
16,
33,
20,
23,
34,
21,
35,
22,
18,
64,
1912,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_mip1() {
let mut optimizer = GurobiOptimizer::new("mip1");
let x = optimizer.add_var('B', false);
let y = optimizer.add_var('B', false);
let z = optimizer.add_var('B', false);
let obj = optimizer.add_var('I', true);
optimizer.add_constraint(&vec![x, y, z, obj], &vec![1.0, 1.0, 2.0, -1.0], '=', 0.0);
optimizer.add_constraint(&vec![x, y, z], &vec![1.0, 2.0, 3.0], '<', 4.0);
optimizer.add_constraint(&vec![x, y], &vec![1.0, 1.0], '>', 1.0);
optimizer.optimize("max");
assert!(*optimizer.solutions.get(&x).unwrap() == 1.0);
assert!(*optimizer.solutions.get(&y).unwrap() == 0.0);
assert!(*optimizer.solutions.get(&z).unwrap() == 1.0);
} | rust_cleaned_test_functions.jsonl/125770 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 339
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
717,
573,
16,
368,
341,
262,
1077,
5206,
25632,
284,
479,
2798,
8221,
80637,
486,
931,
445,
76,
573,
16,
797,
262,
1077,
856,
284,
25632,
1364,
4612,
492,
33,
516,
895,
317,
262,
1077,
379,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_cmsg_space() {
unsafe {
for l in 0..128 {
assert_eq!(libc::CMSG_SPACE(l) as usize, cmsg_space(l));
}
}
} | rust_cleaned_test_functions.jsonl/91467 | {
"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,
666,
3236,
14663,
368,
341,
286,
19860,
341,
310,
369,
326,
304,
220,
15,
496,
16,
17,
23,
341,
394,
2060,
10714,
10297,
55576,
486,
34,
19575,
38404,
2333,
8,
438,
22301,
11,
272,
3236,
14663... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_introspect() {
let c = Connection::get_private(super::BusType::Session).unwrap();
let mut o = make_objpath(&c);
o.set_registered(true).unwrap();
let mut o2 = ObjectPath::new(&c, "/echo/subpath", true);
o2.set_registered(true).unwrap();
let mut msg = Message::new_method_call("com.example.echoserver", "/echo", "org.freedesktop.DBus.Introspectable", "Introspect").unwrap();
println!("Introspect result: {}", parse_msg_str(o.i.introspect(&mut msg).unwrap().get(0)).unwrap());
let result = r##"<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node name="/echo">
<interface name="com.example.echo">
<method name="Echo">
<arg name="request" type="s" direction="in"/>
<arg name="reply" type="s" direction="out"/>
</method>
<property name="EchoCount" type="i" access="read"/>
<signal name="Echoed">
<arg name="data" type="s"/>
</signal>
</interface>
<interface name="org.freedesktop.DBus.Introspectable">
<method name="Introspect">
<arg name="xml_data" type="s" direction="out"/>
</method>
</interface>
<interface name="org.freedesktop.DBus.Properties">
<method name="Get">
<arg name="interface_name" type="s" direction="in"/>
<arg name="property_name" type="s" direction="in"/>
<arg name="value" type="v" direction="out"/>
</method>
<method name="GetAll">
<arg name="interface_name" type="s" direction="in"/>
<arg name="props" type="a{sv}" direction="out"/>
</method>
<method name="Set">
<arg name="interface_name" type="s" direction="in"/>
<arg name="property_name" type="s" direction="in"/>
<arg name="value" type="v" direction="in"/>
</method>
</interface>
<node name="subpath"/>
</node>"##;
assert_eq!(result, parse_msg_str(o.i.introspect(&mut msg).unwrap().get(0)).unwrap());
} | rust_cleaned_test_functions.jsonl/129764 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 783
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4042,
3630,
987,
368,
341,
262,
1077,
272,
284,
11032,
486,
455,
26249,
56040,
486,
15073,
929,
486,
5283,
568,
15454,
543,
262,
1077,
5206,
297,
284,
1281,
7328,
2343,
2099,
66,
317,
262,
297,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_guild() {
let input = r#"{
"d": {
"afk_channel_id": "1337",
"afk_timeout": 300,
"application_id": null,
"banner": null,
"default_message_notifications": 0,
"description": null,
"discovery_splash": null,
"embed_channel_id": null,
"embed_enabled": false,
"emojis": [
{
"animated": false,
"available": true,
"id": "1338",
"managed": false,
"name": "goodboi",
"require_colons": true,
"roles": []
}
],
"explicit_content_filter": 0,
"features": [
"INVITE_SPLASH",
"ANIMATED_ICON"
],
"guild_id": "1339",
"icon": "foobar",
"id": "13310",
"max_members": 250000,
"max_presences": null,
"mfa_level": 0,
"name": "FooBaz",
"owner_id": "13311",
"preferred_locale": "en-US",
"premium_subscription_count": 4,
"premium_tier": 1,
"region": "eu-central",
"roles": [
{
"color": 0,
"hoist": false,
"id": "13312",
"managed": false,
"mentionable": false,
"name": "@everyone",
"permissions": 104193601,
"position": 0
}
],
"rules_channel_id": null,
"splash": "barbaz",
"system_channel_flags": 0,
"system_channel_id": "13313",
"vanity_url_code": null,
"verification_level": 0,
"widget_channel_id": null,
"widget_enabled": false
},
"op": 0,
"s": 42,
"t": "GUILD_UPDATE"
}"#;
let deserializer = GatewayEventDeserializer::from_json(input).unwrap();
let mut json_deserializer = Deserializer::from_str(input);
let event = deserializer.deserialize(&mut json_deserializer).unwrap();
assert!(matches!(event, GatewayEvent::Dispatch(42, _)));
} | rust_cleaned_test_functions.jsonl/78645 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 877
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1889,
1498,
368,
341,
286,
1077,
1946,
284,
435,
55543,
515,
220,
330,
67,
788,
341,
262,
330,
2577,
74,
14571,
842,
788,
330,
16,
18,
18,
22,
756,
262,
330,
2577,
74,
20537,
788,
220,
18,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_new_full_address() {
let code_hash = Byte32::from_slice(
h256!("0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8").as_bytes(),
)
.unwrap();
let args = Bytes::from(h160!("0xb39bbc0b3673c7d36450bc14cfcdad2d559c6c64").as_bytes());
let payload =
AddressPayload::new_full(ScriptHashType::Type, code_hash.clone(), args.clone());
let address = Address::new(NetworkType::Mainnet, payload, true);
assert_eq!(address.to_string(), "ckb1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqdnnw7qkdnnclfkg59uzn8umtfd2kwxceqxwquc4");
assert_eq!(address, Address::from_str("ckb1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqdnnw7qkdnnclfkg59uzn8umtfd2kwxceqxwquc4").unwrap());
let payload =
AddressPayload::new_full(ScriptHashType::Data, code_hash.clone(), args.clone());
let address = Address::new(NetworkType::Mainnet, payload, true);
assert_eq!(address.to_string(), "ckb1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq9nnw7qkdnnclfkg59uzn8umtfd2kwxceqvguktl");
assert_eq!(address, Address::from_str("ckb1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq9nnw7qkdnnclfkg59uzn8umtfd2kwxceqvguktl").unwrap());
let payload = AddressPayload::new_full(ScriptHashType::Data1, code_hash, args);
let address = Address::new(NetworkType::Mainnet, payload, true);
assert_eq!(address.to_string(), "ckb1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq4nnw7qkdnnclfkg59uzn8umtfd2kwxceqcydzyt");
assert_eq!(address, Address::from_str("ckb1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq4nnw7qkdnnclfkg59uzn8umtfd2kwxceqcydzyt").unwrap());
} | rust_cleaned_test_functions.jsonl/13676 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 915
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5921,
16372,
6744,
368,
341,
286,
1077,
2038,
8950,
284,
10906,
18,
17,
486,
1499,
26488,
1006,
310,
305,
17,
20,
21,
17223,
15,
87,
24,
8940,
22,
68,
15,
21,
69,
18,
757,
69,
19,
1371,
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_unique_non_finite_numbers() {
let v = to_value(vec![
::std::f64::NEG_INFINITY, // NaN and friends get deserialized as Null by serde.
::std::f64::NAN,
])
.unwrap();
let args = HashMap::new();
let result = unique(&v, &args);
assert!(result.is_err());
assert_eq!(result.unwrap_err().to_string(), "Null is not a unique value");
} | rust_cleaned_test_functions.jsonl/62062 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 213
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21218,
21637,
761,
15856,
32964,
368,
341,
286,
1077,
348,
284,
311,
3142,
25592,
90515,
310,
3504,
1834,
486,
69,
21,
19,
486,
97127,
91110,
11,
442,
32178,
323,
4780,
633,
939,
67577,
438,
180... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_extract_struct_one_field_named() {
check_assist(
extract_struct_from_enum_variant,
"enum A { <|>One { foo: u32 } }",
r#"struct One{ pub foo: u32 }
enum A { One(One) }"#,
);
} | rust_cleaned_test_functions.jsonl/13104 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 141
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39123,
15126,
11667,
5013,
71834,
368,
341,
286,
1779,
12083,
380,
1006,
310,
8649,
15126,
5673,
31054,
46112,
345,
310,
330,
9018,
362,
314,
82639,
29,
3966,
314,
15229,
25,
575,
18,
17,
335,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_process_store_ok() {
solana_logger::setup();
let (bank, mint_keypair) = create_bank(10_000);
let (bank_client, config_keypair) = create_config_account(bank, &mint_keypair);
let config_pubkey = config_keypair.pubkey();
let my_config = MyConfig::new(42);
let instruction = config_instruction::store(&config_pubkey, &my_config);
let message = Message::new_with_payer(vec![instruction], Some(&mint_keypair.pubkey()));
bank_client
.send_message(&[&mint_keypair, &config_keypair], message)
.unwrap();
let config_account_data = bank_client
.get_account_data(&config_pubkey)
.unwrap()
.unwrap();
assert_eq!(
my_config,
MyConfig::deserialize(&config_account_data).unwrap()
);
} | rust_cleaned_test_functions.jsonl/23614 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 407
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11305,
14809,
19817,
368,
341,
286,
2048,
3362,
27413,
486,
15188,
543,
286,
1077,
320,
17033,
11,
28337,
3097,
12670,
8,
284,
1855,
35733,
7,
16,
15,
62,
15,
15,
15,
317,
286,
1077,
320,
1703... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_index_range() {
assert_eq!(&VECTOR3[..1], &[1]);
assert_eq!(&VECTOR3[..2], &[1, 2]);
assert_eq!(VECTOR3[..1].len(), 1);
assert_eq!(VECTOR3[..2].len(), 2);
assert_eq!(&VECTOR3[2..], &[3]);
assert_eq!(&VECTOR3[1..], &[2, 3]);
assert_eq!(VECTOR3[2..].len(), 1);
assert_eq!(VECTOR3[1..].len(), 2);
assert_eq!(&VECTOR3[..], &[1, 2, 3]);
assert_eq!(VECTOR3[..].len(), 3);
} | rust_cleaned_test_functions.jsonl/39584 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 324
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3560,
9698,
368,
341,
310,
2060,
10714,
0,
2099,
43687,
18,
95874,
16,
1125,
44590,
16,
2558,
310,
2060,
10714,
0,
2099,
43687,
18,
95874,
17,
1125,
44590,
16,
11,
220,
17,
2558,
310,
2060,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_report_update_check_failure_reason() {
let (mut reporter, mut receiver) = CobaltMetricsReporter::new_mock();
reporter
.report_metrics(Metrics::UpdateCheckFailureReason(
UpdateCheckFailureReason::Configuration,
))
.unwrap();
assert_eq!(
receiver.try_next().unwrap().unwrap(),
CobaltEvent {
metric_id: mos_metrics_registry::UPDATE_CHECK_FAILURE_METRIC_ID,
event_codes: vec![
mos_metrics_registry::UpdateCheckFailureMetricDimensionReason::Configuration
as u32
],
component: None,
payload: EventPayload::Event(fidl_fuchsia_cobalt::Event),
}
);
} | rust_cleaned_test_functions.jsonl/90998 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 426
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14813,
8882,
7200,
43618,
38229,
368,
341,
286,
1077,
320,
6984,
18960,
11,
5206,
13964,
8,
284,
45951,
3145,
27328,
52766,
486,
931,
34134,
543,
286,
18960,
198,
310,
659,
11736,
37686,
3189,
134... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_block_commitment() {
let mut cache = BlockCommitment::default();
assert_eq!(cache.get_confirmation_stake(1), 0);
cache.increase_confirmation_stake(1, 10);
assert_eq!(cache.get_confirmation_stake(1), 10);
cache.increase_confirmation_stake(1, 20);
assert_eq!(cache.get_confirmation_stake(1), 30);
} | rust_cleaned_test_functions.jsonl/21583 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 171
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7113,
36346,
478,
368,
341,
286,
1077,
5206,
6500,
284,
8362,
33441,
478,
486,
2258,
543,
286,
2060,
10714,
10297,
9360,
670,
37681,
1261,
726,
7,
16,
701,
220,
15,
317,
286,
6500,
1858,
19947,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_seq_is_empty() {
Python::with_gil(|py| {
let list = vec![1].to_object(py);
let seq = list.cast_as::<PySequence>(py).unwrap();
assert!(!seq.is_empty().unwrap());
let vec: Vec<u32> = Vec::new();
let empty_list = vec.to_object(py);
let empty_seq = empty_list.cast_as::<PySequence>(py).unwrap();
assert!(empty_seq.is_empty().unwrap());
});
} | rust_cleaned_test_functions.jsonl/70304 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 246
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14486,
6892,
15124,
368,
341,
286,
13027,
486,
4197,
1889,
321,
22428,
3288,
91,
341,
310,
1077,
1140,
284,
7486,
20703,
16,
936,
983,
5314,
46827,
317,
310,
1077,
12981,
284,
1140,
35091,
11898,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_return() {
let mut g = Gn::new_scoped(|_s| {
return 42;
});
assert_eq!(g.next(), Some(42));
assert!(g.is_done());
} | rust_cleaned_test_functions.jsonl/91409 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 85
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12511,
368,
341,
262,
1077,
5206,
342,
284,
95151,
486,
931,
13171,
16367,
22428,
62,
82,
91,
341,
286,
470,
220,
19,
17,
280,
262,
1625,
262,
2060,
10714,
10297,
70,
4529,
1507,
4329,
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 |
#[test]
fn test_icmpv6_nxthdr_unknown() {
let (mut iface, mut socket_set) = create_loopback();
let remote_ip_addr = Ipv6Address::new(0xfe80, 0, 0, 0, 0, 0, 0, 1);
let payload = [0x12, 0x34, 0x56, 0x78];
let ipv6_repr = Ipv6Repr {
src_addr: remote_ip_addr,
dst_addr: Ipv6Address::LOOPBACK,
next_header: IpProtocol::HopByHop,
payload_len: 12,
hop_limit: 0x40,
};
let mut bytes = vec![0; 52];
let frame = {
let ip_repr = IpRepr::Ipv6(ipv6_repr);
ip_repr.emit(&mut bytes, &ChecksumCapabilities::default());
let mut offset = ipv6_repr.buffer_len();
{
let mut hbh_pkt =
Ipv6HopByHopHeader::new_unchecked(&mut bytes[offset..]);
hbh_pkt.set_next_header(IpProtocol::Unknown(0x0c));
hbh_pkt.set_header_len(0);
offset += 8;
{
let mut pad_pkt = Ipv6Option::new_unchecked(&mut hbh_pkt.options_mut()[..]);
Ipv6OptionRepr::PadN(3).emit(&mut pad_pkt);
}
{
let mut pad_pkt = Ipv6Option::new_unchecked(&mut hbh_pkt.options_mut()[5..]);
Ipv6OptionRepr::Pad1.emit(&mut pad_pkt);
}
}
bytes[offset..].copy_from_slice(&payload);
Ipv6Packet::new_unchecked(&bytes)
};
let reply_icmp_repr = Icmpv6Repr::ParamProblem {
reason: Icmpv6ParamProblem::UnrecognizedNxtHdr,
pointer: 40,
header: ipv6_repr,
data: &payload[..]
};
let reply_ipv6_repr = Ipv6Repr {
src_addr: Ipv6Address::LOOPBACK,
dst_addr: remote_ip_addr,
next_header: IpProtocol::Icmpv6,
payload_len: reply_icmp_repr.buffer_len(),
hop_limit: 0x40,
};
// Ensure the unknown next header causes a ICMPv6 Parameter Problem
// error message to be sent to the sender.
assert_eq!(iface.inner.process_ipv6(&mut socket_set, Instant::from_millis(0), &frame),
Ok(Some(IpPacket::Icmpv6((reply_ipv6_repr, reply_icmp_repr)))));
} | rust_cleaned_test_functions.jsonl/100749 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1323
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
32747,
1307,
85,
21,
1089,
87,
339,
3612,
57507,
368,
341,
286,
1077,
320,
6984,
49313,
11,
5206,
7575,
2602,
8,
284,
1855,
17198,
1419,
1428,
286,
1077,
8699,
10385,
7387,
284,
358,
30168,
21,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_case_3() {
let hkdf = Hkdf {
salt: decode("").unwrap(),
ikm: decode("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b").unwrap(),
info: decode("").unwrap(),
length: 42,
hmac: ShaVariantOption::SHA256,
};
let expected_prk =
decode("19ef24a32c717b167f33a91d6f648bdf96596776afdb6377ac434c1c293ccb04").unwrap();
let expected_okm = decode(
"8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d\
9d201395faa4b61a96c8",
).unwrap();
let actual_prk = hkdf.extract(&hkdf.salt, &hkdf.ikm);
assert_eq!(actual_prk, expected_prk);
assert_eq!(hkdf.expand(&actual_prk).unwrap(), expected_okm);
assert_eq!(hkdf.derive_key().unwrap(), expected_okm);
} | rust_cleaned_test_functions.jsonl/85135 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 500
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19096,
62,
18,
368,
341,
286,
1077,
83381,
2940,
284,
472,
74,
2940,
341,
310,
12021,
25,
16895,
80821,
15454,
3148,
310,
13361,
76,
25,
16895,
445,
15,
65,
15,
65,
15,
65,
15,
65,
15,
65,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_in_values_singular() {
let mut cols = Row::new();
cols.push(Column::from("id1"));
let mut vals = Values::new(vec![]);
{
let mut row1 = Row::new();
row1.push(1);
let mut row2 = Row::new();
row2.push(2);
vals.push(row1);
vals.push(row2);
}
let query = Select::from_table("test").so_that(cols.in_selection(vals));
let (sql, params) = Sqlite::build(query).unwrap();
let expected_sql = "SELECT `test`.* FROM `test` WHERE `id1` IN (?,?)";
assert_eq!(expected_sql, sql);
assert_eq!(vec![Value::integer(1), Value::integer(2),], params)
} | rust_cleaned_test_functions.jsonl/52902 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 364
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1243,
9146,
93240,
368,
341,
286,
1077,
5206,
17000,
284,
10801,
486,
931,
543,
286,
17000,
2552,
95105,
486,
1499,
445,
307,
16,
14929,
286,
1077,
5206,
28356,
284,
24979,
486,
931,
25592,
0,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_escaped_content() {
let mut r = Reader::from_str("<a><test></a>");
r.trim_text(true);
next_eq!(r, Start, b"a");
let mut buf = Vec::new();
match r.read_event(&mut buf) {
Ok(Text(e)) => {
if &*e != b"<test>" {
panic!(
"content unexpected: expecting '<test>', got '{:?}'",
from_utf8(&*e)
);
}
match e.unescaped() {
Ok(ref c) => {
if &**c != b"<test>" {
panic!(
"unescaped content unexpected: expecting '<test<', got '{:?}'",
from_utf8(c)
)
}
}
Err(e) => panic!(
"cannot escape content at position {}: {:?}",
r.buffer_position(),
e
),
}
}
Ok(e) => panic!("Expecting text event, got {:?}", e),
Err(e) => panic!(
"Cannot get next event at position {}: {:?}",
r.buffer_position(),
e
),
}
next_eq!(r, End, b"a");
} | rust_cleaned_test_functions.jsonl/42095 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 796
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
65826,
7495,
368,
341,
262,
1077,
5206,
435,
284,
25166,
486,
1499,
2895,
9639,
64,
5789,
4832,
26,
1944,
15361,
11347,
64,
15084,
262,
435,
16419,
4326,
3715,
317,
262,
1790,
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... | 5 |
#[test]
fn test_utf16_conversion() {
let db = Connection::open_in_memory().unwrap();
db.pragma_update(None, "encoding", &"UTF-16le").unwrap();
let encoding: String = db
.pragma_query_value(None, "encoding", |row| row.get(0))
.unwrap();
assert_eq!("UTF-16le", encoding);
db.execute_batch("CREATE TABLE foo(x TEXT)").unwrap();
let expected = "テスト";
db.execute("INSERT INTO foo(x) VALUES (?)", &[&expected])
.unwrap();
let actual: String = db
.query_row("SELECT x FROM foo", NO_PARAMS, |row| row.get(0))
.unwrap();
assert_eq!(expected, actual);
} | rust_cleaned_test_functions.jsonl/57191 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 335
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39453,
16,
21,
64132,
368,
341,
286,
1077,
2927,
284,
11032,
486,
2508,
1243,
19195,
1005,
15454,
543,
286,
2927,
556,
4101,
1728,
8882,
26717,
11,
330,
17159,
497,
609,
1,
8561,
12,
16,
21,
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_bio_tags_to_slots() {
// Given
let language = Language::EN;
let slot_name = "animal";
let intent_slots_mapping = hashmap!["animal".to_string() => "animal".to_string()];
let tags: Vec<Test> = vec![
Test {
text: "".to_string(),
tags: vec![],
expected_slots: vec![],
},
Test {
text: "nothing here".to_string(),
tags: vec![OUTSIDE.to_string(), OUTSIDE.to_string()],
expected_slots: vec![],
},
Test {
text: "i am a blue bird".to_string(),
tags: vec![
OUTSIDE.to_string(),
OUTSIDE.to_string(),
OUTSIDE.to_string(),
format!("{}{}", BEGINNING_PREFIX, slot_name),
format!("{}{}", INSIDE_PREFIX, slot_name),
],
expected_slots: vec![InternalSlot {
char_range: 7..16,
value: "blue bird".to_string(),
entity: slot_name.to_string(),
slot_name: slot_name.to_string(),
}],
},
Test {
text: "i am a bird".to_string(),
tags: vec![
OUTSIDE.to_string(),
OUTSIDE.to_string(),
OUTSIDE.to_string(),
format!("{}{}", BEGINNING_PREFIX, slot_name),
],
expected_slots: vec![InternalSlot {
char_range: 7..11,
value: "bird".to_string(),
entity: slot_name.to_string(),
slot_name: slot_name.to_string(),
}],
},
Test {
text: "bird".to_string(),
tags: vec![format!("{}{}", BEGINNING_PREFIX, slot_name)],
expected_slots: vec![InternalSlot {
char_range: 0..4,
value: "bird".to_string(),
entity: slot_name.to_string(),
slot_name: slot_name.to_string(),
}],
},
Test {
text: "blue bird".to_string(),
tags: vec![
format!("{}{}", BEGINNING_PREFIX, slot_name),
format!("{}{}", INSIDE_PREFIX, slot_name),
],
expected_slots: vec![InternalSlot {
char_range: 0..9,
value: "blue bird".to_string(),
entity: slot_name.to_string(),
slot_name: slot_name.to_string(),
}],
},
Test {
text: "light blue bird blue bird".to_string(),
tags: vec![
format!("{}{}", BEGINNING_PREFIX, slot_name),
format!("{}{}", INSIDE_PREFIX, slot_name),
format!("{}{}", INSIDE_PREFIX, slot_name),
format!("{}{}", BEGINNING_PREFIX, slot_name),
format!("{}{}", INSIDE_PREFIX, slot_name),
],
expected_slots: vec![
InternalSlot {
char_range: 0..15,
value: "light blue bird".to_string(),
entity: slot_name.to_string(),
slot_name: slot_name.to_string(),
},
InternalSlot {
char_range: 16..25,
value: "blue bird".to_string(),
entity: slot_name.to_string(),
slot_name: slot_name.to_string(),
},
],
},
Test {
text: "bird birdy".to_string(),
tags: vec![
format!("{}{}", BEGINNING_PREFIX, slot_name),
format!("{}{}", BEGINNING_PREFIX, slot_name),
],
expected_slots: vec![
InternalSlot {
char_range: 0..4,
value: "bird".to_string(),
entity: slot_name.to_string(),
slot_name: slot_name.to_string(),
},
InternalSlot {
char_range: 5..10,
value: "birdy".to_string(),
entity: slot_name.to_string(),
slot_name: slot_name.to_string(),
},
],
},
Test {
text: "blue bird and white bird".to_string(),
tags: vec![
format!("{}{}", BEGINNING_PREFIX, slot_name),
format!("{}{}", INSIDE_PREFIX, slot_name),
OUTSIDE.to_string(),
format!("{}{}", INSIDE_PREFIX, slot_name),
format!("{}{}", INSIDE_PREFIX, slot_name),
],
expected_slots: vec![
InternalSlot {
char_range: 0..9,
value: "blue bird".to_string(),
entity: slot_name.to_string(),
slot_name: slot_name.to_string(),
},
InternalSlot {
char_range: 14..24,
value: "white bird".to_string(),
entity: slot_name.to_string(),
slot_name: slot_name.to_string(),
},
],
},
];
for data in tags {
// When
let slots = tags_to_slots(
&data.text,
&tokenize(&data.text, language),
&data.tags,
TaggingScheme::BIO,
&intent_slots_mapping,
)
.unwrap();
// Then
assert_eq!(slots, data.expected_slots);
}
} | rust_cleaned_test_functions.jsonl/55312 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 3918
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
89641,
16333,
2346,
54161,
368,
341,
286,
442,
16246,
198,
286,
1077,
4128,
284,
11434,
486,
953,
280,
286,
1077,
9446,
1269,
284,
330,
47899,
876,
286,
1077,
7385,
54161,
26930,
284,
92148,
0,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_metadata_custom_plugin_with_dataclass() {
let md = pb::SummaryMetadata {
plugin_data: Some(PluginData {
plugin_name: "myplugin".to_string(),
content: Bytes::from_static(b"mycontent"),
..Default::default()
}),
data_class: pb::DataClass::Tensor.into(),
..Default::default()
};
let v = SummaryValue(Box::new(Value::SimpleValue(0.125)));
let result = v.initial_metadata(Some(md.clone()));
assert_eq!(*result, md);
} | rust_cleaned_test_functions.jsonl/6227 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 351
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
22220,
15875,
23110,
6615,
1769,
1040,
368,
341,
310,
1077,
10688,
284,
17310,
486,
19237,
14610,
341,
394,
9006,
1769,
25,
4329,
7,
11546,
1043,
341,
503,
9006,
1269,
25,
330,
2408,
9138,
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_compression_level_conversion() {
// predefined compression levels
assert_eq!(CompressionLevel::Uncompressed.convert().unwrap(), 0);
assert_eq!(CompressionLevel::Fastest.convert().unwrap(), 1);
assert_eq!(CompressionLevel::Maximum.convert().unwrap(), 9);
// numeric compression levels
for level in 0..=9 {
assert_eq!(CompressionLevel::Level(level).convert().unwrap(), level);
}
// invalid levels
assert!(CompressionLevel::Level(10).convert().is_err());
} | rust_cleaned_test_functions.jsonl/34038 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 232
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2965,
4011,
8274,
64132,
368,
341,
286,
442,
63062,
25111,
5866,
198,
286,
2060,
10714,
10297,
81411,
4449,
486,
1806,
45703,
24012,
1005,
15454,
1507,
220,
15,
317,
286,
2060,
10714,
10297,
81411,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_memtables_merge_append_neighbor() {
let first_rid = 17;
let mut last_rid = first_rid;
let mut batches = vec![
LogItemBatch::with_capacity(0),
LogItemBatch::with_capacity(0),
LogItemBatch::with_capacity(0),
];
let files: Vec<_> = (0..batches.len())
.map(|i| FileId::new(LogQueue::Append, 10 + i as u64))
.collect();
batches[0].put(last_rid, b"key1".to_vec(), b"val1".to_vec());
batches[1].delete(last_rid, b"key1".to_vec());
batches[2].put(last_rid, b"key1".to_vec(), b"val2".to_vec());
last_rid += 1;
batches[0].put(last_rid, b"key".to_vec(), b"ANYTHING".to_vec());
batches[1].add_command(last_rid, Command::Clean);
last_rid += 1;
batches[0].add_entry_indexes(last_rid, generate_entry_indexes(1, 11, files[0]));
batches[1].add_command(last_rid, Command::Compact { index: 5 });
batches[2].add_entry_indexes(last_rid, generate_entry_indexes(11, 21, files[2]));
for b in batches.iter_mut() {
b.finish_write(FileBlockHandle::dummy(LogQueue::Append));
}
// reverse merge
let mut ctxs = VecDeque::default();
for (batch, file_id) in batches.clone().into_iter().zip(files) {
let mut ctx = MemTableRecoverContext::default();
ctx.replay(batch, file_id).unwrap();
ctxs.push_back(ctx);
}
while ctxs.len() > 1 {
let (y, mut x) = (ctxs.pop_back().unwrap(), ctxs.pop_back().unwrap());
x.merge(y, LogQueue::Append).unwrap();
ctxs.push_back(x);
}
let (merged_memtables, merged_global_stats) = ctxs.pop_front().unwrap().finish();
// sequential apply
let sequential_global_stats = Arc::new(GlobalStats::default());
let sequential_memtables = MemTableAccessor::new(sequential_global_stats.clone());
for mut batch in batches.clone() {
sequential_memtables.apply(batch.drain(), LogQueue::Append);
}
for rid in first_rid..=last_rid {
let m = merged_memtables.get(rid);
let s = sequential_memtables.get(rid);
if m.is_none() {
assert!(s.is_none());
continue;
}
let merged = m.as_ref().unwrap().read();
let sequential = s.as_ref().unwrap().read();
let mut merged_vec = Vec::new();
let mut sequential_vec = Vec::new();
merged
.fetch_entry_indexes_before(u64::MAX, &mut merged_vec)
.unwrap();
sequential
.fetch_entry_indexes_before(u64::MAX, &mut sequential_vec)
.unwrap();
assert_eq!(merged_vec, sequential_vec);
merged_vec.clear();
sequential_vec.clear();
merged
.fetch_rewritten_entry_indexes(&mut merged_vec)
.unwrap();
sequential
.fetch_rewritten_entry_indexes(&mut sequential_vec)
.unwrap();
assert_eq!(merged_vec, sequential_vec);
let mut merged_vec = Vec::new();
let mut sequential_vec = Vec::new();
merged.fetch_kvs_before(u64::MAX, &mut merged_vec);
sequential.fetch_kvs_before(u64::MAX, &mut sequential_vec);
assert_eq!(merged_vec, sequential_vec);
merged_vec.clear();
sequential_vec.clear();
merged.fetch_rewritten_kvs(&mut merged_vec);
sequential.fetch_rewritten_kvs(&mut sequential_vec);
assert_eq!(merged_vec, sequential_vec);
}
assert_eq!(
merged_global_stats.live_entries(LogQueue::Append),
sequential_global_stats.live_entries(LogQueue::Append),
);
assert_eq!(
merged_global_stats.rewrite_entries(),
sequential_global_stats.rewrite_entries(),
);
assert_eq!(
merged_global_stats.deleted_rewrite_entries(),
sequential_global_stats.deleted_rewrite_entries(),
);
} | rust_cleaned_test_functions.jsonl/18148 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2129
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12976,
32110,
20888,
26041,
71888,
368,
341,
286,
1077,
1156,
1710,
307,
284,
220,
16,
22,
280,
286,
1077,
5206,
1537,
1710,
307,
284,
1156,
1710,
307,
401,
286,
1077,
5206,
44792,
284,
7486,
90... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_max_profit() {
let prices = vec![1, 3, 7];
assert_eq!(max_profit(prices), 6);
let prices = vec![2, 3, 7, 1, 9];
assert_eq!(max_profit(prices), 8);
} | rust_cleaned_test_functions.jsonl/94591 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 112
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6345,
72042,
368,
341,
286,
1077,
7576,
284,
7486,
20703,
16,
11,
220,
18,
11,
220,
22,
935,
286,
2060,
10714,
10297,
2810,
72042,
24974,
1216,
701,
220,
21,
317,
286,
1077,
7576,
284,
7486,
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_linuxcontainer_pause() {
let ret = new_linux_container_and_then(|mut c: LinuxContainer| {
c.cgroup_manager = FsManager::new("").ok();
c.pause().map_err(|e| anyhow!(e))
});
assert!(ret.is_ok(), "Expecting Ok, Got {:?}", ret);
} | rust_cleaned_test_functions.jsonl/16618 | {
"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,
77463,
3586,
59989,
368,
341,
286,
1077,
2112,
284,
501,
77463,
15847,
8378,
68367,
22428,
6984,
272,
25,
14340,
4502,
91,
341,
310,
272,
520,
4074,
12144,
284,
84619,
2043,
486,
931,
80821,
562,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_into_bits() {
let mut rng = XorShiftRng::from_seed([
0x59, 0x62, 0xbe, 0x3d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06,
0xbc, 0xe5,
]);
for i in 0..200 {
let r = Scalar::random(&mut rng);
let mut cs = TestConstraintSystem::new();
let n = AllocatedNum::alloc(&mut cs, || Ok(r)).unwrap();
let bits = if i % 2 == 0 {
n.to_bits_le(&mut cs).unwrap()
} else {
n.to_bits_le_strict(&mut cs).unwrap()
};
assert!(cs.is_satisfied());
for (b, a) in r
.to_le_bits()
.iter()
.by_vals()
.rev()
.skip(1)
.zip(bits.iter().rev())
{
if let Boolean::Is(ref a) = a {
assert_eq!(b, a.get_value().unwrap());
} else {
unreachable!()
}
}
cs.set("num", Scalar::random(&mut rng));
assert!(!cs.is_satisfied());
cs.set("num", r);
assert!(cs.is_satisfied());
for i in 0..Scalar::NUM_BITS {
let name = format!("bit {}/boolean", i);
let cur = cs.get(&name);
let mut tmp = Scalar::one();
tmp.sub_assign(&cur);
cs.set(&name, tmp);
assert!(!cs.is_satisfied());
cs.set(&name, cur);
assert!(cs.is_satisfied());
}
}
} | rust_cleaned_test_functions.jsonl/119282 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1027
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
45514,
20034,
368,
341,
286,
1077,
5206,
28422,
284,
1599,
269,
24841,
49,
968,
486,
1499,
33809,
8956,
310,
220,
15,
87,
20,
24,
11,
220,
15,
87,
21,
17,
11,
220,
15,
42459,
11,
220,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
#[test]
fn test_dt_to_string() {
let dt = Utc.ymd(2021, 7, 8).and_hms(8, 10, 11); // `2021-07-08T08:10:11Z`
let dt_string = dt_to_string(&dt);
assert_eq!(dt_string, String::from("2021-07-08 08:10:11+00"));
} | rust_cleaned_test_functions.jsonl/78037 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 137
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
27516,
2346,
3904,
368,
341,
286,
1077,
7594,
284,
547,
10413,
13,
1600,
67,
7,
17,
15,
17,
16,
11,
220,
22,
11,
220,
23,
568,
437,
1523,
1011,
7,
23,
11,
220,
16,
15,
11,
220,
16,
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_scale_zero() {
let quad = BoundedQuadratic::new(2.5, 5., 1., -5., 6.);
quad.scale_arg(0.);
} | rust_cleaned_test_functions.jsonl/19873 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 74
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16727,
19359,
368,
341,
286,
1077,
27082,
284,
425,
13082,
2183,
88678,
486,
931,
7,
17,
13,
20,
11,
220,
20,
2572,
220,
16,
2572,
481,
20,
2572,
220,
21,
58957,
286,
27082,
17266,
6057,
7,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_remove() {
let points = create_random_points(1000, SEED_1);
let offsets = create_random_points(1000, SEED_2);
let scaled = offsets.iter().map(|p| p.mul(0.05));
let edges: Vec<_> = points
.iter()
.zip(scaled)
.map(|(from, offset)| Line::new(*from, from.add(&offset)))
.collect();
let mut tree = RTree::bulk_load(edges.clone());
for edge in &edges {
let size_before_removal = tree.size();
assert!(tree.remove(edge).is_some());
assert!(tree.remove(edge).is_none());
assert_eq!(size_before_removal - 1, tree.size());
}
} | rust_cleaned_test_functions.jsonl/24151 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 349
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18193,
368,
341,
286,
1077,
3501,
284,
1855,
22644,
12928,
7,
16,
15,
15,
15,
11,
5052,
1479,
62,
16,
317,
286,
1077,
35046,
284,
1855,
22644,
12928,
7,
16,
15,
15,
15,
11,
5052,
1479,
62,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_destroy_peer_on_pending_snapshot() {
let _guard = crate::setup();
let mut cluster = new_server_cluster(0, 4);
configure_for_snapshot(&mut cluster);
let pd_client = Arc::clone(&cluster.pd_client);
pd_client.disable_default_operator();
let r1 = cluster.run_conf_change();
pd_client.must_add_peer(r1, new_peer(2, 2));
pd_client.must_add_peer(r1, new_peer(3, 3));
cluster.must_put(b"k1", b"v1");
// Ensure peer 3 is initialized.
must_get_equal(&cluster.get_engine(3), b"k1", b"v1");
cluster.must_transfer_leader(1, new_peer(1, 1));
cluster.add_send_filter(IsolationFilterFactory::new(3));
for i in 0..20 {
cluster.must_put(format!("k1{}", i).as_bytes(), b"v1");
}
let apply_snapshot_fp = "apply_pending_snapshot";
fail::cfg(apply_snapshot_fp, "return()").unwrap();
cluster.clear_send_filters();
// Wait for leader send snapshot.
sleep_ms(100);
cluster.add_send_filter(IsolationFilterFactory::new(3));
pd_client.must_remove_peer(r1, new_peer(3, 3));
pd_client.must_add_peer(r1, new_peer(4, 4));
pd_client.must_remove_peer(r1, new_peer(4, 4));
pd_client.must_add_peer(r1, new_peer(3, 5));
let destroy_peer_fp = "destroy_peer";
fail::cfg(destroy_peer_fp, "pause").unwrap();
cluster.clear_send_filters();
// Wait for leader send msg to peer 3.
// Then destroy peer 3 and create peer 5.
sleep_ms(100);
fail::remove(destroy_peer_fp);
fail::remove(apply_snapshot_fp);
must_get_equal(&cluster.get_engine(3), b"k119", b"v1");
} | rust_cleaned_test_functions.jsonl/80895 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 682
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18066,
45159,
4470,
37861,
53265,
368,
341,
262,
1077,
716,
26098,
284,
17717,
486,
15188,
1428,
262,
1077,
5206,
10652,
284,
501,
12015,
28441,
7,
15,
11,
220,
19,
317,
262,
14411,
5478,
53265,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_nonatomic() -> Result<()> {
let query: Item = from_str(
r###"
Query:
items:
- Pipeline:
- From: employees
- Take: 20
- Filter:
- Ident: country
- Raw: "="
- String: USA
- Aggregate:
by:
- Ident: title
- Ident: country
calcs:
- Terms:
- Ident: average
- Ident: salary
assigns: []
- Aggregate:
by:
- Ident: title
- Ident: country
calcs:
- Terms:
- Ident: average
- Ident: salary
assigns: []
- Sort:
- Ident: sum_gross_cost
"###,
)?;
assert_display_snapshot!((translate(&query)?), @r###"
WITH table_0 AS (
SELECT
TOP (20) *
FROM
employees
),
table_1 AS (
SELECT
title,
country,
average salary
FROM
table_0
WHERE
country = 'USA'
GROUP BY
title,
country
),
table_2 AS (
SELECT
title,
country,
average salary
FROM
table_1
GROUP BY
title,
country
ORDER BY
sum_gross_cost
)
SELECT
*
FROM
table_2
"###);
Ok(())
} | rust_cleaned_test_functions.jsonl/64114 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 956
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21637,
6618,
368,
1464,
5714,
71698,
341,
1789,
286,
1077,
3239,
25,
5739,
284,
504,
2895,
1006,
310,
435,
14374,
698,
2859,
510,
220,
3589,
510,
262,
481,
40907,
510,
414,
481,
5542,
25,
8256,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_cluster_partition_1_2() {
let empty = |_: &mut LocalCluster, _: &mut ()| {};
let on_partition_resolved = |cluster: &mut LocalCluster, _: &mut ()| {
cluster.check_for_new_roots(16, "PARTITION_TEST", SocketAddrSpace::Unspecified);
};
run_cluster_partition(
&[vec![1], vec![1, 1]],
None,
(),
empty,
empty,
on_partition_resolved,
None,
None,
vec![],
)
} | rust_cleaned_test_functions.jsonl/31897 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 248
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28441,
43840,
62,
16,
62,
17,
368,
341,
262,
1077,
4287,
284,
760,
23211,
609,
6984,
8774,
28678,
11,
58536,
609,
6984,
1719,
91,
9321,
262,
1077,
389,
43840,
4918,
8731,
284,
760,
18855,
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_visited_goals() {
let mut goals = VisitedGoals::default();
let tp_name = TypeName::new("T");
let ty_int = Ty::int(NReason::none());
let added_super = goals.try_add_visited_generic_sub(tp_name, &ty_int);
assert!(matches!(added_super, GoalResult::NewGoal));
} | rust_cleaned_test_functions.jsonl/14535 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 148
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
96729,
96244,
368,
341,
286,
1077,
5206,
8845,
284,
7656,
1608,
93817,
486,
2258,
543,
286,
1077,
18101,
1269,
284,
97725,
486,
931,
445,
51,
797,
286,
1077,
13580,
4042,
284,
13897,
486,
396,
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_internally_tagged_struct_variant_containing_unit_variant() {
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub enum Level {
Info,
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "action")]
pub enum Message {
Log { level: Level },
}
assert_de_tokens(
&Message::Log { level: Level::Info },
&[
Token::Struct {
name: "Message",
len: 2,
},
Token::Str("action"),
Token::Str("Log"),
Token::Str("level"),
Token::BorrowedStr("Info"),
Token::StructEnd,
],
);
} | rust_cleaned_test_functions.jsonl/56438 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 361
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4042,
932,
745,
9372,
3556,
15126,
46112,
10260,
2056,
14832,
46112,
368,
341,
262,
11506,
27098,
42618,
11,
55039,
11,
39900,
11,
48440,
5563,
262,
6675,
7618,
9395,
341,
286,
13074,
345,
262,
55... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_get_open_fds() -> Result<()> {
let file = fs::File::open("/dev/null")?;
let fd = file.as_raw_fd();
let open_fds = LinuxSyscall::get_open_fds()?;
if !open_fds.iter().any(|&v| v == fd) {
bail!("failed to find the opened dev null fds: {:?}", open_fds);
}
// explicitly close the file before the test case returns.
drop(file);
// The stdio fds should also be contained in the list of opened fds.
if !vec![0, 1, 2]
.iter()
.all(|&stdio_fd| open_fds.iter().any(|&open_fd| open_fd == stdio_fd))
{
bail!("failed to find the stdio fds: {:?}", open_fds);
}
Ok(())
} | rust_cleaned_test_functions.jsonl/84395 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 374
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
11311,
90438,
368,
1464,
5714,
71698,
341,
286,
1077,
1034,
284,
8619,
486,
1703,
486,
2508,
4283,
3583,
19293,
899,
37445,
286,
1077,
12414,
284,
1034,
5357,
16067,
17676,
543,
286,
1077,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
#[test]
fn test_record_complete_builder() {
use super::{Level, Record};
let target = "myApp";
let record_test = Record::builder()
.module_path(Some("foo"))
.file(Some("bar"))
.line(Some(30))
.target(target)
.level(Level::Error)
.build();
assert_eq!(record_test.target(), "myApp");
assert_eq!(record_test.level(), Level::Error);
assert_eq!(record_test.module_path(), Some("foo"));
assert_eq!(record_test.file(), Some("bar"));
assert_eq!(record_test.line(), Some(30));
} | rust_cleaned_test_functions.jsonl/71741 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 303
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14192,
27675,
28532,
368,
341,
286,
990,
2256,
22964,
4449,
11,
13583,
2440,
286,
1077,
2169,
284,
330,
2408,
2164,
876,
286,
1077,
3255,
4452,
284,
13583,
486,
17850,
741,
310,
659,
4352,
2638,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_return_error_from_highest_priority_nameserver() {
use trust_dns_proto::op::ResponseCode;
use trust_dns_resolver::error::ResolveErrorKind;
let query = Query::query(Name::from_str("www.example.").unwrap(), RecordType::A);
const ERROR_RESPONSE_CODES: [ResponseCode; 4] = [
ResponseCode::ServFail,
ResponseCode::Refused,
ResponseCode::FormErr,
ResponseCode::NotImp,
];
let name_servers = ERROR_RESPONSE_CODES
.iter()
.map(|response_code| {
let mut error_message = message(query.clone(), vec![], vec![], vec![]);
error_message.set_response_code(*response_code);
let response = ResolveError::from_response(error_message.into(), true)
.expect_err("error code should result in resolve error");
mock_nameserver(vec![Err(response)], ResolverOpts::default())
})
.collect();
let mut pool = mock_nameserver_pool(name_servers, vec![], None, ResolverOpts::default());
let request = message(query, vec![], vec![], vec![]);
let future = pool.send(request).first_answer();
let error = block_on(future).expect_err(
"DNS query should result in a `ResolveError` since all name servers return error responses",
);
let expected_response_code = ERROR_RESPONSE_CODES.first().unwrap();
match error.kind() {
ResolveErrorKind::NoRecordsFound { response_code, .. }
if response_code == expected_response_code => {}
kind => panic!(
"got unexpected kind of resolve error; expected `NoRecordsFound` error with response \
code `{:?}`, got {:#?}",
expected_response_code, kind,
),
}
} | rust_cleaned_test_functions.jsonl/86471 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 721
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12511,
4096,
5673,
1523,
7504,
38161,
9187,
2836,
368,
341,
262,
990,
6950,
71125,
37689,
486,
453,
486,
2582,
2078,
280,
262,
990,
6950,
71125,
91578,
486,
841,
486,
56808,
1454,
10629,
401,
262,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_rope_leaf_at() {
let rope = Rope::new(String::from("first"), 1);
let rope = rope.concat(Rope::new(String::from("second"), 2));
let rope = rope.concat(Rope::new(String::from("third"), 3));
assert_eq!(rope.leaf_at(2).hl_id, 1);
assert_eq!(rope.leaf_at(0).hl_id, 1);
assert_eq!(rope.leaf_at(5).hl_id, 1);
assert_eq!(rope.leaf_at(6).hl_id, 2);
assert_eq!(rope.leaf_at(8).hl_id, 2);
assert_eq!(rope.leaf_at(11).hl_id, 2);
assert_eq!(rope.leaf_at(13).hl_id, 3);
} | rust_cleaned_test_functions.jsonl/14033 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 305
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26608,
375,
38909,
3752,
368,
341,
286,
1077,
33420,
284,
97896,
486,
931,
2242,
486,
1499,
445,
3896,
3975,
220,
16,
317,
286,
1077,
33420,
284,
33420,
15256,
2785,
2792,
486,
931,
2242,
486,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_test_failure_incorrect_value() {
let test = Patch::Test {
value: json!(123),
path: Path::new("/a/c"),
};
let root = json!({
"a": {
"b": 123,
"c": 234,
},
"b": [1],
});
assert!(matches!(apply_single(root, test), Err(Error::FailedTest)));
} | rust_cleaned_test_functions.jsonl/52520 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 240
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4452,
43618,
1243,
19928,
3142,
368,
341,
286,
1077,
1273,
284,
30412,
486,
2271,
341,
310,
897,
25,
2951,
10297,
16,
17,
18,
1326,
310,
1815,
25,
7933,
486,
931,
4283,
64,
2899,
4461,
286,
36... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_eq() {
let mut m1 = HashMap::new();
m1.insert(1, 2);
m1.insert(2, 3);
m1.insert(3, 4);
let mut m2 = HashMap::new();
m2.insert(1, 2);
m2.insert(2, 3);
assert!(!m1.par_eq(&m2));
m2.insert(3, 4);
assert!(m1.par_eq(&m2));
} | rust_cleaned_test_functions.jsonl/45217 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 203
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10714,
368,
341,
286,
1077,
5206,
296,
16,
284,
10528,
486,
931,
543,
286,
296,
16,
7030,
7,
16,
11,
220,
17,
317,
286,
296,
16,
7030,
7,
17,
11,
220,
18,
317,
286,
296,
16,
7030,
7,
18,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ban_pass() {
let _ =
tracing::subscriber::set_default(tracing_subscriber::fmt().with_test_writer().finish());
let events = INITIAL_EVENTS();
let auth_events = events
.values()
.map(|ev| {
((ev.event_type().to_owned(), ev.state_key().unwrap().to_owned()), Arc::clone(ev))
})
.collect::<StateMap<_>>();
let requester = to_pdu_event(
"HELLO",
alice(),
EventType::RoomMember,
Some(charlie().as_str()),
member_content_ban(),
&[],
&["IMC"],
);
let fetch_state = |ty, key| auth_events.get(&(ty, key)).cloned();
let target_user = charlie();
let sender = alice();
assert!(valid_membership_change(
&RoomVersion::V6,
&target_user,
fetch_state(EventType::RoomMember, target_user.to_string()),
&sender,
fetch_state(EventType::RoomMember, sender.to_string()),
&requester,
None::<StateEvent>,
fetch_state(EventType::RoomPowerLevels, "".to_owned()),
fetch_state(EventType::RoomJoinRules, "".to_owned()),
None,
None,
fetch_state(EventType::RoomCreate, "".to_owned()).unwrap(),
)
.unwrap());
} | rust_cleaned_test_functions.jsonl/47144 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 743
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
880,
276,
15464,
368,
341,
286,
1077,
716,
4035,
310,
45415,
486,
59205,
486,
746,
9993,
7624,
4527,
5228,
20351,
486,
12501,
1005,
4197,
4452,
28908,
1005,
30150,
1423,
286,
1077,
4357,
284,
5685... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_fold_logical_op_2() {
fold("x = foo() || true || bar()", "x = foo() || true");
fold("x = foo() || true && bar()", "x = foo() || bar()");
fold("x = foo() || false && bar()", "x = foo() || false");
fold("x = foo() && false && bar()", "x = foo() && false");
fold("x = foo() && false || bar()", "x = (foo() && false,bar())");
fold("x = foo() || false || bar()", "x = foo() || bar()");
fold("x = foo() && true && bar()", "x = foo() && bar()");
fold("x = foo() || true || bar()", "x = foo() || true");
fold("x = foo() && false && bar()", "x = foo() && false");
fold("x = foo() && 0 && bar()", "x = foo() && 0");
fold("x = foo() && 1 && bar()", "x = foo() && bar()");
fold("x = foo() || 0 || bar()", "x = foo() || bar()");
fold("x = foo() || 1 || bar()", "x = foo() || 1");
fold_same("x = foo() || bar() || baz()");
fold_same("x = foo() && bar() && baz()");
fold("0 || b()", "b()");
fold("1 && b()", "b()");
fold("a() && (1 && b())", "a() && b()");
fold("(a() && 1) && b()", "a() && b()");
fold("(x || '') || y;", "x || y");
fold("false || (x || '');", "x || ''");
fold("(x && 1) && y;", "x && y");
fold("true && (x && 1);", "x && 1");
fold_same("x = foo() && true || bar()");
fold_same("foo() && true || bar()");
} | rust_cleaned_test_functions.jsonl/122170 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 604
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
61187,
86484,
10287,
62,
17,
368,
341,
262,
11555,
445,
87,
284,
15229,
368,
1369,
830,
1369,
3619,
50514,
330,
87,
284,
15229,
368,
1369,
830,
797,
262,
11555,
445,
87,
284,
15229,
368,
1369,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_dec_as_int_with_overflow() {
let cases = vec![
(
0,
vec![Datum::Dec(
Decimal::from_f64(i64::MAX as f64 + 100.5).unwrap(),
)],
i64::MAX,
),
(
types::UNSIGNED_FLAG,
vec![Datum::Dec(
Decimal::from_f64(u64::MAX as f64 + 100.5).unwrap(),
)],
u64::MAX as i64,
),
];
for (flag, cols, exp) in cases {
let mut col_expr = col_expr(0, i32::from(types::NEW_DECIMAL));
let mut ex = scalar_func_expr(ScalarFuncSig::CastDecimalAsInt, &[col_expr]);
ex.mut_field_type().set_flag(flag as u32);
// test with overflow as warning
let mut ctx =
EvalContext::new(Arc::new(EvalConfig::new().set_overflow_as_warning(true)));
let e = Expression::build(&mut ctx, ex.clone()).unwrap();
let res = e.eval_int(&mut ctx, &cols).unwrap().unwrap();
assert_eq!(res, exp);
assert_eq!(ctx.warnings.warning_cnt, 1);
assert_eq!(
ctx.warnings.warnings[0].get_code(),
ERR_TRUNCATE_WRONG_VALUE
);
// test overflow as error
ctx = EvalContext::new(Arc::new(EvalConfig::default()));
let e = Expression::build(&mut ctx, ex).unwrap();
let res = e.eval_int(&mut ctx, &cols);
assert!(res.is_err());
}
} | rust_cleaned_test_functions.jsonl/38160 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 910
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13783,
11898,
4042,
6615,
79073,
368,
341,
286,
1077,
5048,
284,
7486,
90515,
310,
2399,
394,
220,
15,
345,
394,
7486,
20703,
68036,
486,
4900,
1006,
503,
26728,
486,
1499,
761,
21,
19,
1956,
21... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_append() {
Python::with_gil(|py| {
let list = PyList::new(py, &[2]);
list.append(3).unwrap();
assert_eq!(2, list[0].extract::<i32>().unwrap());
assert_eq!(3, list[1].extract::<i32>().unwrap());
});
} | rust_cleaned_test_functions.jsonl/108626 | {
"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,
26041,
368,
341,
286,
13027,
486,
4197,
1889,
321,
22428,
3288,
91,
341,
310,
1077,
1140,
284,
5355,
852,
486,
931,
46827,
11,
44590,
17,
2558,
310,
1140,
2057,
7,
18,
568,
15454,
543,
310,
20... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_store_account_stress() {
let slot = 42;
let num_threads = 2;
let min_file_bytes = std::mem::size_of::<StoredMeta>()
+ std::mem::size_of::<crate::append_vec::AccountMeta>();
let db = Arc::new(AccountsDb::new_sized(Vec::new(), min_file_bytes as u64));
db.add_root(slot);
let thread_hdls: Vec<_> = (0..num_threads)
.map(|_| {
let db = db.clone();
std::thread::Builder::new()
.name("account-writers".to_string())
.spawn(move || {
let pubkey = solana_sdk::pubkey::new_rand();
let mut account = AccountSharedData::new(1, 0, &pubkey);
let mut i = 0;
loop {
let account_bal = thread_rng().gen_range(1, 99);
account.set_lamports(account_bal);
db.store_uncached(slot, &[(&pubkey, &account)]);
let (account, slot) = db
.load_without_fixed_root(&Ancestors::default(), &pubkey)
.unwrap_or_else(|| {
panic!("Could not fetch stored account {}, iter {}", pubkey, i)
});
assert_eq!(slot, slot);
assert_eq!(account.lamports(), account_bal);
i += 1;
}
})
.unwrap()
})
.collect();
for t in thread_hdls {
t.join().unwrap();
}
} | rust_cleaned_test_functions.jsonl/1365 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1060
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14809,
13500,
1261,
673,
368,
341,
286,
1077,
9446,
284,
220,
19,
17,
280,
286,
1077,
1629,
29725,
284,
220,
17,
401,
286,
1077,
1308,
2458,
12524,
284,
1460,
486,
10536,
486,
2141,
3575,
27638,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
#[test]
fn test_fidelio_config() {
let (causet, _dir) = EINSTEINDBConfig::with_tmp().unwrap();
let causet_controller = ConfigController::new(causet);
let mut causet = causet_controller.get_current().clone();
// normal fidelio
causet_controller
.fidelio(change("violetabftstore.violetabft-log-gc-memory_barrier", "2000"))
.unwrap();
causet.violetabft_store.violetabft_log_gc_memory_barrier = 2000;
assert_eq!(causet_controller.get_current(), causet);
// fidelio not support config
let res = causet_controller.fidelio(change("server.addr", "localhost:3000"));
assert!(res.is_err());
assert_eq!(causet_controller.get_current(), causet);
// fidelio to invalid config
let res = causet_controller.fidelio(change("violetabftstore.violetabft-log-gc-memory_barrier", "0"));
assert!(res.is_err());
assert_eq!(causet_controller.get_current(), causet);
// bad fidelio request
let res = causet_controller.fidelio(change("xxx.yyy", "0"));
assert!(res.is_err());
let res = causet_controller.fidelio(change("violetabftstore.xxx", "0"));
assert!(res.is_err());
let res = causet_controller.fidelio(change("violetabftstore.violetabft-log-gc-memory_barrier", "10MB"));
assert!(res.is_err());
let res = causet_controller.fidelio(change("violetabft-log-gc-memory_barrier", "10MB"));
assert!(res.is_err());
assert_eq!(causet_controller.get_current(), causet);
} | rust_cleaned_test_functions.jsonl/7497 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 593
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
761,
26802,
815,
5332,
368,
341,
262,
1077,
320,
924,
18187,
11,
716,
3741,
8,
284,
468,
687,
58684,
687,
3506,
2648,
486,
4197,
16125,
1005,
15454,
543,
262,
1077,
2162,
18187,
21600,
284,
5532... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_decoder_request() {
fn parse(s: &str) -> ParsedMessage<RequestLine> {
let mut bytes = BytesMut::from(s);
Server::parse(
&mut bytes,
ParseContext {
cached_headers: &mut None,
req_method: &mut None,
h1_parser_config: Default::default(),
h1_header_read_timeout: None,
h1_header_read_timeout_fut: &mut None,
h1_header_read_timeout_running: &mut false,
preserve_header_case: false,
h09_responses: false,
#[cfg(feature = "ffi")]
on_informational: &mut None,
#[cfg(feature = "ffi")]
raw_headers: false,
},
)
.expect("parse ok")
.expect("parse complete")
}
fn parse_err(s: &str, comment: &str) -> crate::error::Parse {
let mut bytes = BytesMut::from(s);
Server::parse(
&mut bytes,
ParseContext {
cached_headers: &mut None,
req_method: &mut None,
h1_parser_config: Default::default(),
h1_header_read_timeout: None,
h1_header_read_timeout_fut: &mut None,
h1_header_read_timeout_running: &mut false,
preserve_header_case: false,
h09_responses: false,
#[cfg(feature = "ffi")]
on_informational: &mut None,
#[cfg(feature = "ffi")]
raw_headers: false,
},
)
.expect_err(comment)
}
// no length or transfer-encoding means 0-length body
assert_eq!(
parse(
"\
GET / HTTP/1.1\r\n\
\r\n\
"
)
.decode,
DecodedLength::ZERO
);
assert_eq!(
parse(
"\
POST / HTTP/1.1\r\n\
\r\n\
"
)
.decode,
DecodedLength::ZERO
);
// transfer-encoding: chunked
assert_eq!(
parse(
"\
POST / HTTP/1.1\r\n\
transfer-encoding: chunked\r\n\
\r\n\
"
)
.decode,
DecodedLength::CHUNKED
);
assert_eq!(
parse(
"\
POST / HTTP/1.1\r\n\
transfer-encoding: gzip, chunked\r\n\
\r\n\
"
)
.decode,
DecodedLength::CHUNKED
);
assert_eq!(
parse(
"\
POST / HTTP/1.1\r\n\
transfer-encoding: gzip\r\n\
transfer-encoding: chunked\r\n\
\r\n\
"
)
.decode,
DecodedLength::CHUNKED
);
// content-length
assert_eq!(
parse(
"\
POST / HTTP/1.1\r\n\
content-length: 10\r\n\
\r\n\
"
)
.decode,
DecodedLength::new(10)
);
// transfer-encoding and content-length = chunked
assert_eq!(
parse(
"\
POST / HTTP/1.1\r\n\
content-length: 10\r\n\
transfer-encoding: chunked\r\n\
\r\n\
"
)
.decode,
DecodedLength::CHUNKED
);
assert_eq!(
parse(
"\
POST / HTTP/1.1\r\n\
transfer-encoding: chunked\r\n\
content-length: 10\r\n\
\r\n\
"
)
.decode,
DecodedLength::CHUNKED
);
assert_eq!(
parse(
"\
POST / HTTP/1.1\r\n\
transfer-encoding: gzip\r\n\
content-length: 10\r\n\
transfer-encoding: chunked\r\n\
\r\n\
"
)
.decode,
DecodedLength::CHUNKED
);
// multiple content-lengths of same value are fine
assert_eq!(
parse(
"\
POST / HTTP/1.1\r\n\
content-length: 10\r\n\
content-length: 10\r\n\
\r\n\
"
)
.decode,
DecodedLength::new(10)
);
// multiple content-lengths with different values is an error
parse_err(
"\
POST / HTTP/1.1\r\n\
content-length: 10\r\n\
content-length: 11\r\n\
\r\n\
",
"multiple content-lengths",
);
// content-length with prefix is not allowed
parse_err(
"\
POST / HTTP/1.1\r\n\
content-length: +10\r\n\
\r\n\
",
"prefixed content-length",
);
// transfer-encoding that isn't chunked is an error
parse_err(
"\
POST / HTTP/1.1\r\n\
transfer-encoding: gzip\r\n\
\r\n\
",
"transfer-encoding but not chunked",
);
parse_err(
"\
POST / HTTP/1.1\r\n\
transfer-encoding: chunked, gzip\r\n\
\r\n\
",
"transfer-encoding doesn't end in chunked",
);
parse_err(
"\
POST / HTTP/1.1\r\n\
transfer-encoding: chunked\r\n\
transfer-encoding: afterlol\r\n\
\r\n\
",
"transfer-encoding multiple lines doesn't end in chunked",
);
// http/1.0
assert_eq!(
parse(
"\
POST / HTTP/1.0\r\n\
content-length: 10\r\n\
\r\n\
"
)
.decode,
DecodedLength::new(10)
);
parse_err(
"\
POST / HTTP/1.0\r\n\
transfer-encoding: chunked\r\n\
\r\n\
",
"1.0 chunked",
);
} | rust_cleaned_test_functions.jsonl/7665 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 4446
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
49843,
7893,
368,
341,
286,
5168,
4715,
1141,
25,
609,
495,
8,
1464,
393,
18112,
2052,
27,
1900,
2460,
29,
341,
310,
1077,
5206,
5820,
284,
30024,
51440,
486,
1499,
1141,
317,
310,
8422,
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_mine_genesis() {
let configs_fixture = test_make_configs_fixture();
//clear from sideffects.
test_helper_clear_block_dir(&configs_fixture.get_block_dir());
// mine
write_genesis(&configs_fixture);
// read file
let block_file =
fs::read_to_string("./test_blocks_temp_1/block_0.json").expect("Could not read latest block");
let latest_block: Block =
serde_json::from_str(&block_file).expect("could not deserialize latest block");
assert_eq!(latest_block.height, 0, "test");
// Test the expected proof is writtent to file correctly.
let correct_proof = "004812351796d94cab9a9932ec179630d86ced7db3fd7dbd66f36b0a9c0f1398756465304908e05c6397bffc7b6ac9b158c166eaade6169ffe54ddcd9251c149c5f3cceeacc59a9044bc9b9427237ac63d189873736b8ff2970f236f541bef4cf1d789f39f97f8b87ecccf7fd34f99bc4e193986da0761f5698f9715de76f0b5b5ffd41a4dcd73c3bbc19f1047bb2862c65699a4dc5ecbdf6297383a6a4e97d346a098f0a6d83b9aa3ccb703ab008356c45fb84a6e550f06f98c55300865f9774d0dee94bfcefc79208c35e79b3a8458ac246193ccf36f5b8d74975d1b0ecb7cefc419960fa9b31bda6582a046c70ba2aaec637a5d0a95ec59cda1edcf8a51b97463000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001";
assert_eq!(hex::encode(&latest_block.proof), correct_proof, "test");
test_helper_clear_block_dir(&configs_fixture.get_block_dir());
} | rust_cleaned_test_functions.jsonl/26869 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 678
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
717,
482,
16322,
13774,
368,
341,
9401,
262,
1077,
42309,
74409,
284,
1273,
28230,
59150,
74409,
1428,
262,
442,
7422,
504,
3108,
39927,
624,
262,
1273,
10418,
21811,
7113,
4334,
2099,
53978,
74409,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_faucet_build_airdrop_transaction() {
let to = Pubkey::new_unique();
let blockhash = Hash::default();
let request = FaucetRequest::GetAirdrop {
lamports: 2,
to,
blockhash,
};
let ip = socketaddr!([203, 0, 113, 1], 1234).ip();
let mint = Keypair::new();
let mint_pubkey = mint.pubkey();
let mut faucet = Faucet::new(mint, None, None, None);
if let FaucetTransaction::Airdrop(tx) =
faucet.build_airdrop_transaction(request, ip).unwrap()
{
let message = tx.message();
assert_eq!(tx.signatures.len(), 1);
assert_eq!(
message.account_keys,
vec![mint_pubkey, to, Pubkey::default()]
);
assert_eq!(message.recent_blockhash, blockhash);
assert_eq!(message.instructions.len(), 1);
let instruction: SystemInstruction =
deserialize(&message.instructions[0].data).unwrap();
assert_eq!(instruction, SystemInstruction::Transfer { lamports: 2 });
} else {
panic!("airdrop should succeed");
}
// Test per-time request cap
let mint = Keypair::new();
faucet = Faucet::new(mint, None, Some(2), None);
let _tx = faucet.build_airdrop_transaction(request, ip).unwrap(); // first request succeeds
let tx = faucet.build_airdrop_transaction(request, ip);
assert!(tx.is_err());
// Test multiple requests from loopback with different addresses succeed
let mint = Keypair::new();
faucet = Faucet::new(mint, None, Some(2), None);
let ip = socketaddr!([127, 0, 0, 1], 0).ip();
let other = Pubkey::new_unique();
let _tx0 = faucet.build_airdrop_transaction(request, ip).unwrap(); // first request succeeds
let request1 = FaucetRequest::GetAirdrop {
lamports: 2,
to: other,
blockhash,
};
let _tx1 = faucet.build_airdrop_transaction(request1, ip).unwrap(); // first request succeeds
let tx0 = faucet.build_airdrop_transaction(request, ip);
assert!(tx0.is_err());
let tx1 = faucet.build_airdrop_transaction(request1, ip);
assert!(tx1.is_err());
// Test multiple requests from allowed ip with different addresses succeed
let mint = Keypair::new();
let ip = socketaddr!([203, 0, 113, 1], 0).ip();
let mut allowed_ips = HashSet::new();
allowed_ips.insert(ip);
faucet = Faucet::new_with_allowed_ips(mint, None, Some(2), None, allowed_ips);
let other = Pubkey::new_unique();
let _tx0 = faucet.build_airdrop_transaction(request, ip).unwrap(); // first request succeeds
let request1 = FaucetRequest::GetAirdrop {
lamports: 2,
to: other,
blockhash,
};
let _tx1 = faucet.build_airdrop_transaction(request1, ip).unwrap(); // first request succeeds
let tx0 = faucet.build_airdrop_transaction(request, ip);
assert!(tx0.is_err());
let tx1 = faucet.build_airdrop_transaction(request1, ip);
assert!(tx1.is_err());
// Test per-request cap
let mint = Keypair::new();
let mint_pubkey = mint.pubkey();
let mut faucet = Faucet::new(mint, None, None, Some(1));
if let FaucetTransaction::Memo((tx, memo)) =
faucet.build_airdrop_transaction(request, ip).unwrap()
{
let message = tx.message();
assert_eq!(tx.signatures.len(), 1);
assert_eq!(
message.account_keys,
vec![mint_pubkey, Pubkey::new(&spl_memo::id().to_bytes())]
);
assert_eq!(message.recent_blockhash, blockhash);
assert_eq!(message.instructions.len(), 1);
let parsed_memo = std::str::from_utf8(&message.instructions[0].data).unwrap();
let expected_memo = "request too large; req: ◎0.000000002, cap: ◎0.000000001";
assert_eq!(parsed_memo, expected_memo);
assert_eq!(memo, expected_memo);
} else {
panic!("airdrop attempt should result in memo tx");
}
} | rust_cleaned_test_functions.jsonl/1269 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2003
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
761,
20436,
295,
20801,
50827,
6719,
28884,
368,
341,
286,
1077,
311,
284,
22611,
792,
486,
931,
21218,
543,
286,
1077,
2504,
8296,
284,
6531,
486,
2258,
543,
286,
1077,
1681,
284,
96362,
295,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_add() {
let ctx = FieldCtx::new();
let a = FieldElem::from_num(1);
let b = FieldElem::from_num(0xffff_ffff);
let c = ctx.add(&a, &b);
let c1 = FieldElem::from_num(0x1_0000_0000);
assert!(c == c1);
let b1 = ctx.add(&ctx.modulus, &b);
assert!(b1 == b);
} | rust_cleaned_test_functions.jsonl/99461 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 192
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
368,
341,
286,
1077,
5635,
284,
8601,
23684,
486,
931,
1428,
286,
1077,
264,
284,
8601,
25586,
486,
1499,
4273,
7,
16,
317,
286,
1077,
293,
284,
8601,
25586,
486,
1499,
4273,
7,
15,
2051... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_strings() {
test_string(b"\xd8\x20\x76\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x65\x78\x61\x6d\x70\x6c\x65\x2e\x63\x6f\x6d", "http://www.example.com");
test_string(b"\x60", "");
test_string(b"\x61\x61", "a");
test_string(b"\x64\x49\x45\x54\x46", "IETF");
test_string(b"\x64\x49\x45\x54\x46", "IETF");
test_string(b"\x62\x22\x5c", "\"\\");
test_string(b"\x62\xc3\xbc", "ü");
test_string(b"\x63\xe6\xb0\xb4", "水");
test_string(b"\x64\xf0\x90\x85\x91", "𐅑");
} | rust_cleaned_test_functions.jsonl/62588 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 326
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
33500,
368,
341,
262,
1273,
3904,
1883,
11934,
9703,
23,
3462,
17,
15,
3462,
22,
21,
3462,
21,
23,
3462,
22,
19,
3462,
22,
19,
3462,
22,
15,
3462,
18,
64,
3462,
17,
69,
3462,
17,
69,
3462,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ease_in_out_quad() {
assert_eq!(ease(ease_in_out_quad, 1.0, 0.0, 1.0), 0.0);
assert_eq!(ease(ease_in_out_quad, 1.00, 0.0, 0.4), 0.67999995);
} | rust_cleaned_test_functions.jsonl/40065 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 113
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2204,
519,
1243,
6068,
68631,
368,
341,
286,
2060,
10714,
10297,
46614,
2026,
519,
1243,
6068,
68631,
11,
220,
16,
13,
15,
11,
220,
15,
13,
15,
11,
220,
16,
13,
15,
701,
220,
15,
13,
15,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_normalizer() {
let table_create = TableCreateCommand::new("Test".to_string())
.normalizer(NormalizerType::Auto);
let mut arg: HashMap<String, String> = HashMap::new();
arg.insert("normalizer".to_string(), "NormalizerAuto".to_string());
let expected = TableCreateCommand {
command: TableCreate,
name: "Test".to_string(),
arguments: arg,
};
assert_eq!(expected, table_create);
} | rust_cleaned_test_functions.jsonl/74223 | {
"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,
13973,
3135,
368,
341,
286,
1077,
1965,
8657,
284,
6633,
4021,
4062,
486,
931,
445,
2271,
3263,
983,
3904,
2398,
310,
659,
8252,
3135,
8204,
2492,
3135,
929,
486,
13253,
317,
286,
1077,
5206,
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_get_ufo_path_unique_filename() {
let op = get_ufo_outpath(&Path::new("one/two/three.ufo"), &Some("-new".to_string()), &None);
assert_eq!(op, PathBuf::from("one/two/three-new.ufo"));
} | rust_cleaned_test_functions.jsonl/21542 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 110
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
7300,
824,
2638,
21218,
13323,
368,
341,
286,
1077,
1179,
284,
633,
7300,
824,
6068,
2343,
2099,
1820,
486,
931,
445,
603,
5523,
1126,
20439,
765,
11634,
824,
3975,
609,
8373,
13645,
931,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_bytes_single() {
new_ucmd!()
.arg("-c")
.arg("10")
.arg(FOOBAR_TXT)
.run()
.stdout_is_fixture("foobar_bytes_single.expected");
} | rust_cleaned_test_functions.jsonl/31127 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 113
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12524,
19487,
368,
341,
262,
501,
68887,
2277,
0,
741,
286,
659,
858,
13645,
66,
1138,
286,
659,
858,
445,
16,
15,
1138,
286,
659,
858,
7,
3788,
20608,
934,
84411,
340,
286,
659,
6108,
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 |
#[test]
fn test_parse_time() {
fn h(a: Result<(i32, i32), Box<dyn Error>>, b: (i32, i32)) {
match a {
Ok(a) => {
assert_eq!(a, b);
}
Err(e) => {
println!("{:?}", e);
}
}
}
h(parse_time("10AM"), (10, 0));
h(parse_time("11AM"), (11, 0));
h(parse_time("11:30AM"), (11, 30));
h(parse_time("3PM"), (15, 0));
h(parse_time("5PM"), (17, 0));
h(parse_time("5:30PM"), (17, 30));
} | rust_cleaned_test_functions.jsonl/25042 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 306
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
3009,
368,
341,
262,
5168,
305,
2877,
25,
5714,
28706,
72,
18,
17,
11,
600,
18,
17,
701,
8261,
92846,
4600,
81360,
293,
25,
320,
72,
18,
17,
11,
600,
18,
17,
593,
341,
286,
2432,
26... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_literal_plus_function_call() {
let program = r#"
DECLARE FUNCTION Sum(A, B)
PRINT 1 + Sum(1, 2)
FUNCTION Sum(A, B)
Sum = A + B
END FUNCTION
"#;
let interpreter = interpret(program);
assert_eq!(interpreter.stdlib.output, vec!["4"]);
} | rust_cleaned_test_functions.jsonl/22651 | {
"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,
34100,
28043,
9174,
13429,
368,
341,
310,
1077,
2025,
284,
435,
2,
698,
310,
70819,
24819,
8116,
4346,
11,
425,
692,
310,
35893,
220,
16,
488,
8116,
7,
16,
11,
220,
17,
692,
310,
24819,
8116,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_constructor_error_out() {
let md: Result<String> = setup_empty().as_markdown();
if let Err(e) = md {
assert_eq!(e.to_string(), "Table must have at least 1 row.".to_string());
} else {
panic!("Test should not reach this branch.")
}
} | rust_cleaned_test_functions.jsonl/90513 | {
"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,
15124,
66210,
4096,
6068,
368,
341,
286,
1077,
10688,
25,
5714,
3464,
29,
284,
6505,
15124,
1005,
300,
18924,
2923,
1428,
286,
421,
1077,
15495,
2026,
8,
284,
10688,
341,
310,
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... | 2 |
#[test]
fn test_round_ceil_precision() {
let mut args = HashMap::new();
args.insert("method".to_string(), to_value("ceil"));
args.insert("precision".to_string(), to_value(1));
let result = round(to_value(2.11), args);
assert!(result.is_ok());
assert_eq!(result.unwrap(), to_value(2.2));
} | rust_cleaned_test_functions.jsonl/62622 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 162
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
29896,
62,
22058,
54618,
368,
341,
286,
1077,
5206,
2827,
284,
10528,
486,
931,
543,
286,
2827,
7030,
445,
4393,
3263,
983,
3904,
1507,
311,
3142,
445,
22058,
4010,
286,
2827,
7030,
445,
27182,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_arrays() {
let mut ran = Random::new();
let arr = vec![2,3,4,5,6];
let x = ran.one_of(&arr[0..3]);
assert_eq!( x >= 2 && x < 5 , true);
let x = ran.some_of(&arr, 2);
assert_eq!(x.len(), 2);
} | rust_cleaned_test_functions.jsonl/101585 | {
"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,
68983,
368,
341,
286,
1077,
5206,
10613,
284,
10612,
486,
931,
1428,
286,
1077,
2890,
284,
7486,
20703,
17,
11,
18,
11,
19,
11,
20,
11,
21,
935,
286,
1077,
856,
284,
10613,
30973,
3575,
2099,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_make_worktree_head_upstream() {
let info = make_worktree_head(
[
"# branch.oid hello",
"# branch.head main",
"# branch.upstream origin/main",
"# branch.ab +25 -30",
]
.iter()
.map(|x| *x),
);
assert_eq!(
info,
WorktreeHead::Attached {
commit: BranchCommit::Oid("hello".to_string()),
head: "main".to_string(),
upstream: Some(UpstreamInfo {
name: "origin/main".to_string(),
added: 25,
removed: 30,
}),
}
);
} | rust_cleaned_test_functions.jsonl/114805 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 459
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28230,
11498,
9344,
13138,
8237,
4027,
368,
341,
286,
1077,
3546,
284,
1281,
11498,
9344,
13138,
1006,
310,
2278,
394,
5869,
8870,
13,
588,
23811,
756,
394,
5869,
8870,
16042,
1887,
756,
394,
5869... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_struct_list () {
use test_capnp::test_struct_list;
let mut message = message::Builder::new(message::HeapAllocator::new());
let mut test_struct_list = message.init_root::<test_struct_list::Builder>();
test_struct_list.reborrow().init_struct_list(4);
{
let struct_list = test_struct_list.reborrow().get_struct_list().unwrap();
struct_list.get(0).init_uint8_list(1).set(0, 5u8);
}
{
let reader = test_struct_list.into_reader();
assert_eq!(reader.get_struct_list().unwrap().get(0).get_uint8_list().unwrap().get(0), 5u8);
}
} | rust_cleaned_test_functions.jsonl/55846 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 314
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15126,
2019,
1719,
1476,
286,
990,
1273,
16388,
6199,
486,
1944,
15126,
2019,
401,
286,
1077,
5206,
1943,
284,
1943,
486,
3297,
486,
931,
7333,
486,
27909,
42730,
486,
931,
5231,
286,
1077,
5206,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_sign_verify_this_ed25519() {
for method_data_base in [MethodData::new_b58, MethodData::new_multibase] {
let key: KeyPair = KeyPair::new_ed25519().unwrap();
let controller: CoreDID = "did:example:1234".parse().unwrap();
let public_key = key.public().as_ref().to_vec();
let method: VerificationMethod = VerificationMethod::builder(Default::default())
.id(controller.to_url().join("#key-1").unwrap())
.controller(controller.clone())
.key_type(MethodType::Ed25519VerificationKey2018)
.key_data(method_data_base(public_key))
.build()
.unwrap();
let mut document: CoreDocument<Properties> = CoreDocument::builder(Default::default())
.id(controller)
.verification_method(method)
.build()
.unwrap();
assert!(document.verifier().verify(&document).is_err());
document
.clone()
.signer(key.private())
.method("#key-1")
.sign(&mut document)
.unwrap();
assert!(document.verifier().verify(&document).is_ok());
}
} | rust_cleaned_test_functions.jsonl/53495 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 423
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11172,
35638,
24868,
32370,
17,
20,
20,
16,
24,
368,
341,
220,
369,
1714,
1769,
7651,
304,
508,
3523,
1043,
486,
931,
880,
20,
23,
11,
6730,
1043,
486,
931,
26290,
98746,
60,
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... | 2 |
#[test]
fn test_update_add_htlc_bolt2_sender_value_below_minimum_msat() {
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
let _chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 95000000, InitFeatures::known(), InitFeatures::known());
let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[1]);
let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
let logger = test_utils::TestLogger::new();
let mut route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph, &nodes[1].node.get_our_node_id(), Some(InvoiceFeatures::known()), None, &[], 100000, TEST_FINAL_CLTV, &logger).unwrap();
route.paths[0][0].fee_msat = 100;
unwrap_send_err!(nodes[0].node.send_payment(&route, our_payment_hash, &Some(our_payment_secret)), true, APIError::ChannelUnavailable { ref err },
assert!(regex::Regex::new(r"Cannot send less than their minimum HTLC value \(\d+\)").unwrap().is_match(err)));
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
nodes[0].logger.assert_log_contains("lightning::ln::channelmanager".to_string(), "Cannot send less than their minimum HTLC value".to_string(), 1);
} | rust_cleaned_test_functions.jsonl/16919 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 532
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8882,
2891,
49086,
17257,
880,
6181,
17,
54356,
3142,
82750,
84855,
21416,
266,
368,
341,
1572,
10217,
26023,
1645,
18343,
82,
284,
1855,
45552,
1645,
18343,
82,
7,
17,
317,
10217,
2436,
18343,
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,
1,
1,
1... | 1 |
#[test]
fn test_full_exit_nft_success() {
let circuit = apply_nft_mint_and_full_exit_nft_operations();
// Verify that there are no unsatisfied constraints
check_circuit(circuit);
} | rust_cleaned_test_functions.jsonl/45532 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 77
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16372,
16880,
1089,
723,
18632,
368,
341,
262,
1077,
16224,
284,
3796,
1089,
723,
717,
396,
8378,
16372,
16880,
1089,
723,
57345,
1428,
262,
442,
25429,
429,
1052,
525,
902,
6975,
46265,
16982,
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 |
#[test]
fn test_tseitin_no_good() {
use cryptominisat::Lbool;
let mut solver = Solver::new();
let (r, x, y, z) = (
solver.new_var(),
solver.new_var(),
solver.new_var(),
solver.new_var(),
);
add_tseitin_nogood(&mut solver, r, &[x, y, z]);
// The constraint set is feasible.
assert_eq!(solver.solve(), Lbool::True);
// Iterate over the truth value for all 4 variables
for values in 0..16 {
let r_value = (values & 1) != 0;
let x_value = (values & 2) != 0;
let y_value = (values & 4) != 0;
let z_value = (values & 8) != 0;
let assumptions = [
Lit::new(r.var(), !r_value).expect("ok"),
Lit::new(x.var(), !x_value).expect("ok"),
Lit::new(y.var(), !y_value).expect("ok"),
Lit::new(z.var(), !z_value).expect("ok"),
];
let expected = if r_value == (x_value & y_value & z_value) {
Lbool::True
} else {
Lbool::False
};
println!(
"values={} assumptions={:?} expected={:?}",
values, assumptions, expected
);
assert_eq!(solver.solve_with_assumptions(&assumptions), expected);
}
} | rust_cleaned_test_functions.jsonl/97532 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 632
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
528,
325,
84886,
6536,
44781,
368,
341,
262,
990,
14436,
7970,
285,
266,
486,
43,
2641,
401,
262,
1077,
5206,
28961,
284,
68295,
486,
931,
543,
262,
1077,
320,
81,
11,
856,
11,
379,
11,
1147,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_all_features() -> Result<()> {
let options = CommonOptions::from_iter_safe(vec!["foo", "--wasm-features=all"])?;
let wasmparser::WasmFeatures {
reference_types,
multi_value,
bulk_memory,
module_linking,
simd,
threads,
tail_call,
deterministic_only,
multi_memory,
exceptions,
memory64,
} = options.wasm_features.unwrap();
assert!(reference_types);
assert!(multi_value);
assert!(bulk_memory);
assert!(module_linking);
assert!(simd);
assert!(threads);
assert!(!tail_call); // Not supported
assert!(!deterministic_only); // Not supported
assert!(multi_memory);
assert!(!exceptions); // Not supported
assert!(!memory64); // Not supported
Ok(())
} | rust_cleaned_test_functions.jsonl/96572 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 466
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5705,
14965,
368,
1464,
5714,
71698,
341,
286,
1077,
2606,
284,
7718,
3798,
486,
1499,
11723,
34067,
25592,
0,
1183,
7975,
497,
14482,
86,
10530,
12,
20304,
88277,
1341,
89720,
286,
1077,
572,
130... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_primitive_array_neq() {
cmp_i64!(
neq,
&[8, 8, 8, 8, 8, 8, 8, 8, 8, 8],
&[6, 7, 8, 9, 10, 6, 7, 8, 9, 10],
vec![true, true, false, true, true, true, true, false, true, true]
);
} | rust_cleaned_test_functions.jsonl/38867 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 170
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
84087,
3858,
13925,
80,
368,
341,
286,
26089,
5318,
21,
19,
33673,
310,
834,
80,
345,
310,
44590,
23,
11,
220,
23,
11,
220,
23,
11,
220,
23,
11,
220,
23,
11,
220,
23,
11,
220,
23,
11,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_for() {
check_output_default(
"for (var i = 0; i < 5; i = i + 1) \n\
{ \n\
print(i); \n\
}",
"0\n1\n2\n3\n4",
);
} | rust_cleaned_test_functions.jsonl/111839 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 161
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5478,
368,
341,
286,
1779,
7645,
9993,
1006,
310,
330,
1958,
320,
947,
600,
284,
220,
15,
26,
600,
366,
220,
20,
26,
600,
284,
600,
488,
220,
16,
8,
1124,
77,
5661,
1797,
314,
1124,
77,
56... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_register_decorator() {
let mut handlebars = Registry::new();
handlebars
.register_template_string("t0", "{{*foo}}".to_string())
.unwrap();
let data = btreemap! {
"hello".to_string() => "world".to_string()
};
assert!(handlebars.render("t0", &data).is_err());
handlebars.register_decorator(
"foo",
Box::new(
|_: &Directive,
_: &Registry,
_: &Context,
_: &mut RenderContext|
-> Result<(), RenderError> { Ok(()) },
),
);
assert_eq!(handlebars.render("t0", &data).ok().unwrap(), "".to_string());
} | rust_cleaned_test_functions.jsonl/50778 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 406
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14000,
87252,
368,
341,
286,
1077,
5206,
3705,
24950,
284,
32112,
486,
931,
543,
286,
3705,
24950,
198,
310,
659,
6343,
8693,
3904,
445,
83,
15,
497,
47219,
9,
7975,
3417,
3263,
983,
3904,
2398,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_weighted_shuffle_iterator() {
let mut test_set = [0; 6];
let mut count = 0;
let shuffle = weighted_shuffle(&[50, 10, 2, 1, 1, 1], [0x5a; 32]);
shuffle.into_iter().for_each(|x| {
assert_eq!(test_set[x], 0);
test_set[x] = 1;
count += 1;
});
assert_eq!(count, 6);
} | rust_cleaned_test_functions.jsonl/68772 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 208
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15876,
291,
73484,
13491,
368,
341,
286,
1077,
5206,
1273,
2602,
284,
508,
15,
26,
220,
21,
935,
286,
1077,
5206,
1760,
284,
220,
15,
280,
286,
1077,
25947,
284,
36824,
73484,
2099,
58,
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_run_fonts_east_asia_build() {
let c = RunFonts::new().east_asia("Hiragino");
let b = c.build();
assert_eq!(
str::from_utf8(&b).unwrap(),
r#"<w:rFonts w:eastAsia="Hiragino" />"#
);
} | rust_cleaned_test_functions.jsonl/117548 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 152
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14007,
71502,
2204,
559,
11898,
685,
20801,
368,
341,
286,
1077,
272,
284,
6452,
55369,
486,
931,
1005,
60501,
11898,
685,
445,
39,
404,
351,
3313,
797,
286,
1077,
293,
284,
272,
13239,
543,
286... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.