Commit 60798e35 authored by User expired's avatar User expired
Browse files

test: Comments and safe line counting tests

Add both standard and error output to be sure an error
is reported also in case of unexpected error messages.
parent 179326a2
......@@ -90,8 +90,8 @@ setUp() {
testPrintNonAsciiCharacters() {
# Two lines contain non ascii characters.
assertEquals '2' "$(bib-format -p $fileOne | wc -l)"
assertEquals '2' "$(bib-format -p $fileTwo | wc -l)"
assertEquals '2' "$(bib-format -p $fileOne 2>&1 | wc -l)"
assertEquals '2' "$(bib-format -p $fileTwo 2>&1 | wc -l)"
assertTrue 'file1 contains á' "bib-format -p $fileOne | grep -q 'á'"
assertTrue 'file1 contains ó' "bib-format -p $fileOne | grep -q 'ó'"
assertTrue 'file1 contains –' "bib-format -p $fileOne | grep -q '–'"
......@@ -99,7 +99,7 @@ testPrintNonAsciiCharacters() {
assertTrue 'file2 contains ó' "bib-format -p $fileTwo | grep -q 'ó'"
assertTrue 'file2 contains –' "bib-format -p $fileTwo | grep -q '–'"
# No non ascii characters in third file.
assertEquals '0' "$(bib-format -p $fileThree | wc -l)"
assertEquals '0' "$(bib-format -p $fileThree 2>&1 | wc -l)"
}
testPrintChangesStructure() {
......
......@@ -53,24 +53,24 @@ testListOfUnknownJournals() {
testJournalAbbreviation() {
# First only print changes.
assertEquals '5 lines change preview' '5' "$(bib-jabbr -n $fileOne | wc -l)"
assertEquals '5 lines change preview' '5' "$(bib-jabbr -n $fileOne 2>&1 | wc -l)"
assertTrue 'no file change with -n' "writeFileOne | diff - $fileOne"
# Now do the abbreviation.
bib-jabbr $fileOne
assertFalse 'file was changed' "writeFileOne | diff - $fileOne"
assertEquals '2 short name found' '2' "$(grep "$abbrName" $fileOne | wc -l)"
assertEquals '2 short name found' '2' "$(grep "$abbrName" $fileOne 2>&1 | wc -l)"
# No further changes in subsequent call.
assertEquals 'empty change preview' '' "$(bib-jabbr -n $fileOne)"
}
testJournalUnabbreviation() {
# First only print changes.
assertEquals '5 lines change preview' '5' "$(bib-jabbr -n -f $fileOne | wc -l)"
assertEquals '5 lines change preview' '5' "$(bib-jabbr -n -f $fileOne 2>&1 | wc -l)"
assertTrue 'no file change with -n' "writeFileOne | diff - $fileOne"
# Now replace abbreviation by full name.
bib-jabbr -f $fileOne
assertFalse 'file was changed' "writeFileOne | diff - $fileOne"
assertEquals '2 long names found' '2' "$(grep "$fullName" $fileOne | wc -l)"
assertEquals '2 long names found' '2' "$(grep "$fullName" $fileOne 2>&1 | wc -l)"
# No further changes in subsequent call.
assertEquals 'empty change preview' '' "$(bib-jabbr -n -f $fileOne)"
}
......
......@@ -131,17 +131,17 @@ testExampleBibtexFile() {
}
testQuietAndPrintChanges() {
assertEquals '3' "$(bib-keyinsert -n $fileOne | wc -l)"
assertEquals '@Article{doi:10.1063/1.3276633,' "$(head -n1 $fileOne)"
assertEquals '0' "$(bib-keyinsert -q $fileOne | wc -l)"
assertEquals '@Article{Czako2009:jcp,' "$(head -n1 $fileOne)"
assertEquals '0' "$(bib-keyinsert -n $fileOne | wc -l)"
assertEquals '3 lines preview' '3' "$(bib-keyinsert -n $fileOne 2>&1 | wc -l)"
assertEquals 'Unchanged file' '@Article{doi:10.1063/1.3276633,' "$(head -n1 $fileOne)"
assertEquals 'Quiet with -q' '0' "$(bib-keyinsert -q $fileOne 2>&1 | wc -l)"
assertEquals 'Updated key' '@Article{Czako2009:jcp,' "$(head -n1 $fileOne)"
assertEquals '0 lines preview' '0' "$(bib-keyinsert -n $fileOne 2>&1 | wc -l)"
}
testIgnoreCase() {
sed -i '1s_doi:10.1063/1.3276633_czako2009:jcp_' $fileOne
# If not case sensitive do not print and do not do changes.
assertFalse '' "$bib-keyinsert -n -i $fileOne | grep ."
assertFalse 'No changes' "bib-keyinsert -n -i $fileOne | grep ."
bib-keyinsert -q -i $fileOne
assertEquals '@Article{czako2009:jcp,' "$(head -n1 $fileOne)"
# If case sensitive do update the citation key.
......@@ -158,7 +158,7 @@ testYearWithLetter() {
testPrintKeys() {
# Option -p prints 4 unsorted keys.
assertEquals '4' "$(bib-keyinsert -p $fileTwo | wc -l)"
assertEquals '4' "$(bib-keyinsert -p $fileTwo 2>&1 | wc -l)"
assertEquals "$KEYS" "$(bib-keyinsert -p $fileTwo | cut -d' ' -f2 | sort -u)"
# Option -d print duplicate key occuring two times.
assertEquals '2' "$(bib-keyinsert -d $fileTwo | cut -f1)"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment