Initial commit

This commit is contained in:
simon987 2021-01-02 09:13:57 -05:00
parent 3393e181d9
commit ddac1a0f50
5 changed files with 68 additions and 0 deletions

10
.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
.idea/
cmake-build-debug
CMakeFiles
Testing
cmake_install.cmake
CMakeCache.txt
*.a
*.cbp
mailparse_test
Makefile

27
CMakeLists.txt Normal file
View File

@ -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 ()

8
src/library.c Normal file
View File

@ -0,0 +1,8 @@
#include "library.h"
#include <stdio.h>
int hello() {
printf("Hello, World!\n");
return 12;
}

6
src/library.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef LIBMAILPARSE_LIBRARY_H
#define LIBMAILPARSE_LIBRARY_H
int hello();
#endif

17
test/main.cpp Normal file
View File

@ -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();
}