Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix autoformatter crashing #19

Merged
merged 13 commits into from
Feb 18, 2024
14 changes: 9 additions & 5 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ jobs:
clang-format:
name: Clang-Format
runs-on: ubuntu-latest
permissions:
contents: write
environment: ${{ github.actor }}_environment

steps:
- name: Checkout code
Expand All @@ -18,10 +21,10 @@ jobs:
run: sudo apt-get install -y clang-format

- name: Format source code
run: clang-format -i game/**/*.cpp game/**/*.hpp 0 --style file:.clang-format --verbose
run: clang-format -i game/**/*.cpp game/**/*.hpp --ferror-limit=0 --style file:.clang-format --verbose

- name: Format tests
run: clang-format -i tests/**/*.cpp tests/**/*.hpp 0 --style file:.clang-format --verbose
run: clang-format -i tests/**/*.cpp tests/**/*.hpp --ferror-limit=0 --style file:.clang-format --verbose

- name: Check for modifications
id: check_modifications
Expand All @@ -31,9 +34,10 @@ jobs:
- name: Commit and push changes
if: env.modified == 'true'
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -a -m "Format: ${{github.event.commits[0].message}}"
git config --global user.email "${{ github.event.commits[0].author.email }}"
git config --global user.name "${{ github.event.commits[0].author.name }}"
git commit -a -m "Autoformat code"
- name: Push changes
uses: ad-m/github-push-action@master
with:
Expand Down
Empty file.
Empty file.
Empty file added tests/unit-tests/dummy.hpp
Empty file.
36 changes: 18 additions & 18 deletions tests/unit-tests/example_test.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include <limits.h>
#include "gtest/gtest.h"

#include "gtest/gtest.h"

int Factorial(int n) {
//For negative n, n! is defined to be 1.
// For negative n, n! is defined to be 1.
int result = 1;
for (int i = 1; i <= n; i++) {
result *= i;
result *= i;
}

return result;
Expand All @@ -33,29 +33,29 @@ TEST(FactorialTest, Negative) {
TEST(FactorialTest, Zero) { EXPECT_EQ(1, Factorial(0)); }

TEST(FactorialTest, Positive) {
EXPECT_EQ(1, Factorial(1));
EXPECT_EQ(2, Factorial(2));
EXPECT_EQ(6, Factorial(3));
EXPECT_EQ(40320, Factorial(8));
EXPECT_EQ(1, Factorial(1));
EXPECT_EQ(2, Factorial(2));
EXPECT_EQ(6, Factorial(3));
EXPECT_EQ(40320, Factorial(8));
}

TEST(IsPrimeTest, Negative) {
EXPECT_FALSE(IsPrime(-1));
EXPECT_FALSE(IsPrime(-2));
EXPECT_FALSE(IsPrime(INT_MIN));
EXPECT_FALSE(IsPrime(-1));
EXPECT_FALSE(IsPrime(-2));
EXPECT_FALSE(IsPrime(INT_MIN));
}

TEST(IsPrimeTest, Trivial) {
EXPECT_FALSE(IsPrime(0));
EXPECT_FALSE(IsPrime(1));
EXPECT_TRUE(IsPrime(2));
EXPECT_TRUE(IsPrime(3));
EXPECT_FALSE(IsPrime(0));
EXPECT_FALSE(IsPrime(1));
EXPECT_TRUE(IsPrime(2));
EXPECT_TRUE(IsPrime(3));
}

TEST(IsPrimeTest, Positive) {
EXPECT_FALSE(IsPrime(4));
EXPECT_TRUE(IsPrime(5));
EXPECT_FALSE(IsPrime(6));
EXPECT_TRUE(IsPrime(23));
EXPECT_FALSE(IsPrime(4));
EXPECT_TRUE(IsPrime(5));
EXPECT_FALSE(IsPrime(6));
EXPECT_TRUE(IsPrime(23));
}
} // namespace
Loading