package domain64 import ( "testing" ) // https://gobyexample.com/testing-and-benchmarking // For testing the conversion between a Domain64 struct // and the int64 representation of that domain. var tests = []struct { d64 Domain64 asInt int64 }{ { Domain64{ TLD: 1, Domain: 1, Subdomain: 1, Path: 1, }, 72057598349672449}, { Domain64{ TLD: 2, Domain: 1, Subdomain: 1, Path: 0, }, 144115192387600384}, } func TestDomain64ToInt(t *testing.T) { for _, tt := range tests { if tt.d64.ToInt64() != tt.asInt { t.Errorf("%q != %d Domain64 did not convert", tt.d64, tt.asInt) } } } func TestIntToDomain64(t *testing.T) { for _, tt := range tests { if IntToDomain64(tt.asInt) != tt.d64 { t.Errorf("%d != %q int64 did not convert", tt.asInt, tt.d64) } } }