MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / set_len_write

Function set_len_write

rust/tests/data_buffer.rs:14–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12
13#[test]
14fn set_len_write() {
15 let mut data = DataBuffer::default();
16 assert_eq!(data.get_data(), &[]);
17 unsafe { data.set_len(DUMMY_DATA_0.len()) };
18 assert_eq!(data.len(), DUMMY_DATA_0.len());
19 let mut contents = DUMMY_DATA_0.to_vec();
20 data.set_data(&contents);
21 // modify the orinal contents, to make sure DataBuffer copied the data
22 // and is not using the original pointer
23 contents.as_mut_slice().fill(0x55);
24 drop(contents);
25 assert_eq!(data.get_data(), DUMMY_DATA_0);
26
27 // make sure the new len truncate the original data
28 unsafe { data.set_len(13) };
29 assert_eq!(data.get_data(), &DUMMY_DATA_0[..13]);
30
31 data.clear();
32 assert_eq!(data.get_data(), &[]);
33}
34
35#[test]
36fn assign_append() {

Callers

nothing calls this directly

Calls 5

set_lenMethod · 0.80
to_vecMethod · 0.80
lenMethod · 0.45
set_dataMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected