Yushin Cho | 77bba8d | 2016-11-04 16:36:56 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
| 3 | * |
| 4 | * This source code is subject to the terms of the BSD 2 Clause License and |
| 5 | * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License |
| 6 | * was not distributed with this source code in the LICENSE file, you can |
| 7 | * obtain it at www.aomedia.org/license/software. If the Alliance for Open |
| 8 | * Media Patent License 1.0 was not distributed with this source code in the |
| 9 | * PATENTS file, you can obtain it at www.aomedia.org/license/patent. |
| 10 | */ |
Yaowu Xu | 253c001 | 2016-08-15 10:27:19 -0700 | [diff] [blame] | 11 | |
| 12 | #include <stdlib.h> |
| 13 | |
| 14 | #include "third_party/googletest/src/include/gtest/gtest.h" |
| 15 | |
| 16 | #include "test/acm_random.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 17 | #include "av1/common/odintrin.h" |
Yaowu Xu | 253c001 | 2016-08-15 10:27:19 -0700 | [diff] [blame] | 18 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 19 | using libaom_test::ACMRandom; |
Yaowu Xu | 253c001 | 2016-08-15 10:27:19 -0700 | [diff] [blame] | 20 | |
| 21 | TEST(Daala, TestDIVUuptoMAX) { |
| 22 | for (int d = 1; d <= OD_DIVU_DMAX; d++) { |
| 23 | for (uint32_t x = 1; x <= 1000000; x++) { |
clang-format | 21a0c2c | 2016-08-18 15:10:22 -0700 | [diff] [blame] | 24 | GTEST_ASSERT_EQ(x / d, OD_DIVU_SMALL(x, d)) |
| 25 | << "x=" << x << " d=" << d << " x/d=" << (x / d) |
| 26 | << " != " << OD_DIVU_SMALL(x, d); |
Yaowu Xu | 253c001 | 2016-08-15 10:27:19 -0700 | [diff] [blame] | 27 | } |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | TEST(Daala, TestDIVUrandI31) { |
| 32 | ACMRandom rnd(ACMRandom::DeterministicSeed()); |
| 33 | for (int d = 1; d < OD_DIVU_DMAX; d++) { |
| 34 | for (int i = 0; i < 1000000; i++) { |
| 35 | uint32_t x = rnd.Rand31(); |
clang-format | 21a0c2c | 2016-08-18 15:10:22 -0700 | [diff] [blame] | 36 | GTEST_ASSERT_EQ(x / d, OD_DIVU_SMALL(x, d)) |
| 37 | << "x=" << x << " d=" << d << " x/d=" << (x / d) |
| 38 | << " != " << OD_DIVU_SMALL(x, d); |
Yaowu Xu | 253c001 | 2016-08-15 10:27:19 -0700 | [diff] [blame] | 39 | } |
| 40 | } |
| 41 | } |