This commit is contained in:
2021-10-14 13:47:35 +02:00
commit 6625a8dfaa
4026 changed files with 844291 additions and 0 deletions
@@ -0,0 +1,70 @@
#######################################################################
# Software License Agreement (AGPL-3 License)
#
# OpenViBE SDK Test Software
# Based on OpenViBE V1.1.0, Copyright (C) Inria, 2006-2015
# Copyright (C) Inria, 2015-2017,V1.0
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License version 3,
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#######################################################################
PROJECT(openvibe-module-ebml-test)
# ---------------------------------
# Target macros
# Defines target operating system, architecture and compiler
# ---------------------------------
SET_BUILD_PLATFORM()
# ----------------------
# Configure test target
# ----------------------
# Test that needs to called with parameters
SET(TEST_WITH_PARAM
uoEBMLReaderTest.cpp
uoEBMLWriterTest.cpp
)
# Test that needs to called without parameters
SET(TEST_NO_PARAM
)
# Create test sources list
# This macro auto-generate ${PROJECT_NAME}.cpp
# in the build tree. ${PROJECT_NAME}.cpp is
# the test driver called by ctest to run
# the different tests added to this target.
CREATE_TEST_SOURCELIST (Tests
${PROJECT_NAME}.cpp
${TEST_WITH_PARAM}
${TEST_NO_PARAM}
)
ADD_EXECUTABLE(${PROJECT_NAME} ${Tests})
INCLUDE("FindOpenViBE")
INCLUDE("FindOpenViBECommon")
INCLUDE("FindOpenViBEModuleEBML")
SET_PROPERTY(TARGET ${PROJECT_NAME} PROPERTY FOLDER ${TESTS_FOLDER})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${OVT_UNIT_TOOLKIT_LIB} ${OV_MODULE_EBML})
# Add test without parameter to driver
FOREACH(test ${TEST_NO_PARAM})
GET_FILENAME_COMPONENT(TName ${test} NAME_WE)
ADD_TEST(NAME ${TName} COMMAND ${PROJECT_NAME} ${TName})
ENDFOREACH()
# Add test with parameter to driver
ADD_TEST(NAME uoEBMLReaderTest COMMAND ${PROJECT_NAME} uoEBMLReaderTest "${CMAKE_CURRENT_SOURCE_DIR}/data/" "${OVT_TEST_TEMPORARY_DIR}")
ADD_TEST(NAME uoEBMLWriterTest COMMAND ${PROJECT_NAME} uoEBMLWriterTest "${CMAKE_CURRENT_SOURCE_DIR}/data/" "${OVT_TEST_TEMPORARY_DIR}")
@@ -0,0 +1,408 @@
testing with n=17
Opening child node [0x000000000a45dfa3]
Opening child node [0x0000000000000282]
Got doc type : [matroska]
Node closed
Opening child node [0x0000000000000287]
Got doc type version : [0x0000000000000001]
Node closed
Opening child node [0x0000000000000285]
Got doc type read version : [0x000000000009fffc]
Node closed
Node closed
Opening child node [0x0000000000001234]
Got uinteger : [0x0000000000000000]
Node closed
Opening child node [0xffffffffffffffff]
Got uinteger : [0xff000000ff000000]
Node closed
Opening child node [0x0000000000004321]
Got double : [3.14159]
Node closed
Opening child node [0x0000000000008765]
Got float : [3.14159]
Node closed
testing with n=16
Opening child node [0x000000000a45dfa3]
Opening child node [0x0000000000000282]
Got doc type : [matroska]
Node closed
Opening child node [0x0000000000000287]
Got doc type version : [0x0000000000000001]
Node closed
Opening child node [0x0000000000000285]
Got doc type read version : [0x000000000009fffc]
Node closed
Node closed
Opening child node [0x0000000000001234]
Got uinteger : [0x0000000000000000]
Node closed
Opening child node [0xffffffffffffffff]
Got uinteger : [0xff000000ff000000]
Node closed
Opening child node [0x0000000000004321]
Got double : [3.14159]
Node closed
Opening child node [0x0000000000008765]
Got float : [3.14159]
Node closed
testing with n=15
Opening child node [0x000000000a45dfa3]
Opening child node [0x0000000000000282]
Got doc type : [matroska]
Node closed
Opening child node [0x0000000000000287]
Got doc type version : [0x0000000000000001]
Node closed
Opening child node [0x0000000000000285]
Got doc type read version : [0x000000000009fffc]
Node closed
Node closed
Opening child node [0x0000000000001234]
Got uinteger : [0x0000000000000000]
Node closed
Opening child node [0xffffffffffffffff]
Got uinteger : [0xff000000ff000000]
Node closed
Opening child node [0x0000000000004321]
Got double : [3.14159]
Node closed
Opening child node [0x0000000000008765]
Got float : [3.14159]
Node closed
testing with n=14
Opening child node [0x000000000a45dfa3]
Opening child node [0x0000000000000282]
Got doc type : [matroska]
Node closed
Opening child node [0x0000000000000287]
Got doc type version : [0x0000000000000001]
Node closed
Opening child node [0x0000000000000285]
Got doc type read version : [0x000000000009fffc]
Node closed
Node closed
Opening child node [0x0000000000001234]
Got uinteger : [0x0000000000000000]
Node closed
Opening child node [0xffffffffffffffff]
Got uinteger : [0xff000000ff000000]
Node closed
Opening child node [0x0000000000004321]
Got double : [3.14159]
Node closed
Opening child node [0x0000000000008765]
Got float : [3.14159]
Node closed
testing with n=13
Opening child node [0x000000000a45dfa3]
Opening child node [0x0000000000000282]
Got doc type : [matroska]
Node closed
Opening child node [0x0000000000000287]
Got doc type version : [0x0000000000000001]
Node closed
Opening child node [0x0000000000000285]
Got doc type read version : [0x000000000009fffc]
Node closed
Node closed
Opening child node [0x0000000000001234]
Got uinteger : [0x0000000000000000]
Node closed
Opening child node [0xffffffffffffffff]
Got uinteger : [0xff000000ff000000]
Node closed
Opening child node [0x0000000000004321]
Got double : [3.14159]
Node closed
Opening child node [0x0000000000008765]
Got float : [3.14159]
Node closed
testing with n=12
Opening child node [0x000000000a45dfa3]
Opening child node [0x0000000000000282]
Got doc type : [matroska]
Node closed
Opening child node [0x0000000000000287]
Got doc type version : [0x0000000000000001]
Node closed
Opening child node [0x0000000000000285]
Got doc type read version : [0x000000000009fffc]
Node closed
Node closed
Opening child node [0x0000000000001234]
Got uinteger : [0x0000000000000000]
Node closed
Opening child node [0xffffffffffffffff]
Got uinteger : [0xff000000ff000000]
Node closed
Opening child node [0x0000000000004321]
Got double : [3.14159]
Node closed
Opening child node [0x0000000000008765]
Got float : [3.14159]
Node closed
testing with n=11
Opening child node [0x000000000a45dfa3]
Opening child node [0x0000000000000282]
Got doc type : [matroska]
Node closed
Opening child node [0x0000000000000287]
Got doc type version : [0x0000000000000001]
Node closed
Opening child node [0x0000000000000285]
Got doc type read version : [0x000000000009fffc]
Node closed
Node closed
Opening child node [0x0000000000001234]
Got uinteger : [0x0000000000000000]
Node closed
Opening child node [0xffffffffffffffff]
Got uinteger : [0xff000000ff000000]
Node closed
Opening child node [0x0000000000004321]
Got double : [3.14159]
Node closed
Opening child node [0x0000000000008765]
Got float : [3.14159]
Node closed
testing with n=10
Opening child node [0x000000000a45dfa3]
Opening child node [0x0000000000000282]
Got doc type : [matroska]
Node closed
Opening child node [0x0000000000000287]
Got doc type version : [0x0000000000000001]
Node closed
Opening child node [0x0000000000000285]
Got doc type read version : [0x000000000009fffc]
Node closed
Node closed
Opening child node [0x0000000000001234]
Got uinteger : [0x0000000000000000]
Node closed
Opening child node [0xffffffffffffffff]
Got uinteger : [0xff000000ff000000]
Node closed
Opening child node [0x0000000000004321]
Got double : [3.14159]
Node closed
Opening child node [0x0000000000008765]
Got float : [3.14159]
Node closed
testing with n=9
Opening child node [0x000000000a45dfa3]
Opening child node [0x0000000000000282]
Got doc type : [matroska]
Node closed
Opening child node [0x0000000000000287]
Got doc type version : [0x0000000000000001]
Node closed
Opening child node [0x0000000000000285]
Got doc type read version : [0x000000000009fffc]
Node closed
Node closed
Opening child node [0x0000000000001234]
Got uinteger : [0x0000000000000000]
Node closed
Opening child node [0xffffffffffffffff]
Got uinteger : [0xff000000ff000000]
Node closed
Opening child node [0x0000000000004321]
Got double : [3.14159]
Node closed
Opening child node [0x0000000000008765]
Got float : [3.14159]
Node closed
testing with n=8
Opening child node [0x000000000a45dfa3]
Opening child node [0x0000000000000282]
Got doc type : [matroska]
Node closed
Opening child node [0x0000000000000287]
Got doc type version : [0x0000000000000001]
Node closed
Opening child node [0x0000000000000285]
Got doc type read version : [0x000000000009fffc]
Node closed
Node closed
Opening child node [0x0000000000001234]
Got uinteger : [0x0000000000000000]
Node closed
Opening child node [0xffffffffffffffff]
Got uinteger : [0xff000000ff000000]
Node closed
Opening child node [0x0000000000004321]
Got double : [3.14159]
Node closed
Opening child node [0x0000000000008765]
Got float : [3.14159]
Node closed
testing with n=7
Opening child node [0x000000000a45dfa3]
Opening child node [0x0000000000000282]
Got doc type : [matroska]
Node closed
Opening child node [0x0000000000000287]
Got doc type version : [0x0000000000000001]
Node closed
Opening child node [0x0000000000000285]
Got doc type read version : [0x000000000009fffc]
Node closed
Node closed
Opening child node [0x0000000000001234]
Got uinteger : [0x0000000000000000]
Node closed
Opening child node [0xffffffffffffffff]
Got uinteger : [0xff000000ff000000]
Node closed
Opening child node [0x0000000000004321]
Got double : [3.14159]
Node closed
Opening child node [0x0000000000008765]
Got float : [3.14159]
Node closed
testing with n=6
Opening child node [0x000000000a45dfa3]
Opening child node [0x0000000000000282]
Got doc type : [matroska]
Node closed
Opening child node [0x0000000000000287]
Got doc type version : [0x0000000000000001]
Node closed
Opening child node [0x0000000000000285]
Got doc type read version : [0x000000000009fffc]
Node closed
Node closed
Opening child node [0x0000000000001234]
Got uinteger : [0x0000000000000000]
Node closed
Opening child node [0xffffffffffffffff]
Got uinteger : [0xff000000ff000000]
Node closed
Opening child node [0x0000000000004321]
Got double : [3.14159]
Node closed
Opening child node [0x0000000000008765]
Got float : [3.14159]
Node closed
testing with n=5
Opening child node [0x000000000a45dfa3]
Opening child node [0x0000000000000282]
Got doc type : [matroska]
Node closed
Opening child node [0x0000000000000287]
Got doc type version : [0x0000000000000001]
Node closed
Opening child node [0x0000000000000285]
Got doc type read version : [0x000000000009fffc]
Node closed
Node closed
Opening child node [0x0000000000001234]
Got uinteger : [0x0000000000000000]
Node closed
Opening child node [0xffffffffffffffff]
Got uinteger : [0xff000000ff000000]
Node closed
Opening child node [0x0000000000004321]
Got double : [3.14159]
Node closed
Opening child node [0x0000000000008765]
Got float : [3.14159]
Node closed
testing with n=4
Opening child node [0x000000000a45dfa3]
Opening child node [0x0000000000000282]
Got doc type : [matroska]
Node closed
Opening child node [0x0000000000000287]
Got doc type version : [0x0000000000000001]
Node closed
Opening child node [0x0000000000000285]
Got doc type read version : [0x000000000009fffc]
Node closed
Node closed
Opening child node [0x0000000000001234]
Got uinteger : [0x0000000000000000]
Node closed
Opening child node [0xffffffffffffffff]
Got uinteger : [0xff000000ff000000]
Node closed
Opening child node [0x0000000000004321]
Got double : [3.14159]
Node closed
Opening child node [0x0000000000008765]
Got float : [3.14159]
Node closed
testing with n=3
Opening child node [0x000000000a45dfa3]
Opening child node [0x0000000000000282]
Got doc type : [matroska]
Node closed
Opening child node [0x0000000000000287]
Got doc type version : [0x0000000000000001]
Node closed
Opening child node [0x0000000000000285]
Got doc type read version : [0x000000000009fffc]
Node closed
Node closed
Opening child node [0x0000000000001234]
Got uinteger : [0x0000000000000000]
Node closed
Opening child node [0xffffffffffffffff]
Got uinteger : [0xff000000ff000000]
Node closed
Opening child node [0x0000000000004321]
Got double : [3.14159]
Node closed
Opening child node [0x0000000000008765]
Got float : [3.14159]
Node closed
testing with n=2
Opening child node [0x000000000a45dfa3]
Opening child node [0x0000000000000282]
Got doc type : [matroska]
Node closed
Opening child node [0x0000000000000287]
Got doc type version : [0x0000000000000001]
Node closed
Opening child node [0x0000000000000285]
Got doc type read version : [0x000000000009fffc]
Node closed
Node closed
Opening child node [0x0000000000001234]
Got uinteger : [0x0000000000000000]
Node closed
Opening child node [0xffffffffffffffff]
Got uinteger : [0xff000000ff000000]
Node closed
Opening child node [0x0000000000004321]
Got double : [3.14159]
Node closed
Opening child node [0x0000000000008765]
Got float : [3.14159]
Node closed
testing with n=1
Opening child node [0x000000000a45dfa3]
Opening child node [0x0000000000000282]
Got doc type : [matroska]
Node closed
Opening child node [0x0000000000000287]
Got doc type version : [0x0000000000000001]
Node closed
Opening child node [0x0000000000000285]
Got doc type read version : [0x000000000009fffc]
Node closed
Node closed
Opening child node [0x0000000000001234]
Got uinteger : [0x0000000000000000]
Node closed
Opening child node [0xffffffffffffffff]
Got uinteger : [0xff000000ff000000]
Node closed
Opening child node [0x0000000000004321]
Got double : [3.14159]
Node closed
Opening child node [0x0000000000008765]
Got float : [3.14159]
Node closed
@@ -0,0 +1,169 @@
/*********************************************************************
* Software License Agreement (AGPL-3 License)
*
* OpenViBE SDK Test Software
* Based on OpenViBE V1.1.0, Copyright (C) Inria, 2006-2015
* Copyright (C) Inria, 2015-2017,V1.0
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <iomanip>
#include <fstream>
#include "ebml/IReader.h"
#include "ebml/CReader.h"
#include "ebml/CReaderHelper.h"
#include "ovtAssert.h"
std::ofstream g_OutputStream;
class CReaderCallBack : public EBML::IReaderCallBack
{
public:
CReaderCallBack() { }
~CReaderCallBack() override { }
bool isMasterChild(const EBML::CIdentifier& identifier) override
{
if (identifier == EBML_Identifier_Header) { return true; }
if (identifier == EBML::CIdentifier(0xffff)) { return true; }
return false;
}
void openChild(const EBML::CIdentifier& identifier) override
{
m_CurrentID = identifier;
for (int i = 0; i < m_Depth; ++i) { g_OutputStream << " "; }
g_OutputStream << "Opening child node [0x" << std::setw(16) << std::setfill('0') << std::hex << m_CurrentID << std::dec << "]\n";
m_Depth++;
}
void processChildData(const void* buffer, const size_t size) override
{
for (int i = 0; i < m_Depth; ++i) { g_OutputStream << " "; }
if (m_CurrentID == EBML_Identifier_DocType) { g_OutputStream << "Got doc type : [" << m_helper.getStr(buffer, size) << "]\n"; }
else if (m_CurrentID == EBML_Identifier_EBMLVersion)
{
g_OutputStream << "Got EBML version : [0x" << std::setw(16) << std::setfill('0') << std::hex << m_helper.getUInt(buffer, size) << std::dec << "]\n";
}
else if (m_CurrentID == EBML_Identifier_EBMLIdLength)
{
g_OutputStream << "Got EBML ID length : [0x" << std::setw(16) << std::setfill('0') << std::hex << m_helper.getUInt(buffer, size) << std::dec <<
"]\n";
}
else if (m_CurrentID == EBML_Identifier_DocTypeVersion)
{
g_OutputStream << "Got doc type version : [0x" << std::setw(16) << std::setfill('0') << std::hex << m_helper.getUInt(buffer, size) << std::dec <<
"]\n";
}
else if (m_CurrentID == EBML_Identifier_DocTypeReadVersion)
{
g_OutputStream << "Got doc type read version : [0x" << std::setw(16) << std::setfill('0') << std::hex << m_helper.getUInt(buffer, size) << std::dec
<< "]\n";
}
else if (m_CurrentID == EBML::CIdentifier(0x1234))
{
g_OutputStream << "Got uinteger : [0x" << std::setw(16) << std::setfill('0') << std::hex << m_helper.getUInt(buffer, size) << std::dec << "]\n";
}
else if (m_CurrentID == EBML::CIdentifier(0xffffffffffffffffLL))
{
g_OutputStream << "Got uinteger : [0x" << std::setw(16) << std::setfill('0') << std::hex << m_helper.getUInt(buffer, size) << std::dec << "]\n";
}
else if (m_CurrentID == EBML::CIdentifier(0x4321)) { g_OutputStream << "Got double : [" << m_helper.getDouble(buffer, size) << "]\n"; }
else if (m_CurrentID == EBML::CIdentifier(0x8765)) { g_OutputStream << "Got float : [" << m_helper.getDouble(buffer, size) << "]\n"; }
else { g_OutputStream << "Got " << size << " data bytes, node id not known\n"; }
}
void closeChild() override
{
m_Depth--;
for (int i = 0; i < m_Depth; ++i) { g_OutputStream << " "; }
g_OutputStream << "Node closed\n";
}
private:
int m_Depth = 0;
EBML::CReaderHelper m_helper;
EBML::CIdentifier m_CurrentID;
};
int uoEBMLReaderTest(int argc, char* argv[])
{
OVT_ASSERT(argc == 3, "Failure to retrieve tests arguments. Expecting: data_dir output_dir");
std::string dataFile = std::string(argv[1]) + "ref_data.ebml";
std::string expectedFile = std::string(argv[1]) + "ref_result.txt";
std::string outputFile = std::string(argv[2]) + "uoEBMLReaderTest.txt";
// The test parses a known ebml file,
// writes the results into a text file and compares the output
// text file to a reference text file.
g_OutputStream.open(outputFile);
OVT_ASSERT(g_OutputStream.is_open(), "Failure to open output file for writing");
// parsing
for (size_t n = 17; n >= 1; n--)
{
CReaderCallBack callback;
EBML::CReader reader(callback);
g_OutputStream << "testing with n=" << n << std::endl;
FILE* file = fopen(dataFile.c_str(), "rb");
OVT_ASSERT(file != nullptr, "Failure to open data file for reading");
unsigned char* c = new unsigned char[n];
size_t i = 0;
while (!feof(file))
{
i = fread(c, 1, n * sizeof(unsigned char), file);
reader.processData(c, i);
}
delete[] c;
fclose(file);
}
g_OutputStream.close();
// comparison part
std::ifstream generatedStream(outputFile);
std::ifstream expectedStream(expectedFile);
OVT_ASSERT(generatedStream.is_open(), "Failure to open generated results for reading");
OVT_ASSERT(expectedStream.is_open(), "Failure to open expected results for reading");
std::string generatedString;
std::string expectedString;
while (std::getline(expectedStream, expectedString))
{
OVT_ASSERT(std::getline(generatedStream, generatedString), "Failure to retrieve a line to match");
OVT_ASSERT_STREQ(expectedString, generatedString, "Failure to match expected line to generated line");
}
// last check to verify the expected file has no additional line
OVT_ASSERT(!std::getline(generatedStream, generatedString), "Failure to match expected file size and generated file size");
return EXIT_SUCCESS;
}
@@ -0,0 +1,140 @@
/*********************************************************************
* Software License Agreement (AGPL-3 License)
*
* OpenViBE SDK Test Software
* Based on OpenViBE V1.1.0, Copyright (C) Inria, 2006-2015
* Copyright (C) Inria, 2015-2017,V1.0
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <iomanip>
#include <fstream>
#include <cstdio>
#include "ebml/defines.h"
#include "ebml/IWriter.h"
#include "ebml/CWriterHelper.h"
#include "ovtAssert.h"
#include <iostream>
#define OVP_NodeId_OpenViBEStream_Header EBML::CIdentifier(0xF59505AB, 0x3684C8D8)
#define OVP_NodeId_OpenViBEStream_Header_Compression EBML::CIdentifier(0x40358769, 0x166380D1)
#define OVP_NodeId_OpenViBEStream_Header_StreamType EBML::CIdentifier(0x732EC1D1, 0xFE904087)
#define OVP_NodeId_OpenViBEStream_Buffer EBML::CIdentifier(0x2E60AD18, 0x87A29BDF)
#define OVP_NodeId_OpenViBEStream_Buffer_StreamIndex EBML::CIdentifier(0x30A56D8A, 0xB9C12238)
#define OVP_NodeId_OpenViBEStream_Buffer_StartTime EBML::CIdentifier(0x093E6A0A, 0xC5A9467B)
#define OVP_NodeId_OpenViBEStream_Buffer_EndTime EBML::CIdentifier(0x8B5CCCD9, 0xC5024F29)
#define OVP_NodeId_OpenViBEStream_Buffer_Content EBML::CIdentifier(0x8D4B0BE8, 0x7051265C)
#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795
#endif
class CWriterCallBack : public EBML::IWriterCallBack
{
public:
CWriterCallBack(const char* filename) { m_file = std::fopen(filename, "wb"); }
~CWriterCallBack() override { if (m_file) { std::fclose(m_file); } } // in case release is not called
void write(const void* buffer, const size_t size) override { if (m_file) { std::fwrite(buffer, size_t(size), 1, m_file); } }
// necessary thjor the test to close the stream and re-open it for inspection
void release()
{
std::fclose(m_file);
m_file = nullptr;
}
private:
std::FILE* m_file{ nullptr };
};
int uoEBMLWriterTest(int argc, char* argv[])
{
OVT_ASSERT(argc == 3, "Failure to retrieve tests arguments. Expecting: data_dir output_dir");
const std::string expectedFile = std::string(argv[1]) + "ref_data.ebml";
const std::string outputFile = std::string(argv[2]) + "uoEBMLWriterTest.ebml";
// The test serializes a known ebml sequence and compares the output
// to a reference.
// serializing
CWriterCallBack callback(outputFile.c_str());
EBML::IWriter* writer = createWriter(callback);
EBML::CWriterHelper helper;
helper.connect(writer);
helper.openChild(EBML_Identifier_Header);
helper.openChild(EBML_Identifier_DocType);
helper.setStr("matroska");
helper.closeChild();
helper.openChild(EBML_Identifier_DocTypeVersion);
helper.setUInt(1);
helper.closeChild();
helper.openChild(EBML_Identifier_DocTypeReadVersion);
helper.setInt(655356);
helper.closeChild();
helper.closeChild();
helper.openChild(0x1234);
helper.setUInt(0);
helper.closeChild();
helper.openChild(0xffffffffffffffffLL);
helper.setUInt(0xff000000ff000000LL);
helper.closeChild();
helper.openChild(0x4321);
helper.setDouble(M_PI);
helper.closeChild();
helper.openChild(0x8765);
helper.setFloat(float(M_PI));
helper.closeChild();
writer->release();
callback.release();
// comparison part
std::ifstream generatedStream(outputFile, std::ios::binary);
std::ifstream expectedStream(expectedFile, std::ios::binary);
OVT_ASSERT(generatedStream.is_open(), "Failure to open generated ebml stream for reading");
OVT_ASSERT(expectedStream.is_open(), "Failure to open reference stream for reading");
char generatedChar;
char expectedChar;
while (expectedStream.get(expectedChar))
{
OVT_ASSERT(generatedStream.get(generatedChar), "Failure to retrieve a char to match");
OVT_ASSERT(generatedChar == expectedChar, "Failure to match expected char to generated char");
}
// last check to verify the expected file has no additional line
OVT_ASSERT(!generatedStream.get(generatedChar), "Failure to match expected file size and generated file size");
return EXIT_SUCCESS;
}