87 lines · cpp
1#include <string>2#include <cstring>3 4struct A {5 char data[4];6 char overflow[4];7};8 9#define MAKE_VARS3(c, v, s) \10 c v s char c##v##s##chararray[] = #c #v #s "char"; \11 c v s char *c##v##s##charstar = c##v##s##chararray12#define MAKE_VARS2(c, v) \13 MAKE_VARS3(c, v, ); \14 MAKE_VARS3(c, v, signed); \15 MAKE_VARS3(c, v, unsigned)16#define MAKE_VARS(c) \17 MAKE_VARS2(c, ); \18 MAKE_VARS2(c, volatile)19 20MAKE_VARS();21MAKE_VARS(const);22 23template<typename T>24struct S {25 int x = 0;26};27S<char[5]> Schar5;28S<char *> Scharstar;29 30int main (int argc, char const *argv[])31{32 const char manytrailingnuls[] = "F\0OO\0BA\0R\0\0\0\0";33 A a, b, c;34 // Deliberately write past the end of data to test that the formatter stops35 // at the end of array.36 memcpy(a.data, "FOOBAR", 7);37 memcpy(b.data, "FO\0BAR", 7);38 memcpy(c.data, "F\0O\0AR", 7);39 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"))40 const char *charwithtabs = stdstring.c_str();41 std::string longstring(42"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"43" 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"44" 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.."45" for science, or something"46 "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"47 " 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"48 " 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.."49 " for science, or something"50 "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"51 " 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"52 " 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.."53 " for science, or something"54 );55 const char* longconstcharstar = longstring.c_str();56 return 0; //% if self.TraceOn(): self.runCmd('frame variable')57 //%58 //% self.expect_var_path('stdstring', summary='"Hello\\t\\tWorld\\nI am here\\t\\tto say hello\\n"')59 //% self.expect_var_path('charwithtabs', summary='"Hello\\t\\tWorld\\nI am here\\t\\tto say hello\\n"')60 //% self.expect_var_path("a.data", summary='"FOOB"')61 //% self.expect_var_path("b.data", summary=r'"FO\0B"')62 //% self.expect_var_path("c.data", summary=r'"F\0O"')63 //% self.expect_var_path("manytrailingnuls", summary=r'"F\0OO\0BA\0R"')64 //%65 //% for c in ["", "const"]:66 //% for v in ["", "volatile"]:67 //% for s in ["", "unsigned"]:68 //% summary = '"'+c+v+s+'char"'69 //% self.expect_var_path(c+v+s+"chararray", summary=summary)70 //% # These should be printed normally71 //% self.expect_var_path(c+v+s+"charstar", summary=summary)72 //% Schar5 = self.expect_var_path("Schar5",73 //% children=[ValueCheck(name="x", value="0")])74 //% self.assertIsNone(Schar5.GetSummary())75 //% Scharstar = self.expect_var_path("Scharstar",76 //% children=[ValueCheck(name="x", value="0")])77 //% self.assertIsNone(Scharstar.GetSummary())78 //%79 //% self.runCmd("setting set escape-non-printables false")80 //% self.expect_var_path('stdstring', summary='"Hello\t\tWorld\nI am here\t\tto say hello\n"')81 //% self.expect_var_path('charwithtabs', summary='"Hello\t\tWorld\nI am here\t\tto say hello\n"')82 //% self.assertTrue(self.frame().FindVariable('longstring').GetSummary().endswith('"...'))83 //% self.assertTrue(self.frame().FindVariable('longconstcharstar').GetSummary().endswith('"...'))84 // FIXME: make "b.data" and "c.data" work sanely85}86 87