summaryrefslogtreecommitdiff
path: root/absl/base/internal/endian_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'absl/base/internal/endian_test.cc')
-rw-r--r--absl/base/internal/endian_test.cc24
1 files changed, 11 insertions, 13 deletions
diff --git a/absl/base/internal/endian_test.cc b/absl/base/internal/endian_test.cc
index aa6b8496..a1691b1f 100644
--- a/absl/base/internal/endian_test.cc
+++ b/absl/base/internal/endian_test.cc
@@ -54,24 +54,22 @@ const uint32_t k32ValueBE{0x67452301};
const uint16_t k16ValueBE{0x2301};
#endif
-template<typename T>
-std::vector<T> GenerateAllValuesForType() {
- std::vector<T> result;
- T next = std::numeric_limits<T>::min();
- while (true) {
- result.push_back(next);
- if (next == std::numeric_limits<T>::max()) {
- return result;
- }
- ++next;
+std::vector<uint16_t> GenerateAllUint16Values() {
+ std::vector<uint16_t> result;
+ result.reserve(size_t{1} << (sizeof(uint16_t) * 8));
+ for (uint32_t i = std::numeric_limits<uint16_t>::min();
+ i <= std::numeric_limits<uint16_t>::max(); ++i) {
+ result.push_back(static_cast<uint16_t>(i));
}
+ return result;
}
template<typename T>
-std::vector<T> GenerateRandomIntegers(size_t numValuesToTest) {
+std::vector<T> GenerateRandomIntegers(size_t num_values_to_test) {
std::vector<T> result;
+ result.reserve(num_values_to_test);
std::mt19937_64 rng(kRandomSeed);
- for (size_t i = 0; i < numValuesToTest; ++i) {
+ for (size_t i = 0; i < num_values_to_test; ++i) {
result.push_back(rng());
}
return result;
@@ -148,7 +146,7 @@ void Swap64(char* bytes) {
}
TEST(EndianessTest, Uint16) {
- GBSwapHelper(GenerateAllValuesForType<uint16_t>(), &Swap16);
+ GBSwapHelper(GenerateAllUint16Values(), &Swap16);
}
TEST(EndianessTest, Uint32) {