MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TestNumberOrdering

Function TestNumberOrdering

tensorflow/core/lib/strings/ordered_code_test.cc:166–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164
165template <typename T>
166void 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
202size_t FindSpecial(const string& x) {

Callers

nothing calls this directly

Calls 3

CompareStringsFunction · 0.85
minMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected