• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 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 "base/strings/char_traits.h"
6 #include "base/strings/string16.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8 
9 namespace base {
10 
TEST(CharTraitsTest,CharCompare)11 TEST(CharTraitsTest, CharCompare) {
12   static_assert(CharTraits<char>::compare("abc", "def", 3) == -1, "");
13   static_assert(CharTraits<char>::compare("def", "def", 3) == 0, "");
14   static_assert(CharTraits<char>::compare("ghi", "def", 3) == 1, "");
15 }
16 
TEST(CharTraitsTest,CharLength)17 TEST(CharTraitsTest, CharLength) {
18   static_assert(CharTraits<char>::length("") == 0, "");
19   static_assert(CharTraits<char>::length("abc") == 3, "");
20 }
21 
TEST(CharTraitsTest,Char16TCompare)22 TEST(CharTraitsTest, Char16TCompare) {
23   static_assert(CharTraits<char16_t>::compare(u"abc", u"def", 3) == -1, "");
24   static_assert(CharTraits<char16_t>::compare(u"def", u"def", 3) == 0, "");
25   static_assert(CharTraits<char16_t>::compare(u"ghi", u"def", 3) == 1, "");
26 }
27 
TEST(CharTraitsTest,Char16TLength)28 TEST(CharTraitsTest, Char16TLength) {
29   static_assert(CharTraits<char16_t>::length(u"abc") == 3, "");
30 }
31 
32 }  // namespace base
33