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_serialize_key() {
let map_key = Op {
action: OpType::Inc(12),
obj: ObjectId::Root,
key: "somekey".into(),
insert: false,
pred: Vec::new(),
};
let json = serde_json::to_value(map_key).unwrap();
let expected: serde_json::Value = "somekey".into();
assert_eq!(json.as_object().unwrap().get("key"), Some(&expected));
let elemid_key = Op {
action: OpType::Inc(12),
obj: ObjectId::Root,
key: OpId::from_str("1@7ef48769b04d47e9a88e98a134d62716")
.unwrap()
.into(),
insert: false,
pred: Vec::new(),
};
let json = serde_json::to_value(elemid_key).unwrap();
let expected: serde_json::Value = "1@7ef48769b04d47e9a88e98a134d62716".into();
assert_eq!(json.as_object().unwrap().get("elemId"), Some(&expected));
} | rust_cleaned_test_functions.jsonl/45057 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 509
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
88686,
3097,
368,
341,
286,
1077,
2415,
3097,
284,
10672,
341,
310,
1917,
25,
10672,
929,
486,
39245,
7,
16,
17,
1326,
310,
2839,
25,
50090,
486,
8439,
345,
310,
1376,
25,
330,
14689,
792,
326... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_query() {
assert_eq!(parse_query_map(""), BTreeMap::default());
assert_eq!(parse_query_map("foo"), BTreeMap::from_iter([("foo", "")]));
assert_eq!(
parse_query_map("foo=bar"),
BTreeMap::from_iter([("foo", "bar")])
);
assert_eq!(
parse_query_map("foo=bar&baz=42"),
BTreeMap::from_iter([("foo", "bar"), ("baz", "42")])
);
assert_eq!(
parse_query_map("foo&baz=42"),
BTreeMap::from_iter([("foo", ""), ("baz", "42")])
);
assert_eq!(
parse_query_map("foo&baz&&"),
BTreeMap::from_iter([("foo", ""), ("baz", "")])
);
} | rust_cleaned_test_functions.jsonl/64061 | {
"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,
21039,
5738,
368,
341,
262,
2060,
10714,
10297,
6400,
5738,
5376,
86076,
425,
6533,
2227,
486,
2258,
1423,
262,
2060,
10714,
10297,
6400,
5738,
5376,
445,
7975,
3975,
425,
6533,
2227,
486,
1499,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_is_valid_email_returns_false_for_junk_emails() {
let exp = compile_expr("valid_email('foo@guerrillamailblock.com')".to_string()).unwrap();
let r = exp.search(json!(null)).unwrap();
assert!(!r.is_truthy());
} | rust_cleaned_test_functions.jsonl/131415 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 120
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6892,
8337,
9172,
58900,
36015,
5478,
5374,
3122,
77773,
368,
341,
286,
1077,
1343,
284,
19192,
21915,
445,
1891,
9172,
492,
7975,
31,
8717,
615,
483,
309,
604,
4574,
905,
863,
3263,
983,
3904,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_mods() {
let handle: LoggerHandle = Logger::try_with_env_or_str(
"info, test_windows_line_ending::mymod1=debug, test_windows_line_ending::mymod2=error",
)
.unwrap()
.format(detailed_format)
.log_to_file(FileSpec::default())
.use_windows_line_ending()
.start()
.unwrap_or_else(|e| panic!("Logger initialization failed with {}", e));
error!("This is an error message");
warn!("This is a warning");
info!("This is an info message");
debug!("This is a debug message - you must not see it!");
trace!("This is a trace message - you must not see it!");
mymod1::test_traces();
mymod2::test_traces();
handle.validate_logs(&[
("ERROR", "test_windows_line_ending", "error"),
("WARN", "test_windows_line_ending", "warning"),
("INFO", "test_windows_line_ending", "info"),
("ERROR", "test_windows_line_ending", "error"),
("WARN", "test_windows_line_ending", "warning"),
("INFO", "test_windows_line_ending", "info"),
("DEBUG", "test_windows_line_ending", "debug"),
("ERROR", "test_windows_line_ending", "error"),
]);
} | rust_cleaned_test_functions.jsonl/3837 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 477
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7480,
82,
368,
341,
262,
1077,
3705,
25,
9514,
6999,
284,
9514,
486,
1539,
6615,
15879,
8734,
2895,
1006,
286,
330,
2733,
11,
1273,
58220,
6528,
62,
2459,
486,
76,
1600,
347,
16,
28,
8349,
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_astar_runtime_optimal() {
let mut g = Graph::new();
let a = g.add_node("A");
let b = g.add_node("B");
let c = g.add_node("C");
let d = g.add_node("D");
let e = g.add_node("E");
g.add_edge(a, b, 2);
g.add_edge(a, c, 3);
g.add_edge(b, d, 3);
g.add_edge(c, d, 1);
g.add_edge(d, e, 1);
let mut times_called = 0;
let _ = astar(&g, a, |n| n == e, |edge| {
times_called += 1;
*edge.weight()
}, |_| 0);
assert_eq!(times_called, 5);
} | rust_cleaned_test_functions.jsonl/46743 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 306
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
48019,
277,
33232,
15032,
2861,
368,
341,
262,
1077,
5206,
342,
284,
12165,
486,
931,
543,
262,
1077,
264,
284,
342,
1364,
5084,
445,
32,
797,
262,
1077,
293,
284,
342,
1364,
5084,
445,
33,
79... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_disburse_to_neuron() {
let from = *TEST_NEURON_1_OWNER_PRINCIPAL;
// Compute the subaccount to which the transfer would have been made
let nonce = 1234u64;
let block_height = 543212234;
let dissolve_delay_seconds = MIN_DISSOLVE_DELAY_FOR_VOTE_ELIGIBILITY_SECONDS;
let neuron_stake_e8s = 10 * 100_000_000; // 10 ICPT
let (mut driver, mut gov, id, _to_subaccount) = governance_with_staked_neuron(
dissolve_delay_seconds,
neuron_stake_e8s,
block_height,
from,
nonce,
);
let parent_neuron = gov.proto.neurons.get_mut(&id.id).unwrap();
let transaction_fee = gov.proto.economics.as_ref().unwrap().transaction_fee_e8s;
// Now Set the neuron to start dissolving
parent_neuron
.configure(
&from,
driver.now(),
&Configure {
operation: Some(Operation::StartDissolving(StartDissolving {})),
},
)
.unwrap();
// Advance the time in the env
driver.advance_time_by(MIN_DISSOLVE_DELAY_FOR_VOTE_ELIGIBILITY_SECONDS + 1);
// now disburse the neuron.
assert_eq!(
parent_neuron.get_neuron_info(driver.now()).state(),
NeuronState::Dissolved
);
let child_controller = *TEST_NEURON_2_OWNER_PRINCIPAL;
let child_nid = gov
.disburse_to_neuron(
&id,
&from,
&DisburseToNeuron {
new_controller: Some(child_controller),
amount_e8s: 2 * 100_000_000 + transaction_fee, // 2 ICPT + transaction_fee
dissolve_delay_seconds: 24 * 60 * 60, // 1 day.
kyc_verified: true,
nonce,
},
)
.now_or_never()
.unwrap()
.unwrap();
// We should now have 2 neurons.
assert_eq!(gov.proto.neurons.len(), 2);
// And we should have two ledger accounts.
driver.assert_num_neuron_accounts_exist(2);
let child_neuron = gov
.get_neuron(&child_nid)
.expect("The child neuron is missing");
let parent_neuron = gov.get_neuron(&id).expect("The parent neuron is missing");
let child_subaccount = child_neuron.account.clone();
assert_eq!(
parent_neuron.cached_neuron_stake_e8s,
neuron_stake_e8s - 2 * 100_000_000 - transaction_fee
);
assert_eq!(
child_neuron,
&Neuron {
id: Some(child_nid.clone()),
account: child_subaccount,
controller: Some(child_controller),
cached_neuron_stake_e8s: 2 * 100_000_000,
created_timestamp_seconds: driver.now(),
aging_since_timestamp_seconds: driver.now(),
dissolve_state: Some(DissolveState::DissolveDelaySeconds(24 * 60 * 60)),
kyc_verified: true,
..Default::default()
}
);
let to_subaccount = {
let mut state = Sha256::new();
state.write(&[0x0c]);
state.write(b"neuron-split");
state.write(child_controller.as_slice());
state.write(&nonce.to_be_bytes());
state.finish()
};
assert_eq!(child_neuron.account, to_subaccount);
} | rust_cleaned_test_functions.jsonl/1163 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1555
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9932,
37982,
2346,
13925,
36090,
368,
341,
262,
1077,
504,
284,
353,
10033,
14039,
1511,
711,
62,
16,
74323,
10571,
38439,
3298,
969,
280,
262,
442,
22603,
279,
1186,
4608,
311,
892,
279,
8317,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_all() -> Result<()> {
let temp_dir = TempDir::new(&format!(
"temp_rand_index_{}",
uuid::Uuid::new_v4().to_string()
))?;
let (posts, index) = build_random_posts_index(10, temp_dir.path())?;
assert_eq!(posts.len(), 10);
let q: Box<dyn Query> = Box::new(AllQuery {});
let docs = get_all(&q, &index, None)?;
assert!(docs.is_some());
assert_eq!(docs.unwrap().len(), 10);
Ok(())
} | rust_cleaned_test_functions.jsonl/67715 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 260
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
5705,
368,
1464,
5714,
71698,
341,
286,
1077,
2730,
4334,
284,
19944,
6184,
486,
931,
2099,
2243,
33673,
310,
330,
3888,
33864,
3560,
62,
6257,
756,
310,
16040,
486,
38431,
486,
931,
2273,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_start_serialize_struct() {
let mut buffer = Vec::new();
{
let mut ser = Serializer::new(&mut buffer);
let _ = ser.serialize_struct("foo", 0).unwrap();
}
let got = String::from_utf8(buffer).unwrap();
assert_eq!(got, "<foo>");
} | rust_cleaned_test_functions.jsonl/107663 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 156
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4906,
88686,
15126,
368,
341,
286,
1077,
5206,
4147,
284,
11312,
486,
931,
1428,
286,
341,
310,
1077,
5206,
1420,
284,
58822,
486,
931,
2099,
6984,
4147,
317,
310,
1077,
716,
284,
1420,
33969,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_encoding_decoding_instructions() {
test_encoding_decoding(DecoderInstruction::InsertCountIncrement { increment: 1 });
test_encoding_decoding(DecoderInstruction::InsertCountIncrement { increment: 10_000 });
test_encoding_decoding(DecoderInstruction::HeaderAck { stream_id: 1 });
test_encoding_decoding(DecoderInstruction::HeaderAck { stream_id: 10_000 });
test_encoding_decoding(DecoderInstruction::StreamCancellation { stream_id: 1 });
test_encoding_decoding(DecoderInstruction::StreamCancellation { stream_id: 10_000 });
} | rust_cleaned_test_functions.jsonl/775 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 224
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
37613,
13783,
3700,
82427,
368,
341,
286,
1273,
37613,
13783,
3700,
7,
20732,
16664,
486,
13780,
2507,
38311,
314,
16252,
25,
220,
16,
1625,
286,
1273,
37613,
13783,
3700,
7,
20732,
16664,
486,
13... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_log_file_normal() {
let tempdir = tempfile::tempdir().unwrap();
let mut log_file = LogFile::new(tempdir.path(), "test_log_file", 2).unwrap();
let info1 = create_file_info(1, EncryptionMethod::Aes256Ctr);
let info2 = create_file_info(2, EncryptionMethod::Unknown);
let info3 = create_file_info(3, EncryptionMethod::Aes128Ctr);
let info4 = create_file_info(4, EncryptionMethod::Aes128Ctr);
log_file.insert("info1", &info1).unwrap();
log_file.insert("info2", &info2).unwrap();
log_file.insert("info3", &info3).unwrap();
let file_dict = log_file.recovery().unwrap();
assert_eq!(*file_dict.files.get("info1").unwrap(), info1);
assert_eq!(*file_dict.files.get("info2").unwrap(), info2);
assert_eq!(*file_dict.files.get("info3").unwrap(), info3);
assert_eq!(file_dict.files.len(), 3);
log_file.remove("info2").unwrap();
log_file.remove("info1").unwrap();
log_file.insert("info2", &info4).unwrap();
let file_dict = log_file.recovery().unwrap();
assert_eq!(file_dict.files.get("info1"), None);
assert_eq!(*file_dict.files.get("info2").unwrap(), info4);
assert_eq!(*file_dict.files.get("info3").unwrap(), info3);
assert_eq!(file_dict.files.len(), 2);
} | rust_cleaned_test_functions.jsonl/35557 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 605
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5224,
2458,
13973,
368,
341,
286,
1077,
2730,
3741,
284,
54819,
486,
3888,
3741,
1005,
15454,
543,
286,
1077,
5206,
1487,
2458,
284,
2835,
1703,
486,
931,
9758,
3741,
3875,
1507,
330,
1944,
5224,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_prev_index() {
let sql = "SELECT version";
let mut tokenizer = Tokenizer::new(sql);
let tokens = tokenizer.tokenize().unwrap();
let mut parser = Parser::new(sql.to_string(), tokens);
assert_eq!(parser.peek_token(), Some(Token::make_keyword("SELECT")));
assert_eq!(parser.next_token(), Some(Token::make_keyword("SELECT")));
parser.prev_token();
assert_eq!(parser.next_token(), Some(Token::make_keyword("SELECT")));
assert_eq!(parser.next_token(), Some(Token::make_word("version", None)));
parser.prev_token();
assert_eq!(parser.peek_token(), Some(Token::make_word("version", None)));
assert_eq!(parser.next_token(), Some(Token::make_word("version", None)));
assert_eq!(parser.peek_token(), None);
parser.prev_token();
assert_eq!(parser.next_token(), Some(Token::make_word("version", None)));
assert_eq!(parser.next_token(), None);
assert_eq!(parser.next_token(), None);
parser.prev_token();
} | rust_cleaned_test_functions.jsonl/17053 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 447
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25566,
3560,
368,
341,
286,
1077,
5704,
284,
330,
4858,
2319,
876,
286,
1077,
5206,
45958,
284,
9660,
3135,
486,
931,
13148,
317,
286,
1077,
11211,
284,
45958,
96790,
1005,
15454,
543,
286,
1077,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_erc20_transfer_from() {
// Given token with initial state.
let (env, mut token) = setup();
let owner = env.get_account(0);
let recipient = env.get_account(1);
let spender = env.get_account(2);
let amount = U256::one();
let initial_supply = U256::from(INITIAL_SUPPLY);
// When spender is approved by the owner.
token.approve(spender, amount).unwrap();
// Then allowance is incremented.
assert_eq!(token.allowance(owner, spender), amount);
// Then Approval event is emitted.
token.assert_event_at(
1,
Approval {
owner,
spender,
value: amount,
},
);
// When transfer more then allowed.
let result = token.transfer_from(owner, recipient, amount + 1);
// Then it raises an error.
assert_eq!(result.unwrap_err(), Error::InsufficientAllowance);
// When spender transfers owner's tokens to recipient.
token
.as_account(spender)
.transfer_from(owner, recipient, amount)
.unwrap();
// Then total supply does not change.
assert_eq!(token.total_supply(), initial_supply);
// Then balance of owner is decremented.
assert_eq!(token.balance_of(owner), initial_supply - amount);
// Then balance of recipient is incremented.
assert_eq!(token.balance_of(recipient), amount);
// Then allowance is decremented.
assert_eq!(token.allowance(owner, spender), U256::zero());
// Then Transfer event is emited.
token.assert_event_at(
2,
Transfer {
from: Some(owner),
to: Some(recipient),
value: amount,
},
);
// And Approval event is emited.
token.assert_event_at(
3,
Approval {
owner,
spender,
value: U256::zero(),
},
);
} | rust_cleaned_test_functions.jsonl/61315 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 787
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
2962,
17,
15,
35403,
5673,
368,
341,
262,
442,
16246,
3950,
448,
2856,
1584,
624,
262,
1077,
320,
3160,
11,
5206,
3950,
8,
284,
6505,
543,
262,
1077,
6372,
284,
6105,
670,
13500,
7,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_style_from_str_raw_with_box() {
let actual_style = Style::from_str("raw", None, Some("box"), true, false);
let empty_ansi_term_style = ansi_term::Style::new();
assert_eq!(
actual_style,
Style {
ansi_term_style: empty_ansi_term_style,
decoration_style: DecorationStyle::Box(empty_ansi_term_style),
is_raw: true,
..Style::new()
}
)
} | rust_cleaned_test_functions.jsonl/129646 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 265
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15117,
5673,
2895,
16067,
6615,
10194,
368,
341,
286,
1077,
5042,
15117,
284,
11913,
486,
1499,
2895,
445,
1041,
497,
2240,
11,
4329,
445,
2011,
3975,
830,
11,
895,
317,
286,
1077,
4287,
62,
520... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_initialize_ok() {
ExtBuilder::default().build().execute_with(|| {
assert_ok!(CrowdloanRewards::initialize(Origin::root()));
assert_eq!(CrowdloanRewards::total_rewards(), 0);
assert_eq!(CrowdloanRewards::claimed_rewards(), 0);
});
} | rust_cleaned_test_functions.jsonl/41083 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 107
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
40889,
19817,
368,
341,
76605,
3297,
486,
2258,
1005,
5834,
1005,
10257,
6615,
79453,
341,
197,
6948,
19817,
10297,
93926,
67,
38329,
58465,
2347,
486,
21641,
7,
13298,
486,
2888,
7392,
197,
6948,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_optimistic_prewrite_committed_transaction() {
let engine = TestEngineBuilder::new().build().unwrap();
let cm = ConcurrencyManager::new(1.into());
let mut statistics = Statistics::default();
let key = b"k";
must_prewrite_put_async_commit(&engine, key, b"v1", key, &Some(vec![]), 5, 10);
must_commit(&engine, key, 5, 10);
let cmd = Prewrite::with_1pc(
vec![Mutation::make_put(Key::from_raw(key), b"v2".to_vec())],
key.to_vec(),
15.into(),
TimeStamp::default(),
);
let result = prewrite_command(&engine, cm.clone(), &mut statistics, cmd).unwrap();
let one_pc_commit_ts = result.one_pc_commit_ts;
// T3 is after T1 and T2
must_prewrite_put(&engine, key, b"v3", key, 20);
must_commit(&engine, key, 20, 25);
// Repeating the T1 prewrite request
let cmd = Prewrite::new(
vec![Mutation::make_put(Key::from_raw(key), b"v1".to_vec())],
key.to_vec(),
5.into(),
200,
false,
1,
10.into(),
TimeStamp::default(),
Some(vec![]),
false,
AssertionLevel::Off,
Context::default(),
);
let context = WriteContext {
lock_mgr: &DummyLockManager {},
concurrency_manager: cm.clone(),
extra_op: ExtraOp::Noop,
statistics: &mut statistics,
async_apply_prewrite: false,
};
let snap = engine.snapshot(Default::default()).unwrap();
let result = cmd.cmd.process_write(snap, context).unwrap();
assert!(result.to_be_write.modifies.is_empty()); // should not make real modifies
assert!(result.lock_guards.is_empty());
match result.pr {
ProcessResult::PrewriteResult { result } => {
assert!(result.locks.is_empty());
assert_eq!(result.min_commit_ts, 10.into()); // equals to the real commit ts
assert_eq!(result.one_pc_commit_ts, 0.into()); // not using 1PC
}
res => panic!("unexpected result {:?}", res),
}
// Repeating the T2 prewrite request
let cmd = Prewrite::with_1pc(
vec![Mutation::make_put(Key::from_raw(key), b"v2".to_vec())],
key.to_vec(),
15.into(),
TimeStamp::default(),
);
let context = WriteContext {
lock_mgr: &DummyLockManager {},
concurrency_manager: cm,
extra_op: ExtraOp::Noop,
statistics: &mut statistics,
async_apply_prewrite: false,
};
let snap = engine.snapshot(Default::default()).unwrap();
let result = cmd.cmd.process_write(snap, context).unwrap();
assert!(result.to_be_write.modifies.is_empty()); // should not make real modifies
assert!(result.lock_guards.is_empty());
match result.pr {
ProcessResult::PrewriteResult { result } => {
assert!(result.locks.is_empty());
assert_eq!(result.min_commit_ts, 0.into()); // 1PC does not need this
assert_eq!(result.one_pc_commit_ts, one_pc_commit_ts); // equals to the previous 1PC commit_ts
}
res => panic!("unexpected result {:?}", res),
}
} | rust_cleaned_test_functions.jsonl/31430 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1691
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15032,
318,
4532,
620,
52473,
2965,
5483,
28884,
368,
341,
286,
1077,
4712,
284,
3393,
4571,
3297,
486,
931,
1005,
5834,
1005,
15454,
543,
286,
1077,
9961,
284,
1200,
15973,
2043,
486,
931,
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... | 3 |
#[test]
fn test_with_docker_compose_yml() -> io::Result<()> {
let cfg_dir = tempfile::tempdir()?;
let cfg_file = cfg_dir.path().join("config.json");
let pwd = tempfile::tempdir()?;
File::create(pwd.path().join("docker-compose.yml"))?.sync_all()?;
let config_content = serde_json::json!({
"currentContext": "starship"
});
let mut docker_config = File::create(&cfg_file)?;
docker_config.write_all(config_content.to_string().as_bytes())?;
docker_config.sync_all()?;
let actual = ModuleRenderer::new("docker_context")
.env("DOCKER_CONFIG", cfg_dir.path().to_string_lossy())
.path(pwd.path())
.collect();
let expected = Some(format!("via {} ", Color::Blue.bold().paint("🐳 starship")));
assert_eq!(expected, actual);
cfg_dir.close()?;
pwd.close()
} | rust_cleaned_test_functions.jsonl/18767 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 436
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6615,
814,
13659,
2965,
2900,
4178,
1014,
368,
1464,
6399,
486,
2077,
71698,
341,
286,
1077,
13286,
4334,
284,
54819,
486,
3888,
3741,
94136,
286,
1077,
13286,
2458,
284,
13286,
4334,
3875,
1005,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
#[test]
fn test_basic_uint_ops() -> Result<(), Error> {
let mut info = Data::new();
info.apply(&create_numeric_property!(parent: ROOT_ID, id: 3, name: "value",
value: Number::UintT(42)))?;
assert!(info.apply(&add_number!(id: 3, value: Number::UintT(3))).is_ok());
assert!(info.to_string().contains("value: Uint(45)"));
assert!(info.apply(&add_number!(id: 3, value: Number::IntT(3))).is_err());
assert!(info.apply(&add_number!(id: 3, value: Number::DoubleT(3.0))).is_err());
assert!(info.to_string().contains("value: Uint(45)"));
assert!(info.apply(&subtract_number!(id: 3, value: Number::UintT(5))).is_ok());
assert!(info.to_string().contains("value: Uint(40)"));
assert!(info.apply(&subtract_number!(id: 3, value: Number::IntT(5))).is_err());
assert!(info.apply(&subtract_number!(id: 3, value: Number::DoubleT(5.0))).is_err());
assert!(info.to_string().contains("value: Uint(40)"));
assert!(info.apply(&set_number!(id: 3, value: Number::UintT(22))).is_ok());
assert!(info.to_string().contains("value: Uint(22)"));
assert!(info.apply(&set_number!(id: 3, value: Number::IntT(23))).is_err());
assert!(info.apply(&set_number!(id: 3, value: Number::DoubleT(24.0))).is_err());
assert!(info.to_string().contains("value: Uint(22)"));
Ok(())
} | rust_cleaned_test_functions.jsonl/10354 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 675
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34729,
15807,
21959,
368,
1464,
5714,
68843,
4600,
29,
341,
286,
1077,
5206,
3546,
284,
2885,
486,
931,
543,
286,
3546,
13045,
2099,
3182,
29418,
16638,
10297,
3765,
25,
35736,
3450,
11,
877,
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... | 2 |
#[test]
fn test_issues_217_222() {
let hdr = indoc! {"
#include <string>
#include <cstdint>
#include <cstddef>
template <typename STRING_TYPE> class BasicStringPiece {
public:
typedef size_t size_type;
typedef typename STRING_TYPE::traits_type traits_type;
typedef typename STRING_TYPE::value_type value_type;
typedef const value_type* pointer;
typedef const value_type& reference;
typedef const value_type& const_reference;
typedef ptrdiff_t difference_type;
typedef const value_type* const_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
static const size_type npos;
};
template<typename CHAR>
class Replacements {
public:
Replacements() {
}
void SetScheme(const CHAR*) {
}
uint16_t a;
};
struct Component {
uint16_t a;
};
template <typename STR>
class StringPieceReplacements : public Replacements<typename STR::value_type> {
private:
using CharT = typename STR::value_type;
using StringPieceT = BasicStringPiece<STR>;
using ParentT = Replacements<CharT>;
using SetterFun = void (ParentT::*)(const CharT*, const Component&);
void SetImpl(SetterFun, StringPieceT) {
}
public:
void SetSchemeStr(const CharT* str) { SetImpl(&ParentT::SetScheme, str); }
};
class GURL {
public:
typedef StringPieceReplacements<std::string> UrlReplacements;
GURL() {}
GURL ReplaceComponents(const Replacements<char>&) const {
return GURL();
}
uint16_t a;
};
"};
let rs = quote! {
ffi::GURL::make_unique();
};
// The block! directives here are to avoid running into
// https://github.com/rust-lang/rust-bindgen/pull/1975
run_test_ex(
"",
hdr,
rs,
quote! { generate!("GURL") block!("StringPiece") block!("Replacements") },
None,
None,
None,
);
} | rust_cleaned_test_functions.jsonl/9869 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 945
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
90232,
62,
17,
16,
22,
62,
17,
17,
17,
368,
341,
262,
1077,
36615,
284,
1257,
509,
0,
314,
698,
262,
671,
997,
366,
917,
397,
262,
671,
997,
366,
96975,
397,
262,
671,
997,
366,
66,
66397,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_output_selection() {
figment::Jail::expect_with(|jail| {
jail.create_file(
"foundry.toml",
r#"
[default]
extra_output = ["metadata", "ir-optimized"]
extra_output_files = ["metadata"]
"#,
)?;
let config = Config::load();
assert_eq!(
config.extra_output,
vec![ContractOutputSelection::Metadata, ContractOutputSelection::IrOptimized]
);
assert_eq!(config.extra_output_files, vec![ContractOutputSelection::Metadata]);
Ok(())
});
} | rust_cleaned_test_functions.jsonl/42701 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 378
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7645,
23672,
368,
341,
286,
4144,
478,
486,
41,
604,
486,
17119,
6615,
22428,
73,
604,
91,
341,
310,
17540,
2520,
2458,
1006,
394,
330,
15105,
884,
73494,
75,
756,
394,
435,
2,
698,
394,
508,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_transform() {
// Contructors
trans_eq!(Transform::new(), Transform {
matrix: [1.0, 0.0, 0.0, 1.0, 0.0, 0.0],
});
trans_eq!(Transform::new().with_translation(11.1, 22.2), Transform {
matrix: [1.0, 0.0, 0.0, 1.0, 11.1, 22.2],
});
trans_eq!(Transform::new().with_scale(11.1, 22.2), Transform {
matrix: [11.1, 0.0, 0.0, 22.2, 0.0, 0.0],
});
trans_eq!(Transform::new().with_skew(11.1, 22.2), Transform {
matrix: [1.0, 22.2, 11.1, 1.0, 0.0, 0.0],
});
let angle = 90f32.to_radians();
trans_eq!(Transform::new().with_rotation(angle), Transform {
matrix: [angle.cos(), angle.sin(), -angle.sin(), angle.cos(), 0.0, 0.0],
});
// Multiplication
let identity = Transform::new();
let trans = Transform::new().with_translation(10.0, 20.0);
trans_eq!(identity * trans, trans);
trans_eq!(trans * identity, trans);
trans_eq!(identity * identity, identity);
let a = Transform::new().with_rotation(123.0);
let b = Transform::new().with_skew(66.6, 1337.2);
trans_not_eq!(a * b, b * a);
} | rust_cleaned_test_functions.jsonl/23342 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 625
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18449,
368,
341,
286,
442,
34241,
667,
1087,
198,
286,
1356,
10714,
10297,
8963,
486,
931,
1507,
15226,
341,
310,
6172,
25,
508,
16,
13,
15,
11,
220,
15,
13,
15,
11,
220,
15,
13,
15,
11,
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_poisson() {
let initial = ndt("2000-01-01 15:15:15");
let mut poisson = PoissonSeries {
current: initial,
rate: Duration::days(365),
};
let mut rng = rand::thread_rng();
let iter1 = poisson.next(&mut rng).into_yielded().unwrap();
let iter2 = poisson.next(&mut rng).into_yielded().unwrap();
let iter3 = poisson.next(&mut rng).into_yielded().unwrap();
assert!(initial < iter1);
assert!(iter1 < iter2);
assert!(iter2 < iter3);
} | rust_cleaned_test_functions.jsonl/33874 | {
"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,
620,
29048,
930,
368,
341,
286,
1077,
2856,
284,
15581,
83,
445,
17,
15,
15,
15,
12,
15,
16,
12,
15,
16,
220,
16,
20,
25,
16,
20,
25,
16,
20,
797,
286,
1077,
5206,
3193,
48263,
284,
1380... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_pool_ray_usdc() {
pool_actions::run_test(
"RDM.RAY-USDC-V4",
vec![
utils::Swap {
protocol: "RDM",
from_token: "SOL",
to_token: "RAY",
amount: 0.10000001,
},
utils::Swap {
protocol: "RDM",
from_token: "SOL",
to_token: "USDC",
amount: 0.09999999,
},
],
vec![],
true,
);
} | rust_cleaned_test_functions.jsonl/120683 | {
"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,
15709,
72690,
11306,
7628,
368,
341,
262,
7314,
25368,
486,
6108,
4452,
1006,
286,
330,
49,
8395,
2013,
3022,
32340,
5626,
19625,
19,
756,
286,
7486,
90515,
310,
12439,
486,
46179,
341,
394,
11507... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_custom_ignore_files() {
let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);
fs::File::create(te.test_root().join("custom.ignore"))
.unwrap()
.write_all(b"C.Foo2\nthree")
.unwrap();
te.assert_output(
&["--ignore-file", "custom.ignore", "foo"],
"a.foo
one/b.foo
one/two/c.foo",
);
} | rust_cleaned_test_functions.jsonl/10868 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 202
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15875,
58493,
10931,
368,
341,
262,
1077,
1013,
284,
3393,
14359,
486,
931,
43175,
90560,
11,
11955,
48010,
626,
1066,
262,
8619,
486,
1703,
486,
3182,
71847,
5958,
12993,
1005,
5987,
445,
9163,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_vectors_xchacha20_poly1305() {
test_aead_all::<XChaCha20Poly1305>(&include!("fixtures/xchacha20_poly1305.rs")).unwrap();
} | rust_cleaned_test_functions.jsonl/99031 | {
"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,
49158,
3212,
331,
51576,
17,
15,
36133,
16,
18,
15,
20,
368,
341,
286,
1273,
4306,
3149,
5705,
27638,
55,
95971,
95971,
17,
15,
38164,
16,
18,
15,
20,
44784,
997,
17223,
45247,
10776,
331,
515... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_staging_one_file() {
let file_path = Path::new("file1.txt");
let (_td, repo) = repo_init().unwrap();
let root = repo.path().parent().unwrap();
let repo_path = root.as_os_str().to_str().unwrap();
File::create(&root.join(file_path))
.unwrap()
.write_all(b"test file1 content")
.unwrap();
File::create(&root.join(Path::new("file2.txt")))
.unwrap()
.write_all(b"test file2 content")
.unwrap();
assert_eq!(get_statuses(repo_path), (2, 0));
stage_add_file(repo_path, file_path).unwrap();
assert_eq!(get_statuses(repo_path), (1, 1));
} | rust_cleaned_test_functions.jsonl/36665 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 359
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1261,
4118,
11667,
2458,
368,
341,
286,
1077,
1034,
2638,
284,
7933,
486,
931,
445,
1192,
16,
3909,
797,
286,
1077,
5453,
1296,
11,
15867,
8,
284,
15867,
6137,
1005,
15454,
543,
286,
1077,
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_bit_set_union_with() {
//a should grow to include larger elements
let mut a = BitSet::new();
a.insert(0);
let mut b = BitSet::new();
b.insert(5);
let expected = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10000100]));
a.union_with(&b);
assert_eq!(a, expected);
// Standard
let mut a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100010]));
let mut b = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01100010]));
let c = a.clone();
a.union_with(&b);
b.union_with(&c);
assert_eq!(a.len(), 4);
assert_eq!(b.len(), 4);
} | rust_cleaned_test_functions.jsonl/76232 | {
"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,
13996,
2602,
51621,
6615,
368,
341,
286,
442,
64,
1265,
3063,
311,
2924,
8131,
5424,
198,
286,
1077,
5206,
264,
284,
57227,
486,
931,
543,
286,
264,
7030,
7,
15,
317,
286,
1077,
5206,
293,
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_md_request() -> Result<()> {
let d1 = b"This is a testing digest. it isn";
let d2 = b"'t actually SHA-256.............";
let mut req = MicrodescRequest::default();
req.push(*d1);
assert!(!req.partial_docs_ok());
req.push(*d2);
assert!(req.partial_docs_ok());
assert_eq!(req.max_response_len(), 16 << 10);
let req = crate::util::encode_request(&req.make_request()?);
assert_eq!(req,
format!("GET /tor/micro/d/J3QgYWN0dWFsbHkgU0hBLTI1Ni4uLi4uLi4uLi4uLi4-VGhpcyBpcyBhIHRlc3RpbmcgZGlnZXN0LiBpdCBpc24.z HTTP/1.0\r\naccept-encoding: {}\r\n\r\n", encodings()));
let req2: MicrodescRequest = vec![*d1, *d2].into_iter().collect();
let ds: Vec<_> = req2.digests().collect();
assert_eq!(ds, vec![d1, d2]);
let req2 = crate::util::encode_request(&req2.make_request()?);
assert_eq!(req, req2);
Ok(())
} | rust_cleaned_test_functions.jsonl/22457 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 502
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
32994,
7893,
368,
1464,
5714,
71698,
341,
286,
1077,
294,
16,
284,
293,
21520,
374,
264,
7497,
20882,
13,
432,
4436,
876,
286,
1077,
294,
17,
284,
293,
20584,
83,
3520,
21721,
12,
17,
20,
21,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_sync_dir() {
let tmp_dir = TempDir::new().unwrap();
sync_dir(tmp_dir.path()).unwrap();
let non_existent_file = tmp_dir.path().join("non_existent_file");
sync_dir(non_existent_file).unwrap_err();
} | rust_cleaned_test_functions.jsonl/23428 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 119
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
23008,
4334,
368,
341,
286,
1077,
4174,
4334,
284,
19944,
6184,
486,
931,
1005,
15454,
543,
286,
12811,
4334,
10368,
4334,
3875,
6011,
15454,
543,
286,
1077,
2477,
2702,
18128,
2458,
284,
4174,
43... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_binaryparser_try_from() {
let test_bytes: Vec<u8> = hex::decode(TEST_HEX).expect("");
let string_parser = BinaryParser::try_from(TEST_HEX).unwrap();
assert_eq!(string_parser, test_bytes[..]);
} | rust_cleaned_test_functions.jsonl/20410 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 113
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31761,
9657,
53283,
5673,
368,
341,
286,
1077,
1273,
12524,
25,
11312,
34837,
23,
29,
284,
12371,
486,
18196,
50320,
86502,
568,
17119,
13056,
286,
1077,
914,
18517,
284,
17718,
6570,
486,
1539,
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 |
#[test]
fn test_const() {
const R: f64 = 12.3;
const I: f64 = -4.5;
const C: Complex64 = Complex::new(R, I);
assert_eq!(C.re, 12.3);
assert_eq!(C.im, -4.5);
} | rust_cleaned_test_functions.jsonl/105676 | {
"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,
13610,
368,
341,
286,
733,
431,
25,
282,
21,
19,
284,
220,
16,
17,
13,
18,
280,
286,
733,
358,
25,
282,
21,
19,
284,
481,
19,
13,
20,
280,
286,
733,
356,
25,
22096,
21,
19,
284,
22096,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_enforce_in_field() {
{
let mut cs = TestConstraintSystem::<Fr>::new();
let mut bits = vec![];
for (i, b) in BitIterator::new(Fr::characteristic()).skip(1).enumerate() {
bits.push(Boolean::from(
AllocatedBit::alloc(cs.ns(|| format!("bit_gadget {}", i)), || Ok(b)).unwrap(),
));
}
Boolean::enforce_in_field::<_, _, Fr>(&mut cs, &bits).unwrap();
assert!(!cs.is_satisfied());
}
let mut rng = XorShiftRng::seed_from_u64(1231275789u64);
for _ in 0..1000 {
let r = Fr::rand(&mut rng);
let mut cs = TestConstraintSystem::<Fr>::new();
let mut bits = vec![];
for (i, b) in BitIterator::new(r.into_repr()).skip(1).enumerate() {
bits.push(Boolean::from(
AllocatedBit::alloc(cs.ns(|| format!("bit_gadget {}", i)), || Ok(b)).unwrap(),
));
}
Boolean::enforce_in_field::<_, _, Fr>(&mut cs, &bits).unwrap();
assert!(cs.is_satisfied());
}
// // Sample a random element not in the field
// let r = loop {
// // we're shaving off the high bit_gadget later
// break a;
// let mut bits = vec![];
// bits.push(Boolean::from(
} | rust_cleaned_test_functions.jsonl/230 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 930
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6205,
8833,
1243,
5013,
368,
341,
286,
341,
310,
1077,
5206,
10532,
284,
3393,
17890,
2320,
27638,
22560,
6831,
931,
1428,
310,
1077,
5206,
9472,
284,
7486,
0,
15078,
310,
369,
320,
72,
11,
293,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
#[test]
fn test_named_impl() {
let foo = Named::from_tuple((3, 5, "bar".into()));
assert_eq!(foo.into_tuple(), (3, 5, "bar".into()));
} | rust_cleaned_test_functions.jsonl/121832 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 72
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
71834,
21007,
368,
341,
262,
1077,
15229,
284,
40459,
486,
1499,
21773,
1188,
18,
11,
220,
20,
11,
330,
2257,
3263,
18122,
7392,
262,
2060,
10714,
10297,
7975,
39860,
21773,
1507,
320,
18,
11,
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 |
#[test]
fn test_head_mut() {
let mut a = vec![];
assert_eq!(a.head_mut(), None);
a = vec![11i];
assert_eq!(*a.head_mut().unwrap(), 11);
a = vec![11i, 12];
assert_eq!(*a.head_mut().unwrap(), 11);
} | rust_cleaned_test_functions.jsonl/31818 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 143
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13138,
29523,
368,
341,
286,
1077,
5206,
264,
284,
7486,
0,
15078,
286,
2060,
10714,
10297,
64,
16042,
29523,
1507,
2240,
317,
286,
264,
284,
7486,
20703,
16,
16,
72,
935,
286,
2060,
10714,
0,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_length() {
assert_eq!(length(100), 1);
assert_eq!(length(1000), 2);
assert_eq!(length(1 << 49), 8);
assert_eq!(length((1 << 56) - 1), 8);
assert_eq!(length(1 << 56), 9);
assert_eq!(length((1 << 63) - 1), 9);
assert_eq!(length(1 << 63), 10);
} | rust_cleaned_test_functions.jsonl/86795 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 126
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5118,
368,
341,
220,
2060,
10714,
10297,
4129,
7,
16,
15,
15,
701,
220,
16,
317,
220,
2060,
10714,
10297,
4129,
7,
16,
15,
15,
15,
701,
220,
17,
626,
220,
2060,
10714,
10297,
4129,
7,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parse_attribute_sdata() {
let mut buf = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let bytes_written = {
let mut writable = &mut buf[..];
leb128::write::signed(&mut writable, -4097).expect("should write ok")
};
let unit = test_parse_attribute_unit_default();
let form = constants::DW_FORM_sdata;
let value = AttributeValue::Sdata(-4097);
test_parse_attribute(&buf, bytes_written, &unit, form, value);
} | rust_cleaned_test_functions.jsonl/102021 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 230
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
16791,
643,
691,
368,
341,
286,
1077,
5206,
6607,
284,
508,
15,
11,
220,
15,
11,
220,
15,
11,
220,
15,
11,
220,
15,
11,
220,
15,
11,
220,
15,
11,
220,
15,
11,
220,
15,
11,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_cache_control() {
let port = start_server();
let client = reqwest::blocking::Client::builder().build().unwrap();
let resp = client
.get(&format!("http://127.0.0.1:{}/no/such/resource", port))
.send()
.unwrap();
assert_eq!(resp.status(), StatusCode::NOT_FOUND);
let cache_control = resp.headers().get(CACHE_CONTROL).unwrap().to_str().unwrap();
assert_eq!(cache_control, "no-cache");
} | rust_cleaned_test_functions.jsonl/126005 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 229
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11529,
13436,
368,
341,
286,
1077,
2635,
284,
1191,
12015,
543,
286,
1077,
2943,
284,
4232,
11039,
486,
70356,
486,
2959,
486,
17850,
1005,
5834,
1005,
15454,
1428,
286,
1077,
9039,
284,
2943,
198... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_urlencoded_error() {
let req = TestRequest::with_header(
header::CONTENT_TYPE,
"application/x-www-form-urlencoded",
)
.header(header::CONTENT_LENGTH, "xxxx")
.finish();
assert_eq!(
req.urlencoded::<Info>().poll().err().unwrap(),
UrlencodedError::UnknownLength
);
let req = TestRequest::with_header(
header::CONTENT_TYPE,
"application/x-www-form-urlencoded",
)
.header(header::CONTENT_LENGTH, "1000000")
.finish();
assert_eq!(
req.urlencoded::<Info>().poll().err().unwrap(),
UrlencodedError::Overflow
);
let req = TestRequest::with_header(header::CONTENT_TYPE, "text/plain")
.header(header::CONTENT_LENGTH, "10")
.finish();
assert_eq!(
req.urlencoded::<Info>().poll().err().unwrap(),
UrlencodedError::ContentType
);
} | rust_cleaned_test_functions.jsonl/7653 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 519
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2903,
19329,
4096,
368,
341,
286,
1077,
4232,
284,
3393,
1900,
486,
4197,
8757,
1006,
310,
4247,
486,
67872,
4189,
345,
310,
330,
5132,
10776,
41242,
8460,
44557,
756,
286,
1727,
286,
659,
2708,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_faucet_build_airdrop_transaction() {
let to = Pubkey::new_rand();
let blockhash = Hash::default();
let request = FaucetRequest::GetAirdrop {
lamports: 2,
to,
blockhash,
};
let mint = Keypair::new();
let mint_pubkey = mint.pubkey();
let mut faucet = Faucet::new(mint, None, None, None);
let tx = faucet.build_airdrop_transaction(request).unwrap();
let message = tx.message();
assert_eq!(tx.signatures.len(), 1);
assert_eq!(
message.account_keys,
vec![mint_pubkey, to, Pubkey::default()]
);
assert_eq!(message.recent_blockhash, blockhash);
assert_eq!(message.instructions.len(), 1);
let instruction: SystemInstruction = deserialize(&message.instructions[0].data).unwrap();
assert_eq!(instruction, SystemInstruction::Transfer { lamports: 2 });
// Test per-time request cap
let mint = Keypair::new();
faucet = Faucet::new(mint, None, Some(1), None);
let tx = faucet.build_airdrop_transaction(request);
assert!(tx.is_err());
// Test per-request cap
let mint = Keypair::new();
faucet = Faucet::new(mint, None, None, Some(1));
let tx = faucet.build_airdrop_transaction(request);
assert!(tx.is_err());
} | rust_cleaned_test_functions.jsonl/117725 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 644
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
761,
20436,
295,
20801,
50827,
6719,
28884,
368,
341,
286,
1077,
311,
284,
22611,
792,
486,
931,
33864,
543,
286,
1077,
2504,
8296,
284,
6531,
486,
2258,
543,
286,
1077,
1681,
284,
96362,
295,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_tr_from_tpm_public_password_auth() {
let nv_index_tpm_handle = NvIndexTpmHandle::new(0x01500022).unwrap();
remove_nv_index_handle_from_tpm(nv_index_tpm_handle, Provision::Owner);
let mut context = create_ctx_without_session();
let auth = Auth::try_from(vec![
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
])
.expect("Failed to create auth");
// closure for cleaning up if a call fails.
let cleanup = |context: &mut Context,
e: tss_esapi::Error,
handle: NvIndexHandle,
fn_name: &str|
-> tss_esapi::Error {
// Set password authorization
context.set_sessions((Some(AuthSession::Password), None, None));
let _ = context
.nv_undefine_space(Provision::Owner, handle)
.expect("Failed to call nv_undefine_space");
panic!("{} failed: {}", fn_name, e);
};
// Create nv public.
let nv_index_attributes = NvIndexAttributesBuilder::new()
.with_auth_write(true)
.with_auth_read(true)
.build()
.expect("Failed to create auth nv index attributes");
let nv_public = NvPublicBuilder::new()
.with_nv_index(nv_index_tpm_handle)
.with_index_name_algorithm(HashingAlgorithm::Sha256)
.with_index_attributes(nv_index_attributes)
.with_data_area_size(32)
.build()
.expect("Failed to build nv public");
// Define space
// Set password authorization when creating the space.
context.set_sessions((Some(AuthSession::Password), None, None));
let initial_nv_index_handle = context
.nv_define_space(Provision::Owner, Some(auth), nv_public)
.expect("Failed to call nv_define_space");
// Read the name from the tpm
// No password authorization.
context.clear_sessions();
let (_expected_nv_public, expected_name) = context
.nv_read_public(initial_nv_index_handle)
.map_err(|e| cleanup(&mut context, e, initial_nv_index_handle, "nv_read_public"))
.expect("Failed to call nv_read_public");
let mut handle_to_be_closed: ObjectHandle = initial_nv_index_handle.into();
context
.tr_close(&mut handle_to_be_closed)
.map_err(|e| cleanup(&mut context, e, initial_nv_index_handle, "tr_close"))
.expect("Failed to call tr_close");
assert_eq!(handle_to_be_closed, ObjectHandle::None);
// The value of the handle_to_be_closed will be set to a 'None' handle
// if the operations was successful.
// Make Esys create a new ObjectHandle from the
// data in the TPM.
// The handle is gone so if this fails it is not
// possible to remove the defined space.
let new_nv_index_handle = context
.tr_from_tpm_public(nv_index_tpm_handle.into())
.map_err(|e| -> tss_esapi::Result<ObjectHandle> {
panic!("tr_from_tpm_public failed: {}", e);
})
.expect("Error when call tr_from_tpm_public");
// Get name of the object using the new handle
let actual_name = context
.tr_get_name(new_nv_index_handle)
.map_err(|e| cleanup(&mut context, e, new_nv_index_handle.into(), "tr_get_name"))
.expect("Failed to call tr_get_name");
// Remove undefine the space
// Set password authorization
context.set_sessions((Some(AuthSession::Password), None, None));
let _ = context
.nv_undefine_space(Provision::Owner, new_nv_index_handle.into())
.expect("Failed to call nv_undefine_space");
// Check that we got the correct name
assert_eq!(expected_name, actual_name);
} | rust_cleaned_test_functions.jsonl/103649 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1978
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3547,
5673,
528,
5187,
27074,
10122,
14014,
368,
341,
286,
1077,
31440,
3560,
528,
5187,
10630,
284,
451,
85,
1552,
51,
5187,
6999,
486,
931,
7,
15,
87,
15,
16,
20,
15,
15,
15,
17,
17,
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_rgb_u32() {
test_image_sum_u32("gradient-3c-32b.tiff", ColorType::RGB(32), 2030834111716);
} | rust_cleaned_test_functions.jsonl/75199 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 61
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
37407,
7300,
18,
17,
368,
341,
262,
1273,
4954,
10160,
7300,
18,
17,
445,
26394,
12,
18,
66,
12,
18,
17,
65,
734,
3092,
497,
3478,
929,
486,
18184,
7,
18,
17,
701,
220,
17,
15,
18,
15,
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 |
#[test]
fn test_conversion() {
let mut rng = test_rng();
let a: EdwardsAffine = rng.gen();
let b: EdwardsAffine = rng.gen();
let a_b = {
use ark_ec::group::Group;
(a + &b).double().double()
};
let a_b2 = (a.into_projective() + &b.into_projective())
.double()
.double();
assert_eq!(a_b, a_b2.into_affine());
assert_eq!(a_b.into_projective(), a_b2);
} | rust_cleaned_test_functions.jsonl/10056 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 212
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
64132,
368,
341,
262,
1077,
5206,
28422,
284,
1273,
66849,
543,
262,
1077,
264,
25,
36763,
25841,
482,
284,
28422,
22822,
543,
262,
1077,
293,
25,
36763,
25841,
482,
284,
28422,
22822,
543,
262,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_hall_down_buttons() {
let elevator = ELEVATOR.lock().unwrap();
for i in rand::seq::sample_indices(
&mut rand::thread_rng(),
ElevatorInterface::N_FLOORS as usize - 1,
ElevatorInterface::N_FLOORS as usize - 1,
)
.into_iter()
{
elevator.set_order_button_light(ButtonType::HallDown, i as u8 + 1, true);
thread::sleep(Duration::new(0, 200000000));
elevator.set_order_button_light(ButtonType::HallDown, i as u8 + 1, false);
thread::sleep(Duration::new(0, 200000000));
elevator.set_order_button_light(ButtonType::HallDown, i as u8 + 1, true);
while !elevator.read_order_button(ButtonType::HallDown, i as u8 + 1) {}
elevator.set_order_button_light(ButtonType::HallDown, i as u8 + 1, false);
}
} | rust_cleaned_test_functions.jsonl/42310 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 418
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1523,
541,
13998,
41021,
368,
341,
286,
1077,
38636,
284,
468,
85411,
11857,
21003,
1005,
15454,
1428,
286,
369,
600,
304,
10382,
486,
13262,
486,
13611,
18333,
1006,
310,
609,
6984,
10382,
486,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_add_peer_for_success() {
let a_0 = agent::ZeroAgent::new("inproc://#1".to_string());
a_0.add_peer("inproc://#1".to_string());
} | rust_cleaned_test_functions.jsonl/104674 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 84
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
45159,
5478,
18632,
368,
341,
286,
1077,
264,
62,
15,
284,
8315,
486,
17999,
16810,
486,
931,
445,
258,
15782,
1110,
2,
16,
3263,
983,
3904,
1423,
286,
264,
62,
15,
1364,
45159,
445,
258... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_enum() {
#[derive(Serialize, Deserialize, PartialEq, Debug)]
enum TestEnum {
NoArg,
OneArg(usize),
Args(usize, usize),
AnotherNoArg,
StructLike { x: usize, y: f32 },
}
the_same(TestEnum::NoArg);
the_same(TestEnum::OneArg(4));
the_same(TestEnum::AnotherNoArg);
the_same(TestEnum::StructLike { x: 4, y: 3.14159 });
the_same(vec![
TestEnum::NoArg,
TestEnum::OneArg(5),
TestEnum::AnotherNoArg,
TestEnum::StructLike { x: 4, y: 1.4 },
]);
} | rust_cleaned_test_functions.jsonl/6262 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 299
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31054,
368,
341,
262,
11506,
27098,
3759,
9050,
11,
48440,
11,
55039,
11,
11091,
5563,
262,
7618,
3393,
10766,
341,
286,
2308,
2735,
345,
286,
3776,
2735,
7,
51878,
1326,
286,
17693,
7,
51878,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ir_encode() {
let ir = InstructionRegister {
target: Target::Cntr,
action: Action::Clear,
};
assert_eq!(ir.encode(), CLEAR_CNTR);
} | rust_cleaned_test_functions.jsonl/61610 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 110
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
51433,
11224,
368,
341,
286,
1077,
6216,
284,
29051,
8690,
341,
310,
2169,
25,
13483,
486,
34,
77,
376,
345,
310,
1917,
25,
5586,
486,
14008,
345,
286,
2605,
286,
2060,
10714,
10297,
404,
17313,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_i64() {
test_parse_ok(&[
("<bla>0</bla>", 0),
("<bla>-2</bla>", -2),
("<bla>-1234</bla>", -1234),
("<bla> -1234 </bla>", -1234),
]);
} | rust_cleaned_test_functions.jsonl/54621 | {
"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,
21039,
5318,
21,
19,
368,
341,
262,
1273,
21039,
19817,
2099,
9640,
286,
90276,
64726,
29,
15,
522,
64726,
21156,
220,
15,
1326,
286,
90276,
64726,
38643,
17,
522,
64726,
21156,
481,
17,
1326,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parsing_order_config() {
std::env::set_var("TIME_STYLE", "");
let argv = vec!["lsd"];
let matches = app::build().get_matches_from_safe(argv).unwrap();
let mut config = Config::with_none();
config.date = Some("+%c".into());
assert_eq!(
DateFlag::Formatted("%c".into()),
DateFlag::configure_from(&matches, &config)
);
} | rust_cleaned_test_functions.jsonl/1318 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 211
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
28598,
7869,
5332,
368,
341,
286,
1460,
486,
3160,
486,
746,
4612,
445,
18129,
41775,
497,
14498,
286,
1077,
10213,
284,
7486,
0,
1183,
4730,
67,
6332,
286,
1077,
9071,
284,
906,
486,
5834,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_struct_variant() {
let bser_v2 = b"\x00\x02\x00\x00\x00\x00\x05+\x00\x00\x00\x01\x03\x01\x02\x03\nTestStruct\
\x01\x03\x02\x02\x03\x03abc\x02\x03\x03foo\x02\x03\x03def\x02\x03\x03bar";
let decoded = from_slice::<BytestringVariant>(bser_v2).unwrap();
assert_eq!(
decoded,
BytestringVariant::TestStruct {
abc: (&b"foo"[..]).into(),
def: (&b"bar"[..]).into(),
}
);
} | rust_cleaned_test_functions.jsonl/34070 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 287
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15126,
46112,
368,
341,
1066,
262,
1077,
293,
799,
2273,
17,
284,
293,
11934,
87,
15,
15,
3462,
15,
17,
3462,
15,
15,
3462,
15,
15,
3462,
15,
15,
3462,
15,
15,
3462,
15,
20,
41715,
87,
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_resource_pack_send_system() {
let (mut w, mut d) = t::init_world();
let player = t::add_player(&mut w);
let event = PlayerJoinEvent {
player: player.entity,
};
t::trigger_event(&w, event);
let url = "https://rust-lang.org/".to_string();
let hash = "bLa".to_string();
{
let mut config = Config::clone(&w.fetch::<Arc<Config>>());
config.resource_pack.url = url.clone();
config.resource_pack.hash = hash.clone();
w.insert(Arc::new(config));
}
d.dispatch(&w);
w.maintain();
let packet = t::assert_packet_received(&player, PacketType::ResourcePackSend);
let packet = cast_packet::<ResourcePackSend>(&*packet);
assert_eq!(packet.url, url);
assert_eq!(packet.hash, hash.to_lowercase());
} | rust_cleaned_test_functions.jsonl/58775 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 423
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17962,
32995,
13565,
17687,
368,
341,
286,
1077,
320,
6984,
289,
11,
5206,
294,
8,
284,
259,
486,
2327,
31792,
1428,
286,
1077,
2781,
284,
259,
486,
718,
15524,
2099,
6984,
289,
626,
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_get_metadata() {
let (mock_db, client, _runtime) = create_database_client_and_runtime();
let metadata = client.get_metadata_by_version(1).unwrap().into_inner();
assert_eq!(metadata.version, 1);
assert_eq!(metadata.timestamp, mock_db.timestamps[1]);
} | rust_cleaned_test_functions.jsonl/102707 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 113
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
22220,
368,
341,
262,
1077,
320,
16712,
8685,
11,
2943,
11,
716,
22255,
8,
284,
1855,
27341,
8179,
8378,
33232,
1428,
262,
1077,
11160,
284,
2943,
670,
22220,
3710,
9438,
7,
16,
568,
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_name() {
let name = "test";
let mut pool = Pool::<ThunkWorker<()>>::with_name(name.to_owned(), 2);
let (tx, rx) = sync_channel(0);
// initial thread should share the name "test"
for _ in 0..2 {
let tx = tx.clone();
pool.execute(Thunk::of(move || {
let name = thread::current().name().unwrap().to_owned();
tx.send(name).unwrap();
}));
}
// new spawn thread should share the name "test" too.
pool.set_num_threads(3);
let tx_clone = tx.clone();
pool.execute(Thunk::of(move || {
let name = thread::current().name().unwrap().to_owned();
tx_clone.send(name).unwrap();
panic!();
}));
// recover thread should share the name "test" too.
pool.execute(Thunk::of(move || {
let name = thread::current().name().unwrap().to_owned();
tx.send(name).unwrap();
}));
for thread_name in rx.iter().take(4) {
assert_eq!(name, thread_name);
}
} | rust_cleaned_test_functions.jsonl/22902 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 556
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1269,
368,
341,
286,
1077,
829,
284,
330,
1944,
876,
286,
1077,
5206,
7314,
284,
22728,
27638,
38223,
21936,
27,
368,
77595,
4197,
1269,
3153,
2389,
51973,
1507,
220,
17,
317,
286,
1077,
320,
39... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
#[test]
fn test_is_closing_mark() {
fn check(s: &str, i: usize, expected: QuotationMarkRole) {
let actual = is_closing_mark(s, i);
if actual != expected {
panic!("i={}, expected={:?}, s={}", i, expected, &s[i..]);
}
}
let s1 = r#"keya="val1" keyb="val 2" keyc="val "3"" keyd="""#;
use self::QuotationMarkRole::*;
check(s1, 5, INNER);
check(s1, 10, CLOSING);
check(s1, 17, INNER);
check(s1, 23, CLOSING);
check(s1, 30, INNER);
check(s1, 35, INNER);
check(s1, 37, INNER);
check(s1, 38, CLOSING);
check(s1, 45, INNER);
check(s1, 46, CLOSING);
let s2 = r#"tvg-name="PPV- WRESTLING 03 | GCW: "Bring Em Out" (09.06-4:30PM ET)""#;
check(s2, 10, INNER);
check(s2, 35, INNER);
check(s2, 48, INNER);
check(s2, 57, INNER);
let s3 = r#" keya="val1" keyb="val "2"""#;
check(s3, 6, INNER);
check(s3, 11, CLOSING);
check(s3, 19, INNER);
check(s3, 24, INNER);
check(s3, 26, INNER);
check(s3, 27, CLOSING);
let s4 = r#"a="3" b="9 "13"" c="21"24"27",31, "36""#;
check(s4, 2, INNER);
check(s4, 4, CLOSING);
check(s4, 8, INNER);
check(s4, 11, INNER);
check(s4, 14, INNER);
check(s4, 15, CLOSING);
check(s4, 19, INNER);
check(s4, 22, INNER);
check(s4, 25, INNER);
check(s4, 28, ENDING);
} | rust_cleaned_test_functions.jsonl/107429 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 728
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6892,
666,
17831,
18924,
368,
341,
262,
5168,
1779,
1141,
25,
609,
495,
11,
600,
25,
22301,
11,
3601,
25,
3406,
11606,
8949,
9030,
8,
341,
286,
1077,
5042,
284,
374,
666,
17831,
18924,
1141,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_matches() {
let langid_en: LanguageIdentifier = "en".parse().unwrap();
let langid_en_us: LanguageIdentifier = "en-US".parse().unwrap();
let langid_en_us2: LanguageIdentifier = "en-US".parse().unwrap();
let langid_pl: LanguageIdentifier = "pl".parse().unwrap();
assert_eq!(langid_en.matches(&langid_en_us, false, false), false);
assert_eq!(langid_en_us.matches(&langid_en_us2, false, false), true);
assert_eq!(langid_en.matches(&langid_pl, false, false), false);
assert_eq!(langid_en.matches(&langid_en_us, true, false), true);
} | rust_cleaned_test_functions.jsonl/10764 | {
"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,
38344,
368,
341,
262,
1077,
8688,
307,
6205,
25,
11434,
8714,
284,
330,
268,
3263,
6400,
1005,
15454,
543,
262,
1077,
8688,
307,
6205,
11306,
25,
11434,
8714,
284,
330,
268,
32340,
3263,
6400,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_float() {
#[derive(Deserialize)]
struct TestFloat {
v: f32,
}
let regex = r"^(?P<v>[-+]?\d+(\.\d*)?)$";
assert_eq!(123.0, from_str::<TestFloat>("123", regex).unwrap().v);
assert_eq!(1.23, from_str::<TestFloat>("1.23", regex).unwrap().v);
assert_eq!(-123.0, from_str::<TestFloat>("-123", regex).unwrap().v);
assert_eq!(-1.23, from_str::<TestFloat>("-1.23", regex).unwrap().v);
assert!(from_str::<TestFloat>("#123", regex).is_err());
} | rust_cleaned_test_functions.jsonl/133425 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 285
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17586,
368,
341,
286,
11506,
27098,
7,
64465,
5563,
286,
2036,
3393,
5442,
341,
310,
348,
25,
282,
18,
17,
345,
286,
555,
286,
1077,
20180,
284,
435,
1,
13268,
30,
47,
39297,
29,
7609,
55905,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_abs_nan() {
assert!(f64::is_nan(complex::NAN.abs()));
let z: Complex = Complex::new(f64::INFINITY, f64::NAN);
assert!(f64::is_nan(z.abs()));
} | rust_cleaned_test_functions.jsonl/43829 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 103
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31170,
73936,
368,
341,
286,
2060,
10297,
69,
21,
19,
486,
285,
73936,
14094,
9111,
486,
45,
1093,
14572,
7392,
286,
1077,
1147,
25,
22096,
284,
22096,
486,
931,
955,
21,
19,
486,
687,
55990,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_vcx_connection_update_state_with_message() {
init!("true");
let handle = build_test_connection();
assert!(handle > 0);
connect(handle, None).unwrap();
let cb = return_types_u32::Return_U32_U32::new().unwrap();
let rc = vcx_connection_update_state_with_message(cb.command_handle, handle, CString::new(INVITE_ACCEPTED_RESPONSE).unwrap().into_raw(), Some(cb.get_callback()));
assert_eq!(rc, error::SUCCESS.code_num);
assert_eq!(cb.receive(Some(Duration::from_secs(10))).unwrap(), VcxStateType::VcxStateAccepted as u32);
} | rust_cleaned_test_functions.jsonl/25723 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 268
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2273,
25844,
15866,
8882,
4387,
6615,
6462,
368,
341,
286,
2930,
17223,
1866,
797,
286,
1077,
3705,
284,
1936,
4452,
15866,
543,
286,
2060,
10297,
8192,
861,
220,
15,
317,
286,
4564,
26405,
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_inverse_transform_point() {
let angle = Degrees(72_f64);
let cos_neg_angle = (-angle).cos();
let sin_neg_angle = (-angle).sin();
let distance = Vector2::new(-567_f64, 23_f64);
let isometry = Isometry2::from_angle_translation(angle, &distance);
let point = Point2::new(1_f64, 2_f64);
let diff: Point2<f64> = point - distance;
let expected = Point2::new(
cos_neg_angle * diff.x - sin_neg_angle * diff.y,
sin_neg_angle * diff.x + cos_neg_angle * diff.y
);
let result = isometry.inverse_transform_point(&point);
assert_eq!(result, expected);
} | rust_cleaned_test_functions.jsonl/77218 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 324
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
63333,
18449,
6085,
368,
341,
286,
1077,
9210,
284,
92901,
7,
22,
17,
761,
21,
19,
317,
286,
1077,
7960,
28209,
21727,
284,
10293,
4044,
568,
9407,
543,
286,
1077,
7437,
28209,
21727,
284,
10293... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_linear_distribution() {
// test u64
let mut dataset = Dataset::from_u64_vec(generate_linear_dataset_u64(12, 3, 5000));
evaluate_sketch(dataset);
// test i64
dataset = Dataset::from_i64_vec(generate_linear_dataset_i64(-12, 3, 5000));
evaluate_sketch(dataset);
// test f64
dataset = Dataset::from_f64_vec(generate_linear_dataset_f64(-12.0, 3.0, 5000));
evaluate_sketch(dataset);
} | rust_cleaned_test_functions.jsonl/7527 | {
"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,
40674,
41465,
368,
341,
286,
442,
1273,
575,
21,
19,
198,
286,
1077,
5206,
10337,
284,
39183,
486,
1499,
7300,
21,
19,
13251,
3268,
13220,
40674,
18999,
7300,
21,
19,
7,
16,
17,
11,
220,
18,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_transpile_use_deno() {
let source = r#"
export default function Index() {
const verison = useDeno(() => Deno.version)
const V8 = () => {
const verison = useDeno(() => Deno.version, true)
return <p>v8 v{version.v8}</p>
}
const TS = () => {
const verison = useDeno(() => Deno.version, 1)
return <p>typescript v{version.typescript}</p>
}
return (
<>
<p>Deno v{version.deno}</p>
<V8 />
<TS />
</>
)
}
"#;
let (code, _) = t("/pages/index.tsx", source, false);
println!("{}", code);
assert!(code.contains(", false, \"useDeno-"));
assert!(code.contains(", true, \"useDeno-"));
assert!(code.contains(", 1, \"useDeno-"));
} | rust_cleaned_test_functions.jsonl/34196 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 444
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7965,
12192,
15951,
814,
11790,
368,
341,
262,
1077,
2530,
284,
435,
2,
698,
414,
7485,
1638,
729,
8008,
368,
341,
286,
733,
2739,
3335,
284,
990,
35,
11790,
5065,
589,
9774,
78,
19484,
340,
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_reference_vector_l3_nonstandard_compl_sideinfo_blocktype() {
let test_vector = include_bytes!("../vectors/l3-nonstandard-compl-sideinfo-blocktype.bit");
test_vs_minimp3(test_vector);
} | rust_cleaned_test_functions.jsonl/69848 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 85
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25433,
12247,
907,
18,
21637,
20270,
2965,
500,
30862,
2733,
7113,
1313,
368,
341,
262,
1077,
1273,
12247,
284,
2924,
12524,
17223,
1244,
85,
10605,
13328,
18,
98700,
20270,
11476,
500,
24067,
2733,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_good_tls_values() {
// Take the lock so changing the environment doesn't cause races.
let _env_lock = ENV_LOCK.lock().unwrap();
env::set_var(CONFIG_ENV, "dev");
assert!(RocketConfig::parse(r#"
[staging]
tls = { certs = "some/path.pem", key = "some/key.pem" }
"#.to_string(), TEST_CONFIG_FILENAME).is_ok());
assert!(RocketConfig::parse(r#"
[staging.tls]
certs = "some/path.pem"
key = "some/key.pem"
"#.to_string(), TEST_CONFIG_FILENAME).is_ok());
assert!(RocketConfig::parse(r#"
[global.tls]
certs = "some/path.pem"
key = "some/key.pem"
"#.to_string(), TEST_CONFIG_FILENAME).is_ok());
assert!(RocketConfig::parse(r#"
[global]
tls = { certs = "some/path.pem", key = "some/key.pem" }
"#.to_string(), TEST_CONFIG_FILENAME).is_ok());
} | rust_cleaned_test_functions.jsonl/35240 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 509
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
44781,
71262,
9146,
368,
341,
286,
442,
11778,
279,
5296,
773,
10018,
279,
4573,
3171,
944,
5240,
20588,
624,
286,
1077,
716,
3160,
9818,
284,
32791,
27661,
21003,
1005,
15454,
543,
286,
6105,
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_random_knapsacks() {
for size in [4, 5, 6, 7, 8, 16, 32, 64, 128, 256].iter() {
let sack = ProblemSubsetSum::random(*size);
assert!(
sack.is_legal(),
"illegal random sack with size {}?!?",
*size
);
}
} | rust_cleaned_test_functions.jsonl/13342 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 187
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
22644,
4698,
77,
2625,
7821,
368,
341,
286,
369,
1379,
304,
508,
19,
11,
220,
20,
11,
220,
21,
11,
220,
22,
11,
220,
23,
11,
220,
16,
21,
11,
220,
18,
17,
11,
220,
21,
19,
11,
220,
16,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_add_dim_error_dim_already_exists() {
const DIM_NAME: &str = "dim_1";
const DIM_SIZE_1: usize = 10;
const DIM_SIZE_2: usize = 20;
// Test :
// 1. add a fixed-size dim
// 2. add a fixed-size dim
{
// create the data set
let mut data_set = DataSet::new();
assert_eq!(0, data_set.num_dims());
assert_eq!(false, data_set.has_unlimited_dim());
assert_eq!(false, data_set.has_dim(DIM_NAME));
assert_eq!(None, data_set.dim_size(DIM_NAME));
assert_eq!(None, data_set.dim_type(DIM_NAME));
// add a *fixed-size* dimension
data_set.add_fixed_dim(DIM_NAME, DIM_SIZE_1).unwrap();
assert_eq!(1, data_set.num_dims());
assert_eq!(false, data_set.has_unlimited_dim());
assert_eq!(true, data_set.has_dim(DIM_NAME));
assert_eq!(Some(DIM_SIZE_1), data_set.dim_size(DIM_NAME));
assert_eq!(Some(DimensionType::FixedSize), data_set.dim_type(DIM_NAME));
// Trye to add a other dimension with the same name
assert_eq!(
InvalidDataSet::DimensionAlreadyExists(DIM_NAME.to_string()),
data_set.add_fixed_dim(DIM_NAME, DIM_SIZE_2).unwrap_err()
);
assert_eq!(1, data_set.num_dims());
assert_eq!(false, data_set.has_unlimited_dim());
assert_eq!(true, data_set.has_dim(DIM_NAME));
assert_eq!(Some(DIM_SIZE_1), data_set.dim_size(DIM_NAME));
assert_eq!(Some(DimensionType::FixedSize), data_set.dim_type(DIM_NAME));
}
// Test :
// 1. add a fixed-size dim
// 2. set the unlimited-size dim
{
// create the data set
let mut data_set = DataSet::new();
assert_eq!(0, data_set.num_dims());
assert_eq!(false, data_set.has_unlimited_dim());
assert_eq!(false, data_set.has_dim(DIM_NAME));
assert_eq!(None, data_set.dim_size(DIM_NAME));
assert_eq!(None, data_set.dim_type(DIM_NAME));
// add a *fixed-size* dimension
data_set.add_fixed_dim(DIM_NAME, DIM_SIZE_1).unwrap();
assert_eq!(1, data_set.num_dims());
assert_eq!(false, data_set.has_unlimited_dim());
assert_eq!(true, data_set.has_dim(DIM_NAME));
assert_eq!(Some(DIM_SIZE_1), data_set.dim_size(DIM_NAME));
assert_eq!(Some(DimensionType::FixedSize), data_set.dim_type(DIM_NAME));
// Trye to add a other dimension with the same name
assert_eq!(
InvalidDataSet::DimensionAlreadyExists(DIM_NAME.to_string()),
data_set.set_unlimited_dim(DIM_NAME, DIM_SIZE_2).unwrap_err()
);
assert_eq!(1, data_set.num_dims());
assert_eq!(false, data_set.has_unlimited_dim());
assert_eq!(true, data_set.has_dim(DIM_NAME));
assert_eq!(Some(DIM_SIZE_1), data_set.dim_size(DIM_NAME));
assert_eq!(Some(DimensionType::FixedSize), data_set.dim_type(DIM_NAME));
}
// Test :
// 1. set the unlimited-size dim
// 2. add a fixed-size dim
{
// create the data set
let mut data_set = DataSet::new();
assert_eq!(0, data_set.num_dims());
assert_eq!(false, data_set.has_unlimited_dim());
assert_eq!(false, data_set.has_dim(DIM_NAME));
assert_eq!(None, data_set.dim_size(DIM_NAME));
assert_eq!(None, data_set.dim_type(DIM_NAME));
// add a *fixed-size* dimension
data_set.set_unlimited_dim(DIM_NAME, DIM_SIZE_1).unwrap();
assert_eq!(1, data_set.num_dims());
assert_eq!(true, data_set.has_unlimited_dim());
assert_eq!(true, data_set.has_dim(DIM_NAME));
assert_eq!(Some(DIM_SIZE_1), data_set.dim_size(DIM_NAME));
assert_eq!(Some(DimensionType::UnlimitedSize), data_set.dim_type(DIM_NAME));
// Trye to add a other dimension with the same name
assert_eq!(
InvalidDataSet::DimensionAlreadyExists(DIM_NAME.to_string()),
data_set.add_fixed_dim(DIM_NAME, DIM_SIZE_2).unwrap_err()
);
assert_eq!(1, data_set.num_dims());
assert_eq!(true, data_set.has_unlimited_dim());
assert_eq!(true, data_set.has_dim(DIM_NAME));
assert_eq!(Some(DIM_SIZE_1), data_set.dim_size(DIM_NAME));
assert_eq!(Some(DimensionType::UnlimitedSize), data_set.dim_type(DIM_NAME));
}
} | rust_cleaned_test_functions.jsonl/40513 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2779
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
10791,
4096,
10791,
80772,
9766,
368,
341,
262,
733,
50859,
4708,
25,
609,
495,
284,
330,
12927,
62,
16,
876,
262,
733,
50859,
4098,
62,
16,
25,
22301,
284,
220,
16,
15,
280,
262,
733,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_precommit() {
let propose_hash = hash(&[1, 2, 3]);
let block_hash = hash(&[3, 2, 1]);
let (public_key, secret_key) = gen_keypair();
let time = Utc::now();
// write
let precommit = Precommit::new(
VALIDATOR,
HEIGHT,
ROUND,
&propose_hash,
&block_hash,
time,
&secret_key,
);
// read
assert_eq!(precommit.validator(), VALIDATOR);
assert_eq!(precommit.height(), HEIGHT);
assert_eq!(precommit.round(), ROUND);
assert_eq!(precommit.propose_hash(), &propose_hash);
assert_eq!(precommit.block_hash(), &block_hash);
assert!(precommit.verify_signature(&public_key));
assert_eq!(precommit.time(), time);
let json_str = ::serde_json::to_string(&precommit).unwrap();
assert!(json_str.len() > 0);
let precommit1: Precommit = ::serde_json::from_str(&json_str).unwrap();
assert_eq!(precommit, precommit1);
} | rust_cleaned_test_functions.jsonl/118857 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 421
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10442,
17413,
368,
341,
262,
1077,
29614,
8950,
284,
5175,
2099,
58,
16,
11,
220,
17,
11,
220,
18,
2558,
262,
1077,
2504,
8950,
284,
5175,
2099,
58,
18,
11,
220,
17,
11,
220,
16,
2558,
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_copy() {
assert_eq!(
parse_line("copy 5887 x\nlink 1"),
Ok((
"link 1",
Instruction::Copy(Target::Literal(5887), Target::Register(String::from("x")))
)),
)
} | rust_cleaned_test_functions.jsonl/990 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 157
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16096,
368,
341,
286,
2060,
10714,
33673,
310,
4715,
6528,
445,
8560,
220,
20,
23,
23,
22,
856,
1699,
2080,
220,
16,
4461,
310,
7622,
94702,
394,
330,
2080,
220,
16,
756,
394,
29051,
486,
1210... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_1_conf_open() {
do_test_1_conf_open(ConnectStyle::BestBlockFirst);
do_test_1_conf_open(ConnectStyle::TransactionsFirst);
do_test_1_conf_open(ConnectStyle::FullBlockViaListen);
} | rust_cleaned_test_functions.jsonl/16862 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 81
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
16,
16059,
11311,
368,
341,
19935,
4452,
62,
16,
16059,
11311,
7,
14611,
2323,
486,
14470,
4713,
5338,
317,
19935,
4452,
62,
16,
16059,
11311,
7,
14611,
2323,
486,
48761,
5338,
317,
19935,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_list_index_in_family_methods() {
let dir = TempDir::new(super::gen_tempdir_name().as_str()).unwrap();
let path = dir.path();
let db = create_database(path);
let mut fork = db.fork();
let mut list_index = ListIndex::new_in_family(IDX_NAME, &vec![01], &mut fork);
super::list_index_methods(&mut list_index);
} | rust_cleaned_test_functions.jsonl/87437 | {
"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,
2019,
3560,
1243,
26823,
36084,
368,
341,
310,
1077,
5419,
284,
19944,
6184,
486,
931,
56040,
486,
4370,
11771,
3741,
1269,
1005,
300,
2895,
6011,
15454,
543,
310,
1077,
1815,
284,
5419,
3875,
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_span_vec_insert_coalescing() {
let mut sv = SpanVec::new();
let s_close = Span::new(0, 1).unwrap();
let s_mid = Span::new(1, 2).unwrap();
let s_far = Span::new(3, 4).unwrap();
sv.insert(s_far);
assert_eq!(sv.len(), 1);
sv.insert(s_mid);
assert_eq!(sv.len(), 1);
sv.insert(s_close);
assert_eq!(sv.len(), 1);
assert_eq!(sv[0], Span::new(0, 4).unwrap());
let mut sv = SpanVec::new();
let s_far = Span::new(1000, 1100).unwrap();
let s_close = Span::new(0, 1).unwrap();
let s_big = Span::new(2, 999).unwrap();
sv.insert(s_far);
assert_eq!(sv.len(), 1);
sv.insert(s_close);
assert_eq!(sv[0], s_close);
assert_eq!(sv[1], s_far);
assert_eq!(sv.len(), 2);
sv.insert(s_big);
assert_eq!(sv[0], Span::new(0, 1100).unwrap());
assert_eq!(sv.len(), 1);
let mut sv = SpanVec::new();
let s_far = Span::new(1000, 1100).unwrap();
let s_mid = Span::new(500, 550).unwrap();
let s_bridge_mid_far = Span::new(551, 999).unwrap();
let s_close = Span::new(0, 1).unwrap();
sv.insert(s_mid);
sv.insert(s_far);
sv.insert(s_close);
assert_eq!(sv[0], s_close);
assert_eq!(sv[1], s_mid);
assert_eq!(sv[2], s_far);
sv.insert(s_bridge_mid_far);
assert_eq!(sv[0], s_close);
assert_eq!(sv[1], Span::new(500, 1100).unwrap());
assert_eq!(sv.len(), 2);
let mut sv = SpanVec::new();
sv.insert(Span::new(0, 1).unwrap());
sv.insert(Span::new(3, 4).unwrap());
sv.insert(Span::new(6, 8).unwrap());
sv.insert(Span::new(10, 11).unwrap());
sv.insert(Span::new(13, 14).unwrap());
sv.insert(Span::new(16, 17).unwrap());
sv.insert(Span::new(19, 20).unwrap());
sv.insert(Span::new(23, 24).unwrap());
sv.insert(Span::new(26, 27).unwrap());
sv.insert(Span::new(29, 30).unwrap());
sv.insert(Span::new(400, 405).unwrap());
assert_eq!(sv.len(), 11);
sv.insert(Span::new(7, 399).unwrap());
assert_eq!(sv.len(), 3, "{:#?}", sv);
let mut sv = SpanVec::new();
sv.insert(Span::new(0, 1).unwrap());
sv.insert(Span::new(0, 1).unwrap());
sv.insert(Span::new(3, 4).unwrap());
sv.insert(Span::new(16, 17).unwrap());
sv.insert(Span::new(19, 20).unwrap());
sv.insert(Span::new(6, 8).unwrap());
sv.insert(Span::new(23, 24).unwrap());
sv.insert(Span::new(10, 11).unwrap());
sv.insert(Span::new(26, 27).unwrap());
sv.insert(Span::new(13, 14).unwrap());
sv.insert(Span::new(29, 30).unwrap());
sv.insert(Span::new(36, 37).unwrap());
sv.insert(Span::new(34, 35).unwrap());
sv.insert(Span::new(31, 32).unwrap());
sv.insert(Span::new(33, 34).unwrap());
sv.insert(Span::new(400, 405).unwrap());
assert_eq!(sv.len(), 11);
sv.insert(Span::new(9, 15).unwrap());
assert_eq!(sv.len(), 8, "{:#?}", sv);
sv.insert(Span::new(18, 35).unwrap());
assert_eq!(sv.len(), 4, "{:#?}", sv);
} | rust_cleaned_test_functions.jsonl/109252 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1400
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
37382,
13251,
17678,
11393,
3831,
6125,
368,
341,
262,
1077,
5206,
13559,
284,
11903,
10050,
486,
931,
543,
262,
1077,
274,
12704,
284,
11903,
486,
931,
7,
15,
11,
220,
16,
568,
15454,
543,
262,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_display() {
let l = SourceLocator::temporary().issue(Default::default());
assert_eq!(Sexp::signed(l, 123).to_string(), "123");
assert_eq!(Sexp::signed(l, -456789).to_string(), "-456789");
assert_eq!(
Sexp::signed(l, std::i64::MIN).to_string(),
std::i64::MIN.to_string()
);
assert_eq!(
Sexp::signed(l, std::i64::MAX).to_string(),
std::i64::MAX.to_string()
);
assert_eq!(Sexp::unsigned(l, 0).to_string(), "0");
assert_eq!(
Sexp::unsigned(l, std::u64::MAX).to_string(),
std::u64::MAX.to_string()
);
assert_eq!(Sexp::fpnumber(l, 3.1415.into()).to_string(), "3.1415");
assert_eq!(Sexp::char(l, '\n').to_string(), "#\\\\n");
assert_eq!(
Sexp::symbol(l, "hello/world".to_string()).to_string(),
"hello/world"
);
assert_eq!(
Sexp::string(l, "Hello, World!\n".to_string()).to_string(),
"\"Hello, World!\\n\""
);
assert_eq!(Sexp::list(l, vec![]).to_string(), "()");
assert_eq!(Sexp::list(l, vec![Sexp::signed(l, 1)]).to_string(), "(1)");
assert_eq!(
Sexp::list(l, vec![Sexp::signed(l, 1), Sexp::signed(l, 2)]).to_string(),
"(1 2)"
);
assert_eq!(
Sexp::list(
l,
vec![
Sexp::signed(l, 1),
Sexp::list(l, vec![Sexp::signed(l, 2), Sexp::signed(l, 3)])
]
)
.to_string(),
"(1 (2 3))"
);
assert_eq!(
Sexp::list_like(l, Sexp::signed(l, 1), vec![], Sexp::signed(l, 2),).to_string(),
"(1 . 2)"
);
assert_eq!(
Sexp::list_like(
l,
Sexp::signed(l, 1),
vec![Sexp::signed(l, 3)],
Sexp::signed(l, 2),
)
.to_string(),
"(1 3 . 2)"
);
assert_eq!(
Sexp::list_like(
l,
Sexp::signed(l, 1),
vec![Sexp::signed(l, 3), Sexp::signed(l, 4)],
Sexp::signed(l, 2),
)
.to_string(),
"(1 3 4 . 2)"
);
assert_eq!(Sexp::bool(l, true).to_string(), "#t");
assert_eq!(Sexp::bool(l, false).to_string(), "#f");
assert_eq!(
Sexp::cons(l, Sexp::bool(l, true), Sexp::bool(l, false)).to_string(),
"(#t . #f)"
);
assert_eq!(
Sexp::cons(
l,
Sexp::bool(l, true),
Sexp::list_like(l, Sexp::signed(l, 1), vec![], Sexp::signed(l, 2))
)
.to_string(),
"(#t 1 . 2)"
);
assert_eq!(
Sexp::cons(
l,
Sexp::bool(l, true),
Sexp::list(l, vec![Sexp::signed(l, 1)])
)
.to_string(),
"(#t 1)"
);
assert_eq!(Sexp::nil(l).to_string(), "()");
assert_eq!(Sexp::quote(l, Sexp::bool(l, true)).to_string(), "'#t");
assert_eq!(
Sexp::quasiquote(
l,
Sexp::list(
l,
vec![
Sexp::bool(l, true),
Sexp::unquote(l, Sexp::signed(l, 1)),
Sexp::unquote_splicing(
l,
Sexp::list(
l,
vec![Sexp::symbol(l, "foo".to_string()), Sexp::signed(l, 3)]
)
),
]
)
)
.to_string(),
"`(#t ,1 ,@(foo 3))"
);
assert_eq!(
Sexp::capture(l, Sexp::symbol(l, "foo".to_string()),).to_string(),
"\\foo"
);
assert_eq!(
Sexp::try_question(
l,
Sexp::list(l, vec![Sexp::bool(l, true), Sexp::bool(l, false),])
)
.to_string(),
"(#t #f)?"
);
assert_eq!(
Sexp::try_exclamation(
l,
Sexp::list(l, vec![Sexp::bool(l, true), Sexp::bool(l, false),])
)
.to_string(),
"(#t #f)!"
);
assert_eq!(
Sexp::annotate(
l,
Sexp::signed(l, 1),
vec![Sexp::signed(l, 2), Sexp::signed(l, 3)]
)
.to_string(),
"1 {2 3}"
);
} | rust_cleaned_test_functions.jsonl/25850 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2495
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
14825,
368,
341,
262,
1077,
326,
284,
8748,
33831,
486,
78090,
1005,
11159,
87874,
486,
2258,
5231,
262,
2060,
10714,
10297,
50,
4580,
486,
2215,
2333,
11,
220,
16,
17,
18,
568,
983,
3904,
1507,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_lt_same_num_digits_true() {
// Given:
let a = Counter::from(vec![9, 0]);
let b = Counter::from(vec![0, 1]);
// Then:
assert!(a < b);
} | rust_cleaned_test_functions.jsonl/79518 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 136
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39164,
33574,
4273,
41432,
16082,
368,
341,
310,
442,
16246,
510,
310,
1077,
264,
284,
19735,
486,
1499,
25592,
20703,
24,
11,
220,
15,
2558,
310,
1077,
293,
284,
19735,
486,
1499,
25592,
20703,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_underflow_flag() {
println!("flag before: {:?}", unsafe {underflow_p()});
let smallest_float = f64::from_bits(1);
println!("smallest float: {:e}", smallest_float);
println!("underflow float: {:e}", smallest_float / 2.);
let mut a = Float::with_val(53, smallest_float);
println!("smallest rug?: {:?}", a);
// somehow rug represents numbers beyond the given precision
println!("smaller rug: {:?}", a.clone() / 2.);
// tetrate to force underflow
for _ in 0..32 { a.mul_assign(&a.clone()); }
println!("underflow rug: {:?}", a);
println!("flag after: {:?}", unsafe {underflow_p()});
unsafe {clear_underflow()}
println!("flag cleared: {:?}", unsafe {underflow_p()});
} | rust_cleaned_test_functions.jsonl/51822 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 389
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
58228,
4965,
10933,
368,
341,
286,
13751,
17223,
9903,
1573,
25,
981,
71964,
19860,
314,
7995,
4965,
620,
89460,
1789,
286,
1077,
24632,
17586,
284,
282,
21,
19,
486,
1499,
20034,
7,
16,
317,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_get_interfaces() {
let mut test_config = create_test_config_no_paths();
test_config.device_config = Some(build_full_config());
match test_config.interfaces() {
Some(i) => {
assert_eq!(*i, build_full_config().device.interfaces.unwrap());
}
None => panic!("Got unexpected 'None' option"),
}
} | rust_cleaned_test_functions.jsonl/83808 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 192
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
72960,
368,
341,
286,
1077,
5206,
1273,
5332,
284,
1855,
4452,
5332,
6536,
24152,
543,
286,
1273,
5332,
18355,
5332,
284,
4329,
43333,
16372,
5332,
1423,
286,
2432,
1273,
5332,
34459,
368,
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_add_assign() {
let mut vec_a = Vec2::new(1.0, -4.0);
let vec_b = Vec2::new(5.0, -7.0);
vec_a += vec_b;
assert_approx_eq!(vec_a.x(), 6.0);
assert_approx_eq!(vec_a.y(), -11.0);
} | rust_cleaned_test_functions.jsonl/77721 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 149
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
20688,
368,
341,
286,
1077,
5206,
7486,
4306,
284,
11312,
17,
486,
931,
7,
16,
13,
15,
11,
481,
19,
13,
15,
317,
286,
1077,
7486,
880,
284,
11312,
17,
486,
931,
7,
20,
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_process_transactions_returns_unprocessed_txs() {
solana_logger::setup();
let GenesisConfigInfo {
genesis_config,
mint_keypair,
..
} = create_slow_genesis_config(10_000);
let bank = Arc::new(Bank::new_no_wallclock_throttle(&genesis_config));
let pubkey = solana_sdk::pubkey::new_rand();
let transactions =
vec![
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_config.hash())
.into(),
];
let ledger_path = get_tmp_ledger_path!();
{
let blockstore = Blockstore::open(&ledger_path)
.expect("Expected to be able to open database ledger");
let (poh_recorder, _entry_receiver, record_receiver) = PohRecorder::new(
bank.tick_height(),
bank.last_blockhash(),
bank.slot(),
Some((4, 4)),
bank.ticks_per_slot(),
&solana_sdk::pubkey::new_rand(),
&Arc::new(blockstore),
&Arc::new(LeaderScheduleCache::new_from_bank(&bank)),
&Arc::new(PohConfig::default()),
Arc::new(AtomicBool::default()),
);
// record
let recorder = poh_recorder.recorder();
let poh_simulator = simulate_poh(record_receiver, &Arc::new(Mutex::new(poh_recorder)));
let (gossip_vote_sender, _gossip_vote_receiver) = unbounded();
let (processed_transactions_count, mut retryable_txs) =
BankingStage::process_transactions(
&bank,
&Instant::now(),
&transactions,
&recorder,
None,
&gossip_vote_sender,
);
assert_eq!(processed_transactions_count, 0,);
retryable_txs.sort_unstable();
let expected: Vec<usize> = (0..transactions.len()).collect();
assert_eq!(retryable_txs, expected);
recorder.is_exited.store(true, Ordering::Relaxed);
let _ = poh_simulator.join();
}
Blockstore::destroy(&ledger_path).unwrap();
} | rust_cleaned_test_functions.jsonl/2937 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1232
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11305,
68182,
58900,
4907,
34022,
17805,
82,
368,
341,
286,
2048,
3362,
27413,
486,
15188,
543,
286,
1077,
40788,
2648,
1731,
341,
310,
59366,
5332,
345,
310,
28337,
3097,
12670,
345,
310,
54538,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_u128() {
test_serde!(U128, u128, 0);
test_serde!(U128, u128, 1);
test_serde!(U128, u128, 123);
test_serde!(U128, u128, 10u128.pow(18));
test_serde!(U128, u128, 2u128.pow(100));
test_serde!(U128, u128, u128::max_value());
assert!(U128::from(u128::min_value()) < U128::from(u128::max_value()));
} | rust_cleaned_test_functions.jsonl/16265 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 211
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7300,
16,
17,
23,
368,
341,
286,
1273,
75861,
450,
10297,
52,
16,
17,
23,
11,
575,
16,
17,
23,
11,
220,
15,
317,
286,
1273,
75861,
450,
10297,
52,
16,
17,
23,
11,
575,
16,
17,
23,
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_controller_is_running() {
let mut ctrl0 = Controller::new();
ctrl0.start();
let mut ctrl1 = Controller::new();
ctrl1.stop();
assert_eq!(ctrl0.is_running(), true);
assert_eq!(ctrl1.is_running(), false);
} | rust_cleaned_test_functions.jsonl/12613 | {
"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,
21600,
6892,
37333,
368,
341,
286,
1077,
5206,
23743,
15,
284,
9771,
486,
931,
543,
286,
23743,
15,
4962,
1428,
286,
1077,
5206,
23743,
16,
284,
9771,
486,
931,
543,
286,
23743,
16,
13227,
1428,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_nothing_comparisson_eq() {
let engine_state = EngineState::new();
let mut working_set = StateWorkingSet::new(&engine_state);
let (block, err) = parse(&mut working_set, None, b"2 == $nothing", true, &[]);
assert!(err.is_none());
assert!(block.len() == 1);
let expressions = &block[0];
assert!(expressions.len() == 1);
assert!(matches!(
&expressions[0],
Expression {
expr: Expr::BinaryOp(..),
..
}
))
} | rust_cleaned_test_functions.jsonl/7102 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 230
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6536,
1596,
2965,
1732,
48263,
10714,
368,
341,
262,
1077,
4712,
4387,
284,
8200,
1397,
486,
931,
543,
262,
1077,
5206,
3238,
2602,
284,
3234,
33978,
1649,
486,
931,
2099,
8512,
4387,
317,
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_rejected_add_keeps_state() {
let mut assr = Assembler::new(CONTIG_COUNT*20);
for c in 1..=CONTIG_COUNT-1 {
assert_eq!(assr.add(c*10, 3), Ok(()));
}
// Maximum of allowed holes is reached
let assr_before = assr.clone();
assert_eq!(assr.add(1, 3), Err(()));
assert_eq!(assr_before, assr);
} | rust_cleaned_test_functions.jsonl/52013 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 199
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1288,
28303,
2891,
45476,
7124,
4387,
368,
341,
286,
1077,
5206,
1071,
81,
284,
1634,
35401,
486,
931,
98747,
1914,
14672,
9,
17,
15,
317,
286,
369,
272,
304,
220,
16,
496,
28,
23312,
1914,
14... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_gt_negative_and_zero() {
assert!(decimal("0.0") > decimal("-0.1"));
assert!(decimal("0.0") > decimal("-1.0"));
} | rust_cleaned_test_functions.jsonl/58115 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 71
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
37479,
53865,
8378,
19359,
368,
341,
262,
2060,
10297,
23289,
445,
15,
13,
15,
899,
861,
12122,
13645,
15,
13,
16,
4010,
262,
2060,
10297,
23289,
445,
15,
13,
15,
899,
861,
12122,
13645,
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 |
#[test]
fn test_update_twin_works() {
ExternalityBuilder::build().execute_with(|| {
create_twin();
let ip = "some_other_ip".as_bytes().to_vec();
assert_ok!(TfgridModule::update_twin(Origin::signed(alice()), ip));
});
} | rust_cleaned_test_functions.jsonl/35363 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 118
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8882,
528,
7526,
11498,
82,
368,
341,
262,
1374,
4160,
2719,
3297,
486,
5834,
1005,
10257,
6615,
79453,
341,
286,
1855,
528,
7526,
1428,
286,
1077,
5997,
284,
330,
14689,
30456,
10385,
3263,
300,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_gen_path_9_6_3_4() {
let partition_depth: u32 = 3;
let partition_size: u32 = 4;
let hash = "606060606467";
let _path = gen_path(hash, partition_size, partition_depth);
} | rust_cleaned_test_functions.jsonl/7878 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 113
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16322,
2638,
62,
24,
62,
21,
62,
18,
62,
19,
368,
341,
286,
1077,
16658,
19061,
25,
575,
18,
17,
284,
220,
18,
280,
286,
1077,
16658,
2368,
25,
575,
18,
17,
284,
220,
19,
280,
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_eval_unary_function_scalar() {
#[derive(Debug, Clone, Copy, RpnFunction)]
#[rpn_function(args = 1)]
struct FnFoo;
impl FnFoo {
fn call(
_ctx: &mut EvalContext,
_payload: RpnFnCallPayload<'_>,
v: &Option<f64>,
) -> Result<Option<f64>> {
Ok(v.map(|v| v * 2.0))
}
}
let exp = RpnExpressionBuilder::new()
.push_constant(1.5f64)
.push_fn_call(FnFoo, FieldTypeTp::Double)
.build();
let mut ctx = EvalContext::default();
let mut columns = LazyBatchColumnVec::empty();
let result = exp.eval(&mut ctx, 3, &[], &mut columns);
let val = result.unwrap();
assert!(val.is_vector());
assert_eq!(
val.vector_value().unwrap().as_real_slice(),
[Some(3.0), Some(3.0), Some(3.0)]
);
assert_eq!(val.field_type().tp(), FieldTypeTp::Double);
} | rust_cleaned_test_functions.jsonl/111582 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 574
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21296,
4907,
658,
9174,
41652,
368,
341,
394,
11506,
27098,
42618,
11,
27913,
11,
14540,
11,
431,
19958,
5152,
5563,
286,
11506,
81,
19958,
9174,
7356,
284,
220,
16,
5563,
286,
2036,
50182,
40923,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_transaction_and_output_list_with_proof() {
let transaction = Transaction::BlockMetadata(BlockMetadata::new(
HashValue::random(),
0,
0,
vec![],
AccountAddress::random(),
));
let event = create_event();
let transaction_output = TransactionOutput::new(
WriteSet::default(),
vec![event.clone()],
0,
TransactionStatus::Keep(KeptVMStatus::MiscellaneousError),
);
// Create transaction output list with proof
let transaction_info_list_proof =
create_single_transaction_info_proof(Some(transaction.hash()), None);
let transaction_output_list_proof = TransactionOutputListWithProof::new(
vec![(transaction.clone(), transaction_output.clone())],
Some(1),
transaction_info_list_proof.clone(),
);
// Verify first transaction version must match the proof
let empty_ledger_info = LedgerInfo::new(BlockInfo::empty(), HashValue::zero());
transaction_output_list_proof
.verify(&empty_ledger_info, None)
.unwrap_err();
let expected_info_hash = transaction_info_list_proof.transaction_infos[0].hash();
let block_info = BlockInfo::new(0, 0, HashValue::random(), expected_info_hash, 0, 0, None);
let ledger_info = LedgerInfo::new(block_info, HashValue::zero());
transaction_output_list_proof
.verify(&ledger_info, Some(1))
.unwrap_err();
// Construct a new transaction output list proof where the transaction info and event hashes match
let transaction_info_list_proof =
create_single_transaction_info_proof(Some(transaction.hash()), Some(event.hash()));
let expected_info_hash = transaction_info_list_proof.transaction_infos[0].hash();
let transaction_and_output_list_proof = TransactionOutputListWithProof::new(
vec![(transaction, transaction_output)],
Some(1),
transaction_info_list_proof,
);
// Ensure ledger verification now passes
let block_info = BlockInfo::new(0, 0, HashValue::random(), expected_info_hash, 0, 0, None);
let ledger_info = LedgerInfo::new(block_info, HashValue::zero());
transaction_and_output_list_proof
.verify(&ledger_info, Some(1))
.unwrap();
} | rust_cleaned_test_functions.jsonl/33633 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 854
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
28884,
8378,
7645,
2019,
6615,
86757,
368,
341,
1066,
262,
1077,
7745,
284,
17869,
486,
4713,
14610,
55243,
14610,
486,
931,
1006,
286,
6531,
1130,
486,
11463,
3148,
286,
220,
15,
345,
286,
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_derived_enum() {
// Ensure that rename works.
assert_eq!(SomeEnum::name(&()), Some("Some"));
// Ensure validity of meta info.
let mut registry = juniper::Registry::new(FnvHashMap::default());
let meta = SomeEnum::meta(&(), &mut registry);
assert_eq!(meta.name(), Some("Some"));
assert_eq!(meta.description(), Some(&"enum descr".to_string()));
// Test Regular variant.
assert_eq!(
SomeEnum::Regular.to_input_value(),
InputValue::String("REGULAR".into())
);
assert_eq!(
FromInputValue::from_input_value(&InputValue::String("REGULAR".into())),
Some(SomeEnum::Regular)
);
// Test FULL variant.
assert_eq!(
SomeEnum::Full.to_input_value(),
InputValue::String("full".into())
);
assert_eq!(
FromInputValue::from_input_value(&InputValue::String("full".into())),
Some(SomeEnum::Full)
);
} | rust_cleaned_test_functions.jsonl/65544 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 386
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
35345,
2221,
31054,
368,
341,
262,
442,
29279,
429,
29074,
4278,
624,
262,
2060,
10714,
10297,
8373,
10766,
486,
606,
2099,
11858,
4329,
445,
8373,
14929,
262,
442,
29279,
31839,
315,
8823,
3546,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_do_parse_lat_lon() {
let (_, lat_lon) = do_parse_lat_lon(b"4807.038,N,01131.324,E").unwrap();
relative_eq!(lat_lon.0, 48. + 7.038 / 60.);
relative_eq!(lat_lon.1, 11. + 31.324 / 60.);
} | rust_cleaned_test_functions.jsonl/76512 | {
"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,
26309,
21039,
26174,
57688,
368,
341,
286,
1077,
39464,
6844,
57688,
8,
284,
653,
21039,
26174,
57688,
1883,
1,
19,
23,
15,
22,
13,
15,
18,
23,
22037,
11,
15,
16,
16,
18,
16,
13,
18,
17,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_multiwhitespace() {
use Token::*;
let (tokens, maybe_error) =
tokenize_string("add subtract\n# # into # into #\n\n# into\n#into#into\n#\n#\nend");
assert_eq!(tokens, vec![Add, Subtract, End]);
assert!(maybe_error.is_none());
} | rust_cleaned_test_functions.jsonl/78238 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 153
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25133,
1312,
36074,
368,
341,
286,
990,
9660,
56162,
286,
1077,
320,
30566,
11,
7196,
4096,
8,
4035,
310,
77651,
3904,
445,
718,
32256,
1699,
2,
671,
1119,
671,
1119,
671,
59,
77,
1699,
2,
111... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_fmt() {
let vals = vec![
(1, 0, ( "1", "1.0", "1.0000")),
(1, 1, ( "0.1", "0.1", "0.1000")),
(1, 2, ( "0.01", "0.0", "0.0100")),
(1, -2, ("100", "100.0", "100.0000")),
(-1, 0, ( "-1", "-1.0", "-1.0000")),
(-1, 1, ( "-0.1", "-0.1", "-0.1000")),
(-1, 2, ( "-0.01", "-0.0", "-0.0100")),
];
for (i, scale, results) in vals {
let x = BigDecimal::new(num::BigInt::from(i), scale);
assert_eq!(format!("{}", x), results.0);
assert_eq!(format!("{:.1}", x), results.1);
assert_eq!(format!("{:.4}", x), results.2);
}
} | rust_cleaned_test_functions.jsonl/75822 | {
"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,
38128,
368,
341,
286,
1077,
28356,
284,
7486,
90515,
16159,
310,
320,
16,
11,
220,
15,
11,
220,
320,
220,
330,
16,
497,
257,
330,
16,
13,
15,
497,
262,
330,
16,
13,
15,
15,
15,
15,
30154,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_reserve_space_for_recover() {
let tmp_dir = Builder::new()
.prefix("test_reserve_space_for_recover")
.tempdir()
.unwrap();
let data_path = tmp_dir.path();
let disk_stats_before = fs2::statvfs(data_path).unwrap();
let cap1 = disk_stats_before.available_space();
let reserve_size = 64 * 1024;
reserve_space_for_recover(data_path, reserve_size).unwrap();
let disk_stats_after = fs2::statvfs(data_path).unwrap();
let cap2 = disk_stats_after.available_space();
assert_eq!(cap1 - cap2, reserve_size);
reserve_space_for_recover(data_path, 0).unwrap();
let disk_stats = fs2::statvfs(data_path).unwrap();
let cap3 = disk_stats.available_space();
assert_eq!(cap1, cap3);
} | rust_cleaned_test_functions.jsonl/82521 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 387
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
89591,
14663,
5478,
1288,
3688,
368,
341,
286,
1077,
4174,
4334,
284,
20626,
486,
931,
741,
310,
659,
11849,
445,
1944,
89591,
14663,
5478,
1288,
3688,
1138,
310,
659,
3888,
3741,
741,
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_parse_field_tag() {
assert_eq!(parse_field_tag(b"003@").unwrap().1, BString::from("003@"));
assert_eq!(parse_field_tag(b"012A").unwrap().1, BString::from("012A"));
assert_eq!(parse_field_tag(b"003").is_err(), true);
assert_eq!(parse_field_tag(b"03").is_err(), true);
assert_eq!(parse_field_tag(b"0").is_err(), true);
assert_eq!(parse_field_tag(b"").is_err(), true);
assert_eq!(parse_field_tag(b"003!").is_err(), true);
assert_eq!(parse_field_tag(b"303@").is_err(), true);
} | rust_cleaned_test_functions.jsonl/101494 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 277
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
5013,
9372,
368,
341,
286,
2060,
10714,
10297,
6400,
5013,
9372,
1883,
1,
15,
15,
18,
31,
1827,
15454,
1005,
16,
11,
425,
703,
486,
1499,
445,
15,
15,
18,
31,
4010,
286,
2060,
10714,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_inbound_connection() {
let mut transport = InprocTransport::default();
let mut listener = transport
.listen("inproc://test_inbound_connection")
.expect("Cannot listen for connections");
let mesh = Mesh::new(512, 128);
let (conn_tx, conn_rx) = mpsc::channel();
let mut remote_transport = transport.clone();
let jh = thread::spawn(move || {
let _connection = remote_transport
.connect("inproc://test_inbound_connection")
.unwrap();
// block until done
conn_rx.recv().unwrap();
});
let mut cm = ConnectionManager::builder()
.with_authorizer(Box::new(NoopAuthorizer::new("test_identity")))
.with_matrix_life_cycle(mesh.get_life_cycle())
.with_matrix_sender(mesh.get_sender())
.with_transport(Box::new(transport))
.start()
.expect("Unable to start Connection Manager");
let connector = cm.connector();
let (subs_tx, subs_rx) = mpsc::channel();
connector.subscribe(subs_tx).expect("Cannot get subscriber");
let connection = listener.accept().unwrap();
connector
.add_inbound_connection(connection)
.expect("Unable to add inbound connection");
let notification = subs_rx
.iter()
.next()
.expect("Cannot get message from subscriber");
let connection_id_for_removal;
if let ConnectionManagerNotification::InboundConnection {
endpoint,
connection_id,
..
} = notification
{
connection_id_for_removal = connection_id.to_string();
assert_eq!("inproc://test_inbound_connection", &endpoint);
} else {
panic!("Incorrect notification received: {:?}", notification);
}
let connection_endpoints = connector.list_connections().unwrap();
assert_eq!(
vec!["inproc://test_inbound_connection".to_string()],
connection_endpoints
);
connector
.remove_connection(
"inproc://test_inbound_connection",
&connection_id_for_removal,
)
.unwrap();
let connection_endpoints = connector.list_connections().unwrap();
assert!(connection_endpoints.is_empty());
conn_tx.send(()).unwrap();
jh.join().unwrap();
cm.signal_shutdown();
cm.wait_for_shutdown()
.expect("Unable to shutdown connection manager");
} | rust_cleaned_test_functions.jsonl/86770 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1225
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1243,
10891,
15866,
368,
341,
286,
1077,
5206,
7557,
284,
758,
15782,
27560,
486,
2258,
543,
286,
1077,
5206,
11446,
284,
7557,
198,
310,
659,
36337,
445,
258,
15782,
1110,
1944,
1243,
10891,
1586... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_castle_kingside_white() {
let castle_move = Move {
kind: MoveKind::CastleKingside,
from: Square::E1,
to: Square::G1,
};
let mut builder = PositionBuilder::new();
builder
.side_to_move(Color::White)
.place(Square::E1, Piece::King, Color::White)
.place(Square::H1, Piece::Rook, Color::White);
let position = builder.build();
let moves = MoveGenerator::new().moves(&position);
assert_eq!(false, moves.contains(&castle_move));
// Castle flag must be set
builder.can_castle_kside(Color::White, true);
let position = builder.build();
let moves = MoveGenerator::new().moves(&position);
assert_eq!(true, moves.contains(&castle_move));
// King must not be in check
let position =
builder.clone().place(Square::F3, Piece::Knight, Color::Black).build();
let moves = MoveGenerator::new().moves(&position);
assert_eq!(false, moves.contains(&castle_move));
// King must not pass through check
let position = builder
.clone()
.place(Square::E2, Piece::BlackPawn, Color::Black)
.build();
let moves = MoveGenerator::new().moves(&position);
assert_eq!(false, moves.contains(&castle_move));
} | rust_cleaned_test_functions.jsonl/134612 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 473
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5303,
273,
4698,
819,
577,
44431,
368,
341,
262,
1077,
32584,
17134,
284,
14561,
341,
414,
3093,
25,
14561,
10629,
486,
86603,
42,
819,
577,
345,
414,
504,
25,
15619,
486,
36,
16,
345,
414,
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_missing_comma_error() {
let tuple_string = r#"(
1 // <-- forgotten comma here
2
)"#;
assert_eq!(
ron::from_str::<(i32, i32)>(tuple_string).unwrap_err(),
SpannedError {
code: Error::ExpectedComma,
position: Position { line: 3, col: 9 }
}
);
let list_string = r#"[
0,
1 // <-- forgotten comma here
2
]"#;
assert_eq!(
ron::from_str::<Vec<i32>>(list_string).unwrap_err(),
SpannedError {
code: Error::ExpectedComma,
position: Position { line: 4, col: 9 }
}
);
let struct_string = r#"Test(
a: 1 // <-- forgotten comma here
b: 2
)"#;
assert_eq!(
ron::from_str::<Test>(struct_string).unwrap_err(),
SpannedError {
code: Error::ExpectedComma,
position: Position { line: 3, col: 9 }
}
);
let map_string = r#"{
"a": 1 // <-- forgotten comma here
"b": 2
}"#;
assert_eq!(
ron::from_str::<std::collections::HashMap<String, i32>>(map_string).unwrap_err(),
SpannedError {
code: Error::ExpectedComma,
position: Position { line: 3, col: 9 }
}
);
} | rust_cleaned_test_functions.jsonl/103475 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 675
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
40447,
2965,
1728,
4096,
368,
341,
262,
1077,
14405,
3904,
284,
435,
55543,
1006,
286,
220,
16,
442,
70386,
24547,
31683,
1588,
198,
286,
220,
17,
198,
262,
873,
57676,
401,
262,
2060,
10714,
33... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_simplity_optimized_plan_support_values() {
let expr1 = Expr::BinaryExpr {
left: Box::new(lit(1)),
op: Operator::Plus,
right: Box::new(lit(2)),
};
let expr2 = Expr::BinaryExpr {
left: Box::new(lit(2)),
op: Operator::Minus,
right: Box::new(lit(1)),
};
let values = vec![vec![expr1, expr2]];
let plan = LogicalPlanBuilder::values(values).unwrap().build().unwrap();
let expected = "\
Values: (Int32(3) AS Int32(1) + Int32(2), Int32(1) AS Int32(2) - Int32(1))";
assert_optimized_plan_eq(&plan, expected);
} | rust_cleaned_test_functions.jsonl/19702 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 347
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
643,
6383,
487,
15032,
45706,
26564,
25827,
9146,
368,
341,
286,
1077,
15169,
16,
284,
28819,
486,
21338,
16041,
341,
310,
2115,
25,
8261,
486,
931,
2333,
275,
7,
16,
6965,
310,
1179,
25,
28498,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_syscall_sol_panic() {
let string = "Gaggablaghblagh!";
let addr = string.as_ptr() as *const _ as u64;
let ro_region = MemoryRegion {
addr_host: addr,
addr_vm: 100,
len: string.len() as u64,
};
let rw_region = MemoryRegion::default();
syscall_sol_panic(
100,
string.len() as u64,
42,
84,
0,
&[ro_region],
&[rw_region],
)
.unwrap();
} | rust_cleaned_test_functions.jsonl/42303 | {
"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,
20344,
6659,
53668,
620,
31270,
368,
341,
286,
1077,
914,
284,
330,
38,
15718,
370,
13363,
71,
2024,
33756,
26782,
286,
1077,
10789,
284,
914,
5357,
4348,
368,
438,
353,
1024,
716,
438,
575,
21,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_from_string_succeeds() {
init!("true");
let handle = create_cred_def_fake();
let credentialdef_data = to_string(handle).unwrap();
assert!(!credentialdef_data.is_empty());
release(handle).unwrap();
let new_handle = from_string(&credentialdef_data).unwrap();
let new_credentialdef_data = to_string(new_handle).unwrap();
let credentialdef1: CredentialDef = CredentialDef::from_str(&credentialdef_data).unwrap();
let credentialdef2: CredentialDef = CredentialDef::from_str(&new_credentialdef_data).unwrap();
assert_eq!(credentialdef1, credentialdef2);
assert_eq!(CredentialDef::from_str("{}").unwrap_err().kind(), VcxErrorKind::CreateCredDef);
} | rust_cleaned_test_functions.jsonl/64628 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 321
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5673,
3904,
643,
29264,
82,
368,
341,
286,
2930,
17223,
1866,
797,
286,
1077,
3705,
284,
1855,
73475,
7844,
56881,
543,
286,
1077,
40207,
750,
1769,
284,
311,
3904,
26405,
568,
15454,
543,
286,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_bundle_paths() {
assert_eq!(sanitize_bundle_path("foo"), "foo");
assert_eq!(sanitize_bundle_path("foo/bar"), "foo/bar");
assert_eq!(sanitize_bundle_path("/foo/bar"), "foo/bar");
assert_eq!(sanitize_bundle_path("C:/foo/bar"), "C/foo/bar");
assert_eq!(sanitize_bundle_path("\\foo\\bar"), "foo/bar");
assert_eq!(sanitize_bundle_path("\\\\UNC\\foo\\bar"), "UNC/foo/bar");
} | rust_cleaned_test_functions.jsonl/51756 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 221
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
60986,
24152,
368,
341,
286,
2060,
10714,
10297,
65704,
60986,
2638,
445,
7975,
3975,
330,
7975,
797,
286,
2060,
10714,
10297,
65704,
60986,
2638,
445,
7975,
49513,
3975,
330,
7975,
49513,
797,
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_read_wrapping_value() {
let mut mmapped_buf = MMappedBuf {
data: [0; PAGE_SIZE * 2],
};
fake_mmap(&mut mmapped_buf);
let mut buf = PerfBuffer::open(1, PAGE_SIZE, 1).unwrap();
let sample = PerfSample {
s_hdr: Sample {
header: perf_event_header {
type_: PERF_RECORD_SAMPLE as u32,
misc: 0,
size: mem::size_of::<PerfSample<u64>>() as u16,
},
size: mem::size_of::<u64>() as u32,
},
value: 0xCAFEBABEu32,
};
let offset = PAGE_SIZE - mem::size_of::<PerfSample<u32>>();
mmapped_buf.mmap_page.data_tail = offset as u64;
write(&mut mmapped_buf, offset, sample);
write(&mut mmapped_buf, 0, 0xBAADCAFEu32);
let mut out_bufs = [BytesMut::with_capacity(8)];
let events = buf.read_events(&mut out_bufs).unwrap();
assert_eq!(events, Events { lost: 0, read: 1 });
assert_eq!(u64_from_buf(&out_bufs[0]), 0xBAADCAFECAFEBABE);
} | rust_cleaned_test_functions.jsonl/118768 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 600
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
44074,
3629,
3142,
368,
341,
286,
1077,
5206,
9465,
5677,
10363,
284,
21665,
5677,
15064,
341,
310,
821,
25,
508,
15,
26,
25040,
4098,
353,
220,
17,
1259,
286,
2605,
286,
12418,
717,
2186,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_transport_worker_data_event() {
let (_, stop_rx) = mpsc::channel();
let (_, worker_rx) = mpsc::channel();
let (worker_tx, rx) = mpsc::channel();
let worker = TransportWorker {
stop: stop_rx,
timeout: Duration::from_micros(0),
rx: worker_rx,
txs: HashMap::from_iter(vec![(1, worker_tx)].into_iter()),
};
let data = Event::Data(vec![1, 2]);
worker.handle_data(data);
match rx.recv().unwrap() {
Event::Data(output) => assert_eq!(output, vec![2]),
e => panic!(format!("Unexpected output: {:?}", e)),
}
} | rust_cleaned_test_functions.jsonl/126108 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 342
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
46398,
40385,
1769,
6748,
368,
341,
286,
1077,
39464,
2936,
24330,
8,
284,
296,
81984,
486,
10119,
543,
286,
1077,
39464,
11864,
24330,
8,
284,
296,
81984,
486,
10119,
543,
286,
1077,
320,
21462,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_update_last_wins() {
let key = Keypair::new();
let index = AccountsIndex::<bool>::default_for_tests();
let ancestors = vec![(0, 0)].into_iter().collect();
let mut gc = Vec::new();
index.upsert(
0,
&key.pubkey(),
&Pubkey::default(),
&[],
&AccountSecondaryIndexes::default(),
true,
&mut gc,
UPSERT_PREVIOUS_SLOT_ENTRY_WAS_CACHED_FALSE,
);
assert!(gc.is_empty());
let (list, idx) = index.get(&key.pubkey(), Some(&ancestors), None).unwrap();
assert_eq!(list.slot_list()[idx], (0, true));
drop(list);
let mut gc = Vec::new();
index.upsert(
0,
&key.pubkey(),
&Pubkey::default(),
&[],
&AccountSecondaryIndexes::default(),
false,
&mut gc,
UPSERT_PREVIOUS_SLOT_ENTRY_WAS_CACHED_FALSE,
);
assert_eq!(gc, vec![(0, true)]);
let (list, idx) = index.get(&key.pubkey(), Some(&ancestors), None).unwrap();
assert_eq!(list.slot_list()[idx], (0, false));
} | rust_cleaned_test_functions.jsonl/99732 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 655
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8882,
12195,
1670,
1330,
368,
341,
286,
1077,
1376,
284,
6569,
1082,
1310,
486,
931,
543,
286,
1077,
1922,
284,
40655,
1552,
27638,
2641,
6831,
2258,
5478,
32509,
543,
286,
1077,
37518,
284,
7486,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_find_matching_closing_symbol_no_match() {
let doc = Document::new(vec![Row::from("fn test( {}")], PathBuf::from("test.txt"));
assert_eq!(
Navigator::find_matching_closing_symbol(
&doc,
&Position {
x: 7,
y: 0,
x_offset: 0
},
&Position {
x: 0,
y: 0,
x_offset: 0
},
),
None
);
} | rust_cleaned_test_functions.jsonl/52828 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 314
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21814,
70763,
666,
17831,
21179,
6536,
10708,
368,
341,
262,
1077,
4629,
284,
11789,
486,
931,
25592,
20703,
3102,
486,
1499,
445,
8822,
1273,
7,
4687,
899,
1125,
7933,
15064,
486,
1499,
445,
1944... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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.