-
Notifications
You must be signed in to change notification settings - Fork 1
/
photon_test.go
54 lines (48 loc) · 940 Bytes
/
photon_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
package particle
import "testing"
func TestHasVariableSuccess(t *testing.T) {
var p Photon
h, _ := p.HasVariable("variable")
if h {
t.Error("HasVariable - failed")
}
}
func TestGetVariableFail(t *testing.T) {
var v Variable
v.Name = "pi"
v.Value = 3.14
var p Photon
p.SetVariable(&v)
vv := p.GetVariable("var")
if vv != nil {
t.Error("GetVariable - failed")
}
}
func TestSetAndGetVariableSuccess(t *testing.T) {
var v Variable
v.Name = "pi"
v.Value = 3.14
var p Photon
p.SetVariable(&v)
h, i := p.HasVariable("pi")
if !h {
t.Error("HasVariable")
}
if i != 0 {
t.Error("HasVariable - get index failed")
}
vv := p.GetVariable("pi")
if vv.Name != "pi" {
t.Error("GetVariable - get name failed")
}
if vv.Value != 3.14 {
t.Error("GetVariable - get value failed")
}
}
func TestHasFunction(t *testing.T) {
var p Photon
h, _ := p.HasFunction("SayHello")
if h {
t.Error("HasFunction - failed")
}
}