Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cellframe-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
18
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
cellframe
cellframe-sdk
Commits
d370e60b
Commit
d370e60b
authored
2 years ago
by
Evgeniy Kramsakov
Committed by
Roman Khlopkov
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
hotfix-7652
parent
f0f7c9ec
No related branches found
No related tags found
1 merge request
!995
hotfix-7652
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/256_tests.cc
+73
-0
73 additions, 0 deletions
test/256_tests.cc
with
73 additions
and
0 deletions
test/256_tests.cc
+
73
−
0
View file @
d370e60b
...
@@ -3235,6 +3235,79 @@ TEST(MathTests, Div256OneMax256) {
...
@@ -3235,6 +3235,79 @@ TEST(MathTests, Div256OneMax256) {
ASSERT_STREQ
(
dap_chain_balance_print
(
c
),
(
bmp
::
uint256_t
(
lhs
)
/
bmp
::
uint256_t
(
rhs
)).
str
().
c_str
());
ASSERT_STREQ
(
dap_chain_balance_print
(
c
),
(
bmp
::
uint256_t
(
lhs
)
/
bmp
::
uint256_t
(
rhs
)).
str
().
c_str
());
}
}
TEST
(
MathTests
,
DivMoreToLess
)
{
uint256_t
a
,
b
,
c
=
uint256_0
;
string
lhs
=
"25000"
;
string
rhs
=
"10000"
;
a
=
dap_chain_balance_scan
(
lhs
.
c_str
());
b
=
dap_chain_balance_scan
(
rhs
.
c_str
());
DIV_256_COIN
(
a
,
b
,
&
c
);
ASSERT_STREQ
(
dap_chain_balance_to_coins
(
c
),
"2.5"
);
}
TEST
(
MathTests
,
DivMoreToLessPrimes
)
{
uint256_t
a
,
b
,
c
=
uint256_0
;
string
lhs
=
"23"
;
string
rhs
=
"13"
;
a
=
dap_chain_balance_scan
(
lhs
.
c_str
());
b
=
dap_chain_balance_scan
(
rhs
.
c_str
());
DIV_256_COIN
(
a
,
b
,
&
c
);
ASSERT_STREQ
(
dap_chain_balance_to_coins
(
c
),
"1.76923076923076923"
);
}
TEST
(
MathTests
,
DivMoreToLessClassic
)
{
uint256_t
a
,
b
,
c
=
uint256_0
;
string
lhs
=
"2500"
;
string
rhs
=
"1000"
;
a
=
dap_chain_balance_scan
(
lhs
.
c_str
());
b
=
dap_chain_balance_scan
(
rhs
.
c_str
());
DIV_256_COIN
(
a
,
b
,
&
c
);
ASSERT_STREQ
(
dap_chain_balance_to_coins
(
c
),
"2.5"
);
}
TEST
(
MathTests
,
DivMoreToLessSixFour
)
{
uint256_t
a
,
b
,
c
=
uint256_0
;
string
lhs
=
"6"
;
string
rhs
=
"4"
;
a
=
dap_chain_balance_scan
(
lhs
.
c_str
());
b
=
dap_chain_balance_scan
(
rhs
.
c_str
());
DIV_256_COIN
(
a
,
b
,
&
c
);
ASSERT_STREQ
(
dap_chain_balance_to_coins
(
c
),
"1.5"
);
}
TEST
(
MathTests
,
DivMoreToLessSixThree
)
{
uint256_t
a
,
b
,
c
=
uint256_0
;
string
lhs
=
"6"
;
string
rhs
=
"3"
;
a
=
dap_chain_balance_scan
(
lhs
.
c_str
());
b
=
dap_chain_balance_scan
(
rhs
.
c_str
());
DIV_256_COIN
(
a
,
b
,
&
c
);
ASSERT_STREQ
(
dap_chain_balance_to_coins
(
c
),
"2.0"
);
}
TEST
(
MathTests
,
DivMoreToLessBigBig
)
{
uint256_t
a
,
b
,
c
=
uint256_0
;
string
lhs
=
"1.0e+57"
;
string
rhs
=
"1.0e+23"
;
a
=
dap_chain_balance_scan
(
lhs
.
c_str
());
b
=
dap_chain_balance_scan
(
rhs
.
c_str
());
DIV_256_COIN
(
a
,
b
,
&
c
);
ASSERT_STREQ
(
dap_chain_balance_to_coins
(
c
),
"10000000000000000000000000000000000.0"
);
}
TEST_F
(
RandomMathTests
,
Div256
)
{
TEST_F
(
RandomMathTests
,
Div256
)
{
bmp
::
uint256_t
boost_a
(
gen256
()),
boost_b
(
gen256
());
bmp
::
uint256_t
boost_a
(
gen256
()),
boost_b
(
gen256
());
...
...
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