This repository has been archived by the owner on Aug 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.cpp
54 lines (53 loc) · 2.49 KB
/
main.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
51
52
53
54
#include "../src/PureJson.hpp"
#include <iostream>
#include <list>
#include <string>
//
#define ASSERT_EQUAL(string1, string2) assert((string1) == (string2))
//
//
std::list<std::string> tests{};
std::list<std::string> expects{}; // TODO
//
void begin_test()
{
for (auto &str : tests)
{
std::cout << "source: " << str << std::endl;
std::cout << "target: " << RemoveComment(str) << std::endl;
}
}
//
int main()
{
// Simple inline comments.
tests.push_back(std::string(R"( //this is a comment )"));
tests.push_back(std::string(R"( this is not a comment )"));
// Somewhat more complex comments within and out of the qoutes.
tests.push_back(std::string(R"( "//this is not a comment, it's in the string" )"));
tests.push_back(
std::string(R"( "//this is not a comment, it's in the string", but //those are comments to be removed. )"));
// More complex comments with fake qoutes (escaped)
tests.push_back(
std::string(R"( "//this is not a comment, it's in the string \", and //those are not comments neither" )"));
tests.push_back(std::string(
R"( "//this is not a comment, it's in the string \\", but //those are comments since the string is terminated )"));
// Test cases with single and double qoutes.
tests.push_back(std::string(
R"( '//this is not a comment, it's in the string, // but, only for the first part and those are comments since the string is terminated )"));
tests.push_back(std::string(
R"( "//this is not a comment, it's in the string ", and '//those are not comments as well' since in the //single qoutes." )"));
// Test cases with block comments.
tests.push_back(std::string(R"( /*this is a comment*/ my actrual data )"));
tests.push_back(std::string(R"( /**/ my actrual data /**/ )"));
tests.push_back(std::string(R"( /**/ my actr/**/ual data /**/ )"));
tests.push_back(std::string(R"( /**/ my actr/****////**/**///**/**/ual data /**/ )"));
// Test cases with blocked comments single and double qoutes.
tests.push_back(std::string(
R"( '//this is not a comment, it's i/**/n the st/**/ring, // but, on/**/ly for the first part and those are comments since the string is terminated )"));
tests.push_back(std::string(
R"( "//this is not a comment, it's /*in the string*/ ", and '//those are not comments as well' since in the single qoutes./* and in the comments */" )"));
//
begin_test();
return 0;
}