mirror of
				https://github.com/pocoproject/poco.git
				synced 2025-10-30 13:47:10 +01:00 
			
		
		
		
	SF #3544720: AbstractConfigurator to support 64bit values
This commit is contained in:
		| @@ -36,14 +36,20 @@ | ||||
| #include "Poco/AutoPtr.h" | ||||
| #include "Poco/Exception.h" | ||||
| #include "Poco/Delegate.h" | ||||
| #include "Poco/NumberFormatter.h" | ||||
| #include "Poco/Types.h" | ||||
| #include <algorithm> | ||||
| #undef min | ||||
| #undef max | ||||
| #include <limits> | ||||
|  | ||||
|  | ||||
| using Poco::Util::AbstractConfiguration; | ||||
| using Poco::Util::MapConfiguration; | ||||
| using Poco::NumberFormatter; | ||||
| using Poco::AutoPtr; | ||||
| using Poco::Int64; | ||||
| using Poco::UInt64; | ||||
|  | ||||
|  | ||||
| AbstractConfigurationTest::AbstractConfigurationTest(const std::string& name): CppUnit::TestCase(name) | ||||
| @@ -125,8 +131,9 @@ void AbstractConfigurationTest::testGetInt64() | ||||
| #if defined(POCO_HAVE_INT64) | ||||
| 	AutoPtr<AbstractConfiguration> pConf = createConfiguration(); | ||||
|  | ||||
| 	assert (pConf->getInt64("prop4.bigint1") == 420000000000L); | ||||
| 	assert (pConf->getInt64("prop4.bigint2") == -420000000000L); | ||||
| 	assert (pConf->getInt64("prop4.bigint1") == std::numeric_limits<Int64>::max()); | ||||
| 	assert (pConf->getInt64("prop4.bigint2") == std::numeric_limits<Int64>::min()); | ||||
| 	assert (pConf->getUInt64("prop4.biguint") == std::numeric_limits<UInt64>::max()); | ||||
| 	assert (pConf->getInt64("ref2") == 42); | ||||
|  | ||||
| 	try | ||||
| @@ -139,9 +146,10 @@ void AbstractConfigurationTest::testGetInt64() | ||||
| 	{ | ||||
| 	} | ||||
|  | ||||
| 	assert (pConf->getInt64("prop4.bigint1", 100) == 420000000000L); | ||||
| 	assert (pConf->getInt64("prop4.bigint2", 100) == -420000000000L); | ||||
| #endif //defined(POCO_HAVE_INT64) | ||||
| 	assert (pConf->getInt64("prop4.bigint1", 100) == std::numeric_limits<Int64>::max()); | ||||
| 	assert (pConf->getInt64("prop4.bigint2", 100) == std::numeric_limits<Int64>::min()); | ||||
| 	assert (pConf->getUInt64("prop4.biguint", 100) == std::numeric_limits<UInt64>::max()); | ||||
| #endif | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -252,10 +260,12 @@ void AbstractConfigurationTest::testSetInt64() | ||||
| #if defined(POCO_HAVE_INT64) | ||||
| 	AutoPtr<AbstractConfiguration> pConf = createConfiguration(); | ||||
|  | ||||
| 	pConf->setInt64("set.bigint1", 440000000000L); | ||||
| 	pConf->setInt64("set.bigint2", -440000000000L); | ||||
| 	assert (pConf->getInt64("set.int1") == 440000000000L); | ||||
| 	assert (pConf->getInt64("set.int2") == -440000000000L); | ||||
| 	pConf->setInt64("set.bigint1", std::numeric_limits<Int64>::max()); | ||||
| 	pConf->setInt64("set.bigint2", std::numeric_limits<Int64>::min()); | ||||
| 	pConf->setInt64("set.biguint", std::numeric_limits<UInt64>::max()); | ||||
| 	assert (pConf->getInt64("set.bigint1") == std::numeric_limits<Int64>::max()); | ||||
| 	assert (pConf->getInt64("set.bigint2") == std::numeric_limits<Int64>::min()); | ||||
| 	assert (pConf->getInt64("set.biguint") == std::numeric_limits<UInt64>::max()); | ||||
| #endif //defined(POCO_HAVE_INT64) | ||||
| } | ||||
|  | ||||
| @@ -374,7 +384,7 @@ void AbstractConfigurationTest::testRemove() | ||||
| 	pConf->keys(keys); | ||||
| 	assert (keys.size() == 13); | ||||
| 	pConf->keys("prop4", keys); | ||||
| 	assert (keys.size() == 15); | ||||
| 	assert (keys.size() == 17); | ||||
|  | ||||
| 	pConf->remove("prop4.bool1"); | ||||
| 	assert (!pConf->hasProperty("prop4.bool1")); | ||||
| @@ -383,7 +393,7 @@ void AbstractConfigurationTest::testRemove() | ||||
| 	pConf->keys(keys); | ||||
| 	assert (keys.size() == 13); | ||||
| 	pConf->keys("prop4", keys); | ||||
| 	assert (keys.size() == 14); | ||||
| 	assert (keys.size() == 16); | ||||
|  | ||||
| 	pConf->remove("prop4"); | ||||
| 	assert (!pConf->hasProperty("prop4.bool1")); | ||||
| @@ -411,8 +421,10 @@ Poco::AutoPtr<AbstractConfiguration> AbstractConfigurationTest::createConfigurat | ||||
| 	pConfig->setString("prop3.string2", "bar"); | ||||
| 	pConfig->setString("prop4.int1", "42"); | ||||
| 	pConfig->setString("prop4.int2", "-42"); | ||||
| 	pConfig->setString("prop4.bigint1", "420000000000"); | ||||
| 	pConfig->setString("prop4.bigint2", "-420000000000"); | ||||
| 	pConfig->setString("prop4.uint", NumberFormatter::format(std::numeric_limits<unsigned>::max())); | ||||
| 	pConfig->setString("prop4.bigint1", NumberFormatter::format(std::numeric_limits<Int64>::max())); | ||||
| 	pConfig->setString("prop4.bigint2", NumberFormatter::format(std::numeric_limits<Int64>::min())); | ||||
| 	pConfig->setString("prop4.biguint", NumberFormatter::format(std::numeric_limits<UInt64>::max())); | ||||
| 	pConfig->setString("prop4.hex", "0x1f"); | ||||
| 	pConfig->setString("prop4.double1", "1"); | ||||
| 	pConfig->setString("prop4.double2", "-1.5"); | ||||
| @@ -439,7 +451,7 @@ Poco::AutoPtr<AbstractConfiguration> AbstractConfigurationTest::createConfigurat | ||||
| 	pConfig->setString("ref7", "${ref1}"); | ||||
| 	pConfig->setString("dollar.atend", "foo$"); | ||||
| 	pConfig->setString("dollar.middle", "foo$bar"); | ||||
| 	 | ||||
|  | ||||
| 	return pConfig; | ||||
| } | ||||
|  | ||||
| @@ -484,3 +496,4 @@ void AbstractConfigurationTest::onPropertyRemoved(const void*, const std::string | ||||
| { | ||||
| 	_removedKey = key; | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Aleksandar Fabijanic
					Aleksandar Fabijanic