diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..35085e5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +.idea/ +cmake-build-debug +CMakeFiles +Testing +cmake_install.cmake +CMakeCache.txt +*.a +*.cbp +mailparse_test +Makefile \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..075fd93 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 3.17) +project(mailparse) + +set(CMAKE_C_STANDARD 11) + +set(BUILD_TESTS on) + +add_library(mailparse src/library.c src/library.h) +set_target_properties(mailparse PROPERTIES LINKER_LANGUAGE C) + +if (BUILD_TESTS) + find_package(GTest CONFIG REQUIRED) + + add_executable(mailparse_test test/main.cpp) + target_compile_options(mailparse_test + PRIVATE + -g + -fsanitize=address + -fno-omit-frame-pointer) + target_link_libraries(mailparse_test + PRIVATE + GTest::gtest + GTest::gtest_main + -fsanitize=address + stdc++ + mailparse) +endif () diff --git a/src/library.c b/src/library.c new file mode 100644 index 0000000..9cd6841 --- /dev/null +++ b/src/library.c @@ -0,0 +1,8 @@ +#include "library.h" + +#include <stdio.h> + +int hello() { + printf("Hello, World!\n"); + return 12; +} diff --git a/src/library.h b/src/library.h new file mode 100644 index 0000000..e41f2f6 --- /dev/null +++ b/src/library.h @@ -0,0 +1,6 @@ +#ifndef LIBMAILPARSE_LIBRARY_H +#define LIBMAILPARSE_LIBRARY_H + +int hello(); + +#endif diff --git a/test/main.cpp b/test/main.cpp new file mode 100644 index 0000000..73a8d02 --- /dev/null +++ b/test/main.cpp @@ -0,0 +1,17 @@ +#include <gtest/gtest.h> + +extern "C" { +#include "../src/library.h" +} + +TEST(PlaceHolderTest, Test1) { + + int ret = hello(); + + ASSERT_EQ(ret, 12); +} + +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +}