summaryrefslogtreecommitdiff
path: root/tests/parser.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/parser.h')
-rw-r--r--tests/parser.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/parser.h b/tests/parser.h
new file mode 100644
index 00000000..65acadb5
--- /dev/null
+++ b/tests/parser.h
@@ -0,0 +1,65 @@
+#ifndef __TESTFILEFORMAT_H
+#define __TESTFILEFORMAT_H
+
+#include <cxxtest/TestSuite.h>
+
+#include <textual.h>
+#include <xml.h>
+#include <binary.h>
+#include <gnucash.h>
+#include <qif.h>
+
+using namespace std;
+using namespace ledger;
+
+class TestFileFormat : public CxxTest::TestSuite
+{
+public:
+ void testEmptyFileIsTextualFile()
+ {
+ stringstream emptyStream(stringstream::in);
+ textual_parser_t textualParser;
+ TS_ASSERT(textualParser.test(emptyStream));
+ TS_ASSERT(emptyStream.good());
+ TS_ASSERT_EQUALS(0, emptyStream.tellg());
+ }
+
+ void testEmptyFileIsNotXMLFile()
+ {
+ stringstream emptyStream(stringstream::in);
+ xml_parser_t xmlParser;
+ TS_ASSERT(!xmlParser.test(emptyStream));
+ TS_ASSERT(emptyStream.good());
+ TS_ASSERT_EQUALS(0, emptyStream.tellg());
+ }
+
+ void testEmptyFileIsNotBinaryFile()
+ {
+ stringstream emptyStream(stringstream::in);
+ binary_parser_t binaryParser;
+ TS_ASSERT(!binaryParser.test(emptyStream));
+ TS_ASSERT(emptyStream.good());
+ TS_ASSERT_EQUALS(0, emptyStream.tellg());
+ }
+
+ void testEmptyFileIsNotGnuCashFile()
+ {
+ stringstream emptyStream(stringstream::in);
+ gnucash_parser_t gnucashParser;
+ TS_ASSERT(!gnucashParser.test(emptyStream));
+ TS_ASSERT(emptyStream.good());
+ TS_ASSERT_EQUALS(0, emptyStream.tellg());
+ }
+
+ void testEmptyFileIsNotQIFFile()
+ {
+ stringstream emptyStream(stringstream::in);
+ qif_parser_t qifParser;
+ TS_ASSERT(!qifParser.test(emptyStream));
+ TS_ASSERT(emptyStream.good());
+ TS_ASSERT_EQUALS(0, emptyStream.tellg());
+ }
+
+};
+
+#endif // __TESTFILEFORMAT_H