mkvtoolnix/tests/unit/init.cpp
2020-08-01 18:03:54 +02:00

52 lines
1.1 KiB
C++

/*
mkvmerge -- utility for splicing together matroska files
from component media subtypes
Distributed under the GPL
see the file COPYING for details
or visit https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
helper functions for unit tests
Written by Moritz Bunkus <moritz@bunkus.org>.
*/
#include "common/common_pch.h"
#include "tests/unit/init.h"
#include "common/hacks.h"
#include "common/unique_numbers.h"
namespace {
void
mxmsg_handler(unsigned int level,
std::string const &message) {
if (MXMSG_WARNING == level)
g_warning_issued = true;
else if (MXMSG_ERROR == level)
throw mtxut::mxerror_x{message};
}
}
void
mtxut::init_suite(char const *argv0) {
clear_list_of_unique_numbers(UNIQUE_ALL_IDS);
mtx_common_init("UNITTESTS", argv0);
set_mxmsg_handler(MXMSG_INFO, mxmsg_handler);
set_mxmsg_handler(MXMSG_WARNING, mxmsg_handler);
set_mxmsg_handler(MXMSG_ERROR, mxmsg_handler);
mtx::hacks::engage(mtx::hacks::NO_VARIABLE_DATA);
}
void
mtxut::init_case() {
clear_list_of_unique_numbers(UNIQUE_ALL_IDS);
g_warning_issued = false;
}