add tests directory for simple test
[?]
2paXZqkGuqYVrdei2n8ZVCtynbH1mwewHrmi87LA9cto
Jan 20, 2022, 12:13 AM
IMR3LWFAPRMNGQFAUAWTS4QT2L4DSNTPBJGMHKH2ZNQJB5BJJSTACDependencies
- [2]
LDHPW77N
Change contents
- file addition: tests[2.1]
- file addition: test.rs[0.17]
use slicefire::*;#[derive(Debug, Copy, Clone, Eq, PartialEq)]#[allow(unused)]struct Foo {x: i32,y: i64,}impl From<i32> for Foo {fn from(x: i32) -> Self {Self { x, y: x as i64 * 2 }}}fn indices(size: usize) -> (Vec<usize>, Vec<Foo>) {let indices = (0..(size)).map(|i| i % (size - 2)).collect::<Vec<usize>>();let vs = (0..size).map(|v| (v as i32).into()).collect::<Vec<Foo>>();(indices, vs)}#[test]fn writes_where_it_should() {let (indices, mut vs) = indices(10);writes_par(&mut vs, 10.into(), &indices);let penultimate = vs.len() - 2;let val = penultimate as i32;let last_two = &vs[penultimate..];assert_eq!(last_two[0], val.into());assert_eq!(last_two[1], (val + 1).into());}