Fix TEXTRELs in the ARM asm.
[profile/ivi/libvpx.git] / vp8 / common / idctllm_test.h
1 /*
2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10
11
12  #include "third_party/googletest/src/include/gtest/gtest.h"
13 typedef void (*idct_fn_t)(short *input, unsigned char *pred_ptr,
14                             int pred_stride, unsigned char *dst_ptr,
15                             int dst_stride);
16 namespace {
17 class IDCTTest : public ::testing::TestWithParam<idct_fn_t>
18 {
19   protected:
20     virtual void SetUp()
21     {
22         int i;
23
24         UUT = GetParam();
25         memset(input, 0, sizeof(input));
26         /* Set up guard blocks */
27         for(i=0; i<256; i++)
28             output[i] = ((i&0xF)<4&&(i<64))?0:-1;
29     }
30
31     idct_fn_t UUT;
32     short input[16];
33     unsigned char output[256];
34     unsigned char predict[256];
35 };
36
37 TEST_P(IDCTTest, TestGuardBlocks)
38 {
39     int i;
40
41     for(i=0; i<256; i++)
42         if((i&0xF) < 4 && i<64)
43             EXPECT_EQ(0, output[i]) << i;
44         else
45             EXPECT_EQ(255, output[i]);
46 }
47
48 TEST_P(IDCTTest, TestAllZeros)
49 {
50     int i;
51
52     UUT(input, output, 16, output, 16);
53
54     for(i=0; i<256; i++)
55         if((i&0xF) < 4 && i<64)
56             EXPECT_EQ(0, output[i]) << "i==" << i;
57         else
58             EXPECT_EQ(255, output[i]) << "i==" << i;
59 }
60
61 TEST_P(IDCTTest, TestAllOnes)
62 {
63     int i;
64
65     input[0] = 4;
66     UUT(input, output, 16, output, 16);
67
68     for(i=0; i<256; i++)
69         if((i&0xF) < 4 && i<64)
70             EXPECT_EQ(1, output[i]) << "i==" << i;
71         else
72             EXPECT_EQ(255, output[i]) << "i==" << i;
73 }
74
75 TEST_P(IDCTTest, TestAddOne)
76 {
77     int i;
78
79     for(i=0; i<256; i++)
80         predict[i] = i;
81
82     input[0] = 4;
83     UUT(input, predict, 16, output, 16);
84
85     for(i=0; i<256; i++)
86         if((i&0xF) < 4 && i<64)
87             EXPECT_EQ(i+1, output[i]) << "i==" << i;
88         else
89             EXPECT_EQ(255, output[i]) << "i==" << i;
90 }
91
92 TEST_P(IDCTTest, TestWithData)
93 {
94     int i;
95
96     for(i=0; i<16; i++)
97         input[i] = i;
98
99     UUT(input, output, 16, output, 16);
100
101     for(i=0; i<256; i++)
102         if((i&0xF) > 3 || i>63)
103             EXPECT_EQ(255, output[i]) << "i==" << i;
104         else if(i == 0)
105             EXPECT_EQ(11, output[i]) << "i==" << i;
106         else if(i == 34)
107             EXPECT_EQ(1, output[i]) << "i==" << i;
108         else if(i == 2 || i == 17 || i == 32)
109             EXPECT_EQ(3, output[i]) << "i==" << i;
110         else
111             EXPECT_EQ(0, output[i]) << "i==" << i;
112 }
113 }