Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
yaml-cpp
Commits
fb080209
Commit
fb080209
authored
Jan 12, 2012
by
Jesse Beder
Browse files
Fixed double -> int conversion (now throws) for old API
parent
643ea61a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
4 deletions
+21
-4
include/yaml-cpp/old-api/conversion.h
include/yaml-cpp/old-api/conversion.h
+2
-3
test/old-api/parsertests.cpp
test/old-api/parsertests.cpp
+19
-1
No files found.
include/yaml-cpp/old-api/conversion.h
View file @
fb080209
...
...
@@ -50,9 +50,8 @@ namespace YAML
inline
bool
Convert
(
const
std
::
string
&
input
,
T
&
output
,
typename
enable_if
<
is_numeric
<
T
>
>::
type
*
=
0
)
{
std
::
stringstream
stream
(
input
);
stream
.
unsetf
(
std
::
ios
::
dec
);
stream
>>
output
;
if
(
!!
stream
)
return
true
;
if
((
stream
>>
output
)
&&
(
stream
>>
std
::
ws
).
eof
())
return
true
;
if
(
std
::
numeric_limits
<
T
>::
has_infinity
)
{
if
(
IsInfinity
(
input
))
{
...
...
test/old-api/parsertests.cpp
View file @
fb080209
...
...
@@ -903,7 +903,24 @@ namespace Test
return
doc
[
"foo"
].
to
<
std
::
string
>
()
==
"
\n
"
;
}
}
bool
DoubleAsInt
()
{
std
::
string
input
=
"1.5"
;
std
::
stringstream
stream
(
input
);
YAML
::
Parser
parser
(
stream
);
YAML
::
Node
doc
;
parser
.
GetNextDocument
(
doc
);
try
{
doc
.
to
<
int
>
();
}
catch
(
const
YAML
::
InvalidScalar
&
e
)
{
return
true
;
}
return
false
;
}
}
namespace
{
void
RunScalarParserTest
(
void
(
*
test
)(
std
::
string
&
,
std
::
string
&
),
const
std
::
string
&
name
,
int
&
passed
,
int
&
total
)
{
...
...
@@ -1184,6 +1201,7 @@ namespace Test
RunParserTest
(
&
Parser
::
NonConstKey
,
"non const key"
,
passed
,
total
);
RunParserTest
(
&
Parser
::
SingleChar
,
"single char"
,
passed
,
total
);
RunParserTest
(
&
Parser
::
QuotedNewline
,
"quoted newline"
,
passed
,
total
);
RunParserTest
(
&
Parser
::
DoubleAsInt
,
"double as int"
,
passed
,
total
);
RunEncodingTest
(
&
EncodeToUtf8
,
false
,
"UTF-8, no BOM"
,
passed
,
total
);
RunEncodingTest
(
&
EncodeToUtf8
,
true
,
"UTF-8 with BOM"
,
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