-
Notifications
You must be signed in to change notification settings - Fork 7
/
encoding_gsm0338_test.go
55 lines (47 loc) · 1.12 KB
/
encoding_gsm0338_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
package gostrutils
import (
"testing"
)
const helloWorld = "Hello World"
const null = "\x00"
func TestUTF8ToGsm0338Valid(t *testing.T) {
gsm := UTF8ToGsm0338(helloWorld)
if gsm != "Hello World" {
t.Errorf("Invalid gsm content: '%s', expected 'Hello World'", gsm)
}
}
func TestUTF8ToGsm0338Valid2(t *testing.T) {
s := "@"
gsm := UTF8ToGsm0338(s)
if gsm != null {
t.Errorf("Invalid gsm, expected NULL, got: %s", gsm)
}
}
func TestUTF8ToGsm0338Invalid(t *testing.T) {
s := "$"
gsm := UTF8ToGsm0338(s)
if gsm == "$" {
t.Errorf("Invalid gsm conversion, expected '\x22', got '%s' ", gsm)
}
}
func TestGSM0338ToUTF8Valid(t *testing.T) {
gsm := UTF8ToGsm0338(helloWorld)
utf8 := GSM0338ToUTF8(gsm)
if utf8 != helloWorld {
t.Errorf("Invalid utf8: '%s'", utf8)
}
}
func TestGSM0338ToUTF8Valid2(t *testing.T) {
gsm := UTF8ToGsm0338("$")
utf8 := GSM0338ToUTF8(gsm)
if utf8 != "$" {
t.Errorf("Invalid utf8, expected '$', got '%+s', gsm: '%s'", utf8, gsm)
}
}
func TestGSM0338ToUTF8Invalid(t *testing.T) {
gsm := null
utf8 := GSM0338ToUTF8(gsm)
if utf8 == null {
t.Errorf("Invalid utf8, expected '@' got %s", utf8)
}
}