mirror of
https://github.com/mcneel/opennurbs.git
synced 2026-03-16 14:18:30 +08:00
adding tests
This commit is contained in:
@@ -469,6 +469,7 @@ if (ANDROID OR LINUX)
|
||||
endif()
|
||||
|
||||
add_subdirectory(zlib)
|
||||
add_subdirectory(tests)
|
||||
|
||||
## opennurbs static library
|
||||
add_library( opennurbsStatic STATIC
|
||||
|
||||
11
README.md
11
README.md
@@ -28,6 +28,17 @@ Please see ["Getting started"](https://developer.rhino3d.com/guides/opennurbs/ge
|
||||
|
||||
There's also a collection of [example 3dm files](example_files/) available for testing.
|
||||
|
||||
## Building
|
||||
- `mkdir build && cd build`
|
||||
- `cmake ..`
|
||||
- `cmake --build .`
|
||||
|
||||
This will also build the tests, which you can run by running them from the build/tests directory:
|
||||
|
||||
- `cd tests`
|
||||
- `ctest`
|
||||
|
||||
|
||||
## Questions?
|
||||
|
||||
For technical support, please head over to [Discourse](https://discourse.mcneel.com/category/opennurbs).
|
||||
|
||||
34
tests/CMakeLists.txt
Normal file
34
tests/CMakeLists.txt
Normal file
@@ -0,0 +1,34 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(ON_Test)
|
||||
|
||||
# GoogleTest requires at least C++14
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
#set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
#set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
URL https://github.com/google/googletest/archive/b10fad38c4026a29ea6561ab15fc4818170d1c10.zip
|
||||
)
|
||||
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
|
||||
enable_testing()
|
||||
|
||||
add_executable(
|
||||
hello_test
|
||||
hello_test.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
hello_test
|
||||
GTest::gtest_main
|
||||
OpenNURBS
|
||||
)
|
||||
|
||||
include(GoogleTest)
|
||||
gtest_discover_tests(hello_test)
|
||||
16
tests/hello_test.cpp
Normal file
16
tests/hello_test.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "../opennurbs_public.h"
|
||||
|
||||
# define M_PI 3.14159265358979323846 /* pi */
|
||||
|
||||
TEST(HelloTest, BasicAssertions) {
|
||||
|
||||
ON_3dPoint center(0,0,0);
|
||||
|
||||
ON_Circle circle(center, 10.00);
|
||||
|
||||
double circumference = 2 * M_PI * circle.radius;
|
||||
|
||||
EXPECT_EQ(circumference, circle.Circumference());
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user