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

Side by Side Diff: mojo/public/c/tests/system/macros_unittest.cc

Issue 218023002: Mojo: Move mojo/public/{c,cpp}/tests/FOO to mojo/public/{c,cpp}/FOO/tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « mojo/public/c/tests/system/core_unittest_pure_c.c ('k') | mojo/public/cpp/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // This file tests the C Mojo system macros and consists of "positive" tests,
6 // i.e., those verifying that things work (without compile errors, or even
7 // warnings if warnings are treated as errors).
8 // TODO(vtl): Fix no-compile tests (which are all disabled; crbug.com/105388)
9 // and write some "negative" tests.
10
11 #include "mojo/public/c/system/macros.h"
12
13 #include <assert.h>
14 #include <stdint.h>
15 #include <stdlib.h>
16
17 #include "testing/gtest/include/gtest/gtest.h"
18
19 namespace mojo {
20 namespace {
21
22 TEST(MacrosTest, AllowUnused) {
23 // Test that no warning/error is issued even though |x| is unused.
24 int x MOJO_ALLOW_UNUSED = 123;
25 }
26
27 int MustUseReturnedResult() MOJO_WARN_UNUSED_RESULT;
28 int MustUseReturnedResult() {
29 return 456;
30 }
31
32 TEST(MacrosTest, WarnUnusedResult) {
33 if (!MustUseReturnedResult())
34 abort();
35 }
36
37 // First test |MOJO_COMPILE_ASSERT()| in a global scope.
38 MOJO_COMPILE_ASSERT(sizeof(int64_t) == 2 * sizeof(int32_t),
39 bad_compile_assert_failure_in_global_scope);
40
41 TEST(MacrosTest, CompileAssert) {
42 // Then in a local scope.
43 MOJO_COMPILE_ASSERT(sizeof(int32_t) == 2 * sizeof(int16_t),
44 bad_compile_assert_failure);
45 }
46
47 } // namespace
48 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/c/tests/system/core_unittest_pure_c.c ('k') | mojo/public/cpp/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698