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_prod_log() {
assert_abs_diff_eq!(0., prod_log(0.));
let e: f64 = std::f64::consts::E;
assert_abs_diff_eq!(e, prod_log(e));
} | rust_cleaned_test_functions.jsonl/27814 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 100
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34984,
5224,
368,
341,
286,
2060,
31170,
15850,
10714,
10297,
15,
2572,
14475,
5224,
7,
15,
13,
1106,
286,
1077,
384,
25,
282,
21,
19,
284,
1460,
486,
69,
21,
19,
486,
95773,
486,
36,
280,
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 |
#[test]
fn test_insert_with_key() {
let mut map = SmallIntMap::new();
fn addMoreToCount(_k: uint, v0: uint, v1: uint) -> uint {
v0 + v1
}
fn addMoreToCount_simple(v0: uint, v1: uint) -> uint {
v0 + v1
}
// count integers
map.update(3, 1, addMoreToCount_simple);
map.update_with_key(9, 1, addMoreToCount);
map.update(3, 7, addMoreToCount_simple);
map.update_with_key(5, 3, addMoreToCount);
map.update_with_key(3, 2, addMoreToCount);
// check the total counts
assert_eq!(map.find(&3).unwrap(), &10);
assert_eq!(map.find(&5).unwrap(), &3);
assert_eq!(map.find(&9).unwrap(), &1);
assert!(map.find(&7).is_none());
} | rust_cleaned_test_functions.jsonl/7535 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 424
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17678,
6615,
3097,
368,
341,
286,
1077,
5206,
2415,
284,
14994,
1072,
2227,
486,
931,
1428,
16885,
286,
5168,
912,
7661,
1249,
2507,
2490,
74,
25,
2622,
11,
348,
15,
25,
2622,
11,
348,
16,
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_fold_logical_op_1() {
fold("x = true && x", "x = x");
fold("x = [foo()] && x", "x = (foo(),x)");
fold("x = false && x", "x = false");
fold("x = true || x", "x = true");
fold("x = false || x", "x = x");
fold("x = 0 && x", "x = 0");
fold("x = 3 || x", "x = 3");
fold("x = false || 0", "x = 0");
fold("a = x && true", "a=x && true");
fold("a = x && false", "a=x && false");
fold("a = x || 3", "a=x || 3");
fold("a = x || false", "a=x || false");
fold("a = b ? c : x || false", "a=b ? c:x || false");
fold("a = b ? x || false : c", "a=b ? x || false:c");
fold("a = b ? c : x && true", "a=b ? c:x && true");
fold("a = b ? x && true : c", "a=b ? x && true:c");
fold_same("a = x || false ? b : c");
fold_same("a = x && true ? b : c");
} | rust_cleaned_test_functions.jsonl/122169 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 399
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
61187,
86484,
10287,
62,
16,
368,
341,
262,
11555,
445,
87,
284,
830,
1009,
856,
497,
330,
87,
284,
856,
797,
262,
11555,
445,
87,
284,
508,
7975,
26556,
1009,
856,
497,
330,
87,
284,
320,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_data_pushing() {
type DataType = i32;
let mut v: Vec2d<DataType> = Vec2d::new();
let data = [1,2,3,4,5,6,7,8,9,10,11,12];
v.push_row(&data[0..1]);
v.push_col(&data[1..2]);
v.push_row(&data[2..4]);
v.push_row(&data[4..6]);
v.push_col(&data[6..9]);
v.push_col(&data[9..12]);
assert_eq!(v.count(), 12);
assert_eq!(v.count_rows(), 3);
assert_eq!(v.count_cols(), 4);
let answers = [1,2,7,10,3,4,8,11,5,6,9,12];
let mut idx: usize = 0;
for row in 0..v.count_rows() {
for col in 0..v.count_cols() {
assert_eq!(v[row][col], answers[idx]);
idx += 1;
}
}
} | rust_cleaned_test_functions.jsonl/110933 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 458
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1769,
14218,
287,
368,
341,
286,
943,
33172,
284,
600,
18,
17,
280,
286,
1077,
5206,
348,
25,
11312,
17,
67,
27,
22653,
29,
284,
11312,
17,
67,
486,
931,
543,
286,
1077,
821,
284,
508,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_max_size_ok() {
let manager = NthConnectFailManager { n: Mutex::new(5) };
let pool = Pool::builder().max_size(5).build(manager).unwrap();
let mut conns = vec![];
for _ in 0..5 {
conns.push(pool.get().ok().unwrap());
}
} | rust_cleaned_test_functions.jsonl/6399 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 121
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6345,
2368,
19817,
368,
341,
262,
1077,
6645,
284,
451,
339,
14611,
19524,
2043,
314,
308,
25,
66215,
486,
931,
7,
20,
8,
2605,
262,
1077,
7314,
284,
22728,
486,
17850,
1005,
2810,
2368,
7,
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... | 2 |
#[test]
fn test_root_subscription() {
let pubsub_addr = SocketAddr::new(
IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)),
rpc_port::DEFAULT_RPC_PUBSUB_PORT,
);
let exit = Arc::new(AtomicBool::new(false));
let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(10_000);
let bank = Bank::new_for_tests(&genesis_config);
let bank_forks = Arc::new(RwLock::new(BankForks::new(bank)));
let bank0 = bank_forks.read().unwrap().get(0).unwrap().clone();
let bank1 = Bank::new_from_parent(&bank0, &Pubkey::default(), 1);
bank_forks.write().unwrap().insert(bank1);
let subscriptions = Arc::new(RpcSubscriptions::new_for_tests(
&exit,
bank_forks.clone(),
Arc::new(RwLock::new(BlockCommitmentCache::default())),
OptimisticallyConfirmedBank::locked_from_bank_forks_root(&bank_forks),
));
let (trigger, pubsub_service) =
PubSubService::new(PubSubConfig::default(), &subscriptions, pubsub_addr);
std::thread::sleep(Duration::from_millis(400));
let (mut client, receiver) =
PubsubClient::root_subscribe(&format!("ws://0.0.0.0:{}/", pubsub_addr.port())).unwrap();
let roots = vec![1, 2, 3];
subscriptions.notify_roots(roots.clone());
// Read notifications
let mut errors: Vec<(Slot, Slot)> = Vec::new();
for expected in roots {
let response = receiver.recv();
match response {
Ok(response) => {
if expected != response {
errors.push((expected, response));
}
}
Err(_) => eprintln!("unexpected websocket receive timeout"),
}
}
exit.store(true, Ordering::Relaxed);
trigger.cancel();
client.shutdown().unwrap();
pubsub_service.close().unwrap();
assert_eq!(errors, [].to_vec());
} | rust_cleaned_test_functions.jsonl/10200 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 802
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12993,
59838,
368,
341,
262,
1077,
6675,
1966,
7387,
284,
20954,
13986,
486,
931,
1006,
286,
35033,
13986,
486,
53,
19,
8972,
30168,
19,
13986,
486,
931,
7,
15,
11,
220,
15,
11,
220,
15,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
#[test]
fn test_array_width_config_exceeds_max_width() {
let toml = r#"
max_width = 60
array_width = 80
"#;
let config = Config::from_toml(toml, Path::new("")).unwrap();
assert_eq!(config.array_width(), 60);
} | rust_cleaned_test_functions.jsonl/130655 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 172
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3858,
7927,
5332,
2702,
4635,
82,
6345,
7927,
368,
341,
310,
1077,
311,
1014,
284,
435,
2,
698,
394,
1932,
7927,
284,
220,
21,
15,
198,
394,
1334,
7927,
284,
220,
23,
15,
198,
310,
5869,
280... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_dup_htlc_onchain_fails_on_reload() {
// having a copy of the relevant fail-/claim-back data and processes the HTLC fail/claim when
// the ChannelMonitor tells it to.
// and de-duplicates ChannelMonitor events.
// This tests that explicit tracking behavior.
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 persister: test_utils::TestPersister;
let new_chain_monitor: test_utils::TestChainMonitor;
let nodes_0_deserialized: ChannelManager<EnforcingSigner, &test_utils::TestChainMonitor, &test_utils::TestBroadcaster, &test_utils::TestKeysInterface, &test_utils::TestFeeEstimator, &test_utils::TestLogger>;
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
// nodes[0].
let (payment_preimage, _, _) = route_payment(&nodes[0], &[&nodes[1]], 10000000);
nodes[0].node.force_close_channel(&nodes[0].node.list_channels()[0].channel_id).unwrap();
check_closed_broadcast!(nodes[0], true);
check_added_monitors!(nodes[0], 1);
check_closed_event!(nodes[0], 1, ClosureReason::HolderForceClosed);
nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id(), false);
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false);
// Connect blocks until the CLTV timeout is up so that we get an HTLC-Timeout transaction
connect_blocks(&nodes[0], TEST_FINAL_CLTV + LATENCY_GRACE_PERIOD_BLOCKS + 1);
let node_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
assert_eq!(node_txn.len(), 3);
assert_eq!(node_txn[0], node_txn[1]);
assert!(nodes[1].node.claim_funds(payment_preimage));
check_added_monitors!(nodes[1], 1);
let mut header = BlockHeader { version: 0x20000000, prev_blockhash: nodes[1].best_block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
connect_block(&nodes[1], &Block { header, txdata: vec![node_txn[1].clone(), node_txn[2].clone()]});
check_closed_broadcast!(nodes[1], true);
check_added_monitors!(nodes[1], 1);
check_closed_event!(nodes[1], 1, ClosureReason::CommitmentTxConfirmed);
let claim_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
header.prev_blockhash = nodes[0].best_block_hash();
connect_block(&nodes[0], &Block { header, txdata: vec![node_txn[1].clone(), node_txn[2].clone()]});
// Serialize out the ChannelMonitor before connecting the on-chain claim transactions. This is
let mut chan_0_monitor_serialized = test_utils::TestVecWriter(Vec::new());
nodes[0].chain_monitor.chain_monitor.monitors.read().unwrap().iter().next().unwrap().1.write(&mut chan_0_monitor_serialized).unwrap();
header.prev_blockhash = nodes[0].best_block_hash();
let claim_block = Block { header, txdata: claim_txn};
connect_block(&nodes[0], &claim_block);
expect_payment_sent!(nodes[0], payment_preimage);
let mut chan_manager_serialized = test_utils::TestVecWriter(Vec::new());
nodes[0].node.write(&mut chan_manager_serialized).unwrap();
persister = test_utils::TestPersister::new();
let keys_manager = &chanmon_cfgs[0].keys_manager;
new_chain_monitor = test_utils::TestChainMonitor::new(Some(nodes[0].chain_source), nodes[0].tx_broadcaster.clone(), nodes[0].logger, node_cfgs[0].fee_estimator, &persister, keys_manager);
nodes[0].chain_monitor = &new_chain_monitor;
let mut chan_0_monitor_read = &chan_0_monitor_serialized.0[..];
let (_, mut chan_0_monitor) = <(BlockHash, ChannelMonitor<EnforcingSigner>)>::read(
&mut chan_0_monitor_read, keys_manager).unwrap();
assert!(chan_0_monitor_read.is_empty());
let (_, nodes_0_deserialized_tmp) = {
let mut channel_monitors = HashMap::new();
channel_monitors.insert(chan_0_monitor.get_funding_txo().0, &mut chan_0_monitor);
<(BlockHash, ChannelManager<EnforcingSigner, &test_utils::TestChainMonitor, &test_utils::TestBroadcaster, &test_utils::TestKeysInterface, &test_utils::TestFeeEstimator, &test_utils::TestLogger>)>
::read(&mut io::Cursor::new(&chan_manager_serialized.0[..]), ChannelManagerReadArgs {
default_config: Default::default(),
keys_manager,
fee_estimator: node_cfgs[0].fee_estimator,
chain_monitor: nodes[0].chain_monitor,
tx_broadcaster: nodes[0].tx_broadcaster.clone(),
logger: nodes[0].logger,
channel_monitors,
}).unwrap()
};
nodes_0_deserialized = nodes_0_deserialized_tmp;
assert!(nodes[0].chain_monitor.watch_channel(chan_0_monitor.get_funding_txo().0, chan_0_monitor).is_ok());
check_added_monitors!(nodes[0], 1);
nodes[0].node = &nodes_0_deserialized;
// Note that if we re-connect the block which exposed nodes[0] to the payment preimage (but
let height = nodes[0].blocks.lock().unwrap().len() as u32 - 1;
nodes[0].chain_monitor.chain_monitor.block_connected(&claim_block, height);
assert!(nodes[0].node.get_and_clear_pending_events().is_empty());
} | rust_cleaned_test_functions.jsonl/16895 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1901
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
51932,
49086,
17257,
4470,
8819,
761,
6209,
4470,
79405,
368,
341,
11120,
197,
322,
3432,
264,
2975,
315,
279,
9760,
3690,
66114,
7859,
15461,
821,
323,
11364,
279,
5260,
8556,
3690,
14,
7859,
979... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_create_hardware_spec_permission_denied() {
let mut context_builder = ContextBuilder::new();
context_builder.log_in(&[]); // Insufficient permissions
let runner = QueryRunner::new(context_builder);
assert_eq!(
runner.query(
QUERY,
hashmap! {
"name" => InputValue::scalar(""),
"numRegisters" => InputValue::scalar(0),
"numStacks" => InputValue::scalar(-1),
"maxStackLength" => InputValue::scalar(-1),
}
),
(
serde_json::Value::Null,
vec![json!({
"locations": [{"line": 8, "column": 9}],
"message": "Insufficient permissions to perform this action",
"path": ["createHardwareSpec"],
})]
)
);
} | rust_cleaned_test_functions.jsonl/61186 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 434
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8657,
1523,
37750,
13594,
37971,
49522,
1122,
368,
341,
262,
1077,
5206,
2266,
28532,
284,
9608,
3297,
486,
931,
543,
262,
2266,
28532,
1665,
1243,
2099,
1294,
1215,
442,
9726,
26683,
8541,
198,
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_tangent_line_at_point() {
let quad = BoundedQuadratic::new(0., 1., 1., 0., 0.);
let expected_tangent_line = BoundedQuadratic::new_extended(0., 2. * 0.5, 0.25 - 1. * 0.5);
assert_eq!(quad.get_tangent_line_at(0.5), expected_tangent_line);
} | rust_cleaned_test_functions.jsonl/19859 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 172
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
528,
66451,
6528,
3752,
6085,
368,
341,
1789,
286,
1077,
27082,
284,
425,
13082,
2183,
88678,
486,
931,
7,
15,
2572,
220,
16,
2572,
220,
16,
2572,
220,
15,
2572,
220,
15,
58957,
16885,
286,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_all_parameters() {
let mut params = Params::new();
params
.hash_length(18)
// Make sure a shorter key properly overwrites a longer one.
.key(b"not the real key")
.key(b"bar")
.salt(b"bazbazba")
.personal(b"bing bin")
.fanout(2)
.max_depth(3)
.max_leaf_length(0x04050607)
.node_offset(0x08090a0b0c0d)
.node_depth(16)
.inner_hash_length(17)
.last_node(true);
// Check the State API.
assert_eq!(
"62361e5392ab0eb7dd27e48a6809ee82dc57",
¶ms.to_state().update(b"foo").finalize().to_hex()
);
// Check the all-at-once API.
assert_eq!(
"62361e5392ab0eb7dd27e48a6809ee82dc57",
¶ms.hash(b"foo").to_hex()
);
} | rust_cleaned_test_functions.jsonl/10643 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 428
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5705,
18263,
368,
341,
262,
1077,
5206,
3628,
284,
34352,
486,
931,
543,
262,
3628,
198,
286,
659,
8296,
5118,
7,
16,
23,
340,
286,
442,
7405,
2704,
264,
23327,
1376,
10277,
916,
59079,
264,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_iterator_peekable_last() {
let xs = [0, 1, 2, 3, 4, 5];
let ys = [0];
let mut it = xs.iter().peekable();
assert_eq!(it.peek(), Some(&&0));
assert_eq!(it.last(), Some(&5));
let mut it = ys.iter().peekable();
assert_eq!(it.peek(), Some(&&0));
assert_eq!(it.last(), Some(&0));
} | rust_cleaned_test_functions.jsonl/36996 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 163
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13491,
62,
29107,
480,
12195,
368,
341,
262,
1077,
11943,
284,
508,
15,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
935,
262,
1077,
31810,
284,
508,
15,
4821,
262,
107... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_rfc3339() {
use super::*;
use crate::offset::FixedOffset;
use crate::DateTime;
let testdates = [
("2015-01-20T17:35:20-08:00", Ok("2015-01-20T17:35:20-08:00")), // normal case
("1944-06-06T04:04:00Z", Ok("1944-06-06T04:04:00+00:00")), // D-day
("2001-09-11T09:45:00-08:00", Ok("2001-09-11T09:45:00-08:00")),
("2015-01-20T17:35:20.001-08:00", Ok("2015-01-20T17:35:20.001-08:00")),
("2015-01-20T17:35:20.000031-08:00", Ok("2015-01-20T17:35:20.000031-08:00")),
("2015-01-20T17:35:20.000000004-08:00", Ok("2015-01-20T17:35:20.000000004-08:00")),
("2015-01-20T17:35:20.000000000452-08:00", Ok("2015-01-20T17:35:20-08:00")), // too small
("2015-02-30T17:35:20-08:00", Err(OUT_OF_RANGE)), // bad day of month
("2015-01-20T25:35:20-08:00", Err(OUT_OF_RANGE)), // bad hour
("2015-01-20T17:65:20-08:00", Err(OUT_OF_RANGE)), // bad minute
("2015-01-20T17:35:90-08:00", Err(OUT_OF_RANGE)), // bad second
("2015-01-20T17:35:20-24:00", Err(OUT_OF_RANGE)), // bad offset
];
fn rfc3339_to_datetime(date: &str) -> ParseResult<DateTime<FixedOffset>> {
let mut parsed = Parsed::new();
parse(&mut parsed, date, [Item::Fixed(Fixed::RFC3339)].iter())?;
parsed.to_datetime()
}
fn fmt_rfc3339_datetime(dt: DateTime<FixedOffset>) -> String {
dt.format_with_items([Item::Fixed(Fixed::RFC3339)].iter()).to_string()
}
// Test against test data above
for &(date, checkdate) in testdates.iter() {
let d = rfc3339_to_datetime(date); // parse a date
let dt = match d {
// did we get a value?
Ok(dt) => Ok(fmt_rfc3339_datetime(dt)),
Err(e) => Err(e), // otherwise keep an error for the comparison
};
if dt != checkdate.map(|s| s.to_string()) {
// check for expected result
panic!(
"Date conversion failed for {}\nReceived: {:?}\nExpected: {:?}",
date, dt, checkdate
);
}
}
} | rust_cleaned_test_functions.jsonl/5318 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1095
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1710,
8316,
18,
18,
18,
24,
368,
341,
262,
990,
2256,
56162,
262,
990,
17717,
486,
3176,
486,
13520,
6446,
280,
262,
990,
17717,
486,
7689,
401,
1066,
262,
1077,
1273,
6394,
284,
2278,
286,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_fuse_commit_version() -> anyhow::Result<()> {
let v = &databend_meta::configs::DATABEND_COMMIT_VERSION;
assert!(v.len() > 0);
Ok(())
} | rust_cleaned_test_functions.jsonl/119222 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 80
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
761,
810,
36346,
9438,
368,
1464,
88964,
486,
2077,
71698,
341,
262,
1077,
348,
284,
609,
67,
2096,
408,
13381,
486,
53978,
486,
35,
19562,
4689,
77364,
10678,
280,
262,
2060,
10297,
85,
19406,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_smoke() {
let (_td, repo) = repo_init().unwrap();
let root = repo.path().parent().unwrap();
let repo_path = root.as_os_str().to_str().unwrap();
assert_eq!(
get_branches_info(repo_path)
.unwrap()
.iter()
.map(|b| b.name.clone())
.collect::<Vec<_>>(),
vec!["master"]
);
} | rust_cleaned_test_functions.jsonl/96503 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 249
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15874,
4740,
368,
341,
286,
1077,
5453,
1296,
11,
15867,
8,
284,
15867,
6137,
1005,
15454,
543,
286,
1077,
3704,
284,
15867,
3875,
1005,
3765,
1005,
15454,
543,
286,
1077,
15867,
2638,
284,
3704,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_channel_delete_guild() {
let cache = InMemoryCache::new();
let (guild_id, channel_id, channel) = test::guild_channel_text();
cache.cache_guild_channel(guild_id, channel.clone());
assert_eq!(1, cache.channels_guild.len());
assert!(cache
.guild_channels
.get(&guild_id)
.unwrap()
.contains(&channel_id));
cache.update(&Event::ChannelDelete(ChannelDelete(Channel::Guild(
channel,
))));
assert!(cache.channels_guild.is_empty());
assert!(cache.guild_channels.get(&guild_id).unwrap().is_empty());
} | rust_cleaned_test_functions.jsonl/35013 | {
"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,
14571,
11353,
1889,
1498,
368,
341,
286,
1077,
6500,
284,
758,
10642,
8233,
486,
931,
543,
286,
1077,
320,
57877,
842,
11,
5496,
842,
11,
5496,
8,
284,
1273,
486,
57877,
14571,
4326,
1428,
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_from_type() {
assert_eq!(Type::from(parquet::Type::Boolean), Type::Boolean);
assert_eq!(Type::from(parquet::Type::Int32), Type::Int32);
assert_eq!(Type::from(parquet::Type::Int64), Type::Int64);
assert_eq!(Type::from(parquet::Type::Int96), Type::Int96);
assert_eq!(Type::from(parquet::Type::Float), Type::Float);
assert_eq!(Type::from(parquet::Type::Double), Type::Double);
assert_eq!(Type::from(parquet::Type::ByteArray), Type::ByteArray);
assert_eq!(
Type::from(parquet::Type::FixedLenByteArray),
Type::FixedLenByteArray
);
} | rust_cleaned_test_functions.jsonl/126060 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 233
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5673,
1819,
368,
341,
197,
6948,
10714,
10297,
929,
486,
1499,
31975,
23300,
486,
929,
486,
6890,
701,
3990,
486,
6890,
317,
197,
6948,
10714,
10297,
929,
486,
1499,
31975,
23300,
486,
929,
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_parse_coordinate_system() {
let cs = match parse_coordinate_system(FileSpan::new(Rc::new(String::from("CoordinateSystem \"test\"")), Rc::new(String::from("input")))).unwrap().1 {
Transformation::CoordinateSystem(c) => c,
_ => panic!()
};
assert_eq!(cs.identity.value, String::from("test"));
} | rust_cleaned_test_functions.jsonl/68351 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 140
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
68649,
17687,
368,
341,
262,
1077,
10532,
284,
2432,
4715,
68649,
17687,
19821,
12485,
486,
931,
2785,
66,
486,
931,
2242,
486,
1499,
445,
28589,
2320,
7245,
1944,
2105,
35674,
81463,
486,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_two_delays() {
let pulse = 4usize;
let mut model = PulsedModel::default();
let fact_0 = PulsedFact {
datum_type: u8::datum_type(),
shape: tvec![pulse.to_dim()],
axis: 0,
dim: stream_dim(),
delay: 0,
};
let source = model.add_source("source", fact_0.clone()).unwrap();
let delay_1 = model
.wire_node("delay-1", Delay::new(fact_0.axis, &(&fact_0).into(), 2, 0), &[source])
.unwrap()[0];
let fact_1 = model.outlet_fact(delay_1).unwrap().clone();
let delay_2 = model
.wire_node("delay-1", Delay::new(fact_1.axis, &(&fact_1).into(), 2, 0), &[delay_1])
.unwrap();
model.set_output_outlets(&delay_2).unwrap();
let plan = SimplePlan::new(model).unwrap();
let mut state = tract_core::plan::SimpleState::new(plan).unwrap();
for i in 0..5 {
let input: Vec<u8> = (pulse * i..(pulse * (i + 1))).map(|a| a as u8).collect();
let expect: Vec<u8> =
(pulse * i..(pulse * (i + 1))).map(|i| i.saturating_sub(4) as u8).collect();
let skip = 4usize.saturating_sub(i * pulse).min(pulse);
let output = state.run(tvec!(tensor1(&input))).unwrap();
assert_eq!(&output[0].as_slice::<u8>().unwrap()[skip..], &expect[skip..]);
}
} | rust_cleaned_test_functions.jsonl/65902 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 735
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
23241,
18029,
942,
368,
341,
286,
1077,
27235,
284,
220,
19,
51878,
280,
286,
1077,
5206,
1614,
284,
393,
14295,
291,
1712,
486,
2258,
543,
286,
1077,
2097,
62,
15,
284,
393,
14295,
291,
17417,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_against_libsodium() {
let mut libsodium_encrypted = vec![0xab; STREAM_LEN];
unsafe {
libsodium_ffi::crypto_stream_chacha20_ietf_xor_ic(
libsodium_encrypted.as_mut_ptr(),
libsodium_encrypted.as_ptr(),
libsodium_encrypted.len() as u64,
NONCE.as_ptr(),
0,
KEY.as_ptr(),
);
}
let mut self_encrypted = vec![0xab; STREAM_LEN];
chacha20_xor(&mut self_encrypted, KEY, NONCE);
assert_eq!(libsodium_encrypted, self_encrypted);
} | rust_cleaned_test_functions.jsonl/49285 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 343
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62427,
267,
16142,
82,
46776,
368,
341,
286,
1077,
5206,
63974,
46776,
13781,
14026,
284,
7486,
20703,
15,
52616,
26,
69811,
15536,
935,
286,
19860,
341,
310,
63974,
46776,
62,
53799,
486,
35772,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ipv6_fragment_not_multiple_of_offset_unit() {
let mut ctx = DummyContext::default();
let fragment_id = 0;
assert_eq!(ctx.get_state_mut().cache_size, 0);
// Test that fragment bodies must be a multiple of
// Process fragment #0
process_ipv6_fragment(&mut ctx, fragment_id, 0, 2, ExpectedResult::NeedMore);
// Process fragment #1 (body size is not a multiple of
let mut bytes = vec![0; 48];
bytes[..4].copy_from_slice(&[0x60, 0x20, 0x00, 0x77][..]);
bytes[6] = Ipv6ExtHdrType::Fragment.into(); // Next Header
bytes[7] = 64;
bytes[8..24].copy_from_slice(DUMMY_CONFIG_V6.remote_ip.bytes());
bytes[24..40].copy_from_slice(DUMMY_CONFIG_V6.local_ip.bytes());
bytes[40] = IpProto::Tcp.into();
bytes[42] = 0;
bytes[43] = (1 << 3) | 1;
bytes[44..48].copy_from_slice(&u32::try_from(fragment_id).unwrap().to_be_bytes());
bytes.extend(FRAGMENT_BLOCK_SIZE..FRAGMENT_BLOCK_SIZE * 2 - 1);
let payload_len = (bytes.len() - 40) as u16;
bytes[4..6].copy_from_slice(&payload_len.to_be_bytes());
let mut buf = Buf::new(bytes, ..);
let packet = buf.parse::<Ipv6Packet<_>>().unwrap();
assert_frag_proc_state_invalid!(process_fragment::<Ipv6, _, &[u8]>(&mut ctx, packet));
// Process fragment #1 (body size is not a multiple of
// allowed to not be a multiple of `FRAGMENT_BLOCK_SIZE`.
let mut bytes = vec![0; 48];
bytes[..4].copy_from_slice(&[0x60, 0x20, 0x00, 0x77][..]);
bytes[6] = Ipv6ExtHdrType::Fragment.into(); // Next Header
bytes[7] = 64;
bytes[8..24].copy_from_slice(DUMMY_CONFIG_V6.remote_ip.bytes());
bytes[24..40].copy_from_slice(DUMMY_CONFIG_V6.local_ip.bytes());
bytes[40] = IpProto::Tcp.into();
bytes[42] = 0;
bytes[43] = 1 << 3;
bytes[44..48].copy_from_slice(&u32::try_from(fragment_id).unwrap().to_be_bytes());
bytes.extend(FRAGMENT_BLOCK_SIZE..FRAGMENT_BLOCK_SIZE * 2 - 1);
let payload_len = (bytes.len() - 40) as u16;
bytes[4..6].copy_from_slice(&payload_len.to_be_bytes());
let mut buf = Buf::new(bytes, ..);
let packet = buf.parse::<Ipv6Packet<_>>().unwrap();
let (key, packet_len) = assert_frag_proc_state_ready!(
process_fragment::<Ipv6, _, &[u8]>(&mut ctx, packet),
DUMMY_CONFIG_V6.remote_ip.get(),
DUMMY_CONFIG_V6.local_ip.get(),
fragment_id,
55
);
validate_cache_size(ctx.get_state());
let mut buffer: Vec<u8> = vec![0; packet_len];
let mut buffer = &mut buffer[..];
let packet =
reassemble_packet::<Ipv6, _, &mut [u8], _>(&mut ctx, &key, &mut buffer).unwrap();
let mut expected_body: Vec<u8> = Vec::new();
expected_body.extend(0..15);
assert_eq!(packet.body(), &expected_body[..]);
assert_eq!(ctx.get_state_mut().cache_size, 0);
} | rust_cleaned_test_functions.jsonl/22028 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1521
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
49378,
21,
43012,
7913,
45233,
3575,
6917,
14832,
368,
341,
286,
1077,
5206,
5635,
284,
50567,
1972,
486,
2258,
543,
286,
1077,
12289,
842,
284,
220,
15,
401,
286,
2060,
10714,
10297,
3773,
670,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_merge_different_sections() {
let mut some = document(json!({ "use": [{ "protocol": "foo" }] }));
let mut other = document(json!({ "expose": [{ "protocol": "bar", "from": "self" }] }));
some.merge_from(&mut other, &Path::new("some/path")).unwrap();
let uses = some.r#use.as_ref().unwrap();
let exposes = some.r#expose.as_ref().unwrap();
assert_eq!(uses.len(), 1);
assert_eq!(exposes.len(), 1);
assert_eq!(
uses[0].protocol.as_ref().unwrap(),
&OneOrMany::One("foo".parse::<Name>().unwrap())
);
assert_eq!(
exposes[0].protocol.as_ref().unwrap(),
&OneOrMany::One("bar".parse::<Name>().unwrap())
);
} | rust_cleaned_test_functions.jsonl/34911 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 375
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20888,
82741,
59485,
368,
341,
286,
1077,
5206,
1045,
284,
2197,
9304,
0,
2306,
330,
810,
788,
18466,
330,
17014,
788,
330,
7975,
1,
58592,
17830,
286,
1077,
5206,
1008,
284,
2197,
9304,
0,
2306... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_manual_dyn_impl() {
struct MyEnum;
impl Valuable for MyEnum {
fn as_value(&self) -> Value<'_> {
Value::Enumerable(self)
}
fn visit(&self, visitor: &mut dyn Visit) {
visitor.visit_unnamed_fields(&[Value::String("hello")]);
}
}
impl Enumerable for MyEnum {
fn definition(&self) -> EnumDef<'_> {
EnumDef::new_dynamic("MyEnum", &[])
}
fn variant(&self) -> Variant<'_> {
Variant::Dynamic(VariantDef::new("MyVariant", Fields::Unnamed))
}
}
let v = MyEnum;
assert_eq!(
format!("{:?}", v.as_value()),
"MyEnum::MyVariant(\"hello\")"
);
} | rust_cleaned_test_functions.jsonl/55828 | {
"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,
75428,
69213,
21007,
368,
341,
262,
2036,
3017,
10766,
401,
262,
11605,
4104,
13128,
369,
3017,
10766,
341,
286,
5168,
438,
3142,
2099,
721,
8,
1464,
5162,
18291,
98377,
341,
310,
5162,
486,
9573,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_range() {
let mut tester: VecDeque<usize> = VecDeque::with_capacity(7);
let cap = tester.capacity();
let minlen = if cfg!(miri) { cap - 1 } else { 0 }; // Miri is too slow
for len in minlen..=cap {
for tail in 0..=cap {
for start in 0..=len {
for end in start..=len {
tester.tail = tail;
tester.head = tail;
for i in 0..len {
tester.push_back(i);
}
// Check that we iterate over the correct values
let range: VecDeque<_> = tester.range(start..end).copied().collect();
let expected: VecDeque<_> = (start..end).collect();
assert_eq!(range, expected);
}
}
}
}
} | rust_cleaned_test_functions.jsonl/80656 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 479
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9698,
368,
341,
262,
1077,
5206,
37111,
25,
11312,
73891,
90244,
29,
284,
11312,
73891,
486,
4197,
35603,
7,
22,
626,
262,
1077,
2062,
284,
37111,
59168,
543,
262,
1077,
1308,
2892,
284,
421,
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... | 7 |
#[test]
fn test_round_default() {
let result = round(to_value(2.1), HashMap::new());
assert!(result.is_ok());
assert_eq!(result.unwrap(), to_value(2.0));
} | rust_cleaned_test_functions.jsonl/62619 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 93
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
29896,
9993,
368,
341,
286,
1077,
1102,
284,
4778,
12186,
3142,
7,
17,
13,
16,
701,
10528,
486,
931,
1423,
286,
2060,
10297,
1382,
2079,
19817,
1423,
286,
2060,
10714,
10297,
1382,
55395,
1507,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_remove_network() {
let mut rt = Runtime::new().unwrap();
let mut connector = HostToReplyConnector::default();
connector.m.insert(
format!("{}://5f", if cfg!(windows) { "net.pipe" } else { "unix" }),
"HTTP/1.1 200 OK\r\nServer: mock1\r\nContent-Type: application/json\r\nContent-Length: 0\r\n\r\n".to_string()
);
let docker =
Docker::connect_with_host_to_reply(connector, "_".to_string(), 5, API_DEFAULT_VERSION)
.unwrap();
let results = docker.remove_network("my_network_name");
let future = results.map(|_| assert!(true));
rt.block_on(future)
.or_else(|e| {
println!("{:?}", e);
Err(e)
})
.unwrap();
rt.shutdown_now().wait().unwrap();
} | rust_cleaned_test_functions.jsonl/131312 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 443
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18193,
20966,
368,
341,
286,
1077,
5206,
16677,
284,
10954,
486,
931,
1005,
15454,
543,
286,
1077,
5206,
26989,
284,
16102,
1249,
20841,
35954,
486,
2258,
1428,
286,
26989,
744,
7030,
1006,
310,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_ntxid() {
let tx_bytes = Vec::from_hex("0100000001a15d57094aa7a21a28cb20b59aab8fc7d1149a3bdbcddba9c622e4f5f6a99ece010000006c493046022100f93bb0e7d8db7bd46e40132d1f8242026e045f03a0efe71bbb8e3f475e970d790221009337cd7f1f929f00cc6ff01f03729b069a7c21b59b1736ddfee5db5946c5da8c0121033b9b137ee87d5a812d6f506efdd37f0affa7ffc310711c06c7f3e097c9447c52ffffffff0100e1f505000000001976a9140389035a9225b3839e2bbf32d826a1e222031fd888ac00000000").unwrap();
let mut tx: Transaction = deserialize(&tx_bytes).unwrap();
let old_ntxid = tx.ntxid();
assert_eq!(format!("{:x}", old_ntxid), "c3573dbea28ce24425c59a189391937e00d255150fa973d59d61caf3a06b601d");
// changing sigs does not affect it
tx.input[0].script_sig = Script::new();
assert_eq!(old_ntxid, tx.ntxid());
// changing pks does
tx.output[0].script_pubkey = Script::new();
assert!(old_ntxid != tx.ntxid());
} | rust_cleaned_test_functions.jsonl/330 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 508
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
38945,
87,
307,
368,
341,
286,
1077,
9854,
12524,
284,
11312,
486,
1499,
32655,
445,
15,
16,
15,
15,
15,
15,
15,
15,
15,
16,
64,
16,
20,
67,
20,
22,
15,
24,
19,
5305,
22,
64,
17,
16,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_rpc_get_balance() {
let bob_pubkey = Pubkey::new_rand();
let (io, meta, _bank, _blockhash, _alice, _leader_pubkey) =
start_rpc_handler_with_tx(&bob_pubkey);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"getBalance","params":["{}"]}}"#,
bob_pubkey
);
let res = io.handle_request_sync(&req, meta);
let expected = format!(r#"{{"jsonrpc":"2.0","result":20,"id":1}}"#);
let expected: Response =
serde_json::from_str(&expected).expect("expected response deserialization");
let result: Response = serde_json::from_str(&res.expect("actual response"))
.expect("actual response deserialization");
assert_eq!(expected, result);
} | rust_cleaned_test_functions.jsonl/20296 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 366
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
60799,
3062,
29396,
368,
341,
286,
1077,
35192,
34014,
792,
284,
22611,
792,
486,
931,
33864,
543,
286,
1077,
320,
815,
11,
8823,
11,
716,
17033,
11,
716,
4574,
8296,
11,
716,
63195,
11,
716,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_decode_adr() {
match decode_16(0xa007) {
Instruction::ADR { params, thumb32 } => {
assert!(params.r == Reg::R0);
assert!(params.imm32 == 7 << 2);
assert!(!thumb32);
}
_ => {
assert!(false);
}
}
} | rust_cleaned_test_functions.jsonl/64756 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 180
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15227,
10027,
81,
368,
341,
1066,
262,
2432,
16895,
62,
16,
21,
7,
15,
9591,
15,
15,
22,
8,
341,
286,
29051,
486,
96473,
314,
3628,
11,
24050,
18,
17,
335,
589,
341,
310,
2060,
10297,
3519,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_prewrite_async_commit() {
let engine = TestEngineBuilder::new().build().unwrap();
let cm = concurrency_manager::ConcurrencyManager::new(1.into());
let key = b"k";
let value = b"v";
let mutations = vec![Mutation::make_put(Key::from_raw(key), value.to_vec())];
let mut statistics = Statistics::default();
let cmd = super::Prewrite::new(
mutations,
key.to_vec(),
10.into(),
0,
false,
1,
TimeStamp::default(),
TimeStamp::default(),
Some(vec![]),
false,
AssertionLevel::Off,
Context::default(),
);
let res = prewrite_command(&engine, cm.clone(), &mut statistics, cmd).unwrap();
assert!(!res.min_commit_ts.is_zero());
assert_eq!(res.one_pc_commit_ts, TimeStamp::zero());
must_locked(&engine, key, 10);
cm.update_max_ts(50.into());
let (k1, v1) = (b"k1", b"v1");
let (k2, v2) = (b"k2", b"v2");
let mutations = vec![
Mutation::make_put(Key::from_raw(k1), v1.to_vec()),
Mutation::make_put(Key::from_raw(k2), v2.to_vec()),
];
let mut statistics = Statistics::default();
// calculated_ts > max_commit_ts
// Test the idempotency of prewrite when falling back to 2PC.
for _ in 0..2 {
let cmd = super::Prewrite::new(
mutations.clone(),
k1.to_vec(),
20.into(),
0,
false,
2,
21.into(),
40.into(),
Some(vec![k2.to_vec()]),
false,
AssertionLevel::Off,
Context::default(),
);
let res = prewrite_command(&engine, cm.clone(), &mut statistics, cmd).unwrap();
assert!(res.min_commit_ts.is_zero());
assert!(res.one_pc_commit_ts.is_zero());
assert!(!must_locked(&engine, k1, 20).use_async_commit);
assert!(!must_locked(&engine, k2, 20).use_async_commit);
}
} | rust_cleaned_test_functions.jsonl/31425 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1178
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
52473,
28346,
36346,
368,
341,
286,
1077,
4712,
284,
3393,
4571,
3297,
486,
931,
1005,
5834,
1005,
15454,
543,
286,
1077,
9961,
284,
78010,
12144,
486,
79611,
2043,
486,
931,
7,
16,
39860,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_iterator_clone() {
let mut n = DList::new();
n.push_back(2);
n.push_back(3);
n.push_back(4);
let mut it = n.iter();
it.next();
let mut jt = it.clone();
assert_eq!(it.next(), jt.next());
assert_eq!(it.next_back(), jt.next_back());
assert_eq!(it.next(), jt.next());
} | rust_cleaned_test_functions.jsonl/56733 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 204
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13491,
54742,
368,
341,
286,
1077,
5206,
308,
284,
422,
852,
486,
931,
543,
286,
308,
2552,
3895,
7,
17,
317,
286,
308,
2552,
3895,
7,
18,
317,
286,
308,
2552,
3895,
7,
19,
317,
286,
1077,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_invalid_grow() {
let mut v: SmallVec<[u8; 8]> = SmallVec::new();
v.extend(0..8);
v.grow(5);
} | rust_cleaned_test_functions.jsonl/88152 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 86
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31433,
1889,
651,
368,
341,
286,
1077,
5206,
348,
25,
14994,
10050,
66746,
84,
23,
26,
220,
23,
25669,
284,
14994,
10050,
486,
931,
543,
286,
348,
15831,
7,
15,
496,
23,
317,
286,
348,
1302,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_utf16_space_with_one_bom_byte() {
let mut decoder = UTF_16LE.new_decoder();
let mut dst = [0u16; 12];
{
let needed = decoder.max_utf16_buffer_length(1).unwrap();
let (result, _, _, _) = decoder.decode_to_utf16(b"\xFF", &mut dst[..needed], false);
assert_eq!(result, CoderResult::InputEmpty);
}
{
let needed = decoder.max_utf16_buffer_length(1).unwrap();
let (result, _, _, _) = decoder.decode_to_utf16(b"\xFF", &mut dst[..needed], true);
assert_eq!(result, CoderResult::InputEmpty);
}
} | rust_cleaned_test_functions.jsonl/90268 | {
"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,
39453,
16,
21,
14663,
6615,
11667,
880,
316,
19737,
368,
341,
286,
1077,
5206,
24551,
284,
20076,
62,
16,
21,
867,
4618,
49843,
543,
286,
1077,
5206,
10648,
284,
508,
15,
84,
16,
21,
26,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ncomponents_err() {
let input = Dataset::from(Array::random((4, 4), Uniform::new(0.0, 1.0)));
let ica = FastIca::new().ncomponents(100);
let ica = ica.fit(&input);
assert!(ica.is_err());
} | rust_cleaned_test_functions.jsonl/84828 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 124
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1089,
5149,
9266,
368,
341,
286,
1077,
1946,
284,
39183,
486,
1499,
38192,
486,
11463,
1188,
19,
11,
220,
19,
701,
47889,
486,
931,
7,
15,
13,
15,
11,
220,
16,
13,
15,
4945,
286,
1077,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_index_version() {
assert_eq!(
IndexScanExecutorImpl::get_index_version(&[0x0, 0x7d, 0x1]).unwrap(),
1
);
assert_eq!(
IndexScanExecutorImpl::get_index_version(&[0x1, 0x7d, 0x1, 0x31]).unwrap(),
1
);
assert_eq!(
IndexScanExecutorImpl::get_index_version(&[
0x0, 0x7d, 0x1, 0x80, 0x0, 0x2, 0x0, 0x0, 0x0, 0x1, 0x2, 0x1, 0x0, 0x2, 0x0, 0x61,
0x31
])
.unwrap(),
1
);
assert_eq!(
IndexScanExecutorImpl::get_index_version(&[
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x31
])
.unwrap(),
0
);
assert_eq!(
IndexScanExecutorImpl::get_index_version(&[0x30]).unwrap(),
0
);
} | rust_cleaned_test_functions.jsonl/12240 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 576
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3560,
9438,
368,
341,
286,
2060,
10714,
33673,
310,
8008,
26570,
25255,
9673,
486,
455,
3560,
9438,
2099,
58,
15,
87,
15,
11,
220,
15,
87,
22,
67,
11,
220,
15,
87,
16,
10697,
15454,
3148,
31... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_simple_operator_in_encrypted_parse() {
let name1 = _random_string(10);
let value1 = _random_string(10);
let json = format!(r#"{{"{}":{{"$in":["{}"]}}}}"#, name1, value1);
let query = parse_from_json(&json).unwrap();
let expected = Operator::In(
TagName::EncryptedTagName(name1.to_vec()),
vec![TargetValue::Unencrypted(value1.clone())]
);
assert_eq!(query, expected);
} | rust_cleaned_test_functions.jsonl/11823 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 227
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
30015,
40594,
1243,
13781,
14026,
21039,
368,
341,
286,
1077,
829,
16,
284,
716,
11463,
3904,
7,
16,
15,
317,
286,
1077,
897,
16,
284,
716,
11463,
3904,
7,
16,
15,
626,
286,
1077,
2951,
284,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_nested() {
let json = r#"{
"": {"err": ["a"]},
"foo": {
"": {"err": ["b"]},
"bar": {
"": {"err": ["c"]}
}
}
}"#;
let mut map = MetaMap::new();
map.insert(".".to_string(), Meta::from_error("a"));
map.insert("foo".to_string(), Meta::from_error("b"));
map.insert("foo.bar".to_string(), Meta::from_error("c"));
assert_eq_dbg!(map, serde_json::from_str(json).unwrap());
} | rust_cleaned_test_functions.jsonl/126370 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 323
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
66279,
368,
341,
286,
1077,
2951,
284,
435,
55543,
515,
310,
330,
788,
5212,
615,
788,
4383,
64,
1341,
1583,
310,
330,
7975,
788,
341,
394,
330,
788,
5212,
615,
788,
4383,
65,
1341,
1583,
394,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_leading_whitespace_should_imply_padding() {
new_ucmd!()
.args(&["--from=auto"])
.pipe_in(" 1K")
.run()
.stdout_is(" 1000\n");
new_ucmd!()
.args(&["--from=auto"])
.pipe_in(" 202Ki")
.run()
.stdout_is(" 206848\n");
} | rust_cleaned_test_functions.jsonl/46009 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 186
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11751,
2228,
86175,
43378,
17895,
2541,
40726,
368,
341,
262,
501,
68887,
2277,
0,
741,
286,
659,
2116,
2099,
1183,
313,
1499,
28,
3902,
14108,
286,
659,
13768,
1243,
445,
256,
220,
16,
42,
1138... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_quic_server_no_params_received() {
let mut server_config =
make_server_config_with_versions(KeyType::ED25519, &[&rustls::version::TLS13]);
server_config.alpn_protocols = vec!["foo".into()];
let server_config = Arc::new(server_config);
let mut server =
ServerConnection::new_quic(server_config, quic::Version::V1, b"server params".to_vec())
.unwrap();
use ring::rand::SecureRandom;
use rustls::internal::msgs::base::PayloadU16;
use rustls::internal::msgs::enums::{
CipherSuite, Compression, HandshakeType, NamedGroup, SignatureScheme,
};
use rustls::internal::msgs::handshake::{
ClientHelloPayload, HandshakeMessagePayload, KeyShareEntry, Random, SessionID,
};
use rustls::internal::msgs::message::PlainMessage;
let rng = ring::rand::SystemRandom::new();
let mut random = [0; 32];
rng.fill(&mut random).unwrap();
let random = Random::from(random);
let kx = ring::agreement::EphemeralPrivateKey::generate(&ring::agreement::X25519, &rng)
.unwrap()
.compute_public_key()
.unwrap();
let client_hello = Message {
version: ProtocolVersion::TLSv1_3,
payload: MessagePayload::Handshake(HandshakeMessagePayload {
typ: HandshakeType::ClientHello,
payload: HandshakePayload::ClientHello(ClientHelloPayload {
client_version: ProtocolVersion::TLSv1_3,
random,
session_id: SessionID::random().unwrap(),
cipher_suites: vec![CipherSuite::TLS13_AES_128_GCM_SHA256],
compression_methods: vec![Compression::Null],
extensions: vec![
ClientExtension::SupportedVersions(vec![ProtocolVersion::TLSv1_3]),
ClientExtension::NamedGroups(vec![NamedGroup::X25519]),
ClientExtension::SignatureAlgorithms(vec![SignatureScheme::ED25519]),
ClientExtension::KeyShare(vec![KeyShareEntry {
group: NamedGroup::X25519,
payload: PayloadU16::new(kx.as_ref().to_vec()),
}]),
],
}),
}),
};
let buf = PlainMessage::from(client_hello)
.into_unencrypted_opaque()
.encode();
server
.read_tls(&mut buf.as_slice())
.unwrap();
assert_eq!(
server.process_new_packets().err(),
Some(Error::PeerMisbehavedError(
"QUIC transport parameters not found".into(),
)),
);
} | rust_cleaned_test_functions.jsonl/51945 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1435
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11280,
292,
12015,
6536,
6745,
40783,
368,
341,
286,
1077,
5206,
3538,
5332,
4035,
310,
1281,
12015,
5332,
6615,
65148,
21358,
929,
486,
1479,
17,
20,
20,
16,
24,
11,
44590,
5,
35788,
4730,
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_make_set() {
let test_cases: Vec<(Vec<ScalarValue>, _)> = vec![
(
vec![
Some(0b110).into(),
Some(b"DataBase".to_vec()).into(),
Some(b"Hello World!".to_vec()).into(),
],
Some(b"Hello World!".to_vec()),
),
(
vec![
Some(0b100).into(),
Some(b"DataBase".to_vec()).into(),
Some(b"Hello World!".to_vec()).into(),
],
Some(b"".to_vec()),
),
(
vec![
Some(0b0).into(),
Some(b"DataBase".to_vec()).into(),
Some(b"Hello World!".to_vec()).into(),
],
Some(b"".to_vec()),
),
(
vec![
Some(0b1).into(),
Some(b"DataBase".to_vec()).into(),
Some(b"Hello World!".to_vec()).into(),
],
Some(b"DataBase".to_vec()),
),
(
vec![
None::<Int>.into(),
Some(b"DataBase".to_vec()).into(),
Some(b"Hello World!".to_vec()).into(),
],
None,
),
(vec![None::<Int>.into(), None::<Bytes>.into()], None),
(
vec![
Some(0b1).into(),
None::<Bytes>.into(),
Some(b"Hello World!".to_vec()).into(),
],
Some(b"".to_vec()),
),
(
vec![
Some(0b11).into(),
None::<Bytes>.into(),
Some(b"Hello World!".to_vec()).into(),
],
Some(b"Hello World!".to_vec()),
),
(
vec![
Some(0b0).into(),
None::<Bytes>.into(),
Some(b"Hello World!".to_vec()).into(),
],
Some(b"".to_vec()),
),
(
vec![
Some(0xffffffff).into(),
None::<Bytes>.into(),
Some(b"Hello World!".to_vec()).into(),
None::<Bytes>.into(),
],
Some(b"Hello World!".to_vec()),
),
(
vec![
Some(0b10).into(),
Some(b"DataBase".to_vec()).into(),
Some(b"Hello World!".to_vec()).into(),
],
Some(b"Hello World!".to_vec()),
),
(
vec![
Some(0xffffffff).into(),
Some(b"a".to_vec()).into(),
Some(b"b".to_vec()).into(),
Some(b"c".to_vec()).into(),
],
Some(b"a,b,c".to_vec()),
),
(
vec![
Some(0xfffffffe).into(),
Some(b"a".to_vec()).into(),
Some(b"b".to_vec()).into(),
Some(b"c".to_vec()).into(),
],
Some(b"b,c".to_vec()),
),
(
vec![
Some(0xfffffffd).into(),
Some(b"a".to_vec()).into(),
Some(b"b".to_vec()).into(),
Some(b"c".to_vec()).into(),
],
Some(b"a,c".to_vec()),
),
];
for (args, expect_output) in test_cases {
let output = RpnFnScalarEvaluator::new()
.push_params(args)
.evaluate(ScalarFuncSig::MakeSet)
.unwrap();
assert_eq!(output, expect_output);
}
} | rust_cleaned_test_functions.jsonl/19757 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2754
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28230,
2602,
368,
341,
286,
1077,
1273,
41427,
25,
11312,
28706,
10050,
78505,
1130,
8066,
716,
16018,
284,
7486,
90515,
310,
2399,
394,
7486,
90515,
503,
4329,
7,
15,
65,
16,
16,
15,
568,
18122... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_batch_raft_cmd_request_builder() {
let mut cfg = Config::default();
cfg.raft_entry_max_size = ReadableSize(1000);
let mut builder = BatchRaftCmdRequestBuilder::<KvTestEngine>::new();
let mut q = Request::default();
let mut metric = RaftMetrics::new(true);
let mut req = RaftCmdRequest::default();
req.set_admin_request(AdminRequest::default());
assert!(!builder.can_batch(&cfg, &req, 0));
let mut req = RaftCmdRequest::default();
req.set_status_request(StatusRequest::default());
assert!(!builder.can_batch(&cfg, &req, 0));
let mut req = RaftCmdRequest::default();
let mut put = PutRequest::default();
put.set_key(b"aaaa".to_vec());
put.set_value(b"bbbb".to_vec());
q.set_cmd_type(CmdType::Put);
q.set_put(put);
req.mut_requests().push(q.clone());
let _ = q.take_put();
let req_size = req.compute_size();
assert!(builder.can_batch(&cfg, &req, req_size));
let mut req = RaftCmdRequest::default();
q.set_cmd_type(CmdType::Snap);
req.mut_requests().push(q.clone());
let mut put = PutRequest::default();
put.set_key(b"aaaa".to_vec());
put.set_value(b"bbbb".to_vec());
q.set_cmd_type(CmdType::Put);
q.set_put(put);
req.mut_requests().push(q.clone());
let req_size = req.compute_size();
assert!(!builder.can_batch(&cfg, &req, req_size));
let mut req = RaftCmdRequest::default();
let mut put = PutRequest::default();
put.set_key(b"aaaa".to_vec());
put.set_value(vec![8_u8; 2000]);
q.set_cmd_type(CmdType::Put);
q.set_put(put);
req.mut_requests().push(q.clone());
let req_size = req.compute_size();
assert!(!builder.can_batch(&cfg, &req, req_size));
// Check batch callback
let mut req = RaftCmdRequest::default();
let mut put = PutRequest::default();
put.set_key(b"aaaa".to_vec());
put.set_value(vec![8_u8; 20]);
q.set_cmd_type(CmdType::Put);
q.set_put(put);
req.mut_requests().push(q);
let mut cbs_flags = vec![];
let mut proposed_cbs_flags = vec![];
let mut committed_cbs_flags = vec![];
let mut response = RaftCmdResponse::default();
for i in 0..10 {
let flag = Arc::new(AtomicBool::new(false));
cbs_flags.push(flag.clone());
// Some commands don't have proposed_cb.
let proposed_cb: Option<ExtCallback> = if i % 2 == 0 {
let proposed_flag = Arc::new(AtomicBool::new(false));
proposed_cbs_flags.push(proposed_flag.clone());
Some(Box::new(move || {
proposed_flag.store(true, Ordering::Release);
}))
} else {
None
};
let committed_cb: Option<ExtCallback> = if i % 3 == 0 {
let committed_flag = Arc::new(AtomicBool::new(false));
committed_cbs_flags.push(committed_flag.clone());
Some(Box::new(move || {
committed_flag.store(true, Ordering::Release);
}))
} else {
None
};
let cb = Callback::write_ext(
Box::new(move |_resp| {
flag.store(true, Ordering::Release);
}),
proposed_cb,
committed_cb,
);
response.mut_responses().push(Response::default());
let cmd = RaftCommand::new(req.clone(), cb);
builder.add(cmd, 100);
}
let (request, mut callback) = builder.build(&mut metric).unwrap();
callback.invoke_proposed();
for flag in proposed_cbs_flags {
assert!(flag.load(Ordering::Acquire));
}
callback.invoke_committed();
for flag in committed_cbs_flags {
assert!(flag.load(Ordering::Acquire));
}
assert_eq!(10, request.get_requests().len());
callback.invoke_with_response(response);
for flag in cbs_flags {
assert!(flag.load(Ordering::Acquire));
}
} | rust_cleaned_test_functions.jsonl/22865 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2122
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14534,
62,
2944,
11684,
7893,
28532,
368,
341,
286,
1077,
5206,
13286,
284,
5532,
486,
2258,
543,
286,
13286,
13,
2944,
9078,
6345,
2368,
284,
4457,
480,
1695,
7,
16,
15,
15,
15,
317,
286,
107... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
#[test]
fn test_merge_kind_get_if_mergeable() {
let mut transaction_context = TransactionContext::new(Vec::new(), 1);
let invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
let authority_pubkey = Pubkey::new_unique();
let initial_lamports = 4242424242;
let rent = Rent::default();
let rent_exempt_reserve = rent.minimum_balance(std::mem::size_of::<StakeState>());
let stake_lamports = rent_exempt_reserve + initial_lamports;
let meta = Meta {
rent_exempt_reserve,
..Meta::auto(&authority_pubkey)
};
let stake_account = AccountSharedData::new_ref_data_with_space(
stake_lamports,
&StakeState::Uninitialized,
std::mem::size_of::<StakeState>(),
&id(),
)
.expect("stake_account");
let stake_keyed_account = KeyedAccount::new(&authority_pubkey, true, &stake_account);
let mut clock = Clock::default();
let mut stake_history = StakeHistory::default();
// Uninitialized state fails
assert_eq!(
MergeKind::get_if_mergeable(
&invoke_context,
&stake_keyed_account,
&clock,
&stake_history
)
.unwrap_err(),
InstructionError::InvalidAccountData
);
// RewardsPool state fails
stake_keyed_account
.set_state(&StakeState::RewardsPool)
.unwrap();
assert_eq!(
MergeKind::get_if_mergeable(
&invoke_context,
&stake_keyed_account,
&clock,
&stake_history
)
.unwrap_err(),
InstructionError::InvalidAccountData
);
// Initialized state succeeds
stake_keyed_account
.set_state(&StakeState::Initialized(meta))
.unwrap();
assert_eq!(
MergeKind::get_if_mergeable(
&invoke_context,
&stake_keyed_account,
&clock,
&stake_history
)
.unwrap(),
MergeKind::Inactive(meta, stake_lamports)
);
clock.epoch = 0;
let mut effective = 2 * initial_lamports;
let mut activating = 0;
let mut deactivating = 0;
stake_history.add(
clock.epoch,
StakeHistoryEntry {
effective,
activating,
deactivating,
},
);
clock.epoch += 1;
activating = initial_lamports;
stake_history.add(
clock.epoch,
StakeHistoryEntry {
effective,
activating,
deactivating,
},
);
let stake = Stake {
delegation: Delegation {
stake: initial_lamports,
activation_epoch: 1,
deactivation_epoch: 5,
..Delegation::default()
},
..Stake::default()
};
stake_keyed_account
.set_state(&StakeState::Stake(meta, stake))
.unwrap();
// activation_epoch succeeds
assert_eq!(
MergeKind::get_if_mergeable(
&invoke_context,
&stake_keyed_account,
&clock,
&stake_history
)
.unwrap(),
MergeKind::ActivationEpoch(meta, stake),
);
loop {
clock.epoch += 1;
let delta =
activating.min((effective as f64 * stake.delegation.warmup_cooldown_rate) as u64);
effective += delta;
activating -= delta;
stake_history.add(
clock.epoch,
StakeHistoryEntry {
effective,
activating,
deactivating,
},
);
if activating == 0 {
break;
}
assert_eq!(
MergeKind::get_if_mergeable(
&invoke_context,
&stake_keyed_account,
&clock,
&stake_history
)
.unwrap_err(),
InstructionError::from(StakeError::MergeTransientStake),
);
}
// all epochs for which we're fully active succeed
while clock.epoch < stake.delegation.deactivation_epoch - 1 {
clock.epoch += 1;
stake_history.add(
clock.epoch,
StakeHistoryEntry {
effective,
activating,
deactivating,
},
);
assert_eq!(
MergeKind::get_if_mergeable(
&invoke_context,
&stake_keyed_account,
&clock,
&stake_history
)
.unwrap(),
MergeKind::FullyActive(meta, stake),
);
}
clock.epoch += 1;
deactivating = stake.delegation.stake;
stake_history.add(
clock.epoch,
StakeHistoryEntry {
effective,
activating,
deactivating,
},
);
assert_eq!(
MergeKind::get_if_mergeable(
&invoke_context,
&stake_keyed_account,
&clock,
&stake_history
)
.unwrap_err(),
InstructionError::from(StakeError::MergeTransientStake),
);
loop {
clock.epoch += 1;
let delta =
deactivating.min((effective as f64 * stake.delegation.warmup_cooldown_rate) as u64);
effective -= delta;
deactivating -= delta;
stake_history.add(
clock.epoch,
StakeHistoryEntry {
effective,
activating,
deactivating,
},
);
if deactivating == 0 {
break;
}
assert_eq!(
MergeKind::get_if_mergeable(
&invoke_context,
&stake_keyed_account,
&clock,
&stake_history
)
.unwrap_err(),
InstructionError::from(StakeError::MergeTransientStake),
);
}
// first fully-deactivated epoch succeeds
assert_eq!(
MergeKind::get_if_mergeable(
&invoke_context,
&stake_keyed_account,
&clock,
&stake_history
)
.unwrap(),
MergeKind::Inactive(meta, stake_lamports),
);
} | rust_cleaned_test_functions.jsonl/51813 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 4105
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20888,
33162,
3062,
11119,
20888,
480,
368,
341,
286,
1077,
5206,
7745,
8467,
284,
17869,
1972,
486,
931,
49923,
486,
931,
1507,
220,
16,
317,
286,
1077,
19873,
8467,
284,
39667,
1972,
486,
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... | 4 |
#[test]
fn test_masked_eq_operator() {
// check use case for SeccompCmpArgLen::DWORD
let rules = vec![allow_syscall_if(
libc::SYS_ioctl,
vec![SeccompRule::new(
vec![Cond::new(
1,
SeccompCmpArgLen::DWORD,
MaskedEq(KVM_GET_PIT2_MSB),
KVM_GET_PIT2,
)
.unwrap()],
SeccompAction::Allow,
)],
)];
// check syscalls that are supposed to work
validate_seccomp_filter(
rules.clone(),
|| unsafe {
libc::ioctl(0, KVM_GET_PIT2 as IoctlRequest);
libc::ioctl(0, KVM_GET_PIT2_MSB as IoctlRequest);
},
false,
);
// check syscalls that are not supposed to work
validate_seccomp_filter(
rules.clone(),
|| unsafe {
libc::ioctl(0, KVM_GET_PIT2_LSB as IoctlRequest);
},
true,
);
// check use case for SeccompCmpArgLen::QWORD
let rules = vec![allow_syscall_if(
libc::SYS_ioctl,
vec![SeccompRule::new(
vec![Cond::new(
2,
SeccompCmpArgLen::QWORD,
MaskedEq(u64::from(std::u32::MAX)),
std::u64::MAX,
)
.unwrap()],
SeccompAction::Allow,
)],
)];
// check syscalls that are supposed to work
validate_seccomp_filter(
rules.clone(),
|| unsafe {
libc::ioctl(0, 0 as IoctlRequest, u64::from(std::u32::MAX));
libc::ioctl(0, 0 as IoctlRequest, std::u64::MAX);
},
false,
);
// check syscalls that are not supposed to work
validate_seccomp_filter(
rules.clone(),
|| unsafe {
libc::ioctl(0, 0 as IoctlRequest, 0);
},
true,
);
} | rust_cleaned_test_functions.jsonl/17473 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1289
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9999,
291,
10714,
40594,
368,
341,
286,
442,
1779,
990,
1142,
369,
1345,
638,
14435,
34,
1307,
2735,
11271,
486,
32504,
198,
286,
1077,
5601,
284,
7486,
20703,
7183,
20344,
6659,
11119,
1006,
310,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
#[test]
fn test_get_fields_of() {
let base = test_base();
let id = test_id();
let schema = test_schema();
let logger = test_logger();
let fork = SubgraphFork::new(base, id, schema, logger).unwrap();
assert_eq!(fork.get_fields_of("Gravatar").unwrap(), &test_fields());
} | rust_cleaned_test_functions.jsonl/8653 | {
"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,
3062,
12132,
3575,
368,
341,
286,
1077,
2331,
284,
1273,
7651,
543,
286,
1077,
877,
284,
1273,
842,
543,
286,
1077,
10802,
284,
1273,
25371,
543,
286,
1077,
5925,
284,
1273,
27413,
1428,
286,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_set_loot_box_id_with_not_owner() {
let mut context = get_context(accounts(0));
testing_env!(context.build());
let mut contract = Contract::new(accounts(0).into(), 10);
// caller is not owner
testing_env!(context
.storage_usage(env::storage_usage())
.attached_deposit(150000000000000000000)
.predecessor_account_id(accounts(1))
.build());
contract.set_loot_box_id(accounts(0).into());
} | rust_cleaned_test_functions.jsonl/118756 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 238
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2602,
5560,
354,
10194,
842,
6615,
7913,
29027,
368,
341,
286,
1077,
5206,
2266,
284,
633,
8467,
91868,
7,
15,
1106,
286,
7497,
15879,
10297,
2147,
13239,
1423,
286,
1077,
5206,
5116,
284,
19185,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_response() {
fn parse(s: &str) -> ParsedMessage<StatusCode> {
parse_with_method(s, Method::GET)
}
fn parse_ignores(s: &str) {
let mut bytes = BytesMut::from(s);
assert!(Client::parse(
&mut bytes,
ParseContext {
cached_headers: &mut None,
req_method: &mut Some(Method::GET),
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")
.is_none())
}
fn parse_with_method(s: &str, m: Method) -> ParsedMessage<StatusCode> {
let mut bytes = BytesMut::from(s);
Client::parse(
&mut bytes,
ParseContext {
cached_headers: &mut None,
req_method: &mut Some(m),
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) -> crate::error::Parse {
let mut bytes = BytesMut::from(s);
Client::parse(
&mut bytes,
ParseContext {
cached_headers: &mut None,
req_method: &mut Some(Method::GET),
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("parse should err")
}
// no content-length or transfer-encoding means close-delimited
assert_eq!(
parse(
"\
HTTP/1.1 200 OK\r\n\
\r\n\
"
)
.decode,
DecodedLength::CLOSE_DELIMITED
);
// 204 and 304 never have a body
assert_eq!(
parse(
"\
HTTP/1.1 204 No Content\r\n\
\r\n\
"
)
.decode,
DecodedLength::ZERO
);
assert_eq!(
parse(
"\
HTTP/1.1 304 Not Modified\r\n\
\r\n\
"
)
.decode,
DecodedLength::ZERO
);
// content-length
assert_eq!(
parse(
"\
HTTP/1.1 200 OK\r\n\
content-length: 8\r\n\
\r\n\
"
)
.decode,
DecodedLength::new(8)
);
assert_eq!(
parse(
"\
HTTP/1.1 200 OK\r\n\
content-length: 8\r\n\
content-length: 8\r\n\
\r\n\
"
)
.decode,
DecodedLength::new(8)
);
parse_err(
"\
HTTP/1.1 200 OK\r\n\
content-length: 8\r\n\
content-length: 9\r\n\
\r\n\
",
);
parse_err(
"\
HTTP/1.1 200 OK\r\n\
content-length: +8\r\n\
\r\n\
",
);
// transfer-encoding: chunked
assert_eq!(
parse(
"\
HTTP/1.1 200 OK\r\n\
transfer-encoding: chunked\r\n\
\r\n\
"
)
.decode,
DecodedLength::CHUNKED
);
// transfer-encoding not-chunked is close-delimited
assert_eq!(
parse(
"\
HTTP/1.1 200 OK\r\n\
transfer-encoding: yolo\r\n\
\r\n\
"
)
.decode,
DecodedLength::CLOSE_DELIMITED
);
// transfer-encoding and content-length = chunked
assert_eq!(
parse(
"\
HTTP/1.1 200 OK\r\n\
content-length: 10\r\n\
transfer-encoding: chunked\r\n\
\r\n\
"
)
.decode,
DecodedLength::CHUNKED
);
assert_eq!(
parse_with_method(
"\
HTTP/1.1 200 OK\r\n\
content-length: 8\r\n\
\r\n\
",
Method::HEAD
)
.decode,
DecodedLength::ZERO
);
// CONNECT with 200 never has body
{
let msg = parse_with_method(
"\
HTTP/1.1 200 OK\r\n\
\r\n\
",
Method::CONNECT,
);
assert_eq!(msg.decode, DecodedLength::ZERO);
assert!(!msg.keep_alive, "should be upgrade");
assert!(msg.wants_upgrade, "should be upgrade");
}
// CONNECT receiving non 200 can have a body
assert_eq!(
parse_with_method(
"\
HTTP/1.1 400 Bad Request\r\n\
\r\n\
",
Method::CONNECT
)
.decode,
DecodedLength::CLOSE_DELIMITED
);
// 1xx status codes
parse_ignores(
"\
HTTP/1.1 100 Continue\r\n\
\r\n\
",
);
parse_ignores(
"\
HTTP/1.1 103 Early Hints\r\n\
\r\n\
",
);
// 101 upgrade not supported yet
{
let msg = parse(
"\
HTTP/1.1 101 Switching Protocols\r\n\
\r\n\
",
);
assert_eq!(msg.decode, DecodedLength::ZERO);
assert!(!msg.keep_alive, "should be last");
assert!(msg.wants_upgrade, "should be upgrade");
}
// http/1.0
assert_eq!(
parse(
"\
HTTP/1.0 200 OK\r\n\
\r\n\
"
)
.decode,
DecodedLength::CLOSE_DELIMITED
);
// 1.0 doesn't understand chunked
parse_err(
"\
HTTP/1.0 200 OK\r\n\
transfer-encoding: chunked\r\n\
\r\n\
",
);
// keep-alive
assert!(
parse(
"\
HTTP/1.1 200 OK\r\n\
content-length: 0\r\n\
\r\n\
"
)
.keep_alive,
"HTTP/1.1 keep-alive is default"
);
assert!(
!parse(
"\
HTTP/1.1 200 OK\r\n\
content-length: 0\r\n\
connection: foo, close, bar\r\n\
\r\n\
"
)
.keep_alive,
"connection close is always close"
);
assert!(
!parse(
"\
HTTP/1.0 200 OK\r\n\
content-length: 0\r\n\
\r\n\
"
)
.keep_alive,
"HTTP/1.0 close is default"
);
assert!(
parse(
"\
HTTP/1.0 200 OK\r\n\
content-length: 0\r\n\
connection: foo, keep-alive, bar\r\n\
\r\n\
"
)
.keep_alive,
"connection keep-alive is always keep-alive"
);
} | rust_cleaned_test_functions.jsonl/7666 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 5984
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
49843,
9655,
368,
341,
286,
5168,
4715,
1141,
25,
609,
495,
8,
1464,
393,
18112,
2052,
27,
15872,
29,
341,
310,
4715,
6615,
9032,
1141,
11,
6730,
486,
3806,
340,
286,
555,
286,
5168,
4715,
62,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_eval_with_trial() {
let mut trial_map = HashMap::new();
trial_map.insert("foo".to_owned(), Metric::Selector(BAR_SELECTOR.clone()));
trial_map.insert("foo_plus_one".to_owned(), Metric::Eval("foo+1".to_owned()));
trial_map.insert("oops_plus_one".to_owned(), Metric::Eval("oops+1".to_owned()));
trial_map.insert("ab_plus_one".to_owned(), Metric::Eval("a::b+1".to_owned()));
trial_map.insert("ac_plus_one".to_owned(), Metric::Eval("a::c+1".to_owned()));
// The file "a" should be completely ignored when testing foo_file.
let mut a_map = HashMap::new();
a_map.insert("b".to_owned(), Metric::Eval("2".to_owned()));
a_map.insert("c".to_owned(), Metric::Eval("3".to_owned()));
a_map.insert("foo".to_owned(), Metric::Eval("4".to_owned()));
let mut metrics = HashMap::new();
metrics.insert("foo_file".to_owned(), trial_map);
metrics.insert("a".to_owned(), a_map);
let trial_state =
MetricState::new(&metrics, Fetcher::TrialData(FOO_42_AB_7_TRIAL_FETCHER.clone()), None);
// foo from values shadows foo selector.
assert_eq!(
trial_state.evaluate_variable("foo_file", variable!("foo")),
MetricValue::Int(42)
);
// Value shadowing also works in expressions.
assert_eq!(
trial_state.evaluate_variable("foo_file", variable!("foo_plus_one")),
MetricValue::Int(43)
);
// foo can shadow eval as well as selector.
assert_eq!(trial_state.evaluate_variable("a", variable!("foo")), MetricValue::Int(42));
require_missing(
trial_state.evaluate_variable("foo_file", variable!("oops_plus_one")),
"Trial found nonexistent name",
);
// a::b ignores the "b" in file "a" and uses "a::b" from values.
assert_eq!(
trial_state.evaluate_variable("foo_file", variable!("ab_plus_one")),
MetricValue::Int(8)
);
require_missing(
trial_state.evaluate_variable("foo_file", variable!("ac_plus_one")),
"Trial should not have read c from file a",
);
} | rust_cleaned_test_functions.jsonl/126959 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1032
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21296,
6615,
63486,
368,
341,
286,
1077,
5206,
9091,
5376,
284,
10528,
486,
931,
543,
1789,
286,
9091,
5376,
7030,
445,
7975,
3263,
983,
51973,
1507,
52458,
486,
5877,
5349,
934,
72396,
15997,
739... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_lhld_high() {
let mut state = State8080::empty_state();
state.memory = vec![0; 0x2ff];
state.write_memory(0x00, 0x2a);
state.write_memory(0x01, 0xab);
state.write_memory(0x02, 0x02);
state.write_memory(0x2ab, 0xff);
state.write_memory(0x2ac, 0x03);
state.l = 0x00;
state.h = 0x00;
emulate_8080_op(&mut state);
assert_eq!(state.l, 0xff);
assert_eq!(state.h, 0x03);
assert_eq!(state.program_counter(), 3);
} | rust_cleaned_test_functions.jsonl/7801 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 292
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
907,
71,
507,
22680,
368,
341,
286,
1077,
5206,
1584,
284,
3234,
23,
15,
23,
15,
486,
3194,
4387,
543,
286,
1584,
36611,
284,
7486,
20703,
15,
26,
220,
15,
87,
17,
542,
935,
286,
1584,
3836,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_name_eq_is_case_insensitive() {
let mime1 = Mime::from_str(r#"text/x-custom; abc=a"#).unwrap();
let mime2 = Mime::from_str(r#"text/x-custom; aBc=a"#).unwrap();
assert_eq!(mime1, mime2);
} | rust_cleaned_test_functions.jsonl/99142 | {
"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,
1269,
10714,
6892,
19096,
34386,
18723,
368,
341,
286,
1077,
45270,
16,
284,
82430,
486,
1499,
2895,
2601,
55543,
1318,
10776,
36898,
26,
39022,
24239,
57676,
568,
15454,
543,
286,
1077,
45270,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_switch_directions() {
assert_eq!(should_switch_directions(20, 0), false);
assert_eq!(should_switch_directions(20, 1), false);
assert_eq!(should_switch_directions(20, 14), false);
assert_eq!(should_switch_directions(20, 15), true);
assert_eq!(should_switch_directions(20, 16), false);
assert_eq!(should_switch_directions(20, 19), false);
assert_eq!(should_switch_directions(20, 20), true);
assert_eq!(should_switch_directions(20, 21), false);
assert_eq!(should_switch_directions(20, 99), false);
assert_eq!(should_switch_directions(20, 100), true);
assert_eq!(should_switch_directions(20, 101), false);
} | rust_cleaned_test_functions.jsonl/1525 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 311
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
27652,
25438,
82,
368,
341,
286,
2060,
10714,
10297,
5445,
27652,
25438,
82,
7,
17,
15,
11,
220,
15,
701,
895,
317,
286,
2060,
10714,
10297,
5445,
27652,
25438,
82,
7,
17,
15,
11,
220,
16,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_as_str() {
assert_eq!(Get.as_ref(), "GET");
assert_eq!(Post.as_ref(), "POST");
assert_eq!(Put.as_ref(), "PUT");
assert_eq!(Extension("MOVE".to_owned()).as_ref(), "MOVE");
} | rust_cleaned_test_functions.jsonl/73813 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 122
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11898,
2895,
368,
341,
286,
2060,
10714,
10297,
1949,
5357,
7793,
1507,
330,
3806,
797,
286,
2060,
10714,
10297,
4133,
5357,
7793,
1507,
330,
2946,
797,
286,
2060,
10714,
10297,
19103,
5357,
7793,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_as_ref() {
let p: Point3<i32> = Point3::new(1, 2, 3);
let p_ref: &[i32; 3] = p.as_ref();
assert_eq!(p_ref, &[1, 2, 3]);
} | rust_cleaned_test_functions.jsonl/4560 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 105
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11898,
7793,
368,
341,
286,
1077,
281,
25,
5126,
18,
21897,
18,
17,
29,
284,
5126,
18,
486,
931,
7,
16,
11,
220,
17,
11,
220,
18,
317,
286,
1077,
281,
7793,
25,
44590,
72,
18,
17,
26,
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_pv_subclass_calls() {
let hdr = indoc! {"
#include <cstdint>
extern \"C\" void mark_c_called() noexcept;
extern \"C\" void mark_d_called() noexcept;
extern \"C\" void mark_e_called() noexcept;
extern \"C\" void mark_f_called() noexcept;
extern \"C\" void mark_g_called() noexcept;
extern \"C\" void mark_h_called() noexcept;
class TestObserver {
public:
TestObserver() {}
virtual uint32_t a(uint32_t) const = 0;
virtual uint32_t b(uint32_t) = 0;
virtual uint32_t c(uint32_t) const { mark_c_called(); return 0; };
virtual uint32_t d(uint32_t) { mark_d_called(); return 0; };
virtual uint32_t e(uint32_t) const { mark_e_called(); return 0; };
virtual uint32_t f(uint32_t) { mark_f_called(); return 0; };
virtual uint32_t g(uint32_t) const { mark_g_called(); return 0; };
virtual uint32_t h(uint32_t) { mark_h_called(); return 0; };
virtual ~TestObserver() {}
};
extern TestObserver* obs;
inline void register_observer(TestObserver& a) {
obs = &a;
}
inline uint32_t call_a(uint32_t param) {
return obs->a(param);
}
inline uint32_t call_b(uint32_t param) {
return obs->b(param);
}
inline uint32_t call_c(uint32_t param) {
return obs->c(param);
}
inline uint32_t call_d(uint32_t param) {
return obs->d(param);
}
inline uint32_t call_e(uint32_t param) {
return obs->e(param);
}
inline uint32_t call_f(uint32_t param) {
return obs->f(param);
}
inline uint32_t call_g(uint32_t param) {
return obs->g(param);
}
inline uint32_t call_h(uint32_t param) {
return obs->h(param);
}
"};
run_test_ex(
"TestObserver* obs;",
hdr,
quote! {
let obs = MyTestObserver::new_rust_owned(
MyTestObserver::default()
);
ffi::register_observer(obs.as_ref().borrow_mut().pin_mut());
assert_eq!(ffi::call_a(1), 2);
assert!(Lazy::force(&STATUS).lock().unwrap().sub_a_called);
*Lazy::force(&STATUS).lock().unwrap() = Default::default();
assert_eq!(ffi::call_b(1), 3);
assert!(Lazy::force(&STATUS).lock().unwrap().sub_b_called);
*Lazy::force(&STATUS).lock().unwrap() = Default::default();
assert_eq!(ffi::call_c(1), 4);
assert!(Lazy::force(&STATUS).lock().unwrap().sub_c_called);
assert!(!Lazy::force(&STATUS).lock().unwrap().super_c_called);
*Lazy::force(&STATUS).lock().unwrap() = Default::default();
assert_eq!(ffi::call_d(1), 5);
assert!(Lazy::force(&STATUS).lock().unwrap().sub_d_called);
assert!(!Lazy::force(&STATUS).lock().unwrap().super_d_called);
*Lazy::force(&STATUS).lock().unwrap() = Default::default();
assert_eq!(ffi::call_e(1), 0);
assert!(Lazy::force(&STATUS).lock().unwrap().sub_e_called);
assert!(Lazy::force(&STATUS).lock().unwrap().super_e_called);
*Lazy::force(&STATUS).lock().unwrap() = Default::default();
assert_eq!(ffi::call_f(1), 0);
assert!(Lazy::force(&STATUS).lock().unwrap().sub_f_called);
assert!(Lazy::force(&STATUS).lock().unwrap().super_f_called);
*Lazy::force(&STATUS).lock().unwrap() = Default::default();
assert_eq!(ffi::call_g(1), 0);
assert!(Lazy::force(&STATUS).lock().unwrap().super_g_called);
*Lazy::force(&STATUS).lock().unwrap() = Default::default();
assert_eq!(ffi::call_h(1), 0);
assert!(Lazy::force(&STATUS).lock().unwrap().super_h_called);
*Lazy::force(&STATUS).lock().unwrap() = Default::default();
},
quote! {
generate!("register_observer")
generate!("call_a")
generate!("call_b")
generate!("call_c")
generate!("call_d")
generate!("call_e")
generate!("call_f")
generate!("call_g")
generate!("call_h")
subclass!("TestObserver",MyTestObserver)
},
None,
None,
Some(quote! {
use once_cell::sync::Lazy;
use std::sync::Mutex;
use autocxx::subclass::CppSubclass;
use ffi::TestObserver_methods;
#[autocxx::subclass::subclass]
#[derive(Default)]
pub struct MyTestObserver {
}
impl TestObserver_methods for MyTestObserver {
// a and b are pure virtual
fn a(&self, param: u32) -> u32 {
Lazy::force(&STATUS).lock().unwrap().sub_a_called = true;
param + 1
}
fn b(&mut self, param: u32) -> u32 {
Lazy::force(&STATUS).lock().unwrap().sub_b_called = true;
param + 2
}
// c and d we override the superclass
fn c(&self, param: u32) -> u32 {
Lazy::force(&STATUS).lock().unwrap().sub_c_called = true;
param + 3
}
fn d(&mut self, param: u32) -> u32 {
Lazy::force(&STATUS).lock().unwrap().sub_d_called = true;
param + 4
}
// e and f we call through to the superclass
fn e(&self, param: u32) -> u32 {
Lazy::force(&STATUS).lock().unwrap().sub_e_called = true;
self.peer().e_super(param)
}
fn f(&mut self, param: u32) -> u32 {
Lazy::force(&STATUS).lock().unwrap().sub_f_called = true;
self.peer_mut().f_super(param)
}
// the superclass
}
#[no_mangle]
pub fn mark_c_called() {
Lazy::force(&STATUS).lock().unwrap().super_c_called = true;
}
#[no_mangle]
pub fn mark_d_called() {
Lazy::force(&STATUS).lock().unwrap().super_d_called = true;
}
#[no_mangle]
pub fn mark_e_called() {
Lazy::force(&STATUS).lock().unwrap().super_e_called = true;
}
#[no_mangle]
pub fn mark_f_called() {
Lazy::force(&STATUS).lock().unwrap().super_f_called = true;
}
#[no_mangle]
pub fn mark_g_called() {
Lazy::force(&STATUS).lock().unwrap().super_g_called = true;
}
#[no_mangle]
pub fn mark_h_called() {
Lazy::force(&STATUS).lock().unwrap().super_h_called = true;
}
#[derive(Default)]
struct Status {
super_c_called: bool,
super_d_called: bool,
super_e_called: bool,
super_f_called: bool,
super_g_called: bool,
super_h_called: bool,
sub_a_called: bool,
sub_b_called: bool,
sub_c_called: bool,
sub_d_called: bool,
sub_e_called: bool,
sub_f_called: bool,
}
static STATUS: Lazy<Mutex<Status>> = Lazy::new(|| Mutex::new(Status::default()));
}),
);
} | rust_cleaned_test_functions.jsonl/9953 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 4037
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
91139,
5228,
1040,
45636,
368,
341,
262,
1077,
36615,
284,
1257,
509,
0,
314,
698,
262,
671,
997,
366,
96975,
397,
262,
15637,
7245,
34,
2105,
737,
1868,
666,
27859,
368,
20583,
280,
262,
15637,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_reference_vector_l3_nonstandard_sideinfo_size() {
let test_vector = include_bytes!("../vectors/l3-nonstandard-sideinfo-size.bit");
test_vs_minimp3(test_vector);
} | rust_cleaned_test_functions.jsonl/69850 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 79
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25433,
12247,
907,
18,
21637,
20270,
30862,
2733,
2368,
368,
341,
262,
1077,
1273,
12247,
284,
2924,
12524,
17223,
1244,
85,
10605,
13328,
18,
98700,
20270,
24067,
2733,
7174,
30099,
797,
262,
1273,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_name_match_without_filter_expr() -> Result<()> {
set_rustflags();
let test_filter = TestFilterBuilder::new(
RunIgnored::Default,
None,
vec!["test_multiply_two", "tests::call_dylib_add_two"],
vec![],
);
let test_list = FIXTURE_TARGETS.make_test_list(&test_filter, &TargetRunner::empty());
for test in test_list.iter_tests() {
if test.name.contains("test_multiply_two")
|| test.name.contains("tests::call_dylib_add_two")
{
assert!(
test.test_info.filter_match.is_match(),
"expected test {test:?} to be a match, but it isn't"
);
} else {
assert!(
!test.test_info.filter_match.is_match(),
"expected test {test:?} to not be a match, but it is"
)
}
}
Ok(())
} | rust_cleaned_test_functions.jsonl/118817 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 456
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1269,
10708,
39904,
8727,
21915,
368,
1464,
5714,
71698,
341,
262,
738,
1710,
590,
11161,
1428,
262,
1077,
1273,
8727,
284,
3393,
5632,
3297,
486,
931,
1006,
286,
6452,
43337,
3018,
486,
3675,
345... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_read_write_le_mem() {
let uints = [0, 1, 2, 42, 10_123, 100_123_456, ::u64::max_value];
let mut writer = MemWriter::new();
for i in uints.iter() {
writer.write_le_u64_(*i);
}
let mut reader = MemReader::new(writer.inner());
for i in uints.iter() {
assert!(reader.read_le_u64_() == *i);
}
} | rust_cleaned_test_functions.jsonl/38075 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 210
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
9165,
11751,
12976,
368,
341,
286,
1077,
2622,
82,
284,
508,
15,
11,
220,
16,
11,
220,
17,
11,
220,
19,
17,
11,
220,
16,
15,
62,
16,
17,
18,
11,
220,
16,
15,
15,
62,
16,
17,
18,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_concurrent_requests_2_conns() {
let mut options = ResolverOpts::default();
options.num_concurrent_reqs = 2;
// we want to make sure that both udp connections are called
// this will count down to 0 only if both are called.
let on_send = OnSendBarrier::new(2);
let query = Query::query(Name::from_str("www.example.com.").unwrap(), RecordType::A);
let udp_record = v4_record(query.name().clone(), Ipv4Addr::new(127, 0, 0, 1));
let udp_message = message(query.clone(), vec![udp_record.clone()], vec![], vec![]);
let udp1_nameserver =
mock_nameserver_on_send(vec![Ok(udp_message.into())], options, on_send.clone());
let udp2_nameserver = mock_nameserver_on_send(vec![], options, on_send);
let mut pool = mock_nameserver_pool_on_send(
vec![udp2_nameserver, udp1_nameserver],
vec![],
None,
options,
);
let request = message(query, vec![], vec![], vec![]);
let future = pool.send(request).first_answer();
let response = block_on(future).unwrap();
assert_eq!(response.answers()[0], udp_record);
} | rust_cleaned_test_functions.jsonl/86472 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 484
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3382,
3231,
37216,
62,
17,
3382,
4412,
368,
341,
262,
1077,
5206,
2606,
284,
81854,
43451,
486,
2258,
1428,
1066,
262,
2606,
10522,
3382,
3231,
17644,
82,
284,
220,
17,
401,
262,
442,
582,
1366,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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() {
let mut buf = &fixed_hdr_to_bytes(new_fixed_hdr())[..];
let packet = buf.parse::<Ipv6Packet<_>>().unwrap();
assert_eq!(packet.ds(), 0);
assert_eq!(packet.ecn(), 2);
assert_eq!(packet.flowlabel(), 0x77);
assert_eq!(packet.hop_limit(), 64);
assert_eq!(packet.fixed_hdr.next_hdr, IpProto::Tcp.into());
assert_eq!(packet.proto(), IpProto::Tcp.into());
assert_eq!(packet.src_ip(), DEFAULT_SRC_IP);
assert_eq!(packet.dst_ip(), DEFAULT_DST_IP);
assert_eq!(packet.body(), []);
} | rust_cleaned_test_functions.jsonl/85888 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 312
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
368,
341,
286,
1077,
5206,
6607,
284,
609,
22021,
28238,
2346,
12524,
1755,
37839,
28238,
66600,
496,
935,
286,
1077,
10151,
284,
6607,
4632,
27638,
80656,
21,
16679,
32399,
2452,
1005,
15454... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_pending_transactions_endpoint() -> Result<(), Box<dyn Error>> {
// load variables in .env
dotenv().ok();
let algod = Algod::new()
.bind(env::var("ALGOD_URL")?.as_ref())
.auth(env::var("ALGOD_TOKEN")?.as_ref())
.client_v1()?;
println!("{:?}", algod.pending_transactions(0));
assert!(algod.pending_transactions(0).is_ok());
Ok(())
} | rust_cleaned_test_functions.jsonl/21960 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 191
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
37861,
68182,
36699,
368,
1464,
5714,
68843,
8261,
92846,
4600,
2452,
341,
262,
442,
2795,
7332,
304,
659,
3160,
198,
262,
91286,
1005,
562,
1428,
262,
1077,
17345,
347,
284,
1674,
39711,
486,
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... | 4 |
#[test]
fn test_array() {
// Create and use a default value.
let default = DoubleArrayProperty::default();
default.add(1, 1.0);
let default = IntArrayProperty::default();
default.add(1, 1);
let default = UintArrayProperty::default();
default.add(1, 1);
let inspector = Inspector::new();
let root = inspector.root();
let node = root.create_child("node");
let node_block = node.get_block().unwrap();
{
let array = node.create_double_array("array_property", 5);
let array_block = array.get_block().unwrap();
array.set(0, 5.0);
assert_eq!(array_block.array_get_double_slot(0).unwrap(), 5.0);
array.add(0, 5.3);
assert_eq!(array_block.array_get_double_slot(0).unwrap(), 10.3);
array.subtract(0, 3.4);
assert_eq!(array_block.array_get_double_slot(0).unwrap(), 6.9);
array.set(1, 2.5);
array.set(3, -3.1);
for (i, value) in [6.9, 2.5, 0.0, -3.1, 0.0].iter().enumerate() {
assert_eq!(array_block.array_get_double_slot(i).unwrap(), *value);
}
array.clear();
for i in 0..5 {
assert_eq!(0.0, array_block.array_get_double_slot(i).unwrap());
}
assert_eq!(node_block.child_count().unwrap(), 1);
}
assert_eq!(node_block.child_count().unwrap(), 0);
} | rust_cleaned_test_functions.jsonl/109243 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 759
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3858,
368,
341,
286,
442,
4230,
323,
990,
264,
1638,
897,
624,
286,
1077,
1638,
284,
7093,
1857,
3052,
486,
2258,
543,
286,
1638,
1364,
7,
16,
11,
220,
16,
13,
15,
317,
286,
1077,
1638,
284,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_filter_incoming_max_subscribed_valid() {
let t: Vec<_> = (0..5).map(|i| TopicHash::from_raw(format!("t{}", i))).collect();
let mut filter = MaxCountSubscriptionFilter {
filter: WhitelistSubscriptionFilter(t.iter().take(4).cloned().collect()),
max_subscribed_topics: 2,
max_subscriptions_per_request: 5,
};
let old = t[0..2].iter().cloned().collect();
let subscriptions = vec![
GossipsubSubscription {
action: Subscribe,
topic_hash: t[4].clone(),
},
GossipsubSubscription {
action: Subscribe,
topic_hash: t[2].clone(),
},
GossipsubSubscription {
action: Subscribe,
topic_hash: t[3].clone(),
},
GossipsubSubscription {
action: Unsubscribe,
topic_hash: t[0].clone(),
},
GossipsubSubscription {
action: Unsubscribe,
topic_hash: t[1].clone(),
},
];
let result = filter.filter_incoming_subscriptions(&subscriptions, &old).unwrap();
assert_eq!(result, subscriptions[1..].iter().collect());
} | rust_cleaned_test_functions.jsonl/121434 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 680
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8727,
1243,
4959,
6345,
5228,
49785,
8337,
368,
341,
286,
1077,
259,
25,
11312,
32399,
29,
284,
320,
15,
496,
20,
568,
2186,
22428,
72,
91,
32911,
6370,
486,
1499,
16067,
20698,
17223,
83,
42351... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_flags_from_vec_15() {
let (flags, subcommand, argv) =
flags_from_vec(svec!["deno", "run", "-c", "tsconfig.json", "script.ts"]);
assert_eq!(
flags,
DenoFlags {
config_path: Some("tsconfig.json".to_owned()),
..DenoFlags::default()
}
);
assert_eq!(subcommand, DenoSubcommand::Run);
assert_eq!(argv, svec!["deno", "script.ts"]);
} | rust_cleaned_test_functions.jsonl/112844 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 200
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14130,
5673,
13251,
62,
16,
20,
368,
341,
262,
1077,
320,
11161,
11,
1186,
5631,
11,
10213,
8,
4035,
414,
8042,
5673,
13251,
1141,
4083,
0,
1183,
5183,
78,
497,
330,
6108,
497,
6523,
66,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_can_remove_balance_from_coldkey_account_err_insufficient_balance() {
new_test_ext().execute_with(|| {
let coldkey_id = 87987984;
let initial_amount = 10000;
let remove_amount = 20000;
Subtensor::add_balance_to_coldkey_account(&coldkey_id, initial_amount);
assert_eq!(Subtensor::can_remove_balance_from_coldkey_account(&coldkey_id, remove_amount), false);
});
} | rust_cleaned_test_functions.jsonl/17176 | {
"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,
27421,
18193,
29396,
5673,
666,
813,
792,
13500,
9266,
34386,
26683,
29396,
368,
341,
8638,
4452,
9927,
1005,
10257,
6615,
79453,
341,
197,
10217,
9255,
792,
842,
284,
220,
23,
22,
24,
23,
22,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_acquire_capability() {
let root_id = uuid::Uuid::parse_str("00000000-0000-0000-0000-000000000000");
let root_id = root_id.expect("Couldn't parse uuid.");
let unit_json = json!(null);
let path = Path { root_id, segments: default() };
let method = "file/receivesTreeUpdates".to_string();
let register_options = RegisterOptions::Path { path };
test_request(
|client| client.acquire_capability(&method, ®ister_options),
"capability/acquire",
json!({
"method" : "file/receivesTreeUpdates",
"registerOptions" : {
"path" : {
"rootId" : "00000000-0000-0000-0000-000000000000",
"segments" : []
}
}
}),
unit_json,
(),
);
} | rust_cleaned_test_functions.jsonl/32829 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 411
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
97523,
89686,
368,
341,
262,
1077,
3704,
842,
284,
16040,
486,
38431,
486,
6400,
2895,
445,
15,
15,
15,
15,
15,
15,
15,
15,
12,
15,
15,
15,
15,
12,
15,
15,
15,
15,
12,
15,
15,
15,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_negative_decimal_value() {
use crate::{encode::encode, schema::Name};
use num_bigint::ToBigInt;
let inner = Box::new(Schema::Fixed {
size: 2,
name: Name::new("decimal"),
});
let schema = Schema::Decimal {
inner,
precision: 4,
scale: 2,
};
let bigint = (-423).to_bigint().unwrap();
let value = Value::Decimal(Decimal::from(bigint.to_signed_bytes_be()));
let mut buffer = Vec::new();
encode(&value, &schema, &mut buffer);
let mut bytes = &buffer[..];
let result = decode(&schema, &mut bytes).unwrap();
assert_eq!(result, value);
} | rust_cleaned_test_functions.jsonl/56203 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 354
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
53865,
74429,
3142,
368,
341,
286,
990,
17717,
22964,
6180,
486,
6180,
11,
10802,
486,
675,
2440,
286,
990,
1629,
36386,
396,
486,
1249,
87474,
280,
286,
1077,
9179,
284,
8261,
486,
931,
3759,
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_palindrome_pairs1() {
let words: Vec<String> = vec!["abcd", "dcba", "lls", "s", "sssll"]
.into_iter()
.map(|s| s.to_string())
.collect();
let mut ans = Solution::palindrome_pairs(words);
ans.sort_by(|w1, w2| w1[0].cmp(&w2[0])); let mut want = vec![vec![0, 1], vec![1, 0], vec![3, 2], vec![2, 4]];
want.sort_by(|w1, w2| w1[0].cmp(&w2[0]));
assert_eq!(ans, want);
} | rust_cleaned_test_functions.jsonl/98992 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 267
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
73310,
36058,
36430,
16,
368,
341,
286,
1077,
4244,
25,
11312,
3464,
29,
284,
7486,
0,
1183,
68644,
497,
330,
7628,
4645,
497,
330,
654,
82,
497,
330,
82,
497,
330,
84160,
654,
7026,
310,
659,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_version_set_get_range() {
let cmp = DefaultCmp;
let fs = example_files();
assert_eq!(
("a".as_bytes().to_vec(), "z".as_bytes().to_vec()),
get_range(&cmp, fs.iter())
);
} | rust_cleaned_test_functions.jsonl/41931 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 138
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9438,
2602,
3062,
9698,
368,
341,
286,
1077,
26089,
284,
7899,
34,
1307,
280,
286,
1077,
8619,
284,
3110,
10931,
543,
286,
2060,
10714,
33673,
310,
3489,
64,
3263,
300,
12524,
1005,
983,
13251,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_books_without_price() -> Result<()> {
let sql = SqlBuilder::select_from("books")
.field("title")
.and_where_is_null("price")
.sql()?;
assert_eq!(&sql, "SELECT title FROM books WHERE price IS NULL;");
let sql = SqlBuilder::select_from("books")
.field("title")
.and_where_is_not_null("price")
.sql()?;
assert_eq!(&sql, "SELECT title FROM books WHERE price IS NOT NULL;");
Ok(())
} | rust_cleaned_test_functions.jsonl/12599 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 253
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
73084,
39904,
9040,
368,
1464,
5714,
71698,
341,
286,
1077,
5704,
284,
7224,
3297,
486,
1742,
5673,
445,
12110,
1138,
310,
659,
2566,
445,
2102,
1138,
310,
659,
437,
36814,
6892,
15162,
445,
6555,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_human_getInsurance () {
use crate::lib::model::player::Human;
let mut h = Human::new();
h.chip = 1;
h.bet = 1;
h.insurance = true;
h.get_2xinsurance();
assert!(h.chip == 2);
} | rust_cleaned_test_functions.jsonl/125154 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 158
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
86247,
3062,
78754,
1719,
1476,
286,
990,
17717,
486,
2740,
486,
2528,
486,
3434,
486,
33975,
280,
286,
1077,
5206,
305,
284,
11097,
486,
931,
1428,
286,
305,
5329,
573,
414,
284,
220,
16,
280,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parse_valid_redshift_revoke_cluster_security_group_ingress() {
let mock_response = MockResponseReader::read_response(
"test_resources/generated/valid",
"redshift-revoke-cluster-security-group-ingress.xml",
);
let mock = MockRequestDispatcher::with_status(200).with_body(&mock_response);
let client = RedshiftClient::new(mock, MockCredentialsProvider, rusoto_region::UsEast1);
let request = RevokeClusterSecurityGroupIngressMessage::default();
let result = client.revoke_cluster_security_group_ingress(request).sync();
assert!(result.is_ok(), "parse error: {:?}", result);
} | rust_cleaned_test_functions.jsonl/12126 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 270
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
8337,
26058,
13418,
1288,
7621,
28441,
48726,
6288,
59112,
673,
368,
341,
286,
1077,
7860,
9655,
284,
14563,
2582,
5062,
486,
878,
9655,
1006,
310,
330,
1944,
35569,
79372,
14,
1891,
756,
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_vault_command_parser_returns_error_for_no_command_arguments() {
let command_name = format!("lookup");
let args = format!("");
let result = VaultCommand::parse(&command_name, &args);
assert_eq!(result.is_err(), true);
let error = result.unwrap_err();
assert_eq!(
format!("{}", error),
"The `lookup` command requires two arguments for an execution."
);
} | rust_cleaned_test_functions.jsonl/113264 | {
"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,
2273,
945,
10811,
18517,
58900,
4096,
5478,
6536,
10811,
43433,
368,
341,
286,
1077,
3210,
1269,
284,
3561,
17223,
21020,
797,
286,
1077,
2827,
284,
3561,
17223,
3071,
286,
1077,
1102,
284,
41397,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_module_with_headers() {
let specifier = ModuleSpecifier::parse("https://localhost/file").unwrap();
let mut headers = HashMap::new();
headers.insert(
"content-type".to_string(),
"application/typescript; charset=utf-8".to_string(),
);
let maybe_headers = Some(&headers);
let result = parse_module(
&specifier,
maybe_headers,
Arc::new(
r#"declare interface A {
a: string;
}"#
.to_string(),
),
None,
None,
);
assert!(result.is_ok());
} | rust_cleaned_test_functions.jsonl/94374 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 249
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
10750,
6615,
26719,
368,
341,
262,
1077,
97616,
284,
13711,
87297,
486,
6400,
445,
2428,
1110,
8301,
23903,
1827,
15454,
543,
262,
1077,
5206,
7102,
284,
10528,
486,
931,
543,
262,
7102,
70... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_element_attributes_command_encode_all_attributes() {
let b = GetElementAttributesCommand::all_attributes();
assert_eq!(
b.attributes(),
&[
MediaAttributeId::Title,
MediaAttributeId::ArtistName,
MediaAttributeId::AlbumName,
MediaAttributeId::TrackNumber,
MediaAttributeId::TotalNumberOfTracks,
MediaAttributeId::Genre,
MediaAttributeId::PlayingTime,
MediaAttributeId::DefaultCoverArt
]
);
assert_eq!(b.pdu_id(), PduId::GetElementAttributes);
assert_eq!(b.command_type(), AvcCommandType::Status);
assert_eq!(b.encoded_len(), 9);
let mut buf = vec![0; b.encoded_len()];
assert!(b.encode(&mut buf[..]).is_ok());
assert_eq!(
buf,
&[
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // NOW_PLAYING identifier
0x00 // passing 0 for all attributes
]
);
} | rust_cleaned_test_functions.jsonl/93001 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 581
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
7894,
18240,
10811,
11224,
5705,
18240,
368,
341,
286,
1077,
293,
284,
2126,
1691,
10516,
4062,
486,
541,
18240,
543,
286,
2060,
10714,
33673,
310,
293,
26140,
3148,
310,
609,
9640,
394,
781... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_native_equality() {
let rng = &mut test_rng();
let cs = ConstraintSystem::<Fr>::new_ref();
let (input, input_var) = generate_input(cs.clone(), rng);
println!("number of constraints for input: {}", cs.num_constraints());
let parameters = TestCRH::setup(rng).unwrap();
let primitive_result = TestCRH::evaluate(¶meters, &input).unwrap();
let parameters_var = <TestCRHGadget as CRHGadget<TestCRH, Fr>>::ParametersVar::new_witness(
ark_relations::ns!(cs, "parameters_var"),
|| Ok(¶meters),
)
.unwrap();
println!(
"number of constraints for input + params: {}",
cs.num_constraints()
);
let result_var = TestCRHGadget::evaluate(¶meters_var, &input_var).unwrap();
println!("number of constraints total: {}", cs.num_constraints());
let primitive_result = primitive_result.into_affine();
assert_eq!(primitive_result, result_var.value().unwrap().into_affine());
assert!(cs.is_satisfied().unwrap());
} | rust_cleaned_test_functions.jsonl/8222 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 482
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
44494,
2204,
10473,
368,
341,
286,
1077,
28422,
284,
609,
6984,
1273,
66849,
543,
286,
1077,
10532,
284,
44264,
2320,
27638,
22560,
6831,
931,
7793,
1428,
286,
1077,
320,
1355,
11,
1946,
4612,
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_is_compaction_filter_allowed() {
let gate = FeatureGate::default();
gate.set_version("4.1.0").unwrap();
let mut cfg_value = GcConfig::default();
assert!(!is_compaction_filter_allowed(&cfg_value, &gate));
cfg_value.enable_compaction_filter = true;
assert!(!is_compaction_filter_allowed(&cfg_value, &gate));
cfg_value.compaction_filter_skip_version_check = true;
assert!(is_compaction_filter_allowed(&cfg_value, &gate));
gate.set_version("5.0.0").unwrap();
cfg_value.compaction_filter_skip_version_check = false;
assert!(is_compaction_filter_allowed(&cfg_value, &gate));
} | rust_cleaned_test_functions.jsonl/101615 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 296
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6892,
18177,
1311,
8727,
42155,
368,
341,
286,
1077,
18126,
284,
19998,
42318,
486,
2258,
543,
286,
18126,
980,
9438,
445,
19,
13,
16,
13,
15,
1827,
15454,
543,
286,
1077,
5206,
13286,
3142,
284... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_make_reset_telemetry() {
make_reset_telemetry!(
/// TestValue1
TestVal1 => 0x30,
);
assert_eq!(
command(Type::TestVal1),
(
Command {
cmd: 0x30,
data: vec![0x00],
},
4,
)
);
} | rust_cleaned_test_functions.jsonl/63578 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 264
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28230,
18983,
528,
18871,
15149,
368,
341,
286,
1281,
18983,
528,
18871,
15149,
33673,
310,
1048,
3393,
1130,
16,
198,
310,
3393,
2208,
16,
589,
220,
15,
87,
18,
15,
345,
286,
3475,
286,
2060,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_skewness() {
test_case(0.0, 0.0, |x| x.skewness());
test_case(4.0, 0.0, |x| x.skewness());
test_case(0.3, 0.0, |x| x.skewness());
test_case(f64::INFINITY, 0.0, |x| x.skewness());
} | rust_cleaned_test_functions.jsonl/66860 | {
"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,
33811,
365,
2090,
368,
341,
286,
1273,
19096,
7,
15,
13,
15,
11,
220,
15,
13,
15,
11,
760,
87,
91,
856,
39454,
365,
2090,
1423,
286,
1273,
19096,
7,
19,
13,
15,
11,
220,
15,
13,
15,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_add_stake_transaction_fee_ends_up_in_transaction_fee_pool() {
let test_neuron_cold_key = 1;
let test_neuron_hot_key = 2;
let balances = vec![(test_neuron_cold_key, 1_000_000_000)];
mock::test_ext_with_balances(balances).execute_with(|| {
// Register neuron_1
assert_ok!(Subtensor::set_registeration_key(<<Test as Config>::Origin>::root(), 0));
let test_neuron = register_ok_neuron(0, 0, test_neuron_hot_key, test_neuron_cold_key);
// Verify start situation
let start_balance = Subtensor::get_coldkey_balance(&test_neuron_cold_key);
let start_stake = Subtensor::get_stake_of_neuron_hotkey_account_by_uid(test_neuron.uid);
assert_eq!(start_balance, 1_000_000_000);
assert_eq!(start_stake, 0);
let call = Call::Subtensor(SubtensorCall::add_stake(test_neuron_hot_key, 500_000_000));
let xt = TestXt::new(call, mock::sign_extra(test_neuron_cold_key, 0));
let result = mock::Executive::apply_extrinsic( xt );
assert_ok!(result);
let end_balance = Subtensor::get_coldkey_balance(&test_neuron_cold_key);
assert_eq!(end_balance, 500_000_000);
});
} | rust_cleaned_test_functions.jsonl/17149 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 460
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
1261,
726,
28884,
34305,
90729,
8237,
1243,
28884,
34305,
15709,
368,
341,
10217,
1273,
13925,
36090,
666,
813,
3097,
284,
220,
16,
280,
10217,
1273,
13925,
36090,
33433,
3097,
284,
220,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_updating_in_place() {
let mut manager = ConfigManager::default();
assert_eq!(manager.default_buffer_config().items.font_size, 14.);
let changes = json!({"font_size": 69, "font_face": "nice"})
.as_object().unwrap().to_owned();
manager.update_user_config(ConfigDomain::General, changes).unwrap();
assert_eq!(manager.default_buffer_config().items.font_size, 69.);
// null values in updates removes keys
let changes = json!({"font_size": Value::Null})
.as_object().unwrap().to_owned();
manager.update_user_config(ConfigDomain::General, changes).unwrap();
assert_eq!(manager.default_buffer_config().items.font_size, 14.);
assert_eq!(manager.default_buffer_config().items.font_face, "nice");
let changes = json!({"font_face": "Roboto"})
.as_object().unwrap().to_owned();
manager.update_user_config(SyntaxDefinition::Dart.into(), changes).unwrap();
let config = manager.get_buffer_config(SyntaxDefinition::Dart, None);
assert_eq!(config.items.font_face, "Roboto");
} | rust_cleaned_test_functions.jsonl/40019 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 463
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8237,
14110,
1243,
34548,
368,
341,
286,
1077,
5206,
6645,
284,
5532,
2043,
486,
2258,
543,
286,
2060,
10714,
10297,
13297,
8764,
7776,
5332,
1005,
3615,
13990,
2368,
11,
220,
16,
19,
58957,
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_poll() {
let (r, w) = pipe().unwrap();
let mut fds = [PollFd::new(r, PollFlags::POLLIN)];
// Poll an idle pipe. Should timeout
let nfds = loop_while_eintr!(poll(&mut fds, 100));
assert_eq!(nfds, 0);
assert!(!fds[0].revents().unwrap().contains(PollFlags::POLLIN));
write(w, b".").unwrap();
let nfds = poll(&mut fds, 100).unwrap();
assert_eq!(nfds, 1);
assert!(fds[0].revents().unwrap().contains(PollFlags::POLLIN));
} | rust_cleaned_test_functions.jsonl/16104 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 227
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
40002,
368,
341,
262,
1077,
320,
81,
11,
289,
8,
284,
13647,
1005,
15454,
543,
262,
1077,
5206,
93734,
284,
508,
49207,
74476,
486,
931,
2601,
11,
24385,
9195,
486,
47,
21535,
687,
73663,
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_empty_transaction_status() {
let ledger_path = get_tmp_ledger_path_auto_delete!();
let blockstore = Blockstore::open(ledger_path.path()).unwrap();
blockstore.set_roots(std::iter::once(&0)).unwrap();
assert_eq!(
blockstore
.get_rooted_transaction(Signature::default())
.unwrap(),
None
);
} | rust_cleaned_test_functions.jsonl/9566 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 207
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15124,
28884,
4773,
368,
341,
286,
1077,
46933,
2638,
284,
633,
16125,
38367,
1389,
2638,
27740,
11353,
0,
543,
286,
1077,
2504,
4314,
284,
8362,
4314,
486,
2508,
7,
50704,
2638,
3875,
6011,
15454... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_need_gc() {
let path = Builder::new()
.prefix("test_storage_mvcc_reader")
.tempdir()
.unwrap();
let path = path.path().to_str().unwrap();
let region = make_region(1, vec![0], vec![10]);
test_without_properties(path, ®ion);
test_with_properties(path, ®ion);
} | rust_cleaned_test_functions.jsonl/3921 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 183
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
71506,
49423,
368,
341,
286,
1077,
1815,
284,
20626,
486,
931,
741,
310,
659,
11849,
445,
1944,
23310,
73187,
638,
22306,
1138,
310,
659,
3888,
3741,
741,
310,
659,
15454,
543,
286,
1077,
1815,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_totp() {
let auth = otpauth::TOTP::new("python");
let timestamp1 = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs();
let code = auth.generate(30, timestamp1);
let timestamp2 = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs();
assert!(auth.verify(code, 30, timestamp2));
assert!(!auth.verify(123456, 30, timestamp2));
assert!(!auth.verify(1234567, 30, timestamp2));
} | rust_cleaned_test_functions.jsonl/93462 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 183
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36138,
79,
368,
341,
262,
1077,
4166,
284,
83431,
3242,
486,
65620,
47,
486,
931,
445,
12669,
797,
262,
1077,
11441,
16,
284,
739,
1462,
486,
3328,
1005,
17021,
56262,
7,
99089,
2089,
69945,
568... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_annotate() {
let input = r##"
a = 2
a = a + 4;
b = 3 + a;
c = 3 + b;
"##;
let loc = Loc(3, 21);
let mut annotated = String::new();
assert!(loc.annotate(&mut annotated, &input).is_ok());
assert_eq!(
annotated,
r##"2 | a = 2
| ^^^^
3 | a = a + 4;
| ^^^^^^^^^^^
4 | b = 3 + a;
| ^^^
"##
);
} | rust_cleaned_test_functions.jsonl/21938 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 190
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
91350,
368,
341,
262,
1077,
1946,
284,
435,
565,
698,
64,
284,
220,
17,
198,
64,
284,
264,
488,
220,
19,
280,
65,
284,
220,
18,
488,
264,
280,
66,
284,
220,
18,
488,
293,
280,
1,
565... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_selector_pseudo_nth_last_of_type() -> Result {
let html = r#"
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>:nth-last-of-type</title>
</head>
<body>
<dl>
<dt>dt1</dt>
<dd>dd1</dd>
<dd>dd2</dd>
<dd>dd3</dd>
<dt>dt2</dt>
<dd>dd4</dd>
<dt>dt3</dt>
<dd>dd5</dd>
<dd>dd6</dd>
</dl>
</body>
</html>
"#;
let root = Vis::load(html)?;
let dl = root.find("dl");
let last_type_child = dl.find(":nth-last-of-type(1)");
assert_eq!(last_type_child.length(), 2);
assert_eq!(last_type_child.text(), "dt3dd6");
let last_odd_type_childs = dl.find(":nth-last-of-type(odd)");
assert_eq!(last_odd_type_childs.length(), 5);
assert_eq!(last_odd_type_childs.text(), "dt1dd2dd4dt3dd6",);
let childs_type_last_3n = dl.find(":nth-last-of-type(3n)");
assert_eq!(childs_type_last_3n.length(), 3);
assert_eq!(childs_type_last_3n.text(), "dt1dd1dd4");
let childs_type_last_3n_2n = childs_type_last_3n.filter(":nth-last-of-type(2n)");
assert_eq!(childs_type_last_3n_2n.length(), 1);
assert_eq!(childs_type_last_3n_2n.text(), "dd1");
// prevs
let childs_type_last_3n_2n_prevs = childs_type_last_3n_2n.prev_all(":nth-last-of-type(3n)");
assert_eq!(childs_type_last_3n_2n_prevs.length(), 1);
assert_eq!(childs_type_last_3n_2n_prevs.text(), "dt1");
// nexts
let childs_type_last_3n_2n_nests = childs_type_last_3n_2n.next_all(":nth-last-of-type(3n)");
assert_eq!(childs_type_last_3n_2n_nests.length(), 1);
assert_eq!(childs_type_last_3n_2n_nests.text(), "dd4");
Ok(())
} | rust_cleaned_test_functions.jsonl/58030 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 896
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28890,
620,
21952,
78342,
12195,
3575,
1819,
368,
1464,
5714,
341,
10217,
5272,
284,
435,
2,
698,
262,
71341,
50139,
5272,
397,
262,
366,
1551,
8688,
428,
268,
881,
414,
366,
1983,
397,
286,
366... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_single_node_candidate() {
let l = default_logger();
let mut tt = Network::new(vec![None], &l);
tt.send(vec![new_message(1, 1, MessageType::MsgHup, 0)]);
assert_eq!(tt.peers[&1].state, StateRole::Leader);
} | rust_cleaned_test_functions.jsonl/19100 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 111
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
19487,
5084,
62360,
368,
341,
262,
1077,
326,
284,
1638,
27413,
543,
262,
1077,
5206,
17853,
284,
8141,
486,
931,
25592,
20703,
4064,
1125,
609,
75,
317,
262,
17853,
5219,
25592,
20703,
931,
6462,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_deactivate_device() {
let mut d = TestDevices::default();
let core_a = MockDeviceId(1);
let a = d.add_active_device(core_a, |id| id + 10).unwrap();
let b = d.add_device(|id| id + 20);
assert_eq!(d.deactivate_device(b).unwrap_err(), ToggleError::NoChange);
assert_eq!(d.deactivate_device(1000).unwrap_err(), ToggleError::NotFound);
let (core, info) = d.deactivate_device(a).unwrap();
assert_eq!(core, core_a);
assert_eq!(info.info, a + 10);
assert_eq!(info.core_id, None);
// both a and b should be inactive now:
assert!(d.active_devices.is_empty());
assert!(d.id_map.is_empty());
} | rust_cleaned_test_functions.jsonl/18164 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 333
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2259,
16856,
9204,
368,
341,
286,
1077,
5206,
294,
284,
3393,
40835,
486,
2258,
543,
286,
1077,
6200,
4306,
284,
14563,
6985,
764,
7,
16,
317,
286,
1077,
264,
284,
294,
1364,
12930,
9204,
47867,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_multiple_controllers() {
let mut exec = fasync::TestExecutor::new().expect("failed to create an executor");
let test_values = test_setup();
let serve_fut = test_values.ap.serve_provider_requests(test_values.requests);
pin_mut!(serve_fut);
assert_variant!(exec.run_until_stalled(&mut serve_fut), Poll::Pending);
// Request a controller.
let (_controller1, _) = request_controller(&test_values.provider);
assert_variant!(exec.run_until_stalled(&mut serve_fut), Poll::Pending);
// Request another controller.
let (controller2, _) = request_controller(&test_values.provider);
assert_variant!(exec.run_until_stalled(&mut serve_fut), Poll::Pending);
let chan = controller2.into_channel().expect("error turning proxy into channel");
let mut buffer = zx::MessageBuf::new();
let epitaph_fut = chan.recv_msg(&mut buffer);
pin_mut!(epitaph_fut);
assert_variant!(exec.run_until_stalled(&mut epitaph_fut), Poll::Ready(Ok(_)));
// Verify Epitaph was received.
use fidl::encoding::{decode_transaction_header, Decodable, Decoder, EpitaphBody};
let (header, tail) =
decode_transaction_header(buffer.bytes()).expect("failed decoding header");
let mut msg = Decodable::new_empty();
Decoder::decode_into::<EpitaphBody>(&header, tail, &mut [], &mut msg)
.expect("failed decoding body");
assert_eq!(msg.error, zx::Status::ALREADY_BOUND);
assert!(chan.is_closed());
} | rust_cleaned_test_functions.jsonl/59832 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 670
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
45233,
10260,
7273,
368,
341,
286,
1077,
5206,
3883,
284,
282,
7692,
486,
2271,
25255,
486,
931,
1005,
17119,
445,
16091,
311,
1855,
458,
31558,
797,
286,
1077,
1273,
9146,
284,
1273,
21363,
543,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_write_timestamp_millisecond() {
let expected = vec![
"+-------------------------+",
"| f |",
"+-------------------------+",
"| 1970-01-01 03:05:11.111 |",
"| |",
"+-------------------------+",
];
check_datetime!(
i64,
DataType::Timestamp(TimeUnit::Millisecond, None),
11111111,
expected
);
} | rust_cleaned_test_functions.jsonl/39715 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 301
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9165,
23073,
717,
65358,
368,
341,
286,
1077,
3601,
284,
7486,
90515,
310,
6630,
771,
22738,
10,
756,
310,
25203,
282,
5180,
760,
756,
310,
6630,
771,
22738,
10,
756,
310,
25203,
220,
16,
24,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_max_coding_shreds() {
let keypair = Arc::new(Keypair::new());
let hash = hash(Hash::default().as_ref());
let version = shred_version::version_from_hash(&hash);
assert_ne!(version, 0);
let shredder =
Shredder::new(0, 0, 1.0, keypair, 0, version).expect("Failed in creating shredder");
let entries: Vec<_> = (0..500)
.map(|_| {
let keypair0 = Keypair::new();
let keypair1 = Keypair::new();
let tx0 =
system_transaction::transfer(&keypair0, &keypair1.pubkey(), 1, Hash::default());
Entry::new(&Hash::default(), 1, vec![tx0])
})
.collect();
let start_index = 0x12;
let (data_shreds, _next_index) =
shredder.entries_to_data_shreds(&entries, true, start_index);
assert!(data_shreds.len() > MAX_DATA_SHREDS_PER_FEC_BLOCK as usize);
(1..=MAX_DATA_SHREDS_PER_FEC_BLOCK as usize)
.into_iter()
.for_each(|count| {
let coding_shreds = shredder.data_shreds_to_coding_shreds(&data_shreds[..count]);
assert_eq!(coding_shreds.len(), count);
});
let coding_shreds = shredder.data_shreds_to_coding_shreds(
&data_shreds[..MAX_DATA_SHREDS_PER_FEC_BLOCK as usize + 1],
);
assert_eq!(
coding_shreds.len(),
MAX_DATA_SHREDS_PER_FEC_BLOCK as usize * 2
);
} | rust_cleaned_test_functions.jsonl/28200 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 816
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6345,
666,
3700,
3712,
53369,
368,
341,
286,
1077,
1376,
12670,
284,
19689,
486,
931,
7,
6608,
1082,
1310,
486,
931,
1423,
286,
1077,
5175,
284,
5175,
7,
6370,
486,
2258,
1005,
300,
7793,
1423,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_debug() {
let cases = &[
("hello", "\"hello\""),
("hello \"world\"", "\"hello \\\"world\\\"\""),
("\u{7FFF}hello", "\"\\xe7\\xbf\\xbfhello\""),
];
for &(value, expected) in cases {
let val = HeaderValue::from_bytes(value.as_bytes()).unwrap();
let actual = format!("{:?}", val);
assert_eq!(expected, actual);
}
let mut sensitive = HeaderValue::from_static("password");
sensitive.set_sensitive(true);
assert_eq!("Sensitive", format!("{:?}", sensitive));
} | rust_cleaned_test_functions.jsonl/102947 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 242
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15446,
368,
341,
262,
1077,
5048,
284,
609,
9640,
286,
3489,
14990,
497,
15898,
14990,
2105,
4461,
286,
3489,
14990,
7245,
14615,
55853,
15898,
14990,
24984,
2105,
14615,
3422,
2105,
2105,
4461,
286... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_http_session_serde() {
{
let json = r#"{"id": "abc"}"#;
assert_eq!(
serde_json::from_str::<HttpSession>(json).unwrap(),
HttpSession::Old {
id: "abc".to_string()
}
);
}
{
let json = r#"{}"#;
assert_eq!(
serde_json::from_str::<HttpSession>(json).unwrap(),
HttpSession::New(Default::default())
);
}
{
let json = r#"{"unexpected": ""}"#;
assert!(serde_json::from_str::<HttpSession>(json).is_err());
}
} | rust_cleaned_test_functions.jsonl/42108 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 329
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25888,
12316,
75861,
450,
368,
341,
262,
341,
286,
1077,
2951,
284,
435,
55543,
4913,
307,
788,
330,
13683,
9207,
57676,
280,
286,
2060,
10714,
33673,
310,
61570,
9455,
486,
1499,
2895,
27638,
290... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_inverse_score() {
let inverse_score = InverseScore::new(100, 90);
let mut score = inverse_score.execute(50);
info!("{:?}", score);
assert!(score > 90);
score = inverse_score.execute(100);
info!("{:?}", score);
assert_eq!(score, 90);
score = inverse_score.execute(200);
info!("{:?}", score);
assert!(score < 90);
} | rust_cleaned_test_functions.jsonl/100337 | {
"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,
63333,
10405,
368,
341,
262,
1077,
27949,
10405,
284,
758,
4450,
10570,
486,
931,
7,
16,
15,
15,
11,
220,
24,
15,
317,
262,
1077,
5206,
5456,
284,
27949,
10405,
7769,
7,
20,
15,
317,
262,
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_xor_data() {
let v1: Vec<u8> = vec![1, 0, 0, 1];
let v2: Vec<u8> = vec![1, 1];
let expected: Vec<u8> = vec![0, 1, 1, 0];
assert_eq!(xor_data(v1, v2), expected);
} | rust_cleaned_test_functions.jsonl/78893 | {
"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,
76462,
1769,
368,
341,
286,
1077,
348,
16,
25,
11312,
34837,
23,
29,
284,
7486,
20703,
16,
11,
220,
15,
11,
220,
15,
11,
220,
16,
935,
286,
1077,
348,
17,
25,
11312,
34837,
23,
29,
284,
74... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_validate_db_and_cf() {
let valid_cases = vec![
(DBType::Kv, CF_DEFAULT),
(DBType::Kv, CF_WRITE),
(DBType::Kv, CF_LOCK),
(DBType::Kv, CF_RAFT),
(DBType::Raft, CF_DEFAULT),
];
for (db, cf) in valid_cases {
validate_db_and_cf(db, cf).unwrap();
}
let invalid_cases = vec![
(DBType::Raft, CF_WRITE),
(DBType::Raft, CF_LOCK),
(DBType::Raft, CF_RAFT),
(DBType::Invalid, CF_DEFAULT),
(DBType::Invalid, "BAD_CF"),
];
for (db, cf) in invalid_cases {
validate_db_and_cf(db, cf).unwrap_err();
}
} | rust_cleaned_test_functions.jsonl/33459 | {
"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,
42681,
8685,
8378,
71143,
368,
341,
286,
1077,
2697,
41427,
284,
7486,
90515,
310,
320,
3506,
929,
486,
42,
85,
11,
20795,
13811,
1326,
310,
320,
3506,
929,
486,
42,
85,
11,
20795,
17475,
1326,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_receive_gratuitous_arp_request() {
let mut ctx = DummyContext::default();
send_arp_packet(
&mut ctx,
ArpOp::Request,
TEST_REMOTE_IPV4,
TEST_REMOTE_IPV4,
TEST_REMOTE_MAC,
TEST_INVALID_MAC,
);
// We should have cached the sender's address information.
assert_eq!(
ctx.get_ref().arp_state.table.lookup(TEST_REMOTE_IPV4).unwrap(),
&TEST_REMOTE_MAC
);
// Gratuitous ARPs should not prompt a response.
assert_eq!(ctx.frames().len(), 0);
} | rust_cleaned_test_functions.jsonl/16988 | {
"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,
38557,
15682,
266,
3083,
782,
62,
7876,
7893,
368,
341,
1789,
23459,
286,
1077,
5206,
5635,
284,
50567,
1972,
486,
2258,
543,
286,
3624,
62,
7876,
21078,
1006,
310,
609,
6984,
5635,
345,
310,
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_qtime_is_valid() {
let valid_qtime = QTime::from_h_m_s_ms(10, 30, Some(40), Some(300));
assert!(valid_qtime.is_valid());
let invalid_qtime = QTime::from_h_m_s_ms(10, 30, Some(40), Some(9999));
assert!(!invalid_qtime.is_valid());
} | rust_cleaned_test_functions.jsonl/45522 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 128
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8976,
1678,
6892,
8337,
368,
341,
262,
1077,
2697,
8976,
1678,
284,
1207,
1462,
486,
1499,
1523,
717,
643,
21416,
7,
16,
15,
11,
220,
18,
15,
11,
4329,
7,
19,
15,
701,
4329,
7,
18,
15,
15,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_closure_while_true() {
assert_eq!(
eval_ok(
"let x = 1.
{
x = x * 2.
x < 10
}
whileTrue.
x"
)
.integer(),
16
);
} | rust_cleaned_test_functions.jsonl/15567 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 194
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
72823,
86069,
16082,
368,
341,
262,
2060,
10714,
33673,
286,
5603,
19817,
1006,
310,
330,
1149,
856,
284,
220,
16,
624,
1797,
341,
2290,
856,
284,
856,
353,
220,
17,
624,
2290,
856,
366,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_uncompress_panic() {
use std::io::Cursor;
let msg: Vec<u8> = vec![12, 42, 84, 104, 105, 115, 32, 105, 115, 32, 116, 101, 115, 116];
let uncomp_msg = String::from_utf8(uncompress(Cursor::new(msg)).unwrap()).unwrap();
assert_eq!(&uncomp_msg[..], "This is test");
} | rust_cleaned_test_functions.jsonl/110025 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 134
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4907,
38360,
620,
31270,
368,
341,
262,
990,
1460,
486,
815,
486,
14543,
280,
262,
1077,
3750,
25,
11312,
34837,
23,
29,
284,
7486,
20703,
16,
17,
11,
220,
19,
17,
11,
220,
23,
19,
11,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_does_not_confuse_different_duplicates() {
let inputs = ["eagle"];
let outputs: Vec<&str> = vec![];
assert_eq!(anagram::anagrams_for("galea", &inputs), outputs);
} | rust_cleaned_test_functions.jsonl/65506 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 87
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
96374,
7913,
16059,
810,
82741,
75051,
368,
341,
262,
1077,
11127,
284,
4383,
68,
32674,
6332,
262,
1077,
16275,
25,
11312,
52244,
495,
29,
284,
7486,
0,
15078,
262,
2060,
10714,
10297,
276,
5745,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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.