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