| 134 | |
| 135 | template <typename T> |
| 136 | void TestNumbers(T multiplier) { |
| 137 | // first test powers of 2 (and nearby numbers) |
| 138 | for (T x = std::numeric_limits<T>().max(); x != 0; x /= 2) { |
| 139 | TestWriteRead(multiplier * (x - 1)); |
| 140 | TestWriteRead(multiplier * x); |
| 141 | if (x != std::numeric_limits<T>::max()) { |
| 142 | TestWriteRead(multiplier * (x + 1)); |
| 143 | } else if (multiplier < 0 && multiplier == -1) { |
| 144 | TestWriteRead(-x - 1); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | random::PhiloxRandom philox(301, 17); |
| 149 | random::SimplePhilox rnd(&philox); |
| 150 | for (int bits = 1; bits <= std::numeric_limits<T>().digits; ++bits) { |
| 151 | // test random non-negative numbers with given number of significant bits |
| 152 | const uint64 mask = (~0ULL) >> (64 - bits); |
| 153 | for (int i = 0; i < 1000; i++) { |
| 154 | T x = rnd.Rand64() & mask; |
| 155 | TestWriteRead(multiplier * x); |
| 156 | T y = rnd.Rand64() & mask; |
| 157 | TestWriteAppends(multiplier * x, multiplier * y); |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | // Return true iff 'a' is "before" 'b' |
| 163 | bool CompareStrings(const string& a, const string& b) { return (a < b); } |
nothing calls this directly
no test coverage detected