| Marc Kupietz | ab0a733 | 2024-04-26 13:25:16 +0200 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | TESTDIR=$(dirname $0) |
| 3 | ASSERTSH=${TESTDIR}/assert.sh |
| 4 | set -e |
| 5 | . ${ASSERTSH} |
| 6 | |
| 7 | TEXTS=6 |
| 8 | I5_FILE=target/dnb18.i5.xml |
| 9 | if [ ! -f "$I5_FILE" ]; then |
| 10 | log_failure "File $I5_FILE does not exist" |
| 11 | exit 1 |
| 12 | fi |
| 13 | |
| 14 | |
| 15 | observed=$(xmlstarlet sel --net -t -v "count(//idsText)" $I5_FILE) |
| 16 | |
| 17 | if $(assert_eq "$observed" "$TEXTS"); then |
| 18 | log_success "$I5_FILE contains $TEXTS idsText elements" |
| 19 | else |
| Marc Kupietz | 41c4238 | 2024-04-26 17:02:53 +0200 | [diff] [blame^] | 20 | log_failure "$I5_FILE does not contain $TEXTS idsText elements, but: $observed" |
| Marc Kupietz | ab0a733 | 2024-04-26 13:25:16 +0200 | [diff] [blame] | 21 | fi |
| 22 | |
| 23 | |
| 24 | observed=$(xmlstarlet sel --net -t -v "count(/idsCorpus/idsDoc/idsText/idsHeader/fileDesc/sourceDesc/biblStruct/monogr/h.author[normalize-space(.)])" $I5_FILE) |
| 25 | if $(assert_eq "$observed" "$TEXTS"); then |
| 26 | log_success "$I5_FILE contains $TEXTS non-empty h.author elements" |
| 27 | else |
| Marc Kupietz | 41c4238 | 2024-04-26 17:02:53 +0200 | [diff] [blame^] | 28 | log_failure "$I5_FILE does not contain $TEXTS non-empty h.author elements: $observed" |
| 29 | fi |
| 30 | |
| 31 | observed=$(xmlstarlet sel --net -t -v "/idsCorpus/idsHeader/fileDesc/titleStmt/c.title" target/dnb13.i5.xml) |
| 32 | if $(assert_eq "$observed" "Deutsche Nationalbibliothek: Belletristik 2013"); then |
| 33 | log_success "c.title contains yeaar" |
| 34 | else |
| 35 | log_failure "c.title does not contain year: $observed" |
| Marc Kupietz | ab0a733 | 2024-04-26 13:25:16 +0200 | [diff] [blame] | 36 | fi |
| 37 | |
| Marc Kupietz | fddbb51 | 2024-04-26 16:49:02 +0200 | [diff] [blame] | 38 | observed=$(xmlstarlet sel --net -t -v "count(/idsCorpus/idsDoc/idsText/idsHeader/fileDesc/sourceDesc/biblStruct/monogr/h.author[contains(., '[')])" target/dnb13.i5.xml) |
| Marc Kupietz | ab0a733 | 2024-04-26 13:25:16 +0200 | [diff] [blame] | 39 | if $(assert_eq "$observed" "0"); then |
| 40 | log_success "authors do not contain []" |
| 41 | else |
| Marc Kupietz | 41c4238 | 2024-04-26 17:02:53 +0200 | [diff] [blame^] | 42 | log_failure "authors contain []: $observed" |
| Marc Kupietz | ab0a733 | 2024-04-26 13:25:16 +0200 | [diff] [blame] | 43 | fi |