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

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 separate Generate AcceptLanguage Header from http_util 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) 2012 The Chromium Authors. All rights reserved.
Seigo Nonaka 2016/12/12 01:48:54 2016
Yirui Huang 2016/12/12 06:50:41 Done.
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 <algorithm>
Seigo Nonaka 2016/12/12 01:48:54 remove?
Yirui Huang 2016/12/12 06:50:41 Done.
6 #include <limits>
Seigo Nonaka 2016/12/12 01:48:54 remove?
Yirui Huang 2016/12/12 06:50:41 Done.
7
8 #include "base/strings/string_util.h"
Seigo Nonaka 2016/12/12 01:48:54 remove?
Yirui Huang 2016/12/12 06:50:41 Done.
9 #include "net/http/http_util_icu.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace net {
13
14 namespace {
15 class HttpUtilIcuTest : public testing::Test {};
Seigo Nonaka 2016/12/12 01:48:54 Not necessary. Please remove this class declaratio
Yirui Huang 2016/12/12 06:50:41 Done.
16 }
17
18 TEST(HttpUtilIcuTest, GenerateAcceptLanguageHeader) {
19 EXPECT_EQ(std::string("en-US,en;q=0.8,fr;q=0.6,de;q=0.4"),
20 HttpUtilIcu::GenerateAcceptLanguageHeader("en-US,fr,de"));
21
22 // Test whitespace between language tags.
23 EXPECT_EQ(std::string("en-US,en;q=0.8,fr;q=0.6,de;q=0.4"),
24 HttpUtilIcu::GenerateAcceptLanguageHeader("en-US, fr, de"));
25
26 // Test a language code is inserted after languageTag only if it is not
27 // already in the request language list
28 EXPECT_EQ(std::string("en-US,en;q=0.8,fr-FR;q=0.6,fr;q=0.4,zh-CN;q=0.2,"
29 "zh;q=0.2"),
30 HttpUtilIcu::GenerateAcceptLanguageHeader("en-US,fr-FR,zh-CN"));
31
32 // Test a language code will not be inserted after languageTag if it is
33 // already in the request language list
34 EXPECT_EQ(std::string("en-US,en;q=0.8,fr-FR;q=0.6,fr;q=0.4,zh-CN;q=0.2,"
35 "zh;q=0.2"),
36 HttpUtilIcu::GenerateAcceptLanguageHeader("en-US,fr-FR,fr,zh-CN"));
37
38 // Make sure a language code is only inserted after the last languageTag that
39 // contains that language.
40 EXPECT_EQ(std::string("en-US,en-GB;q=0.8,en;q=0.6,fr;q=0.4,zh-CN;q=0.2,"
41 "zh;q=0.2"),
42 HttpUtilIcu::GenerateAcceptLanguageHeader("en-US,en-GB,fr,zh-CN"));
43 }
44 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698