Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Side by Side Diff: mojo/system/memory_unittest.cc

Issue 603983003: Mojo: COMPILE_ASSERT -> static_assert in mojo/system and mojo/embedder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/system/local_data_pipe_unittest.cc ('k') | mojo/system/message_in_transit.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « mojo/system/local_data_pipe_unittest.cc ('k') | mojo/system/message_in_transit.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698