Skip to content

Commit

Permalink
Run clang-format script in pre-commit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
mortinger91 committed Oct 24, 2023
1 parent 83a69e8 commit bc694df
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
8 changes: 8 additions & 0 deletions ProjectFolder/scripts/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@
find ProjectFolder/src/ -iname *.h -o -iname *.cpp | xargs clang-format -i

find ProjectFolder/tests/ -iname *.h -o -iname *.cpp | xargs clang-format -i

# Check if any changes were made by clang-format
if git diff --exit-code; then
echo "Formatting is ok, no changes applied"
else
echo "Formatting is wrong, changes have been applied"
exit 1
fi
22 changes: 14 additions & 8 deletions ProjectFolder/tests/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,21 @@ namespace test
} // namespace test

#ifdef _WIN32
#define assertTrue(expr) if (!(expr)) { \
std::cerr << "Assertion failed: " << #expr << " in " << __FILE__ << " line " << __LINE__ << std::endl; \
ExitProcess(1); \
}
#define assertTrue(expr) \
if (!(expr)) \
{ \
std::cerr << "Assertion failed: " << #expr << " in " << __FILE__ \
<< " line " << __LINE__ << std::endl; \
ExitProcess(1); \
}
#else
#define assertTrue(expr) if (!(expr)) { \
std::cerr << "Assertion failed: " << #expr << " in " << __FILE__ << " line " << __LINE__ << std::endl; \
std::abort(); \
}
#define assertTrue(expr) \
if (!(expr)) \
{ \
std::cerr << "Assertion failed: " << #expr << " in " << __FILE__ \
<< " line " << __LINE__ << std::endl; \
std::abort(); \
}
#endif

#define ASSERT_THROW(condition) \
Expand Down

0 comments on commit bc694df

Please sign in to comment.