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

@@ -251,7 +251,6 @@ TEST_OBJS = $(COMMON_OBJS) \
test/gpujpeg_test.o \
test/libavcodec_test.o \
test/misc_test.o \
test/video_desc_test.o \
test/test_bitstream.o \
test/test_aes.o \
test/test_des.o \

View File

@@ -10,6 +10,7 @@
#include <string>
#include <utility>
#include "unit_common.h"
#include "video_codec.h"
#include "video_capture/testcard_common.h"
@@ -20,11 +21,6 @@ using std::string;
using std::to_string;
using std::ostringstream;
#define ASSERT_EQUAL_MESSAGE(msg, expected, actual) if ((expected) != (actual)) { \
cerr << "Assertion failed - expected " << (expected) << ", actual : " << (actual) << ": " << (msg) << "\n"; \
return false; \
}
extern "C" bool codec_conversion_test_testcard_uyvy_to_i420(void);
bool codec_conversion_test_testcard_uyvy_to_i420(void)

View File

@@ -17,6 +17,7 @@
#include "libavcodec/from_lavc_vid_conv.h"
#include "libavcodec/to_lavc_vid_conv.h"
#include "tv.h"
#include "unit_common.h"
#include "video_capture/testcard_common.h"
#include "video_codec.h"
@@ -45,11 +46,6 @@ extern "C" {
bool ff_codec_conversions_test_pX10_from_to_v210();
}
#define ASSERT_MESSAGE(msg, expr) if (!(expr)) { \
cerr << "Assertion " << #expr << " failed: " << (msg) << "\n"; \
return false; \
}
#define CHECK(expr) if (!(expr)) { return false; }
#define TIMER(t) struct timeval t{}; gettimeofday(&(t), nullptr)

View File

@@ -4,102 +4,85 @@
#include "config_win32.h"
#endif
#ifdef HAVE_CPPUNIT
#include <cppunit/config/SourcePrefix.h>
#include <cmath>
#include <iostream>
#include <string>
#include "get_framerate_test.hpp"
#include "unit_common.h"
#include "utils/misc.h"
/// for 10 FPS the difference between 10000/1000 and 10000/1001 is ~0.001
/// and this needs to be less than a half of that
#define EPS 0.0049
using std::cerr;
using std::string;
using std::to_string;
// Registers the fixture into the 'registry'
CPPUNIT_TEST_SUITE_REGISTRATION( get_framerate_test );
get_framerate_test::get_framerate_test()
{
extern "C" {
bool get_framerate_test();
bool get_framerate_test_2997();
bool get_framerate_test_3000();
bool get_framerate_test_free();
}
get_framerate_test::~get_framerate_test()
{
}
void
get_framerate_test::setUp()
{
}
void
get_framerate_test::tearDown()
{
}
void
get_framerate_test::test_2997()
bool get_framerate_test_2997()
{
// approx
CPPUNIT_ASSERT_EQUAL(30000, get_framerate_n(29.97));
CPPUNIT_ASSERT_EQUAL(1001, get_framerate_d(29.97));
ASSERT_EQUAL(30000, get_framerate_n(29.97));
ASSERT_EQUAL(1001, get_framerate_d(29.97));
// "exactly" 30000/1001
CPPUNIT_ASSERT_EQUAL(30000, get_framerate_n(30000.0/1001));
CPPUNIT_ASSERT_EQUAL(1001, get_framerate_d(30000.0/1001));
ASSERT_EQUAL(30000, get_framerate_n(30000.0/1001));
ASSERT_EQUAL(1001, get_framerate_d(30000.0/1001));
// with epsilon
CPPUNIT_ASSERT_EQUAL(30000, get_framerate_n(30000.0/1001 + EPS));
CPPUNIT_ASSERT_EQUAL(30000, get_framerate_n(30000.0/1001 + EPS));
CPPUNIT_ASSERT_EQUAL(1001, get_framerate_d(30000.0/1001 - EPS));
CPPUNIT_ASSERT_EQUAL(1001, get_framerate_d(30000.0/1001 - EPS));
ASSERT_EQUAL(30000, get_framerate_n(30000.0/1001 + EPS));
ASSERT_EQUAL(30000, get_framerate_n(30000.0/1001 + EPS));
ASSERT_EQUAL(1001, get_framerate_d(30000.0/1001 - EPS));
ASSERT_EQUAL(1001, get_framerate_d(30000.0/1001 - EPS));
return true;
}
void
get_framerate_test::test_3000()
bool get_framerate_test_3000()
{
CPPUNIT_ASSERT_EQUAL(30000, get_framerate_n(30));
CPPUNIT_ASSERT_EQUAL(1000, get_framerate_d(30));
ASSERT_EQUAL(30000, get_framerate_n(30));
ASSERT_EQUAL(1000, get_framerate_d(30));
CPPUNIT_ASSERT_EQUAL(30000, get_framerate_n(30 + EPS));
CPPUNIT_ASSERT_EQUAL(1000, get_framerate_d(30 + EPS));
CPPUNIT_ASSERT_EQUAL(30000, get_framerate_n(30 - EPS));
CPPUNIT_ASSERT_EQUAL(1000, get_framerate_d(30 - EPS));
ASSERT_EQUAL(30000, get_framerate_n(30 + EPS));
ASSERT_EQUAL(1000, get_framerate_d(30 + EPS));
ASSERT_EQUAL(30000, get_framerate_n(30 - EPS));
ASSERT_EQUAL(1000, get_framerate_d(30 - EPS));
return true;
}
void
get_framerate_test::test_free()
bool get_framerate_test_free()
{
for (int i = 10; i < 480; ++i) {
// base 1000
string num_str = to_string(i);
CPPUNIT_ASSERT_EQUAL_MESSAGE(num_str, i * 1000, get_framerate_n(i));
CPPUNIT_ASSERT_EQUAL_MESSAGE(num_str, 1000, get_framerate_d(i));
CPPUNIT_ASSERT_EQUAL_MESSAGE(num_str, i * 1000, get_framerate_n(i + EPS));
CPPUNIT_ASSERT_EQUAL_MESSAGE(num_str, 1000, get_framerate_d(i + EPS));
CPPUNIT_ASSERT_EQUAL_MESSAGE(num_str, i * 1000, get_framerate_n(i - EPS));
CPPUNIT_ASSERT_EQUAL_MESSAGE(num_str, 1000, get_framerate_d(i - EPS));
ASSERT_EQUAL_MESSAGE(num_str, i * 1000, get_framerate_n(i));
ASSERT_EQUAL_MESSAGE(num_str, 1000, get_framerate_d(i));
ASSERT_EQUAL_MESSAGE(num_str, i * 1000, get_framerate_n(i + EPS));
ASSERT_EQUAL_MESSAGE(num_str, 1000, get_framerate_d(i + EPS));
ASSERT_EQUAL_MESSAGE(num_str, i * 1000, get_framerate_n(i - EPS));
ASSERT_EQUAL_MESSAGE(num_str, 1000, get_framerate_d(i - EPS));
// base 1001
double num = i * 1000.0 / 1001.0;
num_str = to_string(num);
CPPUNIT_ASSERT_EQUAL_MESSAGE(num_str, i * 1000, get_framerate_n(num));
CPPUNIT_ASSERT_EQUAL_MESSAGE(num_str, 1001, get_framerate_d(num));
CPPUNIT_ASSERT_EQUAL_MESSAGE(num_str, i * 1000, get_framerate_n(num + EPS));
CPPUNIT_ASSERT_EQUAL_MESSAGE(num_str, 1001, get_framerate_d(num + EPS));
CPPUNIT_ASSERT_EQUAL_MESSAGE(num_str, i * 1000, get_framerate_n(num - EPS));
CPPUNIT_ASSERT_EQUAL_MESSAGE(num_str, 1001, get_framerate_d(num - EPS));
ASSERT_EQUAL_MESSAGE(num_str, i * 1000, get_framerate_n(num));
ASSERT_EQUAL_MESSAGE(num_str, 1001, get_framerate_d(num));
ASSERT_EQUAL_MESSAGE(num_str, i * 1000, get_framerate_n(num + EPS));
ASSERT_EQUAL_MESSAGE(num_str, 1001, get_framerate_d(num + EPS));
ASSERT_EQUAL_MESSAGE(num_str, i * 1000, get_framerate_n(num - EPS));
ASSERT_EQUAL_MESSAGE(num_str, 1001, get_framerate_d(num - EPS));
// halves
num = i + 0.5;
num_str = to_string(num);
CPPUNIT_ASSERT_EQUAL_MESSAGE(num_str, (int) round(num * 1000), get_framerate_n(num));
CPPUNIT_ASSERT_EQUAL_MESSAGE(num_str, 1000, get_framerate_d(num));
ASSERT_EQUAL_MESSAGE(num_str, (int) round(num * 1000), get_framerate_n(num));
ASSERT_EQUAL_MESSAGE(num_str, 1000, get_framerate_d(num));
}
return true;
}
#endif // defined HAVE_CPPUNIT

View File

@@ -1,28 +0,0 @@
#ifndef GET_FRAMERATE_TEST_HPP
#define GET_FRAMERATE_TEST_HPP
#include <cppunit/extensions/HelperMacros.h>
#include <list>
#include "utils/misc.h"
class get_framerate_test : public CPPUNIT_NS::TestFixture
{
CPPUNIT_TEST_SUITE( get_framerate_test );
CPPUNIT_TEST( test_2997 );
CPPUNIT_TEST( test_3000 );
CPPUNIT_TEST( test_free );
CPPUNIT_TEST_SUITE_END();
public:
get_framerate_test();
~get_framerate_test();
void setUp();
void tearDown();
void test_2997();
void test_3000();
void test_free();
};
#endif // !defined GET_FRAMERATE_TEST_HPP

View File

@@ -4,18 +4,19 @@
#include "config_win32.h"
#endif
#if defined HAVE_CPPUNIT && defined HAVE_GPUJPEG
extern "C" bool gpujpeg_test_simple();
#if defined HAVE_GPUJPEG
#include <algorithm>
#include <cppunit/config/SourcePrefix.h>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include "gpujpeg_test.h"
#include "host.h"
#include "module.h"
#include "unit_common.h"
#include "video.h"
#include "video_compress.h"
#include "video_decompress.h"
@@ -27,11 +28,24 @@ using std::shared_ptr;
using std::to_string;
using std::vector;
// Registers the fixture into the 'registry'
CPPUNIT_TEST_SUITE_REGISTRATION( gpujpeg_test );
struct compress_state;
struct state_decompress;
void
gpujpeg_test::setUp()
static bool no_gpu = false;
static compress_state *compress{nullptr};
static state_decompress *decompress{nullptr};
static void gpujpeg_test_teardown()
{
module_done(CAST_MODULE(compress));
if (decompress != nullptr) {
decompress_done(decompress);
}
}
static pthread_once_t set_up = PTHREAD_ONCE_INIT;
static void gpujpeg_test_setup()
{
struct compress_state *compression;
int ret = compress_init(nullptr, "GPUJPEG:check", &compression);
@@ -41,63 +55,59 @@ gpujpeg_test::setUp()
}
} else {
clog << "Either GPUJPEG not compiled in or no CUDA-capable devices found - skipping GPUJPEG tests.\n";
m_skip = true;
no_gpu = true;
return;
}
ret = compress_init(nullptr, "GPUJPEG", &m_compress);
CPPUNIT_ASSERT_MESSAGE("Compression initialization failed", ret >= 0);
ret = compress_init(nullptr, "GPUJPEG", &compress);
assert(ret >= 0 && "Compression initialization failed");
commandline_params["decompress"] = "gpujpeg";
atexit(gpujpeg_test_teardown);
}
void
gpujpeg_test::tearDown()
{
module_done(CAST_MODULE(m_compress));
if (m_decompress != nullptr) {
decompress_done(m_decompress);
}
}
void
gpujpeg_test::test_simple()
bool gpujpeg_test_simple()
{
using namespace std::string_literals;
if (m_skip) {
return;
pthread_once(&set_up, gpujpeg_test_setup);
if (no_gpu) {
return true;
}
struct video_desc desc{1920, 1080, RGB, 1, PROGRESSIVE, 1};
auto in = shared_ptr<video_frame>(vf_alloc_desc_data(desc), vf_free);
memset(in->tiles[0].data, 127, in->tiles[0].data_len); /// @todo use some more reasonable stuff
compress_frame(m_compress, in);
auto compressed = compress_pop(m_compress);
CPPUNIT_ASSERT_MESSAGE("Compression failed", compressed);
compress_frame(compress, in);
auto compressed = compress_pop(compress);
ASSERT_MESSAGE("Compression failed", compressed);
vector<unsigned char> decompressed(in->tiles[0].data_len);
auto comp_desc = desc;
comp_desc.color_spec = JPEG;
if (bool ret = decompress_init_multi(JPEG, pixfmt_desc{}, RGB, &m_decompress, 1)) {
CPPUNIT_ASSERT_MESSAGE("Decompression init failed", ret);
if (bool ret = decompress_init_multi(JPEG, pixfmt_desc{}, RGB, &decompress, 1)) {
ASSERT_MESSAGE("Decompression init failed", ret);
}
auto ret = decompress_reconfigure(m_decompress, comp_desc, 0, 8, 16, vc_get_linesize(desc.width, desc.color_spec), desc.color_spec);
CPPUNIT_ASSERT_MESSAGE("Decompression reconfiguration failed", ret == TRUE);
auto status = decompress_frame(m_decompress,
auto ret = decompress_reconfigure(decompress, comp_desc, 0, 8, 16, vc_get_linesize(desc.width, desc.color_spec), desc.color_spec);
ASSERT_MESSAGE("Decompression reconfiguration failed", ret == TRUE);
auto status = decompress_frame(decompress,
decompressed.data(),
reinterpret_cast<unsigned char *>(compressed->tiles[0].data),
compressed->tiles[0].data_len,
0,
nullptr,
nullptr);
CPPUNIT_ASSERT_MESSAGE("Decompression failed", status == DECODER_GOT_FRAME);
ASSERT_MESSAGE("Decompression failed", status == DECODER_GOT_FRAME);
int i = 0;
int max_diff = 0;
for_each(decompressed.begin(), decompressed.end(), [&](unsigned char &x) {max_diff = max(abs(x - (unsigned char) in->tiles[0].data[i++]), max_diff);});
CPPUNIT_ASSERT_MESSAGE("Maximal allowed difference 1, found "s + to_string(max_diff), max_diff <= 1);
ASSERT_MESSAGE("Maximal allowed difference 1, found "s + to_string(max_diff), max_diff <= 1);
return true;
}
#endif // defined HAVE_CPPUNIT && defined HAVE_GPUJPEG
#else
bool gpujpeg_test_simple()
{
return true;
}
#endif // defined HAVE_GPUJPEG

View File

@@ -1,40 +0,0 @@
#ifndef GPUJPEG_TEST_H_96F45515_1EFA_4C80_A802_D520ECE5A079
#define GPUJPEG_TEST_H_96F45515_1EFA_4C80_A802_D520ECE5A079
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "config_unix.h"
#include "config_win32.h"
#endif
#ifdef HAVE_GPUJPEG
#include <cppunit/extensions/HelperMacros.h>
#include <list>
#include "utils/misc.h"
struct compress_state;
struct state_decompress;
class gpujpeg_test : public CPPUNIT_NS::TestFixture
{
CPPUNIT_TEST_SUITE( gpujpeg_test );
CPPUNIT_TEST( test_simple );
CPPUNIT_TEST_SUITE_END();
public:
gpujpeg_test() = default;
~gpujpeg_test() = default;
void setUp();
void tearDown();
void test_simple();
private:
bool m_skip{false};
compress_state *m_compress{nullptr};
state_decompress *m_decompress{nullptr};
};
#endif // defined HAVE_GPUJPEG
#endif // defined GPUJPEG_TEST_H_96F45515_1EFA_4C80_A802_D520ECE5A079

View File

@@ -4,14 +4,14 @@
#include "config_win32.h"
#endif
#if defined HAVE_CPPUNIT && defined HAVE_LAVC
#if defined HAVE_LAVC
#include <list>
#include <string>
#include <tuple>
#include "libavcodec/lavc_common.h"
#include "libavcodec_test.hpp"
#include "unit_common.h"
#include "video_codec.h"
using std::get;
@@ -22,20 +22,9 @@ using std::tuple;
extern "C" decoder_t (*testable_get_decoder_from_uv_to_uv)(codec_t in, enum AVPixelFormat av, codec_t *out);
// Registers the fixture into the 'registry'
CPPUNIT_TEST_SUITE_REGISTRATION(libavcodec_test);
extern "C" bool libavcodec_test_get_decoder_from_uv_to_uv();
void
libavcodec_test::setUp()
{
}
void
libavcodec_test::tearDown()
{
}
void libavcodec_test::test_get_decoder_from_uv_to_uv()
bool libavcodec_test_get_decoder_from_uv_to_uv()
{
using namespace std::string_literals;
@@ -51,11 +40,12 @@ void libavcodec_test::test_get_decoder_from_uv_to_uv()
for (auto & test_case : expected_decoders) {
codec_t out = VIDEO_CODEC_NONE;
decoder_t dec = testable_get_decoder_from_uv_to_uv(get<0>(test_case), get<4>(test_case), &out);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected intermediate "s + get_codec_name(get<1>(test_case)) + " for UG decoder for "s
ASSERT_EQUAL_MESSAGE("Expected intermediate "s + get_codec_name(get<1>(test_case)) + " for UG decoder for "s
+ get_codec_name(get<0>(test_case)) + " to "s + av_get_pix_fmt_name(get<4>(test_case)), get<1>(test_case), out);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected UG decoder "s + get<3>(test_case) + " for "s + get_codec_name(get<0>(test_case)) + " to "s
ASSERT_EQUAL_MESSAGE("Expected UG decoder "s + get<3>(test_case) + " for "s + get_codec_name(get<0>(test_case)) + " to "s
+ av_get_pix_fmt_name(get<4>(test_case)), (decoder_t) get<2>(test_case), dec);
}
return true;
}
#endif // defined HAVE_CPPUNIT && HAVE_LAVC
#endif // defined HAVE_LAVC

View File

@@ -1,27 +0,0 @@
#ifndef LIBAVCODEC_TEST_HPP_5452263A_93AB_4E74_8922_F2AB006FC351
#define LIBAVCODEC_TEST_HPP_5452263A_93AB_4E74_8922_F2AB006FC351
#include "config.h"
#ifdef HAVE_LAVC
#include <cppunit/extensions/HelperMacros.h>
class libavcodec_test : public CPPUNIT_NS::TestFixture
{
CPPUNIT_TEST_SUITE(libavcodec_test);
CPPUNIT_TEST(test_get_decoder_from_uv_to_uv);
CPPUNIT_TEST_SUITE_END();
public:
libavcodec_test() = default;
~libavcodec_test() override = default;
void setUp() override;
void tearDown() override;
void test_get_decoder_from_uv_to_uv();
};
#endif // defined HAVE_LAVC
#endif //defined LIBAVCODEC_TEST_HPP_5452263A_93AB_4E74_8922_F2AB006FC351

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;
}

View File

@@ -1,21 +0,0 @@
#ifndef MISC_TEST_HPP_85A3153C_9322_11EC_B6F6_F0DEF1A0ACC9
#define MISC_TEST_HPP_85A3153C_9322_11EC_B6F6_F0DEF1A0ACC9
#include <cppunit/extensions/HelperMacros.h>
class misc_test : public CPPUNIT_NS::TestFixture
{
CPPUNIT_TEST_SUITE( misc_test );
CPPUNIT_TEST( test_replace_all );
CPPUNIT_TEST_SUITE_END();
public:
misc_test();
~misc_test();
void setUp();
void tearDown();
void test_replace_all();
};
#endif // !defined MISC_TEST_HPP_85A3153C_9322_11EC_B6F6_F0DEF1A0ACC9

View File

@@ -143,6 +143,13 @@ DECLARE_TEST(ff_codec_conversions_test_yuv444pXXle_from_to_r12l);
DECLARE_TEST(ff_codec_conversions_test_yuv444p16le_from_to_rg48);
DECLARE_TEST(ff_codec_conversions_test_yuv444p16le_from_to_rg48_out_of_range);
DECLARE_TEST(ff_codec_conversions_test_pX10_from_to_v210);
DECLARE_TEST(get_framerate_test_2997);
DECLARE_TEST(get_framerate_test_3000);
DECLARE_TEST(get_framerate_test_free);
DECLARE_TEST(gpujpeg_test_simple);
DECLARE_TEST(libavcodec_test_get_decoder_from_uv_to_uv);
DECLARE_TEST(misc_test_replace_all);
DECLARE_TEST(misc_test_video_desc_io_op_symmetry);
struct {
const char *name;
@@ -154,6 +161,14 @@ struct {
DEFINE_TEST(ff_codec_conversions_test_yuv444p16le_from_to_rg48),
DEFINE_TEST(ff_codec_conversions_test_yuv444p16le_from_to_rg48_out_of_range),
DEFINE_TEST(ff_codec_conversions_test_pX10_from_to_v210),
DEFINE_TEST(get_framerate_test_2997),
DEFINE_TEST(get_framerate_test_3000),
DEFINE_TEST(get_framerate_test_free),
DEFINE_TEST(gpujpeg_test_simple),
DEFINE_TEST(libavcodec_test_get_decoder_from_uv_to_uv),
DEFINE_TEST(misc_test_replace_all),
DEFINE_TEST(misc_test_video_desc_io_op_symmetry),
};
static bool test_helper(const char *name, bool (*func)()) {

22
test/unit_common.h Normal file
View File

@@ -0,0 +1,22 @@
#include <iostream>
#define ASSERT(expr) if (!(expr)) { \
std::cerr << "Assertion " << #expr << " failed!" << "\n"; \
return false; \
}
#define ASSERT_MESSAGE(msg, expr) if (!(expr)) { \
std::cerr << "Assertion " << #expr << " failed: " << (msg) << "\n"; \
return false; \
}
#define ASSERT_EQUAL(expected, actual) if ((expected) != (actual)) { \
std::cerr << "Assertion failed - expected " << (expected) << ", actual : " << (actual) << "\n"; \
return false; \
}
#define ASSERT_EQUAL_MESSAGE(msg, expected, actual) if ((expected) != (actual)) { \
std::cerr << "Assertion failed - expected " << (expected) << ", actual : " << (actual) << ": " << (msg) << "\n"; \
return false; \
}

View File

@@ -1,67 +0,0 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "config_unix.h"
#include "config_win32.h"
#endif
#ifdef HAVE_CPPUNIT
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "config_unix.h"
#include "config_win32.h"
#endif
#include <cppunit/config/SourcePrefix.h>
#include "video_desc_test.h"
#include <sstream>
#include "video.h"
using namespace std;
// Registers the fixture into the 'registry'
CPPUNIT_TEST_SUITE_REGISTRATION( video_desc_test );
video_desc_test::video_desc_test() : m_test_desc{{1920, 1080, UYVY, 25, INTERLACED_MERGED, 1},
{1920, 1080, DXT5, 60, PROGRESSIVE, 4},
{640, 480, H264, 15, PROGRESSIVE, 1}}
{
}
video_desc_test::~video_desc_test()
{
}
void
video_desc_test::setUp()
{
}
void
video_desc_test::tearDown()
{
}
void
video_desc_test::testIOOperatorSymetry()
{
for (const auto & i : m_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();
CPPUNIT_ASSERT_MESSAGE(err_elem, video_desc_eq(tmp, i));
CPPUNIT_ASSERT_EQUAL_MESSAGE(err_elem, tmp, i);
}
}
#endif // defined HAVE_CPPUNIT

View File

@@ -1,26 +0,0 @@
#ifndef VIDEO_DESC_TEST_H
#define VIDEO_DESC_TEST_H
#include <cppunit/extensions/HelperMacros.h>
#include <list>
#include "types.h"
class video_desc_test : public CPPUNIT_NS::TestFixture
{
CPPUNIT_TEST_SUITE( video_desc_test );
CPPUNIT_TEST( testIOOperatorSymetry );
CPPUNIT_TEST_SUITE_END();
public:
video_desc_test();
~video_desc_test();
void setUp();
void tearDown();
void testIOOperatorSymetry();
private:
const std::list<video_desc> m_test_desc; // tested desc
};
#endif // VIDEO_DESC_TEST_H