Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
openairinterface5G
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
oai
openairinterface5G
Commits
c2535df3
Commit
c2535df3
authored
6 months ago
by
Robert Schmidt
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/fix_log2_approx_tests' into integration_2024_w40
parents
5ed1dcd2
28656a1a
No related branches found
No related tags found
1 merge request
!3014
Integration: `2024.w40`
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
openair1/PHY/TOOLS/tests/CMakeLists.txt
+1
-1
1 addition, 1 deletion
openair1/PHY/TOOLS/tests/CMakeLists.txt
openair1/PHY/TOOLS/tests/test_log2_approx.cpp
+13
-11
13 additions, 11 deletions
openair1/PHY/TOOLS/tests/test_log2_approx.cpp
with
14 additions
and
12 deletions
openair1/PHY/TOOLS/tests/CMakeLists.txt
+
1
−
1
View file @
c2535df3
...
...
@@ -14,4 +14,4 @@ add_executable(test_log2_approx test_log2_approx.cpp ../log2_approx.c)
target_link_libraries
(
test_log2_approx PRIVATE GTest::gtest LOG minimal_lib
)
add_dependencies
(
tests test_log2_approx
)
add_test
(
NAME test_log2_approx
COMMAND ./test_log2_approx
)
COMMAND ./test_log2_approx
--gtest_filter=-log2_approx.complete
)
This diff is collapsed.
Click to expand it.
openair1/PHY/TOOLS/tests/test_log2_approx.cpp
+
13
−
11
View file @
c2535df3
...
...
@@ -10,25 +10,27 @@ uint8_t log2_approx_ref(uint32_t x)
return
std
::
round
(
std
::
log2
(
x
));
}
uint8_t
log2_approx64_ref
(
unsigned
long
long
int
x
)
{
return
std
::
round
(
std
::
log2
(
static_cast
<
long
double
>
(
x
)));
}
TEST
(
log2_approx
,
complete
)
{
for
(
uint32_t
i
=
0
;
i
<
UINT32_MAX
;
i
++
)
EXPECT_EQ
(
log2_approx
(
i
),
log2_approx_ref
(
i
));
}
TEST
(
log2_approx
,
boundaries
)
{
for
(
int
i
=
0
;
i
<
32
;
i
++
)
{
uint32_t
i2
=
std
::
pow
(
2.0
,
i
+
0.5
);
EXPECT_EQ
(
log2_approx
(
i2
),
i
)
<<
"log2("
<<
i2
<<
")"
;
EXPECT_EQ
(
log2_approx
(
i2
+
1
),
i
+
1
)
<<
"log2("
<<
i2
+
1
<<
")"
;
}
}
TEST
(
log2_approx64
,
boundaries
)
{
for
(
long
double
i
=
0
;
i
<
64
;
i
++
)
{
unsigned
long
long
i2
=
std
::
pow
(
2.0
L
,
i
+
0.5
L
);
for
(
unsigned
long
long
j
=
-
10
;
j
<=
10
;
j
++
)
{
unsigned
long
long
x
=
i2
+
j
;
EXPECT_EQ
(
log2_approx64
(
x
),
log2_approx64_ref
(
x
));
}
for
(
int
i
=
0
;
i
<
64
;
i
++
)
{
unsigned
long
long
int
i2
=
std
::
pow
(
2.0
L
,
i
+
0.5
L
);
EXPECT_EQ
(
log2_approx64
(
i2
),
i
)
<<
"log2("
<<
i2
<<
")"
;
EXPECT_EQ
(
log2_approx64
(
i2
+
1
),
i
+
1
)
<<
"log2("
<<
i2
+
1
<<
")"
;
}
}
...
...
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