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

Side by Side Diff: net/http/http_util_icu_unittest.cc

Issue 2559243003: Extend with a language code in http accept languages
Patch Set: Removed unnecessary imports and checked develop path 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
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 HttpUtilIcu::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 HttpUtilIcu::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 HttpUtilIcu::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(std::string("en-US,en;q=0.8,fr-FR;q=0.6,fr;q=0.4,zh-CN;q=0.2,"
27 "zh;q=0.2"),
28 HttpUtilIcu::GenerateAcceptLanguageHeader("en-US,fr-FR,fr,zh-CN"));
29
30 // Make sure a language code is only inserted after the last languageTag that
31 // contains that language.
32 EXPECT_EQ(std::string("en-US,en-GB;q=0.8,en;q=0.6,fr;q=0.4,zh-CN;q=0.2,"
33 "zh;q=0.2"),
34 HttpUtilIcu::GenerateAcceptLanguageHeader("en-US,en-GB,fr,zh-CN"));
35 }
36 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698