# # # add_file "tests/StdioParserTest.h" # content [530b1e0e4a35ee4d8a738025270d12b3748abe47] # # patch "tests/test.cpp" # from [1bc1c23455d91468e22f229dffa8fcee9277a8a9] # to [5c0d58e33ae0f5c94e1165555413fe17a9c89c35] # # patch "tests/test.pro" # from [5005bf499b91c8cf6e51e3c74915ee1d9069a312] # to [a26d718f0957faf3945331cd06b5c562fc1ac210] # ============================================================ --- tests/StdioParserTest.h 530b1e0e4a35ee4d8a738025270d12b3748abe47 +++ tests/StdioParserTest.h 530b1e0e4a35ee4d8a738025270d12b3748abe47 @@ -0,0 +1,36 @@ + +#include +#include +#include "StdioParser.h" + +/* + StdioParser(const QByteArray &); + + bool parse(); + inline int getCommandNumber() const { return commandNumber; } + inline int getErrorCode() const { return errorCode; } + inline char getChunkType() const { return chunkType; } + inline int getChunkSize() const { return chunkSize; } + inline QByteArray getPayload() const { return payload; } + +*/ + +class StdioParserTest: public QObject +{ + Q_OBJECT + +private slots: + void emptyPayloadTest() + { + QByteArray in("2:0:l:0:"); + StdioParser parser(in); + QVERIFY(parser.parse()); + QVERIFY(parser.getCommandNumber() == 2); + QVERIFY(parser.getErrorCode() == 0); + QVERIFY(parser.getChunkType() == 'l'); + QVERIFY(parser.getChunkSize() == 0); + QByteArray out = parser.getPayload(); + QVERIFY(out.isNull()); + } +}; + ============================================================ --- tests/test.cpp 1bc1c23455d91468e22f229dffa8fcee9277a8a9 +++ tests/test.cpp 5c0d58e33ae0f5c94e1165555413fe17a9c89c35 @@ -1,10 +1,16 @@ +#include + +#define TEST(name, argc, argv) QTest::qExec(new name(), argc, argv); + #include "TestTest.h" +#include "StdioParserTest.h" int main(int argc, char** argv) { QCoreApplication app(argc, argv); - QTest::qExec(&TestTest(), argc, argv); + TEST(TestTest, argc, argv); + TEST(StdioParserTest, argc, argv); } ============================================================ --- tests/test.pro 5005bf499b91c8cf6e51e3c74915ee1d9069a312 +++ tests/test.pro a26d718f0957faf3945331cd06b5c562fc1ac210 @@ -1,16 +1,19 @@ INCLUDEPATH = . \ TEMPLATE = app TARGET = test CONFIG += qt debug qtestlib INCLUDEPATH = . \ - ../guitone/src/ \ - ../guitone/src/view \ - ../guitone/src/view/dialogs \ - ../guitone/src/model \ - ../guitone/src/monotone \ - ../guitone/src/util -HEADERS += TestTest.h -SOURCES += test.cpp + ../src/ \ + ../src/view \ + ../src/view/dialogs \ + ../src/model \ + ../src/monotone \ + ../src/util +HEADERS += TestTest.h \ + StdioParserTest.h +SOURCES += test.cpp \ + ../src/util/StdioParser.cpp \ + ../src/util/AbstractParser.cpp OBJECTS_DIR = tmp MOC_DIR = tmp