-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstructs_test.go
50 lines (41 loc) · 1.48 KB
/
structs_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 libknot
import (
"testing"
)
// TestDataToFromCtlEmpty makes sure that the consistency of the data between the C and Go structures remains good with nil values
func TestDataToFromCtlEmpty(t *testing.T) {
testData := KnotCtlData{}
t.Log("KnotCtlData.ToCtl() : Converting testData (type KnotCtlData) to testCtl (type C.knot_ctl_data_t)")
testCtl := testData.ToCtl()
t.Log("KnotCtlData.FromCtl(<testCtl>) : Converting testCtl (type C.knot_ctl_data_t) to testStruct (type KnotCtlData)")
var dataStruct KnotCtlData
dataStruct.FromCtl(testCtl)
if dataStruct != testData {
t.Errorf("Excepted %s from testData, got %s", testData, dataStruct)
}
}
// TestDataToFromCtlEmpty makes sure that the consistency of the data between the C and Go structures remains good with non empty values
func TestDataToFromCtl(t *testing.T) {
testData := KnotCtlData{
Command: "cmd",
Flags: "flags",
Error: "err",
Section: "sec",
Item: "item",
Id: "id",
Zone: "zone",
Owner: "own",
Ttl: "ttl",
Type: "type",
Data: "data",
Filter: "filter",
}
t.Log("KnotCtlData.ToCtl() : Converting testData (type KnotCtlData) to testCtl (type C.knot_ctl_data_t)")
testCtl := testData.ToCtl()
t.Log("KnotCtlData.FromCtl(<testCtl>) : Converting testCtl (type C.knot_ctl_data_t) to testStruct (type KnotCtlData)")
var dataStruct KnotCtlData
dataStruct.FromCtl(testCtl)
if dataStruct != testData {
t.Errorf("Excepted %s from testData, got %s", testData, dataStruct)
}
}