~samwhited/xmpp

63e21c13d6c7046cf7ee155cf55acfddf38b6c8e — Sam Whited 5 years ago 8fb8d7d
Add compile time regression tests
2 files changed, 8 insertions(+), 3 deletions(-)

M jid/safejid_test.go
M jid/unsafejid_test.go
M jid/safejid_test.go => jid/safejid_test.go +3 -0
@@ 8,6 8,9 @@ import (
	"testing"
)

// Compile time check ot make sure that SafeJID is a JID
var _ JID = (*SafeJID)(nil)

// SafeJID's cannot contain invalid UTF8 in the localpart.
func TestNewInvalidUtf8Localpart(t *testing.T) {
	invalid := string([]byte{0xff, 0xfe, 0xfd})

M jid/unsafejid_test.go => jid/unsafejid_test.go +5 -3
@@ 10,9 10,12 @@ import (
	"testing"
)

// Compile time check ot make sure that UnsafeJID is a JID
var _ JID = (*UnsafeJID)(nil)

// Ensure that JID parts are split properly.
func TestValidPartsFromString(t *testing.T) {
	decompositions := [][]string{
	for _, d := range [][]string{
		{"lp@dp/rp", "lp", "dp", "rp"},
		{"dp/rp", "", "dp", "rp"},
		{"dp", "", "dp", ""},


@@ 25,8 28,7 @@ func TestValidPartsFromString(t *testing.T) {
		{"dp/@rp/", "", "dp", "@rp/"},
		{"dp/lp@dp/rp", "", "dp", "lp@dp/rp"},
		{"₩", "", "₩", ""},
	}
	for _, d := range decompositions {
	} {
		lp, dp, rp, err := SplitString(d[0])
		if err != nil || lp != d[1] || dp != d[2] || rp != d[3] {
			t.FailNow()