summaryrefslogtreecommitdiff
path: root/sal/qa/rtl/random
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2010-11-28 21:23:54 +0000
committerCaolán McNamara <caolanm@redhat.com>2010-11-28 21:23:54 +0000
commit7d71a684e14218f81f8f84ef93c6041b72324211 (patch)
tree61bd53eca4be59477fca55abb6bc559420659918 /sal/qa/rtl/random
parentd745ce53ceab949666e9ce683f7e07778c817702 (diff)
make these cppunit tests buildable again
Diffstat (limited to 'sal/qa/rtl/random')
-rw-r--r--sal/qa/rtl/random/makefile.mk19
-rw-r--r--sal/qa/rtl/random/rtl_random.cxx118
2 files changed, 71 insertions, 66 deletions
diff --git a/sal/qa/rtl/random/makefile.mk b/sal/qa/rtl/random/makefile.mk
index cd57ec9bcc13..cb79ff90a770 100644
--- a/sal/qa/rtl/random/makefile.mk
+++ b/sal/qa/rtl/random/makefile.mk
@@ -28,8 +28,6 @@ PRJ=..$/..$/..
PRJNAME=sal
TARGET=qa_rtl_random
-# this is removed at the moment because we need some enhancements
-# TESTDIR=TRUE
ENABLE_EXCEPTIONS=TRUE
@@ -37,13 +35,16 @@ ENABLE_EXCEPTIONS=TRUE
.INCLUDE : settings.mk
-CFLAGS+= $(LFS_CFLAGS)
-CXXFLAGS+= $(LFS_CFLAGS)
+#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)
+DLLPRE = # no leading "lib" on .so files
-# BEGIN ----------------------------------------------------------------
-# auto generated Target:job by codegen.pl
SHL1OBJS= \
$(SLO)$/rtl_random.obj
@@ -53,12 +54,10 @@ SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB)
SHL1IMPLIB= i$(SHL1TARGET)
DEF1NAME =$(SHL1TARGET)
SHL1VERSIONMAP= $(PRJ)$/qa$/export.map
-# auto generated Target:job
-# END ------------------------------------------------------------------
#------------------------------- All object files -------------------------------
-# do this here, so we get right dependencies
-# SLOFILES=$(SHL1OBJS)
+SLOFILES= \
+ $(SHL1OBJS)
# --- Targets ------------------------------------------------------
diff --git a/sal/qa/rtl/random/rtl_random.cxx b/sal/qa/rtl/random/rtl_random.cxx
index 3b9442bea115..9a4690543599 100644
--- a/sal/qa/rtl/random/rtl_random.cxx
+++ b/sal/qa/rtl/random/rtl_random.cxx
@@ -29,13 +29,21 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sal.hxx"
-// autogenerated file with codegen.pl
-#include <algorithm> // STL
+#include <algorithm>
-#include <testshl/simpleheader.hxx>
+#include "preextstl.h"
+#include <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+#include "postextstl.h"
+
+#include <osl/diagnose.h>
#include <rtl/random.h>
+#include <string.h>
+
namespace rtl_random
{
@@ -161,7 +169,7 @@ public:
rtl_random_addBytes(aPool, pBuffer, nBufLen);
- t_print("%2x %2x %2x %2x\n", pBuffer[0], pBuffer[1], pBuffer[2], pBuffer[3]);
+ printf("%2x %2x %2x %2x\n", pBuffer[0], pBuffer[1], pBuffer[2], pBuffer[3]);
rtl_random_destroyPool(aPool);
delete [] pBuffer;
@@ -191,57 +199,62 @@ class Statistics
public:
void clearDispensation()
+ {
+ for (int i = 0;i < 256;++i) // clear array
{
- for (int i = 0;i < 256;i ++) // clear array
- {
- m_nDispensation[i] = 0;
- }
+ m_nDispensation[i] = 0;
}
+ }
Statistics()
- {
- clearDispensation();
- }
+ : m_nMin(0)
+ , m_nMax(0)
+ , m_nAverage(0)
+ , m_nMinDeviation(0)
+ , m_nMaxDeviation(0)
+ {
+ clearDispensation();
+ }
~Statistics(){}
void addValue(sal_Int16 _nIndex, sal_Int32 _nValue)
- {
- OSL_ASSERT(_nIndex >= 0 && _nIndex < 256);
- m_nDispensation[_nIndex] += _nValue;
- }
+ {
+ OSL_ASSERT(_nIndex >= 0 && _nIndex < 256);
+ m_nDispensation[_nIndex] += _nValue;
+ }
void build(sal_Int32 _nCountMax)
- {
- m_nMin = _nCountMax;
- m_nMax = 0;
+ {
+ m_nMin = _nCountMax;
+ m_nMax = 0;
- m_nAverage = _nCountMax / 256;
+ m_nAverage = _nCountMax / 256;
- m_nMinDeviation = _nCountMax;
- m_nMaxDeviation = 0;
+ m_nMinDeviation = _nCountMax;
+ m_nMaxDeviation = 0;
- for (int i = 0;i < 256;i ++) // show dispensation
- {
- m_nMin = std::min(m_nMin, m_nDispensation[i]);
- m_nMax = std::max(m_nMax, m_nDispensation[i]);
+ for (int i = 0;i < 256;++i) // show dispensation
+ {
+ m_nMin = std::min(m_nMin, m_nDispensation[i]);
+ m_nMax = std::max(m_nMax, m_nDispensation[i]);
- m_nMinDeviation = std::min(m_nMinDeviation, abs(m_nAverage - m_nDispensation[i]));
- m_nMaxDeviation = std::max(m_nMaxDeviation, abs(m_nAverage - m_nDispensation[i]));
- }
+ m_nMinDeviation = std::min(m_nMinDeviation, abs(m_nAverage - m_nDispensation[i]));
+ m_nMaxDeviation = std::max(m_nMaxDeviation, abs(m_nAverage - m_nDispensation[i]));
}
+ }
void print()
- {
- // LLA: these are only info values
- t_print("\nSome statistics\n");
- t_print("Min: %d\n", m_nMin);
- t_print("Max: %d\n", m_nMax);
- t_print("Average: %d\n", m_nAverage);
- t_print("Min abs deviation: %d\n", m_nMinDeviation);
- t_print("Max abs deviation: %d\n", m_nMaxDeviation);
- }
+ {
+ // LLA: these are only info values
+ printf("\nSome statistics\n");
+ printf("Min: %d\n", m_nMin);
+ printf("Max: %d\n", m_nMax);
+ printf("Average: %d\n", m_nAverage);
+ printf("Min abs deviation: %d\n", m_nMinDeviation);
+ printf("Max abs deviation: %d\n", m_nMaxDeviation);
+ }
- sal_Int32 getAverage() {return m_nAverage;}
- sal_Int32 getMaxDeviation() {return m_nMaxDeviation;}
+ sal_Int32 getAverage() const {return m_nAverage;}
+ sal_Int32 getMaxDeviation() const {return m_nMaxDeviation;}
};
@@ -290,7 +303,7 @@ public:
rtlRandomError aError = rtl_random_getBytes(aPool, pBuffer, nBufLen);
CPPUNIT_ASSERT_MESSAGE("wrong parameter", aError == rtl_Random_E_None);
- t_print("%2x %2x %2x %2x\n", pBuffer[0], pBuffer[1], pBuffer[2], pBuffer[3]);
+ printf("%2x %2x %2x %2x\n", pBuffer[0], pBuffer[1], pBuffer[2], pBuffer[3]);
rtl_random_destroyPool(aPool);
delete [] pBuffer;
@@ -309,7 +322,7 @@ public:
rtlRandomError aError = rtl_random_getBytes(aPool, pBuffer, nBufLen);
CPPUNIT_ASSERT_MESSAGE("wrong parameter", aError == rtl_Random_E_None);
- t_print("%2x %2x %2x %2x %2x %2x %2x %2x\n", pBuffer[0], pBuffer[1], pBuffer[2], pBuffer[3], pBuffer[4], pBuffer[5], pBuffer[6], pBuffer[7]);
+ printf("%2x %2x %2x %2x %2x %2x %2x %2x\n", pBuffer[0], pBuffer[1], pBuffer[2], pBuffer[3], pBuffer[4], pBuffer[5], pBuffer[6], pBuffer[7]);
CPPUNIT_ASSERT_MESSAGE("internal memory overwrite", pBuffer[4] == 0 && pBuffer[5] == 0 && pBuffer[6] == 0 && pBuffer[7] == 0);
@@ -332,7 +345,7 @@ public:
int nCount = 0;
int nCountMax = 1000000;
- for(nCount = 0;nCount < nCountMax; nCount ++) // run 100000000 through getBytes(...)
+ for(nCount = 0;nCount < nCountMax; ++nCount) // run 100000000 through getBytes(...)
{
/* rtlRandomError aError = */ rtl_random_getBytes(aPool, pBuffer, nBufLen);
/* CPPUNIT_ASSERT_MESSAGE("wrong parameter", aError == rtl_Random_E_None); */
@@ -364,15 +377,13 @@ public:
int nCount = 0;
int nCountMax = 10000;
- for(nCount = 0;nCount < nCountMax; nCount ++) // run 100000000 through getBytes(...)
+ for(nCount = 0;nCount < nCountMax; ++nCount) // run 100000000 through getBytes(...)
{
/* rtlRandomError aError = */ rtl_random_getBytes(aPool, pBuffer, nBufLen);
// CPPUNIT_ASSERT_MESSAGE("wrong parameter", aError == rtl_Random_E_None);
- for (sal_uInt32 i=0;i<nBufLen;i++)
- {
+ for (sal_uInt32 i=0;i<nBufLen;++i)
aStat.addValue(pBuffer[i], 1);
- }
}
aStat.build(nCountMax * nBufLen);
@@ -398,17 +409,12 @@ public:
}; // class getBytes
// -----------------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_random::createPool, "rtl_random");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_random::destroyPool, "rtl_random");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_random::addBytes, "rtl_random");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_random::getBytes, "rtl_random");
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_random::createPool);
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_random::destroyPool);
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_random::addBytes);
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_random::getBytes);
} // namespace rtl_random
-
-// -----------------------------------------------------------------------------
-
-// this macro creates an empty function, which will called by the RegisterAllFunctions()
-// to let the user the possibility to also register some functions by hand.
-NOADDITIONAL;
+CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */