• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2021 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  */
23 
24 #include <gtest/gtest.h>
25 #include "util/macros.h"
26 
27 #define MESA_UINT24_MAX  16777215
28 #define MESA_INT24_MAX   8388607
29 #define MESA_INT24_MIN   (-8388607-1)
30 
31 #define MESA_UINT12_MAX  4095
32 #define MESA_INT12_MAX   2047
33 #define MESA_INT12_MIN   (-2047-1)
34 
35 #define MESA_UINT10_MAX  1023
36 #define MESA_INT10_MAX   511
37 #define MESA_INT10_MIN   (-511-1)
38 
TEST(int_min_max,u_intN_min)39 TEST(int_min_max, u_intN_min)
40 {
41    EXPECT_EQ(INT64_MIN, u_intN_min(64));
42    EXPECT_EQ(INT32_MIN, u_intN_min(32));
43    EXPECT_EQ(INT16_MIN, u_intN_min(16));
44    EXPECT_EQ(INT8_MIN,  u_intN_min(8));
45 
46    EXPECT_EQ(MESA_INT24_MIN, u_intN_min(24));
47    EXPECT_EQ(MESA_INT12_MIN, u_intN_min(12));
48    EXPECT_EQ(MESA_INT10_MIN, u_intN_min(10));
49 }
50 
TEST(int_min_max,u_intN_max)51 TEST(int_min_max, u_intN_max)
52 {
53    EXPECT_EQ(INT64_MAX, u_intN_max(64));
54    EXPECT_EQ(INT32_MAX, u_intN_max(32));
55    EXPECT_EQ(INT16_MAX, u_intN_max(16));
56    EXPECT_EQ(INT8_MAX,  u_intN_max(8));
57 
58    EXPECT_EQ(MESA_INT24_MAX, u_intN_max(24));
59    EXPECT_EQ(MESA_INT12_MAX, u_intN_max(12));
60    EXPECT_EQ(MESA_INT10_MAX, u_intN_max(10));
61 }
62 
TEST(int_min_max,u_uintN_max)63 TEST(int_min_max, u_uintN_max)
64 {
65    EXPECT_EQ(UINT64_MAX, u_uintN_max(64));
66    EXPECT_EQ(UINT32_MAX, u_uintN_max(32));
67    EXPECT_EQ(UINT16_MAX, u_uintN_max(16));
68    EXPECT_EQ(UINT8_MAX,  u_uintN_max(8));
69 
70    EXPECT_EQ(MESA_UINT24_MAX, u_uintN_max(24));
71    EXPECT_EQ(MESA_UINT12_MAX, u_uintN_max(12));
72    EXPECT_EQ(MESA_UINT10_MAX, u_uintN_max(10));
73 }
74