1 /*
2  * Copyright (C) 2013 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "gtest/gtest.h"
18 
19 #include <utility>  // std::forward
20 
21 #include "berberis/intrinsics/simd_register.h"
22 
23 namespace berberis {
24 
25 namespace {
26 
27 constexpr Int64x2 kLhs = {0x5555'5555'5555'5555, 0x5555'5555'5555'5555};
28 constexpr Int64x2 kRhs = {0x3333'3333'3333'3333, 0x3333'3333'3333'3333};
29 
TEST(SIMD_REGISTER,TestEq)30 TEST(SIMD_REGISTER, TestEq) {
31   SIMD128Register lhs = kLhs;
32   ASSERT_EQ(lhs, lhs);
33   ASSERT_EQ(lhs, kLhs);
34   ASSERT_EQ(kLhs, lhs);
35 }
36 
TEST(SIMD_REGISTER,TestNe)37 TEST(SIMD_REGISTER, TestNe) {
38   SIMD128Register lhs = kLhs;
39   SIMD128Register rhs = kRhs;
40   ASSERT_NE(lhs, rhs);
41   ASSERT_NE(lhs, kRhs);
42   ASSERT_NE(kLhs, rhs);
43 }
44 
TEST(SIMD_REGISTER,TestAnd)45 TEST(SIMD_REGISTER, TestAnd) {
46   SIMD128Register lhs = kLhs;
47   SIMD128Register rhs = kRhs;
48   SIMD128Register result = Int64x2{0x1111'1111'1111'1111, 0x1111'1111'1111'1111};
49   ASSERT_EQ(lhs & rhs, result);
50 }
51 
TEST(SIMD_REGISTER,TestNot)52 TEST(SIMD_REGISTER, TestNot) {
53   SIMD128Register lhs = kLhs;
54   SIMD128Register result = Int64x2{-0x5555'5555'5555'5556, -0x5555'5555'5555'5556};
55   ASSERT_EQ(~lhs, result);
56 }
57 
TEST(SIMD_REGISTER,TestOr)58 TEST(SIMD_REGISTER, TestOr) {
59   SIMD128Register lhs = kLhs;
60   SIMD128Register rhs = kRhs;
61   SIMD128Register result = Int64x2{0x7777'7777'7777'7777, 0x7777'7777'7777'7777};
62   ASSERT_EQ(lhs | rhs, result);
63 }
64 
TEST(SIMD_REGISTER,TestXor)65 TEST(SIMD_REGISTER, TestXor) {
66   SIMD128Register lhs = kLhs;
67   SIMD128Register rhs = kRhs;
68   SIMD128Register result = Int64x2{0x6666'6666'6666'6666, 0x6666'6666'6666'6666};
69   ASSERT_EQ(lhs ^ rhs, result);
70 }
71 
72 }  // namespace
73 
74 }  // namespace berberis
75