[mapguide-commits] r6711 - in branches/2.4/MgDev: Common/Foundation/Data Common/Foundation/System Common/PlatformBase/Services Server Server/src/UnitTesting
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Thu May 31 04:25:25 PDT 2012
Author: jng
Date: 2012-05-31 04:25:25 -0700 (Thu, 31 May 2012)
New Revision: 6711
Added:
branches/2.4/MgDev/Server/src/UnitTesting/TestMisc.cpp
branches/2.4/MgDev/Server/src/UnitTesting/TestMisc.h
Modified:
branches/2.4/MgDev/Common/Foundation/Data/NamedCollection.cpp
branches/2.4/MgDev/Common/Foundation/System/Util.h
branches/2.4/MgDev/Common/PlatformBase/Services/FeatureReader.cpp
branches/2.4/MgDev/Server/Server_VS2010.sln
branches/2.4/MgDev/Server/src/UnitTesting/UnitTesting.cpp
Log:
#2013: Derp. I forgot to include the actual unit test source files! Also cleaned up some tab/space discrepancies and include out the stringified min/max values for MG_CHECK_RANGE() macro. Also the UnitTesting project wasn't being built on release/x64 so that has been fixed too
Modified: branches/2.4/MgDev/Common/Foundation/Data/NamedCollection.cpp
===================================================================
--- branches/2.4/MgDev/Common/Foundation/Data/NamedCollection.cpp 2012-05-31 07:54:05 UTC (rev 6710)
+++ branches/2.4/MgDev/Common/Foundation/Data/NamedCollection.cpp 2012-05-31 11:25:25 UTC (rev 6711)
@@ -111,11 +111,11 @@
{
MgNamedSerializable* item = FindItem(name);
if (!item)
- {
- MgStringCollection args;
- args.Add(name);
+ {
+ MgStringCollection args;
+ args.Add(name);
throw new MgObjectNotFoundException(L"GetItem", __LINE__, __WFILE__, NULL, L"MgNoNameForObject", &args); // EXC::Create(Exception::NLSGetMessage(NLSID(38_ITEMNOTFOUND),name));
- }
+ }
return item;
}
Modified: branches/2.4/MgDev/Common/Foundation/System/Util.h
===================================================================
--- branches/2.4/MgDev/Common/Foundation/System/Util.h 2012-05-31 07:54:05 UTC (rev 6710)
+++ branches/2.4/MgDev/Common/Foundation/System/Util.h 2012-05-31 11:25:25 UTC (rev 6711)
@@ -20,6 +20,8 @@
#include "LinuxMemoryStatus.h"
+#include <sstream>
+#include <iostream>
// Math-related macros
@@ -583,8 +585,8 @@
#define CHECKNULL(pointer, methodname) \
if (pointer == NULL) \
{ \
- MgStringCollection args; \
- args.Add(L#pointer); \
+ MgStringCollection args; \
+ args.Add(L#pointer); \
throw new MgNullReferenceException(methodname, \
__LINE__, __WFILE__, NULL, L"MgNullPointer", &args); \
}
@@ -592,8 +594,8 @@
#define CHECKARGUMENTNULL(pointer, methodname) \
if (pointer == NULL) \
{ \
- MgStringCollection args; \
- args.Add(L#pointer); \
+ MgStringCollection args; \
+ args.Add(L#pointer); \
throw new MgNullArgumentException(methodname, \
__LINE__, __WFILE__, NULL, L"MgNullArgument", &args); \
}
@@ -603,10 +605,14 @@
{ \
if (NULL != methodName) \
{ \
- MgStringCollection args; \
- args.Add(L#min); \
- args.Add(L#max); \
- args.Add(L#value); \
+ std::wostringstream minStr; \
+ minStr << min; \
+ std::wostringstream maxStr; \
+ maxStr << max; \
+ MgStringCollection args; \
+ args.Add(minStr.str()); \
+ args.Add(maxStr.str()); \
+ args.Add(L#value); \
throw new MgArgumentOutOfRangeException( \
methodName, __LINE__, __WFILE__, NULL, L"MgArgumentOutOfRange", &args); \
} \
Modified: branches/2.4/MgDev/Common/PlatformBase/Services/FeatureReader.cpp
===================================================================
--- branches/2.4/MgDev/Common/PlatformBase/Services/FeatureReader.cpp 2012-05-31 07:54:05 UTC (rev 6710)
+++ branches/2.4/MgDev/Common/PlatformBase/Services/FeatureReader.cpp 2012-05-31 11:25:25 UTC (rev 6711)
@@ -75,8 +75,8 @@
}
else
{
- MgStringCollection args;
- args.Add(propertyName);
+ MgStringCollection args;
+ args.Add(propertyName);
throw new MgObjectNotFoundException(L"MgFeatureReader.GetPropertyIndex", __LINE__, __WFILE__, NULL, L"MgNoNameForObject", &args);
return -1; // to suppress compiler warning.
}
Modified: branches/2.4/MgDev/Server/Server_VS2010.sln
===================================================================
--- branches/2.4/MgDev/Server/Server_VS2010.sln 2012-05-31 07:54:05 UTC (rev 6710)
+++ branches/2.4/MgDev/Server/Server_VS2010.sln 2012-05-31 11:25:25 UTC (rev 6711)
@@ -281,6 +281,7 @@
{DD0284A0-1ECE-4387-AED3-E9BF5EE74FF8}.Release|Win32.ActiveCfg = Release|Win32
{DD0284A0-1ECE-4387-AED3-E9BF5EE74FF8}.Release|Win32.Build.0 = Release|Win32
{DD0284A0-1ECE-4387-AED3-E9BF5EE74FF8}.Release|x64.ActiveCfg = Release|x64
+ {DD0284A0-1ECE-4387-AED3-E9BF5EE74FF8}.Release|x64.Build.0 = Release|x64
{F486B768-640A-445D-8C09-437C896EFFAD}.Debug|Win32.ActiveCfg = Debug|Win32
{F486B768-640A-445D-8C09-437C896EFFAD}.Debug|Win32.Build.0 = Debug|Win32
{F486B768-640A-445D-8C09-437C896EFFAD}.Debug|x64.ActiveCfg = Debug|x64
Added: branches/2.4/MgDev/Server/src/UnitTesting/TestMisc.cpp
===================================================================
--- branches/2.4/MgDev/Server/src/UnitTesting/TestMisc.cpp (rev 0)
+++ branches/2.4/MgDev/Server/src/UnitTesting/TestMisc.cpp 2012-05-31 11:25:25 UTC (rev 6711)
@@ -0,0 +1,261 @@
+//
+// Copyright (C) 2004-2011 by Autodesk, Inc.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of version 2.1 of the GNU Lesser
+// General Public License as published by the Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+#include "MapGuideCommon.h"
+#include "TestMisc.h"
+#include "../UnitTesting/CppUnitExtensions.h"
+#include "FoundationDefs.h"
+const STRING TEST_LOCALE = L"en";
+
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(TestMisc, "TestMisc");
+
+TestMisc::TestMisc()
+{
+}
+
+
+TestMisc::~TestMisc()
+{
+}
+
+
+void TestMisc::setUp()
+{
+}
+
+
+void TestMisc::tearDown()
+{
+}
+
+
+void TestMisc::TestStart()
+{
+ ACE_DEBUG((LM_INFO, ACE_TEXT("\nRunning Miscellaneous tests.\n")));
+}
+
+
+void TestMisc::TestEnd()
+{
+ ACE_DEBUG((LM_INFO, ACE_TEXT("\nMiscellaneous tests completed.\n\n")));
+}
+
+void TestMisc::TestCase_CommonExceptionMessages()
+{
+ try
+ {
+ MgObject* ptr = NULL;
+ CHECKNULL(ptr, L"TestMisc::TestCase_CommonExceptionMessages");
+ }
+ catch(MgException* ex)
+ {
+ STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+ //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+ std::string assertMsg = "Expected identifier 'ptr' in exception message: ";
+ assertMsg += MgUtil::WideCharToMultiByte(msg);
+ CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"ptr") != STRING::npos);
+ ex->Release();
+ }
+
+ try
+ {
+ MgObject* ptr2 = NULL;
+ CHECKNULL((void*)ptr2, L"TestMisc::TestCase_CommonExceptionMessages");
+ }
+ catch(MgException* ex)
+ {
+ STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+ //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+ std::string assertMsg = "Expected identifier 'ptr2' in exception message: ";
+ assertMsg += MgUtil::WideCharToMultiByte(msg);
+ CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"ptr2") != STRING::npos);
+ ex->Release();
+ }
+
+ try
+ {
+ MgObject* ptr3 = NULL;
+ CHECKARGUMENTNULL(ptr3, L"TestMisc::TestCase_CommonExceptionMessages");
+ }
+ catch(MgException* ex)
+ {
+ STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+ //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+ std::string assertMsg = "Expected identifier 'ptr3' in exception message: ";
+ assertMsg += MgUtil::WideCharToMultiByte(msg);
+ CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"ptr3") != STRING::npos);
+ ex->Release();
+ }
+
+ try
+ {
+ MgObject* ptr4 = NULL;
+ CHECKARGUMENTNULL((void*)ptr4, L"TestMisc::TestCase_CommonExceptionMessages");
+ }
+ catch(MgException* ex)
+ {
+ STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+ //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+ std::string assertMsg = "Expected identifier 'ptr4' in exception message: ";
+ assertMsg += MgUtil::WideCharToMultiByte(msg);
+ CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"ptr4") != STRING::npos);
+ ex->Release();
+ }
+
+ try
+ {
+ INT32 val = 1;
+ MG_CHECK_RANGE(val, 2, 3, L"TestMisc::TestCase_CommonExceptionMessages");
+ }
+ catch(MgException* ex)
+ {
+ STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+ //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+ std::string assertMsg = "Expected identifier 'val' in exception message: ";
+ assertMsg += MgUtil::WideCharToMultiByte(msg);
+ CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"val") != STRING::npos);
+ ex->Release();
+ }
+
+ try
+ {
+ INT32 val = 1;
+ INT32 min = 2;
+ INT32 max = 3;
+ MG_CHECK_RANGE(val, min, max, L"TestMisc::TestCase_CommonExceptionMessages");
+ }
+ catch(MgException* ex)
+ {
+ STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+ //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+ std::string assertMsg = "Expected identifier '' in exception message: ";
+ assertMsg += MgUtil::WideCharToMultiByte(msg);
+ CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"") != STRING::npos);
+ ex->Release();
+ }
+
+ try
+ {
+ INT64 val = 1L;
+ MG_CHECK_RANGE(val, 2L, 3L, L"TestMisc::TestCase_CommonExceptionMessages");
+ }
+ catch(MgException* ex)
+ {
+ STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+ //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+ std::string assertMsg = "Expected identifier '' in exception message: ";
+ assertMsg += MgUtil::WideCharToMultiByte(msg);
+ CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"") != STRING::npos);
+ ex->Release();
+ }
+
+ try
+ {
+ INT64 val = 1L;
+ INT64 min = 2L;
+ INT64 max = 3L;
+ MG_CHECK_RANGE(val, min, max, L"TestMisc::TestCase_CommonExceptionMessages");
+ }
+ catch(MgException* ex)
+ {
+ STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+ //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+ std::string assertMsg = "Expected identifier '' in exception message: ";
+ assertMsg += MgUtil::WideCharToMultiByte(msg);
+ CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"") != STRING::npos);
+ ex->Release();
+ }
+
+ try
+ {
+ float val = 1.0f;
+ MG_CHECK_RANGE(val, 2.0f, 3.0f, L"TestMisc::TestCase_CommonExceptionMessages");
+ }
+ catch(MgException* ex)
+ {
+ STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+ //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+ std::string assertMsg = "Expected identifier '' in exception message: ";
+ assertMsg += MgUtil::WideCharToMultiByte(msg);
+ CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"") != STRING::npos);
+ ex->Release();
+ }
+
+ try
+ {
+ float val = 1.0f;
+ float min = 2.0f;
+ float max = 3.0f;
+ MG_CHECK_RANGE(val, min, max, L"TestMisc::TestCase_CommonExceptionMessages");
+ }
+ catch(MgException* ex)
+ {
+ STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+ //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+ std::string assertMsg = "Expected identifier '' in exception message: ";
+ assertMsg += MgUtil::WideCharToMultiByte(msg);
+ CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"") != STRING::npos);
+ ex->Release();
+ }
+
+ try
+ {
+ double val = 1.0;
+ MG_CHECK_RANGE(val, 2.0, 3.0, L"TestMisc::TestCase_CommonExceptionMessages");
+ }
+ catch(MgException* ex)
+ {
+ STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+ //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+ std::string assertMsg = "Expected identifier '' in exception message: ";
+ assertMsg += MgUtil::WideCharToMultiByte(msg);
+ CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"") != STRING::npos);
+ ex->Release();
+ }
+
+ try
+ {
+ double val = 1.0;
+ double min = 2.0;
+ double max = 3.0;
+ MG_CHECK_RANGE(val, min, max, L"TestMisc::TestCase_CommonExceptionMessages");
+ }
+ catch(MgException* ex)
+ {
+ STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+ //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+ std::string assertMsg = "Expected identifier '' in exception message: ";
+ assertMsg += MgUtil::WideCharToMultiByte(msg);
+ CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"") != STRING::npos);
+ ex->Release();
+ }
+
+ try
+ {
+ Ptr<MgNamedCollection> coll = new MgNamedCollection(false);
+ coll->GetItem(L"Foo");
+ }
+ catch(MgException* ex)
+ {
+ STRING msg = ex->GetExceptionMessage(TEST_LOCALE);
+ //ACE_DEBUG((LM_INFO, ACE_TEXT("Exception: %W\n"), msg.c_str()));
+ std::string assertMsg = "Expected string 'Foo' in exception message: ";
+ assertMsg += MgUtil::WideCharToMultiByte(msg);
+ CPPUNIT_ASSERT_MESSAGE(assertMsg, msg.find(L"Foo") != STRING::npos);
+ ex->Release();
+ }
+}
\ No newline at end of file
Added: branches/2.4/MgDev/Server/src/UnitTesting/TestMisc.h
===================================================================
--- branches/2.4/MgDev/Server/src/UnitTesting/TestMisc.h (rev 0)
+++ branches/2.4/MgDev/Server/src/UnitTesting/TestMisc.h 2012-05-31 11:25:25 UTC (rev 6711)
@@ -0,0 +1,45 @@
+//
+// Copyright (C) 2004-2011 by Autodesk, Inc.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of version 2.1 of the GNU Lesser
+// General Public License as published by the Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+#ifndef _TESTTILESERVICE_H
+#define _TESTTILESERVICE_H
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class TestMisc : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE(TestMisc);
+ CPPUNIT_TEST(TestStart); // This must be the very first unit test
+
+ CPPUNIT_TEST(TestCase_CommonExceptionMessages);
+
+ CPPUNIT_TEST(TestEnd); // This must be the very last unit test
+ CPPUNIT_TEST_SUITE_END();
+
+public:
+ TestMisc();
+ ~TestMisc();
+
+ void setUp();
+ void tearDown();
+ void TestStart();
+ void TestEnd();
+
+ void TestCase_CommonExceptionMessages();
+};
+
+#endif
Modified: branches/2.4/MgDev/Server/src/UnitTesting/UnitTesting.cpp
===================================================================
--- branches/2.4/MgDev/Server/src/UnitTesting/UnitTesting.cpp 2012-05-31 07:54:05 UTC (rev 6710)
+++ branches/2.4/MgDev/Server/src/UnitTesting/UnitTesting.cpp 2012-05-31 11:25:25 UTC (rev 6711)
@@ -53,7 +53,7 @@
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestMdfModel").makeTest());
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestKmlService").makeTest());
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestMappingService").makeTest());
- runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestMisc").makeTest());
+ runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestMisc").makeTest());
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestRenderingService").makeTest());
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestResourceService").makeTest());
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestTileService").makeTest());
@@ -83,7 +83,7 @@
ACE_OS::printf(" LogManager\n");
ACE_OS::printf(" MappingService\n");
ACE_OS::printf(" MdfModel\n");
- ACE_OS::printf(" Misc\n");
+ ACE_OS::printf(" Misc\n");
ACE_OS::printf(" Performance\n");
ACE_OS::printf(" RenderingService\n");
ACE_OS::printf(" ResourceService\n");
@@ -134,7 +134,7 @@
ACE_DEBUG((LM_INFO, ACE_TEXT(">>>>> Running only MdfModel tests. <<<<<\n\n")));
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestMdfModel").makeTest());
}
- else if(ACE_OS::strcasecmp(MG_WCHAR_TO_TCHAR(test), ACE_LIB_TEXT("Misc")) == 0)
+ else if(ACE_OS::strcasecmp(MG_WCHAR_TO_TCHAR(test), ACE_LIB_TEXT("Misc")) == 0)
{
ACE_DEBUG((LM_INFO, ACE_TEXT(">>>>> Running only Miscellaneous tests. <<<<<\n\n")));
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestMisc").makeTest());
@@ -216,7 +216,7 @@
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestMdfModel").makeTest());
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestKmlService").makeTest());
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestMappingService").makeTest());
- runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestMisc").makeTest());
+ runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestMisc").makeTest());
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestRenderingService").makeTest());
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestResourceService").makeTest());
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry("TestTileService").makeTest());
More information about the mapguide-commits
mailing list