| 1 | #[cfg(any(feature = "write-floats", feature = "write-integers"))] |
| 2 | use lexical_util::algorithm; |
| 3 | |
| 4 | #[test] |
| 5 | #[cfg(any(feature = "write-floats", feature = "write-integers"))] |
| 6 | fn copy_to_dest_test() { |
| 7 | let src = b"12345"; |
| 8 | let mut dst = [b'0'; 16]; |
| 9 | |
| 10 | assert_eq!(5, algorithm::copy_to_dst(&mut dst, src)); |
| 11 | assert_eq!(&dst[..5], src); |
| 12 | } |
| 13 | |
| 14 | #[test] |
| 15 | #[cfg(any(feature = "write-floats", feature = "write-integers"))] |
| 16 | fn ltrim_char_test() { |
| 17 | let w = "0001"; |
| 18 | let x = "1010"; |
| 19 | let y = "1.00"; |
| 20 | let z = "1e05"; |
| 21 | |
| 22 | assert_eq!(algorithm::ltrim_char_count(w.as_bytes(), b'0'), 3); |
| 23 | assert_eq!(algorithm::ltrim_char_count(x.as_bytes(), b'0'), 0); |
| 24 | assert_eq!(algorithm::ltrim_char_count(x.as_bytes(), b'1'), 1); |
| 25 | assert_eq!(algorithm::ltrim_char_count(y.as_bytes(), b'0'), 0); |
| 26 | assert_eq!(algorithm::ltrim_char_count(y.as_bytes(), b'1'), 1); |
| 27 | assert_eq!(algorithm::ltrim_char_count(z.as_bytes(), b'0'), 0); |
| 28 | assert_eq!(algorithm::ltrim_char_count(z.as_bytes(), b'1'), 1); |
| 29 | assert_eq!(algorithm::ltrim_char_count(z.as_bytes(), b'5'), 0); |
| 30 | } |