a gleam implementation of a CS assignment originally written in cpp

feat: handle the special case that psalms throws at us

Changed files
+9 -6
src
test
+8 -5
src/lab66.cpp
···
getline(OT, input); // handle multi word books
-
if (input == normalizedBook) {
+
// second check is for the book of psalms
+
if (input == normalizedBook || input == (normalizedBook + "S")) {
foundBook = true;
getline(OT, input); // discard empty line
···
} else {
if (!foundChapter) {
OT >> input;
-
if (input != "CHAPTER") {
+
if (input != "CHAPTER" && input != "PSALM") {
if (input == "THE") break;
continue;
}
+
OT >> input;
if (input == to_string(chapter)) {
foundChapter = true;
···
} else {
OT >> input;
-
if (input == "CHAPTER") break;
+
if (input == "CHAPTER" || input == "PSALM") break;
if (input == to_string(verse)) {
foundVerse = true;
···
OF.close();
} else {
if (!foundBook) {
-
cout << book << " does not exist in the Old Testament";
+
cout << (normalizedBook == "PSALM" ? book += "s" : book) << " does not exist in the Old Testament";
} else {
if (!foundChapter) {
-
cout << "Chapter " << chapter << " does not exist in " << book;
+
cout << (normalizedBook == "PSALM" ? "Psalm " : "Chapter ") << chapter;
+
cout << " does not exist in " << (normalizedBook == "PSALM" ? book += "s" : book);
} else if (!foundVerse) {
cout << "Verse " << verse << " does not exist in " << book << " " << chapter;
}
+1 -1
test/test.sh
···
print_section "Valid Verse Tests"
run_verse_test "Exodus 20:3" "Exodus" "20" "3" "3 Thou shalt have no other gods before me" true
-
run_verse_test "Psalm 23:1" "Psalm" "23" "1" "1 The LORD is my shepherd; I shall not want" true
+
run_verse_test "Psalm 23:1" "Psalm" "23" "1" "1 The LORD [is] my shepherd; I shall not want." true
# Error Case Tests
print_section "Error Case Tests"