-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #178 from yungyuc/refactor/gtest-buffer
Add google-test version 1.12.1 and make extension initializer cleaner
- Loading branch information
Showing
19 changed files
with
298 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ jobs: | |
matrix: | ||
path: | ||
- 'cpp' | ||
- 'gtests' | ||
|
||
steps: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (c) 2019, Yung-Yu Chen <yyc@solvcon.net> | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* - Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* - Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* - Neither the name of the copyright holder nor the names of its contributors | ||
* may be used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include <modmesh/toggle/pymod/toggle_pymod.hpp> // Must be the first include. | ||
#include <modmesh/buffer/pymod/buffer_pymod.hpp> | ||
|
||
namespace modmesh | ||
{ | ||
|
||
namespace python | ||
{ | ||
|
||
struct buffer_pymod_tag; | ||
|
||
template <> | ||
OneTimeInitializer<buffer_pymod_tag> & OneTimeInitializer<buffer_pymod_tag>::me() | ||
{ | ||
static OneTimeInitializer<buffer_pymod_tag> instance; | ||
return instance; | ||
} | ||
|
||
void initialize_buffer(pybind11::module & mod) | ||
{ | ||
auto initialize_impl = [](pybind11::module & mod) | ||
{ | ||
import_numpy(); | ||
|
||
wrap_ConcreteBuffer(mod); | ||
wrap_SimpleArray(mod); | ||
}; | ||
|
||
OneTimeInitializer<buffer_pymod_tag>::me()(mod, initialize_impl); | ||
} | ||
|
||
} /* end namespace python */ | ||
|
||
} /* end namespace modmesh */ | ||
|
||
// vim: set ff=unix fenc=utf8 nobomb et sw=4 ts=4 sts=4: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) 2019, Yung-Yu Chen <yyc@solvcon.net> | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* - Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* - Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* - Neither the name of the copyright holder nor the names of its contributors | ||
* may be used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include <modmesh/toggle/pymod/toggle_pymod.hpp> // Must be the first include. | ||
#include <modmesh/buffer/pymod/buffer_pymod.hpp> | ||
|
||
namespace modmesh | ||
{ | ||
|
||
namespace python | ||
{ | ||
|
||
struct mesh_pymod_tag; | ||
|
||
template <> | ||
OneTimeInitializer<mesh_pymod_tag> & OneTimeInitializer<mesh_pymod_tag>::me() | ||
{ | ||
static OneTimeInitializer<mesh_pymod_tag> instance; | ||
return instance; | ||
} | ||
|
||
void initialize_mesh(pybind11::module & mod) | ||
{ | ||
auto initialize_impl = [](pybind11::module & mod) | ||
{ | ||
wrap_StaticGrid(mod); | ||
wrap_StaticMesh(mod); | ||
}; | ||
|
||
OneTimeInitializer<mesh_pymod_tag>::me()(mod, initialize_impl); | ||
} | ||
|
||
} /* end namespace python */ | ||
|
||
} /* end namespace modmesh */ | ||
|
||
// vim: set ff=unix fenc=utf8 nobomb et sw=4 ts=4 sts=4: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright (c) 2022, Yung-Yu Chen <yyc@solvcon.net> | ||
# BSD-style license; see COPYING | ||
|
||
cmake_minimum_required(VERSION 3.16) | ||
|
||
# See https://google.github.io/googletest/quickstart-cmake.html for the | ||
# recommended cmake configuration | ||
include(FetchContent) | ||
FetchContent_Declare( | ||
googletest | ||
URL https://github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz | ||
DOWNLOAD_EXTRACT_TIMESTAMP ON | ||
) | ||
# 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( | ||
test_nopython | ||
test_nopython_buffer.cpp | ||
test_nopython_modmesh.cpp | ||
) | ||
target_link_libraries( | ||
test_nopython | ||
GTest::gtest_main | ||
) | ||
|
||
include(GoogleTest) | ||
gtest_discover_tests(test_nopython) | ||
|
||
add_custom_target(run_gtest | ||
COMMAND $<TARGET_FILE:test_nopython> | ||
DEPENDS test_nopython) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <modmesh/buffer/buffer.hpp> | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#ifdef Py_PYTHON_H | ||
#error "Python.h should not be included." | ||
#endif | ||
|
||
TEST(nopython_buffer, dummy) | ||
{ | ||
EXPECT_TRUE(true); | ||
} | ||
|
||
TEST(SimpleArray, construction) | ||
{ | ||
namespace mm = modmesh; | ||
mm::SimpleArray<double> arr_double(10); | ||
EXPECT_EQ(arr_double.nbody(), 10); | ||
mm::SimpleArray<int> arr_int(17); | ||
EXPECT_EQ(arr_int.nbody(), 17); | ||
} | ||
|
||
// vim: set ff=unix fenc=utf8 et sw=4 ts=4 sts=4: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <modmesh/modmesh.hpp> | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#ifdef Py_PYTHON_H | ||
#error "Python.h should not be included." | ||
#endif | ||
|
||
TEST(nopython_modmesh, dummy) | ||
{ | ||
EXPECT_TRUE(true); | ||
} | ||
|
||
// vim: set ff=unix fenc=utf8 et sw=4 ts=4 sts=4: |
Oops, something went wrong.