blob: 064f8ee4541e7dc8fc5a21b73fce76dc79f8a1fa [file] [log] [blame]
Yushin Cho77bba8d2016-11-04 16:36:56 -07001/*
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 Xu253c0012016-08-15 10:27:19 -070011
12#include <stdlib.h>
13
Tom Finegan7a07ece2017-02-07 17:14:05 -080014#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
Yaowu Xu253c0012016-08-15 10:27:19 -070015
16#include "test/acm_random.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070017#include "av1/common/odintrin.h"
Yaowu Xu253c0012016-08-15 10:27:19 -070018
Yaowu Xuc27fc142016-08-22 16:08:15 -070019using libaom_test::ACMRandom;
Yaowu Xu253c0012016-08-15 10:27:19 -070020
21TEST(Daala, TestDIVUuptoMAX) {
22 for (int d = 1; d <= OD_DIVU_DMAX; d++) {
23 for (uint32_t x = 1; x <= 1000000; x++) {
clang-format21a0c2c2016-08-18 15:10:22 -070024 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 Xu253c0012016-08-15 10:27:19 -070027 }
28 }
29}
30
31TEST(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-format21a0c2c2016-08-18 15:10:22 -070036 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 Xu253c0012016-08-15 10:27:19 -070039 }
40 }
41}