Skip to content

Commit

Permalink
c++/leap: 2nd iteration - c header -> cpp header
Browse files Browse the repository at this point in the history
  • Loading branch information
vpayno committed Jul 17, 2023
1 parent e56b0c2 commit 33ac22f
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 56 deletions.
6 changes: 3 additions & 3 deletions cpp/leap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ endif()
# Use the common Catch library?
if(EXERCISM_COMMON_CATCH)
# For Exercism track development only
add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.h
add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.hpp
$<TARGET_OBJECTS:catchlib>)
elseif(EXERCISM_TEST_SUITE)
# The Exercism test suite is being run, the Docker image already includes a
# pre-built version of Catch.
find_package(Catch2 REQUIRED)
add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.h)
add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.hpp)
target_link_libraries(${exercise} PRIVATE Catch2::Catch2WithMain)
# When Catch is installed system wide we need to include a different header,
# we need this define to use the correct one.
target_compile_definitions(${exercise} PRIVATE EXERCISM_TEST_SUITE)
else()
# Build executable from sources and headers
add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.h
add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.hpp
test/tests-main.cpp)
endif()

Expand Down
2 changes: 1 addition & 1 deletion cpp/leap/leap.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "leap.h"
#include "leap.hpp"

namespace leap {

Expand Down
12 changes: 0 additions & 12 deletions cpp/leap/leap.h

This file was deleted.

10 changes: 10 additions & 0 deletions cpp/leap/leap.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#if !defined(LEAP_HPP)
#define LEAP_HPP

namespace leap {

bool is_leap_year(int year);

} // namespace leap

#endif // LEAP_HPP
2 changes: 1 addition & 1 deletion cpp/leap/leap_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "leap.h"
#include "leap.hpp"
#ifdef EXERCISM_TEST_SUITE
#include <catch2/catch.hpp>
#else
Expand Down
72 changes: 33 additions & 39 deletions cpp/leap/run-tests-cpp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Running automated test file(s):
Running: make clean
rm -rf ./build

real 0m0.007s
real 0m0.010s
user 0m0.001s
sys 0m0.006s
sys 0m0.009s

===============================================================================

Expand Down Expand Up @@ -70,25 +70,25 @@ Directory: .
File Lines Exec Cover Missing
------------------------------------------------------------------------------
leap.cpp 8 8 100%
leap_test.cpp 18 18 100%
leap_test.cpp 14 14 100%
test/catch.hpp 34 29 85% 1642-1643,2301-2302,2560
------------------------------------------------------------------------------
TOTAL 60 55 91%
TOTAL 56 51 91%
------------------------------------------------------------------------------
lines: 91.7% (55 out of 60)
lines: 91.1% (51 out of 56)
branches: 39.6% (38 out of 96)

real 0m9.146s
user 0m8.484s
sys 0m0.659s
real 0m9.643s
user 0m8.761s
sys 0m0.877s

===============================================================================

cmake-format --in-place CMakeLists.txt

real 0m0.265s
user 0m0.181s
sys 0m0.081s
real 0m0.347s
user 0m0.246s
sys 0m0.080s

===============================================================================

Expand All @@ -110,55 +110,49 @@ found lint:
Convention: 4


real 0m0.158s
user 0m0.104s
sys 0m0.056s
real 0m0.172s
user 0m0.115s
sys 0m0.058s

===============================================================================

Running: clang-format-16 -style=file -i ./leap.cpp ./leap_test.cpp ./leap.h
Running: clang-format-16 -style=file -i ./leap.cpp ./leap_test.cpp

real 0m0.023s
user 0m0.014s
sys 0m0.008s
real 0m0.019s
user 0m0.009s
sys 0m0.010s

===============================================================================

Running: ../../.github/citools/cpp/clang-check
clang-check-16 --analyze ./leap.cpp ./leap_test.cpp ./leap.h
error: argument unused during compilation: '-stdlib=libstdc++' [-Werror,-Wunused-command-line-argument]
error: invalid argument '-std=c++17' not allowed with 'C'
clang-check-16 --analyze ./leap.cpp ./leap_test.cpp ./leap.hpp

real 0m0.466s
user 0m0.398s
sys 0m0.067s
real 0m0.413s
user 0m0.373s
sys 0m0.039s


real 0m0.467s
user 0m0.398s
sys 0m0.069s
real 0m0.414s
user 0m0.375s
sys 0m0.040s

===============================================================================

Running: ../../.github/citools/cpp/clang-tidy | head -n 100
35376 warnings generated.
35376 warnings and 2 errors generated.
Error while processing /home/vpayno/git_vpayno/exercism-workspace/cpp/leap/leap.h.
35376 warnings generated.
Suppressed 35381 warnings (35376 in non-user code, 5 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
Found compiler error(s).

real 0m5.255s
user 0m5.190s
sys 0m0.064s
Running: clang-tidy-16 ./leap.cpp ./leap_test.cpp ./leap.h
error: invalid argument '-std=c++17' not allowed with 'C' [clang-diagnostic-error]
error: argument unused during compilation: '-stdlib=libstdc++' [clang-diagnostic-unused-command-line-argument]
real 0m5.439s
user 0m5.378s
sys 0m0.060s
Running: clang-tidy-16 ./leap.cpp ./leap_test.cpp ./leap.hpp


real 0m5.257s
user 0m5.190s
sys 0m0.068s
real 0m5.440s
user 0m5.379s
sys 0m0.062s

===============================================================================

0 comments on commit 33ac22f

Please sign in to comment.