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

Unified Diff: mojo/public/cpp/bindings/tests/constant_unittest.cc

Issue 2637393002: Make mojom-generated C++ string constants really constant. (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | mojo/public/interfaces/bindings/tests/test_constants.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/tests/constant_unittest.cc
diff --git a/mojo/public/cpp/bindings/tests/constant_unittest.cc b/mojo/public/cpp/bindings/tests/constant_unittest.cc
index f6394f3a644dc9daed18ede0ae4b246146871e37..caa6464cf459eb069d03a3b671224459db29f7e7 100644
--- a/mojo/public/cpp/bindings/tests/constant_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/constant_unittest.cc
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <cmath>
+
+#include "base/strings/string_piece.h"
#include "mojo/public/interfaces/bindings/tests/test_constants.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -19,23 +22,38 @@ TEST(ConstantTest, GlobalConstants) {
static_assert(kUint32Value == 4294967295U, "");
static_assert(kInt64Value == -9223372036854775807, "");
static_assert(kUint64Value == 9999999999999999999ULL, "");
-
- EXPECT_DOUBLE_EQ(kDoubleValue, 3.14159);
- EXPECT_FLOAT_EQ(kFloatValue, 2.71828f);
+ static_assert(kDoubleValue == 3.14159, "");
+ static_assert(kFloatValue == 2.71828f, "");
+
+ EXPECT_EQ(base::StringPiece(kStringValue), "test string contents");
+ EXPECT_TRUE(std::isnan(kDoubleNaN));
+ EXPECT_TRUE(std::isinf(kDoubleInfinity));
+ EXPECT_TRUE(std::isinf(kDoubleNegativeInfinity));
+ EXPECT_NE(kDoubleInfinity, kDoubleNegativeInfinity);
+ EXPECT_TRUE(std::isnan(kFloatNaN));
+ EXPECT_TRUE(std::isinf(kFloatInfinity));
+ EXPECT_TRUE(std::isinf(kFloatNegativeInfinity));
+ EXPECT_NE(kFloatInfinity, kFloatNegativeInfinity);
}
TEST(ConstantTest, StructConstants) {
// Compile-time constants.
static_assert(StructWithConstants::kInt8Value == 5U, "");
+ static_assert(StructWithConstants::kFloatValue == 765.432f, "");
- EXPECT_FLOAT_EQ(StructWithConstants::kFloatValue, 765.432f);
+ EXPECT_EQ(base::StringPiece(StructWithConstants::kStringValue),
+ "struct test string contents");
}
TEST(ConstantTest, InterfaceConstants) {
// Compile-time constants.
static_assert(InterfaceWithConstants::kUint32Value == 20100722, "");
+ static_assert(InterfaceWithConstants::kDoubleValue == 12.34567, "");
- EXPECT_DOUBLE_EQ(InterfaceWithConstants::kDoubleValue, 12.34567);
+ EXPECT_EQ(base::StringPiece(InterfaceWithConstants::kStringValue),
+ "interface test string contents");
+ EXPECT_EQ(base::StringPiece(InterfaceWithConstants::Name_),
+ "mojo::test::InterfaceWithConstants");
}
} // namespace test
« no previous file with comments | « no previous file | mojo/public/interfaces/bindings/tests/test_constants.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698