diff --git a/testfiles/matroska_wave1-test3.json b/testfiles/matroska_wave1-test3.json new file mode 100644 index 0000000..f13c387 --- /dev/null +++ b/testfiles/matroska_wave1-test3.json @@ -0,0 +1,45 @@ +[ + { + "fileName": "test3.mkv", + "size": 21061472, + "mimeType": "video/x-matroska", + "tags": [ + { + "format": "Matroska tag", + "target": { + "level": 50, + "levelName": "", + "tracks": [], + "chapters": [], + "editions": [], + "attachments": [] + }, + "fields": { + "comment": [ + { + "kind": "text", + "mimeType": "", + "value": "Matroska Validation File 3, header stripping on the video track and no SimpleBlock" + } + ], + "title": [ + { + "kind": "text", + "mimeType": "", + "value": "Elephant Dream - test 3" + } + ], + "year": [ + { + "kind": "text", + "mimeType": "", + "value": "2010" + } + ] + } + } + ], + "formatSummary": "H.264-576p / MP3-2ch-eng", + "duration": "00:00:00" + } +] diff --git a/tests/cli.cpp b/tests/cli.cpp index 467bc99..d056581 100644 --- a/tests/cli.cpp +++ b/tests/cli.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -46,6 +47,7 @@ class CliTests : public TestFixture CPPUNIT_TEST(testExtraction); CPPUNIT_TEST(testReadingAndWritingDocumentTitle); CPPUNIT_TEST(testFileLayoutOptions); + CPPUNIT_TEST(testJsonExport); #endif CPPUNIT_TEST_SUITE_END(); @@ -68,6 +70,7 @@ public: void testExtraction(); void testReadingAndWritingDocumentTitle(); void testFileLayoutOptions(); + void testJsonExport(); #endif private: @@ -848,4 +851,19 @@ void CliTests::testFileLayoutOptions() remove(mp4File2.data()); remove((mp4File2 + ".bak").data()); } + +/*! + * \brief Tests the JSON export. + */ +void CliTests::testJsonExport() +{ + cout << "\nJSON export" << endl; + string stdout, stderr; + + const auto file(testFilePath("matroska_wave1/test3.mkv")); + const auto expectedJson(IoUtilities::readFile(testFilePath("matroska_wave1-test3.json"), 2048)); + const char *const args[] = {"tageditor", "export", "--pretty", "-f", file.data(), nullptr}; + TESTUTILS_ASSERT_EXEC(args); + CPPUNIT_ASSERT_EQUAL(expectedJson, stdout); +} #endif