Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
spbro
OpenXG-RAN
Commits
c2535df3
Commit
c2535df3
authored
Oct 02, 2024
by
Robert Schmidt
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/fix_log2_approx_tests' into integration_2024_w40
parents
5ed1dcd2
28656a1a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
12 deletions
+14
-12
openair1/PHY/TOOLS/tests/CMakeLists.txt
openair1/PHY/TOOLS/tests/CMakeLists.txt
+1
-1
openair1/PHY/TOOLS/tests/test_log2_approx.cpp
openair1/PHY/TOOLS/tests/test_log2_approx.cpp
+13
-11
No files found.
openair1/PHY/TOOLS/tests/CMakeLists.txt
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
)
openair1/PHY/TOOLS/tests/test_log2_approx.cpp
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
<<
")"
;
}
}
...
...
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