OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Crashpad Authors. All rights reserved. |
| 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. |
| 14 |
| 15 #include "util/misc/arraysize_unsafe.h" |
| 16 |
| 17 #include "base/compiler_specific.h" |
| 18 #include "gtest/gtest.h" |
| 19 |
| 20 namespace crashpad { |
| 21 namespace test { |
| 22 namespace { |
| 23 |
| 24 TEST(ArraySizeUnsafe, ArraySizeUnsafe) { |
| 25 char c1[1]; |
| 26 static_assert(ARRAYSIZE_UNSAFE(c1) == 1, "c1"); |
| 27 ALLOW_UNUSED_LOCAL(c1); |
| 28 |
| 29 char c2[2]; |
| 30 static_assert(ARRAYSIZE_UNSAFE(c2) == 2, "c2"); |
| 31 ALLOW_UNUSED_LOCAL(c2); |
| 32 |
| 33 char c4[4]; |
| 34 static_assert(ARRAYSIZE_UNSAFE(c4) == 4, "c4"); |
| 35 ALLOW_UNUSED_LOCAL(c4); |
| 36 |
| 37 int i1[1]; |
| 38 static_assert(ARRAYSIZE_UNSAFE(i1) == 1, "i1"); |
| 39 ALLOW_UNUSED_LOCAL(i1); |
| 40 |
| 41 int i2[2]; |
| 42 static_assert(ARRAYSIZE_UNSAFE(i2) == 2, "i2"); |
| 43 ALLOW_UNUSED_LOCAL(i2); |
| 44 |
| 45 int i4[4]; |
| 46 static_assert(ARRAYSIZE_UNSAFE(i4) == 4, "i4"); |
| 47 ALLOW_UNUSED_LOCAL(i4); |
| 48 |
| 49 long l8[8]; |
| 50 static_assert(ARRAYSIZE_UNSAFE(l8) == 8, "l8"); |
| 51 ALLOW_UNUSED_LOCAL(l8); |
| 52 |
| 53 int l9[9]; |
| 54 static_assert(ARRAYSIZE_UNSAFE(l9) == 9, "l9"); |
| 55 ALLOW_UNUSED_LOCAL(l9); |
| 56 |
| 57 struct S { |
| 58 char c; |
| 59 int i; |
| 60 long l; |
| 61 bool b; |
| 62 }; |
| 63 |
| 64 S s1[1]; |
| 65 static_assert(ARRAYSIZE_UNSAFE(s1) == 1, "s1"); |
| 66 ALLOW_UNUSED_LOCAL(s1); |
| 67 |
| 68 S s10[10]; |
| 69 static_assert(ARRAYSIZE_UNSAFE(s10) == 10, "s10"); |
| 70 ALLOW_UNUSED_LOCAL(s10); |
| 71 } |
| 72 |
| 73 } // namespace |
| 74 } // namespace test |
| 75 } // namespace crashpad |
OLD | NEW |