| 164 | |
| 165 | template <typename T> |
| 166 | void TestNumberOrdering() { |
| 167 | // first the negative numbers (if T is signed, otherwise no-op) |
| 168 | string laststr = OCWrite<T>(std::numeric_limits<T>().min()); |
| 169 | for (T num = std::numeric_limits<T>().min() / 2; num != 0; num /= 2) { |
| 170 | string strminus1 = OCWrite<T>(num - 1); |
| 171 | string str = OCWrite<T>(num); |
| 172 | string strplus1 = OCWrite<T>(num + 1); |
| 173 | |
| 174 | CHECK(CompareStrings(strminus1, str)); |
| 175 | CHECK(CompareStrings(str, strplus1)); |
| 176 | |
| 177 | // Compare 'str' with 'laststr'. When we approach 0, 'laststr' is |
| 178 | // not necessarily before 'strminus1'. |
| 179 | CHECK(CompareStrings(laststr, str)); |
| 180 | laststr = str; |
| 181 | } |
| 182 | |
| 183 | // then the positive numbers |
| 184 | laststr = OCWrite<T>(0); |
| 185 | T num = 1; |
| 186 | while (num < std::numeric_limits<T>().max() / 2) { |
| 187 | num *= 2; |
| 188 | string strminus1 = OCWrite<T>(num - 1); |
| 189 | string str = OCWrite<T>(num); |
| 190 | string strplus1 = OCWrite<T>(num + 1); |
| 191 | |
| 192 | CHECK(CompareStrings(strminus1, str)); |
| 193 | CHECK(CompareStrings(str, strplus1)); |
| 194 | |
| 195 | // Compare 'str' with 'laststr'. |
| 196 | CHECK(CompareStrings(laststr, str)); |
| 197 | laststr = str; |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | // Helper routine for testing TEST_SkipToNextSpecialByte |
| 202 | size_t FindSpecial(const string& x) { |
nothing calls this directly
no test coverage detected