summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohann <johannkoenig@google.com>2017-07-05 11:14:51 -0700
committerJohann <johannkoenig@google.com>2017-07-05 11:21:18 -0700
commitda2ad47d665bc496633a3322d19c5befc42b5553 (patch)
tree0f63eb8ac68f3c817240050c496109c9e87cdd0c /test
parent7d526c1654ed972e4083c89f17fbb8f92782dfb0 (diff)
downloadlibvpx-da2ad47d665bc496633a3322d19c5befc42b5553.tar
libvpx-da2ad47d665bc496633a3322d19c5befc42b5553.tar.gz
libvpx-da2ad47d665bc496633a3322d19c5befc42b5553.tar.bz2
libvpx-da2ad47d665bc496633a3322d19c5befc42b5553.zip
test/buffer.h: move range checking to compiler
Pass low/high values as type T. Out of range values should be caught by static analysis instead. Change-Id: I0a3ee8820af05f4c791ab097626174e2206fa6d5
Diffstat (limited to 'test')
-rw-r--r--test/buffer.h8
1 files changed, 2 insertions, 6 deletions
diff --git a/test/buffer.h b/test/buffer.h
index a6b9f4389..2175dad9d 100644
--- a/test/buffer.h
+++ b/test/buffer.h
@@ -77,7 +77,7 @@ class Buffer {
// 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 @@ void Buffer<T>::Set(ACMRandom *rand_class, T (ACMRandom::*rand_func)()) {
}
}
-// 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());