mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-04 19:13:30 +01:00
added tests for DegestStream / NumberParser / NumberFormatter
This commit is contained in:
parent
a4931bb9af
commit
ae48e7465a
@ -1,115 +1,125 @@
|
||||
//
|
||||
// DigestStreamTest.cpp
|
||||
//
|
||||
//
|
||||
// DigestStreamTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/testsuite/src/DigestStreamTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "DigestStreamTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/DigestStream.h"
|
||||
#include "Poco/MD5Engine.h"
|
||||
#include <sstream>
|
||||
|
||||
|
||||
using Poco::DigestInputStream;
|
||||
using Poco::DigestOutputStream;
|
||||
using Poco::DigestEngine;
|
||||
using Poco::MD5Engine;
|
||||
|
||||
|
||||
DigestStreamTest::DigestStreamTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DigestStreamTest::~DigestStreamTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DigestStreamTest::testInputStream()
|
||||
{
|
||||
std::istringstream istr("abcdefghijklmnopqrstuvwxyz");
|
||||
MD5Engine md5;
|
||||
DigestInputStream ds(md5, istr);
|
||||
std::string s;
|
||||
ds >> s;
|
||||
assert (DigestEngine::digestToHex(md5.digest()) == "c3fcd3d76192e4007dfb496cca67e13b");
|
||||
assert (s == "abcdefghijklmnopqrstuvwxyz");
|
||||
}
|
||||
|
||||
|
||||
void DigestStreamTest::testOutputStream1()
|
||||
{
|
||||
MD5Engine md5;
|
||||
DigestOutputStream ds(md5);
|
||||
ds << "abcdefghijklmnopqrstuvwxyz";
|
||||
ds.close();
|
||||
assert (DigestEngine::digestToHex(md5.digest()) == "c3fcd3d76192e4007dfb496cca67e13b");
|
||||
|
||||
ds << "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
ds << "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
ds.close();
|
||||
assert (DigestEngine::digestToHex(md5.digest()) == "d174ab98d277d9f5a5611c2c9f419d9f");
|
||||
}
|
||||
|
||||
|
||||
void DigestStreamTest::testOutputStream2()
|
||||
{
|
||||
MD5Engine md5;
|
||||
std::ostringstream ostr;
|
||||
DigestOutputStream ds(md5, ostr);
|
||||
ds << "abcdefghijklmnopqrstuvwxyz";
|
||||
ds.close();
|
||||
assert (DigestEngine::digestToHex(md5.digest()) == "c3fcd3d76192e4007dfb496cca67e13b");
|
||||
assert (ostr.str() == "abcdefghijklmnopqrstuvwxyz");
|
||||
}
|
||||
|
||||
|
||||
void DigestStreamTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DigestStreamTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* DigestStreamTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("DigestStreamTest");
|
||||
|
||||
CppUnit_addTest(pSuite, DigestStreamTest, testInputStream);
|
||||
CppUnit_addTest(pSuite, DigestStreamTest, testOutputStream1);
|
||||
CppUnit_addTest(pSuite, DigestStreamTest, testOutputStream2);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "DigestStreamTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/DigestStream.h"
|
||||
#include "Poco/MD5Engine.h"
|
||||
#include <sstream>
|
||||
|
||||
|
||||
using Poco::DigestInputStream;
|
||||
using Poco::DigestOutputStream;
|
||||
using Poco::DigestEngine;
|
||||
using Poco::MD5Engine;
|
||||
|
||||
|
||||
DigestStreamTest::DigestStreamTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DigestStreamTest::~DigestStreamTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DigestStreamTest::testInputStream()
|
||||
{
|
||||
std::istringstream istr("abcdefghijklmnopqrstuvwxyz");
|
||||
MD5Engine md5;
|
||||
DigestInputStream ds(md5, istr);
|
||||
std::string s;
|
||||
ds >> s;
|
||||
assert (DigestEngine::digestToHex(md5.digest()) == "c3fcd3d76192e4007dfb496cca67e13b");
|
||||
assert (s == "abcdefghijklmnopqrstuvwxyz");
|
||||
}
|
||||
|
||||
|
||||
void DigestStreamTest::testOutputStream1()
|
||||
{
|
||||
MD5Engine md5;
|
||||
DigestOutputStream ds(md5);
|
||||
ds << "abcdefghijklmnopqrstuvwxyz";
|
||||
ds.close();
|
||||
assert (DigestEngine::digestToHex(md5.digest()) == "c3fcd3d76192e4007dfb496cca67e13b");
|
||||
|
||||
ds << "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
ds << "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
ds.close();
|
||||
assert (DigestEngine::digestToHex(md5.digest()) == "d174ab98d277d9f5a5611c2c9f419d9f");
|
||||
}
|
||||
|
||||
|
||||
void DigestStreamTest::testOutputStream2()
|
||||
{
|
||||
MD5Engine md5;
|
||||
std::ostringstream ostr;
|
||||
DigestOutputStream ds(md5, ostr);
|
||||
ds << "abcdefghijklmnopqrstuvwxyz";
|
||||
ds.close();
|
||||
assert (DigestEngine::digestToHex(md5.digest()) == "c3fcd3d76192e4007dfb496cca67e13b");
|
||||
assert (ostr.str() == "abcdefghijklmnopqrstuvwxyz");
|
||||
}
|
||||
|
||||
|
||||
void DigestStreamTest::testToFromHex()
|
||||
{
|
||||
std::string digest("c3fcd3d76192e4007dfb496cca67e13b");
|
||||
Poco::DigestEngine::Digest dig = DigestEngine::digestFromHex(digest);
|
||||
std::string digest2 = DigestEngine::digestToHex(dig);
|
||||
assert (digest == digest2);
|
||||
}
|
||||
|
||||
|
||||
void DigestStreamTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DigestStreamTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* DigestStreamTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("DigestStreamTest");
|
||||
|
||||
CppUnit_addTest(pSuite, DigestStreamTest, testInputStream);
|
||||
CppUnit_addTest(pSuite, DigestStreamTest, testOutputStream1);
|
||||
CppUnit_addTest(pSuite, DigestStreamTest, testOutputStream2);
|
||||
CppUnit_addTest(pSuite, DigestStreamTest, testToFromHex);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@ -1,62 +1,63 @@
|
||||
//
|
||||
// DigestStreamTest.h
|
||||
//
|
||||
//
|
||||
// DigestStreamTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/testsuite/src/DigestStreamTest.h#1 $
|
||||
//
|
||||
// Definition of the DigestStreamTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef DigestStreamTest_INCLUDED
|
||||
#define DigestStreamTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class DigestStreamTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
DigestStreamTest(const std::string& name);
|
||||
~DigestStreamTest();
|
||||
|
||||
void testInputStream();
|
||||
void testOutputStream1();
|
||||
void testOutputStream2();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // DigestStreamTest_INCLUDED
|
||||
//
|
||||
// Definition of the DigestStreamTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef DigestStreamTest_INCLUDED
|
||||
#define DigestStreamTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class DigestStreamTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
DigestStreamTest(const std::string& name);
|
||||
~DigestStreamTest();
|
||||
|
||||
void testInputStream();
|
||||
void testOutputStream1();
|
||||
void testOutputStream2();
|
||||
void testToFromHex();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // DigestStreamTest_INCLUDED
|
||||
|
@ -1,181 +1,188 @@
|
||||
//
|
||||
// NumberFormatterTest.cpp
|
||||
//
|
||||
//
|
||||
// NumberFormatterTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/testsuite/src/NumberFormatterTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "NumberFormatterTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/NumberFormatter.h"
|
||||
|
||||
|
||||
using Poco::NumberFormatter;
|
||||
using Poco::Int64;
|
||||
using Poco::UInt64;
|
||||
|
||||
|
||||
NumberFormatterTest::NumberFormatterTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NumberFormatterTest::~NumberFormatterTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NumberFormatterTest::testFormat()
|
||||
{
|
||||
assert (NumberFormatter::format(123) == "123");
|
||||
assert (NumberFormatter::format(-123) == "-123");
|
||||
assert (NumberFormatter::format(-123, 5) == " -123");
|
||||
|
||||
assert (NumberFormatter::format((unsigned) 123) == "123");
|
||||
assert (NumberFormatter::format((unsigned) 123, 5) == " 123");
|
||||
assert (NumberFormatter::format0((unsigned) 123, 5) == "00123");
|
||||
|
||||
assert (NumberFormatter::format((long) 123) == "123");
|
||||
assert (NumberFormatter::format((long) -123) == "-123");
|
||||
assert (NumberFormatter::format((long) -123, 5) == " -123");
|
||||
|
||||
assert (NumberFormatter::format((unsigned long) 123) == "123");
|
||||
assert (NumberFormatter::format((unsigned long) 123, 5) == " 123");
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
assert (NumberFormatter::format((Int64) 123) == "123");
|
||||
assert (NumberFormatter::format((Int64) -123) == "-123");
|
||||
assert (NumberFormatter::format((Int64) -123, 5) == " -123");
|
||||
|
||||
assert (NumberFormatter::format((UInt64) 123) == "123");
|
||||
assert (NumberFormatter::format((UInt64) 123, 5) == " 123");
|
||||
#endif
|
||||
|
||||
if (sizeof(void*) == 4)
|
||||
{
|
||||
assert (NumberFormatter::format((void*) 0x12345678) == "12345678");
|
||||
}
|
||||
else
|
||||
{
|
||||
assert (NumberFormatter::format((void*) 0x12345678) == "0000000012345678");
|
||||
}
|
||||
|
||||
assert (NumberFormatter::format(12.25) == "12.25");
|
||||
assert (NumberFormatter::format(12.25, 4) == "12.2500");
|
||||
assert (NumberFormatter::format(12.25, 8, 4) == " 12.2500");
|
||||
}
|
||||
|
||||
|
||||
void NumberFormatterTest::testFormat0()
|
||||
{
|
||||
assert (NumberFormatter::format0(123, 5) == "00123");
|
||||
assert (NumberFormatter::format0(-123, 5) == "-0123");
|
||||
assert (NumberFormatter::format0((long) 123, 5) == "00123");
|
||||
assert (NumberFormatter::format0((long) -123, 5) == "-0123");
|
||||
assert (NumberFormatter::format0((unsigned long) 123, 5) == "00123");
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
assert (NumberFormatter::format0((Int64) 123, 5) == "00123");
|
||||
assert (NumberFormatter::format0((Int64) -123, 5) == "-0123");
|
||||
assert (NumberFormatter::format0((UInt64) 123, 5) == "00123");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void NumberFormatterTest::testFormatHex()
|
||||
{
|
||||
assert (NumberFormatter::formatHex(0x12) == "12");
|
||||
assert (NumberFormatter::formatHex(0xab) == "AB");
|
||||
assert (NumberFormatter::formatHex(0x12, 4) == "0012");
|
||||
assert (NumberFormatter::formatHex(0xab, 4) == "00AB");
|
||||
|
||||
assert (NumberFormatter::formatHex((unsigned) 0x12) == "12");
|
||||
assert (NumberFormatter::formatHex((unsigned) 0xab) == "AB");
|
||||
assert (NumberFormatter::formatHex((unsigned) 0x12, 4) == "0012");
|
||||
assert (NumberFormatter::formatHex((unsigned) 0xab, 4) == "00AB");
|
||||
|
||||
assert (NumberFormatter::formatHex((long) 0x12) == "12");
|
||||
assert (NumberFormatter::formatHex((long) 0xab) == "AB");
|
||||
assert (NumberFormatter::formatHex((long) 0x12, 4) == "0012");
|
||||
assert (NumberFormatter::formatHex((long) 0xab, 4) == "00AB");
|
||||
|
||||
assert (NumberFormatter::formatHex((unsigned long) 0x12) == "12");
|
||||
assert (NumberFormatter::formatHex((unsigned long) 0xab) == "AB");
|
||||
assert (NumberFormatter::formatHex((unsigned long) 0x12, 4) == "0012");
|
||||
assert (NumberFormatter::formatHex((unsigned long) 0xab, 4) == "00AB");
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
assert (NumberFormatter::formatHex((Int64) 0x12) == "12");
|
||||
assert (NumberFormatter::formatHex((Int64) 0xab) == "AB");
|
||||
assert (NumberFormatter::formatHex((Int64) 0x12, 4) == "0012");
|
||||
assert (NumberFormatter::formatHex((Int64) 0xab, 4) == "00AB");
|
||||
|
||||
assert (NumberFormatter::formatHex((UInt64) 0x12) == "12");
|
||||
assert (NumberFormatter::formatHex((UInt64) 0xab) == "AB");
|
||||
assert (NumberFormatter::formatHex((UInt64) 0x12, 4) == "0012");
|
||||
assert (NumberFormatter::formatHex((UInt64) 0xab, 4) == "00AB");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void NumberFormatterTest::testFormatFloat()
|
||||
{
|
||||
std::string s(NumberFormatter::format(1.0f));
|
||||
assert (s == "1");
|
||||
s = NumberFormatter::format(0.1f);
|
||||
assert (s == "0.1");
|
||||
|
||||
s = NumberFormatter::format(1.0);
|
||||
assert (s == "1");
|
||||
s = NumberFormatter::format(0.1);
|
||||
assert (s == "0.1");
|
||||
}
|
||||
|
||||
|
||||
void NumberFormatterTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NumberFormatterTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* NumberFormatterTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("NumberFormatterTest");
|
||||
|
||||
CppUnit_addTest(pSuite, NumberFormatterTest, testFormat);
|
||||
CppUnit_addTest(pSuite, NumberFormatterTest, testFormat0);
|
||||
CppUnit_addTest(pSuite, NumberFormatterTest, testFormatHex);
|
||||
CppUnit_addTest(pSuite, NumberFormatterTest, testFormatFloat);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "NumberFormatterTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/NumberFormatter.h"
|
||||
|
||||
|
||||
using Poco::NumberFormatter;
|
||||
using Poco::Int64;
|
||||
using Poco::UInt64;
|
||||
|
||||
|
||||
NumberFormatterTest::NumberFormatterTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NumberFormatterTest::~NumberFormatterTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NumberFormatterTest::testFormat()
|
||||
{
|
||||
assert (NumberFormatter::format(123) == "123");
|
||||
assert (NumberFormatter::format(-123) == "-123");
|
||||
assert (NumberFormatter::format(-123, 5) == " -123");
|
||||
|
||||
assert (NumberFormatter::format((unsigned) 123) == "123");
|
||||
assert (NumberFormatter::format((unsigned) 123, 5) == " 123");
|
||||
assert (NumberFormatter::format0((unsigned) 123, 5) == "00123");
|
||||
|
||||
assert (NumberFormatter::format((long) 123) == "123");
|
||||
assert (NumberFormatter::format((long) -123) == "-123");
|
||||
assert (NumberFormatter::format((long) -123, 5) == " -123");
|
||||
|
||||
assert (NumberFormatter::format((unsigned long) 123) == "123");
|
||||
assert (NumberFormatter::format((unsigned long) 123, 5) == " 123");
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
assert (NumberFormatter::format((Int64) 123) == "123");
|
||||
assert (NumberFormatter::format((Int64) -123) == "-123");
|
||||
assert (NumberFormatter::format((Int64) -123, 5) == " -123");
|
||||
|
||||
assert (NumberFormatter::format((UInt64) 123) == "123");
|
||||
assert (NumberFormatter::format((UInt64) 123, 5) == " 123");
|
||||
#endif
|
||||
|
||||
if (sizeof(void*) == 4)
|
||||
{
|
||||
assert (NumberFormatter::format((void*) 0x12345678) == "12345678");
|
||||
}
|
||||
else
|
||||
{
|
||||
assert (NumberFormatter::format((void*) 0x12345678) == "0000000012345678");
|
||||
}
|
||||
|
||||
assert (NumberFormatter::format(12.25) == "12.25");
|
||||
assert (NumberFormatter::format(12.25, 4) == "12.2500");
|
||||
assert (NumberFormatter::format(12.25, 8, 4) == " 12.2500");
|
||||
|
||||
assert (NumberFormatter::format(true, NumberFormatter::FMT_TRUE_FALSE) == "true");
|
||||
assert (NumberFormatter::format(false, NumberFormatter::FMT_TRUE_FALSE) == "false");
|
||||
assert (NumberFormatter::format(true, NumberFormatter::FMT_YES_NO) == "yes");
|
||||
assert (NumberFormatter::format(false, NumberFormatter::FMT_YES_NO) == "no");
|
||||
assert (NumberFormatter::format(true, NumberFormatter::FMT_ON_OFF) == "on");
|
||||
assert (NumberFormatter::format(false, NumberFormatter::FMT_ON_OFF) == "off");
|
||||
}
|
||||
|
||||
|
||||
void NumberFormatterTest::testFormat0()
|
||||
{
|
||||
assert (NumberFormatter::format0(123, 5) == "00123");
|
||||
assert (NumberFormatter::format0(-123, 5) == "-0123");
|
||||
assert (NumberFormatter::format0((long) 123, 5) == "00123");
|
||||
assert (NumberFormatter::format0((long) -123, 5) == "-0123");
|
||||
assert (NumberFormatter::format0((unsigned long) 123, 5) == "00123");
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
assert (NumberFormatter::format0((Int64) 123, 5) == "00123");
|
||||
assert (NumberFormatter::format0((Int64) -123, 5) == "-0123");
|
||||
assert (NumberFormatter::format0((UInt64) 123, 5) == "00123");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void NumberFormatterTest::testFormatHex()
|
||||
{
|
||||
assert (NumberFormatter::formatHex(0x12) == "12");
|
||||
assert (NumberFormatter::formatHex(0xab) == "AB");
|
||||
assert (NumberFormatter::formatHex(0x12, 4) == "0012");
|
||||
assert (NumberFormatter::formatHex(0xab, 4) == "00AB");
|
||||
|
||||
assert (NumberFormatter::formatHex((unsigned) 0x12) == "12");
|
||||
assert (NumberFormatter::formatHex((unsigned) 0xab) == "AB");
|
||||
assert (NumberFormatter::formatHex((unsigned) 0x12, 4) == "0012");
|
||||
assert (NumberFormatter::formatHex((unsigned) 0xab, 4) == "00AB");
|
||||
|
||||
assert (NumberFormatter::formatHex((long) 0x12) == "12");
|
||||
assert (NumberFormatter::formatHex((long) 0xab) == "AB");
|
||||
assert (NumberFormatter::formatHex((long) 0x12, 4) == "0012");
|
||||
assert (NumberFormatter::formatHex((long) 0xab, 4) == "00AB");
|
||||
|
||||
assert (NumberFormatter::formatHex((unsigned long) 0x12) == "12");
|
||||
assert (NumberFormatter::formatHex((unsigned long) 0xab) == "AB");
|
||||
assert (NumberFormatter::formatHex((unsigned long) 0x12, 4) == "0012");
|
||||
assert (NumberFormatter::formatHex((unsigned long) 0xab, 4) == "00AB");
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
assert (NumberFormatter::formatHex((Int64) 0x12) == "12");
|
||||
assert (NumberFormatter::formatHex((Int64) 0xab) == "AB");
|
||||
assert (NumberFormatter::formatHex((Int64) 0x12, 4) == "0012");
|
||||
assert (NumberFormatter::formatHex((Int64) 0xab, 4) == "00AB");
|
||||
|
||||
assert (NumberFormatter::formatHex((UInt64) 0x12) == "12");
|
||||
assert (NumberFormatter::formatHex((UInt64) 0xab) == "AB");
|
||||
assert (NumberFormatter::formatHex((UInt64) 0x12, 4) == "0012");
|
||||
assert (NumberFormatter::formatHex((UInt64) 0xab, 4) == "00AB");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void NumberFormatterTest::testFormatFloat()
|
||||
{
|
||||
std::string s(NumberFormatter::format(1.0f));
|
||||
assert (s == "1");
|
||||
s = NumberFormatter::format(0.1f);
|
||||
assert (s == "0.1");
|
||||
|
||||
s = NumberFormatter::format(1.0);
|
||||
assert (s == "1");
|
||||
s = NumberFormatter::format(0.1);
|
||||
assert (s == "0.1");
|
||||
}
|
||||
|
||||
|
||||
void NumberFormatterTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NumberFormatterTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* NumberFormatterTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("NumberFormatterTest");
|
||||
|
||||
CppUnit_addTest(pSuite, NumberFormatterTest, testFormat);
|
||||
CppUnit_addTest(pSuite, NumberFormatterTest, testFormat0);
|
||||
CppUnit_addTest(pSuite, NumberFormatterTest, testFormatHex);
|
||||
CppUnit_addTest(pSuite, NumberFormatterTest, testFormatFloat);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@ -1,196 +1,205 @@
|
||||
//
|
||||
// NumberParserTest.cpp
|
||||
//
|
||||
//
|
||||
// NumberParserTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Foundation/testsuite/src/NumberParserTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "NumberParserTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/NumberParser.h"
|
||||
#include "Poco/Exception.h"
|
||||
|
||||
|
||||
using Poco::NumberParser;
|
||||
using Poco::SyntaxException;
|
||||
|
||||
|
||||
NumberParserTest::NumberParserTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NumberParserTest::~NumberParserTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NumberParserTest::testParse()
|
||||
{
|
||||
assert (NumberParser::parse("123") == 123);
|
||||
assert (NumberParser::parse("-123") == -123);
|
||||
assert (NumberParser::parseUnsigned("123") == 123);
|
||||
assert (NumberParser::parseHex("12AB") == 0x12ab);
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
assert (NumberParser::parse64("123") == 123);
|
||||
assert (NumberParser::parse64("-123") == -123);
|
||||
assert (NumberParser::parseUnsigned64("123") == 123);
|
||||
assert (NumberParser::parseHex64("12AB") == 0x12ab);
|
||||
#endif
|
||||
|
||||
assertEqualDelta (12.34, NumberParser::parseFloat("12.34"), 0.01);
|
||||
}
|
||||
|
||||
void NumberParserTest::testParseError()
|
||||
{
|
||||
try
|
||||
{
|
||||
NumberParser::parse("");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parse("asd");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parseUnsigned("a123");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parseHex("z23");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parseHex("23z");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parse64("asd");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parseUnsigned64("");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parseHex64("zaz");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parseHex64("12345z");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parseFloat("a12.3");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parseFloat("12.3aa");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NumberParserTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NumberParserTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* NumberParserTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("NumberParserTest");
|
||||
|
||||
CppUnit_addTest(pSuite, NumberParserTest, testParse);
|
||||
CppUnit_addTest(pSuite, NumberParserTest, testParseError);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "NumberParserTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/NumberParser.h"
|
||||
#include "Poco/Exception.h"
|
||||
|
||||
|
||||
using Poco::NumberParser;
|
||||
using Poco::SyntaxException;
|
||||
|
||||
|
||||
NumberParserTest::NumberParserTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NumberParserTest::~NumberParserTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NumberParserTest::testParse()
|
||||
{
|
||||
assert (NumberParser::parse("123") == 123);
|
||||
assert (NumberParser::parse("-123") == -123);
|
||||
assert (NumberParser::parseUnsigned("123") == 123);
|
||||
assert (NumberParser::parseHex("12AB") == 0x12ab);
|
||||
|
||||
assert (NumberParser::parseBool("0") == false);
|
||||
assert (NumberParser::parseBool("FALSE") == false);
|
||||
assert (NumberParser::parseBool("no") == false);
|
||||
assert (NumberParser::parseBool("1") == true);
|
||||
assert (NumberParser::parseBool("True") == true);
|
||||
assert (NumberParser::parseBool("YeS") == true);
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
assert (NumberParser::parse64("123") == 123);
|
||||
assert (NumberParser::parse64("-123") == -123);
|
||||
assert (NumberParser::parseUnsigned64("123") == 123);
|
||||
assert (NumberParser::parseHex64("12AB") == 0x12ab);
|
||||
#endif
|
||||
|
||||
assertEqualDelta (12.34, NumberParser::parseFloat("12.34"), 0.01);
|
||||
}
|
||||
|
||||
void NumberParserTest::testParseError()
|
||||
{
|
||||
try
|
||||
{
|
||||
NumberParser::parse("");
|
||||
NumberParser::parseBool("");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parse("asd");
|
||||
NumberParser::parseBool("asd");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parseUnsigned("a123");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parseHex("z23");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parseHex("23z");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parse64("asd");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parseUnsigned64("");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parseHex64("zaz");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parseHex64("12345z");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parseFloat("a12.3");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parseFloat("12.3aa");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NumberParserTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NumberParserTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* NumberParserTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("NumberParserTest");
|
||||
|
||||
CppUnit_addTest(pSuite, NumberParserTest, testParse);
|
||||
CppUnit_addTest(pSuite, NumberParserTest, testParseError);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user