mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +00:00
Split the tests into two files for the interpreter and others
This commit is contained in:
parent
0e82faf845
commit
d79131f18f
3 changed files with 61 additions and 42 deletions
|
@ -134,15 +134,20 @@ if(BUILD_TESTING)
|
||||||
|
|
||||||
FetchContent_MakeAvailable(Catch2)
|
FetchContent_MakeAvailable(Catch2)
|
||||||
|
|
||||||
add_executable(api_tests tests/tests.cpp)
|
macro(sixtyfps_test NAME)
|
||||||
target_link_libraries(api_tests PRIVATE SixtyFPS Catch2::Catch2)
|
add_executable(test_${NAME} tests/${NAME}.cpp)
|
||||||
target_compile_definitions(api_tests PRIVATE
|
target_link_libraries(test_${NAME} PRIVATE SixtyFPS Catch2::Catch2)
|
||||||
SOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/\"
|
target_compile_definitions(test_${NAME} PRIVATE
|
||||||
)
|
SOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/\"
|
||||||
add_test(api_tests ${CMAKE_CURRENT_BINARY_DIR}/api_tests)
|
)
|
||||||
# Somehow the wrong relative rpath ends up in the binary, requiring us to change the
|
add_test(test_${NAME} ${CMAKE_CURRENT_BINARY_DIR}/test_${NAME})
|
||||||
# working directory.
|
# Somehow the wrong relative rpath ends up in the binary, requiring us to change the
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
# working directory.
|
||||||
set_property(TEST api_tests PROPERTY WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
endif()
|
set_property(TEST test_${NAME} PROPERTY WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||||
|
endif()
|
||||||
|
endmacro(sixtyfps_test)
|
||||||
|
sixtyfps_test(datastructures)
|
||||||
|
sixtyfps_test(interpreter)
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
44
api/sixtyfps-cpp/tests/datastructures.cpp
Normal file
44
api/sixtyfps-cpp/tests/datastructures.cpp
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/* LICENSE BEGIN
|
||||||
|
This file is part of the SixtyFPS Project -- https://sixtyfps.io
|
||||||
|
Copyright (c) 2020 Olivier Goffart <olivier.goffart@sixtyfps.io>
|
||||||
|
Copyright (c) 2020 Simon Hausmann <simon.hausmann@sixtyfps.io>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
This file is also available under commercial licensing terms.
|
||||||
|
Please contact info@sixtyfps.io for more information.
|
||||||
|
LICENSE END */
|
||||||
|
|
||||||
|
#define CATCH_CONFIG_MAIN
|
||||||
|
#include "catch2/catch.hpp"
|
||||||
|
|
||||||
|
#include <sixtyfps.h>
|
||||||
|
|
||||||
|
SCENARIO("SharedString API")
|
||||||
|
{
|
||||||
|
sixtyfps::SharedString str;
|
||||||
|
|
||||||
|
REQUIRE(str.empty());
|
||||||
|
|
||||||
|
SECTION("Construct from string_view")
|
||||||
|
{
|
||||||
|
std::string foo("Foo");
|
||||||
|
std::string_view foo_view(foo);
|
||||||
|
str = foo_view;
|
||||||
|
REQUIRE(str == "Foo");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Basic SharedVector API", "[vector]")
|
||||||
|
{
|
||||||
|
sixtyfps::SharedVector<int> vec;
|
||||||
|
REQUIRE(vec.empty());
|
||||||
|
|
||||||
|
SECTION("Initializer list")
|
||||||
|
{
|
||||||
|
sixtyfps::SharedVector<int> vec({ 1, 4, 10 });
|
||||||
|
REQUIRE(vec.size() == 3);
|
||||||
|
REQUIRE(vec[0] == 1);
|
||||||
|
REQUIRE(vec[1] == 4);
|
||||||
|
REQUIRE(vec[2] == 10);
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,36 +14,6 @@ LICENSE END */
|
||||||
#include <sixtyfps.h>
|
#include <sixtyfps.h>
|
||||||
#include <sixtyfps_interpreter.h>
|
#include <sixtyfps_interpreter.h>
|
||||||
|
|
||||||
SCENARIO("SharedString API")
|
|
||||||
{
|
|
||||||
sixtyfps::SharedString str;
|
|
||||||
|
|
||||||
REQUIRE(str.empty());
|
|
||||||
|
|
||||||
SECTION("Construct from string_view")
|
|
||||||
{
|
|
||||||
std::string foo("Foo");
|
|
||||||
std::string_view foo_view(foo);
|
|
||||||
str = foo_view;
|
|
||||||
REQUIRE(str == "Foo");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("Basic SharedVector API", "[vector]")
|
|
||||||
{
|
|
||||||
sixtyfps::SharedVector<int> vec;
|
|
||||||
REQUIRE(vec.empty());
|
|
||||||
|
|
||||||
SECTION("Initializer list")
|
|
||||||
{
|
|
||||||
sixtyfps::SharedVector<int> vec({ 1, 4, 10 });
|
|
||||||
REQUIRE(vec.size() == 3);
|
|
||||||
REQUIRE(vec[0] == 1);
|
|
||||||
REQUIRE(vec[1] == 4);
|
|
||||||
REQUIRE(vec[2] == 10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SCENARIO("Value API")
|
SCENARIO("Value API")
|
||||||
{
|
{
|
||||||
using namespace sixtyfps::interpreter;
|
using namespace sixtyfps::interpreter;
|
Loading…
Add table
Add a link
Reference in a new issue