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

Unified Diff: net/http/http_util_icu_unittest.cc

Issue 2559243003: Extend with a language code in http accept languages
Patch Set: Rebased, fixed nits and handed over this CL :( Created 4 years 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 | « net/http/http_util_icu.cc ('k') | net/http/http_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_util_icu_unittest.cc
diff --git a/net/http/http_util_icu_unittest.cc b/net/http/http_util_icu_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5775dd059ac35479f90ade63c205d40ea361fc30
--- /dev/null
+++ b/net/http/http_util_icu_unittest.cc
@@ -0,0 +1,38 @@
+// Copyright (c) 2016 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 "net/http/http_util_icu.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+
+TEST(HttpUtilIcuTest, GenerateAcceptLanguageHeader) {
+ EXPECT_EQ(std::string("en-US,en;q=0.8,fr;q=0.6,de;q=0.4"),
+ http_util_icu::GenerateAcceptLanguageHeader("en-US,fr,de"));
+
+ // Test whitespace between language tags.
+ EXPECT_EQ(std::string("en-US,en;q=0.8,fr;q=0.6,de;q=0.4"),
+ http_util_icu::GenerateAcceptLanguageHeader("en-US, fr, de"));
+
+ // Test a language code is inserted after languageTag only if it is not
+ // already in the request language list
+ EXPECT_EQ(std::string("en-US,en;q=0.8,fr-FR;q=0.6,fr;q=0.4,zh-CN;q=0.2,"
+ "zh;q=0.2"),
+ http_util_icu::GenerateAcceptLanguageHeader("en-US,fr-FR,zh-CN"));
+
+ // Test a language code will not be inserted after languageTag if it is
+ // already in the request language list
+ EXPECT_EQ(
+ std::string("en-US,en;q=0.8,fr-FR;q=0.6,fr;q=0.4,zh-CN;q=0.2,"
+ "zh;q=0.2"),
+ http_util_icu::GenerateAcceptLanguageHeader("en-US,fr-FR,fr,zh-CN"));
+
+ // Make sure a language code is only inserted after the last languageTag that
+ // contains that language.
+ EXPECT_EQ(
+ std::string("en-US,en-GB;q=0.8,en;q=0.6,fr;q=0.4,zh-CN;q=0.2,"
+ "zh;q=0.2"),
+ http_util_icu::GenerateAcceptLanguageHeader("en-US,en-GB,fr,zh-CN"));
+}
+}
« no previous file with comments | « net/http/http_util_icu.cc ('k') | net/http/http_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698