当前位置: 首页>>代码示例>>C++>>正文


C++ TokenStream::IsEmpty方法代码示例

本文整理汇总了C++中TokenStream::IsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ TokenStream::IsEmpty方法的具体用法?C++ TokenStream::IsEmpty怎么用?C++ TokenStream::IsEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TokenStream的用法示例。


在下文中一共展示了TokenStream::IsEmpty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Outputf


//.........这里部分代码省略.........
        {   "+1.0 ('ABCD')", 4,
            {   F(1.0),
                T(LeftParen),
                S("ABCD"),
                T(RightParen)
            }
        },
        // The uber test
        {   "0 -0 +0 1 -2 +3 0. -0. +0. 1. -2. +3. 0.0 -0.1 +0.2 1.0 -2.1 +3.2 "
            "0.e0 0.e-1 0.e+2 1.e1 2.e-2 3.e+3 -1.e1 -2.e-2 -3.e+3 +1.e1 +2.e-2 +3.e+3 "
            "0.012345 1.23456 ( ) [ ] | & : -i "
            " \"abcxyzABCXYZ_ ( ) [ ] | & : -i \t\n \\\" ' \\012\\0\\377\\x00\\x12\\xab\\xCD\\xeF\\x1A\\xb2 \" "
            " 'abcxyzABCXYZ_ ( ) [ ] | & : -i \t\n \" \\' \\012\\0\\377\\x00\\x12\\xab\\xCD\\xeF\\x1A\\xb2 ' "
            " \\000abc_xyz123\"'\"'456 \\xA1a1 \\!\\?\\\\ "
            " 0x00 0x12 0xabCD 0xaBcD 0x0123456789aBcDeFfEdCbA", 50,
            {   I(0), I(0), I(0), I(1), I(-2), I(3), F(0.0), F(0.0), F(0.0),
                F(1.0), F(-2.0), F(3.0), F(0.0), F(-0.1), F(0.2), F(1.0), F(-2.1), F(3.2),
                F(0.0), F(0.0e-1), F(0.0e2), F(1.0e1), F(2.0e-2), F(3.0e3),
                F(-1.0e1), F(-2.0e-2), F(-3.0e3), F(1.0e1), F(2.0e-2), F(3.0e3),
                F(0.012345), F(1.23456), T(LeftParen), T(RightParen), T(LeftBracket),
                T(RightBracket), T(Divider), T(Ampersand), T(Colon), T(CaseInsensitiveFlag),
                S(std::string("abcxyzABCXYZ_ ( ) [ ] | & : -i \t\n \" ' \012\0\377\x00\x12\xab\xCD\xeF\x1A\xb2 ", 49)),
                S(std::string("abcxyzABCXYZ_ ( ) [ ] | & : -i \t\n \" ' \012\0\377\x00\x12\xab\xCD\xeF\x1A\xb2 ", 49)),
                S(std::string("\000abc_xyz123\"'\"'456", 18)),
                S("\241a1"),
                S("!?\\"),
                S(std::string("\x00", 1)), S("\x12"), S("\xAB\xCD"), S("\xAB\xCD"),
                S("\x01\x23\x45\x67\x89\xAB\xCD\xEF\xFE\xDC\xBA")
            }
        },
    };

// Undefine our nasty macros
#undef T
#undef S
#undef I
#undef F

    const int testCaseCount = sizeof(testCases) / sizeof(test_case);
    for (int i = 0; i < testCaseCount; i++) {
        NextSubTest();
//		cout << endl << testCases[i].rule << endl;
        TokenStream stream;
        try {
            stream.SetTo(testCases[i].rule);

            CHK(stream.InitCheck() == B_OK);
            for (int j = 0; j < testCases[i].tokenCount; j++) {
                const Token *token = stream.Get();
                CHK(token);
                /*
                				cout << tokenTypeToString(token->Type()) << endl;

                				if (token->Type() == CharacterString)
                					cout << " token1 == " << token->String() << endl;
                				if (testCases[i].tokens[j]->Type() == CharacterString)
                					cout << " token2 == " << (testCases[i].tokens[j])->String() << endl;

                				if (token->Type() == CharacterString)
                				{
                					const std::string &str = token->String();
                					printf("parser: ");
                					for (int i = 0; i < str.length(); i++)
                						printf("%x ", str[i]);
                					printf("\n");
                				}
                				if (testCases[i].tokens[j]->Type() == CharacterString)
                				{
                					const std::string &str = (testCases[i].tokens[j])->String();
                					printf("tester: ");
                					for (int i = 0; i < str.length(); i++)
                						printf("%x ", str[i]);
                					printf("\n");
                				}

                				switch (token->Type()) {
                					case CharacterString:
                						cout << " string == " << token->String() << endl;
                						break;
                					case Integer:
                						cout << " int == " << token->Int() << endl;
                						break;
                					case FloatingPoint:
                						cout << " float == " << token->Float() << endl;
                						break;
                				}
                */
                CHK(*token == *(testCases[i].tokens[j]));
                delete testCases[i].tokens[j];
            }
            CHK(stream.IsEmpty());
        } catch (Err *e) {
            CppUnit::Exception *err = new CppUnit::Exception(e->Msg());
            delete e;
            throw *err;
        }
    }

#endif	// !TEST_R5
}
开发者ID:yunxiaoxiao110,项目名称:haiku,代码行数:101,代码来源:MimeSnifferTest.cpp


注:本文中的TokenStream::IsEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。