-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjmbg_test.go
56 lines (49 loc) · 951 Bytes
/
jmbg_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
47
48
49
50
51
52
53
54
55
56
package jmbg
import (
"testing"
"time"
"github.com/dusnm/jmbg/checksum"
"github.com/dusnm/jmbg/region"
"github.com/dusnm/jmbg/sex"
"github.com/stretchr/testify/require"
)
func TestShouldParseJmbg(t *testing.T) {
t.Parallel()
// arrange
assert := require.New(t)
number := "0101000805018"
expected := JMBG{
Number: number,
Digits: [13]uint{0, 1, 0, 1, 0, 0, 0, 8, 0, 5, 0, 1, 8},
DateOfBirth: func() time.Time {
value, _ := time.Parse(
"01-02-2006",
"01-01-2000",
)
return value
}(),
Region: region.Region{
Code: region.NSD,
Name: region.Name{
Cyrillic: "Нови Сад",
Latin: "Novi Sad",
},
},
Sex: sex.Sex{
Code: sex.FEMALE,
Name: sex.Name{
Cyrillic: "женски",
Latin: "ženski",
},
},
Checksum: checksum.Checksum{
Value: 8,
Valid: true,
},
}
// act
jmbg, err := New(number)
// assert
assert.NoError(err)
assert.Equal(expected, jmbg)
}