michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "TestHarness.h" michael@0: #include "nsDeque.h" michael@0: #include "nsCRT.h" michael@0: #include michael@0: michael@0: /************************************************************** michael@0: Now define the token deallocator class... michael@0: **************************************************************/ michael@0: class _TestDeque { michael@0: public: michael@0: int Test(); michael@0: private: michael@0: int OriginalTest(); michael@0: int OriginalFlaw(); michael@0: int AssignFlaw(); michael@0: int TestRemove(); michael@0: }; michael@0: michael@0: class _Dealloc: public nsDequeFunctor { michael@0: virtual void* operator()(void* aObject) { michael@0: return 0; michael@0: } michael@0: }; michael@0: michael@0: #define TEST(aCondition, aMsg) \ michael@0: if (!(aCondition)) { fail("TestDeque: "#aMsg); return 1; } michael@0: michael@0: michael@0: /** michael@0: * conduct automated self test for this class michael@0: * michael@0: * @param michael@0: * @return michael@0: */ michael@0: int _TestDeque::Test() { michael@0: /* the old deque should have failed a bunch of these tests */ michael@0: int results=0; michael@0: results+=OriginalTest(); michael@0: results+=OriginalFlaw(); michael@0: results+=AssignFlaw(); michael@0: results+=TestRemove(); michael@0: return results; michael@0: } michael@0: michael@0: int _TestDeque::OriginalTest() { michael@0: const int size = 200; michael@0: int ints[size]; michael@0: int i=0; michael@0: int temp; michael@0: nsDeque theDeque(new _Dealloc); //construct a simple one... michael@0: michael@0: // ints = [0...199] michael@0: for (i=0;i