Test JSON export

This commit is contained in:
Martchus 2018-02-03 17:41:58 +01:00
parent 9b3d80992a
commit 9633d248f5
2 changed files with 63 additions and 0 deletions

View File

@ -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"
}
]

View File

@ -1,5 +1,6 @@
#include <c++utilities/conversion/stringconversion.h>
#include <c++utilities/io/catchiofailure.h>
#include <c++utilities/io/misc.h>
#include <c++utilities/tests/testutils.h>
#include <tagparser/mediafileinfo.h>
@ -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