Code::Blocks  SVN r11506
debuggergdb_test_parse_locals.cpp
Go to the documentation of this file.
2 #include "parsewatchvalue.h"
3 
4 inline std::ostream& operator<<(std::ostream &stream, GDBLocalVariable const &s)
5 {
6  return stream << s.name.utf8_str().data() << "|" << s.value.utf8_str().data() << ">";
7 }
8 
9 inline bool operator == (wxString const &s, GDBLocalVariable const &v)
10 {
11  return s == v.name + wxT("|") + v.value;
12 }
13 
14 
15 SUITE(GDBLocalsParser)
16 {
17 
18 TEST(TokenizeSimple)
19 {
20  std::vector<GDBLocalVariable> results;
21  TokenizeGDBLocals(results, wxT("a = 5\nb = 10"));
22  CHECK_EQUAL(2u, results.size());
23  CHECK_EQUAL(wxT("a|5"), results[0]);
24  CHECK_EQUAL(wxT("b|10"), results[1]);
25 }
26 
27 TEST(TokenizeCompound)
28 {
29  std::vector<GDBLocalVariable> results;
30  TokenizeGDBLocals(results, wxT("a = 10\ncompound = {\n a = 1, \n b = 2\n}"));
31  CHECK_EQUAL(2u, results.size());
32  CHECK_EQUAL(wxT("a|10"), results[0]);
33  CHECK_EQUAL(wxT("compound|{\n a = 1, \n b = 2\n}"), results[1]);
34 }
35 
36 TEST(TokenizeString0)
37 {
38  std::vector<GDBLocalVariable> results;
39  TokenizeGDBLocals(results, wxT("a = \"test\n\"\nb = 10"));
40  CHECK_EQUAL(2u, results.size());
41  CHECK_EQUAL(wxT("a|\"test\n\""), results[0]);
42  CHECK_EQUAL(wxT("b|10"), results[1]);
43 }
44 
45 TEST(TokenizeString1)
46 {
47  std::vector<GDBLocalVariable> results;
48  TokenizeGDBLocals(results, wxT("a = \"test{\"\nb = 10"));
49  CHECK_EQUAL(2u, results.size());
50  CHECK_EQUAL(wxT("a|\"test{\""), results[0]);
51  CHECK_EQUAL(wxT("b|10"), results[1]);
52 }
53 
54 TEST(TokenizeString1Escaped1)
55 {
56  std::vector<GDBLocalVariable> results;
57  TokenizeGDBLocals(results, wxT("a = \"test\\\"{\"\nb = 10"));
58  CHECK_EQUAL(2u, results.size());
59  CHECK_EQUAL(wxT("a|\"test\\\"{\""), results[0]);
60  CHECK_EQUAL(wxT("b|10"), results[1]);
61 }
62 
63 TEST(TokenizeString1Escaped2)
64 {
65  std::vector<GDBLocalVariable> results;
66  TokenizeGDBLocals(results, wxT("a = \"test{\\\\\"\nb = 10"));
67  CHECK_EQUAL(2u, results.size());
68  CHECK_EQUAL(wxT("a|\"test{\\\\\""), results[0]);
69  CHECK_EQUAL(wxT("b|10"), results[1]);
70 }
71 
72 TEST(TokenizeString2)
73 {
74  std::vector<GDBLocalVariable> results;
75  TokenizeGDBLocals(results, wxT("a = 123 '{'\nb = 10"));
76  CHECK_EQUAL(2u, results.size());
77  CHECK_EQUAL(wxT("a|123 '{'"), results[0]);
78  CHECK_EQUAL(wxT("b|10"), results[1]);
79 }
80 
81 TEST(TokenizeString3)
82 {
83  std::vector<GDBLocalVariable> results;
84  TokenizeGDBLocals(results, wxT("a = 123 '\"'\nb = 10"));
85  CHECK_EQUAL(2u, results.size());
86  CHECK_EQUAL(wxT("a|123 '\"'"), results[0]);
87  CHECK_EQUAL(wxT("b|10"), results[1]);
88 }
89 
90 TEST(TokenizeString4)
91 {
92  std::vector<GDBLocalVariable> results;
93  TokenizeGDBLocals(results, wxT("a = \"test's\"\nb = 10"));
94  CHECK_EQUAL(2u, results.size());
95  CHECK_EQUAL(wxT("a|\"test's\""), results[0]);
96  CHECK_EQUAL(wxT("b|10"), results[1]);
97 }
98 
99 TEST(TokenizeCharSingleQuoteEscaped1)
100 {
101  std::vector<GDBLocalVariable> results;
102  TokenizeGDBLocals(results, wxT("a = 5\nl = {a = 100094, b = 39 '\\''}\nb = 4"));
103  CHECK_EQUAL(3u, results.size());
104  CHECK_EQUAL(wxT("a|5"), results[0]);
105  CHECK_EQUAL(wxT("l|{a = 100094, b = 39 '\\''}"), results[1]);
106  CHECK_EQUAL(wxT("b|4"), results[2]);
107 }
108 TEST(TokenizeCharSingleQuoteEscaped2)
109 {
110  std::vector<GDBLocalVariable> results;
111  TokenizeGDBLocals(results, wxT("a = 5\nl = {a = 100094, b = 39 '\\\\'}\nb = 4"));
112  CHECK_EQUAL(3u, results.size());
113  CHECK_EQUAL(wxT("a|5"), results[0]);
114  CHECK_EQUAL(wxT("l|{a = 100094, b = 39 '\\\\'}"), results[1]);
115  CHECK_EQUAL(wxT("b|4"), results[2]);
116 }
117 
118 } // SUITE(GDBLocalsParser)
const wxScopedCharBuffer utf8_str() const
void TokenizeGDBLocals(std::vector< GDBLocalVariable > &results, wxString const &value)
#define wxT(string)
bool operator==(wxString const &s, GDBLocalVariable const &v)
SUITE(GDBLocalsParser)
std::ostream & operator<<(std::ostream &stream, GDBLocalVariable const &s)