mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-19 21:09:01 +00:00
55 lines
1.2 KiB
C++
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
|