tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

divu_small_test.cc (1333B)


      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 */
     11 
     12 #include <stdlib.h>
     13 
     14 #include "gtest/gtest.h"
     15 
     16 #include "test/acm_random.h"
     17 #include "aom_dsp/odintrin.h"
     18 
     19 using libaom_test::ACMRandom;
     20 
     21 TEST(DivuSmallTest, TestDIVUuptoMAX) {
     22  for (int d = 1; d <= OD_DIVU_DMAX; d++) {
     23    for (uint32_t x = 1; x <= 1000000; x++) {
     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);
     27    }
     28  }
     29 }
     30 
     31 TEST(DivuSmallTest, 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();
     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);
     39    }
     40  }
     41 }