[Libreoffice-commits] .: sw/qa
Caolán McNamara
caolan at kemper.freedesktop.org
Mon Dec 20 07:53:02 PST 2010
sw/qa/core/Test-BigPtrArray.cxx | 165 +++++++++++++++++++++-------------------
sw/qa/core/export.map | 2
sw/qa/core/makefile.mk | 19 ++--
3 files changed, 97 insertions(+), 89 deletions(-)
New commits:
commit 85a2853b681f34eb79652213bf2ca7100eb38d1e
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Dec 20 15:52:54 2010 +0000
cppcheck: make this test buildable again
diff --git a/sw/qa/core/Test-BigPtrArray.cxx b/sw/qa/core/Test-BigPtrArray.cxx
index fa7cb29..3c9efb3 100644
--- a/sw/qa/core/Test-BigPtrArray.cxx
+++ b/sw/qa/core/Test-BigPtrArray.cxx
@@ -30,9 +30,16 @@
#include "precompiled_sw.hxx"
#define TIMELOG
-#include <testshl/simpleheader.hxx>
+#include "preextstl.h"
+#include <cppunit/TestSuite.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/TestCase.h>
+#include <cppunit/plugin/TestPlugIn.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include "postextstl.h"
+
#include <bparr.hxx>
-#include <string>
+#include <string.h>
#include <stdlib.h>
#include <rtl/logfile.hxx>
@@ -43,12 +50,12 @@ using namespace std;
namespace /* private */
{
- const int NUM_ENTRIES = 100000;
+ const ULONG NUM_ENTRIES = 10;
class BigPtrEntryMock : public BigPtrEntry
{
public:
- BigPtrEntryMock(int count) : count_(count)
+ BigPtrEntryMock(ULONG count) : count_(count)
{
}
@@ -59,12 +66,12 @@ namespace /* private */
#endif
}
- int getCount() const
+ ULONG getCount() const
{
return count_;
}
- void setCount(int newCount)
+ void setCount(ULONG newCount)
{
count_ = newCount;
}
@@ -75,7 +82,7 @@ namespace /* private */
}
private:
- int count_;
+ ULONG count_;
};
BOOL AddToCount(const ElementPtr& rElem, void* pArgs)
@@ -92,12 +99,14 @@ namespace /* private */
printf("bparr[%i,%i]: %i\n", i, static_cast<BigPtrEntryMock*>(bparr[i])->Position(), static_cast<BigPtrEntryMock*>(bparr[i])->getCount());
printf("\n");
+ #else
+ (void)bparr;
#endif
}
void fillBigPtrArray(BigPtrArray& bparr, ULONG numEntries)
{
- for (int i = 0; i < numEntries; i++)
+ for (ULONG i = 0; i < numEntries; i++)
bparr.Insert(new BigPtrEntryMock(i), bparr.Count());
}
@@ -105,12 +114,14 @@ namespace /* private */
{
#ifdef ENABLE_DEBUG_OUTPUT
printf(name);
+ #else
+ (void)name;
#endif
}
bool checkElementPositions(const BigPtrArray& bparr)
{
- for (int i = 0; i < bparr.Count(); i++)
+ for (ULONG i = 0; i < bparr.Count(); i++)
{
if (static_cast<BigPtrEntryMock*>(bparr[i])->Position() != i)
return false;
@@ -120,7 +131,7 @@ namespace /* private */
void releaseBigPtrArrayContent(BigPtrArray& bparr)
{
- for (int i = 0; i < bparr.Count(); i++)
+ for (ULONG i = 0; i < bparr.Count(); i++)
delete bparr[i];
}
@@ -161,7 +172,7 @@ public:
BigPtrArray bparr;
- for (int i = 0; i < NUM_ENTRIES; i++)
+ for (ULONG i = 0; i < NUM_ENTRIES; i++)
{
ULONG oldCount = bparr.Count();
bparr.Insert(new BigPtrEntryMock(i), 0);
@@ -169,25 +180,25 @@ public:
(
"test_insert_entries_at_front failed",
(bparr.Count() == oldCount + 1)
- )
+ );
}
RTL_LOGFILE_CONTEXT_TRACE(logFile, "END: test_insert_entries_at_front");
- for (int i = 0, j = NUM_ENTRIES - 1; i < NUM_ENTRIES; i++, j--)
+ for (ULONG i = 0, j = NUM_ENTRIES - 1; i < NUM_ENTRIES; i++, j--)
{
CPPUNIT_ASSERT_MESSAGE
(
"test_insert_entries_at_front failed",
static_cast<BigPtrEntryMock*>(bparr[i])->getCount() == j
- )
+ );
}
CPPUNIT_ASSERT_MESSAGE
(
"test_insert_entries_at_front failed",
checkElementPositions(bparr)
- )
+ );
releaseBigPtrArrayContent(bparr);
dumpBigPtrArray(bparr);
@@ -214,13 +225,13 @@ public:
(
"test_insert_entries_in_the_middle failed",
(oldCount + 1 == bparr.Count() && static_cast<BigPtrEntryMock*>(bparr[bparr.Count() / 2])->getCount() == NUM_ENTRIES)
- )
+ );
CPPUNIT_ASSERT_MESSAGE
(
"test_insert_entries_in_the_middle failed",
checkElementPositions(bparr)
- )
+ );
releaseBigPtrArrayContent(bparr);
dumpBigPtrArray(bparr);
@@ -237,9 +248,9 @@ public:
fillBigPtrArray(bparr, NUM_ENTRIES);
dumpBigPtrArray(bparr);
- int oldCount = bparr.Count();
+ ULONG oldCount = bparr.Count();
- for (int i = 0, j = -5; i < 5; i++, j++)
+ for (ULONG i = 0, j = -5; i < 5; i++, j++)
bparr.Insert(new BigPtrEntryMock(j), i);
RTL_LOGFILE_CONTEXT_TRACE(logFile, "END: test_insert_at_already_used_index");
@@ -248,22 +259,22 @@ public:
(
"test_insert_at_already_used_index failed",
(oldCount + 5 == bparr.Count())
- )
+ );
- for (int i = 0, j = -5; i < bparr.Count(); i++, j++)
+ for (ULONG i = 0, j = -5; i < bparr.Count(); i++, j++)
{
CPPUNIT_ASSERT_MESSAGE
(
"test_insert_at_already_used_index failed",
static_cast<BigPtrEntryMock*>(bparr[i])->getCount() == j
- )
+ );
}
CPPUNIT_ASSERT_MESSAGE
(
"test_insert_at_already_used_index failed",
checkElementPositions(bparr)
- )
+ );
releaseBigPtrArrayContent(bparr);
dumpBigPtrArray(bparr);
@@ -285,13 +296,13 @@ public:
(
"test_insert_at_end failed",
(oldCount + 1 == bparr.Count() && static_cast<BigPtrEntryMock*>(bparr[bparr.Count()-1])->getCount() == NUM_ENTRIES)
- )
+ );
CPPUNIT_ASSERT_MESSAGE
(
"test_insert_at_end failed",
checkElementPositions(bparr)
- )
+ );
releaseBigPtrArrayContent(bparr);
dumpBigPtrArray(bparr);
@@ -308,7 +319,7 @@ public:
fillBigPtrArray(bparr, NUM_ENTRIES);
dumpBigPtrArray(bparr);
- for (int i = 0; i < NUM_ENTRIES; i++)
+ for (ULONG i = 0; i < NUM_ENTRIES; i++)
{
ULONG oldCount = bparr.Count();
@@ -319,22 +330,22 @@ public:
(
"test_remove_at_front failed (wrong count)",
(oldCount - 1 == bparr.Count())
- )
+ );
- for (int j = 0, k = i + 1; j < bparr.Count(); j++, k++)
+ for (ULONG j = 0, k = i + 1; j < bparr.Count(); j++, k++)
{
CPPUNIT_ASSERT_MESSAGE
(
"test_remove_at_front failed",
static_cast<BigPtrEntryMock*>(bparr[j])->getCount() == k
- )
+ );
}
CPPUNIT_ASSERT_MESSAGE
(
"test_remove_at_front failed",
checkElementPositions(bparr)
- )
+ );
dumpBigPtrArray(bparr);
}
@@ -361,22 +372,22 @@ public:
(
"test_remove_at_back failed (wrong count)",
(oldCount - 1 == bparr.Count())
- )
+ );
- for (int j = 0; j < bparr.Count(); j++)
+ for (ULONG j = 0; j < bparr.Count(); j++)
{
CPPUNIT_ASSERT_MESSAGE
(
"test_remove_at_back failed",
static_cast<BigPtrEntryMock*>(bparr[j])->getCount() == j
- )
+ );
}
CPPUNIT_ASSERT_MESSAGE
(
"test_remove_at_back failed",
checkElementPositions(bparr)
- )
+ );
dumpBigPtrArray(bparr);
}
@@ -396,7 +407,7 @@ public:
while (bparr.Count())
{
ULONG oldCount = bparr.Count();
- int oldElement = static_cast<BigPtrEntryMock*>(bparr[bparr.Count() / 2])->getCount();
+ ULONG oldElement = static_cast<BigPtrEntryMock*>(bparr[bparr.Count() / 2])->getCount();
delete bparr[bparr.Count() / 2];
bparr.Remove(bparr.Count() / 2);
@@ -405,22 +416,22 @@ public:
(
"test_remove_in_the_middle failed (wrong count)",
(oldCount - 1 == bparr.Count())
- )
+ );
- for (int i = 0; i < bparr.Count(); i++)
+ for (ULONG i = 0; i < bparr.Count(); i++)
{
CPPUNIT_ASSERT_MESSAGE
(
"test_remove_in_the_middle failed",
static_cast<BigPtrEntryMock*>(bparr[i])->getCount() != oldElement
- )
+ );
}
CPPUNIT_ASSERT_MESSAGE
(
"test_remove_in_the_middle failed",
checkElementPositions(bparr)
- )
+ );
dumpBigPtrArray(bparr);
}
@@ -441,7 +452,7 @@ public:
ULONG nRemove = (bparr.Count() > 3) ? 3 : bparr.Count();
ULONG oldCount = bparr.Count();
- for (int i = 0; i < nRemove; i++)
+ for (ULONG i = 0; i < nRemove; i++)
delete bparr[i];
bparr.Remove(0, nRemove);
@@ -450,13 +461,13 @@ public:
(
"test_remove_multiple_elements_at_once failed",
(oldCount - nRemove == bparr.Count())
- )
+ );
CPPUNIT_ASSERT_MESSAGE
(
"test_remove_multiple_elements_at_once failed",
checkElementPositions(bparr)
- )
+ );
dumpBigPtrArray(bparr);
}
@@ -478,7 +489,7 @@ public:
(
"test_remove_all_elements_at_once failed",
bparr.Count() == 0
- )
+ );
dumpBigPtrArray(bparr);
}
@@ -492,32 +503,32 @@ public:
fillBigPtrArray(bparr, NUM_ENTRIES);
dumpBigPtrArray(bparr);
- for (int i = 0; i < NUM_ENTRIES - 1; i++)
+ for (ULONG i = 0; i < NUM_ENTRIES - 1; i++)
{
bparr.Move(i, i + 2);
dumpBigPtrArray(bparr);
}
- for (int i = 0; i < (NUM_ENTRIES - 1); i++)
+ for (ULONG i = 0; i < (NUM_ENTRIES - 1); i++)
{
CPPUNIT_ASSERT_MESSAGE
(
"test_move_elements_from_lower_to_higher_pos failed",
static_cast<BigPtrEntryMock*>(bparr[i])->getCount() == (i + 1)
- )
+ );
}
CPPUNIT_ASSERT_MESSAGE
(
"test_move_elements_from_lower_to_higher_pos failed",
static_cast<BigPtrEntryMock*>(bparr[NUM_ENTRIES -1])->getCount() == 0
- )
+ );
CPPUNIT_ASSERT_MESSAGE
(
"test_move_elements_from_lower_to_higher_pos failed",
checkElementPositions(bparr)
- )
+ );
releaseBigPtrArrayContent(bparr);
}
@@ -541,22 +552,22 @@ public:
(
"test_move_elements_from_higher_to_lower_pos failed",
static_cast<BigPtrEntryMock*>(bparr[0])->getCount() == (NUM_ENTRIES - 1)
- )
+ );
- for (int i = 1; i < NUM_ENTRIES; i++)
+ for (ULONG i = 1; i < NUM_ENTRIES; i++)
{
CPPUNIT_ASSERT_MESSAGE
(
"test_move_elements_from_higher_to_lower_pos failed",
static_cast<BigPtrEntryMock*>(bparr[i])->getCount() == (i - 1)
- )
+ );
}
CPPUNIT_ASSERT_MESSAGE
(
"test_move_elements_from_higher_to_lower_pos failed",
checkElementPositions(bparr)
- )
+ );
releaseBigPtrArrayContent(bparr);
}
@@ -570,27 +581,27 @@ public:
fillBigPtrArray(bparr, NUM_ENTRIES);
dumpBigPtrArray(bparr);
- for (int i = 0; i < NUM_ENTRIES; i++)
+ for (ULONG i = 0; i < NUM_ENTRIES; i++)
{
bparr.Move(i, i);
}
dumpBigPtrArray(bparr);
- for (int i = 0; i < NUM_ENTRIES; i++)
+ for (ULONG i = 0; i < NUM_ENTRIES; i++)
{
CPPUNIT_ASSERT_MESSAGE
(
"test_move_to_same_position failed",
static_cast<BigPtrEntryMock*>(bparr[i])->getCount() == i
- )
+ );
}
CPPUNIT_ASSERT_MESSAGE
(
"test_move_to_same_position failed",
checkElementPositions(bparr)
- )
+ );
releaseBigPtrArrayContent(bparr);
dumpBigPtrArray(bparr);
@@ -605,27 +616,27 @@ public:
fillBigPtrArray(bparr, NUM_ENTRIES);
dumpBigPtrArray(bparr);
- for (int i = 0, j = NUM_ENTRIES - 1; i < NUM_ENTRIES; i++, j--)
+ for (ULONG i = 0, j = NUM_ENTRIES - 1; i < NUM_ENTRIES; i++, j--)
{
delete bparr[i];
bparr.Replace(i, new BigPtrEntryMock(j));
dumpBigPtrArray(bparr);
}
- for (int i = 0; i < NUM_ENTRIES; i++)
+ for (ULONG i = 0; i < NUM_ENTRIES; i++)
{
CPPUNIT_ASSERT_MESSAGE
(
"test_replace_elements failed",
static_cast<BigPtrEntryMock*>(bparr[i])->getCount() == (NUM_ENTRIES - i - 1)
- )
+ );
}
CPPUNIT_ASSERT_MESSAGE
(
"test_replace_elements failed",
checkElementPositions(bparr)
- )
+ );
releaseBigPtrArrayContent(bparr);
}
@@ -642,13 +653,13 @@ public:
int addCount = 1;
bparr.ForEach(AddToCount, &addCount);
- for (int i = 0; i < NUM_ENTRIES; i++)
+ for (ULONG i = 0; i < NUM_ENTRIES; i++)
{
CPPUNIT_ASSERT_MESSAGE
(
"test_for_each failed",
static_cast<BigPtrEntryMock*>(bparr[i])->getCount() == (i+1)
- )
+ );
}
releaseBigPtrArrayContent(bparr);
@@ -657,24 +668,24 @@ public:
void test_for_some1()
{
- printMethodName("test_for_some1\n");
+ printMethodName("test_for_some1\n");
BigPtrArray bparr;
fillBigPtrArray(bparr, NUM_ENTRIES);
dumpBigPtrArray(bparr);
- int addCount = 1;
+ ULONG addCount = 1;
bparr.ForEach(0, NUM_ENTRIES / 2, AddToCount, &addCount);
- int i = 0;
+ ULONG i = 0;
for (/* */; i < NUM_ENTRIES / 2; i++)
{
CPPUNIT_ASSERT_MESSAGE
(
"test_for_some1 failed",
static_cast<BigPtrEntryMock*>(bparr[i])->getCount() == (i+1)
- )
+ );
}
for (/* */; i < NUM_ENTRIES; i++)
@@ -683,7 +694,7 @@ public:
(
"test_for_some1 failed",
static_cast<BigPtrEntryMock*>(bparr[i])->getCount() == (i)
- )
+ );
}
releaseBigPtrArrayContent(bparr);
@@ -702,14 +713,14 @@ public:
int addCount = 1;
bparr.ForEach(NUM_ENTRIES / 2, NUM_ENTRIES, AddToCount, &addCount);
- int i = 0;
+ ULONG i = 0;
for (/* */; i < NUM_ENTRIES / 2; i++)
{
CPPUNIT_ASSERT_MESSAGE
(
"test_for_some2 failed",
static_cast<BigPtrEntryMock*>(bparr[i])->getCount() == (i)
- )
+ );
}
for (/* */; i < NUM_ENTRIES; i++)
@@ -718,7 +729,7 @@ public:
(
"test_for_some2 failed",
static_cast<BigPtrEntryMock*>(bparr[i])->getCount() == (i+1)
- )
+ );
}
releaseBigPtrArrayContent(bparr);
@@ -734,16 +745,16 @@ public:
fillBigPtrArray(bparr, NUM_ENTRIES);
dumpBigPtrArray(bparr);
- int addCount = 1;
+ ULONG addCount = 1;
bparr.ForEach(0, 0, AddToCount, &addCount);
- for (int i = 0; i < NUM_ENTRIES; i++)
+ for (ULONG i = 0; i < NUM_ENTRIES; i++)
{
CPPUNIT_ASSERT_MESSAGE
(
"test_for_some3 failed",
static_cast<BigPtrEntryMock*>(bparr[i])->getCount() == i
- )
+ );
}
releaseBigPtrArrayContent(bparr);
}
@@ -868,12 +879,10 @@ private:
}
};
-
-//#####################################
// register test suites
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(BigPtrArrayUnittest, "BigPtrArrayUnittest");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(BigPtrArrayPerformanceTest, "BigPtrArrayPerformanceTest");
+CPPUNIT_TEST_SUITE_REGISTRATION(BigPtrArrayUnittest);
+CPPUNIT_TEST_SUITE_REGISTRATION(BigPtrArrayPerformanceTest);
-NOADDITIONAL;
+CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/core/export.map b/sw/qa/core/export.map
index f313c44..0dbbcc5 100644
--- a/sw/qa/core/export.map
+++ b/sw/qa/core/export.map
@@ -27,7 +27,7 @@
UDK_3_0_0 {
global:
- registerAllTestFunction;
+ cppunitTestPlugIn;
local:
*;
diff --git a/sw/qa/core/makefile.mk b/sw/qa/core/makefile.mk
index 00ebfda..295eca0 100644
--- a/sw/qa/core/makefile.mk
+++ b/sw/qa/core/makefile.mk
@@ -28,8 +28,6 @@ PRJ=..$/..
PRJNAME=sw
TARGET=test-bigptrarray
-# this is removed at the moment because we need some enhancements
-# TESTDIR=TRUE
ENABLE_EXCEPTIONS=TRUE
@@ -37,16 +35,17 @@ ENABLE_EXCEPTIONS=TRUE
.INCLUDE : settings.mk
-CFLAGSCXX += $(CPPUNIT_CFLAGS)
-
-# BEGIN ----------------------------------------------------------------
-# auto generated Target:testjob by codegen.pl
-
-.IF "$(GUI)" == "WNT"
- CFLAGS+=/Ob1
+#building with stlport, but cppunit was not built with stlport
+.IF "$(USE_SYSTEM_STL)"!="YES"
+.IF "$(SYSTEM_CPPUNIT)"=="YES"
+CFLAGSCXX+=-DADAPT_EXT_STL
.ENDIF
+.ENDIF
+
+CFLAGSCXX += $(CPPUNIT_CFLAGS)
-SHL1OBJS=$(SLO)$/Test-BigPtrArray.obj \
+SHL1OBJS=\
+ $(SLO)$/Test-BigPtrArray.obj \
$(SLO)$/bparr.obj
SHL1TARGET=$(TARGET)
More information about the Libreoffice-commits
mailing list