aboutsummaryrefslogtreecommitdiff
path: root/test/common/StringTest.cpp
blob: 53ed359f7c74bf9b3bd061bbb754882eaeb7e820 (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
#include "cru/common/String.hpp"

#include <gtest/gtest.h>

TEST(String, Append) {
  using cru::String;

  String s;
  s.append(u"ha");
  s.append(s);
  ASSERT_EQ(s, String(u"haha"));
}

TEST(String, IndexConvert) {
  using cru::String;

  String s(u"123");
  ASSERT_EQ(s.IndexFromCodePointToCodeUnit(1), 1);
  ASSERT_EQ(s.IndexFromCodeUnitToCodePoint(1), 1);
  ASSERT_EQ(s.IndexFromCodeUnitToCodePoint(3), 3);
  ASSERT_EQ(s.IndexFromCodeUnitToCodePoint(3), 3);

}

TEST(String, Format) {
  using cru::Format;
  using cru::String;

  ASSERT_EQ(Format(u"{} + {} = {}", 123, 321, 444), String(u"123 + 321 = 444"));
}