OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/system/memory.h" | 5 #include "mojo/system/memory.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <limits> | 10 #include <limits> |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 } | 162 } |
163 | 163 |
164 TEST(MemoryTest, InvalidDeath) { | 164 TEST(MemoryTest, InvalidDeath) { |
165 const char kMemoryCheckFailedRegex[] = "Check failed"; | 165 const char kMemoryCheckFailedRegex[] = "Check failed"; |
166 | 166 |
167 // Note: |Check...()| are defined to be "best effort" checks (and may always | 167 // Note: |Check...()| are defined to be "best effort" checks (and may always |
168 // return true). Thus these tests of invalid cases only reflect the current | 168 // return true). Thus these tests of invalid cases only reflect the current |
169 // implementation. | 169 // implementation. |
170 | 170 |
171 // These tests depend on |int32_t| and |int64_t| having nontrivial alignment. | 171 // These tests depend on |int32_t| and |int64_t| having nontrivial alignment. |
172 MOJO_COMPILE_ASSERT(MOJO_ALIGNOF(int32_t) != 1, | 172 static_assert(MOJO_ALIGNOF(int32_t) != 1, |
173 int32_t_does_not_have_to_be_aligned); | 173 "int32_t does not require nontrivial alignment"); |
174 MOJO_COMPILE_ASSERT(MOJO_ALIGNOF(int64_t) != 1, | 174 static_assert(MOJO_ALIGNOF(int64_t) != 1, |
175 int64_t_does_not_have_to_be_aligned); | 175 "int64_t does not require nontrivial alignment"); |
176 | 176 |
177 // Null: | 177 // Null: |
178 { | 178 { |
179 UserPointer<char> ptr(nullptr); | 179 UserPointer<char> ptr(nullptr); |
180 char array[5] = {}; | 180 char array[5] = {}; |
181 EXPECT_DEATH_IF_SUPPORTED(ptr.Check(), kMemoryCheckFailedRegex); | 181 EXPECT_DEATH_IF_SUPPORTED(ptr.Check(), kMemoryCheckFailedRegex); |
182 EXPECT_DEATH_IF_SUPPORTED(ptr.Get(), kMemoryCheckFailedRegex); | 182 EXPECT_DEATH_IF_SUPPORTED(ptr.Get(), kMemoryCheckFailedRegex); |
183 EXPECT_DEATH_IF_SUPPORTED(ptr.Put('x'), kMemoryCheckFailedRegex); | 183 EXPECT_DEATH_IF_SUPPORTED(ptr.Put('x'), kMemoryCheckFailedRegex); |
184 EXPECT_DEATH_IF_SUPPORTED(ptr.CheckArray(5), kMemoryCheckFailedRegex); | 184 EXPECT_DEATH_IF_SUPPORTED(ptr.CheckArray(5), kMemoryCheckFailedRegex); |
185 EXPECT_DEATH_IF_SUPPORTED(ptr.GetArray(array, 5), kMemoryCheckFailedRegex); | 185 EXPECT_DEATH_IF_SUPPORTED(ptr.GetArray(array, 5), kMemoryCheckFailedRegex); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 EXPECT_DEATH_IF_SUPPORTED(ptr.GetArray(&x, kTooBig), | 285 EXPECT_DEATH_IF_SUPPORTED(ptr.GetArray(&x, kTooBig), |
286 kMemoryCheckFailedRegex); | 286 kMemoryCheckFailedRegex); |
287 } | 287 } |
288 | 288 |
289 // TODO(vtl): Tests for |UserPointer{Reader,Writer,ReaderWriter}|. | 289 // TODO(vtl): Tests for |UserPointer{Reader,Writer,ReaderWriter}|. |
290 } | 290 } |
291 | 291 |
292 } // namespace | 292 } // namespace |
293 } // namespace system | 293 } // namespace system |
294 } // namespace mojo | 294 } // namespace mojo |
OLD | NEW |