summaryrefslogtreecommitdiffstats
path: root/base/i18n/case_conversion_unittest.cc
blob: 87a349ebda2eadbdc2ecf64984c0206f0acc0921 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (c) 2011 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 "base/i18n/case_conversion.h"
#include "base/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {

// Test upper and lower case string conversion.
TEST(CaseConversionTest, UpperLower) {
  string16 mixed(ASCIIToUTF16("Text with UPPer & lowER casE."));
  const string16 expected_lower(ASCIIToUTF16("text with upper & lower case."));
  const string16 expected_upper(ASCIIToUTF16("TEXT WITH UPPER & LOWER CASE."));

  string16 result = base::i18n::ToLower(mixed);
  EXPECT_EQ(expected_lower, result);

  result = base::i18n::ToUpper(mixed);
  EXPECT_EQ(expected_upper, result);
}

// Test upper and lower case string conversion.
TEST(CaseConversionTest, WideUpperLower) {
  std::wstring mixed(L"Text with UPPer & lowER casE.");
  const std::wstring expected_lower(L"text with upper & lower case.");
  const std::wstring expected_upper(L"TEXT WITH UPPER & LOWER CASE.");

  std::wstring result = base::i18n::WideToLower(mixed);
  EXPECT_EQ(expected_lower, result);

  result = base::i18n::WideToUpper(mixed);
  EXPECT_EQ(expected_upper, result);
}

// TODO(jshin): More tests are needed, especially with non-ASCII characters.

}  // namespace