You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.1 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright 2004 The WebRTC Project Authors. All rights reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #include "rtc_base/string_utils.h"
  11. #include "test/gtest.h"
  12. namespace rtc {
  13. TEST(string_trim_Test, Trimming) {
  14. EXPECT_EQ("temp", string_trim("\n\r\t temp \n\r\t"));
  15. EXPECT_EQ("temp\n\r\t temp", string_trim(" temp\n\r\t temp "));
  16. EXPECT_EQ("temp temp", string_trim("temp temp"));
  17. EXPECT_EQ("", string_trim(" \r\n\t"));
  18. EXPECT_EQ("", string_trim(""));
  19. }
  20. TEST(string_toHexTest, ToHex) {
  21. EXPECT_EQ(ToHex(0), "0");
  22. EXPECT_EQ(ToHex(0X1243E), "1243e");
  23. EXPECT_EQ(ToHex(-20), "ffffffec");
  24. }
  25. #if defined(WEBRTC_WIN)
  26. TEST(string_toutf, Empty) {
  27. char empty_string[] = "";
  28. EXPECT_TRUE(ToUtf16(empty_string, 0u).empty());
  29. wchar_t empty_wchar[] = L"";
  30. EXPECT_TRUE(ToUtf8(empty_wchar, 0u).empty());
  31. }
  32. #endif // WEBRTC_WIN
  33. } // namespace rtc