Clean up some test files.
This commit is contained in:
parent
1adc9272f8
commit
b45385e8c7
51 changed files with 485 additions and 281 deletions
|
@ -1,76 +1,27 @@
|
|||
add_library(test_utils STATIC
|
||||
test_utils/TestCase.h
|
||||
test_utils/TestCaseRunner.cpp
|
||||
)
|
||||
add_subdirectory(test_utils)
|
||||
|
||||
target_include_directories(test_utils PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/test_utils"
|
||||
)
|
||||
set(TEST_MODULES
|
||||
audio
|
||||
compiler
|
||||
compression
|
||||
core
|
||||
database
|
||||
fonts
|
||||
graphics
|
||||
image
|
||||
ipc
|
||||
network
|
||||
publishing
|
||||
video
|
||||
web
|
||||
windows)
|
||||
|
||||
list(APPEND TestFiles
|
||||
audio/TestAudioWriter.cpp
|
||||
audio/TestMidiReader.cpp
|
||||
compiler/TestTemplatingEngine.cpp
|
||||
compression/TestStreamCompressor.cpp
|
||||
compression/TestHuffmanStream.cpp
|
||||
compression/TestLz77Encoder.cpp
|
||||
core/TestByteUtils.cpp
|
||||
core/TestBitStream.cpp
|
||||
core/TestTomlReader.cpp
|
||||
core/TestDataStructures.cpp
|
||||
database/TestDatabase.cpp
|
||||
fonts/TestFontReader.cpp
|
||||
graphics/TestRasterizer.cpp
|
||||
image/TestPngReader.cpp
|
||||
image/TestPngWriter.cpp
|
||||
network/TestNetworkManagerClient.cpp
|
||||
network/TestNetworkManagerServer.cpp
|
||||
publishing/TestPdfWriter.cpp
|
||||
web/TestMarkdownParser.cpp
|
||||
web/TestXmlParser.cpp
|
||||
)
|
||||
|
||||
if (${HAS_FFMPEG})
|
||||
list(APPEND TestFiles
|
||||
video/TestVideoDecoder.cpp
|
||||
)
|
||||
endif()
|
||||
foreach(module ${TEST_MODULES})
|
||||
add_subdirectory(${module})
|
||||
string(TOUPPER ${module} MODULE_UPPER)
|
||||
list(APPEND UNIT_TEST_FILES ${${MODULE_UPPER}_UNIT_TEST_FILES})
|
||||
list(APPEND UNIT_TEST_DEPENDENCIES ${${MODULE_UPPER}_UNIT_TEST_DEPENDENCIES})
|
||||
endforeach()
|
||||
|
||||
find_package(Wayland QUIET)
|
||||
if(WAYLAND_FOUND)
|
||||
list(APPEND TestFiles
|
||||
windows/TestWaylandWindow.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
set(OpenGL_GL_PREFERENCE "GLVND")
|
||||
find_package(OpenGL QUIET)
|
||||
if (OpenGL_FOUND)
|
||||
list(APPEND TestFiles
|
||||
graphics/TestOpenGlRendering.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(DBUS dbus-1 QUIET)
|
||||
if (DBUS_FOUND)
|
||||
include_directories(${DBUS_INCLUDE_DIRS})
|
||||
link_directories(${DBUS_LIBRARY_DIRS})
|
||||
list(APPEND TestFiles
|
||||
ipc/TestDbus.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
find_package(Freetype QUIET)
|
||||
if(Freetype_FOUND)
|
||||
list(APPEND TestFiles
|
||||
fonts/TestFreeTypeFontEngine.cpp
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_executable(test_runner test_runner.cpp ${TestFiles})
|
||||
|
||||
target_link_libraries(test_runner PUBLIC test_utils publishing core compiler fonts network database geometry audio graphics web client)
|
||||
add_executable(unit_tests test_runner.cpp ${UNIT_TEST_FILES})
|
||||
target_link_libraries(unit_tests PUBLIC test_utils ${UNIT_TEST_DEPENDENCIES})
|
||||
|
|
10
test/audio/CMakeLists.txt
Normal file
10
test/audio/CMakeLists.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
set(AUDIO_UNIT_TEST_FILES
|
||||
audio/TestAudioWriter.cpp
|
||||
audio/TestMidiReader.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
set(AUDIO_UNIT_TEST_DEPENDENCIES
|
||||
audio
|
||||
PARENT_SCOPE
|
||||
)
|
9
test/compiler/CMakeLists.txt
Normal file
9
test/compiler/CMakeLists.txt
Normal file
|
@ -0,0 +1,9 @@
|
|||
set(COMPILER_UNIT_TEST_FILES
|
||||
compiler/TestTemplatingEngine.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
set(COMPILER_UNIT_TEST_DEPENDENCIES
|
||||
compiler
|
||||
PARENT_SCOPE
|
||||
)
|
|
@ -1,6 +1,6 @@
|
|||
#include "TemplatingEngine.h"
|
||||
|
||||
#include <File.h>
|
||||
#include "File.h"
|
||||
#include "TestFramework.h"
|
||||
|
||||
#include <filesystem>
|
||||
|
@ -8,12 +8,12 @@
|
|||
|
||||
TEST_CASE(TestTemplatingEngine, "compiler")
|
||||
{
|
||||
const auto data_loc = std::filesystem::path(__FILE__) / "../../data";
|
||||
const auto data_loc = std::filesystem::path(__FILE__) / "../../data";
|
||||
|
||||
auto engine = TemplatingEngine(data_loc);
|
||||
engine.loadTemplateFiles();
|
||||
const auto content = engine.processTemplate("index");
|
||||
auto engine = TemplatingEngine(data_loc);
|
||||
engine.loadTemplateFiles();
|
||||
const auto content = engine.processTemplate("index");
|
||||
|
||||
File outfile("index.html");
|
||||
outfile.WriteText(content);
|
||||
File outfile("index.html");
|
||||
outfile.WriteText(content);
|
||||
}
|
||||
|
|
11
test/compression/CMakeLists.txt
Normal file
11
test/compression/CMakeLists.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
set(COMPRESSION_UNIT_TEST_FILES
|
||||
compression/TestStreamCompressor.cpp
|
||||
compression/TestHuffmanStream.cpp
|
||||
compression/TestLz77Encoder.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
set(COMPRESSION_UNIT_TEST_DEPENDENCIES
|
||||
compression
|
||||
PARENT_SCOPE
|
||||
)
|
|
@ -28,7 +28,7 @@ TEST_CASE(TestLz77Encoder, "compression")
|
|||
for(const auto& hit : hit_buffer)
|
||||
{
|
||||
const auto& [length, distance, next_char] = hit;
|
||||
std::cout << "Got hit " << length << " | " << distance << " | " << static_cast<int>(next_char) << std::endl;
|
||||
//std::cout << "Got hit " << length << " | " << distance << " | " << static_cast<int>(next_char) << std::endl;
|
||||
}
|
||||
|
||||
HuffmanEncoder huffman_encoder;
|
||||
|
|
|
@ -54,7 +54,7 @@ TEST_CASE(TestLz77Encoder, "compression")
|
|||
Lz77Encoder encoder(&input_stream, &output_stream);
|
||||
encoder.encode();
|
||||
|
||||
std::cout << "Encoded: " << StringUtils::toString(output_stream.getBuffer()) << std::endl;
|
||||
//std::cout << "Encoded: " << StringUtils::toString(output_stream.getBuffer()) << std::endl;
|
||||
|
||||
//auto decoded = encoder.decode(encoded);
|
||||
|
||||
|
|
12
test/core/CMakeLists.txt
Normal file
12
test/core/CMakeLists.txt
Normal file
|
@ -0,0 +1,12 @@
|
|||
set(CORE_UNIT_TEST_FILES
|
||||
core/TestByteUtils.cpp
|
||||
core/TestBitStream.cpp
|
||||
core/TestTomlReader.cpp
|
||||
core/TestDataStructures.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
set(CORE_UNIT_TEST_DEPENDENCIES
|
||||
core
|
||||
PARENT_SCOPE
|
||||
)
|
|
@ -21,22 +21,22 @@ TEST_CASE(TestReadBitStream, "core")
|
|||
|
||||
unsigned char buffer{0} ;
|
||||
auto valid = stream.readNextNBits(1, buffer);
|
||||
std::cout << "Slice0 is " << ByteUtils::toString(buffer) << std::endl;
|
||||
//std::cout << "Slice0 is " << ByteUtils::toString(buffer) << std::endl;
|
||||
|
||||
valid = stream.readNextNBits(2, buffer);
|
||||
std::cout << "Slice1 is " << ByteUtils::toString(buffer) << std::endl;
|
||||
//std::cout << "Slice1 is " << ByteUtils::toString(buffer) << std::endl;
|
||||
|
||||
valid = stream.readNextNBits(5, buffer);
|
||||
std::cout << "Slice2 is " << ByteUtils::toString(buffer) << std::endl;
|
||||
//std::cout << "Slice2 is " << ByteUtils::toString(buffer) << std::endl;
|
||||
|
||||
valid = stream.readNextNBits(5, buffer);
|
||||
std::cout << "Slice3 is " << ByteUtils::toString(buffer) << std::endl;
|
||||
//std::cout << "Slice3 is " << ByteUtils::toString(buffer) << std::endl;
|
||||
|
||||
valid = stream.readNextNBits(4, buffer);
|
||||
std::cout << "Slice3 is " << ByteUtils::toString(buffer) << " and int " << static_cast<int>(buffer) << std::endl;
|
||||
//std::cout << "Slice3 is " << ByteUtils::toString(buffer) << " and int " << static_cast<int>(buffer) << std::endl;
|
||||
|
||||
valid = stream.readNextNBits(3, buffer);
|
||||
std::cout << "Slice3 is " << ByteUtils::toString(buffer) << std::endl;
|
||||
//std::cout << "Slice3 is " << ByteUtils::toString(buffer) << std::endl;
|
||||
}
|
||||
|
||||
TEST_CASE(TestWritingBitStream, "core")
|
||||
|
@ -68,9 +68,9 @@ TEST_CASE(TestWritingBitStream, "core")
|
|||
auto byte3 = ByteUtils::toString(*stream.readNextByte());
|
||||
auto byte4 = ByteUtils::toString(*stream.readNextByte());
|
||||
|
||||
std::cout << "Got bytes 0 " << byte0 << std::endl;
|
||||
std::cout << "Got bytes 1 " << byte1 << std::endl;
|
||||
std::cout << "Got bytes 2 " << byte2 << std::endl;
|
||||
std::cout << "Got bytes 3 " << byte3 << std::endl;
|
||||
std::cout << "Got bytes 4 " << byte4 << std::endl;
|
||||
//std::cout << "Got bytes 0 " << byte0 << std::endl;
|
||||
//std::cout << "Got bytes 1 " << byte1 << std::endl;
|
||||
//std::cout << "Got bytes 2 " << byte2 << std::endl;
|
||||
//std::cout << "Got bytes 3 " << byte3 << std::endl;
|
||||
//std::cout << "Got bytes 4 " << byte4 << std::endl;
|
||||
}
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
TEST_CASE(TestReadByteUtils, "core")
|
||||
{
|
||||
auto byte = ByteUtils::getFromString("00110101");
|
||||
std::cout << "Value is " << static_cast<unsigned>(byte) << std::endl;
|
||||
//std::cout << "Value is " << static_cast<unsigned>(byte) << std::endl;
|
||||
|
||||
auto string_rep = ByteUtils::toString(byte);
|
||||
std::cout << "String rep is " << string_rep << std::endl;
|
||||
//std::cout << "String rep is " << string_rep << std::endl;
|
||||
|
||||
auto slice = ByteUtils::getMBitsAtN(byte, 3, 3);
|
||||
std::cout << "Slice is " << ByteUtils::toString(slice) << std::endl;
|
||||
//std::cout << "Slice is " << ByteUtils::toString(slice) << std::endl;
|
||||
|
||||
uint32_t input {12345678};
|
||||
auto byte0 = ByteUtils::getByteN(input, 0);
|
||||
|
@ -21,17 +21,17 @@ TEST_CASE(TestReadByteUtils, "core")
|
|||
auto byte2 = ByteUtils::getByteN(input, 2);
|
||||
auto byte3 = ByteUtils::getByteN(input, 3);
|
||||
|
||||
std::cout << "Byte0 is " << ByteUtils::toString(byte0) << std::endl;
|
||||
std::cout << "Byte1 is " << ByteUtils::toString(byte1) << std::endl;
|
||||
std::cout << "Byte2 is " << ByteUtils::toString(byte2) << std::endl;
|
||||
std::cout << "Byte3 is " << ByteUtils::toString(byte3) << std::endl;
|
||||
//std::cout << "Byte0 is " << ByteUtils::toString(byte0) << std::endl;
|
||||
//std::cout << "Byte1 is " << ByteUtils::toString(byte1) << std::endl;
|
||||
//std::cout << "Byte2 is " << ByteUtils::toString(byte2) << std::endl;
|
||||
//std::cout << "Byte3 is " << ByteUtils::toString(byte3) << std::endl;
|
||||
|
||||
std::cout << "Mirroring" << std::endl;
|
||||
//std::cout << "Mirroring" << std::endl;
|
||||
|
||||
auto out = ByteUtils::mirror(byte);
|
||||
std::cout << "Mirror is " << ByteUtils::toString(out) << std::endl;
|
||||
//std::cout << "Mirror is " << ByteUtils::toString(out) << std::endl;
|
||||
|
||||
unsigned hold = byte;
|
||||
hold = (hold << 5) + 3;
|
||||
std::cout << "Big val is " << ByteUtils::toString(hold, 16) << std::endl;
|
||||
//std::cout << "Big val is " << ByteUtils::toString(hold, 16) << std::endl;
|
||||
}
|
||||
|
|
|
@ -10,25 +10,25 @@ TEST_CASE(TestCircleBuffer, "core")
|
|||
|
||||
for (auto item : {1, 2, 3})
|
||||
{
|
||||
std::cout << "Add item: " << item << std::endl;
|
||||
//std::cout << "Add item: " << item << std::endl;
|
||||
buffer.addItem(item);
|
||||
}
|
||||
|
||||
for (std::size_t idx=0; idx<3; idx++)
|
||||
{
|
||||
auto item = buffer.getItem(idx);
|
||||
std::cout << "Got item: " << idx << " " << item << std::endl;
|
||||
//std::cout << "Got item: " << idx << " " << item << std::endl;
|
||||
}
|
||||
|
||||
for (auto item : {4, 5})
|
||||
{
|
||||
std::cout << "Add item: " << item << std::endl;
|
||||
buffer.addItem(item);
|
||||
//std::cout << "Add item: " << item << std::endl;
|
||||
//buffer.addItem(item);
|
||||
}
|
||||
|
||||
for (std::size_t idx=0; idx<3; idx++)
|
||||
{
|
||||
auto item = buffer.getItem(idx);
|
||||
std::cout << "Got item: " << idx << " " << item << std::endl;
|
||||
//std::cout << "Got item: " << idx << " " << item << std::endl;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,9 @@ TEST_CASE(TestTomlReader, "core")
|
|||
reader.read(sample_toml_file);
|
||||
|
||||
auto themes_table = reader.getContent()->getTable("themes");
|
||||
|
||||
REQUIRE(themes_table);
|
||||
|
||||
for (const auto& items : themes_table->getKeyValuePairs())
|
||||
{
|
||||
std::cout << "Got entry with key: " << items.first << " and val " << items.second << std::endl;
|
||||
|
|
9
test/database/CMakeLists.txt
Normal file
9
test/database/CMakeLists.txt
Normal file
|
@ -0,0 +1,9 @@
|
|||
set(DATABASE_UNIT_TEST_FILES
|
||||
database/TestDatabase.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
set(DATABASE_UNIT_TEST_DEPENDENCIES
|
||||
database
|
||||
PARENT_SCOPE
|
||||
)
|
22
test/fonts/CMakeLists.txt
Normal file
22
test/fonts/CMakeLists.txt
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
set(PLATFORM_UNIT_TEST_FILES)
|
||||
if(UNIX)
|
||||
find_package(Freetype QUIET)
|
||||
if(Freetype_FOUND)
|
||||
set(PLATFORM_UNIT_TEST_FILES
|
||||
fonts/TestFreeTypeFontEngine.cpp
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
set(FONTS_UNIT_TEST_FILES
|
||||
fonts/TestFontReader.cpp
|
||||
${PLATFORM_UNIT_TEST_FILES}
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
set(FONTS_UNIT_TEST_DEPENDENCIES
|
||||
fonts
|
||||
PARENT_SCOPE
|
||||
)
|
20
test/graphics/CMakeLists.txt
Normal file
20
test/graphics/CMakeLists.txt
Normal file
|
@ -0,0 +1,20 @@
|
|||
set(PLATFORM_UNIT_TEST_FILES)
|
||||
|
||||
set(OpenGL_GL_PREFERENCE "GLVND")
|
||||
find_package(OpenGL QUIET)
|
||||
if (OpenGL_FOUND)
|
||||
set(PLATFORM_UNIT_TEST_FILES
|
||||
graphics/TestOpenGlRendering.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
set(GRAPHICS_UNIT_TEST_FILES
|
||||
graphics/TestRasterizer.cpp
|
||||
${PLATFORM_UNIT_TEST_FILES}
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
set(GRAPHICS_UNIT_TEST_DEPENDENCIES
|
||||
graphics client
|
||||
PARENT_SCOPE
|
||||
)
|
|
@ -15,5 +15,7 @@ TEST_CASE(TestOpenGlRendering, "graphics")
|
|||
|
||||
app->setUiInterfaceBackend(UiInterfaceFactory::Backend::X11);
|
||||
//app->setUiInterfaceBackend(UiInterfaceFactory::Backend::X11_RASTER);
|
||||
app->run();
|
||||
|
||||
|
||||
//app->run();
|
||||
};
|
||||
|
|
10
test/image/CMakeLists.txt
Normal file
10
test/image/CMakeLists.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
set(IMAGE_UNIT_TEST_FILES
|
||||
image/TestPngReader.cpp
|
||||
image/TestPngWriter.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
set(IMAGE_UNIT_TEST_DEPENDENCIES
|
||||
image
|
||||
PARENT_SCOPE
|
||||
)
|
|
@ -40,7 +40,7 @@ TEST_CASE(TestCompressedPng, "image")
|
|||
|
||||
while(auto byte = test_file.readNextByte())
|
||||
{
|
||||
std::cout << static_cast<unsigned>(*byte) << std::endl;
|
||||
//std::cout << static_cast<unsigned>(*byte) << std::endl;
|
||||
}
|
||||
test_file.Close();
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ TEST_CASE(TestFixedPng, "image")
|
|||
|
||||
//return;
|
||||
File test_file("test_fixed.png");
|
||||
std::cout << test_file.dumpBinary();
|
||||
//std::cout << test_file.dumpBinary();
|
||||
|
||||
}
|
||||
|
||||
|
@ -100,5 +100,5 @@ TEST_CASE(TestDynamicCompressedPng, "image")
|
|||
|
||||
//return;
|
||||
File test_file("test_dynamic.png");
|
||||
std::cout << test_file.dumpBinary();
|
||||
//std::cout << test_file.dumpBinary();
|
||||
}
|
||||
|
|
20
test/ipc/CMakeLists.txt
Normal file
20
test/ipc/CMakeLists.txt
Normal file
|
@ -0,0 +1,20 @@
|
|||
set(PLATFORM_UNIT_TEST_FILES)
|
||||
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(DBUS dbus-1 QUIET)
|
||||
if (DBUS_FOUND)
|
||||
include_directories(${DBUS_INCLUDE_DIRS})
|
||||
link_directories(${DBUS_LIBRARY_DIRS})
|
||||
set(PLATFORM_UNIT_TEST_FILES
|
||||
ipc/TestDbus.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
set(IPC_UNIT_TEST_FILES
|
||||
${PLATFORM_UNIT_TEST_FILES}
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
set(IPC_UNIT_TEST_DEPENDENCIES
|
||||
PARENT_SCOPE
|
||||
)
|
10
test/network/CMakeLists.txt
Normal file
10
test/network/CMakeLists.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
set(NETWORK_UNIT_TEST_FILES
|
||||
network/TestNetworkManagerClient.cpp
|
||||
network/TestNetworkManagerServer.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
set(NETWORK_UNIT_TEST_DEPENDENCIES
|
||||
network
|
||||
PARENT_SCOPE
|
||||
)
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
TEST_CASE(TestNetworkManagerClient, "network")
|
||||
{
|
||||
std::cout << "into main" << std::endl;
|
||||
auto network_manager = NetworkManager::Create();
|
||||
|
||||
network_manager->RunHttpClient();
|
||||
|
|
|
@ -2,12 +2,9 @@
|
|||
|
||||
#include "TestFramework.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
TEST_CASE(TestNetworkManagerServer, "network")
|
||||
{
|
||||
std::cout << "into main" << std::endl;
|
||||
auto network_manager = NetworkManager::Create();
|
||||
|
||||
network_manager->RunHttpServer();
|
||||
//network_manager->RunHttpServer();
|
||||
}
|
||||
|
|
9
test/publishing/CMakeLists.txt
Normal file
9
test/publishing/CMakeLists.txt
Normal file
|
@ -0,0 +1,9 @@
|
|||
set(PUBLISHING_UNIT_TEST_FILES
|
||||
publishing/TestPdfWriter.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
set(PUBLISHING_UNIT_TEST_DEPENDENCIES
|
||||
publishing
|
||||
PARENT_SCOPE
|
||||
)
|
|
@ -11,8 +11,7 @@ int main()
|
|||
CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
|
||||
#endif
|
||||
|
||||
auto test_runner = TestCaseRunner::getInstance();
|
||||
test_runner.run();
|
||||
auto result = TestCaseRunner::getInstance().run();
|
||||
|
||||
#ifdef _WIN32
|
||||
CoUninitialize();
|
||||
|
|
9
test/test_utils/CMakeLists.txt
Normal file
9
test/test_utils/CMakeLists.txt
Normal file
|
@ -0,0 +1,9 @@
|
|||
add_library(test_utils SHARED
|
||||
TestCase.h
|
||||
TestCaseRunner.cpp
|
||||
)
|
||||
|
||||
target_include_directories(test_utils PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
target_link_libraries(test_utils core)
|
|
@ -1,14 +1,27 @@
|
|||
#include "TestCaseRunner.h"
|
||||
|
||||
#include "FileLogger.h"
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
bool TestCaseRunner::sLastTestFailed = false;
|
||||
std::string TestCaseRunner::sFailureLine = {};
|
||||
|
||||
TestCaseRunner::TestCaseRunner()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TestCaseRunner::~TestCaseRunner()
|
||||
{
|
||||
for (auto testCase : mCases)
|
||||
{
|
||||
//delete testCase;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TestCaseRunner& TestCaseRunner::getInstance()
|
||||
{
|
||||
static TestCaseRunner instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void TestCaseRunner::addTestCase(const std::string& label, const std::string& tag, TestCase::TestCaseFunction func)
|
||||
|
@ -17,28 +30,35 @@ void TestCaseRunner::addTestCase(const std::string& label, const std::string& ta
|
|||
mCases.push_back(test_case);
|
||||
}
|
||||
|
||||
void TestCaseRunner::markTestFailure(const std::string& line)
|
||||
{
|
||||
sLastTestFailed = true;
|
||||
sFailureLine = line;
|
||||
}
|
||||
|
||||
bool TestCaseRunner::run()
|
||||
{
|
||||
FileLogger::GetInstance().disable();
|
||||
for (auto test_case : mCases)
|
||||
{
|
||||
sLastTestFailed = false;
|
||||
std::cout << "TestFramework: Running Test - " << test_case->getName() << std::endl;
|
||||
test_case->run();
|
||||
}
|
||||
|
||||
bool testsPassed = true;
|
||||
/*
|
||||
for(const auto& test : mCases)
|
||||
{
|
||||
std::cout << "Running " << test->getName() << std::endl;
|
||||
const auto result = test->Run();
|
||||
if (!result)
|
||||
if (sLastTestFailed)
|
||||
{
|
||||
std::cout << test->getName() << " Failed" << std::endl;
|
||||
testsPassed = false;
|
||||
break;
|
||||
std::cout << "Failed at line: " << sLastTestFailed << std::endl;
|
||||
mFailingTests.push_back(test_case->getName());
|
||||
}
|
||||
}
|
||||
return testsPassed;
|
||||
*/
|
||||
|
||||
if (mFailingTests.size() > 0)
|
||||
{
|
||||
std::cout << mFailingTests.size() << " failing tests: " << std::endl;
|
||||
for(const auto& name : mFailingTests)
|
||||
{
|
||||
std::cout << name << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -8,20 +8,21 @@
|
|||
class TestCaseRunner
|
||||
{
|
||||
public:
|
||||
TestCaseRunner() = default;
|
||||
TestCaseRunner();
|
||||
|
||||
static TestCaseRunner& getInstance()
|
||||
{
|
||||
static TestCaseRunner instance;
|
||||
return instance;
|
||||
}
|
||||
static TestCaseRunner& getInstance();
|
||||
|
||||
~TestCaseRunner();
|
||||
|
||||
void addTestCase(const std::string& label, const std::string& tag, TestCase::TestCaseFunction func);
|
||||
|
||||
void markTestFailure(const std::string& line);
|
||||
|
||||
bool run();
|
||||
|
||||
private:
|
||||
std::vector<std::string> mFailingTests;
|
||||
static bool sLastTestFailed;
|
||||
static std::string sFailureLine;
|
||||
std::vector<TestCase*> mCases;
|
||||
};
|
||||
|
|
|
@ -16,3 +16,13 @@ struct Holder
|
|||
static void Test##NAME() \
|
||||
|
||||
|
||||
#define REQUIRE(predicate) \
|
||||
if(!predicate) \
|
||||
{ \
|
||||
TestCaseRunner::getInstance().markTestFailure(std::to_string(__LINE__)); \
|
||||
return; \
|
||||
} \
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
17
test/video/CMakeLists.txt
Normal file
17
test/video/CMakeLists.txt
Normal file
|
@ -0,0 +1,17 @@
|
|||
set(PLATFORM_UNIT_TEST_FILES)
|
||||
|
||||
if (${HAS_FFMPEG})
|
||||
set(PLATFORM_UNIT_TEST_FILES
|
||||
video/TestVideoDecoder.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
set(VIDEO_UNIT_TEST_FILES
|
||||
${PLATFORM_UNIT_TEST_FILES}
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
set(VIDEO_UNIT_TEST_DEPENDENCIES
|
||||
video
|
||||
PARENT_SCOPE
|
||||
)
|
10
test/web/CMakeLists.txt
Normal file
10
test/web/CMakeLists.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
set(WEB_UNIT_TEST_FILES
|
||||
web/TestMarkdownParser.cpp
|
||||
web/TestXmlParser.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
set(WEB_UNIT_TEST_DEPENDENCIES
|
||||
web
|
||||
PARENT_SCOPE
|
||||
)
|
18
test/windows/CMakeLists.txt
Normal file
18
test/windows/CMakeLists.txt
Normal file
|
@ -0,0 +1,18 @@
|
|||
set(PLATFORM_UNIT_TEST_FILES)
|
||||
|
||||
find_package(Wayland QUIET)
|
||||
if(WAYLAND_FOUND)
|
||||
set( PLATFORM_UNIT_TEST_FILES
|
||||
windows/TestWaylandWindow.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
set(WINDOWS_UNIT_TEST_FILES
|
||||
${PLATFORM_UNIT_TEST_FILES}
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
set(WINDOWS_UNIT_TEST_DEPENDENCIES
|
||||
windows
|
||||
PARENT_SCOPE
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue