net_string_util_unittest.cc 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2017 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. #include "net/base/net_string_util.h"
  5. #include <string>
  6. #include "base/strings/utf_string_conversions.h"
  7. #include "testing/gtest/include/gtest/gtest.h"
  8. namespace net {
  9. TEST(NetStringUtilTest, ToUpperEmpty) {
  10. std::u16string in;
  11. std::u16string out;
  12. std::u16string expected;
  13. ASSERT_TRUE(ToUpper(in, &out));
  14. ASSERT_EQ(expected, out);
  15. }
  16. TEST(NetStringUtilTest, ToUpperSingleChar) {
  17. std::u16string in(u"a");
  18. std::u16string out;
  19. std::u16string expected(u"A");
  20. ASSERT_TRUE(ToUpper(in, &out));
  21. ASSERT_EQ(expected, out);
  22. }
  23. TEST(NetStringUtilTest, ToUpperSimple) {
  24. std::u16string in(u"hello world");
  25. std::u16string out;
  26. std::u16string expected(u"HELLO WORLD");
  27. ASSERT_TRUE(ToUpper(in, &out));
  28. ASSERT_EQ(expected, out);
  29. }
  30. TEST(NetStringUtilTest, ToUpperAlreadyUpper) {
  31. std::u16string in(u"HELLO WORLD");
  32. std::u16string out;
  33. std::u16string expected(u"HELLO WORLD");
  34. ASSERT_TRUE(ToUpper(in, &out));
  35. ASSERT_EQ(expected, out);
  36. }
  37. } // namespace net