1 // Simple tests using MIRI. These are intended only to be a simple exercise of
2 // memchr when tests are run under miri. These are mostly necessary because the
3 // other tests are far more extensive and take too long to run under miri.
4 //
5 // These tests are also run when the 'std' feature is not enabled.
6
7 use crate::{memchr, memchr2, memchr3, memrchr, memrchr2, memrchr3};
8
9 #[test]
simple()10 fn simple() {
11 assert_eq!(memchr(b'a', b"abcda"), Some(0));
12 assert_eq!(memchr(b'z', b"abcda"), None);
13 assert_eq!(memchr2(b'a', b'z', b"abcda"), Some(0));
14 assert_eq!(memchr2(b'z', b'y', b"abcda"), None);
15 assert_eq!(memchr3(b'a', b'z', b'b', b"abcda"), Some(0));
16 assert_eq!(memchr3(b'z', b'y', b'x', b"abcda"), None);
17 assert_eq!(memrchr(b'a', b"abcda"), Some(4));
18 assert_eq!(memrchr(b'z', b"abcda"), None);
19 assert_eq!(memrchr2(b'a', b'z', b"abcda"), Some(4));
20 assert_eq!(memrchr2(b'z', b'y', b"abcda"), None);
21 assert_eq!(memrchr3(b'a', b'z', b'b', b"abcda"), Some(4));
22 assert_eq!(memrchr3(b'z', b'y', b'x', b"abcda"), None);
23 }
24