19 std::string StringVectorToString(
const std::vector<std::string>& str_vec) {
20 std::string str =
"[";
22 for (
const auto& s : str_vec) {
32 "カンマで区切った時,カンマが取り除かれ区切られた文字列に分けられるべ"
36 "c」をカンマで区切った時,「a」「b」「c」に分けられるべき") {
37 const std::string str =
"a,b,c";
38 const std::string delim =
",";
40 const std::vector<std::string> ans = {
"a",
"b",
"c"};
41 const std::vector<std::string> result =
44 INFO(
"分割された文字列は次の通りです." << StringVectorToString(result));
51 "」をカンマで区切った時,「a」「b」「c」に分けられるべき") {
52 const std::string str =
"a,b,c,";
53 const std::string delim =
",";
55 const std::vector<std::string> ans = {
"a",
"b",
"c"};
56 const std::vector<std::string> result =
59 INFO(
"分割された文字列は次の通りです." << StringVectorToString(result));
66 "c」をカンマで区切った時,「」「a」「b」「c」に分けられるべき") {
67 const std::string str =
",a,b,c";
68 const std::string delim =
",";
70 const std::vector<std::string> ans = {
"",
"a",
"b",
"c"};
71 const std::vector<std::string> result =
74 INFO(
"分割された文字列は次の通りです." << StringVectorToString(result));
82 enum class SampleEnum :
int { kOne, knight, three, FOUR, Five };
85 "先頭にkがついた列挙体の要素を渡した時,先頭のkを取り除いた要素名が返るべ"
87 SUBCASE(
"「kOne」を渡した時,文字列「One」が返るべき") {
88 const SampleEnum sample_enum = SampleEnum::kOne;
89 const std::string expect =
"One";
90 const std::string actual =
93 INFO(
"変換された文字列は次の通りです." << actual);
95 CHECK(actual == expect);
98 SUBCASE(
"「knight」を渡した時,文字列「night」が返るべき") {
99 const SampleEnum sample_enum = SampleEnum::knight;
100 const std::string expect =
"night";
101 const std::string actual =
104 INFO(
"変換された文字列は次の通りです." << actual);
106 CHECK(actual == expect);
111 "先頭にkがついてない列挙体の要素を渡した時,そのままの要素名が返るべき") {
112 SUBCASE(
"「three」を渡した時,そのままの要素名が返るべき") {
113 const SampleEnum sample_enum = SampleEnum::three;
114 const std::string expect =
"three";
115 const std::string actual =
118 INFO(
"変換された文字列は次の通りです." << actual);
120 CHECK(actual == expect);
123 SUBCASE(
"「FOUR」を渡した時,そのままの要素名が返るべき") {
124 const SampleEnum sample_enum = SampleEnum::FOUR;
125 const std::string expect =
"FOUR";
126 const std::string actual =
129 INFO(
"変換された文字列は次の通りです." << actual);
131 CHECK(actual == expect);
134 SUBCASE(
"「Five」を渡した時,そのままの要素名が返るべき") {
135 const SampleEnum sample_enum = SampleEnum::Five;
136 const std::string expect =
"Five";
137 const std::string actual =
140 INFO(
"変換された文字列は次の通りです." << actual);
142 CHECK(actual == expect);
std::vector< std::string > Split(const std::string &str, const std::string &separator)
文字列を分割する関数.指定した文字で文字列を分割する. 分割した結果,空白が含まれる場合や文字列がない場合は,そのまま返す. 最後が区切り文字で終わる場合は,...