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

Function TestNumbers

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

Source from the content-addressed store, hash-verified

134
135template <typename T>
136void 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'
163bool CompareStrings(const string& a, const string& b) { return (a < b); }

Callers

nothing calls this directly

Calls 5

TestWriteReadFunction · 0.85
TestWriteAppendsFunction · 0.85
Rand64Method · 0.80
maxFunction · 0.50
maxMethod · 0.45

Tested by

no test coverage detected