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

Function progress_simple_split

rust/src/progress.rs:183–222  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

181
182 #[test]
183 fn progress_simple_split() {
184 let progress = Cell::new(0);
185 let callback = |p, _| {
186 progress.set(p);
187 true
188 };
189 let mut split = callback.split(&[25, 50, 25]);
190 // 0..=25
191 let mut split_instance = split.next_subpart().unwrap();
192 split_instance.progress(0, 100);
193 assert_eq!(progress.get(), 0);
194 split_instance.progress(100, 100);
195 assert_eq!(progress.get(), 25);
196 drop(split_instance);
197
198 // 25..=75
199 let mut split_instance = split.next_subpart().unwrap();
200 split_instance.progress(0, 100);
201 assert_eq!(progress.get(), 25);
202 split_instance.progress(25, 100);
203 // there is no way to check for exact values, it depends on how the calculation is done,
204 // at the time or writing of this test is always round down, but we just check a range because this
205 // could change
206 assert!((36..=37).contains(&progress.get()));
207 split_instance.progress(50, 100);
208 assert_eq!(progress.get(), 50);
209 split_instance.progress(100, 100);
210 assert_eq!(progress.get(), 75);
211 drop(split_instance);
212
213 // 75..=100
214 let mut split_instance = split.next_subpart().unwrap();
215 split_instance.progress(0, 100);
216 assert_eq!(progress.get(), 75);
217 split_instance.progress(100, 100);
218 assert_eq!(progress.get(), 100);
219 drop(split_instance);
220
221 assert!(split.next_subpart().is_none());
222 }
223
224 #[test]
225 fn progress_recursive_split() {

Callers

nothing calls this directly

Calls 3

next_subpartMethod · 0.80
splitMethod · 0.45
progressMethod · 0.45

Tested by

no test coverage detected