Add high bitdepth test suite for Hadamard functions

Add tests for aom_highbd_hadamard_<w>x<h>, and sort the coefficients in
the test functions to match the behavior of aom_highbd_hadamard_8x8_c
that skips the final transpose.

Change-Id: Ie916487ad22cd5fb567165efaac7dd7753e04704
diff --git a/test/acm_random.h b/test/acm_random.h
index bc38ba4..2e9fe56 100644
--- a/test/acm_random.h
+++ b/test/acm_random.h
@@ -52,6 +52,12 @@
     return static_cast<int16_t>(Rand15()) - (1 << 14);
   }
 
+  int16_t Rand13Signed() {
+    // Use 13 bits: values between 4095 and -4096.
+    const uint32_t value = random_.Generate(8192);
+    return static_cast<int16_t>(value) - 4096;
+  }
+
   uint16_t Rand12() {
     const uint32_t value =
         random_.Generate(testing::internal::Random::kMaxRange);
diff --git a/test/hadamard_test.cc b/test/hadamard_test.cc
index 8c4810a..38c3b5c 100644
--- a/test/hadamard_test.cc
+++ b/test/hadamard_test.cc
@@ -259,6 +259,10 @@
     for (int i = 0; i < block_size_; ++i) a[i] = Rand();
     ReferenceHadamard(a, bw_, b_ref, bw_, bh_, shift_);
     API_REGISTER_STATE_CHECK(h_func_(a, bw_, b));
+
+    // The order of the output is not important. Sort before checking.
+    std::sort(b, b + block_size_);
+    std::sort(b_ref, b_ref + block_size_);
     EXPECT_EQ(memcmp(b, b_ref, sizeof(b)), 0);
   }
 
@@ -278,6 +282,10 @@
 
       ReferenceHadamard(a, i, b_ref, bw_, bh_, shift_);
       API_REGISTER_STATE_CHECK(h_func_(a, i, b));
+
+      // The order of the output is not important. Sort before checking.
+      std::sort(b, b + block_size_);
+      std::sort(b_ref, b_ref + block_size_);
       EXPECT_EQ(0, memcmp(b, b_ref, sizeof(b)));
     }
   }
@@ -355,6 +363,32 @@
                       HadamardFuncWithSize(&aom_hadamard_32x32_neon, 32, 32)));
 #endif  // HAVE_NEON
 
+#if CONFIG_AV1_HIGHBITDEPTH
+class HadamardHighbdTest : public HadamardTestBase<tran_low_t, HadamardFunc> {
+ protected:
+  HadamardHighbdTest() : HadamardTestBase(GetParam(), /*do_shift=*/true) {}
+  virtual int16_t Rand() { return rnd_.Rand13Signed(); }
+};
+
+TEST_P(HadamardHighbdTest, CompareReferenceRandom) { CompareReferenceRandom(); }
+
+TEST_P(HadamardHighbdTest, VaryStride) { VaryStride(); }
+
+TEST_P(HadamardHighbdTest, DISABLED_Speed) {
+  SpeedTest(10);
+  SpeedTest(10000);
+  SpeedTest(10000000);
+}
+
+INSTANTIATE_TEST_SUITE_P(
+    C, HadamardHighbdTest,
+    ::testing::Values(
+        HadamardFuncWithSize(&aom_highbd_hadamard_8x8_c, 8, 8),
+        HadamardFuncWithSize(&aom_highbd_hadamard_16x16_c, 16, 16),
+        HadamardFuncWithSize(&aom_highbd_hadamard_32x32_c, 32, 32)));
+
+#endif  // CONFIG_AV1_HIGHBITDEPTH
+
 // Tests for low precision
 class HadamardLowbdLPTest : public HadamardTestBase<int16_t, HadamardLPFunc> {
  public: