()
| 25 | |
| 26 | #[test] |
| 27 | fn test_num_concurrent_events() { |
| 28 | let (price_bars, t1) = setup_labels(); |
| 29 | let t_events: Vec<usize> = vec![1, 2, 5, 7, 10, 11, 12, 20]; |
| 30 | let num = num_concurrent_events(price_bars.len(), &t1, &t_events); |
| 31 | let start = *t_events.first().unwrap(); |
| 32 | let end = t1.iter().map(|(_, e)| *e).max().unwrap(); |
| 33 | let slice = &num[start..=end]; |
| 34 | // value counts: 0 ->5, 1 ->11, 2 ->5, 3 ->1 (from Python test) |
| 35 | let mut counts = std::collections::HashMap::new(); |
| 36 | for v in slice { |
| 37 | *counts.entry(v).or_insert(0) += 1; |
| 38 | } |
| 39 | assert_eq!(*counts.get(&0).unwrap(), 5); |
| 40 | assert_eq!(*counts.get(&1).unwrap(), 11); |
| 41 | assert_eq!(*counts.get(&2).unwrap(), 5); |
| 42 | assert_eq!(*counts.get(&3).unwrap(), 1); |
| 43 | } |
| 44 | |
| 45 | #[test] |
| 46 | fn test_get_av_uniqueness() { |
nothing calls this directly
no test coverage detected