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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/http/http_util_icu.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 namespace net {
9
10 TEST(HttpUtilIcuTest, GenerateAcceptLanguageHeader) {
11 EXPECT_EQ(std::string("en-US,en;q=0.8,fr;q=0.6,de;q=0.4"),
12 http_util_icu::GenerateAcceptLanguageHeader("en-US,fr,de"));
13
14 // Test whitespace between language tags.
15 EXPECT_EQ(std::string("en-US,en;q=0.8,fr;q=0.6,de;q=0.4"),
16 http_util_icu::GenerateAcceptLanguageHeader("en-US, fr, de"));
17
18 // Test a language code is inserted after languageTag only if it is not
19 // already in the request language list
20 EXPECT_EQ(std::string("en-US,en;q=0.8,fr-FR;q=0.6,fr;q=0.4,zh-CN;q=0.2,"
21 "zh;q=0.2"),
22 http_util_icu::GenerateAcceptLanguageHeader("en-US,fr-FR,zh-CN"));
23
24 // Test a language code will not be inserted after languageTag if it is
25 // already in the request language list
26 EXPECT_EQ(
27 std::string("en-US,en;q=0.8,fr-FR;q=0.6,fr;q=0.4,zh-CN;q=0.2,"
28 "zh;q=0.2"),
29 http_util_icu::GenerateAcceptLanguageHeader("en-US,fr-FR,fr,zh-CN"));
30
31 // Make sure a language code is only inserted after the last languageTag that
32 // contains that language.
33 EXPECT_EQ(
34 std::string("en-US,en-GB;q=0.8,en;q=0.6,fr;q=0.4,zh-CN;q=0.2,"
35 "zh;q=0.2"),
36 http_util_icu::GenerateAcceptLanguageHeader("en-US,en-GB,fr,zh-CN"));
37 }
38 }
OLDNEW
« 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