| Adam Lesinski | f90f2f8d | 2014-06-06 14:27:00 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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 | |
| Adam Lesinski | 4c67a47 | 2016-11-10 16:43:59 -0800 | [diff] [blame] | 17 | #include "androidfw/ByteBucketArray.h" |
| Adam Lesinski | f90f2f8d | 2014-06-06 14:27:00 -0700 | [diff] [blame] | 18 | |
| Adam Lesinski | 4c67a47 | 2016-11-10 16:43:59 -0800 | [diff] [blame] | 19 | #include "gtest/gtest.h" |
| Adam Lesinski | f90f2f8d | 2014-06-06 14:27:00 -0700 | [diff] [blame] | 20 | |
| Adam Lesinski | 4c67a47 | 2016-11-10 16:43:59 -0800 | [diff] [blame] | 21 | namespace android { |
| Adam Lesinski | f90f2f8d | 2014-06-06 14:27:00 -0700 | [diff] [blame] | 22 | |
| 23 | TEST(ByteBucketArrayTest, TestSparseInsertion) { |
| Adam Lesinski | 4c67a47 | 2016-11-10 16:43:59 -0800 | [diff] [blame] | 24 | ByteBucketArray<int> bba; |
| 25 | ASSERT_TRUE(bba.set(0, 1)); |
| 26 | ASSERT_TRUE(bba.set(10, 2)); |
| 27 | ASSERT_TRUE(bba.set(26, 3)); |
| 28 | ASSERT_TRUE(bba.set(129, 4)); |
| 29 | ASSERT_TRUE(bba.set(234, 5)); |
| Adam Lesinski | f90f2f8d | 2014-06-06 14:27:00 -0700 | [diff] [blame] | 30 | |
| Adam Lesinski | 4c67a47 | 2016-11-10 16:43:59 -0800 | [diff] [blame] | 31 | for (size_t i = 0; i < bba.size(); i++) { |
| 32 | switch (i) { |
| 33 | case 0: |
| 34 | EXPECT_EQ(1, bba[i]); |
| 35 | break; |
| 36 | case 10: |
| 37 | EXPECT_EQ(2, bba[i]); |
| 38 | break; |
| 39 | case 26: |
| 40 | EXPECT_EQ(3, bba[i]); |
| 41 | break; |
| 42 | case 129: |
| 43 | EXPECT_EQ(4, bba[i]); |
| 44 | break; |
| 45 | case 234: |
| 46 | EXPECT_EQ(5, bba[i]); |
| 47 | break; |
| 48 | default: |
| 49 | EXPECT_EQ(0, bba[i]); |
| 50 | break; |
| Adam Lesinski | f90f2f8d | 2014-06-06 14:27:00 -0700 | [diff] [blame] | 51 | } |
| Adam Lesinski | 4c67a47 | 2016-11-10 16:43:59 -0800 | [diff] [blame] | 52 | } |
| Adam Lesinski | f90f2f8d | 2014-06-06 14:27:00 -0700 | [diff] [blame] | 53 | } |
| Adam Lesinski | 4c67a47 | 2016-11-10 16:43:59 -0800 | [diff] [blame] | 54 | |
| 55 | } // namespace android |