-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove-comments-test.cpp
50 lines (39 loc) · 1.42 KB
/
remove-comments-test.cpp
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* Copyright (c) 2018 Christopher Friedt
*
* SPDX-License-Identifier: MIT
*/
#include <gtest/gtest.h>
#include "remove-comments.cpp"
using namespace std;
TEST(RemoveComments, example1) {
vector<string> source = {"/*Test program */",
"int main()",
"{ ",
" // variable declaration ",
"int a, b, c;",
"/* This is a test",
" multiline ",
" comment for ",
" testing */",
"a = b + c;",
"}"};
vector<string> expected = {"int main()", "{ ", " ",
"int a, b, c;", "a = b + c;", "}"};
EXPECT_EQ(expected, Solution().removeComments(source));
}
TEST(RemoveComments, example2) {
vector<string> source = {"a/*comment", "line", "more_comment*/b"};
vector<string> expected = {"ab"};
EXPECT_EQ(expected, Solution().removeComments(source));
}
TEST(RemoveComments, example3) {
vector<string> source = {"a//*b//*c", "blank", "d/*/e*//f"};
vector<string> expected = {"a", "blank", "d/f"};
EXPECT_EQ(expected, Solution().removeComments(source));
}
TEST(RemoveComments, example4) {
vector<string> source = {"a / /*b// */c"};
vector<string> expected = {"a / c"};
EXPECT_EQ(expected, Solution().removeComments(source));
}