本文整理汇总了C++中Nibbler::getLiteral方法的典型用法代码示例。如果您正苦于以下问题:C++ Nibbler::getLiteral方法的具体用法?C++ Nibbler::getLiteral怎么用?C++ Nibbler::getLiteral使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nibbler
的用法示例。
在下文中一共展示了Nibbler::getLiteral方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
t.ok (n.depleted (), " '' : depleted () -> true");
// bool getUnsignedInt (int&i);
t.diag ("Nibbler::getUnsignedInt");
n = Nibbler ("123 4");
t.ok (n.getUnsignedInt (i), " '123 4' : getUnsignedInt () -> true");
t.is (i, 123, " '123 4' : getUnsignedInt () -> '123'");
t.ok (n.skip (' '), " ' 4' : skip (' ') -> true");
t.ok (n.getUnsignedInt (i), " '4' : getUnsignedInt () -> true");
t.is (i, 4, " '4' : getUnsignedInt () -> '4'");
t.ok (n.depleted (), " '' : depleted () -> true");
// bool getNumber (double&);
t.diag ("Nibbler::getNumber");
n = Nibbler ("-1.234 2.3e4");
t.ok (n.getNumber (d), "'-1.234 2.3e4' : getNumber () -> true");
t.is (d, -1.234, 0.000001, "'-1.234 2.3e4' : getNumber () -> '-1.234'");
t.ok (n.skip (' '), " ' 2.3e4' : skip (' ') -> true");
t.ok (n.getNumber (d), " '2.3e4' : getNumber () -> true");
t.is (d, 2.3e4, " '2.3e4' : getNumber () -> '2.3e4'");
t.ok (n.depleted (), " '' : depleted () -> true");
n = Nibbler ("2.0");
t.ok (n.getNumber (d), "'2.0' : getNumber () -> true");
t.is (d, 2.0, 0.000001, "'2.0' : getNumber () -> '2.0'");
t.ok (n.depleted (), " '' : depleted () -> true");
n = Nibbler ("-864000.00000");
t.ok (n.getNumber (d), "'-864000.00000' : getNumber () -> true");
t.is (d, -864000.0, "'-864000.00000' : getNumber () -> -864000.0");
t.ok (n.depleted (), " '' : depleted () -> true");
// bool getLiteral (const std::string&);
t.diag ("Nibbler::getLiteral");
n = Nibbler ("foobar");
t.ok (n.getLiteral ("foo"), " 'foobar' : getLiteral ('foo') -> true");
t.notok (n.getLiteral ("foo"), " 'bar' : getLiteral ('foo') -> false");
t.ok (n.getLiteral ("bar"), " 'bar' : getLiteral ('bar') -> true");
t.ok (n.depleted (), " '' : depleted () -> true");
#ifdef NIBBLER_FEATURE_REGEX
// bool getRx (const std::string&, std::string&);
t.diag ("Nibbler::getRx");
n = Nibbler ("one two three");
t.ok (n.getRx ("^(o..)", s), "'one two three' : getRx ('^(o..)') -> true");
t.is (s, "one", "'one two three' : getRx ('^(o..)') -> 'one'");
t.ok (n.skip (' '), " ' two three' : skip (' ') -> true");
t.ok (n.getRx ("t..", s), " 'two three' : getRx ('t..') -> true");
t.is (s, "two", " 'two three' : getRx ('t..') -> 'two'");
t.notok (n.getRx ("th...", s), " ' three' : getRx ('th...') -> false");
t.ok (n.skip (' '), " ' three' : skip (' ') -> true");
t.ok (n.getRx ("th...", s), " 'three' : getRx ('th...') -> true");
t.is (s, "three", " 'three' : getRx ('th...') -> 'three'");
t.ok (n.depleted (), " '' : depleted () -> true");
#endif
// bool getUUID (std::string&);
t.diag ("Nibbler::getUUID");
n = Nibbler ("a0b1c2d3-e4f5-A6B7-C8D9-E0F1a2b3c4d5");
t.ok (n.getUUID (s), "uuid 1 found");
t.is (s, "a0b1c2d3-e4f5-A6B7-C8D9-E0F1a2b3c4d5", "uuid 1 -> correct");
t.ok (n.depleted (), "depleted");
n = Nibbler ("00000000-0000-0000-0000-000000000000,a0b1c2d3-e4f5-A6B7-C8D9-E0F1a2b3c4d5");
t.ok (n.getUUID (s), "uuid 1 found");
t.is (s, "00000000-0000-0000-0000-000000000000", "uuid 1 -> correct");