Code::Blocks  SVN r11506
debuggergdb_test_parser.cpp
Go to the documentation of this file.
2 #include "parsewatchvalue.h"
3 
5 {
6  wxString s;
7  watch.GetSymbol(s);
8  s += wxT("=");
9 
10  wxString value;
11  watch.GetValue(value);
12  s += value;
13 
14  if (watch.GetChildCount() > 0)
15  {
16  s += wxT(" {");
17  s += WatchToString(*watch.GetChild(0));
18 
19  for (int ii = 1; ii < watch.GetChildCount(); ++ii)
20  {
21  s += wxT(",");
22  s += WatchToString(*watch.GetChild(ii));
23  }
24 
25  s += wxT("}");
26  }
27 
28  return s;
29 }
30 
31 inline wxString getName(cbWatch const &watch)
32 {
33  wxString name;
34  watch.GetSymbol(name);
35  return name;
36 }
37 
38 std::ostream& operator<<(std::ostream &stream, cbWatch const &w)
39 {
40  return stream << WatchToString(w);
41 }
42 
43 bool operator == (wxString const &s, cbWatch const &w)
44 {
45  return s == WatchToString(w);
46 }
47 
49 {
50 
51 cb::shared_ptr<GDBWatch> MakeWatch(wxString const &symbol, wxString const &value)
52 {
53  cb::shared_ptr<GDBWatch> w(new GDBWatch(symbol));
54  w->SetValue(value);
55  return w;
56 }
57 
58 TEST(Simple)
59 {
60  GDBWatch w(wxT("a"));
61  w.SetValue(wxT("\"5\""));
62 
63  CHECK_EQUAL(wxT("a=\"5\""), w);
64 }
65 
66 TEST(SimpleChildren)
67 {
68  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("a")));
69  cbWatch::AddChild(w, MakeWatch(wxT("b"), wxT("\"5\"")));
70  cbWatch::AddChild(w, MakeWatch(wxT("c"), wxT("\"6\"")));
71 
72  CHECK_EQUAL(wxT("a= {b=\"5\",c=\"6\"}"), *w);
73 }
74 
75 TEST(SimpleChildrenValue)
76 {
77  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("a")));
78  w->SetValue(wxT("\"value\""));
79  cbWatch::AddChild(w, MakeWatch(wxT("b"), wxT("\"5\"")));
80  cbWatch::AddChild(w, MakeWatch(wxT("c"), wxT("\"6\"")));
81 
82  CHECK_EQUAL(wxT("a=\"value\" {b=\"5\",c=\"6\"}"), *w);
83 }
84 
85 TEST(ComplexChildren)
86 {
87  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("a")));
88 
89  cb::shared_ptr<GDBWatch> c(new GDBWatch(wxT("b")));
90  cbWatch::AddChild(c, MakeWatch(wxT("b1"), wxT("\"5\"")));
91  cbWatch::AddChild(c, MakeWatch(wxT("b2"), wxT("\"6\"")));
92  cbWatch::AddChild(w, c);
93 
94  c = cb::shared_ptr<GDBWatch>(new GDBWatch(wxT("c")));
95  cbWatch::AddChild(c, MakeWatch(wxT("c1"), wxT("\"5\"")));
96  cbWatch::AddChild(c, MakeWatch(wxT("c2"), wxT("\"6\"")));
97  cbWatch::AddChild(w, c);
98 
99  CHECK_EQUAL(wxT("a= {b= {b1=\"5\",b2=\"6\"},c= {c1=\"5\",c2=\"6\"}}"), *w);
100 }
101 
102 TEST(ComplexChildrenValue)
103 {
104  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("a")));
105  w->SetValue(wxT("\"valueA\""));
106  cb::shared_ptr<GDBWatch> c(new GDBWatch(wxT("b")));
107  c->SetValue(wxT("\"valueB\""));
108  cbWatch::AddChild(c, MakeWatch(wxT("b1"), wxT("\"5\"")));
109  cbWatch::AddChild(c, MakeWatch(wxT("b2"), wxT("\"6\"")));
110  cbWatch::AddChild(w, c);
111 
112  c = cb::shared_ptr<GDBWatch>(new GDBWatch(wxT("c")));
113  c->SetValue(wxT("\"valueC\""));
114  cbWatch::AddChild(c, MakeWatch(wxT("c1"), wxT("\"5\"")));
115  cbWatch::AddChild(c, MakeWatch(wxT("c2"), wxT("\"6\"")));
116  cbWatch::AddChild(w, c);
117 
118  CHECK_EQUAL(wxT("a=\"valueA\" {b=\"valueB\" {b1=\"5\",b2=\"6\"},c=\"valueC\" {c1=\"5\",c2=\"6\"}}"), *w);
119 }
120 
121 }
122 
123 
124 SUITE(GDBWatchParser)
125 {
126 
127 TEST(Simple)
128 {
129  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("a")));
130  CHECK(ParseGDBWatchValue(w, wxT("0x60d088 \"test_test_test2\"")));
131  CHECK_EQUAL(wxT("a=0x60d088 \"test_test_test2\""), *w);
132 }
133 
134 TEST(SimpleMembers)
135 {
136  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("cmp")));
137  CHECK(ParseGDBWatchValue(w, wxT("{\n a = 5, \n b = 7, \n c = 1, \n d = 2 \n}")));
138  CHECK_EQUAL(wxT("cmp= {a=5,b=7,c=1,d=2}"), *w);
139 }
140 
141 TEST(BoolMembers)
142 {
143  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
144  CHECK(ParseGDBWatchValue(w, wxT("{memberA = {flag = false}, memberB = {flag = true}}")));
145  CHECK_EQUAL(wxT("t= {memberA= {flag=false},memberB= {flag=true}}"), *w);
146 }
147 
148 TEST(GlobalEnumMembers1)
149 {
150  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
151  CHECK(ParseGDBWatchValue(w, wxT("{a = {test = 5, glob = GlobA},b = {test = B::T3}}")));
152  CHECK_EQUAL(wxT("t= {a= {test=5,glob=GlobA},b= {test=B::T3}}"), *w);
153 }
154 
155 TEST(GlobalEnumMembers2)
156 {
157  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
158  CHECK(ParseGDBWatchValue(w, wxT("{a = {glob = GlobA, test = 5},b = {test = B::T3}}")));
159  CHECK_EQUAL(wxT("t= {a= {glob=GlobA,test=5},b= {test=B::T3}}"), *w);
160 }
161 
162 TEST(CurlyBracketChar)
163 {
164  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
165  CHECK(ParseGDBWatchValue(w, wxT("{\n a = 1, \n ch = 123 '{'\n}")));
166  CHECK_EQUAL(wxT("t= {a=1,ch=123 '{'}"), *w);
167 }
168 
169 TEST(SingleInheritance)
170 {
171  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
172  CHECK(ParseGDBWatchValue(w, wxT("{\n <BaseA> = {\n a = 15,\n b = 20\n },\n")
173  wxT(" members of DerivedA:\n c = 5,\n d = 10\n}")));
174  CHECK_EQUAL(wxT("t= {<BaseA>= {a=15,b=20},c=5,d=10}"), *w);
175 }
176 
177 TEST(MultipleInheritance)
178 {
179  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
180  CHECK(ParseGDBWatchValue(w, wxT("{\n <BaseA> = {\n a = 15,\n b = 20\n }, \n")
181  wxT(" <BaseB> = {\n a = 25,\n b = 30\n }, \n")
182  wxT(" members of DerivedAB: \n e = 5,\n f = 10\n}")));
183  CHECK_EQUAL(wxT("t= {<BaseA>= {a=15,b=20},<BaseB>= {a=25,b=30},e=5,f=10}"), *w);
184 }
185 
186 TEST(TemplatedInheritance)
187 {
188  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
189  CHECK(ParseGDBWatchValue(w, wxT("{\nmembers of A<Value,Al<Value> >::Impl:\nVV = 0x72dc440 }")));
190  CHECK_EQUAL(wxT("s= {VV=0x72dc440}"), *w);
191 }
192 
193 TEST(IgnoreWarnings)
194 {
195  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
196  CHECK(ParseGDBWatchValue(w, wxT("warning: can't find linker symbol for virtual table for `wxString' value\n")
197  wxT("warning: found `g_strEmpty' instead\n")
198  wxT("(type) {\n")
199  wxT("warning: can't find linker symbol for virtual table for `wxString' value\n")
200  wxT("warning: found `g_strEmpty' instead\n")
201  wxT(" a = 5,\n b = 10\n }")));
202  CHECK_EQUAL(wxT("t=(type) {a=5,b=10}"), *w);
203 }
204 
205 TEST(NoDataFields)
206 {
207  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
208  CHECK(ParseGDBWatchValue(w, wxT("{ \n field = {<No data fields>} \n}")));
209  CHECK_EQUAL(wxT("t= {field= {[0]=<No data fields>}}"), *w);
210 }
211 
212 TEST(Empty)
213 {
214  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
215  CHECK(ParseGDBWatchValue(w, wxT("{ \n empty = { \n } \n}")));
216  CHECK_EQUAL(wxT("t= {empty=}"), *w);
217 }
218 
219 TEST(SimpleArray)
220 {
221  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
222  CHECK(ParseGDBWatchValue(w, wxT("{1, 2, 3, 4, 5, 6, 7}")));
223  CHECK_EQUAL(wxT("t= {[0]=1,[1]=2,[2]=3,[3]=4,[4]=5,[5]=6,[6]=7}"), *w);
224 }
225 
226 TEST(TupleArray)
227 {
228  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
229  CHECK(ParseGDBWatchValue(w, wxT("{{\n a = 1,\n b = 2\n }, {\n a = 3,\n b = 5\n }}")));
230  CHECK_EQUAL(wxT("t= {[0]= {a=1,b=2},[1]= {a=3,b=5}}"), *w);
231 }
232 
233 TEST(StdStringWithCommas)
234 {
235  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
236  CHECK(ParseGDBWatchValue(w, wxT("{\nb = 0x3e24e4 \"AAAA,BBBB,CCCC,DDDDD\"}")));
237  CHECK_EQUAL(wxT("t= {b=0x3e24e4 \"AAAA,BBBB,CCCC,DDDDD\"}"), *w);
238 }
239 
240 TEST(StringWithQuotes)
241 {
242  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
243  CHECK(ParseGDBWatchValue(w, wxT("{\nb= 0x3e24e4 \"AAAA,\\\"BBBB\\\",CCCC,DDDDD\"}")));
244  CHECK_EQUAL(wxT("t= {b=0x3e24e4 \"AAAA,\\\"BBBB\\\",CCCC,DDDDD\"}"), *w);
245 }
246 
247 TEST(StringWithQuotedQuotes)
248 {
249  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
250  CHECK(ParseGDBWatchValue(w, wxT("{<wxStringBase> = {static npos = 18446744073709551615")
251  wxT(", m_pchData = 0x3106c98 L\"\\\"test\\\"\"}, <No data fields>}")));
252  CHECK_EQUAL(wxT("s= {<wxStringBase>= {static npos=18446744073709551615,m_pchData=0x3106c98 L\"\\\"test\\\"\"},[1]=<No data fields>}"), *w);
253 }
254 
255 TEST(RepeatingChars0)
256 {
257  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
258  CHECK(ParseGDBWatchValue(w, wxT("{\n\tc = 0x400d90 'A' <repeats 16 times>, \"aa\\\"a\"\n}")));
259  CHECK_EQUAL(wxT("t= {c=0x400d90 'A' <repeats 16 times>, \"aa\\\"a\"}"), *w);
260 }
261 
262 TEST(RepeatingChars1)
263 {
264  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
265  CHECK(ParseGDBWatchValue(w, wxT("{\n\tc = 0x400d90 'A' <repeats 16 times>, ' ' <repeats 29 times>, \"aabba\"\n}")));
266  CHECK_EQUAL(wxT("t= {c=0x400d90 'A' <repeats 16 times>, ' ' <repeats 29 times>, \"aabba\"}"), *w);
267 }
268 
269 TEST(RepeatingChars2)
270 {
271  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
272  CHECK(ParseGDBWatchValue(w, wxT("{\n\tc = 0x400d90 'A' <repeats 16 times>, ' ' <repeats 29 times>, \"aaa\",\n\ta = 5}")));
273  CHECK_EQUAL(wxT("t= {c=0x400d90 'A' <repeats 16 times>, ' ' <repeats 29 times>, \"aaa\",a=5}"), *w);
274 }
275 
276 TEST(RepeatingChars3)
277 {
278  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
279  // c = 0x400dd8 "{\n\tc = 0x400d90 'A' <repeats 16 times>, ' ' <repeats 29 times>, \"aaa\"\n}"
280  CHECK(ParseGDBWatchValue(w, wxT("{\n\tc = 0x400dd8 \"{c = 0x400d90 'A' <repeats 16 times>,")
281  wxT(" ' ' <repeats 29 times>, \\\"aaa\\\"}\"}")));
282  CHECK_EQUAL(wxT("t= {c=0x400dd8 \"{c = 0x400d90 'A' <repeats 16 times>, ' ' <repeats 29 times>, \\\"aaa\\\"}\"}"), *w);
283 }
284 
285 TEST(RepeatingChars4)
286 {
287  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
288  CHECK(ParseGDBWatchValue(w, wxT("{\n name = \"bb\", '\\000' <repeats 14 times>\n}")));
289  CHECK_EQUAL(wxT("t= {name=\"bb\", '\\000' <repeats 14 times>}"), *w);
290 }
291 
292 TEST(RepeatingChars5)
293 {
294  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
295  CHECK(ParseGDBWatchValue(w, wxT("{\n name = \"bb\", '\\000' <repeats 14 times>, \"aabbccddee\"\n}")));
296  CHECK_EQUAL(wxT("t= {name=\"bb\", '\\000' <repeats 14 times>, \"aabbccddee\"}"), *w);
297 }
298 
299 TEST(RepeatingChars6)
300 {
301  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
302  CHECK(ParseGDBWatchValue(w, wxT("{\n name1 = \"aa\", '\\000' <repeats 14 times>,\n")
303  wxT(" name2 = \"bb\", '\\000' <repeats 12 times>, \"aabbccddee\"\n}")));
304  CHECK_EQUAL(wxT("t= {name1=\"aa\", '\\000' <repeats 14 times>,name2=\"bb\",")
305  wxT(" '\\000' <repeats 12 times>, \"aabbccddee\"}"), *w);
306 }
307 TEST(RepeatingChars6_count)
308 {
309  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
310  CHECK(ParseGDBWatchValue(w, wxT("{\n name1 = \"aa\", '\\000' <repeats 14 times>,\n")
311  wxT(" name2 = \"bb\", '\\000' <repeats 12 times>, \"aabbccddee\"\n}")));
312  CHECK_EQUAL(2, w->GetChildCount());
313 }
314 
315 TEST(RepeatingChars7)
316 {
317  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
318  CHECK(ParseGDBWatchValue(w, wxT("{\n name = \"bb\", '\\000' <repeats 14 times>, '\\000' <repeats 12 times>\n}")));
319  CHECK_EQUAL(wxT("t= {name=\"bb\", '\\000' <repeats 14 times>, '\\000' <repeats 12 times>}"), *w);
320 }
321 TEST(RepeatingChars7_count)
322 {
323  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
324  CHECK(ParseGDBWatchValue(w, wxT("{\n name = \"bb\", '\\000' <repeats 14 times>, '\\000' <repeats 12 times>\n}")));
325  CHECK_EQUAL(1, w->GetChildCount());
326 }
327 
328 TEST(RepeatingChars8)
329 {
330  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
331  CHECK(ParseGDBWatchValue(w, wxT("{\n name = \"bb\", '\\000' <repeats 14 times>, \"aabb\",")
332  wxT(" '\\000' <repeats 12 times>, \"aabbccddee\"\n}")));
333  CHECK_EQUAL(wxT("t= {name=\"bb\", '\\000' <repeats 14 times>, \"aabb\",")
334  wxT(" '\\000' <repeats 12 times>, \"aabbccddee\"}"), *w);
335 }
336 TEST(RepeatingChars8_count)
337 {
338  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
339  CHECK(ParseGDBWatchValue(w, wxT("{\n name = \"bb\", '\\000' <repeats 14 times>, \"aabb\",")
340  wxT(" '\\000' <repeats 12 times>, \"aabbccddee\"\n}")));
341  CHECK_EQUAL(1, w->GetChildCount());
342 }
343 
344 // parsing the output of "const char *[]"
345 TEST(RepeatingChars9)
346 {
347  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
348  CHECK(ParseGDBWatchValue(w, wxT("{0x400e90 \"1st\", 0x400e94 '.' <repeats 16 times>, 0x400ea5 \"3th\"}")));
349  CHECK_EQUAL(wxT("t= {[0]=0x400e90 \"1st\",[1]=0x400e94 '.' <repeats 16 times>,[2]=0x400ea5 \"3th\"}"), *w);
350 }
351 TEST(RepeatingChars9_count)
352 {
353  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
354  CHECK(ParseGDBWatchValue(w, wxT("{0x400e90 \"1st\", 0x400e94 '.' <repeats 16 times>, 0x400ea5 \"3th\"}")));
355  CHECK_EQUAL(3, w->GetChildCount());
356 }
357 
358 // parsing the output of "const char *[]"
359 TEST(RepeatingChars10)
360 {
361  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
362  CHECK(ParseGDBWatchValue(w, wxT("{0x4080d8 \"1st\", 0x4080dc \"2nd\", '.' <repeats 48 times>, 0x408110 \"3th\"}")));
363  CHECK_EQUAL(wxT("t= {[0]=0x4080d8 \"1st\",[1]=0x4080dc \"2nd\", '.' <repeats 48 times>,[2]=0x408110 \"3th\"}"), *w);
364 }
365 
366 TEST(RepeatingChars10_count)
367 {
368  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
369  CHECK(ParseGDBWatchValue(w, wxT("{0x4080d8 \"1st\", 0x4080dc \"2nd\", '.' <repeats 48 times>, 0x408110 \"3th\"}")));
370  CHECK_EQUAL(3, w->GetChildCount());
371 }
372 
373 // parsing the output of "const char *[]"
374 TEST(RepeatingChars11)
375 {
376  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
377  CHECK(ParseGDBWatchValue(w, wxT("{0x4080d8 \"1st\", 0x4080dc '.' <repeats 14 times>,")
378  wxT(" \"#\", '&' <repeats 16 times>, 0x4080fc \"3th\"}")));
379  CHECK_EQUAL(wxT("t= {[0]=0x4080d8 \"1st\",[1]=0x4080dc '.' <repeats 14 times>, \"#\", '&' <repeats 16 times>,")
380  wxT("[2]=0x4080fc \"3th\"}"), *w);
381 }
382 
383 TEST(RepeatingChars11_children_count)
384 {
385  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
386  ParseGDBWatchValue(w, wxT("{0x4080d8 \"1st\", 0x4080dc '.' <repeats 14 times>,")
387  wxT(" \"#\", '&' <repeats 16 times>, 0x4080fc \"3th\"}"));
388  CHECK_EQUAL(3, w->GetChildCount());
389 }
390 
391 TEST(RepeatingChars11_children_name)
392 {
393  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
394  ParseGDBWatchValue(w, wxT("{0x4080d8 \"1st\", 0x4080dc '.' <repeats 14 times>,")
395  wxT(" \"#\", '&' <repeats 16 times>, 0x4080fc \"3th\"}"));
396  CHECK_EQUAL(wxT("[0]"), getName(*w->GetChild(0)));
397  CHECK_EQUAL(wxT("[1]"), getName(*w->GetChild(1)));
398  CHECK_EQUAL(wxT("[2]"), getName(*w->GetChild(2)));
399 }
400 
401 TEST(RepeatingChars12)
402 {
403  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
404  CHECK(ParseGDBWatchValue(w, wxT("{m_pchData = 0x75225a4 L'/' <repeats 12 times>, '/' <repeats 43 times>}")));
405  CHECK_EQUAL(wxT("t= {m_pchData=0x75225a4 L'/' <repeats 12 times>, '/' <repeats 43 times>}"), *w);
406 }
407 
408 TEST(RepeatingChars13)
409 {
410  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("t")));
411  CHECK(ParseGDBWatchValue(w, wxT("{<wxStringBase> = {static npos = 4294967295, m_pchData = 0x75225a4 L'/' ")
412  wxT("<repeats 43 times>, \"\\n//\\n\", '/' <repeats 43 times>}, <No data fields>}")));
413  CHECK_EQUAL(wxT("t= {<wxStringBase>= {static npos=4294967295,m_pchData=0x75225a4 L'/' ")
414  wxT("<repeats 43 times>, \"\\n//\\n\", '/' <repeats 43 times>},[1]=<No data fields>}"),
415  *w);
416 }
417 
418 TEST(StringWide)
419 {
420  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
421  CHECK(ParseGDBWatchValue(w, wxT("{m_impl = L\"st\", m_test = {a = 5}")));
422  CHECK_EQUAL(wxT("s= {m_impl=L\"st\",m_test= {a=5}}"), *w);
423 }
424 
425 TEST(StringWideChar)
426 {
427  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
428  CHECK(ParseGDBWatchValue(w, wxT("{m_impl = L's', m_test = {a = 5}")));
429  CHECK_EQUAL(wxT("s= {m_impl=L's',m_test= {a=5}}"), *w);
430 }
431 
432 TEST(ShortenedString)
433 {
434  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
435  CHECK(ParseGDBWatchValue(w, wxT("{m_impl = L\"Created: \"...}")));
436  CHECK_EQUAL(1, w->GetChildCount());
437  CHECK_EQUAL(wxT("s= {m_impl=L\"Created: \"...}"), *w);
438 }
439 
440 TEST(ShortenedStringRepeatedChars)
441 {
442  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
443  CHECK(ParseGDBWatchValue(w, wxT("{m_impl = L\"/\", '*' <repeats 63 times>, \"Created: \"...}")));
444  CHECK_EQUAL(1, w->GetChildCount());
445  CHECK_EQUAL(wxT("s= {m_impl=L\"/\", '*' <repeats 63 times>, \"Created: \"...}"), *w);
446 }
447 
448 TEST(ChangeType0)
449 {
450  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("*s")));
451  CHECK(ParseGDBWatchValue(w, wxT("Cannot access memory at address 0x0")));
452  CHECK(ParseGDBWatchValue(w, wxT("{\n number = 29,\n real = 36\n}")));
453  CHECK_EQUAL(wxT("*s= {number=29,real=36}"), *w);
454 }
455 
456 TEST(ChangeType1)
457 {
458  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
459  CHECK(ParseGDBWatchValue(w, wxT("10")));
460  CHECK(ParseGDBWatchValue(w, wxT("{\n number = 29,\n real = 36\n}")));
461  CHECK_EQUAL(wxT("s= {number=29,real=36}"), *w);
462 }
463 
464 TEST(StructSummarySimple)
465 {
466  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
467  CHECK(ParseGDBWatchValue(w, wxT("test = {a=5}")));
468  CHECK_EQUAL(wxT("s=test {a=5}"), *w);
469 }
470 
471 TEST(StructStaticOptimized)
472 {
473  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
474  CHECK(ParseGDBWatchValue(w, wxT("{static mVar = <optimized out>, mValue = 5}")));
475  CHECK_EQUAL(wxT("s= {static mVar=<optimized out>,mValue=5}"), *w);
476 }
477 
478 TEST(StructStaticOptimized_children_count)
479 {
480  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
481  ParseGDBWatchValue(w, wxT("{static mVar = <optimized out>, mValue = 5}"));
482  CHECK_EQUAL(2,w->GetChildCount());
483 }
484 
485 TEST(StructStaticOptimized_children_name)
486 {
487  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
488  ParseGDBWatchValue(w, wxT("{static mVar = <optimized out>, mValue = 5}"));
489  CHECK_EQUAL(wxT("static mVar"), getName(*w->GetChild(0)));
490  CHECK_EQUAL(wxT("mValue"), getName(*w->GetChild(1)));
491 }
492 
493 
494 TEST(StructSummaryComplex)
495 {
496  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
497  CHECK(ParseGDBWatchValue(w, wxT("{a= test2, test3 = {b = 5}}")));
498  CHECK_EQUAL(wxT("s= {a=test2, test3 {b=5}}"), *w);
499 }
500 
501 TEST(PythonSTLVector)
502 {
503  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
504  CHECK(ParseGDBWatchValue(w, wxT("std::vector of length 4, capacity 4 = {0, 1, 2, 3}")));
505  CHECK_EQUAL(wxT("s=std::vector of length 4, capacity 4 {[0]=0,[1]=1,[2]=2,[3]=3}"), *w);
506 }
507 
508 TEST(PythonSTLMap)
509 {
510  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
511  CHECK(ParseGDBWatchValue(w, wxT("std::map with 20 elements = {[\"BEGIN_EVENT_TABLE\"] = \"-END_EVENT_TABLE\"}")));
512  CHECK_EQUAL(wxT("s=std::map with 20 elements {[\"BEGIN_EVENT_TABLE\"]=\"-END_EVENT_TABLE\"}"), *w);
513 }
514 
515 TEST(PythonSTLMapVector)
516 {
517  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
518  CHECK(ParseGDBWatchValue(w, wxT("std::map with 3 elements = {")
519  wxT("[\"test1\"] = std::vector of length 1, capacity 2 = {0, 1, 2, 3}, ")
520  wxT("[\"test2\"] = std::vector of length 2, capacity 3 = {0, 1, 2, 3}, ")
521  wxT("[\"test3\"] = std::vector of length 3, capacity 4 = {0, 1, 2, 3}}")));
522  CHECK_EQUAL(wxT("s=std::map with 3 elements {[\"test1\"]=std::vector of length 1, capacity 2 {[0]=0,[1]=1,[2]=2,[3]=3},")
523  wxT("[\"test2\"]=std::vector of length 2, capacity 3 {[0]=0,[1]=1,[2]=2,[3]=3},")
524  wxT("[\"test3\"]=std::vector of length 3, capacity 4 {[0]=0,[1]=1,[2]=2,[3]=3}}"), *w);
525 }
526 
527 TEST(PythonVector)
528 {
529  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
530  CHECK(ParseGDBWatchValue(w, wxT("{\n a = vector(1,2,3) = {x = 1,y = 2,z = 3},\n")
531  wxT(" b = vector(4,5,6) = {x = 4,y = 5,z = 6}\n}")));
532  CHECK_EQUAL(wxT("s= {a=vector(1,2,3) {x=1,y=2,z=3},b=vector(4,5,6) {x=4,y=5,z=6}}"), *w);
533 }
534 
535 TEST(PythonVector2)
536 {
537  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
538  CHECK(ParseGDBWatchValue(w, wxT("{\n a = vector(1,2,3) = {x = 1,y = 2,z = 3},\n")
539  wxT(" b = {x = 4,y = 5,z = 6}\n}")));
540  CHECK_EQUAL(wxT("s= {a=vector(1,2,3) {x=1,y=2,z=3},b= {x=4,y=5,z=6}}"), *w);
541 }
542 
543 TEST(PythonVector_count)
544 {
545  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
546  ParseGDBWatchValue(w, wxT("{\n a = vector(1,2,3) = {x = 1,y = 2,z = 3},\n b = vector(4,5,6) = {x = 4,y = 5,z = 6}\n}"));
547  CHECK_EQUAL(2, w->GetChildCount());
548 }
549 
550 TEST(PythonNegativeInt)
551 {
552  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
553  CHECK(ParseGDBWatchValue(w, wxT("{a = -134225496, b = 12}")));
554  CHECK_EQUAL(wxT("s= {a=-134225496,b=12}"), *w);
555 }
556 
557 TEST(PythonSTLVectorEmptyInStruct)
558 {
559  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
560  CHECK(ParseGDBWatchValue(w, wxT("{vec = vector size 0, capacity 0}")));
561  CHECK_EQUAL(wxT("s= {vec=vector size 0, capacity 0}"), *w);
562 }
563 
564 TEST(PythonSTLVectorEmptyInStruct2)
565 {
566  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
567  CHECK(ParseGDBWatchValue(w, wxT("{vec1 = vector size 0, capacity 0, vec2 = vector size 0, capacity 1}")));
568  CHECK_EQUAL(wxT("s= {vec1=vector size 0, capacity 0,vec2=vector size 0, capacity 1}"), *w);
569 }
570 
571 TEST(PythonSTLVectorEmptyInStruct2_count)
572 {
573  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
574  CHECK(ParseGDBWatchValue(w, wxT("{vec1 = empty, vector, vec2 = empty, vector}")));
575  CHECK_EQUAL(2, w->GetChildCount());
576 }
577 
578 TEST(PythonSTLVectorEmptyInStruct3)
579 {
580  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
581  CHECK(ParseGDBWatchValue(w, wxT("{vec1 = vector size 0, capacity 0, vec2 = vector size 0, capacity 1,")
582  wxT("vec3 = vector size 0, capacity 2}")));
583  CHECK_EQUAL(wxT("s= {vec1=vector size 0, capacity 0,vec2=vector size 0, capacity 1,")
584  wxT("vec3=vector size 0, capacity 2}"), *w);
585 }
586 
587 TEST(PythonSTLVectorEmptyInStruct3_count)
588 {
589  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
590  CHECK(ParseGDBWatchValue(w, wxT("{vec1 = vector size 0, capacity 0, vec2 = vector size 0, capacity 1,")
591  wxT("vec3 = vector size 0, capacity 2}")));
592  CHECK_EQUAL(3, w->GetChildCount());
593 }
594 
595 TEST(Python3dVectorInfiniteLoop)
596 {
597  cb::shared_ptr<GDBWatch> w(new GDBWatch(wxT("s")));
598  CHECK(ParseGDBWatchValue(w, wxT("{ double = -3.18, vector = (x=5.7, y=2.9, z=-8.4) = ")
599  wxT("{x = 5.7, y = 2.9, z = -8.4}}")));
600  CHECK_EQUAL(2, w->GetChildCount());
601  CHECK_EQUAL(wxT("s= {double=-3.18,vector=(x=5.7, y=2.9, z=-8.4) {x=5.7,y=2.9,z=-8.4}}"), *w);
602 }
603 
604 } // SUITE(GDBWatchParser)
605 
SUITE(WatchToString)
cb::shared_ptr< cbWatch > GetChild(int index)
#define wxT(string)
virtual void GetSymbol(wxString &symbol) const =0
bool ParseGDBWatchValue(cb::shared_ptr< GDBWatch > watch, wxString const &value, int &start, int length)
int GetChildCount() const
std::ostream & operator<<(std::ostream &stream, cbWatch const &w)
wxString WatchToString(cbWatch const &watch)
static void AddChild(cb::shared_ptr< cbWatch > parent, cb::shared_ptr< cbWatch > watch)
virtual void GetValue(wxString &value) const =0
wxString getName(cbWatch const &watch)
bool operator==(wxString const &s, cbWatch const &w)
virtual bool SetValue(const wxString &value)