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

Side by Side Diff: chrome/renderer/translate_helper_unittest.cc

Issue 12221085: Translate: split language code typo correction to apply unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unit test version Created 7 years, 10 months 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 | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/translate_helper.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/translate_helper.h" 5 #include "chrome/renderer/translate_helper.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 typedef testing::Test TranslateHelperTest; 9 typedef testing::Test TranslateHelperTest;
10 10
11 // Tests that well-known language code typos are fixed.
12 TEST_F(TranslateHelperTest, LanguageCodeTypoCorrection) {
13 std::string language;
14
15 // Strip the second and later codes.
16 language = std::string("ja,en");
17 TranslateHelper::CorrectLanguageCodeTypo(&language);
18 EXPECT_EQ(0, language.compare("ja"));
sky 2013/02/12 17:30:07 EXPECT_EQ("ja", language) same pattern for other t
Takashi Toyoshima 2013/02/14 08:00:18 Done.
19
20 // Replace dash with hyphen.
21 language = std::string("ja_JP");
22 TranslateHelper::CorrectLanguageCodeTypo(&language);
23 EXPECT_EQ(0, language.compare("ja-JP"));
24
25 // Correct wrong cases.
26 language = std::string("JA-jp");
27 TranslateHelper::CorrectLanguageCodeTypo(&language);
28 EXPECT_EQ(0, language.compare("ja-JP"));
29 }
30
11 // Tests that synonym language code is converted to one used in supporting list. 31 // Tests that synonym language code is converted to one used in supporting list.
12 TEST_F(TranslateHelperTest, LanguageCodeSynonyms) { 32 TEST_F(TranslateHelperTest, LanguageCodeSynonyms) {
13 std::string language; 33 std::string language;
14 34
15 language = std::string("nb"); 35 language = std::string("nb");
16 TranslateHelper::ConvertLanguageCodeSynonym(&language); 36 TranslateHelper::ConvertLanguageCodeSynonym(&language);
17 EXPECT_EQ(0, language.compare("no")); 37 EXPECT_EQ(0, language.compare("no"));
18 38
19 language = std::string("he"); 39 language = std::string("he");
20 TranslateHelper::ConvertLanguageCodeSynonym(&language); 40 TranslateHelper::ConvertLanguageCodeSynonym(&language);
21 EXPECT_EQ(0, language.compare("iw")); 41 EXPECT_EQ(0, language.compare("iw"));
22 42
23 language = std::string("jv"); 43 language = std::string("jv");
24 TranslateHelper::ConvertLanguageCodeSynonym(&language); 44 TranslateHelper::ConvertLanguageCodeSynonym(&language);
25 EXPECT_EQ(0, language.compare("jw")); 45 EXPECT_EQ(0, language.compare("jw"));
26 46
27 language = std::string("fil"); 47 language = std::string("fil");
28 TranslateHelper::ConvertLanguageCodeSynonym(&language); 48 TranslateHelper::ConvertLanguageCodeSynonym(&language);
29 EXPECT_EQ(0, language.compare("tl")); 49 EXPECT_EQ(0, language.compare("tl"));
30 } 50 }
OLDNEW
« no previous file with comments | « chrome/renderer/translate_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698