• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 Intel Corporation. All Rights Reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the
6  * "Software"), to deal in the Software without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sub license, and/or sell copies of the Software, and to
9  * permit persons to whom the Software is furnished to do so, subject to
10  * the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the
13  * next paragraph) shall be included in all copies or substantial portions
14  * of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #include "test.h"
26 #include "test_utils.h"
27 
28 #include <vector>
29 
TEST(Internal,Resolution)30 TEST(Internal, Resolution)
31 {
32     using VAAPI::Resolution;
33 
34     Resolution res(2, 7);
35 
36     ASSERT_EQ(res.width, Resolution::DataType(2));
37     ASSERT_EQ(res.height, Resolution::DataType(7));
38 
39     EXPECT_LE(res, res);
40     EXPECT_LE(res, Resolution(res.width + 1, res.height));
41     EXPECT_LE(res, Resolution(res.width, res.height + 1));
42 
43     EXPECT_FALSE(res <= Resolution(res.width - 1, res.height));
44     EXPECT_FALSE(res <= Resolution(res.width, res.height - 1));
45 
46     EXPECT_GE(res, res);
47     EXPECT_GE(res, Resolution(res.width - 1, res.height));
48     EXPECT_GE(res, Resolution(res.width, res.height - 1));
49 
50     EXPECT_FALSE(res >= Resolution(res.width + 1, res.height));
51     EXPECT_FALSE(res >= Resolution(res.width, res.height + 1));
52 
53     EXPECT_TRUE(res.isWithin(res, res));
54     EXPECT_TRUE(res.isWithin(Resolution(res.width - 1, res.height), res));
55     EXPECT_TRUE(res.isWithin(Resolution(res.width, res.height - 1), res));
56     EXPECT_TRUE(res.isWithin(res, Resolution(res.width + 1, res.height)));
57     EXPECT_TRUE(res.isWithin(res, Resolution(res.width, res.height + 1)));
58 
59     EXPECT_FALSE(res.isWithin(
60                      Resolution(res.width + 1, res.height),
61                      Resolution(res.width + 1, res.height + 1)));
62     EXPECT_FALSE(res.isWithin(
63                      Resolution(res.width, res.height + 1),
64                      Resolution(res.width + 1, res.height + 1)));
65     EXPECT_FALSE(res.isWithin(
66                      Resolution(res.width - 1, res.height - 1),
67                      Resolution(res.width - 1, res.height)));
68     EXPECT_FALSE(res.isWithin(
69                      Resolution(res.width - 1, res.height - 1),
70                      Resolution(res.width, res.height - 1)));
71 
72     // Verify different initializers
73     {
74         Resolution resolution{10, 100};
75         EXPECT_EQ(resolution.width, Resolution::DataType(10));
76         EXPECT_EQ(resolution.height, Resolution::DataType(100));
77     }
78     {
79         Resolution resolution = {10, 100};
80         EXPECT_EQ(resolution.width, Resolution::DataType(10));
81         EXPECT_EQ(resolution.height, Resolution::DataType(100));
82     }
83     {
84         std::vector<Resolution> resolutions{{10, 100}, {12, 15}};
85         ASSERT_EQ(resolutions.size(), 2u);
86         EXPECT_EQ(resolutions[0].width, Resolution::DataType(10));
87         EXPECT_EQ(resolutions[0].height, Resolution::DataType(100));
88         EXPECT_EQ(resolutions[1].width, Resolution::DataType(12));
89         EXPECT_EQ(resolutions[1].height, Resolution::DataType(15));
90     }
91     {
92         std::vector<Resolution> resolutions = {{10, 100}, {12, 15}};
93         ASSERT_EQ(resolutions.size(), 2u);
94         EXPECT_EQ(resolutions[0].width, Resolution::DataType(10));
95         EXPECT_EQ(resolutions[0].height, Resolution::DataType(100));
96         EXPECT_EQ(resolutions[1].width, Resolution::DataType(12));
97         EXPECT_EQ(resolutions[1].height, Resolution::DataType(15));
98     }
99 }
100