diff --git a/templates/cpp/.codeclimate.yml b/templates/cpp/.codeclimate.yml new file mode 100644 index 0000000..6c4ac90 --- /dev/null +++ b/templates/cpp/.codeclimate.yml @@ -0,0 +1,7 @@ +plugins: + cppcheck: + enabled: true + cpplint: + enabled: true + config: + filter: "-,+whitespace,+readability,-whitespace/ending_newline,-readability/multiline_string,-readability/casting" \ No newline at end of file diff --git a/templates/cpp/.vscode/settings.json b/templates/cpp/.vscode/settings.json new file mode 100644 index 0000000..3f00f17 --- /dev/null +++ b/templates/cpp/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "cmake.configureOnOpen": true +} \ No newline at end of file diff --git a/templates/cpp/CMakeLists.txt b/templates/cpp/CMakeLists.txt index 3abb47c..67fe88a 100644 --- a/templates/cpp/CMakeLists.txt +++ b/templates/cpp/CMakeLists.txt @@ -6,4 +6,7 @@ set(CMAKE_CXX_STANDARD 11) include_directories(src) add_subdirectory(src) -add_subdirectory(test) + +if(DEFINED ENV{CI}) + add_subdirectory(test) +endif() diff --git a/templates/cpp/codefreak.yml b/templates/cpp/codefreak.yml index 78f135c..d88b45e 100644 --- a/templates/cpp/codefreak.yml +++ b/templates/cpp/codefreak.yml @@ -3,8 +3,9 @@ title: Program in C++ description: "# C++ Task Example\n\nThis is a basic C++ task to get you started quickly with Code FREAK.\n\nTo turn this into a useful programming exercise, you have to do the following.\n\n## Provide Code to Students\n\nIf you do not want your students to start completely from scratch, provide some scaffolding code. Look into `src` for some inspiration.\n\n## Setup Automatic Evaluation\n\nThis example comes with a pre-configured evaluation step. You can see it in the _Evaluation_ tab. To try it out, enter _testing mode_ and start the evaluation.\n\n### Unit Tests\n\nUnit tests are your main instrument for automatically validating your students' answers. To get started, look into `test` for example test cases.\n\nThe standard testing framework for C++ is googletest. Refer to the [official documentation](https://github.com/google/googletest) for more information.\n\n## Provide Instructions\n\nClick on this text to edit it. Here you describe to your students what they have to do.\n" hidden: - test/** +- .codeclimate.yml +protected: - CMakeLists.txt -protected: [] evaluation: - step: comments options: {} @@ -19,5 +20,6 @@ evaluation: - make -C build ExampleProject_tst - build/test/ExampleProject_tst --gtest_output=xml:test-results/TEST-report.xml title: Unit Tests -ide: - enabled: true +- step: codeclimate + options: {} + title: Code Quality diff --git a/templates/cpp/test/CalculatorTest.cpp b/templates/cpp/test/CalculatorTest.cpp index a041ca9..c706436 100644 --- a/templates/cpp/test/CalculatorTest.cpp +++ b/templates/cpp/test/CalculatorTest.cpp @@ -26,7 +26,7 @@ TEST_F(CalculatorTest, AdditionWithRegularNumbers) { TEST_F(CalculatorTest, ValidAdditionsWithExtremeValues) { EXPECT_EQ(calculator->add(INT_MAX, 0), INT_MAX); EXPECT_EQ(calculator->add(INT_MIN, 0), INT_MIN); - EXPECT_EQ(calculator->add(INT_MAX, -1 * INT_MIN), 0); + EXPECT_EQ(calculator->add(INT_MAX, INT_MIN + 1), 0); } TEST_F(CalculatorTest, InvalidAdditionsThatWouldResultInAnIntegerOverflow) {