From 107eaa9724b904a43802581f5c623ca6cd22c80d Mon Sep 17 00:00:00 2001 From: Jannik ZANDER Date: Mon, 16 Jul 2018 11:26:50 +0200 Subject: [PATCH 1/1] Initial commit --- .editorconfig | 16 ++++++++++++++++ folder1.c | 11 +++++++++++ folder1.h | 7 +++++++ folder1_test.cpp | 15 +++++++++++++++ folder2.c | 8 ++++++++ folder2.h | 6 ++++++ folder2/Source/CMakeLists.txt | 5 +++++ folder2/Test/CMakeLists.txt | 5 +++++ folder2_test.cpp | 9 +++++++++ meson.build | 15 +++++++++++++++ 10 files changed, 97 insertions(+) create mode 100644 .editorconfig create mode 100644 folder1.c create mode 100644 folder1.h create mode 100644 folder1_test.cpp create mode 100644 folder2.c create mode 100644 folder2.h create mode 100644 folder2/Source/CMakeLists.txt create mode 100644 folder2/Test/CMakeLists.txt create mode 100644 folder2_test.cpp create mode 100644 meson.build diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..6cd80db --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +; Top level editor config +root = true +; Always use Unix style new lines +end_of_line = lf +; New line ending on every file +insert_final_newline = true +; Trim whitespace +trim_trailing_whitespace = true +[*.py] +; PEP8 defines 4 spaces for indentation +indent_style = space +indent_size = 4 +[*.md] +; Markup file 2 spaces for indentation +indent_style = space +indent_size = 2 diff --git a/folder1.c b/folder1.c new file mode 100644 index 0000000..6064ddc --- /dev/null +++ b/folder1.c @@ -0,0 +1,11 @@ +#include "folder1.h" + +int function1() +{ + return 1; +} + +int function2() +{ + return 2; +} diff --git a/folder1.h b/folder1.h new file mode 100644 index 0000000..ae3e5bd --- /dev/null +++ b/folder1.h @@ -0,0 +1,7 @@ +#ifndef FOLDER1_H +#define FOLDER1_H + +int function1(); +int function2(); + +#endif // FOLDER1_H \ No newline at end of file diff --git a/folder1_test.cpp b/folder1_test.cpp new file mode 100644 index 0000000..68d7673 --- /dev/null +++ b/folder1_test.cpp @@ -0,0 +1,15 @@ +#include "gtest/gtest.h" +extern "C" { +#include "folder1.h" +} + +TEST(function1_test, compare1) +{ + ASSERT_EQ(function1(), 1) << "Values are equal function1 == 1"; +} + +TEST(function2_test, compare2) +{ + ASSERT_EQ(function2(), 2) << "Values are equal function2 == 2"; +} + diff --git a/folder2.c b/folder2.c new file mode 100644 index 0000000..2d27b97 --- /dev/null +++ b/folder2.c @@ -0,0 +1,8 @@ +#include "folder1.h" +#include "folder2.h" + + +int function3() +{ + return function1()+function2(); +} diff --git a/folder2.h b/folder2.h new file mode 100644 index 0000000..b03ea51 --- /dev/null +++ b/folder2.h @@ -0,0 +1,6 @@ +#ifndef FOLDER2_H +#define FOLDER2_H + +int function3(); + +#endif // FOLDER2_H \ No newline at end of file diff --git a/folder2/Source/CMakeLists.txt b/folder2/Source/CMakeLists.txt new file mode 100644 index 0000000..b509ca4 --- /dev/null +++ b/folder2/Source/CMakeLists.txt @@ -0,0 +1,5 @@ +add_unit(TARGET folder2 + SRCS folder2.c + INCS . + DEPS folder1) + diff --git a/folder2/Test/CMakeLists.txt b/folder2/Test/CMakeLists.txt new file mode 100644 index 0000000..a03731c --- /dev/null +++ b/folder2/Test/CMakeLists.txt @@ -0,0 +1,5 @@ +add_unittest(TARGET folder2_test + SRCS folder2_test.cpp + INCS . + DEPS folder2) + diff --git a/folder2_test.cpp b/folder2_test.cpp new file mode 100644 index 0000000..6e0d942 --- /dev/null +++ b/folder2_test.cpp @@ -0,0 +1,9 @@ +#include "gtest/gtest.h" +extern "C" { +#include "folder2.h" +} + +TEST(function3_test, compare3) +{ + ASSERT_EQ(function3(), 3) << "Values are equal function3 == 3"; +} diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..26e3c65 --- /dev/null +++ b/meson.build @@ -0,0 +1,15 @@ +project('meson_test','cpp', 'c') + +gtest = dependency('gtest', main : true, required : false) + +# Test 1 +folder1 = 'folder1.c' +folder1_test = executable('folder1_test.cpp', folder1, + dependencies : gtest) +test('folder1 test', folder1_test) + +# Test 2 +folder2 = 'folder2.c' +folder2_test = executable('folder2_test.cpp', folder1, folder2, + dependencies : gtest) +test('folder2 test', folder2_test) -- 2.43.0