]> diplodocus.org Git - nmh/blobdiff - test/mhbuild/test-header-encode
mhbuildsbr.c: Flip logic, moving goto to then-block; no need for else.
[nmh] / test / mhbuild / test-header-encode
index 2bba58ed3ca584e81cda15dc96d68ccd7c68e262..8c0f9aae54668247ad1adc416bde76d0bc2f002c 100755 (executable)
@@ -15,13 +15,16 @@ fi
 . "${MH_OBJ_DIR}/test/common.sh"
 
 setup_test
 . "${MH_OBJ_DIR}/test/common.sh"
 
 setup_test
+
+check_exit '-eq 1' mhbuild -h
+
 testname="${MH_TEST_DIR}/$$"
 testname="${MH_TEST_DIR}/$$"
+backupname="${MH_TEST_DIR}/`mhparam sbackup`$$"
 
 #
 # We're going to hardcode UTF-8 for this test.
 #
 
 #
 # We're going to hardcode UTF-8 for this test.
 #
-
-LC_ALL=en_US.UTF-8; export LC_ALL
+require_locale en_US.UTF-8 en_US.UTF8 en_US.utf-8 en_US.utf8
 
 #
 # Basic test of encoding a short subject
 
 #
 # Basic test of encoding a short subject
@@ -44,7 +47,7 @@ Content-Type: text/plain; charset="us-ascii"
 This is a test
 EOF
 
 This is a test
 EOF
 
-mhbuild "${testname}.basic.actual"
+run_prog mhbuild "${testname}.basic.actual"
 
 check "${testname}.basic.actual" "${testname}.basic.expected" 'keep first'
 
 
 check "${testname}.basic.actual" "${testname}.basic.expected" 'keep first'
 
@@ -77,13 +80,13 @@ Content-Type: text/plain; charset="us-ascii"
 This is a test
 EOF
 
 This is a test
 EOF
 
-mhbuild -headerencoding base64 "${testname}.basic.actual"
+run_prog mhbuild -headerencoding base64 "${testname}.basic.actual"
 
 check "${testname}.basic.actual" "${testname}.basic.expected" 'keep first'
 
 run_test 'eval fmttest -outsize max -format "%(decode{subject})" -message -file "${testname}.basic.actual"' 'This is ä test'
 
 
 check "${testname}.basic.actual" "${testname}.basic.expected" 'keep first'
 
 run_test 'eval fmttest -outsize max -format "%(decode{subject})" -message -file "${testname}.basic.actual"' 'This is ä test'
 
-rm -f "${testname}.basic.actual"
+rm -f "${testname}.basic.actual" "${backupname}.basic.actual.orig"
 
 #
 # Have a subject that will pick base64 as the shorter encoding
 
 #
 # Have a subject that will pick base64 as the shorter encoding
@@ -107,13 +110,13 @@ Content-Type: text/plain; charset="us-ascii"
 This is a test
 EOF
 
 This is a test
 EOF
 
-mhbuild "${testname}.autopick.actual"
+run_prog mhbuild "${testname}.autopick.actual"
 
 check "${testname}.autopick.actual" "${testname}.autopick.expected" 'keep first'
 
 run_test 'eval fmttest -outsize max -format "%(decode{subject})" -message -file "${testname}.autopick.actual"' 'This is ä tëst©'
 
 
 check "${testname}.autopick.actual" "${testname}.autopick.expected" 'keep first'
 
 run_test 'eval fmttest -outsize max -format "%(decode{subject})" -message -file "${testname}.autopick.actual"' 'This is ä tëst©'
 
-rm -f "${testname}.basic.autopick"
+rm -f "${testname}.autopick.actual" "${backupname}.autopick.actual.orig"
 
 #
 # Tests using longer subject lines.
 
 #
 # Tests using longer subject lines.
@@ -142,13 +145,13 @@ Content-Type: text/plain; charset="us-ascii"
 This is a test of a very long subject line.
 EOF
 
 This is a test of a very long subject line.
 EOF
 
-mhbuild "${testname}.longsubject1.actual"
+run_prog mhbuild "${testname}.longsubject1.actual"
 
 check "${testname}.longsubject1.actual" "${testname}.longsubject1.expected" 'keep first'
 
 run_test 'eval fmttest -outsize max -format "%(putlit(decode(trim{subject})))" -message -file "${testname}.longsubject1.actual"' "This is ä tëst of a rather long sübject line; will it overflow the line length?  I sure hope thät ='s and _'s are encoded properly.  Will they be?"
 
 
 check "${testname}.longsubject1.actual" "${testname}.longsubject1.expected" 'keep first'
 
 run_test 'eval fmttest -outsize max -format "%(putlit(decode(trim{subject})))" -message -file "${testname}.longsubject1.actual"' "This is ä tëst of a rather long sübject line; will it overflow the line length?  I sure hope thät ='s and _'s are encoded properly.  Will they be?"
 
-rm -f "${testname}.longsubject1.actual"
+rm -f "${testname}.longsubject1.actual" "${backupname}.longsubject1.actual.orig"
 
 #
 # Test a longer line with base64 encoding
 
 #
 # Test a longer line with base64 encoding
@@ -178,13 +181,13 @@ Content-Type: text/plain; charset="us-ascii"
 This is a test of a very long subject line using base64.
 EOF
 
 This is a test of a very long subject line using base64.
 EOF
 
-mhbuild "${testname}.longsubject2.actual"
+run_prog mhbuild "${testname}.longsubject2.actual"
 
 check "${testname}.longsubject2.actual" "${testname}.longsubject2.expected" 'keep first'
 
 run_test 'eval fmttest -outsize max -format "%(putlit(decode(trim{subject})))" -message -file "${testname}.longsubject2.actual"' "This is ä tëst øf ä räthër løng sübjëct line; will it øvërfløw the line length?  I sure hope thät ='s and \"'s are encoded properly.  Will they be?"
 
 
 check "${testname}.longsubject2.actual" "${testname}.longsubject2.expected" 'keep first'
 
 run_test 'eval fmttest -outsize max -format "%(putlit(decode(trim{subject})))" -message -file "${testname}.longsubject2.actual"' "This is ä tëst øf ä räthër løng sübjëct line; will it øvërfløw the line length?  I sure hope thät ='s and \"'s are encoded properly.  Will they be?"
 
-rm -f "${testname}.longsubject2.actual"
+rm -f "${testname}.longsubject2.actual" "${backupname}.longsubject2.actual.orig"
 
 #
 # Another long test, but make sure multibyte characters are not split across
 
 #
 # Another long test, but make sure multibyte characters are not split across
@@ -213,13 +216,13 @@ Content-Type: text/plain; charset="us-ascii"
 This is another long test.
 EOF
 
 This is another long test.
 EOF
 
-mhbuild "${testname}.longsubject3.actual"
+run_prog mhbuild "${testname}.longsubject3.actual"
 
 check "${testname}.longsubject3.actual" "${testname}.longsubject3.expected" 'keep first'
 
 run_test 'eval fmttest -outsize max -format "%(putlit(decode(trim{subject})))" -message -file "${testname}.longsubject3.actual"' "This is a test of a big UTF-8 multibyte character (😉); will this work properly, or will it get truncated? 😨! Hopefully not"
 
 
 check "${testname}.longsubject3.actual" "${testname}.longsubject3.expected" 'keep first'
 
 run_test 'eval fmttest -outsize max -format "%(putlit(decode(trim{subject})))" -message -file "${testname}.longsubject3.actual"' "This is a test of a big UTF-8 multibyte character (😉); will this work properly, or will it get truncated? 😨! Hopefully not"
 
-rm -f "${testname}.longsubject3.actual"
+rm -f "${testname}.longsubject3.actual" "${backupname}.longsubject3.actual.orig"
 
 cat > "${testname}.longsubject4.actual" <<EOF
 From: Mr Foo Bar <foobar@example.com>
 
 cat > "${testname}.longsubject4.actual" <<EOF
 From: Mr Foo Bar <foobar@example.com>
@@ -243,13 +246,13 @@ Content-Type: text/plain; charset="us-ascii"
 This is another long test.
 EOF
 
 This is another long test.
 EOF
 
-mhbuild "${testname}.longsubject4.actual"
+run_prog mhbuild "${testname}.longsubject4.actual"
 
 check "${testname}.longsubject4.actual" "${testname}.longsubject4.expected" 'keep first'
 
 run_test 'eval fmttest -outsize max -format "%(putlit(decode(trim{subject})))" -message -file "${testname}.longsubject4.actual"' "This is ä tëst øf å big ÜTF-8 (😉) mültibyte character; will this wørk prøperly, ør will it get trµnᴬted? 😨! Hopefully nøt"
 
 
 check "${testname}.longsubject4.actual" "${testname}.longsubject4.expected" 'keep first'
 
 run_test 'eval fmttest -outsize max -format "%(putlit(decode(trim{subject})))" -message -file "${testname}.longsubject4.actual"' "This is ä tëst øf å big ÜTF-8 (😉) mültibyte character; will this wørk prøperly, ør will it get trµnᴬted? 😨! Hopefully nøt"
 
-rm -f "${testname}.longsubject4.actual"
+rm -f "${testname}.longsubject4.actual" "${backupname}.longsubject4.actual.orig"
 
 #
 # Test out some basic email address encoding
 
 #
 # Test out some basic email address encoding
@@ -273,14 +276,14 @@ Content-Type: text/plain; charset="us-ascii"
 This is important information
 EOF
 
 This is important information
 EOF
 
-mhbuild "${testname}.basicemail1.actual"
+run_prog mhbuild "${testname}.basicemail1.actual"
 
 check "${testname}.basicemail1.actual" "${testname}.basicemail1.expected" 'keep first'
 
 run_test 'eval fmttest -outsize max -format "%(decode{from})" -message -file "${testname}.basicemail1.actual"' "Mr Foo Bär <foobar@example.com>"
 run_test 'eval fmttest -outsize max -format "%(decode(friendly{from}))" -message -file "${testname}.basicemail1.actual"' "Mr Foo Bär"
 
 
 check "${testname}.basicemail1.actual" "${testname}.basicemail1.expected" 'keep first'
 
 run_test 'eval fmttest -outsize max -format "%(decode{from})" -message -file "${testname}.basicemail1.actual"' "Mr Foo Bär <foobar@example.com>"
 run_test 'eval fmttest -outsize max -format "%(decode(friendly{from}))" -message -file "${testname}.basicemail1.actual"' "Mr Foo Bär"
 
-rm -f "${testname}.basicemail1.actual"
+rm -f "${testname}.basicemail1.actual" "${backupname}.basicemail1.actual.orig"
 
 cat > "${testname}.basicemail2.actual" <<EOF
 From: foobar@example.com (Mr Foo Bär)
 
 cat > "${testname}.basicemail2.actual" <<EOF
 From: foobar@example.com (Mr Foo Bär)
@@ -300,14 +303,14 @@ Content-Type: text/plain; charset="us-ascii"
 This is important information
 EOF
 
 This is important information
 EOF
 
-mhbuild "${testname}.basicemail2.actual"
+run_prog mhbuild "${testname}.basicemail2.actual"
 
 check "${testname}.basicemail2.actual" "${testname}.basicemail2.expected" 'keep first'
 
 run_test 'eval fmttest -outsize max -format "%(decode{from})" -message -file "${testname}.basicemail2.actual"' "foobar@example.com (Mr Foo Bär)"
 run_test 'eval fmttest -outsize max -format "%(decode(friendly{from}))" -message -file "${testname}.basicemail2.actual"' "Mr Foo Bär"
 
 
 check "${testname}.basicemail2.actual" "${testname}.basicemail2.expected" 'keep first'
 
 run_test 'eval fmttest -outsize max -format "%(decode{from})" -message -file "${testname}.basicemail2.actual"' "foobar@example.com (Mr Foo Bär)"
 run_test 'eval fmttest -outsize max -format "%(decode(friendly{from}))" -message -file "${testname}.basicemail2.actual"' "Mr Foo Bär"
 
-rm -f "${testname}.basicemail2.actual"
+rm -f "${testname}.basicemail2.actual" "${backupname}.basicemail2.actual.orig"
 
 #
 # Make sure the base64 encoder is tested as well
 
 #
 # Make sure the base64 encoder is tested as well
@@ -331,14 +334,14 @@ Content-Type: text/plain; charset="us-ascii"
 This is important information
 EOF
 
 This is important information
 EOF
 
-mhbuild "${testname}.basicemail3.actual"
+run_prog mhbuild "${testname}.basicemail3.actual"
 
 check "${testname}.basicemail3.actual" "${testname}.basicemail3.expected" 'keep first'
 
 run_test 'eval fmttest -outsize max -format "%(decode{from})" -message -file "${testname}.basicemail3.actual"' "Mr Føø Bär <foobar@example.com>"
 run_test 'eval fmttest -outsize max -format "%(decode(friendly{from}))" -message -file "${testname}.basicemail3.actual"' "Mr Føø Bär"
 
 
 check "${testname}.basicemail3.actual" "${testname}.basicemail3.expected" 'keep first'
 
 run_test 'eval fmttest -outsize max -format "%(decode{from})" -message -file "${testname}.basicemail3.actual"' "Mr Føø Bär <foobar@example.com>"
 run_test 'eval fmttest -outsize max -format "%(decode(friendly{from}))" -message -file "${testname}.basicemail3.actual"' "Mr Føø Bär"
 
-rm -f "${testname}.basicemail3.actual"
+rm -f "${testname}.basicemail3.actual" "${backupname}.basicemail3.actual.orig"
 
 cat > "${testname}.basicemail4.actual" <<EOF
 From: foobar@example.com (Mr Føø Bär)
 
 cat > "${testname}.basicemail4.actual" <<EOF
 From: foobar@example.com (Mr Føø Bär)
@@ -358,14 +361,14 @@ Content-Type: text/plain; charset="us-ascii"
 This is important information
 EOF
 
 This is important information
 EOF
 
-mhbuild "${testname}.basicemail4.actual"
+run_prog mhbuild "${testname}.basicemail4.actual"
 
 check "${testname}.basicemail4.actual" "${testname}.basicemail4.expected" 'keep first'
 
 run_test 'eval fmttest -outsize max -format "%(decode{from})" -message -file "${testname}.basicemail4.actual"' "foobar@example.com (Mr Føø Bär)"
 run_test 'eval fmttest -outsize max -format "%(decode(friendly{from}))" -message -file "${testname}.basicemail4.actual"' "Mr Føø Bär"
 
 
 check "${testname}.basicemail4.actual" "${testname}.basicemail4.expected" 'keep first'
 
 run_test 'eval fmttest -outsize max -format "%(decode{from})" -message -file "${testname}.basicemail4.actual"' "foobar@example.com (Mr Føø Bär)"
 run_test 'eval fmttest -outsize max -format "%(decode(friendly{from}))" -message -file "${testname}.basicemail4.actual"' "Mr Føø Bär"
 
-rm -f "${testname}.basicemail4.actual"
+rm -f "${testname}.basicemail4.actual" "${backupname}.basicemail4.actual.orig"
 
 #
 # A more complicated header; it includes groups, addresses that require
 
 #
 # A more complicated header; it includes groups, addresses that require
@@ -401,13 +404,13 @@ Content-Type: text/plain; charset="us-ascii"
 This is a lot of people on this email!
 EOF
 
 This is a lot of people on this email!
 EOF
 
-mhbuild "${testname}.complexemail1.actual"
+run_prog mhbuild "${testname}.complexemail1.actual"
 
 check "${testname}.complexemail1.actual" "${testname}.complexemail1.expected" 'keep first'
 
 run_test 'eval fmttest -outsize max -format "%(decode{to})" -message -file "${testname}.complexemail1.actual"' "\"Mr F. One\" <foo1@example.com>, Mr F. Twø <foo2@example.com>, foo list: Føø Thrëë <foo3@example.com>, Foo Four <foo4@example.com>, Foo Fivë <foo5@example.com>;, Føø Sîx <foo6@example.com>, \"Mr F. Seven\" <foo7@example.com>"
 run_test 'eval fmttest -outsize max -format "%(decode{cc})" -message -file "${testname}.complexemail1.actual"' "The Distingµishëd F. Sëvën <foo7@example.com>"
 
 
 check "${testname}.complexemail1.actual" "${testname}.complexemail1.expected" 'keep first'
 
 run_test 'eval fmttest -outsize max -format "%(decode{to})" -message -file "${testname}.complexemail1.actual"' "\"Mr F. One\" <foo1@example.com>, Mr F. Twø <foo2@example.com>, foo list: Føø Thrëë <foo3@example.com>, Foo Four <foo4@example.com>, Foo Fivë <foo5@example.com>;, Føø Sîx <foo6@example.com>, \"Mr F. Seven\" <foo7@example.com>"
 run_test 'eval fmttest -outsize max -format "%(decode{cc})" -message -file "${testname}.complexemail1.actual"' "The Distingµishëd F. Sëvën <foo7@example.com>"
 
-rm -f "${testname}.complexemail1.actual"
+rm -f "${testname}.complexemail1.actual" "${backupname}.complexemail1.actual.orig"
 
 exit ${failed:-0}
 
 exit ${failed:-0}