-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathobject_test.go
42 lines (33 loc) · 1.08 KB
/
object_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
// Copyright 2014 SteelSeries ApS. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This package implements a basic LISP interpretor for embedding in a go program for scripting.
// This file tests the Object data type.
package golisp
import (
. "gopkg.in/check.v1"
"unsafe"
)
type ObjectAtomSuite struct {
o *Data
}
var _ = Suite(&ObjectAtomSuite{})
type TestStruct struct {
D int
}
func (s *ObjectAtomSuite) TestObject(c *C) {
obj := &TestStruct{D: 5}
s.o = ObjectWithTypeAndValue("TestStruct", unsafe.Pointer(obj))
c.Assert(ObjectType(s.o), Equals, "TestStruct")
c.Assert((*TestStruct)(ObjectValue(s.o)), Equals, obj)
c.Assert((*TestStruct)(ObjectValue(s.o)).D, Equals, 5)
}
func (s *ObjectAtomSuite) TestObjectForNil(c *C) {
c.Assert(ObjectValue(nil), Equals, unsafe.Pointer(nil))
c.Assert(ObjectType(nil), Equals, "")
}
func (s *ObjectAtomSuite) TestObjectForNonObject(c *C) {
o := IntegerWithValue(0)
c.Assert(ObjectValue(o), Equals, unsafe.Pointer(nil))
c.Assert(ObjectType(o), Equals, "")
}