/
imcg_test.go
56 lines (46 loc) · 1.38 KB
/
imcg_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 imcg
import (
"testing"
)
func TestGetMobileNumberData(t *testing.T) {
input1 := "9711889900" // Valid input.
input2 := "9818998866" // Valid input.
input3 := "8813823345" // Valid input.
input4 := "+919711889900" // Valid input.
input5 := "919711889900" // Valid input.
input6 := "8999887788" // Data does not exist.
input7 := "99887766" // Improper length.
input8 := "819711889900" // Improper prefix.
res := GetMobileNumberData(input1)
if res[0] != "VODAFONE" && res[1] != "DELHI" {
t.Error("Expected [VODAFONE,DELHI], Got ", res)
}
res = GetMobileNumberData(input2)
if res[0] != "AIRTEL" && res[1] != "DELHI" {
t.Error("Expected [AIRTEL,DELHI], Got ", res)
}
res = GetMobileNumberData(input3)
if res[0] != "VODAFONE" && res[1] != "HARYANA" {
t.Error("Expected [VODAFONE,HARYANA], Got ", res)
}
res = GetMobileNumberData(input4)
if res[0] != "VODAFONE" && res[1] != "DELHI" {
t.Error("Expected [VODAFONE,DELHI], Got ", res)
}
res = GetMobileNumberData(input5)
if res[0] != "VODAFONE" && res[1] != "DELHI" {
t.Error("Expected [VODAFONE,DELHI], Got ", res)
}
res = GetMobileNumberData(input6)
if res != nil {
t.Error("Expected nil, Got ", res)
}
res = GetMobileNumberData(input7)
if res != nil {
t.Error("Expected nil, Got ", res)
}
res = GetMobileNumberData(input8)
if res != nil {
t.Error("Expected nil, Got ", res)
}
}