-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
64 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
cmake_minimum_required(VERSION 3.21) | ||
|
||
project(ccontainerTests LANGUAGES C CXX) | ||
|
||
include(../cmake/folders.cmake) | ||
|
||
# ---- Dependencies ---- | ||
|
||
if(PROJECT_IS_TOP_LEVEL) | ||
find_package(ccontainer REQUIRED) | ||
enable_testing() | ||
endif() | ||
|
||
find_package(Catch2 REQUIRED) | ||
include(Catch) | ||
|
||
# ---- Tests ---- | ||
|
||
add_executable( | ||
ccontainer_test | ||
source/ccontainer_test.cpp | ||
source/header_impl.c | ||
) | ||
target_link_libraries( | ||
ccontainer_test PRIVATE | ||
ccontainer::ccontainer | ||
Catch2::Catch2WithMain | ||
) | ||
target_compile_features(ccontainer_test PRIVATE c_std_99 cxx_std_11) | ||
|
||
catch_discover_tests(ccontainer_test) | ||
|
||
# ---- End-of-file commands ---- | ||
|
||
add_folders(Test) |
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,27 @@ | ||
#include <cstdlib> | ||
#include <memory> | ||
#include <string> | ||
#include <type_traits> | ||
|
||
#include <catch2/catch.hpp> | ||
|
||
#include "ccontainer/ccontainer.h" | ||
|
||
namespace { | ||
|
||
template<typename T> | ||
void c_free(T* ptr) | ||
{ | ||
using U = typename std::remove_cv<T>::type; | ||
std::free(static_cast<void*>(const_cast<U*>(ptr))); | ||
} | ||
|
||
} | ||
|
||
TEST_CASE("Name is ccontainer", "[library]") | ||
{ | ||
using c_string_ptr = std::unique_ptr<char const, void(*)(char const*)>; | ||
auto name_ptr = c_string_ptr(header_only_name(), &c_free<char const>); | ||
|
||
REQUIRE(std::string("ccontainer") == name_ptr.get()); | ||
} |
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,2 @@ | ||
#define CCONTAINER_IMPLEMENTATION | ||
#include "ccontainer/ccontainer.h" |
Empty file.