forked from ziutek/gogammu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgammu_test.go
50 lines (44 loc) · 972 Bytes
/
gammu_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
package gammu
import (
"flag"
"fmt"
"io"
"os"
"testing"
)
var number string
func init() {
flag.StringVar(&number, "n", "", "phone number (required)")
flag.Parse()
if number == "" {
flag.Usage()
os.Exit(1)
}
}
func checkErr(t *testing.T, e error) {
if e != nil {
t.Fatal(e)
}
}
func TestSend(t *testing.T) {
sm, err := NewStateMachine("")
checkErr(t, err)
checkErr(t, sm.Connect())
checkErr(t, sm.SendSMS(number, "Test1 ąśćźż", true))
checkErr(t, sm.SendLongSMS(number, "Test2 'ąśćźż' The Go programming language is an open source project to make programmers more productive. Go is expressive, concise, clean, and efficient.", true))
checkErr(t, sm.Disconnect())
}
func TestGet(t *testing.T) {
sm, err := NewStateMachine("")
checkErr(t, err)
checkErr(t, sm.Connect())
for {
sms, err := sm.GetSMS()
if err == io.EOF {
break
}
checkErr(t, err)
fmt.Printf("received SMS: %+v\n", sms)
}
checkErr(t, sm.Disconnect())
}