本文整理汇总了C++中TextLine::Append方法的典型用法代码示例。如果您正苦于以下问题:C++ TextLine::Append方法的具体用法?C++ TextLine::Append怎么用?C++ TextLine::Append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextLine
的用法示例。
在下文中一共展示了TextLine::Append方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Test
void TextLine::Test ()
{
//
// ctor
//
TextLine tl;
assert (0 == tl._pStorage);
assert (0 == tl._pData);
assert (0 == tl._numAllocated);
//
// Init()
//
tl.Init ("howdy");
assert (tl._pStorage);
assert (tl._pData);
assert (tl._pData >= tl._pStorage);
assert (tl._numAllocated);
assert (tl._numAllocated > strlen ("howdy"));
assert (0 == strcmp (tl._pData, "howdy"));
//
// copy ctor
//
TextLine tl2 = tl;
assert (tl2._pStorage);
assert (tl2._pData);
assert (tl2._pData >= tl._pStorage);
assert (tl2._numAllocated);
assert (tl2._numAllocated > strlen ("howdy"));
assert (0 == strcmp (tl2._pData, "howdy"));
//
// op=
//
TextLine tl3;
tl3 = tl;
assert (tl3._pStorage);
assert (tl3._pData);
assert (tl3._pData >= tl._pStorage);
assert (tl3._numAllocated);
assert (tl3._numAllocated > strlen ("howdy"));
assert (0 == strcmp (tl3._pData, "howdy"));
//
// GetLength()
//
assert (5 == tl.GetLength());
//
// Append()
//
bool stat;
stat = tl.Append ('!');
assert (stat);
assert (0 == strcmp (tl._pData, "howdy!"));
stat = tl.Append ('\\');
assert (stat);
assert (0 == strcmp (tl._pData, "howdy!\\"));
stat = tl.Append ('\n');
assert (stat);
assert (0 == strcmp (tl._pData, "howdy!\\\n"));
// we should be able to add chars after escaped newline
stat = tl.Append (' ');
assert (stat);
assert (0 == strcmp (tl._pData, "howdy!\\\n "));
stat = tl.Append ('\n');
assert (stat);
assert (0 == strcmp (tl._pData, "howdy!\\\n \n"));
// we should not be able to add chars after non-escaped newline
stat = tl.Append ('x');
assert (! stat);
assert (0 == strcmp (tl._pData, "howdy!\\\n \n"));
stat = tl.Append ('y');
assert (! stat);
assert (0 == strcmp (tl._pData, "howdy!\\\n \n"));
//
// Consume()
//
char c;
stat = tl2.Consume (c);
assert (stat);
assert ('h' == c);
stat = tl2.Consume (c);
assert (stat);
assert ('o' == c);
stat = tl2.Consume (c);
assert (stat);
assert ('w' == c);
stat = tl2.Consume (c);
assert (stat);
assert ('d' == c);
stat = tl2.Consume (c);
assert (stat);
assert ('y' == c);
stat = tl2.Consume (c);
assert (!stat);
//.........这里部分代码省略.........