Yaowu Xu | 253c001 | 2016-08-15 10:27:19 -0700 | [diff] [blame] | 1 | /*Daala video codec |
| 2 | Copyright (c) 2013 Daala project contributors. All rights reserved. |
| 3 | |
| 4 | Redistribution and use in source and binary forms, with or without |
| 5 | modification, are permitted provided that the following conditions are met: |
| 6 | |
| 7 | - Redistributions of source code must retain the above copyright notice, this |
| 8 | list of conditions and the following disclaimer. |
| 9 | |
| 10 | - Redistributions in binary form must reproduce the above copyright notice, |
| 11 | this list of conditions and the following disclaimer in the documentation |
| 12 | and/or other materials provided with the distribution. |
| 13 | |
| 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” |
| 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE |
| 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/ |
| 24 | |
| 25 | #include <stdlib.h> |
| 26 | |
| 27 | #include "third_party/googletest/src/include/gtest/gtest.h" |
| 28 | |
| 29 | #include "test/acm_random.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 30 | #include "av1/common/odintrin.h" |
Yaowu Xu | 253c001 | 2016-08-15 10:27:19 -0700 | [diff] [blame] | 31 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 32 | using libaom_test::ACMRandom; |
Yaowu Xu | 253c001 | 2016-08-15 10:27:19 -0700 | [diff] [blame] | 33 | |
| 34 | TEST(Daala, TestDIVUuptoMAX) { |
| 35 | for (int d = 1; d <= OD_DIVU_DMAX; d++) { |
| 36 | for (uint32_t x = 1; x <= 1000000; x++) { |
clang-format | 21a0c2c | 2016-08-18 15:10:22 -0700 | [diff] [blame] | 37 | GTEST_ASSERT_EQ(x / d, OD_DIVU_SMALL(x, d)) |
| 38 | << "x=" << x << " d=" << d << " x/d=" << (x / d) |
| 39 | << " != " << OD_DIVU_SMALL(x, d); |
Yaowu Xu | 253c001 | 2016-08-15 10:27:19 -0700 | [diff] [blame] | 40 | } |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | TEST(Daala, TestDIVUrandI31) { |
| 45 | ACMRandom rnd(ACMRandom::DeterministicSeed()); |
| 46 | for (int d = 1; d < OD_DIVU_DMAX; d++) { |
| 47 | for (int i = 0; i < 1000000; i++) { |
| 48 | uint32_t x = rnd.Rand31(); |
clang-format | 21a0c2c | 2016-08-18 15:10:22 -0700 | [diff] [blame] | 49 | GTEST_ASSERT_EQ(x / d, OD_DIVU_SMALL(x, d)) |
| 50 | << "x=" << x << " d=" << d << " x/d=" << (x / d) |
| 51 | << " != " << OD_DIVU_SMALL(x, d); |
Yaowu Xu | 253c001 | 2016-08-15 10:27:19 -0700 | [diff] [blame] | 52 | } |
| 53 | } |
| 54 | } |