Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
9195c22e
Commit
9195c22e
authored
Nov 19, 2008
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use new test framework in array test
R=r DELTA=30 (2 added, 5 deleted, 23 changed) OCL=19627 CL=19632
parent
bef9b171
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
28 deletions
+25
-28
src/lib/container/array/testarray.go
src/lib/container/array/testarray.go
+25
-28
No files found.
src/lib/container/array/testarray.go
View file @
9195c22e
...
...
@@ -5,21 +5,21 @@
package
array
import
"array"
import
"testing"
import
"sort"
export
func
TestInit
(
)
bool
{
export
func
TestInit
(
t
*
testing
.
T
)
{
var
a
array
.
Array
;
if
a
.
Init
(
0
)
.
Len
()
!=
0
{
return
false
}
if
a
.
Init
(
1
)
.
Len
()
!=
1
{
return
false
}
if
a
.
Init
(
10
)
.
Len
()
!=
10
{
return
false
}
return
true
;
if
a
.
Init
(
0
)
.
Len
()
!=
0
{
t
.
FailNow
()
}
if
a
.
Init
(
1
)
.
Len
()
!=
1
{
t
.
FailNow
()
}
if
a
.
Init
(
10
)
.
Len
()
!=
10
{
t
.
FailNow
()
}
}
export
func
TestNew
()
bool
{
if
array
.
New
(
0
)
.
Len
()
!=
0
{
return
false
}
if
array
.
New
(
1
)
.
Len
()
!=
1
{
return
false
}
if
array
.
New
(
10
)
.
Len
()
!=
10
{
return
false
}
return
true
;
export
func
TestNew
(
t
*
testing
.
T
)
{
if
array
.
New
(
0
)
.
Len
()
!=
0
{
t
.
FailNow
()
}
if
array
.
New
(
1
)
.
Len
()
!=
1
{
t
.
FailNow
()
}
if
array
.
New
(
10
)
.
Len
()
!=
10
{
t
.
FailNow
()
}
}
...
...
@@ -28,7 +28,7 @@ export func Val(i int) int {
}
export
func
TestAccess
(
)
bool
{
export
func
TestAccess
(
t
*
testing
.
T
)
{
const
n
=
100
;
var
a
array
.
Array
;
a
.
Init
(
n
);
...
...
@@ -36,35 +36,34 @@ export func TestAccess() bool {
a
.
Set
(
i
,
Val
(
i
));
}
for
i
:=
0
;
i
<
n
;
i
++
{
if
a
.
At
(
i
)
.
(
int
)
!=
Val
(
i
)
{
return
false
}
if
a
.
At
(
i
)
.
(
int
)
!=
Val
(
i
)
{
t
.
FailNow
()
}
}
return
true
;
}
export
func
TestInsertRemoveClear
(
)
bool
{
export
func
TestInsertRemoveClear
(
t
*
testing
.
T
)
{
const
n
=
100
;
a
:=
array
.
New
(
0
);
for
i
:=
0
;
i
<
n
;
i
++
{
if
a
.
Len
()
!=
i
{
return
false
}
if
a
.
Len
()
!=
i
{
t
.
FailNow
()
}
a
.
Insert
(
0
,
Val
(
i
));
if
a
.
Last
()
.
(
int
)
!=
Val
(
0
)
{
return
false
}
if
a
.
Last
()
.
(
int
)
!=
Val
(
0
)
{
t
.
FailNow
()
}
}
for
i
:=
n
-
1
;
i
>=
0
;
i
--
{
if
a
.
Last
()
.
(
int
)
!=
Val
(
0
)
{
return
false
}
if
a
.
Remove
(
0
)
.
(
int
)
!=
Val
(
i
)
{
return
false
}
if
a
.
Len
()
!=
i
{
return
false
}
if
a
.
Last
()
.
(
int
)
!=
Val
(
0
)
{
t
.
FailNow
()
}
if
a
.
Remove
(
0
)
.
(
int
)
!=
Val
(
i
)
{
t
.
FailNow
()
}
if
a
.
Len
()
!=
i
{
t
.
FailNow
()
}
}
if
a
.
Len
()
!=
0
{
return
false
}
if
a
.
Len
()
!=
0
{
t
.
FailNow
()
}
for
i
:=
0
;
i
<
n
;
i
++
{
a
.
Push
(
Val
(
i
));
if
a
.
Len
()
!=
i
+
1
{
return
false
}
if
a
.
Last
()
.
(
int
)
!=
Val
(
i
)
{
return
false
}
if
a
.
Len
()
!=
i
+
1
{
t
.
FailNow
()
}
if
a
.
Last
()
.
(
int
)
!=
Val
(
i
)
{
t
.
FailNow
()
}
}
a
.
Init
(
0
);
if
a
.
Len
()
!=
0
{
return
false
}
if
a
.
Len
()
!=
0
{
t
.
FailNow
()
}
const
m
=
5
;
for
j
:=
0
;
j
<
m
;
j
++
{
...
...
@@ -72,11 +71,9 @@ export func TestInsertRemoveClear() bool {
for
i
:=
0
;
i
<
n
;
i
++
{
x
:=
Val
(
i
);
a
.
Push
(
x
);
if
a
.
Pop
()
.
(
int
)
!=
x
{
return
false
}
if
a
.
Len
()
!=
j
+
1
{
return
false
}
if
a
.
Pop
()
.
(
int
)
!=
x
{
t
.
FailNow
()
}
if
a
.
Len
()
!=
j
+
1
{
t
.
FailNow
()
}
}
}
if
a
.
Len
()
!=
m
{
return
false
}
return
true
;
if
a
.
Len
()
!=
m
{
t
.
FailNow
()
}
}
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