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

Unified Diff: url/url_test_utils.h

Issue 2469133002: Clean up URL test string conversions. (Closed)
Patch Set: More Created 4 years, 1 month 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 | « url/url_canon_unittest.cc ('k') | url/url_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: url/url_test_utils.h
diff --git a/url/url_test_utils.h b/url/url_test_utils.h
index 156c428ad7eb60618b1b3955c6104cdb7060e89e..f4f51da4eb48d12c51c95aebe4f1f63c7dc888a6 100644
--- a/url/url_test_utils.h
+++ b/url/url_test_utils.h
@@ -11,6 +11,7 @@
#include <string>
#include "base/strings/string16.h"
+#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/url_canon_internal.h"
@@ -18,10 +19,12 @@ namespace url {
namespace test_utils {
-// Converts a UTF-16 string from native wchar_t format to char16, by
-// truncating the high 32 bits. This is not meant to handle true UTF-32
-// encoded strings.
-inline base::string16 WStringToUTF16(const wchar_t* src) {
+// Converts a UTF-16 string from native wchar_t format to char16 by
+// truncating the high 32 bits. This is different than the conversion function
+// in base bacause it passes invalid UTF-16 characters which is important for
+// test purposes. As a result, this is not meant to handle true UTF-32 encoded
+// strings.
+inline base::string16 TruncateWStringToUTF16(const wchar_t* src) {
base::string16 str;
int length = static_cast<int>(wcslen(src));
for (int i = 0; i < length; ++i) {
@@ -30,25 +33,6 @@ inline base::string16 WStringToUTF16(const wchar_t* src) {
return str;
}
-// Converts a string from UTF-8 to UTF-16.
-inline base::string16 ConvertUTF8ToUTF16(const std::string& src) {
- int length = static_cast<int>(src.length());
- EXPECT_LT(length, 1024);
- RawCanonOutputW<1024> output;
- EXPECT_TRUE(ConvertUTF8ToUTF16(src.data(), length, &output));
- return base::string16(output.data(), output.length());
-}
-
-// Converts a string from UTF-16 to UTF-8.
-inline std::string ConvertUTF16ToUTF8(const base::string16& src) {
- std::string str;
- StdStringCanonOutput output(&str);
- EXPECT_TRUE(ConvertUTF16ToUTF8(src.data(), static_cast<int>(src.length()),
- &output));
- output.Complete();
- return str;
-}
-
} // namespace test_utils
} // namespace url
« no previous file with comments | « url/url_canon_unittest.cc ('k') | url/url_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698