Blender V4.3
tuple_test.cc
Go to the documentation of this file.
1// Copyright (c) 2007, 2008 libmv authors.
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to
5// deal in the Software without restriction, including without limitation the
6// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7// sell copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19// IN THE SOFTWARE.
20
21#include "libmv/image/tuple.h"
22#include "testing/testing.h"
23
24#include <algorithm>
25
26using libmv::Tuple;
27
28namespace {
29
30TEST(Tuple, InitConstantValue) {
31 Tuple<int, 3> t(5);
32 EXPECT_EQ(t(0), 5);
33 EXPECT_EQ(t(0), 5);
34 EXPECT_EQ(t(0), 5);
35}
36
37TEST(Tuple, InitFromPointer) {
38 float vals[3] = {1.0f, 2.0f, 3.0f};
39
40 Tuple<float, 3> t(vals);
41 for (int i = 0; i < 3; i++) {
42 EXPECT_EQ(t(i), vals[i]);
43 }
44
46 EXPECT_EQ(b(0), int(vals[0]));
47 EXPECT_EQ(b(1), int(vals[1]));
48 EXPECT_EQ(b(2), int(vals[2]));
49}
50
51TEST(Tuple, Swap) {
52 unsigned char vala[3] = {1, 2, 3};
53 unsigned char valb[3] = {4, 5, 6};
54
57
58 std::swap(a, b);
59
60 EXPECT_EQ(a(0), int(valb[0]));
61 EXPECT_EQ(a(1), int(valb[1]));
62 EXPECT_EQ(a(2), int(valb[2]));
63 EXPECT_EQ(b(0), int(vala[0]));
64 EXPECT_EQ(b(1), int(vala[1]));
65 EXPECT_EQ(b(2), int(vala[2]));
66}
67
68TEST(Tuple, IsEqualOperator) {
70 a(0) = 1;
71 a(1) = 2;
72 a(2) = 3;
74 b(0) = 1;
75 b(1) = 2;
76 b(2) = 3;
77 EXPECT_TRUE(a == b);
78 EXPECT_FALSE(a != b);
79 b(1) = 5;
80 EXPECT_TRUE(a != b);
81 EXPECT_FALSE(a == b);
82}
83
84} // namespace
TEST(array_store, Nop)
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
local_group_size(16, 16) .push_constant(Type b