Skip to content

Commit

Permalink
add native_test
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Aug 18, 2024
1 parent 1566dfc commit 0c488cd
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/c.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ jobs:
NO_OPTIONAL_TESTS: true
COMPILER_OVERRIDE: clang

- name: Run tests (native runner)
run: make c_native_test

- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/cplusplus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ jobs:
NO_OPTIONAL_TESTS: true
COMPILER_OVERRIDE: clang

- name: Run tests (native test runner)
run: make cp_native_test

- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
Expand Down
6 changes: 5 additions & 1 deletion c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ lint:

.PHONY: native
native: ../LICENSE Unity/src/unity.c
@$(CC) test.c Unity/src/unity.c -O$(O) -g -lm -lc -Wall -Werror -std=gnu99 -march=native -flto
@$(CC) test.c Unity/src/unity.c -O$(O) -g -lm -lc -Wall -Werror -std=gnu99 -march=native -flto --coverage -o native_test_runner

.PHONY: native_test
native_test: native
@./native_test_runner

.PHONY: clean
clean:
Expand Down
2 changes: 1 addition & 1 deletion c/src/include/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Answer get_answer(uint16_t id) {
char *linepointer;
char *tabpointer;
Answer ret = {
id: id,
.id = id,
};
char *answers = get_data_file("answers.tsv");

Expand Down
6 changes: 5 additions & 1 deletion cplusplus/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ lint:

.PHONY: native
native: ../LICENSE Unity/src/unity.c
@$(CXX) test.cpp Unity/src/unity.c -O$(O) -g -lm -lstdc++ -Wall -Werror -std=gnu++11 -march=native -flto
@$(CXX) test.cpp Unity/src/unity.c -O$(O) -g -lm -lstdc++ -Wall -Werror -std=gnu++11 -march=native -flto -Wno-deprecated --coverage -o native_test_runner

.PHONY: native_test
native_test: native
@./native_test_runner

.PHONY: clean
clean:
Expand Down
8 changes: 4 additions & 4 deletions cplusplus/src/include/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Answer get_answer(const uint16_t id) {
break;
default:
std::cerr << "Error: Unsupported int size " << size << "'\n";
Answer err = {0};
Answer err = {{0}};
return err;
}
break;
Expand All @@ -191,7 +191,7 @@ Answer get_answer(const uint16_t id) {
break;
default:
std::cerr << "Error: Unsupported uint size " << size << "'\n";
Answer err = {0};
Answer err = {{0}};
return err;
}
break;
Expand All @@ -202,13 +202,13 @@ Answer get_answer(const uint16_t id) {
answer.value.STR[size] = 0;
} else {
std::cerr << "Error: Memory allocation failed for string\n";
Answer err = {0};
Answer err = {{0}};
return err;
}
break;
default:
std::cerr << "Error: Unknown type (should be unreachable)\n";
Answer err = {0};
Answer err = {{0}};
return err;
}
}
Expand Down

0 comments on commit 0c488cd

Please sign in to comment.