From fe3e1629a6c2eb6949c6882bc269f9cda87b4e5b Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Sun, 14 Jan 2018 21:38:41 +0100 Subject: t/1501-maddr-regress.t: add regression tests for address parsing --- t/1501-maddr-regress.t | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 t/1501-maddr-regress.t (limited to 't') diff --git a/t/1501-maddr-regress.t b/t/1501-maddr-regress.t new file mode 100755 index 0000000..ee1da50 --- /dev/null +++ b/t/1501-maddr-regress.t @@ -0,0 +1,42 @@ +#!/bin/sh +cd ${0%/*} +. ./lib.sh +plan 26 + +check_addr() { + printf "From: %s\n" "$1" | check_test "parse $1" = "$2" "maddr /dev/stdin" +} + +check_addr 'foo@example.org' 'foo@example.org' +check_addr '' 'foo@example.org' +check_addr 'bar ' 'bar ' +check_addr 'bar quux ' 'bar quux ' +check_addr 'bar quux ' 'bar quux ' +check_addr ' (bar)' 'bar ' +check_addr '"Real Name" ' 'Real Name ' +check_addr '"Dr. Real Name" ' 'Dr. Real Name ' +check_addr '"Real Name" (show this) ' 'Real Name (show this) ' +check_addr '"Real Name" (ignore this)' 'Real Name (ignore this) ' + +check_addr '(nested (comments mail@here ) heh) "yep (yap)" ' 'yep (yap) ' + +check_addr 'ignore-this: ' 'foo@example.org' +check_addr 'ignore-this : ' 'foo@example.org' +check_addr '"foo"@example.org' 'foo@example.org' +check_addr '"Barqux" "foo"@example.org' 'Barqux ' +check_addr 'Space Man <"space man"@example.org>' 'Space Man <"space man"@example.org>' +check_addr 'Space Man <"space man"@example.org>' 'Space Man <"space man"@example.org>' +check_addr '' 'spaceman@example.org' +check_addr '< spaceman@example.org >' 'spaceman@example.org' +check_addr '' 'spaceman@example.org' +check_addr 'space\man@example.org' 'spaceman@example.org' + +check_addr 'what is <"thisit"@example.org>' 'what is <"thisit"@example.org>' + +check_addr 'foo@example.org ' 'foo@example.org' + +check_addr 'foo@[::1] (ipv6)' 'ipv6 ' + +# invalid addresses +check_addr '' 'foobar@qux.com' +check_addr '"abc@def"@ghi' '' \ No newline at end of file -- cgit 1.4.1