Setup Basic Testing Framework

This commit is contained in:
Aaron Helton
2019-10-23 21:26:29 -04:00
parent d75ea42b65
commit 78eb546dd6
5 changed files with 70 additions and 1 deletions

View File

@@ -9,4 +9,15 @@ add_executable(NameSort src/main.c
include/name_string.h
include/string_vector.h include/file_io.h src/file_io.c include/constants.h)
target_include_directories(NameSort PRIVATE ${CMAKE_SOURCE_DIR}/include)
# Copy executable to test directory after compilation for ease of testing
add_custom_command(TARGET NameSort POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:NameSort> ${CMAKE_SOURCE_DIR}/test/)
target_include_directories(NameSort PRIVATE ${CMAKE_SOURCE_DIR}/include)
# After everything has been built, we want to automatically run tests as part of the build
add_custom_command(
TARGET NameSort
POST_BUILD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test
COMMAND cmd //C Test.bat
)

BIN
test/NameSort.exe Normal file

Binary file not shown.

50
test/Sorted.txt Normal file
View File

@@ -0,0 +1,50 @@
Kha
Asby
Bain
Dean
Fife
Wile
Baker
Ellis
Evans
Foley
Glock
Graff
Heigl
Lundy
McVey
Nylon
Peery
Reyes
White
Adkins
Broome
Hickey
Laymon
Rogers
Tanton
Taylor
Byfield
Dulaney
Hagberg
Hillman
McCrave
Michael
Padgett
Routson
Starkey
Stegman
Bostwick
Cachedon
Giddings
Guenther
Hatfield
Kalivoda
Kirkland
Phillips
Reynolds
Sullivan
Williams
Clevenger
Fitzjerrell
Hendrickson

8
test/Test.bat Normal file
View File

@@ -0,0 +1,8 @@
NameSort.exe "Sort Me.txt" > Output.txt
fc Output.txt Sorted.txt
if errorlevel 1 {
echo "Test Failure"
} else {
echo "Test Success"
}