199451b44SJordan Rupprecht #include <string>
28093c2eaSPavel Labath #include <cstring>
38093c2eaSPavel Labath 
48093c2eaSPavel Labath struct A {
58093c2eaSPavel Labath   char data[4];
68093c2eaSPavel Labath   char overflow[4];
78093c2eaSPavel Labath };
899451b44SJordan Rupprecht 
9*11dc235cSPavel Labath #define MAKE_VARS3(c, v, s)                                                    \
10*11dc235cSPavel Labath   c v s char c##v##s##chararray[] = #c #v #s "char";                           \
11*11dc235cSPavel Labath   c v s char *c##v##s##charstar = c##v##s##chararray
12*11dc235cSPavel Labath #define MAKE_VARS2(c, v)                                                       \
13*11dc235cSPavel Labath   MAKE_VARS3(c, v, );                                                          \
14*11dc235cSPavel Labath   MAKE_VARS3(c, v, signed);                                                    \
15*11dc235cSPavel Labath   MAKE_VARS3(c, v, unsigned)
16*11dc235cSPavel Labath #define MAKE_VARS(c)                                                           \
17*11dc235cSPavel Labath   MAKE_VARS2(c, );                                                             \
18*11dc235cSPavel Labath   MAKE_VARS2(c, volatile)
19*11dc235cSPavel Labath 
20*11dc235cSPavel Labath MAKE_VARS();
21*11dc235cSPavel Labath MAKE_VARS(const);
22*11dc235cSPavel Labath 
23*11dc235cSPavel Labath template<typename T>
24*11dc235cSPavel Labath struct S {
25*11dc235cSPavel Labath   int x = 0;
26*11dc235cSPavel Labath };
27*11dc235cSPavel Labath S<char[5]> Schar5;
28*11dc235cSPavel Labath S<char *> Scharstar;
29*11dc235cSPavel Labath 
3099451b44SJordan Rupprecht int main (int argc, char const *argv[])
3199451b44SJordan Rupprecht {
32ca0ce99fSPavel Labath     A a, b, c;
338093c2eaSPavel Labath     // Deliberately write past the end of data to test that the formatter stops
348093c2eaSPavel Labath     // at the end of array.
358093c2eaSPavel Labath     memcpy(a.data, "FOOBAR", 7);
368093c2eaSPavel Labath     memcpy(b.data, "FO\0BAR", 7);
37ca0ce99fSPavel Labath     memcpy(c.data, "F\0O\0AR", 7);
3899451b44SJordan Rupprecht     std::string stdstring("Hello\t\tWorld\nI am here\t\tto say hello\n"); //%self.addTearDownHook(lambda x: x.runCmd("setting set escape-non-printables true"))
39*11dc235cSPavel Labath     const char *charwithtabs = stdstring.c_str();
4099451b44SJordan Rupprecht     std::string longstring(
4199451b44SJordan Rupprecht "I am a very long string; in fact I am longer than any reasonable length that a string should be; quite long indeed; oh my, so many words; so many letters; this is kind of like writing a poem; except in real life all that is happening"
4299451b44SJordan Rupprecht " is just me producing a very very long set of words; there is text here, text there, text everywhere; it fills me with glee to see so much text; all around me it's just letters, and symbols, and other pleasant drawings that cause me"
4399451b44SJordan Rupprecht " a large amount of joy upon visually seeing them with my eyes; well, this is now a lot of letters, but it is still not enough for the purpose of the test I want to test, so maybe I should copy and paste this a few times, you know.."
4499451b44SJordan Rupprecht " for science, or something"
4599451b44SJordan Rupprecht       "I am a very long string; in fact I am longer than any reasonable length that a string should be; quite long indeed; oh my, so many words; so many letters; this is kind of like writing a poem; except in real life all that is happening"
4699451b44SJordan Rupprecht       " is just me producing a very very long set of words; there is text here, text there, text everywhere; it fills me with glee to see so much text; all around me it's just letters, and symbols, and other pleasant drawings that cause me"
4799451b44SJordan Rupprecht       " a large amount of joy upon visually seeing them with my eyes; well, this is now a lot of letters, but it is still not enough for the purpose of the test I want to test, so maybe I should copy and paste this a few times, you know.."
4899451b44SJordan Rupprecht       " for science, or something"
4999451b44SJordan Rupprecht             "I am a very long string; in fact I am longer than any reasonable length that a string should be; quite long indeed; oh my, so many words; so many letters; this is kind of like writing a poem; except in real life all that is happening"
5099451b44SJordan Rupprecht             " is just me producing a very very long set of words; there is text here, text there, text everywhere; it fills me with glee to see so much text; all around me it's just letters, and symbols, and other pleasant drawings that cause me"
5199451b44SJordan Rupprecht             " a large amount of joy upon visually seeing them with my eyes; well, this is now a lot of letters, but it is still not enough for the purpose of the test I want to test, so maybe I should copy and paste this a few times, you know.."
5299451b44SJordan Rupprecht             " for science, or something"
5399451b44SJordan Rupprecht       );
5499451b44SJordan Rupprecht     const char* longconstcharstar = longstring.c_str();
5599451b44SJordan Rupprecht     return 0;     //% if self.TraceOn(): self.runCmd('frame variable')
56*11dc235cSPavel Labath     //%
578093c2eaSPavel Labath     //% self.expect_var_path('stdstring', summary='"Hello\\t\\tWorld\\nI am here\\t\\tto say hello\\n"')
58*11dc235cSPavel Labath     //% self.expect_var_path('charwithtabs', summary='"Hello\\t\\tWorld\\nI am here\\t\\tto say hello\\n"')
59ca0ce99fSPavel Labath     //% self.expect_var_path("a.data", summary='"FOOB"')
60ca0ce99fSPavel Labath     //% self.expect_var_path("b.data", summary=r'"FO\0B"')
61ca0ce99fSPavel Labath     //% self.expect_var_path("c.data", summary=r'"F\0O"')
62ca0ce99fSPavel Labath     //%
63*11dc235cSPavel Labath     //% for c in ["", "const"]:
64*11dc235cSPavel Labath     //%   for v in ["", "volatile"]:
65*11dc235cSPavel Labath     //%     for s in ["", "signed", "unsigned"]:
66*11dc235cSPavel Labath     //%       summary = '"'+c+v+s+'char"'
67*11dc235cSPavel Labath     //%       self.expect_var_path(c+v+s+"chararray", summary=summary)
68*11dc235cSPavel Labath     //% # These should be printed normally
69*11dc235cSPavel Labath     //%       self.expect_var_path(c+v+s+"charstar", summary=summary)
70*11dc235cSPavel Labath     //% Schar5 = self.expect_var_path("Schar5",
71*11dc235cSPavel Labath     //%     children=[ValueCheck(name="x", value="0")])
72*11dc235cSPavel Labath     //% self.assertIsNone(Schar5.GetSummary())
73*11dc235cSPavel Labath     //% Scharstar = self.expect_var_path("Scharstar",
74*11dc235cSPavel Labath     //%     children=[ValueCheck(name="x", value="0")])
75*11dc235cSPavel Labath     //% self.assertIsNone(Scharstar.GetSummary())
76*11dc235cSPavel Labath     //%
7799451b44SJordan Rupprecht     //% self.runCmd("setting set escape-non-printables false")
788093c2eaSPavel Labath     //% self.expect_var_path('stdstring', summary='"Hello\t\tWorld\nI am here\t\tto say hello\n"')
79*11dc235cSPavel Labath     //% self.expect_var_path('charwithtabs', summary='"Hello\t\tWorld\nI am here\t\tto say hello\n"')
8099451b44SJordan Rupprecht     //% self.assertTrue(self.frame().FindVariable('longstring').GetSummary().endswith('"...'))
8199451b44SJordan Rupprecht     //% self.assertTrue(self.frame().FindVariable('longconstcharstar').GetSummary().endswith('"...'))
82ca0ce99fSPavel Labath     // FIXME: make "b.data" and "c.data" work sanely
8399451b44SJordan Rupprecht }
8499451b44SJordan Rupprecht 
85