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_opcode_from() {
let hlt = 0x00;
let mov = 0x01;
let igl = 0xf7;
let hltopcode = Opcode::from(hlt);
let movopcode = Opcode::from(mov);
let iglopcode = Opcode::from(igl);
assert_eq!(hltopcode, Opcode::Hlt);
assert_eq!(movopcode, Opcode::Mov);
assert_eq!(iglopcode, Opcode::Igl);
} | rust_cleaned_test_functions.jsonl/91955 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 207
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
71319,
5673,
368,
341,
286,
1077,
305,
4832,
284,
220,
15,
87,
15,
15,
280,
286,
1077,
1974,
284,
220,
15,
87,
15,
16,
280,
286,
1077,
19373,
75,
284,
220,
15,
5848,
22,
401,
286,
1077,
49... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_tcgetattr_enotty() {
let file = tempfile().unwrap();
assert_eq!(termios::tcgetattr(file.as_raw_fd()).err(),
Some(Errno::ENOTTY));
} | rust_cleaned_test_functions.jsonl/103386 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 90
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
63126,
81732,
6205,
57639,
368,
341,
262,
1077,
1034,
284,
54819,
1005,
15454,
543,
262,
2060,
10714,
10297,
4991,
3530,
486,
10413,
81732,
4866,
5357,
16067,
17676,
6011,
615,
3148,
2290,
4329,
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 |
#[test]
fn test_established_rst_bad_seq() {
let mut s = socket_established();
send!(s, TcpRepr {
control: TcpControl::Rst,
seq_number: REMOTE_SEQ, // Wrong seq
ack_number: None,
..SEND_TEMPL
}, Ok(Some(TcpRepr {
seq_number: LOCAL_SEQ + 1,
ack_number: Some(REMOTE_SEQ + 1),
..RECV_TEMPL
})));
assert_eq!(s.state, State::Established);
// Send something to advance seq by 1
send!(s, TcpRepr {
seq_number: REMOTE_SEQ + 1, // correct seq
ack_number: Some(LOCAL_SEQ + 1),
payload: &b"a"[..],
..SEND_TEMPL
});
// The ack number must be updated even if we don't call dispatch on the socket
// See https://github.com/smoltcp-rs/smoltcp/issues/338
send!(s, TcpRepr {
control: TcpControl::Rst,
seq_number: REMOTE_SEQ, // Wrong seq
ack_number: None,
..SEND_TEMPL
}, Ok(Some(TcpRepr {
seq_number: LOCAL_SEQ + 1,
ack_number: Some(REMOTE_SEQ + 2), // this has changed
window_len: 63,
..RECV_TEMPL
})));
} | rust_cleaned_test_functions.jsonl/91852 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 695
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18583,
5102,
291,
1710,
267,
34199,
14486,
368,
341,
286,
1077,
5206,
274,
284,
7575,
18583,
5102,
291,
543,
286,
3624,
10297,
82,
11,
64876,
693,
649,
341,
310,
2524,
25,
64876,
3273,
486,
49,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parse_kv() {
assert_eq!(
Object::parse("OBJET Féminin TEJBO").unwrap(),
("", JoseType::Object((Gender::Feminine, HashMap::new()).into())),
);
assert_eq!(
Object::parse("OBJET Masculin
— « Écoles ouvertes » : Faux ;
— « départements confinés » :
DÉBUT « Seine-Maritime » FIN.
TEJBO").unwrap(),
("", JoseType::Object((Gender::Masculine, vec![
(Cow::from(" départements confinés "), (JoseType::from(vec![" Seine-Maritime ".into()]), true)),
(Cow::from(" Écoles ouvertes "), (JoseType::from(false), false)),
].into_iter().collect()).into())),
);
} | rust_cleaned_test_functions.jsonl/10773 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 355
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
97066,
368,
341,
286,
2060,
10714,
33673,
310,
3002,
486,
6400,
445,
53449,
1348,
88150,
1065,
258,
18289,
41,
4677,
1827,
15454,
3148,
310,
3489,
497,
10860,
929,
486,
1190,
1188,
28914,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_get_joining_group() {
assert_eq!(get_joining_group('a'), JoiningGroup::NoJoiningGroup);
assert_eq!(get_joining_group('.'), JoiningGroup::NoJoiningGroup);
assert_eq!(get_joining_group('カ'), JoiningGroup::NoJoiningGroup);
assert_eq!(get_joining_group('🦳'), JoiningGroup::NoJoiningGroup);
assert_eq!(get_joining_group('ھ'), JoiningGroup::KnottedHeh);
assert_eq!(get_joining_group('𐫍'), JoiningGroup::ManichaeanHeth);
assert_eq!(get_joining_group('د'), JoiningGroup::Dal);
assert_eq!(get_joining_group('𞥋'), JoiningGroup::NoJoiningGroup);
assert_eq!(get_joining_group('ـ'), JoiningGroup::NoJoiningGroup);
} | rust_cleaned_test_functions.jsonl/82507 | {
"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,
3062,
31017,
287,
6288,
368,
341,
286,
2060,
10714,
10297,
455,
31017,
287,
6288,
492,
64,
4567,
16471,
287,
2808,
486,
2753,
12292,
287,
2808,
317,
286,
2060,
10714,
10297,
455,
31017,
287,
6288,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_idle_timeout() {
let mut pool = mocked!();
pool.set_idle_timeout(Some(Duration::from_millis(10)));
let mut stream = pool.connect("127.0.0.1", 3000, "http").unwrap();
assert_eq!(stream.get_ref().id, 0);
stream.get_mut().id = 1337;
drop(stream);
::std::thread::sleep(Duration::from_millis(100));
let stream = pool.connect("127.0.0.1", 3000, "http").unwrap();
assert_eq!(stream.get_ref().id, 0);
} | rust_cleaned_test_functions.jsonl/53082 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 233
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
47810,
20537,
368,
341,
286,
1077,
5206,
7314,
284,
46149,
0,
543,
286,
7314,
980,
47810,
20537,
65405,
64114,
486,
1499,
717,
56212,
7,
16,
15,
4945,
286,
1077,
5206,
4269,
284,
7314,
10800,
44... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_resolve_module_1() {
let (_temp_dir, deno_dir) = test_setup();
let test_cases = [
(
"./subdir/print_hello.ts",
add_root!(
"/Users/rld/go/src/github.com/denoland/deno/testdata/006_url_imports.ts"
),
add_root!(
"/Users/rld/go/src/github.com/denoland/deno/testdata/subdir/print_hello.ts"
),
add_root!(
"/Users/rld/go/src/github.com/denoland/deno/testdata/subdir/print_hello.ts"
),
),
(
"testdata/001_hello.js",
add_root!("/Users/rld/go/src/github.com/denoland/deno/"),
add_root!("/Users/rld/go/src/github.com/denoland/deno/testdata/001_hello.js"),
add_root!("/Users/rld/go/src/github.com/denoland/deno/testdata/001_hello.js"),
),
(
add_root!("/Users/rld/src/deno/hello.js"),
".",
add_root!("/Users/rld/src/deno/hello.js"),
add_root!("/Users/rld/src/deno/hello.js"),
),
(
add_root!("/this/module/got/imported.js"),
add_root!("/that/module/did/it.js"),
add_root!("/this/module/got/imported.js"),
add_root!("/this/module/got/imported.js"),
),
];
for &test in test_cases.iter() {
let module_specifier = String::from(test.0);
let containing_file = String::from(test.1);
let (module_name, filename) = deno_dir
.resolve_module(&module_specifier, &containing_file)
.unwrap();
assert_eq!(module_name, test.2);
assert_eq!(filename, test.3);
}
} | rust_cleaned_test_functions.jsonl/42044 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 721
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
77291,
10750,
62,
16,
368,
341,
220,
1077,
5453,
3888,
4334,
11,
3371,
78,
4334,
8,
284,
1273,
21363,
1428,
220,
1077,
1273,
41427,
284,
2278,
262,
2399,
414,
5924,
1966,
3741,
92221,
96724,
212... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_eq() {
let mut d = RingBuf::new();
assert!(d == RingBuf::with_capacity(0));
d.push_front(137);
d.push_front(17);
d.push_front(42);
d.push_back(137);
let mut e = RingBuf::with_capacity(0);
e.push_back(42);
e.push_back(17);
e.push_back(137);
e.push_back(137);
assert!(&e == &d);
e.pop_back();
e.push_back(0);
assert!(e != d);
e.clear();
assert!(e == RingBuf::new());
} | rust_cleaned_test_functions.jsonl/125103 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 305
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10714,
368,
341,
286,
1077,
5206,
294,
284,
21525,
15064,
486,
931,
543,
286,
2060,
10297,
67,
621,
21525,
15064,
486,
4197,
35603,
7,
15,
1106,
286,
294,
2552,
22926,
7,
16,
18,
22,
317,
286,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_next_tabstop_remaining_mode_none() {
assert_eq!(next_tabstop(&[1, 5], 0, &RemainingMode::None), 1);
assert_eq!(next_tabstop(&[1, 5], 3, &RemainingMode::None), 2);
assert_eq!(next_tabstop(&[1, 5], 6, &RemainingMode::None), 1);
} | rust_cleaned_test_functions.jsonl/54567 | {
"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,
11257,
17344,
9495,
59244,
7302,
31488,
368,
341,
286,
2060,
10714,
10297,
3600,
17344,
9495,
2099,
58,
16,
11,
220,
20,
1125,
220,
15,
11,
609,
54745,
3636,
486,
4064,
701,
220,
16,
317,
286,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_that_generated_file_are_up_to_date_in_git() {
// Better not run the `stdlib` tool when the repository is not in a clean state.
assert_that_version_control_has_no_unstaged_changes();
assert!(Command::new("cargo")
.current_dir("../")
.arg("run")
.arg("-p")
.arg("starcoin-genesis")
.status()
.unwrap()
.success());
// Running the stdlib tool should not create unstaged changes.
assert_that_version_control_has_no_unstaged_changes();
} | rust_cleaned_test_functions.jsonl/65498 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 227
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
70197,
67313,
2458,
56855,
8237,
2346,
4164,
1243,
68801,
368,
341,
262,
442,
23434,
537,
1598,
279,
1565,
13149,
63,
5392,
979,
279,
12542,
374,
537,
304,
264,
4240,
1584,
624,
262,
2060,
70197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ping() {
let mut test = new_test();
test.handler.event = "ping".to_string();
let resp = test.handler.handle_event().unwrap();
assert_eq!((StatusCode::OK, "ping".into()), resp);
} | rust_cleaned_test_functions.jsonl/89628 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 88
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
71661,
368,
341,
262,
1077,
5206,
1273,
284,
501,
4452,
543,
262,
1273,
31171,
5773,
284,
330,
9989,
3263,
983,
3904,
1428,
262,
1077,
9039,
284,
1273,
31171,
10132,
6748,
1005,
15454,
543,
262,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_event_handling() {
let mut event_manager = EventManager::new().unwrap();
let mut net = Net::default_net(TestMutators::default());
let mem_clone = net.mem.clone();
let (rxq, txq) = Net::virtqueues(&mem_clone);
net.assign_queues(rxq.create_queue(), txq.create_queue());
let daddr = 0x2000;
assert!(daddr > txq.end().0);
{
assert_eq!(net.rx_bytes_read, 0);
// Let's imagine we received some data.
net.rx_bytes_read = MAX_BUFFER_SIZE;
{
// a read only descriptor
rxq.avail.ring[0].set(0);
rxq.avail.idx.set(1);
rxq.dtable[0].set(daddr, 0x1000, 0, 0);
assert!(!net.rx_single_frame_no_irq_coalescing());
assert_eq!(rxq.used.idx.get(), 1);
// resetting values
rxq.used.idx.set(0);
net.queues[RX_INDEX] = rxq.create_queue();
net.interrupt_evt.write(1).unwrap();
assert_eq!(net.interrupt_evt.read().unwrap(), 2);
}
{
rxq.dtable[0].flags.set(VIRTQ_DESC_F_WRITE);
check_metric_after_block!(
&METRICS.net.rx_fails,
1,
assert!(!net.rx_single_frame_no_irq_coalescing())
);
assert_eq!(rxq.used.idx.get(), 1);
rxq.used.idx.set(0);
net.queues[RX_INDEX] = rxq.create_queue();
net.interrupt_evt.write(1).unwrap();
assert_eq!(net.interrupt_evt.read().unwrap(), 2);
}
// set rx_count back to 0
net.rx_bytes_read = 0;
}
// Now let's move on to the actual device events.
{
// testing TX_QUEUE_EVENT
txq.avail.idx.set(1);
txq.avail.ring[0].set(0);
txq.dtable[0].set(daddr, 0x1000, 0, 0);
net.queue_evts[TX_INDEX].write(1).unwrap();
let event = EpollEvent::new(EventSet::IN, net.queue_evts[TX_INDEX].as_raw_fd() as u64);
net.process(&event, &mut event_manager);
// Make sure the data queue advanced.
assert_eq!(txq.used.idx.get(), 1);
}
{
// testing RX_TAP_EVENT
assert!(!net.rx_deferred_frame);
// this should work just fine
rxq.avail.idx.set(1);
rxq.avail.ring[0].set(0);
rxq.dtable[0].set(daddr, 0x1000, VIRTQ_DESC_F_WRITE, 0);
net.interrupt_evt.write(1).unwrap();
let tap_event = EpollEvent::new(EventSet::IN, net.tap.as_raw_fd() as u64);
net.process(&tap_event, &mut event_manager);
assert!(net.rx_deferred_frame);
assert_eq!(net.interrupt_evt.read().unwrap(), 3);
assert_eq!(rxq.used.ring[0].get().len, 1234);
// a different execution path.
// reset some parts of the queue first
net.queues[RX_INDEX] = rxq.create_queue();
rxq.used.idx.set(0);
// this should also be successful
net.interrupt_evt.write(1).unwrap();
net.process(&tap_event, &mut event_manager);
assert!(net.rx_deferred_frame);
assert_eq!(net.interrupt_evt.read().unwrap(), 2);
// we can fit inside a single descriptor
net.rx_bytes_read = MAX_BUFFER_SIZE;
net.queues[RX_INDEX] = rxq.create_queue();
rxq.used.idx.set(0);
net.interrupt_evt.write(1).unwrap();
check_metric_after_block!(
&METRICS.net.rx_fails,
1,
net.process(&tap_event, &mut event_manager)
);
assert!(net.rx_deferred_frame);
assert_eq!(net.interrupt_evt.read().unwrap(), 2);
// A mismatch shows the reception was unsuccessful.
assert_ne!(rxq.used.ring[0].get().len as usize, net.rx_bytes_read);
net.rx_bytes_read = 1234;
}
{
// now also try an RX_QUEUE_EVENT
rxq.avail.idx.set(2);
rxq.avail.ring[1].set(1);
rxq.dtable[1].set(daddr + 0x1000, 0x1000, VIRTQ_DESC_F_WRITE, 0);
net.queue_evts[RX_INDEX].write(1).unwrap();
net.interrupt_evt.write(1).unwrap();
let rx_event =
EpollEvent::new(EventSet::IN, net.queue_evts[RX_INDEX].as_raw_fd() as u64);
check_metric_after_block!(
&METRICS.net.rx_count,
2,
net.process(&rx_event, &mut event_manager)
);
assert_eq!(net.interrupt_evt.read().unwrap(), 2);
}
{
let test_mutators = TestMutators {
tap_read_fail: true,
};
let mut net = Net::default_net(test_mutators);
check_metric_after_block!(&METRICS.net.rx_fails, 1, net.process_rx());
}
} | rust_cleaned_test_functions.jsonl/63423 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 3018
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6748,
75642,
368,
341,
286,
1077,
5206,
1538,
12144,
284,
3665,
2043,
486,
931,
1005,
15454,
543,
286,
1077,
5206,
4179,
284,
9374,
486,
2258,
19722,
31159,
51440,
2973,
486,
2258,
1423,
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_next_bar() {
let mut mfi = MoneyFlowIndex::new(3).unwrap();
// tp = 2.0
let bar1 = Bar::new().high(3).low(1).close(2).volume(500.0);
assert_eq!(mfi.next(&bar1), 50.0);
let bar2 = Bar::new().high(2.3).low(2.0).close(2.3).volume(1000.0);
assert_eq!(mfi.next(&bar2), 100.0);
let bar3 = Bar::new().high(9).low(7).close(8).volume(200.0);
assert_eq!(mfi.next(&bar3), 100.0);
let bar4 = Bar::new().high(5).low(3).close(4).volume(500.0);
assert_eq!(mfi.next(&bar4), 3800.0 / 5800.0 * 100.0);
let bar5 = Bar::new().high(4).low(2).close(3).volume(5000.0);
assert_eq!(mfi.next(&bar5), 1600.0 / 18600.0 * 100.0);
let bar6 = Bar::new().high(2).low(1).close(1.5).volume(6000.0);
assert_eq!(mfi.next(&bar6), 0.0 / 23800.0 * 100.0);
let bar7 = Bar::new().high(2).low(2).close(2).volume(7000.0);
assert_eq!(mfi.next(&bar7), 14000.0 / 38000.0 * 100.0);
} | rust_cleaned_test_functions.jsonl/73624 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 577
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11257,
14388,
368,
341,
286,
1077,
5206,
296,
9983,
284,
17633,
18878,
1552,
486,
931,
7,
18,
568,
15454,
1428,
286,
442,
18101,
284,
220,
17,
13,
15,
198,
286,
1077,
3619,
16,
284,
4716,
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_fasttext_get_sentence_vector() {
let mut fasttext = FastText::default();
fasttext
.load_model("tests/fixtures/cooking.model.bin")
.unwrap();
let v = fasttext.get_sentence_vector("banana").unwrap();
assert!(fasttext.get_dimension() == v.len() as isize);
assert!(v[0] != 0f32);
// And it doesn't contain "hello".
assert!(fasttext.get_sentence_vector("hello").unwrap()[0] == 0f32);
} | rust_cleaned_test_functions.jsonl/118636 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 237
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
35743,
1318,
3062,
48332,
12247,
368,
341,
286,
1077,
5206,
4937,
1318,
284,
17288,
1178,
486,
2258,
543,
286,
4937,
1318,
198,
310,
659,
1078,
5047,
445,
23841,
94275,
64942,
10746,
3192,
29394,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_table_sort_columns() {
let mut tab = Table::default();
tab.columns.push((
"a".to_string(),
ColumnInfo {
ordinal: 2,
..Default::default()
},
));
tab.columns.push((
"b".to_string(),
ColumnInfo {
ordinal: 3,
..Default::default()
},
));
tab.columns.push((
"c".to_string(),
ColumnInfo {
ordinal: 1,
..Default::default()
},
));
tab.columns.push((
"d".to_string(),
ColumnInfo {
ordinal: 0,
..Default::default()
},
));
tab.sort_columns_by_ordinal();
println!("columns: {:?}", tab.columns);
} | rust_cleaned_test_functions.jsonl/79220 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 538
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5237,
18435,
22590,
368,
341,
286,
1077,
5206,
5651,
284,
6633,
486,
2258,
543,
286,
5651,
21153,
2552,
94702,
310,
330,
64,
3263,
983,
3904,
3148,
310,
9332,
1731,
341,
394,
67948,
25,
220,
17,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_update_spec_devices() {
let (major, minor) = (7, 2);
let mut spec = Spec::default();
// vm_path empty
let update = DevNumUpdate::from_vm_path("");
assert!(update.is_err());
// linux is empty
let container_path = "/dev/null";
let vm_path = "/dev/null";
let res = update_spec_devices(
&mut spec,
HashMap::from_iter(vec![(
container_path,
DevNumUpdate::from_vm_path(vm_path).unwrap().into(),
)]),
);
assert!(res.is_err());
spec.linux = Some(Linux::default());
// linux.devices doesn't contain the updated device
let res = update_spec_devices(
&mut spec,
HashMap::from_iter(vec![(
container_path,
DevNumUpdate::from_vm_path(vm_path).unwrap().into(),
)]),
);
assert!(res.is_err());
spec.linux.as_mut().unwrap().devices = vec![oci::LinuxDevice {
path: "/dev/null2".to_string(),
major,
minor,
..oci::LinuxDevice::default()
}];
// guest and host path are not the same
let res = update_spec_devices(
&mut spec,
HashMap::from_iter(vec![(
container_path,
DevNumUpdate::from_vm_path(vm_path).unwrap().into(),
)]),
);
assert!(
res.is_err(),
"container_path={:?} vm_path={:?} spec={:?}",
container_path,
vm_path,
spec
);
spec.linux.as_mut().unwrap().devices[0].path = container_path.to_string();
let res = update_spec_devices(
&mut spec,
HashMap::from_iter(vec![(
container_path,
DevNumUpdate::from_vm_path(vm_path).unwrap().into(),
)]),
);
assert!(res.is_ok());
// update both devices and cgroup lists
spec.linux.as_mut().unwrap().devices = vec![oci::LinuxDevice {
path: container_path.to_string(),
major,
minor,
..oci::LinuxDevice::default()
}];
spec.linux.as_mut().unwrap().resources = Some(oci::LinuxResources {
devices: vec![oci::LinuxDeviceCgroup {
major: Some(major),
minor: Some(minor),
..oci::LinuxDeviceCgroup::default()
}],
..oci::LinuxResources::default()
});
let res = update_spec_devices(
&mut spec,
HashMap::from_iter(vec![(
container_path,
DevNumUpdate::from_vm_path(vm_path).unwrap().into(),
)]),
);
assert!(res.is_ok());
} | rust_cleaned_test_functions.jsonl/66435 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1513
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8882,
13594,
41334,
368,
341,
286,
1077,
320,
36505,
11,
8922,
8,
284,
320,
22,
11,
220,
17,
317,
286,
1077,
5206,
1398,
284,
10956,
486,
2258,
1428,
286,
442,
10995,
2638,
4287,
198,
286,
107... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_convert_var_assignment() {
let b = ast::BaseNode::default();
let pkg = ast::Package {
base: b.clone(),
path: "path".to_string(),
package: "main".to_string(),
files: vec![ast::File {
base: b.clone(),
name: "foo.flux".to_string(),
metadata: String::new(),
package: None,
imports: Vec::new(),
body: vec![
ast::Statement::Variable(Box::new(ast::VariableAssgn {
base: b.clone(),
id: ast::Identifier {
base: b.clone(),
name: "a".to_string(),
},
init: ast::Expression::Boolean(ast::BooleanLit {
base: b.clone(),
value: true,
}),
})),
ast::Statement::Expr(Box::new(ast::ExprStmt {
base: b.clone(),
expression: ast::Expression::Identifier(ast::Identifier {
base: b.clone(),
name: "a".to_string(),
}),
})),
],
eof: None,
}],
};
let want = Package {
loc: b.location.clone(),
package: "main".to_string(),
files: vec![File {
loc: b.location.clone(),
package: None,
imports: Vec::new(),
body: vec![
Statement::Variable(Box::new(VariableAssgn::new(
Identifier {
loc: b.location.clone(),
name: "a".to_string(),
},
Expression::Boolean(BooleanLit {
loc: b.location.clone(),
value: true,
}),
b.location.clone(),
))),
Statement::Expr(ExprStmt {
loc: b.location.clone(),
expression: Expression::Identifier(IdentifierExpr {
loc: b.location.clone(),
typ: type_info(),
name: "a".to_string(),
}),
}),
],
}],
};
let got = test_convert(pkg).unwrap();
assert_eq!(want, got);
} | rust_cleaned_test_functions.jsonl/30439 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1743
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34910,
4612,
51891,
368,
341,
286,
1077,
293,
284,
11763,
486,
3978,
1955,
486,
2258,
543,
286,
1077,
24793,
284,
11763,
486,
13100,
341,
310,
2331,
25,
293,
15997,
3148,
310,
1815,
25,
330,
234... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_set_bits_raw() {
const NUM_BYTE: usize = 64;
const NUM_BLOCKS: usize = 12;
const MAX_BLOCK_SIZE: usize = 32;
let mut buf = vec![0; NUM_BYTE];
let mut expected = Vec::with_capacity(NUM_BYTE * 8);
expected.resize(NUM_BYTE * 8, false);
let mut rng = thread_rng();
for _ in 0..NUM_BLOCKS {
let start = rng.gen_range(0, NUM_BYTE * 8 - MAX_BLOCK_SIZE);
let end = start + rng.gen_range(1, MAX_BLOCK_SIZE);
unsafe {
set_bits_raw(buf.as_mut_ptr(), start, end);
}
for i in start..end {
expected[i] = true;
}
}
let raw_ptr = buf.as_ptr();
for (i, b) in expected.iter().enumerate() {
unsafe {
assert_eq!(*b, get_bit_raw(raw_ptr, i));
}
}
} | rust_cleaned_test_functions.jsonl/37931 | {
"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,
2602,
20034,
16067,
368,
341,
286,
733,
15943,
27349,
25,
22301,
284,
220,
21,
19,
280,
286,
733,
15943,
86542,
25,
22301,
284,
220,
16,
17,
280,
286,
733,
8334,
18756,
4098,
25,
22301,
284,
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... | 4 |
#[test]
fn test_compute_merkle_root_inbalanced() {
let transactions = vec![
TransactionBuilder::new().with_version(1).build(),
TransactionBuilder::new().with_version(2).build(),
TransactionBuilder::new().with_version(3).build(),
TransactionBuilder::new().with_version(4).build(),
TransactionBuilder::new().with_version(5).build(),
];
Transaction::tx_id.mock_safe(|tx| {
let txid = match tx.version {
1 => H256Le::from_hex_be(
"a335b243f5e343049fccac2cf4d70578ad705831940d3eef48360b0ea3829ed4",
),
2 => H256Le::from_hex_be(
"d5fd11cb1fabd91c75733f4cf8ff2f91e4c0d7afa4fd132f792eacb3ef56a46c",
),
3 => H256Le::from_hex_be(
"0441cb66ef0cbf78c9ecb3d5a7d0acf878bfdefae8a77541b3519a54df51e7fd",
),
4 => H256Le::from_hex_be(
"1a8a27d690889b28d6cb4dacec41e354c62f40d85a7f4b2d7a54ffc736c6ff35",
),
5 => H256Le::from_hex_be(
"1d543d550676f82bf8bf5b0cc410b16fc6fc353b2a4fd9a0d6a2312ed7338701",
),
_ => panic!("should not happen"),
};
MockResult::Return(txid)
});
let mut builder = BlockBuilder::new();
for tx in transactions {
builder.add_transaction(tx);
}
let merkle_root = builder.compute_merkle_root().unwrap();
let expected =
H256Le::from_hex_be("5766798857e436d6243b46b5c1e0af5b6806aa9c2320b3ffd4ecff7b31fd4647");
assert_eq!(merkle_root, expected);
} | rust_cleaned_test_functions.jsonl/90677 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1023
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
57028,
717,
16754,
273,
12993,
1243,
58402,
368,
341,
1789,
286,
1077,
14131,
284,
7486,
90515,
310,
17869,
3297,
486,
931,
1005,
4197,
9438,
7,
16,
568,
5834,
3148,
310,
17869,
3297,
486,
931,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_encrypt_decrypt_default() {
let (public, private) = gen_keys_default();
let m = "my super secret";
let encrypted = public.encrypt(m.clone());
let decrypted = private.decrypt(&*encrypted);
assert_eq!(m, &*decrypted);
} | rust_cleaned_test_functions.jsonl/67150 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 125
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
66593,
80764,
9993,
368,
341,
286,
1077,
320,
888,
11,
869,
8,
284,
4081,
12631,
9993,
543,
286,
1077,
296,
284,
330,
2408,
2256,
6234,
876,
286,
1077,
24455,
284,
584,
65326,
1255,
15997,
1423,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_frame_allocator_alloc_and_free() {
let mut frame = FrameAllocator::new();
assert!(frame.alloc(1).is_none());
frame.add_frame(0, 1024);
for _ in 0..100 {
let addr = frame.alloc(512).unwrap();
frame.dealloc(addr, 512);
}
} | rust_cleaned_test_functions.jsonl/99756 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 127
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8929,
56910,
14802,
8378,
8905,
368,
341,
262,
1077,
5206,
4034,
284,
16321,
42730,
486,
931,
543,
262,
2060,
10297,
6763,
78224,
7,
16,
568,
285,
31488,
5231,
262,
4034,
1364,
8929,
7,
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... | 2 |
#[test]
fn test_keywords_in_function() {
check(
r"fn quux() { $0 }",
expect![[r#"
kw unsafe
kw fn
kw const
kw type
kw use
kw impl
kw trait
kw static
kw extern
kw mod
kw match
kw while
kw while let
kw loop
kw if
kw if let
kw for
kw let
kw return
"#]],
);
} | rust_cleaned_test_functions.jsonl/72500 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 466
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
51354,
1243,
9174,
368,
341,
286,
1779,
1006,
310,
435,
1,
8822,
922,
2200,
368,
314,
400,
15,
335,
756,
310,
1720,
0,
15505,
81,
2,
698,
394,
29525,
19860,
198,
394,
29525,
5168,
198,
394,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_append_u32_large_vector() {
let mut appender = VectorU32Appender::try_new(4096).unwrap();
let vector_size = 100000;
for _ in 0..10 {
appender.append_nulls(9999).unwrap();
appender.append(2).unwrap();
}
assert_eq!(appender.num_elements(), vector_size);
let finished_vec = appender.finish(vector_size).unwrap();
let reader = VectorReader::<u32>::try_new(&finished_vec[..]).unwrap();
assert_eq!(reader.num_elements(), vector_size as usize);
} | rust_cleaned_test_functions.jsonl/25240 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 264
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26041,
7300,
18,
17,
45228,
12247,
368,
341,
1789,
286,
1077,
5206,
906,
1659,
284,
4196,
52,
18,
17,
2164,
1659,
486,
1539,
5921,
7,
19,
15,
24,
21,
568,
15454,
543,
286,
1077,
4621,
2368,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_parse_uuid_v4_valid() {
let from_hyphenated =
Uuid::parse_str("67e55044-10b1-426f-9247-bb680e5fe0c8").unwrap();
let from_simple =
Uuid::parse_str("67e5504410b1426f9247bb680e5fe0c8").unwrap();
let from_urn =
Uuid::parse_str("urn:uuid:67e55044-10b1-426f-9247-bb680e5fe0c8")
.unwrap();
let from_guid =
Uuid::parse_str("{67e55044-10b1-426f-9247-bb680e5fe0c8}").unwrap();
assert_eq!(from_hyphenated, from_simple);
assert_eq!(from_hyphenated, from_urn);
assert_eq!(from_hyphenated, from_guid);
assert!(Uuid::parse_str("00000000000000000000000000000000").is_ok());
assert!(Uuid::parse_str("67e55044-10b1-426f-9247-bb680e5fe0c8").is_ok());
assert!(Uuid::parse_str("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4").is_ok());
assert!(Uuid::parse_str("67e5504410b1426f9247bb680e5fe0c8").is_ok());
assert!(Uuid::parse_str("01020304-1112-2122-3132-414243444546").is_ok());
assert!(Uuid::parse_str(
"urn:uuid:67e55044-10b1-426f-9247-bb680e5fe0c8"
)
.is_ok());
assert!(
Uuid::parse_str("{6d93bade-bd9f-4e13-8914-9474e1e3567b}").is_ok()
);
// Nil
let nil = Uuid::nil();
assert_eq!(
Uuid::parse_str("00000000000000000000000000000000").unwrap(),
nil
);
assert_eq!(
Uuid::parse_str("00000000-0000-0000-0000-000000000000").unwrap(),
nil
);
} | rust_cleaned_test_functions.jsonl/114738 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 869
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
25540,
2273,
19,
8337,
368,
341,
286,
1077,
504,
1523,
88,
14769,
657,
4035,
310,
547,
2423,
486,
6400,
2895,
445,
21,
22,
68,
20,
20,
15,
19,
19,
12,
16,
15,
65,
16,
12,
19,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_parse_traffic_model() {
assert_eq!(TrafficModel::BestGuess, "best_guess".parse().unwrap());
assert_eq!(TrafficModel::Optimistic, "optimistic".parse().unwrap());
assert_eq!(TrafficModel::Pessimistic, "pessimistic".parse().unwrap());
assert!("unknown".parse::<TrafficModel>().is_err());
} | rust_cleaned_test_functions.jsonl/75493 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 145
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21039,
90012,
5047,
368,
341,
286,
2060,
10714,
10297,
87229,
1712,
486,
14470,
45730,
11,
330,
15862,
54737,
3263,
6400,
1005,
15454,
1423,
286,
2060,
10714,
10297,
87229,
1712,
486,
21367,
318,
45... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_match() {
let value = TestEnum::A;
#[remain::sorted]
match value {
TestEnum::A => {}
TestEnum::B => {}
#[unsorted]
TestEnum::Ignored => {}
TestEnum::C => {}
_ => {}
}
} | rust_cleaned_test_functions.jsonl/34468 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 141
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
10708,
368,
341,
262,
1077,
897,
284,
3393,
10766,
486,
32,
401,
262,
11506,
47584,
486,
28298,
921,
262,
2432,
897,
341,
286,
3393,
10766,
486,
32,
589,
5613,
286,
3393,
10766,
486,
33,
589,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_rpc_get_signature_status() {
let bob_pubkey = Pubkey::new_rand();
let RpcHandler {
io,
meta,
blockhash,
alice,
..
} = start_rpc_handler_with_tx(&bob_pubkey);
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"getSignatureStatus","params":["{}"]}}"#,
tx.signatures[0]
);
let res = io.handle_request_sync(&req, meta.clone());
let expected_res: Option<transaction::Result<()>> = Some(Ok(()));
let expected = json!({
"jsonrpc": "2.0",
"result": expected_res,
"id": 1
});
let expected: Response =
serde_json::from_value(expected).expect("expected response deserialization");
let result: Response = serde_json::from_str(&res.expect("actual response"))
.expect("actual response deserialization");
assert_eq!(expected, result);
// Test getSignatureStatus request on unprocessed tx
let tx = system_transaction::transfer(&alice, &bob_pubkey, 10, blockhash);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"getSignatureStatus","params":["{}"]}}"#,
tx.signatures[0]
);
let res = io.handle_request_sync(&req, meta.clone());
let expected_res: Option<String> = None;
let expected = json!({
"jsonrpc": "2.0",
"result": expected_res,
"id": 1
});
let expected: Response =
serde_json::from_value(expected).expect("expected response deserialization");
let result: Response = serde_json::from_str(&res.expect("actual response"))
.expect("actual response deserialization");
assert_eq!(expected, result);
// Test getSignatureStatus request on a TransactionError
let tx = system_transaction::transfer(&alice, &bob_pubkey, std::u64::MAX, blockhash);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"getSignatureStatus","params":["{}"]}}"#,
tx.signatures[0]
);
let res = io.handle_request_sync(&req, meta);
let expected_res: Option<transaction::Result<()>> = Some(Err(
TransactionError::InstructionError(0, InstructionError::Custom(1)),
));
let expected = json!({
"jsonrpc": "2.0",
"result": expected_res,
"id": 1
});
let expected: Response =
serde_json::from_value(expected).expect("expected response deserialization");
let result: Response = serde_json::from_str(&res.expect("actual response"))
.expect("actual response deserialization");
assert_eq!(expected, result);
} | rust_cleaned_test_functions.jsonl/14437 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1335
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
60799,
3062,
39859,
4773,
368,
341,
286,
1077,
35192,
34014,
792,
284,
22611,
792,
486,
931,
33864,
543,
286,
1077,
79961,
3050,
341,
310,
6399,
345,
310,
8823,
345,
310,
2504,
8296,
345,
310,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_iterator_min() {
let v: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
assert_eq!(v[..4].iter().cloned().min(), Some(0));
assert_eq!(v.iter().cloned().min(), Some(0));
assert_eq!(v[..0].iter().cloned().min(), None);
assert_eq!(v.iter().cloned().map(Mod3).min().map(|x| x.0), Some(0));
} | rust_cleaned_test_functions.jsonl/54120 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 162
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13491,
7260,
368,
341,
262,
1077,
348,
25,
609,
13496,
60,
284,
44590,
15,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11,
220,
21,
11,
220,
22,
11,
220,
23,
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_volume() {
let (sink, mut queue_rx) = Sink::new_idle();
let v = vec![10i16, -10, 20, -20, 30, -30];
// High rate to avoid immediate control.
sink.append(SamplesBuffer::new(2, 44100, v.clone()));
let src = SamplesBuffer::new(2, 44100, v.clone()).convert_samples();
let mut src = src.amplify(0.5);
sink.set_volume(0.5);
for _ in 0..v.len() {
assert_eq!(queue_rx.next(), src.next());
}
} | rust_cleaned_test_functions.jsonl/24069 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 251
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26941,
368,
341,
286,
1077,
320,
66738,
11,
5206,
7177,
24330,
8,
284,
56451,
486,
931,
47810,
1428,
286,
1077,
348,
284,
7486,
20703,
16,
15,
72,
16,
21,
11,
481,
16,
15,
11,
220,
17,
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... | 2 |
#[test]
fn test_parse() {
let file = File::open("samples/sample.rs").expect("cannot open sample file");
let resp = parse(file, String::from("samples/sample.rs"));
assert_eq!(
resp,
vec![Annotation::Todo(Comment {
line: 1,
file: String::from("samples/sample.rs"),
details: r"to delete, definitively because it's a non-sense".to_owned(),
assignee: Some(String::from("bnjjj")),
})]
)
} | rust_cleaned_test_functions.jsonl/102159 | {
"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,
21039,
368,
341,
286,
1077,
1034,
284,
2887,
486,
2508,
445,
41118,
69851,
25638,
1827,
17119,
445,
33260,
1787,
6077,
1034,
3071,
286,
1077,
9039,
284,
4715,
4866,
11,
923,
486,
1499,
445,
41118,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_rotate1() {
assert_eq!(rotate1(2), 2);
assert_eq!(rotate1(3), 3);
assert_eq!(rotate1(5), 5);
assert_eq!(rotate1(7), 7);
assert_eq!(rotate1(11), 11);
assert_eq!(rotate1(13), 31);
assert_eq!(rotate1(13432), 34321);
assert_eq!(rotate1(10), 1);
assert_eq!(rotate1(10000), 1);
} | rust_cleaned_test_functions.jsonl/46996 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 176
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
60834,
16,
368,
341,
262,
2060,
10714,
10297,
16213,
16,
7,
17,
701,
220,
17,
317,
262,
2060,
10714,
10297,
16213,
16,
7,
18,
701,
220,
18,
317,
262,
2060,
10714,
10297,
16213,
16,
7,
20,
70... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_load_graph() {
let mut params_bytes = Vec::new();
fs::File::open(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/graph.params"))
.expect("Could not find TVM graph. Did you run `tests/build_model.py`?")
.read_to_end(&mut params_bytes)
.unwrap();
let _params = tvm_runtime::load_param_dict(¶ms_bytes);
let graph = Graph::try_from(
&fs::read_to_string(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/graph.json")).unwrap(),
)
.unwrap();
assert_eq!(graph.nodes[3].op, "tvm_op");
assert_eq!(
graph.nodes[3]
.attrs
.as_ref()
.unwrap()
.get("func_name")
.unwrap(),
"fuse_dense"
);
assert_eq!(graph.nodes[5].inputs[0].index, 0);
assert_eq!(graph.nodes[6].inputs[0].index, 1);
assert_eq!(graph.heads.len(), 2);
} | rust_cleaned_test_functions.jsonl/129301 | {
"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,
12411,
14738,
368,
341,
262,
1077,
5206,
3628,
12524,
284,
11312,
486,
931,
543,
262,
8619,
486,
1703,
486,
2508,
96360,
10297,
3160,
17223,
34,
7581,
46,
25143,
91120,
8291,
3975,
3521,
23841,
72... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_chacha_construction() {
let seed = [0,0,0,0,0,0,0,0,
1,0,0,0,0,0,0,0,
2,0,0,0,0,0,0,0,
3,0,0,0,0,0,0,0];
let mut rng1 = ChaChaRng::from_seed(seed);
assert_eq!(rng1.next_u32(), 137206642);
let mut rng2 = ChaChaRng::from_rng(rng1).unwrap();
assert_eq!(rng2.next_u32(), 1325750369);
} | rust_cleaned_test_functions.jsonl/112998 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 249
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4138,
51576,
3382,
3024,
368,
341,
286,
1077,
10320,
284,
508,
15,
11,
15,
11,
15,
11,
15,
11,
15,
11,
15,
11,
15,
11,
15,
345,
310,
220,
16,
11,
15,
11,
15,
11,
15,
11,
15,
11,
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_refs() {
let key = Keypair::new();
let key1 = solana_sdk::pubkey::new_rand();
let key2 = solana_sdk::pubkey::new_rand();
let prog1 = solana_sdk::pubkey::new_rand();
let prog2 = solana_sdk::pubkey::new_rand();
let instructions = vec![
CompiledInstruction::new(3, &(), vec![0, 1]),
CompiledInstruction::new(4, &(), vec![0, 2]),
];
let tx = Transaction::new_with_compiled_instructions(
&[&key],
&[key1, key2],
Hash::default(),
vec![prog1, prog2],
instructions,
);
assert!(tx.sanitize().is_ok());
assert_eq!(tx.key(0, 0), Some(&key.pubkey()));
assert_eq!(tx.signer_key(0, 0), Some(&key.pubkey()));
assert_eq!(tx.key(1, 0), Some(&key.pubkey()));
assert_eq!(tx.signer_key(1, 0), Some(&key.pubkey()));
assert_eq!(tx.key(0, 1), Some(&key1));
assert_eq!(tx.signer_key(0, 1), None);
assert_eq!(tx.key(1, 1), Some(&key2));
assert_eq!(tx.signer_key(1, 1), None);
assert_eq!(tx.key(2, 0), None);
assert_eq!(tx.signer_key(2, 0), None);
assert_eq!(tx.key(0, 2), None);
assert_eq!(tx.signer_key(0, 2), None);
assert_eq!(*get_program_id(&tx, 0), prog1);
assert_eq!(*get_program_id(&tx, 1), prog2);
} | rust_cleaned_test_functions.jsonl/11230 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 741
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
60638,
368,
341,
286,
1077,
1376,
284,
6569,
1082,
1310,
486,
931,
543,
286,
1077,
1376,
16,
284,
2048,
3362,
61783,
486,
9585,
792,
486,
931,
33864,
543,
286,
1077,
1376,
17,
284,
2048,
3362,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_config_serialization_params_serialize() {
let mut cfg: UserConfig = UserConfig::default();
let toml_file: tempfile::NamedTempFile = tempfile::NamedTempFile::new().ok().unwrap();
// Insert key
cfg.remote.ssh_keys.insert(
String::from("192.168.1.31"),
PathBuf::from("/home/omar/.ssh/id_rsa"),
);
// Serialize
let writer: Box<dyn Write> = Box::new(std::fs::File::create(toml_file.path()).unwrap());
assert!(serialize(&cfg, writer).is_ok());
// Reload configuration and check if it's ok
toml_file.as_file().sync_all().unwrap();
toml_file.as_file().seek(SeekFrom::Start(0)).unwrap();
assert!(deserialize::<UserConfig>(Box::new(toml_file)).is_ok());
} | rust_cleaned_test_functions.jsonl/16002 | {
"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,
5332,
25602,
2022,
6745,
88686,
368,
341,
286,
1077,
5206,
13286,
25,
2657,
2648,
284,
2657,
2648,
486,
2258,
543,
286,
1077,
311,
1014,
2458,
25,
54819,
486,
15810,
12151,
1703,
284,
54819,
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_pop_mut() {
let mut git_url =
GitUrl::parse("git@github.com:user/foo/bar/quux.git").expect("parse failed");
assert_eq!(git_url.host, "git@github.com");
assert_eq!(git_url.path, "user/foo/bar/quux.git");
assert_eq!(git_url.to_string(), "git@github.com:user/foo/bar/quux.git");
assert!(git_url.pop_mut());
assert_eq!(git_url.host, "git@github.com");
assert_eq!(git_url.path, "user/foo/bar");
assert_eq!(git_url.to_string(), "git@github.com:user/foo/bar");
assert!(git_url.pop_mut());
assert_eq!(git_url.host, "git@github.com");
assert_eq!(git_url.path, "user/foo");
assert_eq!(git_url.to_string(), "git@github.com:user/foo");
assert!(git_url.pop_mut());
assert_eq!(git_url.host, "git@github.com");
assert_eq!(git_url.path, "user");
assert_eq!(git_url.to_string(), "git@github.com:user");
assert!(git_url.pop_mut());
assert_eq!(git_url.host, "git@github.com");
assert_eq!(git_url.path, "");
assert_eq!(git_url.to_string(), "git@github.com");
assert!(!git_url.pop_mut());
assert_eq!(git_url.host, "git@github.com");
assert_eq!(git_url.path, "");
assert_eq!(git_url.to_string(), "git@github.com");
} | rust_cleaned_test_functions.jsonl/12183 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 666
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17061,
29523,
368,
341,
286,
1077,
5206,
16345,
2903,
4035,
310,
21120,
2864,
486,
6400,
445,
12882,
31,
5204,
905,
64280,
60555,
49513,
78845,
2200,
32799,
1827,
17119,
445,
6400,
4641,
3071,
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_gzipped() -> Result<(), Box<dyn std::error::Error>> {
let mut tmp_dir = env::temp_dir();
tmp_dir.push("rpm-builder-test-gzipped");
fs::create_dir_all(&tmp_dir)?;
let mut out_file = tmp_dir.clone();
out_file.push("test.rpm");
let work_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let mut cargo_toml = work_dir.clone();
cargo_toml.push("Cargo.toml");
let mut rpm_builder_path = work_dir.clone();
rpm_builder_path.push("target/debug/rpm-builder");
Command::new(rpm_builder_path)
.args(vec![
"--exec-file",
"target/debug/rpm-builder:/usr/bin/rpm-builder",
"--doc-file",
&format!("{}:/foo/bar", &cargo_toml.to_string_lossy()),
"--config-file",
&format!("{}:/bar/bazz", &cargo_toml.to_string_lossy()),
"--version",
"1.0.0",
"--dir",
&format!("{}/tests/test_assets:/src", &work_dir.to_string_lossy()),
"--compression",
"gzip",
"rpm-builder",
"-o",
&out_file.to_string_lossy(),
"--pre-install-script",
&format!(
"{}/tests/test_assets/preinst.sh",
&work_dir.to_string_lossy()
),
])
.output()
.expect("failed to execute process");
std::fs::remove_dir_all(tmp_dir)?;
Ok(())
} | rust_cleaned_test_functions.jsonl/134562 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 754
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1889,
89,
6450,
368,
1464,
5714,
68843,
8261,
92846,
1460,
486,
841,
486,
1454,
2452,
341,
262,
1077,
5206,
4174,
4334,
284,
6105,
486,
3888,
4334,
543,
262,
4174,
4334,
2552,
445,
73782,
71814,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_fmt() -> Result<(), builder::BuildError> {
let reference_sequence = ReferenceSequence::builder()
.set_name("sq0")
.set_length(13)
.set_md5_checksum(Md5Checksum::from([
0xd7, 0xeb, 0xa3, 0x11, 0x42, 0x1b, 0xbc, 0x9d, 0x3a, 0xda, 0x44, 0x70, 0x9d, 0xd6,
0x15, 0x34,
]))
.build()?;
assert_eq!(
reference_sequence.to_string(),
"@SQ\tSN:sq0\tLN:13\tM5:d7eba311421bbc9d3ada44709dd61534"
);
Ok(())
} | rust_cleaned_test_functions.jsonl/23395 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 355
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
38128,
368,
1464,
5714,
68843,
7363,
486,
11066,
1454,
29,
341,
286,
1077,
5785,
23735,
284,
17207,
14076,
486,
17850,
741,
310,
659,
746,
1269,
445,
28343,
15,
1138,
310,
659,
746,
5118,
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... | 2 |
#[test]
fn test_edge_cases_be() {
use bitstream_io::{BigEndian, BitRead, BitReader};
let data: Vec<u8> = vec![
0, 0, 0, 0, 255, 255, 255, 255, 128, 0, 0, 0, 127, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0,
255, 255, 255, 255, 255, 255, 255, 255, 128, 0, 0, 0, 0, 0, 0, 0, 127, 255, 255, 255, 255,
255, 255, 255,
];
/*0 bit reads*/
let mut r = BitReader::endian(Cursor::new(vec![255]), BigEndian);
assert_eq!(r.read::<u8>(0).unwrap(), 0);
assert_eq!(r.read::<u16>(0).unwrap(), 0);
assert_eq!(r.read::<u32>(0).unwrap(), 0);
assert_eq!(r.read::<u64>(0).unwrap(), 0);
assert_eq!(r.read::<u8>(8).unwrap(), 255);
/*unsigned 32 and 64-bit values*/
let mut r = BitReader::endian(Cursor::new(&data), BigEndian);
assert_eq!(r.read::<u32>(32).unwrap(), 0);
assert_eq!(r.read::<u32>(32).unwrap(), 4294967295);
assert_eq!(r.read::<u32>(32).unwrap(), 2147483648);
assert_eq!(r.read::<u32>(32).unwrap(), 2147483647);
assert_eq!(r.read::<u64>(64).unwrap(), 0);
assert_eq!(r.read::<u64>(64).unwrap(), 0xFFFFFFFFFFFFFFFF);
assert_eq!(r.read::<u64>(64).unwrap(), 9223372036854775808);
assert_eq!(r.read::<u64>(64).unwrap(), 9223372036854775807);
/*signed 32 and 64-bit values*/
let mut r = BitReader::endian(Cursor::new(&data), BigEndian);
assert_eq!(r.read::<i32>(32).unwrap(), 0);
assert_eq!(r.read::<i32>(32).unwrap(), -1);
assert_eq!(r.read::<i32>(32).unwrap(), -2147483648);
assert_eq!(r.read::<i32>(32).unwrap(), 2147483647);
assert_eq!(r.read::<i64>(64).unwrap(), 0);
assert_eq!(r.read::<i64>(64).unwrap(), -1);
assert_eq!(r.read::<i64>(64).unwrap(), -9223372036854775808);
assert_eq!(r.read::<i64>(64).unwrap(), 9223372036854775807);
} | rust_cleaned_test_functions.jsonl/65117 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 862
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17932,
41427,
21263,
368,
341,
262,
990,
2699,
4027,
16939,
22964,
15636,
43231,
11,
6495,
4418,
11,
6495,
5062,
2315,
262,
1077,
821,
25,
11312,
34837,
23,
29,
284,
7486,
90515,
286,
220,
15,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_qs() {
let qs = "a=1&b=2&c=3&c=4&key_without_value&=value_without_key".to_string();
for s in [
qs.as_str(),
("https://abc.com/?".to_string() + qs.as_str()).as_str(),
("https://abc.com/?????".to_string() + qs.as_str()).as_str(),
]
.iter()
{
let q = UrlEncodedData::parse_str(s);
println!("got qs: {}", q);
let pairs_expected_as_str = [
("a", "1"),
("b", "2"),
("c", "3"),
("c", "4"),
("key_without_value", ""),
("", "value_without_key"),
];
for (k, v) in q.as_pairs().iter().map(|(k, v)| (k.as_ref(), v.as_ref())) {
assert!(pairs_expected_as_str.contains(&(k, v)));
}
for (i, (k, v)) in q.as_pairs_of_original_order().iter().enumerate() {
let (k_, v_) = pairs_expected_as_str[i];
assert_eq!(k.as_ref(), k_);
assert_eq!(v.as_ref(), v_);
}
let map_of_multiple_values_expected = hashmap! {
"a"=>vec!("1"),
"b"=>vec!("2"),
"c"=>vec!("3", "4"),
"key_without_value" => vec!(""),
"" => vec!("value_without_key"),
};
dbg!("as_map_of_single_key_to_multiple_values");
println!("as_map_of_single_key_to_multiple_values");
let map = q.as_map_of_single_key_to_multiple_values();
assert_eq!(map.len(), 5);
for (k1, v1) in map {
let v2 = map_of_multiple_values_expected.get(k1.as_ref()).unwrap();
for (i, v2i) in v2.iter().enumerate() {
assert_eq!(v1[i].as_ref(), *v2i);
}
}
let map_of_first_occurrence_value_expected = hashmap! {
"a"=>"1",
"b"=>"2",
"c"=>"3",
"key_without_value" => "",
"" => "value_without_key",
};
dbg!("as_map_of_single_key_to_first_occurrence_value");
let map = q.as_map_of_single_key_to_first_occurrence_value();
assert_eq!(map.len(), 5);
for (k1, v1) in map {
let v2 = map_of_first_occurrence_value_expected
.get(k1.as_ref())
.unwrap();
assert_eq!(&v1, v2);
let ptr1 = v1 as *const Cow<'_, str> as *const usize;
let ptr2 = v2 as *const &str as *const usize;
let msg = format!("{:p}, {:p}", ptr1, ptr2);
dbg!(msg);
println!("{:p}, {:p}", ptr1, ptr2);
assert!(!std::ptr::eq(ptr1, ptr2));
assert_eq!(*v1, **v2);
}
let map_of_last_occurrence_value_expected = hashmap! {
"a"=>"1",
"b"=>"2",
"c"=>"4",
"key_without_value" => "",
"" => "value_without_key",
};
dbg!("as_map_of_single_key_to_last_occurrence_value");
let map = q.as_map_of_single_key_to_last_occurrence_value();
assert_eq!(map.len(), 5);
for (k1, v1) in map {
let v2 = map_of_last_occurrence_value_expected
.get(k1.as_ref())
.unwrap();
assert_eq!(&v1, v2);
}
}
} | rust_cleaned_test_functions.jsonl/70296 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2266
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
80738,
368,
341,
286,
1077,
32421,
284,
330,
64,
28,
16,
5,
65,
28,
17,
5,
66,
28,
18,
5,
66,
28,
19,
5,
792,
39904,
3142,
5,
28,
957,
39904,
3097,
3263,
983,
3904,
543,
286,
369,
274,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_on_files() {
use std::io::Read;
use std::hash::Hasher;
std::fs::create_dir_all("examples/data").unwrap();
let file_in = "examples/data/smallpop.csv";
let file_out = "examples/data/smallpop_out.csv";
#[cfg(not(feature = "tokio"))]
async_std::task::block_on(async {
if let Err(err) = create_async(file_in).await {
assert!(false, "error running create_async: {}", err);
}
if let Err(err) = copy_async(file_in, file_out).await {
assert!(false, "error running copy_async: {}", err);
}
});
#[cfg(feature = "tokio")]
tokio::runtime::Runtime::new().unwrap().block_on(async {
if let Err(err) = create_async(file_in).await {
assert!(false, "error running create_async: {}", err);
}
if let Err(err) = copy_async(file_in, file_out).await {
assert!(false, "error running copy_async: {}", err);
}
});
let mut bytes_in = vec![];
std::fs::File::open(file_in).unwrap().read_to_end(&mut bytes_in).unwrap();
let mut hasher_in = std::collections::hash_map::DefaultHasher::new();
hasher_in.write(&bytes_in);
let mut bytes_out = vec![];
std::fs::File::open(file_out).unwrap().read_to_end(&mut bytes_out).unwrap();
let mut hasher_out = std::collections::hash_map::DefaultHasher::new();
hasher_out.write(&bytes_out);
assert_eq!(hasher_in.finish(), hasher_out.finish(), "Copied file {} is different than source {}", file_out, file_in);
std::fs::remove_file(file_in).unwrap();
std::fs::remove_file(file_out).unwrap();
} | rust_cleaned_test_functions.jsonl/31629 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 878
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
4470,
10931,
368,
341,
286,
990,
1460,
486,
815,
486,
4418,
280,
286,
990,
1460,
486,
8296,
486,
6370,
261,
280,
286,
1460,
486,
3848,
486,
3182,
4334,
5705,
445,
51668,
13167,
1827,
15454,
543,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
#[test]
fn test_raw_tokenizer() {
let factory = RawTokenizerFactory::new();
let tokenizer = factory.create();
let mut stream = tokenizer.token_stream("hello");
{
let token = stream.next().unwrap();
assert_eq!(token.text, "hello");
assert_eq!(token.offset_from, 0);
assert_eq!(token.offset_to, 5);
}
assert!(stream.next().is_none());
} | rust_cleaned_test_functions.jsonl/117031 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 213
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16067,
6458,
3135,
368,
341,
286,
1077,
8633,
284,
23022,
37434,
4153,
486,
931,
543,
286,
1077,
45958,
284,
8633,
2520,
1428,
286,
1077,
5206,
4269,
284,
45958,
14416,
12673,
445,
14990,
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_build_log() {
let (dir, img_path) = gen_fat32img();
let disk = Arc::new(FileDisk::new(img_path));
task::spawn(0, async move {
let disk_root = Chan::attach(disk, b"").await.unwrap();
let fs = Arc::new(FAT::new(50, 100, &disk_root).await.unwrap());
println!("fs: {:?}", fs);
let root = Chan::attach(fs.clone(), b"").await.unwrap();
let src_dir = root.open(b"src", None).await.unwrap().unwrap();
src_dir.close().await;
root.close().await;
disk_root.close().await;
let fs = Arc::try_unwrap(fs).unwrap();
fs.shutdown().unwrap().await;
})
.unwrap();
task::run_all();
drop(dir);
} | rust_cleaned_test_functions.jsonl/130728 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 408
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20801,
5224,
368,
341,
286,
1077,
320,
3741,
11,
4964,
2638,
8,
284,
4081,
761,
266,
18,
17,
1892,
543,
286,
1077,
13364,
284,
19689,
486,
931,
19821,
47583,
486,
931,
11022,
2638,
3237,
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_look_at() {
let rot = Matrix2::look_at(V, Vector2::unit_y());
assert_eq!(rot * Vector2::unit_x(),
V.normalize());
let new_up = Vector2::new(-V.y, V.x).normalize();
assert_eq!(rot * Vector2::unit_y(),
new_up);
let rot_down = Matrix2::look_at(V, -1.0 * Vector2::unit_y());
assert_eq!(rot_down * Vector2::unit_x(),
V.normalize());
assert_eq!(rot_down * Vector2::unit_y(),
-1.0 * new_up);
let rot2 = Matrix2::look_at(-V, Vector2::unit_y());
assert_eq!(rot2 * Vector2::unit_x(),
(-V).normalize());
} | rust_cleaned_test_functions.jsonl/105437 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 390
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
24271,
3752,
368,
341,
1789,
286,
1077,
5749,
284,
11631,
17,
486,
7201,
3752,
12410,
11,
4196,
17,
486,
3843,
4178,
1423,
286,
2060,
10714,
10297,
4640,
353,
4196,
17,
486,
3843,
3212,
3148,
42... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_vtable_index_and_len() {
ok_with_test("class A {}", |ctxt| {
let cls_id = ctxt.cls_by_name("A");
let cls = ctxt.classes[cls_id].borrow();
assert_eq!(cls.vtable_len, 0);
});
ok_with_test("open class A { open fun f() {} }", |ctxt| {
let cls_id = ctxt.cls_by_name("A");
let cls = ctxt.classes[cls_id].borrow();
assert_eq!(cls.vtable_len, 1);
});
ok_with_test(
"open class A { open fun f() {} }
open class B: A { override fun f() {}
open fun g() {} }",
|ctxt| {
let cls_id = ctxt.cls_by_name("A");
let cls = ctxt.classes[cls_id].borrow();
assert_eq!(cls.vtable_len, 1);
let cls_id = ctxt.cls_by_name("B");
let cls = ctxt.classes[cls_id].borrow();
assert_eq!(cls.vtable_len, 2);
},
);
} | rust_cleaned_test_functions.jsonl/75956 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 624
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2273,
2005,
3560,
8378,
6043,
368,
341,
286,
5394,
6615,
4452,
445,
1040,
362,
24689,
760,
77492,
91,
341,
310,
1077,
12790,
842,
284,
59162,
89052,
3710,
1269,
445,
32,
797,
310,
1077,
12790,
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_add() {
let mut program = Program{
code: vec![1, 2, 0],
ip: 0,
move_ip: true,
rel_base: 0,
param_indices: vec![0, 1, 2],
finish: false
};
// Positive add
add(&mut program);
assert_eq!(program.code, vec![1, 2, 3]);
// Partial negative add
program.code = vec![-3, 2, 0];
add(&mut program);
assert_eq!(program.code, vec![-3, 2, -1]);
// Negative add
program.code = vec![-3, -2, 0];
add(&mut program);
assert_eq!(program.code, vec![-3, -2, -5]);
} | rust_cleaned_test_functions.jsonl/52444 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 362
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
368,
341,
286,
1077,
5206,
2025,
284,
6687,
515,
310,
2038,
25,
7486,
20703,
16,
11,
220,
17,
11,
220,
15,
1259,
310,
5997,
25,
220,
15,
345,
310,
3271,
10385,
25,
830,
345,
310,
1351,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_bcs_serialize_with_noise_and_deserialize() {
let value = "\u{10348}.".to_string();
let samples = Runtime::Bcs.serialize_with_noise_and_deserialize(&value);
// 1 for original encoding
// 1 for added incorrect 5-byte UTF8-like codepoint
assert_eq!(samples.len(), value.len() + 3);
} | rust_cleaned_test_functions.jsonl/46329 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 135
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
880,
4837,
88686,
6615,
40313,
8378,
15768,
9050,
368,
341,
262,
1077,
897,
284,
2917,
84,
90,
16,
15,
18,
19,
23,
92,
36911,
983,
3904,
543,
262,
1077,
10469,
284,
10954,
486,
33,
4837,
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 |
#[test]
fn test_get_snapshot_storages_only_roots() {
let db = AccountsDb::new(Vec::new(), &ClusterType::Development);
let key = Pubkey::default();
let account = AccountSharedData::new(1, 0, &key);
let base_slot = 0;
let after_slot = base_slot + 1;
db.store_uncached(base_slot, &[(&key, &account)]);
assert!(db.get_snapshot_storages(after_slot, None).0.is_empty());
db.add_root(base_slot);
assert_eq!(1, db.get_snapshot_storages(after_slot, None).0.len());
} | rust_cleaned_test_functions.jsonl/1387 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 252
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
53265,
1261,
269,
1134,
18410,
26608,
2412,
368,
341,
286,
1077,
2927,
284,
40655,
7994,
486,
931,
49923,
486,
931,
1507,
609,
28678,
929,
486,
39419,
626,
286,
1077,
1376,
284,
22611,
792,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_doc_delete() {
let shared_cat = create_test_catalog("test_index".into());
let handler = IndexHandler::new(Arc::clone(&shared_cat));
let mut terms = HashMap::new();
terms.insert("test_text".to_string(), "document".to_string());
let delete = DeleteDoc {
options: Some(IndexOptions { commit: true }),
terms,
};
let req = handler.delete(delete, "test_index".into());
assert_eq!(req.is_ok(), true);
assert_eq!(req.unwrap().docs_affected, 3);
} | rust_cleaned_test_functions.jsonl/96420 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 248
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18869,
11353,
368,
341,
286,
1077,
6094,
20825,
284,
1855,
4452,
47310,
445,
1944,
3560,
3263,
18122,
1423,
286,
1077,
7013,
284,
8008,
3050,
486,
931,
4346,
1287,
486,
19982,
2099,
6100,
20825,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_same_node() {
let node1 = div();
assert!(node1.is_same_node(&node1));
assert!(!node1.is_same_node(&div()));
} | rust_cleaned_test_functions.jsonl/33770 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 87
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6892,
33574,
5084,
368,
341,
286,
1077,
2436,
16,
284,
3429,
543,
286,
2060,
10297,
3509,
16,
2079,
33574,
5084,
2099,
3509,
16,
1106,
286,
2060,
0,
3471,
3509,
16,
2079,
33574,
5084,
2099,
611,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_sphr11(){
let coord = SphericalPolarCoordinate{r: 1.0,
theta: 0.7853981633974483, phi: 1.0471975511965976}; / assert!(is_very_close(sphr_harm(&coord, 1, 1),
0.1727470747356678));
assert!(is_very_close(sphr_harm(&coord, 1, -1),
0.2992067103010745));
} | rust_cleaned_test_functions.jsonl/104260 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 304
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
643,
759,
81,
16,
16,
19328,
286,
1077,
16489,
284,
328,
44745,
47,
7417,
28589,
90,
81,
25,
220,
16,
13,
15,
11,
715,
15429,
18526,
25,
220,
15,
13,
22,
23,
20,
18,
24,
23,
16,
21,
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_accounts_db_purge_keep_live() {
solana_logger::setup();
let some_lamport = 223;
let zero_lamport = 0;
let no_data = 0;
let owner = *AccountSharedData::default().owner();
let account = AccountSharedData::new(some_lamport, no_data, &owner);
let pubkey = solana_sdk::pubkey::new_rand();
let account2 = AccountSharedData::new(some_lamport, no_data, &owner);
let pubkey2 = solana_sdk::pubkey::new_rand();
let zero_lamport_account = AccountSharedData::new(zero_lamport, no_data, &owner);
let accounts = AccountsDb::new_single_for_tests();
accounts.add_root(0);
// Step A
let mut current_slot = 1;
accounts.store_uncached(current_slot, &[(&pubkey, &account)]);
// Store another live account to slot 1 which will prevent any purge
// since the store count will not be zero
accounts.store_uncached(current_slot, &[(&pubkey2, &account2)]);
accounts.add_root(current_slot);
let (slot1, account_info1) = accounts
.accounts_index
.get(&pubkey, None, None)
.map(|(account_list1, index1)| account_list1.slot_list()[index1])
.unwrap();
let (slot2, account_info2) = accounts
.accounts_index
.get(&pubkey2, None, None)
.map(|(account_list2, index2)| account_list2.slot_list()[index2])
.unwrap();
assert_eq!(slot1, current_slot);
assert_eq!(slot1, slot2);
assert_eq!(account_info1.store_id, account_info2.store_id);
// Step B
current_slot += 1;
let zero_lamport_slot = current_slot;
accounts.store_uncached(current_slot, &[(&pubkey, &zero_lamport_account)]);
accounts.add_root(current_slot);
assert_load_account(&accounts, current_slot, pubkey, zero_lamport);
current_slot += 1;
accounts.add_root(current_slot);
accounts.print_accounts_stats("pre_purge");
accounts.clean_accounts(None, false, None);
accounts.print_accounts_stats("post_purge");
let (slot_list_len, index_slot) = {
let account_entry = accounts
.accounts_index
.get_account_read_entry(&pubkey)
.unwrap();
let slot_list = account_entry.slot_list();
(slot_list.len(), slot_list[0].0)
};
assert_eq!(slot_list_len, 1);
// Zero lamport entry was not the one purged
assert_eq!(index_slot, zero_lamport_slot);
// The ref count should still be 2 because no slots were purged
assert_eq!(accounts.ref_count_for_pubkey(&pubkey), 2);
// was reclaimed
check_storage(&accounts, 1, 1);
check_storage(&accounts, 2, 1);
} | rust_cleaned_test_functions.jsonl/6973 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1326
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
55665,
8685,
620,
39823,
50293,
55203,
368,
341,
286,
2048,
3362,
27413,
486,
15188,
543,
286,
1077,
1045,
907,
309,
403,
284,
220,
17,
17,
18,
280,
286,
1077,
7168,
907,
309,
403,
284,
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... | 1 |
#[test]
fn test_encode_date_time() {
let mut buf = Vec::new();
let date1: NaiveDateTime = "2010-10-17T19:27:30.000001".parse().unwrap();
Encode::<MySql>::encode(&date1, &mut buf);
assert_eq!(*buf, [11, 218, 7, 10, 17, 19, 27, 30, 1, 0, 0, 0]);
buf.clear();
let date2: NaiveDateTime = "2010-10-17T19:27:30".parse().unwrap();
Encode::<MySql>::encode(&date2, &mut buf);
assert_eq!(*buf, [7, 218, 7, 10, 17, 19, 27, 30]);
buf.clear();
let date3: NaiveDateTime = "2010-10-17T00:00:00".parse().unwrap();
Encode::<MySql>::encode(&date3, &mut buf);
assert_eq!(*buf, [4, 218, 7, 10, 17]);
} | rust_cleaned_test_functions.jsonl/18496 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 308
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11224,
4164,
3009,
368,
341,
262,
1077,
5206,
6607,
284,
11312,
486,
931,
1428,
1066,
262,
1077,
2400,
16,
25,
12812,
533,
7689,
284,
330,
17,
15,
16,
15,
12,
16,
15,
12,
16,
22,
51,
16,
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_show() {
let mut e = EnumSet::new();
assert!(format!("{:?}", e) == "EnumSet {}");
e.insert(A);
assert!(format!("{:?}", e) == "EnumSet {A}");
e.insert(C);
assert!(format!("{:?}", e) == "EnumSet {A, C}");
} | rust_cleaned_test_functions.jsonl/51097 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 158
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15267,
368,
341,
286,
1077,
5206,
384,
284,
14086,
1649,
486,
931,
543,
286,
2060,
10297,
2243,
88928,
25,
52652,
384,
8,
621,
330,
10766,
1649,
4687,
797,
286,
384,
7030,
4346,
317,
286,
2060,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_compile_shift_right_wrap_d() {
let compiled = bitwise::compile_shift_right_wrap("D".to_string());
assert_eq!(compiled.len(), 1);
assert_eq!(compiled[0], 0b01110111);
} | rust_cleaned_test_functions.jsonl/100623 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 90
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
74170,
22230,
10539,
38550,
814,
368,
341,
262,
1077,
19697,
284,
97970,
486,
20433,
22230,
10539,
38550,
445,
35,
3263,
983,
3904,
5231,
262,
2060,
10714,
10297,
50845,
19406,
1507,
220,
16,
317,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_credit_request_from_peer() {
let mut ctx = CsmTestContext::new_established();
ctx.init_pkt(uapi::VSOCK_OP_CREDIT_REQUEST, 0);
ctx.send();
assert!(ctx.conn.has_pending_rx());
ctx.recv();
assert_eq!(ctx.pkt.op(), uapi::VSOCK_OP_CREDIT_UPDATE);
assert_eq!(ctx.pkt.buf_alloc(), csm_defs::CONN_TX_BUF_SIZE as u32);
assert_eq!(ctx.pkt.fwd_cnt(), ctx.conn.fwd_cnt.0);
} | rust_cleaned_test_functions.jsonl/83292 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 242
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
51569,
7893,
5673,
45159,
368,
341,
286,
1077,
5206,
5635,
284,
356,
3563,
2271,
1972,
486,
931,
18583,
5102,
291,
543,
286,
5635,
8271,
42051,
8154,
2068,
486,
53,
13880,
3021,
13908,
920,
56463,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_account_resource() {
let (_env, op_tool, _, storage) = launch_swarm_with_op_tool_and_backend(1, 0);
// Fetch the owner account resource
let owner_account = storage.get::<AccountAddress>(OWNER_ACCOUNT).unwrap().value;
let account_resource = op_tool.account_resource(owner_account).unwrap();
assert_eq!(owner_account, account_resource.account);
assert_eq!(0, account_resource.sequence_number);
// Fetch the operator account resource
let operator_account = storage
.get::<AccountAddress>(OPERATOR_ACCOUNT)
.unwrap()
.value;
let account_resource = op_tool.account_resource(operator_account).unwrap();
assert_eq!(operator_account, account_resource.account);
assert_eq!(0, account_resource.sequence_number);
// Verify operator key
let on_chain_operator_key = hex::decode(account_resource.authentication_key).unwrap();
let operator_key = storage.get_public_key(OPERATOR_KEY).unwrap().public_key;
assert_eq!(
AuthenticationKey::ed25519(&operator_key),
AuthenticationKey::try_from(on_chain_operator_key).unwrap()
);
} | rust_cleaned_test_functions.jsonl/64954 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 412
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13500,
17962,
368,
341,
262,
1077,
5453,
3160,
11,
1179,
22785,
11,
8358,
5819,
8,
284,
7050,
32581,
2178,
6615,
10287,
22785,
8378,
40011,
7,
16,
11,
220,
15,
626,
262,
442,
22104,
279,
6372,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_withdraw_ix_bad_recent_blockhash_state_fail() {
let nonce_address = Pubkey::new_unique();
let pubkey = Pubkey::new_unique();
#[allow(deprecated)]
let blockhash_id = sysvar::recent_blockhashes::id();
process_instruction(
&serialize(&SystemInstruction::WithdrawNonceAccount(42)).unwrap(),
vec![
(nonce_address, create_default_account()),
(pubkey, create_default_account()),
(blockhash_id, create_default_account()),
],
vec![
AccountMeta {
pubkey: nonce_address,
is_signer: true,
is_writable: true,
},
AccountMeta {
pubkey,
is_signer: false,
is_writable: false,
},
AccountMeta {
pubkey: blockhash_id,
is_signer: false,
is_writable: false,
},
],
Err(InstructionError::InvalidArgument),
);
} | rust_cleaned_test_functions.jsonl/106219 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 683
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11305,
6615,
7633,
62686,
34199,
62361,
7113,
8296,
4387,
22121,
368,
341,
286,
1077,
39676,
6744,
284,
22611,
792,
486,
931,
21218,
543,
286,
1077,
95116,
284,
22611,
792,
486,
931,
21218,
543,
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_create_rev_reg_def() {
init!("ledger");
let data = r#"["address1","address2","zip","city","state"]"#.to_string();
let (schema_id, _) = ::utils::libindy::anoncreds::tests::create_and_write_test_schema(::utils::constants::DEFAULT_SCHEMA_ATTRS);
let (_, schema_json) = get_schema_json(&schema_id).unwrap();
let did = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap();
let revocation_details = json!({"support_revocation": true, "tails_file": get_temp_dir_path(Some("tails.txt")).to_str().unwrap(), "max_creds": 2}).to_string();
let (id, payment) = create_cred_def(&did, &schema_json, "tag_1", None, Some(true)).unwrap();
create_rev_reg_def(&did, &id, "tails.txt", 2).unwrap();
} | rust_cleaned_test_functions.jsonl/86998 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 341
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8657,
38082,
4920,
7844,
368,
341,
286,
2930,
17223,
50704,
3071,
286,
1077,
821,
284,
435,
55543,
1183,
4995,
16,
2198,
4995,
17,
2198,
9964,
2198,
8926,
2198,
2454,
1341,
57676,
13,
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_dad_duplicate_address_detected_advertisement() {
// Tests whether a duplicate address will get detected by advertisement
// then the second node comes up and it should be able to find out that
// it cannot use the address because someone else has already taken that
// address.
set_logger_for_test();
let mut local = DummyEventDispatcherBuilder::default();
local.add_device(TEST_LOCAL_MAC);
let mut remote = DummyEventDispatcherBuilder::default();
remote.add_device(TEST_REMOTE_MAC);
let device_id = DeviceId::new_ethernet(0);
let mut stack_builder = StackStateBuilder::default();
let mut ndp_configs = crate::device::ndp::NdpConfigurations::default();
ndp_configs.set_max_router_solicitations(None);
stack_builder.device_builder().set_default_ndp_configs(ndp_configs);
// We explicitly call `build_with` when building our contexts below because `build` will
// set the default NDP parameter DUP_ADDR_DETECT_TRANSMITS to 0 (effectively disabling
// DAD) so we use our own custom `StackStateBuilder` to set it to the default value
let mut net = DummyNetwork::new(
vec![
("local", local.build_with(stack_builder.clone(), DummyEventDispatcher::default())),
("remote", remote.build_with(stack_builder, DummyEventDispatcher::default())),
]
.into_iter(),
|ctx, dev| {
if *ctx == "local" {
("remote", device_id, None)
} else {
("local", device_id, None)
}
},
);
println!("Setting new IP on local");
let addr = AddrSubnet::new(local_ip(), 128).unwrap();
let multicast_addr = local_ip().to_solicited_node_address();
set_ip_addr_subnet(net.context("local"), device_id, addr);
// Only local should be in the solicited node multicast group.
assert!(is_in_ip_multicast(net.context("local"), device_id, multicast_addr));
assert!(!is_in_ip_multicast(net.context("remote"), device_id, multicast_addr));
assert!(testutil::trigger_next_timer(net.context("local")));
let local_addr =
EthernetNdpDevice::get_ipv6_addr(net.context("local").state_mut(), device_id.id())
.unwrap();
assert!(!local_addr.is_tentative());
assert_eq!(local_ip(), local_addr.into_inner());
println!("Set new IP on remote");
set_ip_addr_subnet(net.context("remote"), device_id, addr);
assert!(is_in_ip_multicast(net.context("local"), device_id, multicast_addr));
assert!(is_in_ip_multicast(net.context("remote"), device_id, multicast_addr));
net.step();
let remote_addr = get_ip_addr_subnet::<_, Ipv6Addr>(net.context("remote"), device_id);
assert!(remote_addr.is_none());
// let's make sure that our local node still can use that address
let local_addr =
EthernetNdpDevice::get_ipv6_addr(net.context("local").state_mut(), device_id.id())
.unwrap();
assert!(!local_addr.is_tentative());
assert_eq!(local_ip(), local_addr.into_inner());
// Only local should be in the solicited node multicast group.
assert!(is_in_ip_multicast(net.context("local"), device_id, multicast_addr));
assert!(!is_in_ip_multicast(net.context("remote"), device_id, multicast_addr));
} | rust_cleaned_test_functions.jsonl/16137 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1536
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
814,
329,
70434,
6744,
98876,
10027,
44424,
368,
341,
286,
442,
20150,
3425,
264,
22513,
2621,
686,
633,
16507,
553,
32689,
8945,
286,
442,
1221,
279,
2086,
2436,
4041,
705,
323,
432,
1265,
387,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_field_from_bytes_string()
{
let id = "Hello";
let value = "World";
let field = Field::new(id, Type::S(Some(S::new(value))));
assert_eq!(Field::from_bytes(&test_string_data).unwrap(), field);
} | rust_cleaned_test_functions.jsonl/41983 | {
"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,
5013,
5673,
12524,
3904,
741,
262,
341,
286,
1077,
877,
284,
330,
9707,
876,
286,
1077,
897,
284,
330,
10134,
876,
286,
1077,
2070,
284,
8601,
486,
931,
3724,
11,
3990,
486,
50,
65405,
3759,
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_guess_git_blame_filename_extension() {
use ProcessArgs::Args;
fn make_string_vec(args: &[&str]) -> Vec<String> {
args.iter().map(|&x| x.to_owned()).collect::<Vec<String>>()
}
let args = make_string_vec(&["git", "blame", "hello", "world.txt"]);
assert_eq!(
guess_git_blame_filename_extension(&args),
Args("txt".into())
);
let args = make_string_vec(&[
"git",
"blame",
"-s",
"-f",
"hello.txt",
"--date=2015",
"--date",
"now",
]);
assert_eq!(
guess_git_blame_filename_extension(&args),
Args("txt".into())
);
let args = make_string_vec(&["git", "blame", "-s", "-f", "--", "hello.txt"]);
assert_eq!(
guess_git_blame_filename_extension(&args),
Args("txt".into())
);
let args = make_string_vec(&["git", "blame", "--", "--not.an.argument"]);
assert_eq!(
guess_git_blame_filename_extension(&args),
Args("argument".into())
);
let args = make_string_vec(&["foo", "bar", "-a", "--123", "not.git"]);
assert_eq!(
guess_git_blame_filename_extension(&args),
ProcessArgs::OtherProcess
);
let args = make_string_vec(&["git", "blame", "--help.txt"]);
assert_eq!(
guess_git_blame_filename_extension(&args),
ProcessArgs::ArgError
);
let args = make_string_vec(&["git", "-c", "a=b", "blame", "main.rs"]);
assert_eq!(guess_git_blame_filename_extension(&args), Args("rs".into()));
let args = make_string_vec(&["git", "blame", "README"]);
assert_eq!(
guess_git_blame_filename_extension(&args),
Args("README".into())
);
let args = make_string_vec(&["git", "blame", ""]);
assert_eq!(guess_git_blame_filename_extension(&args), Args("".into()));
} | rust_cleaned_test_functions.jsonl/94997 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1083
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
54737,
68801,
13141,
373,
13323,
31035,
368,
341,
286,
990,
8603,
4117,
486,
4117,
401,
286,
5168,
1281,
3904,
13251,
7356,
25,
44590,
5,
495,
2467,
1464,
11312,
3464,
29,
341,
310,
2827,
19471,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_invalid_option() {
for i in 2u8..=255 {
let bytes = [i, 32];
assert_eq!(
<Option<u8>>::try_from_slice(&bytes)
.unwrap_err()
.to_string(),
format!(
"Invalid Option representation: {}. The first byte must be 0 or 1",
i
)
);
}
} | rust_cleaned_test_functions.jsonl/103714 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 226
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31433,
9672,
368,
341,
262,
369,
600,
304,
220,
17,
84,
23,
496,
28,
17,
20,
20,
341,
286,
1077,
5820,
284,
508,
72,
11,
220,
18,
17,
935,
286,
2060,
10714,
33673,
310,
366,
5341,
34837,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_signers_weight() {
use crypto::random::Random;
let mut signers = Signers::new().unwrap();
let mut expected_max_weight = 0;
let mut expected_total_weight = 0;
for _ in 0..10 {
let public_key = PublicKey::random().unwrap();
let weight = Random::u64_range(1, 11).unwrap();
let signer = Signer { public_key, weight };
signers.add(&signer).unwrap();
if signer.weight > expected_max_weight {
expected_max_weight = signer.weight;
}
expected_total_weight += signer.weight;
}
let max_weight = signers.max_weight();
let total_weight = signers.total_weight();
assert_eq!(max_weight, expected_max_weight);
assert_eq!(total_weight, expected_total_weight);
} | rust_cleaned_test_functions.jsonl/13574 | {
"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,
11172,
388,
15876,
368,
341,
262,
990,
19028,
486,
11463,
486,
13999,
401,
262,
1077,
5206,
1841,
388,
284,
7075,
388,
486,
931,
1005,
15454,
543,
262,
1077,
5206,
3601,
6345,
15876,
284,
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... | 3 |
#[test]
fn test_line_input() {
let mut repl = repl!();
let _rx = repl.output_listen();
repl.line_input("test");
assert_eq!(repl.input_buffer(), "test");
repl.line_input(""); // check doesn't break
assert_eq!(repl.input_buffer(), "");
repl.line_input("{");
repl = repl.read().unwrap_read();
assert_eq!(repl.input_buffer(), "{\n");
repl.line_input("test");
assert_eq!(repl.input_buffer(), "{\ntest");
repl.line_input("");
assert_eq!(repl.input_buffer(), "{\n");
} | rust_cleaned_test_functions.jsonl/104486 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 301
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6528,
5898,
368,
972,
286,
1077,
5206,
5791,
284,
5791,
0,
7317,
286,
1077,
716,
12651,
284,
5791,
13413,
79286,
7317,
286,
5791,
10932,
5898,
445,
1944,
2815,
286,
2060,
10714,
10297,
265,
500,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_u64() {
let mut buf = vec![];
let mut ser = Serializer { write: &mut buf };
42_u64.serialize(&mut ser).unwrap();
assert_eq!(buf, [0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
} | rust_cleaned_test_functions.jsonl/79241 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 112
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
7300,
21,
19,
368,
341,
262,
1077,
5206,
6607,
284,
7486,
0,
15078,
262,
1077,
5206,
1420,
284,
58822,
314,
3270,
25,
609,
6984,
6607,
2605,
262,
220,
19,
17,
7300,
21,
19,
33969,
2099,
6984,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_task_remove_no_task() {
let context = get_context(accounts(1));
testing_env!(context.build());
let mut contract = Contract::new();
contract.remove_task(Base64VecU8::from(vec![0, 1, 2, 3]));
} | rust_cleaned_test_functions.jsonl/43002 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 116
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12184,
18193,
6536,
12184,
368,
341,
286,
1077,
2266,
284,
633,
8467,
91868,
7,
16,
1106,
286,
7497,
15879,
10297,
2147,
13239,
1423,
286,
1077,
5206,
5116,
284,
19185,
486,
931,
543,
286,
5116,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_console_file() {
let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
let guest = Guest::new(Box::new(focal));
let console_path = guest.tmp_dir.as_path().join("/tmp/console-output");
let mut child = GuestCommand::new(&guest)
.args(&["--cpus", "boot=1"])
.args(&["--memory", "size=512M"])
.args(&["--kernel", direct_kernel_boot_path().to_str().unwrap()])
.args(&["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
.default_disks()
.default_net()
.args(&[
"--console",
format!("file={}", console_path.to_str().unwrap()).as_str(),
])
.capture_output()
.spawn()
.unwrap();
guest.wait_vm_boot(None).unwrap();
guest.ssh_command("sudo shutdown -h now").unwrap();
let _ = child.wait_timeout(std::time::Duration::from_secs(20));
let _ = child.kill();
let output = child.wait_with_output().unwrap();
let r = std::panic::catch_unwind(|| {
// Check that the cloud-hypervisor binary actually terminated
assert!(output.status.success());
// Do this check after shutdown of the VM as an easy way to ensure
// all writes are flushed to disk
let mut f = std::fs::File::open(console_path).unwrap();
let mut buf = String::new();
f.read_to_string(&mut buf).unwrap();
if !buf.contains(CONSOLE_TEST_STRING) {
eprintln!(
"\n\n==== Console file output ====\n\n{}\n\n==== End console file output ====",
buf
);
}
assert!(buf.contains(CONSOLE_TEST_STRING));
});
handle_child_output(r, &output);
} | rust_cleaned_test_functions.jsonl/26154 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 926
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
51724,
2458,
368,
341,
286,
1077,
41099,
284,
34960,
47583,
2648,
486,
931,
7,
3788,
49533,
19121,
4708,
2389,
3904,
1423,
286,
1077,
8640,
284,
26215,
486,
931,
67758,
486,
931,
955,
3683,
3237,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_find_matching_opening_symbol() {
let doc = Document::new(vec![Row::from("fn test() {}")], PathBuf::from("test.txt"));
assert_eq!(
Navigator::find_matching_opening_symbol(
&doc,
&Position { x: 11, y: 0 },
&ViewportOffset {
columns: 0,
rows: 0
}
),
Some(Position { x: 10, y: 0 })
);
} | rust_cleaned_test_functions.jsonl/77276 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 233
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
21814,
70763,
11311,
287,
21179,
368,
341,
262,
1077,
4629,
284,
11789,
486,
931,
25592,
20703,
3102,
486,
1499,
445,
8822,
1273,
368,
4687,
899,
1125,
7933,
15064,
486,
1499,
445,
1944,
3909,
401... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_field() {
let reader_schema = Schema::parse_str(
r#"
{"type":"record", "name":"Record", "fields":[
{"name":"oldfield1", "type":"int"}
]}
"#,
)
.unwrap();
assert!(SchemaCompatibility::can_read(
&writer_schema(),
&reader_schema,
));
assert_eq!(
SchemaCompatibility::can_read(&reader_schema, &writer_schema()),
false
);
} | rust_cleaned_test_functions.jsonl/21769 | {
"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,
40447,
5013,
368,
341,
286,
1077,
6604,
25371,
284,
12539,
486,
6400,
2895,
1006,
310,
435,
2,
698,
414,
5212,
1313,
3252,
8548,
497,
330,
606,
3252,
6471,
497,
330,
9007,
8899,
198,
286,
5212,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_trapezoidal_integrate_grid() {
let grid: Vec<_> = linspace(0.0, 10.0, 5).collect();
let density = |_, _| LogProb(0.1f64.ln());
let prob = LogProb::ln_trapezoidal_integrate_grid_exp(density, &grid);
assert_relative_eq!(*prob, *LogProb::ln_one(), epsilon = 0.0000001);
} | rust_cleaned_test_functions.jsonl/128288 | {
"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,
3547,
2027,
89,
70816,
4042,
57017,
15604,
368,
341,
286,
1077,
5827,
25,
11312,
32399,
29,
284,
85796,
7,
15,
13,
15,
11,
220,
16,
15,
13,
15,
11,
220,
20,
568,
17384,
543,
286,
1077,
17457... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_hello() {
let t = HelloTemplate { name: "world" }; // instantiate your struct
assert_eq!("Hello, world!", t.call().unwrap()); // then call it.
} | rust_cleaned_test_functions.jsonl/92828 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 65
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
96724,
368,
341,
262,
1077,
259,
284,
21927,
7275,
314,
829,
25,
330,
14615,
1,
20066,
442,
40902,
697,
2036,
198,
262,
2060,
10714,
17223,
9707,
11,
1879,
18789,
259,
8524,
1005,
15454,
13426,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_voice_states() {
let cache = InMemoryCache::new();
cache.cache_voice_state(voice_state(GuildId(1), Some(ChannelId(2)), UserId(3)));
cache.cache_voice_state(voice_state(GuildId(1), Some(ChannelId(2)), UserId(4)));
// Returns both voice states for the channel that exists.
assert_eq!(2, cache.voice_channel_states(ChannelId(2)).unwrap().len());
// Returns None if the channel does not exist.
assert!(cache.voice_channel_states(ChannelId(0)).is_none());
} | rust_cleaned_test_functions.jsonl/86442 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 217
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
76765,
22972,
368,
341,
286,
1077,
6500,
284,
758,
10642,
8233,
486,
931,
543,
286,
6500,
20087,
76765,
4387,
7,
9862,
4387,
6699,
1498,
764,
7,
16,
701,
4329,
68420,
764,
7,
17,
5731,
40883,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_program_bpf_ro_modify() {
solana_logger::setup();
let GenesisConfigInfo {
genesis_config,
mint_keypair,
..
} = create_genesis_config(50);
let mut bank = Bank::new_for_tests(&genesis_config);
let (name, id, entrypoint) = solana_bpf_loader_program!();
bank.add_builtin(&name, &id, entrypoint);
let bank = Arc::new(bank);
let bank_client = BankClient::new_shared(&bank);
let program_pubkey = load_bpf_program(
&bank_client,
&bpf_loader::id(),
&mint_keypair,
"solana_bpf_rust_ro_modify",
);
let test_keypair = Keypair::new();
let account = AccountSharedData::new(10, 0, &system_program::id());
bank.store_account(&test_keypair.pubkey(), &account);
let account_metas = vec![
AccountMeta::new_readonly(system_program::id(), false),
AccountMeta::new(test_keypair.pubkey(), true),
];
let instruction = Instruction::new_with_bytes(program_pubkey, &[1], account_metas.clone());
let message = Message::new(&[instruction], Some(&mint_keypair.pubkey()));
let result = bank_client.send_and_confirm_message(&[&mint_keypair, &test_keypair], message);
assert_eq!(
result.unwrap_err().unwrap(),
TransactionError::InstructionError(0, InstructionError::ProgramFailedToComplete)
);
let instruction = Instruction::new_with_bytes(program_pubkey, &[3], account_metas.clone());
let message = Message::new(&[instruction], Some(&mint_keypair.pubkey()));
let result = bank_client.send_and_confirm_message(&[&mint_keypair, &test_keypair], message);
assert_eq!(
result.unwrap_err().unwrap(),
TransactionError::InstructionError(0, InstructionError::ProgramFailedToComplete)
);
let instruction = Instruction::new_with_bytes(program_pubkey, &[4], account_metas.clone());
let message = Message::new(&[instruction], Some(&mint_keypair.pubkey()));
let result = bank_client.send_and_confirm_message(&[&mint_keypair, &test_keypair], message);
assert_eq!(
result.unwrap_err().unwrap(),
TransactionError::InstructionError(0, InstructionError::ProgramFailedToComplete)
);
} | rust_cleaned_test_functions.jsonl/5744 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 856
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25096,
880,
15897,
26608,
57725,
368,
341,
262,
2048,
3362,
27413,
486,
15188,
1428,
262,
1077,
40788,
2648,
1731,
341,
286,
59366,
5332,
345,
286,
28337,
3097,
12670,
345,
286,
54538,
262,
335,
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_intersection_empty() {
let a = VecDocSet::from(vec![1, 3]);
let b = VecDocSet::from(vec![1, 4]);
let c = VecDocSet::from(vec![3, 9]);
let mut intersection = Intersection::new(vec![a, b, c]);
assert!(!intersection.advance());
} | rust_cleaned_test_functions.jsonl/57498 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 141
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
82558,
15124,
368,
341,
286,
1077,
264,
284,
11312,
9550,
1649,
486,
1499,
25592,
20703,
16,
11,
220,
18,
2558,
286,
1077,
293,
284,
11312,
9550,
1649,
486,
1499,
25592,
20703,
16,
11,
220,
19,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_read_slice_out_of_bounds() {
let mem = Memory::new(&mut []);
expect_syscall_err!(IllegalArgument, mem.try_slice(10, 0));
expect_syscall_err!(IllegalArgument, mem.try_slice(u32::MAX, 0));
} | rust_cleaned_test_functions.jsonl/34765 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 114
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
26488,
6068,
3575,
36878,
368,
341,
286,
1077,
1833,
284,
13850,
486,
931,
2099,
6984,
42197,
286,
1720,
20344,
6659,
9266,
10297,
33713,
9171,
11,
1833,
48779,
26488,
7,
16,
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_add_args_for_creation() {
// test work and break
let cmd = Command::new("myapp");
let matches = add_args_for_create_subcommand(cmd)
.get_matches_from("myapp -w 25 -b 5".split_whitespace());
let work = matches.value_of("work").unwrap();
assert!(work.eq("25"));
let r#break = matches.value_of("break").unwrap();
assert!(r#break.eq("5"));
// test default
let cmd = Command::new("myapp");
let matches =
add_args_for_create_subcommand(cmd).get_matches_from("myapp -d".split_whitespace());
assert!(matches.is_present("default"));
} | rust_cleaned_test_functions.jsonl/23040 | {
"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,
2891,
8384,
5478,
46163,
368,
341,
286,
442,
1273,
975,
323,
1438,
198,
286,
1077,
5439,
284,
7348,
486,
931,
445,
2408,
676,
797,
286,
1077,
9071,
284,
912,
8384,
5478,
8657,
5228,
5631,
14160,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_errs() {
assert!(items(quote! {test="1", test2}).is_err());
assert!(items(quote! {test, "*", args="*"}).is_err());
assert!(items(quote! {test, kwargs="**", args="*"}).is_err());
assert!(items(quote! {test, kwargs="**", args}).is_err());
} | rust_cleaned_test_functions.jsonl/79349 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 145
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9266,
82,
368,
341,
286,
2060,
10297,
3615,
7,
2949,
0,
314,
1944,
428,
16,
497,
1273,
17,
16630,
285,
9266,
1423,
286,
2060,
10297,
3615,
7,
2949,
0,
314,
1944,
11,
79936,
2827,
428,
9,
920... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_address_name() {
assert_eq!(
address_name(&"192.0.2.5".parse::<IpAddr>().unwrap()),
"5.2.0.192.in-addr.arpa"
);
assert_eq!(
address_name(&"2001:db8::567:89ab".parse::<IpAddr>().unwrap()),
"b.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa"
);
} | rust_cleaned_test_functions.jsonl/84251 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 258
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6744,
1269,
368,
341,
286,
2060,
10714,
33673,
310,
2621,
1269,
2099,
1,
16,
24,
17,
13,
15,
13,
17,
13,
20,
3263,
6400,
27638,
23378,
13986,
10483,
15454,
14702,
310,
330,
20,
13,
17,
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... | 1 |
#[test]
fn test_gil_counts() {
// Check GILGuard and GILPool both increase counts correctly
let get_gil_count = || GIL_COUNT.with(|c| c.get());
assert_eq!(get_gil_count(), 0);
let gil = Python::acquire_gil();
assert_eq!(get_gil_count(), 1);
assert_eq!(get_gil_count(), 1);
let pool = unsafe { GILPool::new() };
assert_eq!(get_gil_count(), 2);
let pool2 = unsafe { GILPool::new() };
assert_eq!(get_gil_count(), 3);
drop(pool);
assert_eq!(get_gil_count(), 2);
let gil2 = Python::acquire_gil();
assert_eq!(get_gil_count(), 3);
drop(gil2);
assert_eq!(get_gil_count(), 2);
drop(pool2);
assert_eq!(get_gil_count(), 1);
drop(gil);
assert_eq!(get_gil_count(), 0);
} | rust_cleaned_test_functions.jsonl/25429 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 417
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1889,
321,
25977,
368,
341,
286,
442,
4248,
479,
1715,
20806,
323,
479,
1715,
10551,
2176,
5263,
14579,
12440,
198,
286,
1077,
633,
1889,
321,
3180,
284,
1369,
479,
1715,
14672,
18164,
22428,
66,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_apply_slice() {
let s = &[0, 1, 2, 3, 4, 5, 6];
let x = apply_slice(s, Some(Value::new_int(-1)), None, Some(Value::new_int(-1))).unwrap();
assert_eq!(x, &[6, 5, 4, 3, 2, 1, 0]);
let x = apply_slice(s, Some(Value::new_int(-1)), None, Some(Value::new_int(-1))).unwrap();
assert_eq!(x, &[6, 5, 4, 3, 2, 1, 0]);
let x = apply_slice(
s,
Some(Value::new_int(0)),
Some(Value::new_int(3)),
Some(Value::new_int(2)),
)
.unwrap();
assert_eq!(x, &[0, 2]);
let x = apply_slice(
s,
Some(Value::new_int(5)),
Some(Value::new_int(2)),
Some(Value::new_int(-2)),
)
.unwrap();
assert_eq!(x, &[5, 3]);
let x = apply_slice(
s,
Some(Value::new_int(-1)),
Some(Value::new_int(-5)),
Some(Value::new_int(-1)),
)
.unwrap();
assert_eq!(x, &[6, 5, 4, 3]);
let x = apply_slice(
s,
Some(Value::new_int(-1)),
Some(Value::new_int(0)),
Some(Value::new_int(-1)),
)
.unwrap();
assert_eq!(x, &[6, 5, 4, 3, 2, 1]);
let x = apply_slice(
&[1, 2, 3],
Some(Value::new_int(0)),
Some(Value::new_int(-2)),
Some(Value::new_int(-1)),
)
.unwrap();
assert_eq!(x, &[]);
} | rust_cleaned_test_functions.jsonl/104702 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 899
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
36551,
26488,
368,
341,
286,
1077,
274,
284,
44590,
15,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11,
220,
21,
4821,
286,
1077,
856,
284,
3796,
26488,
1141,
11,
4329... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_decode_cmn() {
match decode_16(0x42ec) {
Instruction::CMN_reg { params, thumb32 } => {
assert!(params.rn == Reg::R4);
assert!(params.rm == Reg::R5);
assert!(params.shift_t == SRType::LSL);
assert!(params.shift_n == 0);
assert!(!thumb32);
}
_ => {
assert!(false);
}
}
} | rust_cleaned_test_functions.jsonl/64777 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 234
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15227,
666,
21775,
368,
341,
1066,
262,
2432,
16895,
62,
16,
21,
7,
15,
87,
19,
17,
757,
8,
341,
286,
29051,
486,
9985,
45,
4920,
314,
3628,
11,
24050,
18,
17,
335,
589,
341,
310,
2060,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_enum() {
assert_eq!(10, EnumWithAlias::A.value());
assert_eq!(10, EnumWithAlias::A_AGAIN.value());
assert_eq!(&[EnumWithAlias::A, EnumWithAlias::B, EnumWithAlias::A_AGAIN], EnumWithAlias::values());
// broken now
} | rust_cleaned_test_functions.jsonl/63346 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 115
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
31054,
368,
341,
262,
2060,
10714,
10297,
16,
15,
11,
14086,
2354,
22720,
486,
32,
2824,
1423,
262,
2060,
10714,
10297,
16,
15,
11,
14086,
2354,
22720,
486,
32,
37851,
6836,
2824,
1423,
262,
206... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_clone_from() {
let a = Box::new(5);
let mut b = Box::new(10);
b.clone_from(&a);
assert_eq!(*b, 5);
} | rust_cleaned_test_functions.jsonl/48518 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 73
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
54742,
5673,
368,
341,
262,
1077,
264,
284,
8261,
486,
931,
7,
20,
317,
262,
1077,
5206,
293,
284,
8261,
486,
931,
7,
16,
15,
317,
262,
293,
15997,
5673,
2099,
64,
317,
262,
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 |
#[test]
fn test_server_compact_lock_cf() {
let count = 1;
let mut cluster = new_server_cluster(0, count);
test_compact_lock_cf(&mut cluster);
} | rust_cleaned_test_functions.jsonl/60209 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 70
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12015,
18177,
531,
9818,
71143,
368,
341,
262,
1077,
1760,
284,
220,
16,
280,
262,
1077,
5206,
10652,
284,
501,
12015,
28441,
7,
15,
11,
1760,
317,
262,
1273,
18177,
531,
9818,
71143,
2099,
6984... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_args() {
let ctx = TestContext::new();
let connect = ctx.async_connection();
block_on_all(connect.and_then(|mut con| async move {
redis::cmd("SET")
.arg("key1")
.arg(b"foo")
.query_async(&mut con)
.await?;
redis::cmd("SET")
.arg(&["key2", "bar"])
.query_async(&mut con)
.await?;
let result = redis::cmd("MGET")
.arg(&["key1", "key2"])
.query_async(&mut con)
.await;
assert_eq!(result, Ok(("foo".to_string(), b"bar".to_vec())));
result
}))
.unwrap();
} | rust_cleaned_test_functions.jsonl/75328 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 373
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8384,
368,
341,
262,
1077,
5635,
284,
3393,
1972,
486,
931,
543,
262,
1077,
4564,
284,
5635,
24747,
15866,
1428,
262,
2504,
4470,
5705,
73480,
34724,
68367,
22428,
6984,
390,
91,
3312,
3271,
341,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_arch_mips() {
test_arch_mode_endian_insns(
&mut Capstone::new()
.mips()
.mode(mips::ArchMode::Mips32R6)
.build()
.unwrap(),
Arch::MIPS,
Mode::Mips32R6,
Some(Endian::Little),
&[],
&[("ori", b"\x56\x34\x21\x34"), ("srl", b"\xc2\x17\x01\x00")],
);
test_arch_mode_endian_insns(
&mut Capstone::new()
.mips()
.mode(mips::ArchMode::Mips32R6)
.endian(Endian::Big)
.build()
.unwrap(),
Arch::MIPS,
Mode::Mips32R6,
Some(Endian::Big),
&[],
&[
("ori", b"\x34\x21\x34\x56"),
("jal", b"\x0C\x10\x00\x97"),
("nop", b"\x00\x00\x00\x00"),
("addiu", b"\x24\x02\x00\x0c"),
("lw", b"\x8f\xa2\x00\x00"),
("ori", b"\x34\x21\x34\x56"),
],
);
test_arch_mode_endian_insns(
&mut Capstone::new()
.mips()
.mode(mips::ArchMode::Mips32R6)
.extra_mode([mips::ArchExtraMode::Micro].iter().map(|x| *x))
.endian(Endian::Big)
.build()
.unwrap(),
Arch::MIPS,
Mode::Mips32R6,
Some(Endian::Big),
&[ExtraMode::Micro],
&[
("break", b"\x00\x07\x00\x07"),
("wait", b"\x00\x11\x93\x7c"),
("syscall", b"\x01\x8c\x8b\x7c"),
("rotrv", b"\x00\xc7\x48\xd0"),
],
);
} | rust_cleaned_test_functions.jsonl/127434 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 999
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34330,
717,
3077,
368,
341,
262,
1273,
34330,
7302,
87193,
34386,
4412,
1006,
286,
609,
6984,
8012,
10812,
486,
931,
741,
310,
659,
76,
3077,
741,
310,
659,
8516,
1255,
3077,
486,
18727,
3636,
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_network() {
let mut cmd1 = Command::cargo_bin("factomd").unwrap();
let mut cmd2 = Command::cargo_bin("factomd").unwrap();
let mut cmd3 = Command::cargo_bin("factomd").unwrap();
cmd1.arg("--network").arg("main").assert().success();
cmd2.arg("--network")
.arg("custom-network-123")
.assert()
.success();
cmd3.arg("--network").arg("1234").assert().success();
} | rust_cleaned_test_functions.jsonl/86582 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 180
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
20966,
368,
341,
262,
1077,
5206,
5439,
16,
284,
7348,
486,
66715,
21816,
445,
33110,
316,
67,
1827,
15454,
543,
262,
1077,
5206,
5439,
17,
284,
7348,
486,
66715,
21816,
445,
33110,
316,
67,
182... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_add_builtin_account_inherited_cap_while_replacing() {
let (genesis_config, mint_keypair) = create_genesis_config(100_000);
let bank = Bank::new_for_tests(&genesis_config);
let program_id = solana_sdk::pubkey::new_rand();
bank.add_builtin_account("mock_program", &program_id, false);
assert_eq!(bank.capitalization(), bank.calculate_capitalization(true));
// someone mess with program_id's balance
bank.withdraw(&mint_keypair.pubkey(), 10).unwrap();
assert_ne!(bank.capitalization(), bank.calculate_capitalization(true));
bank.deposit(&program_id, 10).unwrap();
assert_eq!(bank.capitalization(), bank.calculate_capitalization(true));
bank.add_builtin_account("mock_program v2", &program_id, true);
assert_eq!(bank.capitalization(), bank.calculate_capitalization(true));
} | rust_cleaned_test_functions.jsonl/28953 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 361
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
73829,
13500,
1243,
48394,
16388,
86069,
1288,
47933,
368,
341,
286,
1077,
320,
77894,
5332,
11,
28337,
3097,
12670,
8,
284,
1855,
16322,
13774,
5332,
7,
16,
15,
15,
62,
15,
15,
15,
317,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_signature_hash_simple() {
let private: Private = "5HusYj2b2x4nroApgfvaSfKYZhRbKFH41bVyPooymbC6KfgSXdD".into();
let previous_tx_hash = H256::from_reversed_str("81b4c832d70cb56ff957589752eb4125a4cab78a25a8fc52d6a09e5bd4404d48");
let previous_output_index = 0;
let from: Address = "1MMMMSUb1piy2ufrSguNUdFmAcvqrQF8M5".into();
let to: Address = "1KKKK6N21XKo48zWKuQKXdvSsCf95ibHFa".into();
let previous_output = "76a914df3bd30160e6c6145baaf2c88a8844c13a00d1d588ac".into();
let current_output: Bytes = "76a914c8e90996c7c6080ee06284600c684ed904d14c5c88ac".into();
let value = 91234;
let expected_signature_hash = "5fda68729a6312e17e641e9a49fac2a4a6a680126610af573caab270d232f850".into();
// this is irrelevant
let kp = KeyPair::from_private(private).unwrap();
assert_eq!(kp.address(), from);
assert_eq!(¤t_output[3..23], &*to.hash);
let unsigned_input = UnsignedTransactionInput {
sequence: 0xffff_ffff,
previous_output: OutPoint {
index: previous_output_index,
hash: previous_tx_hash,
},
};
let output = TransactionOutput {
value: value,
script_pubkey: current_output,
};
let input_signer = TransactionInputSigner {
version: 1,
lock_time: 0,
inputs: vec![unsigned_input],
outputs: vec![output],
};
let hash = input_signer.signature_hash(0, 0, &previous_output, SignatureVersion::Base, SighashBase::All.into());
assert_eq!(hash, expected_signature_hash);
} | rust_cleaned_test_functions.jsonl/45009 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 666
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39859,
8950,
30015,
368,
341,
197,
10217,
869,
25,
9679,
284,
330,
20,
39,
355,
56,
73,
17,
65,
17,
87,
19,
77,
299,
32,
3517,
69,
6586,
50,
69,
42,
40209,
71,
49,
65,
65008,
39,
19,
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_handshake_message_exceeds_max_len() {
let params: NoiseParams = "Noise_NN_25519_AESGCM_SHA256".parse().unwrap();
let mut h_i = Builder::new(params).build_initiator().unwrap();
let mut buffer_out = [0u8; 65535*2];
assert!(h_i.write_message(&[0u8; 65530], &mut buffer_out).is_err());
} | rust_cleaned_test_functions.jsonl/27108 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 141
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
23194,
29661,
6462,
2702,
4635,
82,
6345,
6043,
368,
341,
262,
1077,
3628,
25,
50523,
4870,
284,
330,
61819,
1604,
45,
62,
17,
20,
20,
16,
24,
69381,
38,
9985,
38096,
17,
20,
21,
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 |
#[test]
fn test_hex_dump_all_bytes() {
for i in 0..256 {
assert_eq!(hex_dump(&[i as u8]), format!("{:02x}", i));
}
} | rust_cleaned_test_functions.jsonl/54602 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 90
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
32655,
18296,
5705,
12524,
368,
341,
286,
369,
600,
304,
220,
15,
496,
17,
20,
21,
341,
310,
2060,
10714,
10297,
17308,
18296,
2099,
58,
72,
438,
575,
23,
9719,
3561,
88928,
25,
15,
17,
87,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_next_stateless() {
assert_eq!(Rng::new(0).next(), 9413281287807789659);
assert_eq!(Rng::new(0x2b4610ec42f20b13).next(), 12531479686729921902);
} | rust_cleaned_test_functions.jsonl/92306 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 101
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11257,
4387,
1717,
368,
341,
286,
2060,
10714,
10297,
49,
968,
486,
931,
7,
15,
568,
3600,
1507,
220,
24,
19,
16,
18,
17,
23,
16,
17,
23,
22,
23,
15,
22,
22,
23,
24,
21,
20,
24,
317,
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_well_known_types_check_namespaces() -> Result<()> {
// Check that we don't treat a type called `int32_t` in a user-defined
// namespace as if it was the standard type `int32_t`.
// type of `i32`.
// imported with the correct paramter type `my_namespace::int32_t`.
let ir = ir_from_cc(
r#"
namespace my_namespace {
using int32_t = int;
}
void f(my_namespace::int32_t i);
"#,
)?;
assert_strings_contain(
ir.unsupported_items().map(|i| i.name.as_str()).collect_vec().as_slice(),
"f",
);
Ok(())
} | rust_cleaned_test_functions.jsonl/37184 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 317
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1670,
613,
71690,
9763,
7200,
9187,
27338,
368,
1464,
5714,
71698,
341,
262,
442,
4248,
429,
582,
1513,
944,
4228,
264,
943,
2598,
1565,
396,
18,
17,
528,
63,
304,
264,
1196,
38717,
198,
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... | 2 |
#[test]
fn test_take_primitive_non_null_values() {
let index = UInt32Array::from(vec![Some(3), None, Some(1), Some(3), Some(2)]);
test_take_primitive_arrays::<Int8Type>(
vec![Some(0), Some(1), Some(2), Some(3), Some(4)],
&index,
None,
vec![Some(3), None, Some(1), Some(3), Some(2)],
)
.unwrap();
} | rust_cleaned_test_functions.jsonl/27041 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 214
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
73261,
84087,
21637,
15162,
9146,
368,
341,
286,
1077,
1922,
284,
22275,
18,
17,
1857,
486,
1499,
25592,
20703,
8373,
7,
18,
701,
2240,
11,
4329,
7,
16,
701,
4329,
7,
18,
701,
4329,
7,
17,
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_cmd() {
let ret = cmd_format("ls \"test\" 123".to_string()).unwrap();
assert_eq!(ret[0] , String::from("ls"));
assert_eq!(ret[1] , String::from("test"));
assert_eq!(ret[2] , String::from("123"));
let ret = cmd_format("ls \"test\"".to_string()).unwrap();
assert_eq!(ret[0] , String::from("ls"));
assert_eq!(ret[1] , String::from("test"));
} | rust_cleaned_test_functions.jsonl/97300 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 159
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11684,
368,
341,
10217,
2112,
284,
5439,
8955,
445,
4730,
7245,
1944,
2105,
220,
16,
17,
18,
3263,
983,
3904,
6011,
15454,
543,
6948,
10714,
10297,
2122,
58,
15,
60,
1154,
923,
486,
1499,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_toposort_eq() {
let mut g = Graph::<_, _>::new();
let a = g.add_node("A");
let b = g.add_node("B");
g.add_edge(a, b, ());
assert_eq!(petgraph::algo::toposort(&g, None), Ok(vec![a, b]));
} | rust_cleaned_test_functions.jsonl/46749 | {
"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,
10426,
436,
371,
10714,
368,
341,
262,
1077,
5206,
342,
284,
12165,
27638,
6878,
716,
6831,
931,
543,
262,
1077,
264,
284,
342,
1364,
5084,
445,
32,
797,
262,
1077,
293,
284,
342,
1364,
5084,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_set_append() {
let mut a = SgSet::new();
a.insert(1);
a.insert(2);
a.insert(3);
let mut b = SgSet::<_, 10>::new();
b.insert(4);
b.insert(5);
b.insert(6);
a.append(&mut b);
assert!(b.is_empty());
assert_eq!(a.len(), 6);
assert_eq!(
a.into_iter().collect::<Vec<usize>>(),
vec![1, 2, 3, 4, 5, 6]
);
} | rust_cleaned_test_functions.jsonl/68243 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 215
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2602,
26041,
368,
341,
262,
1077,
5206,
264,
284,
328,
70,
1649,
486,
931,
1428,
262,
264,
7030,
7,
16,
317,
262,
264,
7030,
7,
17,
317,
262,
264,
7030,
7,
18,
626,
262,
1077,
5206,
293,
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_add() -> Result<()> {
assert_eq!(run(vec![1, 0, 0, 0, 99])?, halt(vec![2, 0, 0, 0, 99]));
assert_eq!(
run(vec![1, 1, 1, 4, 99, 5, 6, 0, 99])?,
halt(vec![30, 1, 1, 4, 2, 5, 6, 0, 99]),
);
Ok(())
} | rust_cleaned_test_functions.jsonl/2839 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 176
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
368,
1464,
5714,
71698,
341,
286,
2060,
10714,
10297,
6108,
25592,
20703,
16,
11,
220,
15,
11,
220,
15,
11,
220,
15,
11,
220,
24,
24,
2467,
12622,
26269,
25592,
20703,
17,
11,
220,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_mean() {
assert_eq!(0., mean(vec![]));
assert_eq!(5., mean(vec![5.]));
assert_eq!(7.5, mean(vec![5., 10.]));
assert_eq!(5.5, mean(vec![1., 2., 3., 4., 5., 6., 7., 8., 9., 10.]));
assert_eq!(
5.5,
mean(vec![0., 0., 0., 1., 2., 3., 4., 0., 0., 5., 6., 7., 8., 9., 10., 0., 0., 0.])
);
} | rust_cleaned_test_functions.jsonl/41522 | {
"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,
16933,
368,
341,
286,
2060,
10714,
10297,
15,
2572,
3076,
25592,
0,
1294,
1106,
286,
2060,
10714,
10297,
20,
2572,
3076,
25592,
20703,
20,
13,
14382,
286,
2060,
10714,
10297,
22,
13,
20,
11,
307... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.