ref: 9a05f9771a81bf571c82ac4e6a2071922985e3f1
parent: a22bb9809efd372dd4c5d23cecc6ff4d99a6580d
parent: da2ad47d665bc496633a3322d19c5befc42b5553
author: Johann Koenig <johannkoenig@google.com>
date: Wed Jul 5 17:15:13 EDT 2017
Merge "test/buffer.h: move range checking to compiler"
--- a/test/buffer.h
+++ b/test/buffer.h
@@ -77,7 +77,7 @@
// testing::internal::Random::kMaxRange (1u << 31). However, because we want
// to allow negative low (and high) values, it is restricted to INT32_MAX
// here.
- void Set(ACMRandom *rand_class, const int32_t low, const int32_t high);
+ void Set(ACMRandom *rand_class, const T low, const T high);
// Copy the contents of Buffer 'a' (excluding padding).
void CopyFrom(const Buffer<T> &a);
@@ -178,15 +178,11 @@
}
}
-// TODO(johannkoenig): Use T for low/high.
template <typename T>
-void Buffer<T>::Set(ACMRandom *rand_class, const int32_t low,
- const int32_t high) {
+void Buffer<T>::Set(ACMRandom *rand_class, const T low, const T high) {
if (!raw_buffer_) return;
EXPECT_LE(low, high);
- EXPECT_GE(low, std::numeric_limits<T>::min());
- EXPECT_LE(high, std::numeric_limits<T>::max());
EXPECT_LE(static_cast<int64_t>(high) - low,
std::numeric_limits<int32_t>::max());