Vladimir Marko | d8dbc8d | 2017-09-20 13:37:47 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 "src_map_elem.h" |
| 20 | |
| 21 | #include "base/macros.h" |
| 22 | |
| 23 | namespace art { |
| 24 | namespace debug { |
| 25 | |
| 26 | TEST(SrcMapElem, Operators) { |
| 27 | SrcMapElem elems[] = { |
| 28 | { 1u, -1 }, |
| 29 | { 1u, 0 }, |
| 30 | { 1u, 1 }, |
| 31 | { 2u, -1 }, |
| 32 | { 2u, 0 }, // Index 4. |
| 33 | { 2u, 1 }, |
| 34 | { 2u, 0u }, // Index 6: Arbitrarily add identical SrcMapElem with index 4. |
| 35 | }; |
| 36 | |
| 37 | for (size_t i = 0; i != arraysize(elems); ++i) { |
| 38 | for (size_t j = 0; j != arraysize(elems); ++j) { |
| 39 | bool expected = (i != 6u ? i : 4u) == (j != 6u ? j : 4u); |
| 40 | EXPECT_EQ(expected, elems[i] == elems[j]) << i << " " << j; |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | for (size_t i = 0; i != arraysize(elems); ++i) { |
| 45 | for (size_t j = 0; j != arraysize(elems); ++j) { |
| 46 | bool expected = (i != 6u ? i : 4u) < (j != 6u ? j : 4u); |
| 47 | EXPECT_EQ(expected, elems[i] < elems[j]) << i << " " << j; |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | } // namespace debug |
| 53 | } // namespace art |