#!/bin/sh cd ${0%/*} . ./lib.sh plan 33 check_addr() { printf "From: %s\n" "$1" | check_test "parse $1" = "$2" "maddr -" } 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' '' check_addr '"foo@" ' '"foo@" ' check_addr 'test."test"@example.org' 'test.test@example.org' check_addr '' 'test.test@example.org' check_addr 'test"test"@example.org' 'testtest@example.org' check_addr '' 'testtest@example.org' check_addr 'foo' 'foo ' check_addr 'xxxxxxxxx a"test"@example.org' "xxxxxxxxx "