Files
UltraGrid/test/misc_test.cpp
Martin Pulec 05aea72a3c moved some functions from misc to text
moved text-related functions from utils/misc to utils/text
2022-10-13 09:16:16 +02:00

55 lines
1.2 KiB
C++

#ifdef HAVE_CONFIG_H
#include "config.h"
#include "config_unix.h"
#include "config_win32.h"
#endif
#ifdef HAVE_CPPUNIT
#include <cppunit/config/SourcePrefix.h>
#include "misc_test.hpp"
#include "utils/text.h"
using std::string;
using std::to_string;
// Registers the fixture into the 'registry'
CPPUNIT_TEST_SUITE_REGISTRATION( misc_test );
misc_test::misc_test()
{
}
misc_test::~misc_test()
{
}
void
misc_test::setUp()
{
}
void
misc_test::tearDown()
{
}
#ifdef __clang__
#pragma clang diagnostic ignored "-Wstring-concatenation"
#endif
void
misc_test::test_replace_all()
{
char test[][20] = { DELDEL DELDEL DELDEL, DELDEL DELDEL, "XYZX" DELDEL, "XXXyX" };
const char *repl_from[] = { DELDEL , DELDEL, "X", "X" };
const char *repl_to[] = { ":" , ESCAPED_COLON, "x", "" };
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);
}
}
#endif // defined HAVE_CPPUNIT