Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yaml-cpp
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
yaml-cpp
Commits
895af262
Commit
895af262
authored
Apr 13, 2013
by
Jesse Beder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix floating point precision on input.
parent
ae42def6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
0 deletions
+10
-0
include/yaml-cpp/node/convert.h
+1
-0
test/new-api/nodetests.cpp
+9
-0
No files found.
include/yaml-cpp/node/convert.h
View file @
895af262
...
@@ -78,6 +78,7 @@ namespace YAML
...
@@ -78,6 +78,7 @@ namespace YAML
struct convert<type> {\
struct convert<type> {\
static Node encode(const type& rhs) {\
static Node encode(const type& rhs) {\
std::stringstream stream;\
std::stringstream stream;\
stream.precision(std::numeric_limits<type>::digits10 + 1);\
stream << rhs;\
stream << rhs;\
return Node(stream.str());\
return Node(stream.str());\
}\
}\
...
...
test/new-api/nodetests.cpp
View file @
895af262
...
@@ -498,6 +498,14 @@ namespace Test
...
@@ -498,6 +498,14 @@ namespace Test
YAML_ASSERT_THROWS
(
node
.
begin
()
->
begin
()
->
IsDefined
(),
YAML
::
InvalidNode
);
YAML_ASSERT_THROWS
(
node
.
begin
()
->
begin
()
->
IsDefined
(),
YAML
::
InvalidNode
);
return
true
;
return
true
;
}
}
TEST
FloatingPrecision
()
{
const
double
x
=
0.123456789
;
YAML
::
Node
node
=
YAML
::
Node
(
x
);
YAML_ASSERT
(
node
.
as
<
double
>
()
==
x
);
return
true
;
}
}
}
void
RunNodeTest
(
TEST
(
*
test
)(),
const
std
::
string
&
name
,
int
&
passed
,
int
&
total
)
{
void
RunNodeTest
(
TEST
(
*
test
)(),
const
std
::
string
&
name
,
int
&
passed
,
int
&
total
)
{
...
@@ -560,6 +568,7 @@ namespace Test
...
@@ -560,6 +568,7 @@ namespace Test
RunNodeTest
(
&
Node
::
ForceInsertIntoMap
,
"force insert into map"
,
passed
,
total
);
RunNodeTest
(
&
Node
::
ForceInsertIntoMap
,
"force insert into map"
,
passed
,
total
);
RunNodeTest
(
&
Node
::
ResetNode
,
"reset node"
,
passed
,
total
);
RunNodeTest
(
&
Node
::
ResetNode
,
"reset node"
,
passed
,
total
);
RunNodeTest
(
&
Node
::
DereferenceIteratorError
,
"dereference iterator error"
,
passed
,
total
);
RunNodeTest
(
&
Node
::
DereferenceIteratorError
,
"dereference iterator error"
,
passed
,
total
);
RunNodeTest
(
&
Node
::
FloatingPrecision
,
"floating precision"
,
passed
,
total
);
std
::
cout
<<
"Node tests: "
<<
passed
<<
"/"
<<
total
<<
" passed
\n
"
;
std
::
cout
<<
"Node tests: "
<<
passed
<<
"/"
<<
total
<<
" passed
\n
"
;
return
passed
==
total
;
return
passed
==
total
;
...
...
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