Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
1f4f1e99
Commit
1f4f1e99
authored
Feb 20, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go/zodb: persistent tests: Factor checkObj out of TestPersistent
We are going to use this function in other tests too.
parent
8b93cb5e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
38 deletions
+50
-38
go/zodb/persistent_test.go
go/zodb/persistent_test.go
+50
-38
No files found.
go/zodb/persistent_test.go
View file @
1f4f1e99
...
@@ -66,11 +66,10 @@ func init() {
...
@@ -66,11 +66,10 @@ func init() {
RegisterClassAlias
(
"t.zodb.MyOldObject"
,
"t.zodb.MyObject"
)
RegisterClassAlias
(
"t.zodb.MyOldObject"
,
"t.zodb.MyObject"
)
}
}
func
TestPersistent
(
t
*
testing
.
T
)
{
// checkObj verifies current state of persistent object.
assert
:=
require
.
New
(
t
)
//
// one can bind checkObj to t via tCheckObj.
// checkObj verifies current state of persistent object.
func
checkObj
(
t
testing
.
TB
,
obj
IPersistent
,
jar
*
Connection
,
oid
Oid
,
serial
Tid
,
state
ObjectState
,
refcnt
int32
)
{
checkObj
:=
func
(
obj
IPersistent
,
jar
*
Connection
,
oid
Oid
,
serial
Tid
,
state
ObjectState
,
refcnt
int32
)
{
t
.
Helper
()
t
.
Helper
()
xbase
:=
reflect
.
ValueOf
(
obj
)
.
Elem
()
.
FieldByName
(
"Persistent"
)
xbase
:=
reflect
.
ValueOf
(
obj
)
.
Elem
()
.
FieldByName
(
"Persistent"
)
pbase
:=
xbase
.
Addr
()
.
Interface
()
.
(
*
Persistent
)
pbase
:=
xbase
.
Addr
()
.
Interface
()
.
(
*
Persistent
)
...
@@ -106,7 +105,20 @@ func TestPersistent(t *testing.T) {
...
@@ -106,7 +105,20 @@ func TestPersistent(t *testing.T) {
if
pbase
.
instance
!=
obj
{
if
pbase
.
instance
!=
obj
{
badf
(
"base.instance != obj"
)
badf
(
"base.instance != obj"
)
}
}
}
// tCheckObj binds checkObj to t.
func
tCheckObj
(
t
testing
.
TB
)
func
(
IPersistent
,
*
Connection
,
Oid
,
Tid
,
ObjectState
,
int32
)
{
return
func
(
obj
IPersistent
,
jar
*
Connection
,
oid
Oid
,
serial
Tid
,
state
ObjectState
,
refcnt
int32
)
{
t
.
Helper
()
checkObj
(
t
,
obj
,
jar
,
oid
,
serial
,
state
,
refcnt
)
}
}
}
func
TestPersistent
(
t
*
testing
.
T
)
{
assert
:=
require
.
New
(
t
)
checkObj
:=
tCheckObj
(
t
)
// unknown type -> Broken
// unknown type -> Broken
xobj
:=
newGhost
(
"t.unknown"
,
10
,
nil
)
xobj
:=
newGhost
(
"t.unknown"
,
10
,
nil
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment