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