Bug 450137 - Add namespaces to multiple classes with the same name in xpcom/tests, to avoid automated tool confusion, r=dbaron
authorBenjamin Smedberg <benjamin@smedbergs.us>
Mon, 18 Aug 2008 12:45:38 -0400
changeset 16995 4b0bdfceb9e5312d35b8ebf75f5f1ea249330075
parent 16994 c37a5b4ed1afcbcd392951b479e1d9399d098fe2
child 16996 13ed1c63513bb15917c56f80a1d1c5154d56e537
push id1327
push userbsmedberg@mozilla.com
push dateMon, 18 Aug 2008 16:46:25 +0000
treeherdermozilla-central@13ed1c63513b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs450137
milestone1.9.1a2pre
Bug 450137 - Add namespaces to multiple classes with the same name in xpcom/tests, to avoid automated tool confusion, r=dbaron
xpcom/tests/TestArray.cpp
xpcom/tests/TestCRT.cpp
xpcom/tests/TestExpirationTracker.cpp
xpcom/tests/TestHashtables.cpp
xpcom/tests/TestStrings.cpp
xpcom/tests/TestTArray.cpp
--- a/xpcom/tests/TestArray.cpp
+++ b/xpcom/tests/TestArray.cpp
@@ -40,16 +40,18 @@
 #include <stdlib.h>
 #include "nsISupportsArray.h"
 
 // {9e70a320-be02-11d1-8031-006008159b5a}
 #define NS_IFOO_IID \
   {0x9e70a320, 0xbe02, 0x11d1,    \
     {0x80, 0x31, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x5a}}
 
+namespace TestArray {
+
 static const PRBool kExitOnError = PR_TRUE;
 
 class IFoo : public nsISupports {
 public:
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IFOO_IID)
 
   NS_IMETHOD_(nsrefcnt) RefCnt() = 0;
@@ -132,16 +134,20 @@ void FillArray(nsISupportsArray* aArray,
 {
   PRInt32 index;
   for (index = 0; index < aCount; index++) {
     nsCOMPtr<IFoo> foo = new Foo(index);
     aArray->AppendElement(foo);
   }
 }
 
+}
+
+using namespace TestArray;
+
 int main(int argc, char *argv[])
 {
   nsISupportsArray* array;
   nsresult  rv;
   
   if (NS_OK == (rv = NS_NewISupportsArray(&array))) {
     FillArray(array, 10);
     fprintf(stdout, "Array created:\n");
--- a/xpcom/tests/TestCRT.cpp
+++ b/xpcom/tests/TestCRT.cpp
@@ -35,16 +35,18 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsCRT.h"
 #include "nsString.h"
 #include "plstr.h"
 #include <stdlib.h>
 
+namespace TestCRT {
+
 // The return from strcmp etc is only defined to be postive, zero or
 // negative. The magnitude of a non-zero return is irrelevant.
 PRIntn sign(PRIntn val) {
     if (val == 0)
 	return 0;
     else {
 	if (val > 0)
 	    return 1;
@@ -96,16 +98,20 @@ static Test tests[] = {
   { "bar", "foo", 3 },
   { "bar", "fo", 3 },
 
   { "bar", "foo", 3 },
   { "bar", "fo", 3 },
 };
 #define NUM_TESTS int((sizeof(tests) / sizeof(tests[0])))
 
+}
+
+using namespace TestCRT;
+
 int main()
 {
   Test* tp = tests;
   for (int i = 0; i < NUM_TESTS; i++, tp++) {
     Check(tp->s1, tp->s2, tp->n);
   }
 
   return 0;
--- a/xpcom/tests/TestExpirationTracker.cpp
+++ b/xpcom/tests/TestExpirationTracker.cpp
@@ -46,16 +46,18 @@
 #include "nsDirectoryServiceDefs.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsXPCOM.h"
 #include "nsILocalFile.h"
 #include "prinrval.h"
 #include "nsThreadUtils.h"
 
+namespace TestExpirationTracker {
+
 struct Object {
   Object() : mExpired(PR_FALSE) { Touch(); }
   void Touch() { mLastUsed = PR_IntervalNow(); mExpired = PR_FALSE; }
 
   nsExpirationState mExpiration;
   nsExpirationState* GetExpirationState() { return &mExpiration; }
 
   PRIntervalTime mLastUsed;
@@ -205,16 +207,20 @@ static const struct Test {
   TestFunc    func;
 } tests[] = {
   DECL_TEST(test_random3),
   DECL_TEST(test_random4),
   DECL_TEST(test_random8),
   { nsnull, nsnull }
 };
 
+}
+
+using namespace TestExpirationTracker;
+
 int main(int argc, char **argv) {
   int count = 1;
   if (argc > 1)
     count = atoi(argv[1]);
 
   if (NS_FAILED(NS_InitXPCOM2(nsnull, nsnull, nsnull)))
     return -1;
 
--- a/xpcom/tests/TestHashtables.cpp
+++ b/xpcom/tests/TestHashtables.cpp
@@ -42,16 +42,18 @@
 #include "nsClassHashtable.h"
 
 #include "nsCOMPtr.h"
 #include "nsISupports.h"
 #include "nsCOMArray.h"
 
 #include <stdio.h>
 
+namespace TestHashtables {
+
 class TestUniChar // for nsClassHashtable
 {
 public:
   TestUniChar(PRUint32 aWord)
   {
     printf("    TestUniChar::TestUniChar() %u\n", aWord);
     mWord = aWord;
   }
@@ -391,16 +393,20 @@ nsIEnum2(nsISupports* aKey, PRUint32& aD
   nsCAutoString str;
   nsCOMPtr<IFoo> foo = do_QueryInterface(aKey);
   foo->GetString(str);
 
   printf("  enumerated \"%s\" = %u\n", str.get(), aData);
   return PL_DHASH_NEXT;
 }
 
+}
+
+using namespace TestHashtables;
+
 int
 main(void) {
   // check an nsTHashtable
   nsTHashtable<EntityToUnicodeEntry> EntityToUnicode;
 
   printf("Initializing nsTHashtable...");
   if (!EntityToUnicode.Init(ENTITY_COUNT)) {
     printf("FAILED\n");
--- a/xpcom/tests/TestStrings.cpp
+++ b/xpcom/tests/TestStrings.cpp
@@ -36,16 +36,18 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include <stdio.h>
 #include "nsString.h"
 #include "nsStringBuffer.h"
 #include "nsReadableUtils.h"
 #include "nsCRT.h"
 
+namespace TestStrings {
+
 void test_assign_helper(const nsACString& in, nsACString &_retval)
   {
     _retval = in;
   }
 
 PRBool test_assign()
   {
     nsCString result;
@@ -934,17 +936,19 @@ tests[] =
     { "test_findcharinset", test_findcharinset },
     { "test_rfindcharinset", test_rfindcharinset },
     { "test_stringbuffer", test_stringbuffer },
     { "test_voided", test_voided },
     { "test_voided_autostr", test_voided_autostr },
     { nsnull, nsnull }
   };
 
-//----
+}
+
+using namespace TestStrings;
 
 int main(int argc, char **argv)
   {
     int count = 1;
     if (argc > 1)
       count = atoi(argv[1]);
 
     while (count--)
--- a/xpcom/tests/TestTArray.cpp
+++ b/xpcom/tests/TestTArray.cpp
@@ -44,16 +44,18 @@
 #include "nsAutoPtr.h"
 #include "nsString.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsXPCOM.h"
 #include "nsILocalFile.h"
 
+namespace TestTArray {
+
 // Define this so we can use test_basic_array in test_comptr_array
 template <class T>
 inline bool operator<(const nsCOMPtr<T>& lhs, const nsCOMPtr<T>& rhs) {
   return lhs.get() < rhs.get();
 }
 
 //----
 
@@ -513,16 +515,20 @@ static const struct Test {
   DECL_TEST(test_refptr_array),
   DECL_TEST(test_ptrarray),
 #ifdef DEBUG
   DECL_TEST(test_autoarray),
 #endif
   { nsnull, nsnull }
 };
 
+}
+
+using namespace TestTArray;
+
 int main(int argc, char **argv) {
   int count = 1;
   if (argc > 1)
     count = atoi(argv[1]);
 
   if (NS_FAILED(NS_InitXPCOM2(nsnull, nsnull, nsnull)))
     return -1;