-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from branbick/unit-testing
Unit testing
- Loading branch information
Showing
50 changed files
with
1,508 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
**/*.exe | ||
**/*.out | ||
**/build | ||
.vscode/settings.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
C: | ||
gcc tester_c.c ../../src/init_from_input_file.c ../../src/init_tools.c -D PRINT_ERRORS -Wall -Wextra -Wpedantic -std=c90 -o tester_c_print_errors.out | ||
|
||
C++: | ||
g++ tester_cpp.cpp ../../src/init_from_input_file.c ../../src/init_tools.c -D PRINT_ERRORS -Wall -Wextra -Wpedantic -std=c++17 -o tester_cpp_print_errors.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
Build command: | ||
gcc integral_types_min_max.c -Wall -Wextra -Wpedantic -std=c90 -o integral_types_min_max.out | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <limits.h> | ||
|
||
int main(void) | ||
{ | ||
printf(" CHAR_MIN: % d\n", CHAR_MIN); | ||
printf(" CHAR_MAX: % d\n", CHAR_MAX); | ||
printf("SCHAR_MIN: % d\n", SCHAR_MIN); | ||
printf("SCHAR_MAX: % d\n", SCHAR_MAX); | ||
printf("UCHAR_MAX: %u\n\n", UCHAR_MAX); | ||
|
||
printf(" SHRT_MIN: % hd\n", SHRT_MIN); | ||
printf(" SHRT_MAX: % hd\n", SHRT_MAX); | ||
printf("USHRT_MAX: %hu\n\n", USHRT_MAX); | ||
|
||
printf(" INT_MIN: % d\n", INT_MIN); | ||
printf(" INT_MAX: % d\n", INT_MAX); | ||
printf(" UINT_MAX: %u\n\n", UINT_MAX); | ||
|
||
printf(" LONG_MIN: % ld\n", LONG_MIN); | ||
printf(" LONG_MAX: % ld\n", LONG_MAX); | ||
printf("ULONG_MAX: %lu\n\n", ULONG_MAX); | ||
|
||
return 0; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
cmake_minimum_required(VERSION 3.22.1) | ||
|
||
set(project_name init_from_input_file_non_static_fxns_test) | ||
|
||
set(CMAKE_CXX_STANDARD 17) # GoogleTest requires at least C++11 | ||
|
||
project( | ||
${project_name} | ||
LANGUAGES C CXX | ||
DESCRIPTION "Testing the non-static functions declared in \ | ||
src/init_from_input_file.h" | ||
) | ||
|
||
# Use GoogleTest without having it installed locally beforehand | ||
include(FetchContent) | ||
FetchContent_Declare( | ||
googletest | ||
URL https://github.com/google/googletest/archive/refs/tags/release-1.11.0.zip | ||
) | ||
FetchContent_MakeAvailable(googletest) | ||
|
||
enable_testing() | ||
|
||
add_executable( | ||
${project_name} | ||
${project_name}.cpp | ||
../../../src/init_from_input_file.c | ||
../../../src/init_tools.c | ||
) | ||
|
||
target_compile_options(${project_name} PRIVATE -Wall -Wextra -Wpedantic) | ||
|
||
target_link_libraries( | ||
${project_name} | ||
gtest_main | ||
) | ||
|
||
include(GoogleTest) | ||
gtest_discover_tests(${project_name}) |
14 changes: 14 additions & 0 deletions
14
test/init_from_input_file/non_static_fxns/InitFromInputFileTest.inp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
charSuccess A | ||
scharSuccess -1 | ||
ucharSuccess 1 | ||
shortSuccess -2 | ||
ushortSuccess 2 | ||
intSuccess -3 | ||
uintSuccess 3 | ||
longSuccess -4 | ||
ulongSuccess 4 | ||
floatSuccess 0.12345 | ||
doubleSuccess 0.123456789 | ||
ldoubleSuccess 0.12345678987654321 | ||
boolSuccess true | ||
stringSuccess "Hello, world!" |
Oops, something went wrong.