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

Unified Diff: mojo/common/common_type_converters_unittest.cc

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/common/common_type_converters.cc ('k') | mojo/common/dart/.packages » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/common/common_type_converters_unittest.cc
diff --git a/mojo/common/common_type_converters_unittest.cc b/mojo/common/common_type_converters_unittest.cc
deleted file mode 100644
index cffd1a617c8f9ded54547be5ce578195d70dbe3c..0000000000000000000000000000000000000000
--- a/mojo/common/common_type_converters_unittest.cc
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/common/common_type_converters.h"
-
-#include "base/strings/utf_string_conversions.h"
-#include "mojo/common/url_type_converters.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "url/gurl.h"
-
-namespace mojo {
-namespace common {
-namespace test {
-namespace {
-
-void ExpectEqualsStringPiece(const std::string& expected,
- const base::StringPiece& str) {
- EXPECT_EQ(expected, str.as_string());
-}
-
-void ExpectEqualsMojoString(const std::string& expected,
- const String& str) {
- EXPECT_EQ(expected, str.get());
-}
-
-void ExpectEqualsString16(const base::string16& expected,
- const base::string16& actual) {
- EXPECT_EQ(expected, actual);
-}
-
-void ExpectEqualsMojoString(const base::string16& expected,
- const String& str) {
- EXPECT_EQ(expected, str.To<base::string16>());
-}
-
-} // namespace
-
-TEST(CommonTypeConvertersTest, StringPiece) {
- std::string kText("hello world");
-
- base::StringPiece string_piece(kText);
- String mojo_string(String::From(string_piece));
-
- ExpectEqualsMojoString(kText, mojo_string);
- ExpectEqualsStringPiece(kText, mojo_string.To<base::StringPiece>());
-
- // Test implicit construction and conversion:
- ExpectEqualsMojoString(kText, String::From(string_piece));
- ExpectEqualsStringPiece(kText, mojo_string.To<base::StringPiece>());
-
- // Test null String:
- base::StringPiece empty_string_piece = String().To<base::StringPiece>();
- EXPECT_TRUE(empty_string_piece.empty());
-}
-
-TEST(CommonTypeConvertersTest, String16) {
- const base::string16 string16(base::ASCIIToUTF16("hello world"));
- const String mojo_string(String::From(string16));
-
- ExpectEqualsMojoString(string16, mojo_string);
- EXPECT_EQ(string16, mojo_string.To<base::string16>());
-
- // Test implicit construction and conversion:
- ExpectEqualsMojoString(string16, String::From(string16));
- ExpectEqualsString16(string16, mojo_string.To<base::string16>());
-
- // Test empty string conversion.
- ExpectEqualsMojoString(base::string16(), String::From(base::string16()));
-}
-
-TEST(CommonTypeConvertersTest, URL) {
- GURL url("mojo:foo");
- String mojo_string(String::From(url));
-
- ASSERT_EQ(url.spec(), mojo_string);
- EXPECT_EQ(url.spec(), mojo_string.To<GURL>().spec());
- EXPECT_EQ(url.spec(), String::From(url));
-
- GURL invalid = String().To<GURL>();
- ASSERT_TRUE(invalid.spec().empty());
-
- String string_from_invalid = String::From(invalid);
- EXPECT_FALSE(string_from_invalid.is_null());
- ASSERT_EQ(0U, string_from_invalid.size());
-}
-
-TEST(CommonTypeConvertersTest, ArrayUint8ToStdString) {
- Array<uint8_t> data(4);
- data[0] = 'd';
- data[1] = 'a';
- data[2] = 't';
- data[3] = 'a';
-
- EXPECT_EQ("data", data.To<std::string>());
-}
-
-TEST(CommonTypeConvertersTest, StdStringToArrayUint8) {
- std::string input("data");
- Array<uint8_t> data = Array<uint8_t>::From(input);
-
- ASSERT_EQ(4ul, data.size());
- EXPECT_EQ('d', data[0]);
- EXPECT_EQ('a', data[1]);
- EXPECT_EQ('t', data[2]);
- EXPECT_EQ('a', data[3]);
-}
-
-} // namespace test
-} // namespace common
-} // namespace mojo
« no previous file with comments | « mojo/common/common_type_converters.cc ('k') | mojo/common/dart/.packages » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698