Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cmp_tool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dominik Loidolt
cmp_tool
Commits
bba15752
"free_forecast.py" did not exist on "24ab1e48075cfcbe334207eabfcf545818547359"
Commit
bba15752
authored
2 years ago
by
Dominik Loidolt
Browse files
Options
Downloads
Patches
Plain Diff
generalize rand() function
parent
8ba76f75
No related branches found
No related tags found
1 merge request
!11
decompression/compression for non-imagette data
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/cmp_icu/test_decmp.c
+30
-5
30 additions, 5 deletions
test/cmp_icu/test_decmp.c
with
30 additions
and
5 deletions
test/cmp_icu/test_decmp.c
+
30
−
5
View file @
bba15752
...
...
@@ -10,6 +10,30 @@
#include
"../../lib/decmp.c"
/* .c file included to test static functions */
#define IMAX_BITS(m) ((m)/((m)%255+1) / 255%255*8 + 7-86/((m)%255+12))
#define RAND_MAX_WIDTH IMAX_BITS(RAND_MAX)
/**
* @brief generate a uint32_t random number
*
* @return a "random" uint32_t value
* @see https://stackoverflow.com/a/33021408
*/
uint32_t
rand32
(
void
)
{
int
i
;
uint32_t
r
=
0
;
for
(
i
=
0
;
i
<
32
;
i
+=
RAND_MAX_WIDTH
)
{
r
<<=
RAND_MAX_WIDTH
;
r
^=
(
unsigned
int
)
rand
();
}
return
r
;
}
/**
* returns the needed size of the compression entry header plus the max size of the
* compressed data if ent == NULL if ent is set the size of the compression
...
...
@@ -419,11 +443,12 @@ void test_cmp_decmp_s_fx_diff(void)
int
my_random
(
unsigned
int
min
,
unsigned
int
max
)
{
if
(
min
>
max
)
TEST_ASSERT
(
0
);
if
(
max
-
min
>
RAND_MAX
)
TEST_ASSERT
(
0
);
return
min
+
rand
()
/
(
RAND_MAX
/
(
max
-
min
+
1
)
+
1
);
TEST_ASSERT
(
min
<
max
);
if
(
max
-
min
<
RAND_MAX
)
return
min
+
rand
()
/
(
RAND_MAX
/
(
max
-
min
+
1ULL
)
+
1
);
else
return
min
+
rand32
()
/
(
UINT32_MAX
/
(
max
-
min
+
1ULL
)
+
1
);
}
/* #include <cmp_io.h> */
...
...
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