mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-28 19:51:58 +01:00
NumberParser limits test
This commit is contained in:
@@ -33,12 +33,23 @@
|
||||
#include "NumberParserTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/NumberParser.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/Types.h"
|
||||
|
||||
|
||||
using Poco::NumberParser;
|
||||
using Poco::NumberFormatter;
|
||||
using Poco::SyntaxException;
|
||||
using Poco::Int8;
|
||||
using Poco::UInt8;
|
||||
using Poco::Int16;
|
||||
using Poco::UInt16;
|
||||
using Poco::Int32;
|
||||
using Poco::UInt32;
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
using Poco::Int64;
|
||||
using Poco::UInt64;
|
||||
#endif
|
||||
|
||||
|
||||
NumberParserTest::NumberParserTest(const std::string& name): CppUnit::TestCase(name)
|
||||
@@ -75,6 +86,26 @@ void NumberParserTest::testParse()
|
||||
assertEqualDelta(12.34, NumberParser::parseFloat("12.34"), 0.01);
|
||||
}
|
||||
|
||||
|
||||
void NumberParserTest::testLimits()
|
||||
{
|
||||
assert(testUpperLimit<Int8>());
|
||||
assert(testLowerLimit<Int8>());
|
||||
assert(testUpperLimit<UInt8>());
|
||||
assert(testUpperLimit<Int16>());
|
||||
assert(testLowerLimit<Int16>());
|
||||
assert(testUpperLimit<UInt16>());
|
||||
assert(testUpperLimit<Int32>());
|
||||
assert(testUpperLimit<UInt32>());
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
assert(testUpperLimit64<Int64>());
|
||||
assert(testLowerLimit64<Int64>());
|
||||
assert(testUpperLimit64<UInt64>());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void NumberParserTest::testParseError()
|
||||
{
|
||||
try
|
||||
@@ -199,6 +230,7 @@ CppUnit::Test* NumberParserTest::suite()
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("NumberParserTest");
|
||||
|
||||
CppUnit_addTest(pSuite, NumberParserTest, testParse);
|
||||
CppUnit_addTest(pSuite, NumberParserTest, testLimits);
|
||||
CppUnit_addTest(pSuite, NumberParserTest, testParseError);
|
||||
|
||||
return pSuite;
|
||||
|
||||
Reference in New Issue
Block a user