-
Notifications
You must be signed in to change notification settings - Fork 7
/
cns_test.go
46 lines (38 loc) · 1.38 KB
/
cns_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package brdocs_test
import (
"github.com/brazanation/go-documents"
"github.com/brazanation/go-documents/internal/test"
"testing"
)
func TestCnsPermanentShouldBeValid(t *testing.T) {
doc, err := brdocs.NewCns("242912018460005")
internal_test.AssertValidDocument(t, doc, err)
}
func TestCnsTemporaryShouldBeValid(t *testing.T) {
doc, err := brdocs.NewCns("742912018460004")
internal_test.AssertValidDocument(t, doc, err)
}
func TestCnsShouldBeSameType(t *testing.T) {
doc, _ := brdocs.NewCns("242912018460005")
internal_test.AssertDocumentType(t, doc, brdocs.CnsType)
}
func TestCnsShouldBeFormatted(t *testing.T) {
doc, err := brdocs.NewCns("242912018460005")
internal_test.AssertValidDocument(t, doc, err)
internal_test.AssertDocumentFormatted(t, doc, "242 9120 1846 0005")
}
func TestCnsShouldReturnErrorForRepeatedNumber(t *testing.T) {
number := "111111111111111"
_, err := brdocs.NewCns(number)
internal_test.AssertNotValidDocument(t, number, err, "Cns(111111111111111) is invalid")
}
func TestCnsShouldReturnErrorForInvalidNumber(t *testing.T) {
number := "861238979874098"
_, err := brdocs.NewCns(number)
internal_test.AssertNotValidDocument(t, number, err, "Cns(861238979874098) is invalid")
}
func TestCnsShouldReturnErrorForEmptyNumber(t *testing.T) {
number := ``
_, err := brdocs.NewCns(number)
internal_test.AssertNotValidDocument(t, number, err, "Cns must not be empty")
}