Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Core
Tor
Commits
7f9a33a8
Commit
7f9a33a8
authored
9 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Patches
Plain Diff
Bring the dimap tests up to 100%
parent
2691b2bb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/test_util.c
+45
-0
45 additions, 0 deletions
src/test/test_util.c
with
45 additions
and
0 deletions
src/test/test_util.c
+
45
−
0
View file @
7f9a33a8
...
...
@@ -3611,6 +3611,50 @@ test_util_di_ops(void *arg)
;
}
static
void
test_util_di_map
(
void
*
arg
)
{
(
void
)
arg
;
di_digest256_map_t
*
dimap
=
NULL
;
uint8_t
key1
[]
=
"Robert Anton Wilson "
;
uint8_t
key2
[]
=
"Martin Gardner, _Fads&fallacies"
;
uint8_t
key3
[]
=
"Tom Lehrer, _Be Prepared_. "
;
uint8_t
key4
[]
=
"Ursula Le Guin,_A Wizard of... "
;
char
dflt_entry
[]
=
"'You have made a good beginning', but no more"
;
tt_int_op
(
32
,
==
,
sizeof
(
key1
));
tt_int_op
(
32
,
==
,
sizeof
(
key2
));
tt_int_op
(
32
,
==
,
sizeof
(
key3
));
tt_ptr_op
(
dflt_entry
,
==
,
dimap_search
(
dimap
,
key1
,
dflt_entry
));
char
*
str1
=
tor_strdup
(
"You are precisely as big as what you love"
" and precisely as small as what you allow"
" to annoy you."
);
char
*
str2
=
tor_strdup
(
"Let us hope that Lysenko's success in Russia will"
" serve for many generations to come as another"
" reminder to the world of how quickly and easily"
" a science can be corrupted when ignorant"
" political leaders deem themselves competent"
" to arbitrate scientific disputes"
);
char
*
str3
=
tor_strdup
(
"Don't write naughty words on walls "
"if you can't spell."
);
dimap_add_entry
(
&
dimap
,
key1
,
str1
);
dimap_add_entry
(
&
dimap
,
key2
,
str2
);
dimap_add_entry
(
&
dimap
,
key3
,
str3
);
tt_ptr_op
(
str1
,
==
,
dimap_search
(
dimap
,
key1
,
dflt_entry
));
tt_ptr_op
(
str3
,
==
,
dimap_search
(
dimap
,
key3
,
dflt_entry
));
tt_ptr_op
(
str2
,
==
,
dimap_search
(
dimap
,
key2
,
dflt_entry
));
tt_ptr_op
(
dflt_entry
,
==
,
dimap_search
(
dimap
,
key4
,
dflt_entry
));
done:
dimap_free
(
dimap
,
tor_free_
);
}
/**
* Test counting high bits
*/
...
...
@@ -4395,6 +4439,7 @@ struct testcase_t util_tests[] = {
UTIL_LEGACY
(
path_is_relative
),
UTIL_LEGACY
(
strtok
),
UTIL_LEGACY
(
di_ops
),
UTIL_TEST
(
di_map
,
0
),
UTIL_TEST
(
round_to_next_multiple_of
,
0
),
UTIL_TEST
(
laplace
,
0
),
UTIL_TEST
(
find_str_at_start_of_line
,
0
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment