Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
6a13cea6
Commit
6a13cea6
authored
Jan 10, 2011
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rbtree: vary insert and delete orders in test
This covers more code than simply doing an ordered delete/insert.
parent
c520b4ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
10 deletions
+22
-10
ccan/rbtree/test/run-many.c
ccan/rbtree/test/run-many.c
+22
-10
No files found.
ccan/rbtree/test/run-many.c
View file @
6a13cea6
...
...
@@ -24,20 +24,27 @@ static bool lookup_all(trbt_tree_t *rb, bool exist)
return
true
;
}
static
bool
add_one
(
trbt_tree_t
*
rb
,
bool
exist
,
unsigned
int
i
)
{
int
*
p
=
trbt_insert32
(
rb
,
i
,
talloc_memdup
(
rb
,
&
i
,
sizeof
(
i
)));
if
(
p
)
{
if
(
!
exist
)
return
false
;
if
(
*
p
!=
i
)
return
false
;
}
else
if
(
exist
)
return
false
;
return
true
;
}
static
bool
insert_all
(
trbt_tree_t
*
rb
,
bool
exist
)
{
unsigned
int
i
;
for
(
i
=
0
;
i
<
NUM_ELEMS
;
i
++
)
{
int
*
p
=
trbt_insert32
(
rb
,
i
,
talloc_memdup
(
rb
,
&
i
,
sizeof
(
i
)));
if
(
p
)
{
if
(
!
exist
)
return
false
;
if
(
*
p
!=
i
)
return
false
;
}
else
if
(
exist
)
return
false
;
if
(
!
add_one
(
rb
,
exist
,
i
))
return
false
;
}
return
true
;
}
...
...
@@ -46,7 +53,12 @@ static void delete_all(trbt_tree_t *rb)
{
unsigned
int
i
;
for
(
i
=
0
;
i
<
NUM_ELEMS
;
i
++
)
{
/* Don't delete them in the obvious order. */
for
(
i
=
0
;
i
<
NUM_ELEMS
/
2
;
i
++
)
{
trbt_delete32
(
rb
,
i
);
}
for
(
i
=
NUM_ELEMS
-
1
;
i
>=
NUM_ELEMS
/
2
;
i
--
)
{
trbt_delete32
(
rb
,
i
);
}
}
...
...
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