MCPcopy Create free account
hub / github.com/QMHTMY/RustBook / basic_test

Function basic_test

publication/code/chapter04/linked_list.rs:132–149  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

130 iter_mut_test();
131
132 fn basic_test() {
133 let mut list = List::new();
134 list.push(1); list.push(2); list.push(3);
135
136 assert_eq!(list.len(), 3);
137 assert_eq!(list.is_empty(), false);
138 assert_eq!(list.pop(), Some(3));
139 assert_eq!(list.peek(), Some(&2));
140 assert_eq!(list.peek_mut(), Some(&mut 2));
141
142 list.peek_mut().map(|val| {
143 *val = 4;
144 });
145 assert_eq!(list.peek(), Some(&4));
146
147 list.clear();
148 println!("basics test Ok!");
149 }
150
151 fn into_iter_test() {
152 let mut list = List::new();

Callers 1

mainFunction · 0.70

Calls 3

pushMethod · 0.45
peek_mutMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected