···
18
+
output_file="../build/verses.txt"
···
26
-
rm -f "$temp_file" verses.txt
27
+
rm -f "$temp_file" "$output_file"
···
# Test with known valid verse
basic_input="Genesis\n1\n1"
80
-
resp=$(timeout "$test_timeout" bash -c "echo -e '$basic_input' | '$program'" 2>&1)
81
+
resp=$(timeout "$test_timeout" bash -c "echo -e '$basic_input' | '$program' OT.txt '$output_file'" 2>&1)
···
# Check for verse output format
127
-
if [[ "$resp" == *"GENESIS 1:1"* ]]; then
128
+
if [[ "$resp" == *"1 In the beginning God created the heaven and the earth"* ]]; then
print_result "Verse Format" "PASS" "Program outputs verse in correct format"
print_result "Verse Format" "FAIL" "Program missing or incorrect verse format"
133
-
# Check if verses.txt file was created
134
-
if [ -f "verses.txt" ]; then
135
-
verses_content=$(cat verses.txt)
134
+
# Check if test/verses.txt file was created
135
+
if [ -f "$output_file" ]; then
136
+
verses_content=$(cat "$output_file")
if [[ "$verses_content" == *"In the beginning God created the heaven and the earth"* ]]; then
137
-
print_result "File Output" "PASS" "verses.txt created with correct content"
138
+
print_result "File Output" "PASS" "verses.txt created with correct content in build directory"
print_result "File Output" "FAIL" "verses.txt has incorrect content"
142
-
print_result "File Output" "FAIL" "verses.txt file not created"
143
+
print_result "File Output" "FAIL" "verses.txt file not created in build directory"
# Function to run verse lookup test
···
local should_create_file="$6"
156
+
rm -f "$output_file"
input="$book\n$chapter\n$verse"
158
-
output=$(timeout "$test_timeout" bash -c "echo -e '$input' | '$program'" 2>&1)
159
+
output=$(timeout "$test_timeout" bash -c "echo -e '$input' | '$program' OT.txt '$output_file'" 2>&1)
if [ $exit_code -eq 124 ]; then
···
# Check file creation expectations
if [ "$should_create_file" = "true" ]; then
183
-
if [ -f "verses.txt" ] && [ "$pattern_found" = "true" ]; then
184
+
if [ -f "$output_file" ] && [ "$pattern_found" = "true" ]; then
print_result "$test_name" "PASS" "Expected output found and file created"
185
-
elif [ ! -f "verses.txt" ]; then
186
-
print_result "$test_name" "FAIL" "Expected file verses.txt not created"
186
+
elif [ ! -f "$output_file" ]; then
187
+
print_result "$test_name" "FAIL" "Expected file verses.txt not created in build directory"
print_result "$test_name" "FAIL" "File created but expected output not found"
191
-
if [ ! -f "verses.txt" ] && [ "$pattern_found" = "true" ]; then
192
+
if [ ! -f "$output_file" ] && [ "$pattern_found" = "true" ]; then
print_result "$test_name" "PASS" "Expected error output and no file created"
193
-
elif [ -f "verses.txt" ]; then
194
+
elif [ -f "$output_file" ]; then
print_result "$test_name" "FAIL" "verses.txt file should not be created for error cases"
print_result "$test_name" "FAIL" "Expected error message not found"
···
print_section "Valid Verse Tests"
204
-
run_verse_test "Exodus 20:3" "Exodus" "20" "3" "EXODUS 20:3" true
205
-
run_verse_test "Psalm 23:1" "Psalm" "23" "1" "PSALM 23:1" true
205
+
run_verse_test "Exodus 20:3" "Exodus" "20" "3" "3 Thou shalt have no other gods before me" true
206
+
run_verse_test "Psalm 23:1" "Psalm" "23" "1" "1 The LORD is my shepherd; I shall not want" true
print_section "Error Case Tests"
···
run_verse_test "Very Large Verse" "Genesis" "1" "999999" "Please enter the reference" false
229
-
run_verse_test "Lowercase Book" "genesis" "1" "1" "genesis does not exist in the Old Testament" false
230
-
run_verse_test "Mixed Case Book" "GEnesis" "1" "1" "GEnesis does not exist in the Old Testament" false
230
+
run_verse_test "Lowercase Book" "genesis" "1" "1" "1 In the beginning God created the heaven and the earth." true
231
+
run_verse_test "Mixed Case Book" "GEnesis" "1" "1" "1 In the beginning God created the heaven and the earth." true
233
-
run_verse_test "First Samuel" "First Samuel" "1" "1" "FIRST SAMUEL 1:1" true
234
-
run_verse_test "Second Kings" "Second Kings" "1" "1" "SECOND KINGS 1:1" true
234
+
run_verse_test "First Samuel" "First Samuel" "1" "1" "1 Now there was a certain man of Ramathaim-zophim, of mount Ephraim, and his name [was] Elkanah, the son of Jeroham, the son of Elihu, the son of Tohu, the son of Zuph, an Ephrathite:" true
235
+
run_verse_test "Second Kings" "Second Kings" "1" "1" "1 Then Moab rebelled against Israel after the death of Ahab" true
# Function to run file path test
···
local should_succeed="$4"
245
+
rm -f "$output_file"
# Provide verse lookup input for file path tests
if [ -n "$file_path" ]; then
250
-
output=$(timeout "$test_timeout" bash -c "echo -e '$input' | '$program' '$file_path'" 2>&1)
251
+
output=$(timeout "$test_timeout" bash -c "echo -e '$input' | '$program' '$file_path' '$output_file'" 2>&1)
252
-
output=$(timeout "$test_timeout" bash -c "echo -e '$input' | '$program'" 2>&1)
253
+
output=$(timeout "$test_timeout" bash -c "echo -e '$input' | '$program' OT.txt '$output_file'" 2>&1)