blob: c50bab995b261d12b7d274bc8c5db32b2a4365d3 [file] [log] [blame]
Marc Kupietzab0a7332024-04-26 13:25:16 +02001#!/usr/bin/env bash
2TESTDIR=$(dirname $0)
3ASSERTSH=${TESTDIR}/assert.sh
Marc Kupietz73a26bf2024-04-26 17:36:44 +02004# set -e
Marc Kupietzab0a7332024-04-26 13:25:16 +02005. ${ASSERTSH}
Marc Kupietz73a26bf2024-04-26 17:36:44 +02006ERRORS=0
Marc Kupietzab0a7332024-04-26 13:25:16 +02007TEXTS=6
8I5_FILE=target/dnb18.i5.xml
9if [ ! -f "$I5_FILE" ]; then
10 log_failure "File $I5_FILE does not exist"
11 exit 1
12fi
13
14
15observed=$(xmlstarlet sel --net -t -v "count(//idsText)" $I5_FILE)
16
17if $(assert_eq "$observed" "$TEXTS"); then
18 log_success "$I5_FILE contains $TEXTS idsText elements"
19else
Marc Kupietz41c42382024-04-26 17:02:53 +020020 log_failure "$I5_FILE does not contain $TEXTS idsText elements, but: $observed"
Marc Kupietz73a26bf2024-04-26 17:36:44 +020021 ((ERRORS++))
Marc Kupietzab0a7332024-04-26 13:25:16 +020022fi
23
24
25observed=$(xmlstarlet sel --net -t -v "count(/idsCorpus/idsDoc/idsText/idsHeader/fileDesc/sourceDesc/biblStruct/monogr/h.author[normalize-space(.)])" $I5_FILE)
26if $(assert_eq "$observed" "$TEXTS"); then
27 log_success "$I5_FILE contains $TEXTS non-empty h.author elements"
28else
Marc Kupietz41c42382024-04-26 17:02:53 +020029 log_failure "$I5_FILE does not contain $TEXTS non-empty h.author elements: $observed"
30fi
31
32observed=$(xmlstarlet sel --net -t -v "/idsCorpus/idsHeader/fileDesc/titleStmt/c.title" target/dnb13.i5.xml)
33if $(assert_eq "$observed" "Deutsche Nationalbibliothek: Belletristik 2013"); then
34 log_success "c.title contains yeaar"
35else
36 log_failure "c.title does not contain year: $observed"
Marc Kupietz73a26bf2024-04-26 17:36:44 +020037 ((ERRORS++))
Marc Kupietzab0a7332024-04-26 13:25:16 +020038fi
39
Marc Kupietzfddbb512024-04-26 16:49:02 +020040observed=$(xmlstarlet sel --net -t -v "count(/idsCorpus/idsDoc/idsText/idsHeader/fileDesc/sourceDesc/biblStruct/monogr/h.author[contains(., '[')])" target/dnb13.i5.xml)
Marc Kupietzab0a7332024-04-26 13:25:16 +020041if $(assert_eq "$observed" "0"); then
42 log_success "authors do not contain []"
43else
Marc Kupietz41c42382024-04-26 17:02:53 +020044 log_failure "authors contain []: $observed"
Marc Kupietz73a26bf2024-04-26 17:36:44 +020045 ((ERRORS++))
46fi
47
Marc Kupietzeaa90132024-04-26 18:14:40 +020048observed=$(xmlstarlet sel --net -t -v "/idsCorpus/idsDoc/idsText/idsHeader/fileDesc/sourceDesc/biblStruct/monogr/editor[@role='translator'][1]" target/dnb13.i5.xml)
49if $(assert_eq "$observed" "Zwack, Heinz"); then
50 log_success "translator is correctly identified"
51else
52 log_failure "translator is not correctly identified: $observed"
53 ((ERRORS++))
54fi
55
Marc Kupietz54ec28b2024-04-27 10:07:06 +020056observed=$(grep -Ec '^Copyright' target/dnb13.i5.xml)
57if $(assert_eq "$observed" "2"); then
58 log_success "spaces at <br> elements are inserted correctly"
59else
60 log_failure "spaces at <br> elements are not inserted correctly"
61 ((ERRORS++))
62fi
63
Marc Kupietzeaa90132024-04-26 18:14:40 +020064
Marc Kupietz73a26bf2024-04-26 17:36:44 +020065if [ $ERRORS -gt 0 ]; then
66 log_failure "There were $ERRORS errors"
67 exit 1
68else
69 log_success "All tests passed"
70fi