mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
test Canvas: Set up unit test based on gtest.
In test directory, set up unit_test based on gtest First, add a test for SwCanvas generate.
This commit is contained in:
parent
d4e9450ec1
commit
9859a48714
5 changed files with 65 additions and 0 deletions
|
@ -38,16 +38,22 @@ headers = [include_directories('inc'), include_directories('.')]
|
||||||
subdir('inc')
|
subdir('inc')
|
||||||
subdir('src')
|
subdir('src')
|
||||||
|
|
||||||
|
if get_option('test') == true
|
||||||
|
subdir('test')
|
||||||
|
endif
|
||||||
|
|
||||||
summary = '''
|
summary = '''
|
||||||
|
|
||||||
Summary:
|
Summary:
|
||||||
thorvg version : @0@
|
thorvg version : @0@
|
||||||
Build type : @1@
|
Build type : @1@
|
||||||
Prefix : @2@
|
Prefix : @2@
|
||||||
|
Test : @3@
|
||||||
'''.format(
|
'''.format(
|
||||||
meson.project_version(),
|
meson.project_version(),
|
||||||
get_option('buildtype'),
|
get_option('buildtype'),
|
||||||
get_option('prefix'),
|
get_option('prefix'),
|
||||||
|
get_option('test'),
|
||||||
)
|
)
|
||||||
|
|
||||||
message(summary)
|
message(summary)
|
||||||
|
|
|
@ -32,3 +32,8 @@ option('examples',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
value: false,
|
value: false,
|
||||||
description: 'Enable building examples')
|
description: 'Enable building examples')
|
||||||
|
|
||||||
|
option('test',
|
||||||
|
type: 'boolean',
|
||||||
|
value: false,
|
||||||
|
description: 'Enable building unit tests')
|
||||||
|
|
19
test/meson.build
Normal file
19
test/meson.build
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
|
||||||
|
#TODO:Need to change warning level to 3
|
||||||
|
override_default = ['warning_level=0', 'werror=false']
|
||||||
|
|
||||||
|
gtest_dep = dependency('gtest')
|
||||||
|
|
||||||
|
canvas_test_sources = [
|
||||||
|
'testsuite.cpp',
|
||||||
|
'test_canvas.cpp',
|
||||||
|
]
|
||||||
|
|
||||||
|
canvas_testsuite = executable('canvasTestSuite',
|
||||||
|
canvas_test_sources,
|
||||||
|
include_directories : headers,
|
||||||
|
override_options : override_default,
|
||||||
|
dependencies : [gtest_dep, thorvg_lib_dep],
|
||||||
|
)
|
||||||
|
|
||||||
|
test('Canvas Testsuite', canvas_testsuite)
|
28
test/test_canvas.cpp
Normal file
28
test/test_canvas.cpp
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <thread>
|
||||||
|
#include <thorvg.h>
|
||||||
|
|
||||||
|
class CanvasTest : public ::testing::Test {
|
||||||
|
public:
|
||||||
|
void SetUp() {
|
||||||
|
auto threads = std::thread::hardware_concurrency();
|
||||||
|
//Initialize ThorVG Engine
|
||||||
|
if (tvg::Initializer::init(tvgEngine, threads) == tvg::Result::Success) {
|
||||||
|
swCanvas = tvg::SwCanvas::gen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void TearDown() {
|
||||||
|
|
||||||
|
//Terminate ThorVG Engine
|
||||||
|
tvg::Initializer::term(tvgEngine);
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
std::unique_ptr<tvg::SwCanvas> swCanvas;
|
||||||
|
tvg::CanvasEngine tvgEngine = tvg::CanvasEngine::Sw;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(CanvasTest, GenerateCanvas) {
|
||||||
|
ASSERT_TRUE(swCanvas != nullptr);
|
||||||
|
}
|
||||||
|
|
7
test/testsuite.cpp
Normal file
7
test/testsuite.cpp
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
testing::InitGoogleTest(&argc, argv);
|
||||||
|
return RUN_ALL_TESTS();
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue