1 use fallback;
2 use naive;
3 use {memchr, memchr2, memchr3, memrchr, memrchr2, memrchr3};
4
5 use tests::memchr_tests;
6
7 #[test]
memchr1_find()8 fn memchr1_find() {
9 for test in memchr_tests() {
10 test.one(false, memchr);
11 }
12 }
13
14 #[test]
memchr1_fallback_find()15 fn memchr1_fallback_find() {
16 for test in memchr_tests() {
17 test.one(false, fallback::memchr);
18 }
19 }
20
21 #[test]
memchr2_find()22 fn memchr2_find() {
23 for test in memchr_tests() {
24 test.two(false, memchr2);
25 }
26 }
27
28 #[test]
memchr2_fallback_find()29 fn memchr2_fallback_find() {
30 for test in memchr_tests() {
31 test.two(false, fallback::memchr2);
32 }
33 }
34
35 #[test]
memchr3_find()36 fn memchr3_find() {
37 for test in memchr_tests() {
38 test.three(false, memchr3);
39 }
40 }
41
42 #[test]
memchr3_fallback_find()43 fn memchr3_fallback_find() {
44 for test in memchr_tests() {
45 test.three(false, fallback::memchr3);
46 }
47 }
48
49 #[test]
memrchr1_find()50 fn memrchr1_find() {
51 for test in memchr_tests() {
52 test.one(true, memrchr);
53 }
54 }
55
56 #[test]
memrchr1_fallback_find()57 fn memrchr1_fallback_find() {
58 for test in memchr_tests() {
59 test.one(true, fallback::memrchr);
60 }
61 }
62
63 #[test]
memrchr2_find()64 fn memrchr2_find() {
65 for test in memchr_tests() {
66 test.two(true, memrchr2);
67 }
68 }
69
70 #[test]
memrchr2_fallback_find()71 fn memrchr2_fallback_find() {
72 for test in memchr_tests() {
73 test.two(true, fallback::memrchr2);
74 }
75 }
76
77 #[test]
memrchr3_find()78 fn memrchr3_find() {
79 for test in memchr_tests() {
80 test.three(true, memrchr3);
81 }
82 }
83
84 #[test]
memrchr3_fallback_find()85 fn memrchr3_fallback_find() {
86 for test in memchr_tests() {
87 test.three(true, fallback::memrchr3);
88 }
89 }
90
91 quickcheck! {
92 fn qc_memchr1_matches_naive(n1: u8, corpus: Vec<u8>) -> bool {
93 memchr(n1, &corpus) == naive::memchr(n1, &corpus)
94 }
95 }
96
97 quickcheck! {
98 fn qc_memchr2_matches_naive(n1: u8, n2: u8, corpus: Vec<u8>) -> bool {
99 memchr2(n1, n2, &corpus) == naive::memchr2(n1, n2, &corpus)
100 }
101 }
102
103 quickcheck! {
104 fn qc_memchr3_matches_naive(
105 n1: u8, n2: u8, n3: u8,
106 corpus: Vec<u8>
107 ) -> bool {
108 memchr3(n1, n2, n3, &corpus) == naive::memchr3(n1, n2, n3, &corpus)
109 }
110 }
111
112 quickcheck! {
113 fn qc_memrchr1_matches_naive(n1: u8, corpus: Vec<u8>) -> bool {
114 memrchr(n1, &corpus) == naive::memrchr(n1, &corpus)
115 }
116 }
117
118 quickcheck! {
119 fn qc_memrchr2_matches_naive(n1: u8, n2: u8, corpus: Vec<u8>) -> bool {
120 memrchr2(n1, n2, &corpus) == naive::memrchr2(n1, n2, &corpus)
121 }
122 }
123
124 quickcheck! {
125 fn qc_memrchr3_matches_naive(
126 n1: u8, n2: u8, n3: u8,
127 corpus: Vec<u8>
128 ) -> bool {
129 memrchr3(n1, n2, n3, &corpus) == naive::memrchr3(n1, n2, n3, &corpus)
130 }
131 }
132