rewritten all remaining tests without cppunit

This commit is contained in:
Martin Pulec
2023-03-07 13:58:29 +01:00
parent 8b61de68d9
commit 84db4767bb
15 changed files with 170 additions and 362 deletions

View File

@@ -4,42 +4,26 @@
#include "config_win32.h"
#endif
#ifdef HAVE_CPPUNIT
#include <list>
#include <sstream>
#include <cppunit/config/SourcePrefix.h>
#include "misc_test.hpp"
#include "types.h"
#include "utils/text.h"
#include "unit_common.h"
#include "video.h"
#include "video_frame.h"
using std::string;
using std::to_string;
// Registers the fixture into the 'registry'
CPPUNIT_TEST_SUITE_REGISTRATION( misc_test );
misc_test::misc_test()
{
extern "C" {
bool misc_test_replace_all();
bool misc_test_video_desc_io_op_symmetry();
}
misc_test::~misc_test()
{
}
void
misc_test::setUp()
{
}
void
misc_test::tearDown()
{
}
using namespace std;
#ifdef __clang__
#pragma clang diagnostic ignored "-Wstring-concatenation"
#endif
void
misc_test::test_replace_all()
bool misc_test_replace_all()
{
char test[][20] = { DELDEL DELDEL DELDEL, DELDEL DELDEL, "XYZX" DELDEL, "XXXyX" };
const char *repl_from[] = { DELDEL , DELDEL, "X", "X" };
@@ -47,8 +31,30 @@ misc_test::test_replace_all()
const char *res[] = { ":::" , ESCAPED_COLON ESCAPED_COLON, "xYZx" DELDEL, "y" };
for (unsigned i = 0; i < sizeof test / sizeof test[0]; ++i) {
replace_all(test[i], repl_from[i], repl_to[i]);
CPPUNIT_ASSERT(strcmp(test[i], res[i]) == 0);
ASSERT(strcmp(test[i], res[i]) == 0);
}
return true;
}
#endif // defined HAVE_CPPUNIT
bool misc_test_video_desc_io_op_symmetry()
{
const std::list<video_desc> test_desc = {
{1920, 1080, DXT5, 60, PROGRESSIVE, 4},
{640, 480, H264, 15, PROGRESSIVE, 1}};
for (const auto & i : test_desc) {
video_desc tmp;
ostringstream oss;
oss << i;
istringstream iss(oss.str());
iss >> tmp;
// Check
ostringstream oss2;
oss2 << tmp;
string err_elem = oss.str() + " vs " + oss2.str();
ASSERT_MESSAGE(err_elem, video_desc_eq(tmp, i));
ASSERT_EQUAL_MESSAGE(err_elem, tmp, i);
}
return true;
}