1
1
package suci
2
2
3
- import "testing"
3
+ import (
4
+ "fmt"
5
+ "testing"
6
+ )
4
7
5
8
func TestToSupi (t * testing.T ) {
6
9
suciProfiles := []SuciProfile {
@@ -17,30 +20,42 @@ func TestToSupi(t *testing.T) {
17
20
},
18
21
}
19
22
testCases := []struct {
20
- suci string
21
- expected string
23
+ suci string
24
+ expectedSupi string
25
+ expectedErr error
22
26
}{
23
27
{
24
- suci : "suci-0-208-93-0-0-0-00007487" ,
25
- expected : "imsi-2089300007487" ,
28
+ suci : "suci-0-208-93-0-0-0-00007487" ,
29
+ expectedSupi : "imsi-2089300007487" ,
30
+ expectedErr : nil ,
26
31
},
27
32
{
28
33
suci : "suci-0-208-93-0-1-1-b2e92f836055a255837debf850b528997ce0201cb82a" +
29
34
"dfe4be1f587d07d8457dcb02352410cddd9e730ef3fa87" ,
30
- expected : "imsi-20893001002086" ,
35
+ expectedSupi : "imsi-20893001002086" ,
36
+ expectedErr : nil ,
31
37
},
32
38
{
33
39
suci : "suci-0-208-93-0-2-2-039aab8376597021e855679a9778ea0b67396e68c66d" +
34
40
"f32c0f41e9acca2da9b9d146a33fc2716ac7dae96aa30a4d" ,
35
- expected : "imsi-20893001002086" ,
41
+ expectedSupi : "imsi-20893001002086" ,
42
+ expectedErr : nil ,
43
+ },
44
+ {
45
+ suci : "suci-0-208-93-0-2-2-0434a66778799d52fedd9326db4b690d092e05c9ba0ace5b413da" +
46
+ "fc0a40aa28ee00a79f790fa4da6a2ece892423adb130dc1b30e270b7d0088bdd716b93894891d5221a74c810d6b9350cc067c76" ,
47
+ expectedSupi : "" ,
48
+ expectedErr : fmt .Errorf ("crypto/elliptic: attempted operation on invalid point" ),
36
49
},
37
50
}
38
51
for i , tc := range testCases {
39
52
supi , err := ToSupi (tc .suci , suciProfiles )
40
53
if err != nil {
41
- t .Errorf ("TC%d err: %+v\n " , i , err )
42
- } else if supi != tc .expected {
43
- t .Errorf ("TC%d fail: supi[%s], expected[%s]\n " , i , supi , tc .expected )
54
+ if err .Error () != tc .expectedErr .Error () {
55
+ t .Errorf ("TC%d fail: err[%s], expected[%s]\n " , i , err , tc .expectedErr )
56
+ }
57
+ } else if supi != tc .expectedSupi {
58
+ t .Errorf ("TC%d fail: supi[%s], expected[%s]\n " , i , supi , tc .expectedSupi )
44
59
}
45
60
}
46
61
}
0 commit comments