Simplify testing
diff --git a/test/test-xml.sh b/test/test-xml.sh
index 63bb2ea..3a77a95 100755
--- a/test/test-xml.sh
+++ b/test/test-xml.sh
@@ -4,6 +4,7 @@
# set -e
. ${ASSERTSH}
ERRORS=0
+PASSED=0
TEXTS=6
I5_FILE=target/dnb18.i5.xml
if [ ! -f "$I5_FILE" ]; then
@@ -13,59 +14,23 @@
observed=$(xmlstarlet sel --net -t -v "count(//idsText)" $I5_FILE)
-
-if $(assert_eq "$observed" "$TEXTS"); then
- log_success "$I5_FILE contains $TEXTS idsText elements"
-else
- log_failure "$I5_FILE does not contain $TEXTS idsText elements, but: $observed"
- ((ERRORS++))
-fi
-
+assert_eq "$observed" "$TEXTS" "$I5_FILE contains $TEXTS idsText elements"
observed=$(xmlstarlet sel --net -t -v "count(/idsCorpus/idsDoc/idsText/idsHeader/fileDesc/sourceDesc/biblStruct/monogr/h.author[normalize-space(.)])" $I5_FILE)
-if $(assert_eq "$observed" "$TEXTS"); then
- log_success "$I5_FILE contains $TEXTS non-empty h.author elements"
-else
- log_failure "$I5_FILE does not contain $TEXTS non-empty h.author elements: $observed"
- ((ERRORS++))
-fi
+assert_eq "$observed" "$TEXTS" "$I5_FILE contains $TEXTS non-empty h.author elements"
observed=$(xmlstarlet sel --net -t -v "/idsCorpus/idsHeader/fileDesc/titleStmt/c.title" target/dnb13.i5.xml)
-if $(assert_eq "$observed" "Deutsche Nationalbibliothek: Belletristik 2013"); then
- log_success "c.title contains yeaar"
-else
- log_failure "c.title does not contain year: $observed"
- ((ERRORS++))
-fi
+assert_eq "$observed" "Deutsche Nationalbibliothek: Belletristik 2013" "c.title contains yeaar"
observed=$(xmlstarlet sel --net -t -v "count(/idsCorpus/idsDoc/idsText/idsHeader/fileDesc/sourceDesc/biblStruct/monogr/h.author[contains(., '[')])" target/dnb13.i5.xml)
-if $(assert_eq "$observed" "0"); then
- log_success "authors do not contain []"
-else
- log_failure "authors contain []: $observed"
- ((ERRORS++))
-fi
+assert_eq "$observed" "0" "authors do not contain []"
observed=$(xmlstarlet sel --net -t -v "/idsCorpus/idsDoc/idsText/idsHeader/fileDesc/sourceDesc/biblStruct/monogr/editor[@role='translator'][1]" target/dnb13.i5.xml)
-if $(assert_eq "$observed" "Zwack, Heinz"); then
- log_success "translator is correctly identified"
-else
- log_failure "translator is not correctly identified: $observed"
- ((ERRORS++))
-fi
+assert_eq "$observed" "Zwack, Heinz" "translator is correctly identified"
observed=$(grep -Ec '^Copyright' target/dnb13.i5.xml)
-if $(assert_eq "$observed" "2"); then
- log_success "spaces at <br> elements are inserted correctly"
-else
- log_failure "spaces at <br> elements are not inserted correctly"
- ((ERRORS++))
-fi
+assert_eq "$observed" "2" "spaces at <br> elements are inserted correctly"
+
+exit_with_test_summary
-if [ $ERRORS -gt 0 ]; then
- log_failure "There were $ERRORS errors"
- exit 1
-else
- log_success "All tests passed"
-fi