Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
2452afbf
Commit
2452afbf
authored
Apr 10, 2015
by
Milo Yip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix -Wfloat-equal warnings in Value::operator== and valuetest
parent
e04d66bd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
4 deletions
+6
-4
document.h
include/rapidjson/document.h
+4
-2
valuetest.cpp
test/unittest/valuetest.cpp
+2
-2
No files found.
include/rapidjson/document.h
View file @
2452afbf
...
...
@@ -700,8 +700,10 @@ public:
return
StringEqual
(
rhs
);
case
kNumberType
:
if
(
IsDouble
()
||
rhs
.
IsDouble
())
return
GetDouble
()
==
rhs
.
GetDouble
();
// May convert one operand from integer to double.
if
(
IsDouble
()
||
rhs
.
IsDouble
())
{
float
delta
=
GetDouble
()
-
rhs
.
GetDouble
();
// May convert one operand from integer to double.
return
delta
>=
0
.
0
&&
delta
<=
0
.
0
;
// Prevent -Wfloat-equal
}
else
return
data_
.
n
.
u64
==
rhs
.
data_
.
n
.
u64
;
...
...
test/unittest/valuetest.cpp
View file @
2452afbf
...
...
@@ -339,7 +339,7 @@ TEST(Value, Int) {
EXPECT_EQ
(
1234u
,
x
.
GetUint
());
EXPECT_EQ
(
1234
,
x
.
GetInt64
());
EXPECT_EQ
(
1234u
,
x
.
GetUint64
());
EXPECT_
EQ
(
1234
,
x
.
GetDouble
()
);
EXPECT_
NEAR
(
1234.0
,
x
.
GetDouble
(),
0.0
);
//EXPECT_EQ(1234, (int)x);
//EXPECT_EQ(1234, (unsigned)x);
//EXPECT_EQ(1234, (int64_t)x);
...
...
@@ -397,7 +397,7 @@ TEST(Value, Uint) {
EXPECT_TRUE
(
x
.
IsUint
());
EXPECT_TRUE
(
x
.
IsInt64
());
EXPECT_TRUE
(
x
.
IsUint64
());
EXPECT_
EQ
(
1234.0
,
x
.
GetDouble
()
);
// Number can always be cast as double but !IsDouble().
EXPECT_
NEAR
(
1234.0
,
x
.
GetDouble
(),
0.0
);
// Number can always be cast as double but !IsDouble().
EXPECT_FALSE
(
x
.
IsDouble
());
EXPECT_FALSE
(
x
.
IsNull
());
...
...
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