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 // This file tests the C++ Mojo system macros and consists of "positive" tests, | 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 | 6 // i.e., those verifying that things work (without compile errors, or even |
7 // warnings if warnings are treated as errors). | 7 // warnings if warnings are treated as errors). |
8 // TODO(vtl): Maybe rename "MacrosCppTest" -> "MacrosTest" if/when this gets | 8 // TODO(vtl): Maybe rename "MacrosCppTest" -> "MacrosTest" if/when this gets |
9 // compiled into a different binary from the C API tests. | 9 // compiled into a different binary from the C API tests. |
10 // TODO(vtl): Fix no-compile tests (which are all disabled; crbug.com/105388) | 10 // TODO(vtl): Fix no-compile tests (which are all disabled; crbug.com/105388) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 y.NoOp(); | 60 y.NoOp(); |
61 } | 61 } |
62 | 62 |
63 // Test that |MOJO_ARRAYSIZE()| works in a |static_assert()|. | 63 // Test that |MOJO_ARRAYSIZE()| works in a |static_assert()|. |
64 const int kGlobalArray[5] = {1, 2, 3, 4, 5}; | 64 const int kGlobalArray[5] = {1, 2, 3, 4, 5}; |
65 static_assert(MOJO_ARRAYSIZE(kGlobalArray) == 5u, | 65 static_assert(MOJO_ARRAYSIZE(kGlobalArray) == 5u, |
66 "MOJO_ARRAY_SIZE() failed in static_assert()"); | 66 "MOJO_ARRAY_SIZE() failed in static_assert()"); |
67 | 67 |
68 TEST(MacrosCppTest, ArraySize) { | 68 TEST(MacrosCppTest, ArraySize) { |
69 double local_array[4] = {6.7, 7.8, 8.9, 9.0}; | 69 double local_array[4] = {6.7, 7.8, 8.9, 9.0}; |
| 70 MOJO_ALLOW_UNUSED_LOCAL(local_array); |
70 EXPECT_EQ(4u, MOJO_ARRAYSIZE(local_array)); | 71 EXPECT_EQ(4u, MOJO_ARRAYSIZE(local_array)); |
71 } | 72 } |
72 | 73 |
73 // Note: MSVS is very strict (and arguably buggy) about warnings for classes | 74 // Note: MSVS is very strict (and arguably buggy) about warnings for classes |
74 // defined in a local scope, so define these globally. | 75 // defined in a local scope, so define these globally. |
75 class MoveOnlyInt { | 76 class MoveOnlyInt { |
76 MOJO_MOVE_ONLY_TYPE_FOR_CPP_03(MoveOnlyInt, RValue) | 77 MOJO_MOVE_ONLY_TYPE_FOR_CPP_03(MoveOnlyInt, RValue) |
77 | 78 |
78 public: | 79 public: |
79 MoveOnlyInt() : is_set_(false), value_() {} | 80 MoveOnlyInt() : is_set_(false), value_() {} |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 EXPECT_FALSE(y.is_set()); | 117 EXPECT_FALSE(y.is_set()); |
117 EXPECT_TRUE(z.is_set()); | 118 EXPECT_TRUE(z.is_set()); |
118 EXPECT_EQ(123, z.value()); | 119 EXPECT_EQ(123, z.value()); |
119 z = z.Pass(); | 120 z = z.Pass(); |
120 EXPECT_TRUE(z.is_set()); | 121 EXPECT_TRUE(z.is_set()); |
121 EXPECT_EQ(123, z.value()); | 122 EXPECT_EQ(123, z.value()); |
122 } | 123 } |
123 | 124 |
124 } // namespace | 125 } // namespace |
125 } // namespace mojo | 126 } // namespace mojo |
OLD | NEW |