Merge pull request #3 from Aargonian/test-setup

Add Testing Support
This commit is contained in:
Aaron Helton
2019-10-23 21:54:29 -04:00
committed by GitHub
8 changed files with 100 additions and 2 deletions

5
.gitignore vendored
View File

@@ -6,4 +6,7 @@
cmake-build-debug/
# Ignore VisualStudio specific files
.vs/
.vs/
/test/output.txt
/test/output2.txt

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.

10
test/Sort Me 2.txt Normal file
View File

@@ -0,0 +1,10 @@
Aaron
abbie
Arnold
Barney
Zachariah
George
johnny
Jimmy
Jordan
Liz

10
test/Sorted 2.txt Normal file
View File

@@ -0,0 +1,10 @@
Liz
Aaron
abbie
Jimmy
Arnold
Barney
George
johnny
Jordan
Zachariah

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

14
test/Test.cmd Normal file
View File

@@ -0,0 +1,14 @@
echo off
SET OUTPUT="output.txt"
SET OUTPUT2="output2.txt"
if exist %OUTPUT% del /f %OUTPUT%
NameSort.exe "Sort Me.txt" > %OUTPUT%
fc %OUTPUT% "Sorted.txt"
if %errorlevel% EQU 0 (echo "Success") else ( echo "Failure")
if exist %OUTPUT2% del /f %OUTPUT2%
NameSort.exe "Sort Me 2.txt" > %OUTPUT2%
fc %OUTPUT2% "Sorted 2.txt"
if %errorlevel% EQU 0 (echo "Success") else ( echo "Failure")