summaryrefslogtreecommitdiff
path: root/sal
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
parentd745ce53ceab949666e9ce683f7e07778c817702 (diff)
make these cppunit tests buildable again
Diffstat (limited to 'sal')
-rw-r--r--sal/qa/rtl/digest/makefile.mk15
-rw-r--r--sal/qa/rtl/digest/rtl_digest.cxx121
-rw-r--r--sal/qa/rtl/random/makefile.mk19
-rw-r--r--sal/qa/rtl/random/rtl_random.cxx118
4 files changed, 141 insertions, 132 deletions
diff --git a/sal/qa/rtl/digest/makefile.mk b/sal/qa/rtl/digest/makefile.mk
index 415183b7e9a0..feb76ffe2d40 100644
--- a/sal/qa/rtl/digest/makefile.mk
+++ b/sal/qa/rtl/digest/makefile.mk
@@ -29,8 +29,6 @@ INCPRE+= $(PRJ)$/qa$/inc
PRJNAME=sal
TARGET=rtl_digest
-# this is removed at the moment because we need some enhancements
-# TESTDIR=TRUE
ENABLE_EXCEPTIONS=TRUE
@@ -38,10 +36,15 @@ 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
#----------------------------------- OStringBuffer -----------------------------------
@@ -56,8 +59,8 @@ DEF1NAME= $(SHL1TARGET)
SHL1VERSIONMAP = $(PRJ)$/qa$/export.map
#------------------------------- All object files -------------------------------
-# do this here, so we get right dependencies
-# SLOFILES=$(SHL1OBJS)
+SLOFILES= \
+ $(SHL1OBJS)
# --- Targets ------------------------------------------------------
diff --git a/sal/qa/rtl/digest/rtl_digest.cxx b/sal/qa/rtl/digest/rtl_digest.cxx
index 8a5c0a5e8465..e8da82fd9ef8 100644
--- a/sal/qa/rtl/digest/rtl_digest.cxx
+++ b/sal/qa/rtl/digest/rtl_digest.cxx
@@ -29,13 +29,21 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sal.hxx"
-#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 <rtl/digest.h>
#include <rtl/ustring.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/strbuf.hxx>
+#include <string.h>
+
// sample, how to use digest
rtl::OUString CreateMD5FromString( const rtl::OUString& aMsg )
@@ -58,7 +66,7 @@ rtl::OUString CreateMD5FromString( const rtl::OUString& aMsg )
// Create hex-value string from the MD5 value to keep the string size minimal
rtl::OUStringBuffer aBuffer( nMD5KeyLen * 2 + 1 );
- for ( sal_uInt32 i = 0; i < nMD5KeyLen; i++ )
+ for ( sal_uInt32 i = 0; i < nMD5KeyLen; ++i )
aBuffer.append( (sal_Int32)pMD5KeyBuffer[i], 16 );
delete [] pMD5KeyBuffer;
@@ -134,7 +142,7 @@ public:
void create_007()
{
rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmInvalid );
- t_print("Handle is %x\n", handle);
+ printf("Handle is %p\n", handle);
CPPUNIT_ASSERT_MESSAGE("create with NULL", handle == 0);
rtl_digest_destroy( handle );
}
@@ -437,7 +445,7 @@ public:
rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
- // t_print("nAlgoLength:=%d\n", nAlgoLength);
+ // printf("nAlgoLength:=%d\n", nAlgoLength);
CPPUNIT_ASSERT_MESSAGE("query Length", RTL_DIGEST_LENGTH_MD5 == nAlgoLength);
rtl_digest_destroy( handle );
@@ -447,7 +455,7 @@ public:
rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
- // t_print("nAlgoLength:=%d\n", nAlgoLength);
+ // printf("nAlgoLength:=%d\n", nAlgoLength);
CPPUNIT_ASSERT_MESSAGE("query length", RTL_DIGEST_LENGTH_MD2 == nAlgoLength);
rtl_digest_destroy( handle );
@@ -457,7 +465,7 @@ public:
rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA );
sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
- // t_print("nAlgoLength:=%d\n", nAlgoLength);
+ // printf("nAlgoLength:=%d\n", nAlgoLength);
CPPUNIT_ASSERT_MESSAGE("query length", RTL_DIGEST_LENGTH_SHA == nAlgoLength);
rtl_digest_destroy( handle );
@@ -467,7 +475,7 @@ public:
rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA1 );
sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
- // t_print("nAlgoLength:=%d\n", nAlgoLength);
+ // printf("nAlgoLength:=%d\n", nAlgoLength);
CPPUNIT_ASSERT_MESSAGE("query length", RTL_DIGEST_LENGTH_SHA1 == nAlgoLength);
rtl_digest_destroy( handle );
@@ -477,7 +485,7 @@ public:
rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_MD5 );
sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
- // t_print("nAlgoLength:=%d\n", nAlgoLength);
+ // printf("nAlgoLength:=%d\n", nAlgoLength);
CPPUNIT_ASSERT_MESSAGE("query length", RTL_DIGEST_LENGTH_HMAC_MD5 == nAlgoLength);
rtl_digest_destroy( handle );
@@ -487,7 +495,7 @@ public:
rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_SHA1 );
sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
- // t_print("nAlgoLength:=%d\n", nAlgoLength);
+ // printf("nAlgoLength:=%d\n", nAlgoLength);
CPPUNIT_ASSERT_MESSAGE("query length", RTL_DIGEST_LENGTH_HMAC_SHA1 == nAlgoLength);
rtl_digest_destroy( handle );
@@ -498,7 +506,7 @@ public:
rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmInvalid );
sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
- // t_print("nAlgoLength:=%d\n", nAlgoLength);
+ // printf("nAlgoLength:=%d\n", nAlgoLength);
CPPUNIT_ASSERT_MESSAGE("query length", 0 == nAlgoLength);
rtl_digest_destroy( handle );
@@ -525,13 +533,11 @@ rtl::OString createHex(sal_uInt8 *_pMD5KeyBuffer, sal_uInt32 _nMD5KeyLen)
{
// Create hex-value string from the MD5 value to keep the string size minimal
rtl::OStringBuffer aBuffer( _nMD5KeyLen * 2 + 1 );
- for ( sal_uInt32 i = 0; i < _nMD5KeyLen; i++ )
+ for ( sal_uInt32 i = 0; i < _nMD5KeyLen; ++i )
{
sal_Int32 nValue = (sal_Int32)_pMD5KeyBuffer[i];
if (nValue < 16) // maximul hex value for 1 byte
- {
- aBuffer.append( sal_Int32(0), 16 /* radix */ );
- }
+ aBuffer.append( static_cast<sal_Int32>(0), static_cast<sal_Int16>(16) /* radix */ );
aBuffer.append( nValue, 16 /* radix */ );
}
@@ -594,7 +600,7 @@ public:
rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
delete [] pKeyBuffer;
- t_print("MD2 Sum: %s\n", aSum.getStr());
+ printf("MD2 Sum: %s\n", aSum.getStr());
// LLA: how to check right values
// samples?
@@ -622,7 +628,7 @@ public:
rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
delete [] pKeyBuffer;
- t_print("MD5 Sum: %s\n", aSum.getStr());
+ printf("MD5 Sum: %s\n", aSum.getStr());
// LLA: how to check right values
// samples?
@@ -650,7 +656,7 @@ public:
rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
delete [] pKeyBuffer;
- t_print("SHA Sum: %s\n", aSum.getStr());
+ printf("SHA Sum: %s\n", aSum.getStr());
// LLA: how to check right values
// samples?
@@ -677,7 +683,7 @@ public:
rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
delete [] pKeyBuffer;
- t_print("SHA1 Sum: %s\n", aSum.getStr());
+ printf("SHA1 Sum: %s\n", aSum.getStr());
// LLA: how to check right values
// samples?
@@ -708,7 +714,7 @@ public:
rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
delete [] pKeyBuffer;
- t_print("HMAC_MD5 Sum: %s\n", aSum.getStr());
+ printf("HMAC_MD5 Sum: %s\n", aSum.getStr());
// LLA: how to check right values
// samples?
@@ -739,7 +745,7 @@ public:
rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
delete [] pKeyBuffer;
- t_print("HMAC_SHA1 Sum: %s\n", aSum.getStr());
+ printf("HMAC_SHA1 Sum: %s\n", aSum.getStr());
// LLA: how to check right values
// samples?
@@ -866,7 +872,7 @@ public:
CPPUNIT_ASSERT(aError == rtl_Digest_E_None );
rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_MD2);
- t_print("Decrypt MD2: %s\n", aStr.getStr());
+ printf("Decrypt MD2: %s\n", aStr.getStr());
CPPUNIT_ASSERT_MESSAGE("checksum of sample string is wrong. Code changes or sample problems, please check.", aStr.equals(sSampleString_MD2) );
delete [] pBuffer;
@@ -909,7 +915,7 @@ public:
CPPUNIT_ASSERT(aError == rtl_Digest_E_None );
rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_MD5);
- t_print("Decrypt MD5: %s\n", aStr.getStr());
+ printf("Decrypt MD5: %s\n", aStr.getStr());
CPPUNIT_ASSERT_MESSAGE("checksum of sample string is wrong. Code changes or sample problems, please check.", aStr.equals(sSampleString_MD5) );
delete [] pBuffer;
@@ -954,7 +960,7 @@ public:
CPPUNIT_ASSERT(aError == rtl_Digest_E_None );
rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_SHA);
- t_print("Decrypt SHA: %s\n", aStr.getStr());
+ printf("Decrypt SHA: %s\n", aStr.getStr());
CPPUNIT_ASSERT_MESSAGE("checksum of sample string is wrong. Code changes or sample problems, please check.", aStr.equals(sSampleString_SHA) );
delete [] pBuffer;
@@ -999,7 +1005,7 @@ public:
CPPUNIT_ASSERT(aError == rtl_Digest_E_None );
rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_SHA1);
- t_print("Decrypt SHA1: %s\n", aStr.getStr());
+ printf("Decrypt SHA1: %s\n", aStr.getStr());
CPPUNIT_ASSERT_MESSAGE("checksum of sample string is wrong. Code changes or sample problems, please check.", aStr.equals(sSampleString_SHA1) );
delete [] pBuffer;
@@ -1046,7 +1052,7 @@ public:
CPPUNIT_ASSERT(aError == rtl_Digest_E_None );
rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_HMAC_MD5);
- t_print("Decrypt HMAC_MD5: %s\n", aStr.getStr());
+ printf("Decrypt HMAC_MD5: %s\n", aStr.getStr());
CPPUNIT_ASSERT_MESSAGE("md5sum of sample string is wrong. Code changes or sample problems, please check.", aStr.equals(sSampleString_HMAC_MD5) );
delete [] pBuffer;
@@ -1093,7 +1099,7 @@ public:
CPPUNIT_ASSERT(aError == rtl_Digest_E_None );
rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_HMAC_SHA1);
- t_print("Decrypt HMAC_SHA1: %s\n", aStr.getStr());
+ printf("Decrypt HMAC_SHA1: %s\n", aStr.getStr());
CPPUNIT_ASSERT_MESSAGE("md5sum of sample string is wrong. Code changes or sample problems, please check.", aStr.equals(sSampleString_HMAC_SHA1) );
delete [] pBuffer;
@@ -1147,10 +1153,10 @@ public:
CPPUNIT_ASSERT(aError == rtl_Digest_E_None );
rtl::OString aKey = createHex(pKeyBuffer, nKeyLen);
- t_print("Key: %s\n", aKey.getStr());
+ printf("Key: %s\n", aKey.getStr());
// rtl::OString sSalt = createHex(pSaltData, nSaltDataLen);
- // t_print("Salt: %s\n", sSalt.getStr());
+ // printf("Salt: %s\n", sSalt.getStr());
// CPPUNIT_ASSERT_MESSAGE("md5sum of sample string is wrong. Code changes or sample problems, please check.", aStr.equals(sSampleString_PBKDF2) );
@@ -1416,39 +1422,34 @@ public:
}; // class create
// -----------------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_digest::create, "rtl_digest");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_digest::createMD2, "rtl_digest");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_digest::createMD5, "rtl_digest");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_digest::createSHA, "rtl_digest");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_digest::createSHA1, "rtl_digest");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_digest::createHMAC_MD5, "rtl_digest");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_digest::createHMAC_SHA1, "rtl_digest");
-
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_digest::destroy, "rtl_digest");
-
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_digest::queryAlgorithm, "rtl_digest");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_digest::queryLength, "rtl_digest");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_digest::init, "rtl_digest");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_digest::equalTests, "rtl_digest");
-
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_digest::digest_MD2, "rtl_digest");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_digest::digest_MD5, "rtl_digest");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_digest::digest_SHA, "rtl_digest");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_digest::digest_SHA1, "rtl_digest");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_digest::digest_HMAC_MD5, "rtl_digest");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_digest::digest_HMAC_SHA1, "rtl_digest");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_digest::digest_PBKDF2, "rtl_digest");
-
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_digest::update, "rtl_digest");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_digest::get, "rtl_digest");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_digest::destroy, "rtl_digest");
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::create);
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::createMD2);
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::createMD5);
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::createSHA);
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::createSHA1);
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::createHMAC_MD5);
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::createHMAC_SHA1);
+
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::destroy);
+
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::queryAlgorithm);
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::queryLength);
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::init);
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::equalTests);
+
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::digest_MD2);
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::digest_MD5);
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::digest_SHA);
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::digest_SHA1);
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::digest_HMAC_MD5);
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::digest_HMAC_SHA1);
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::digest_PBKDF2);
+
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::update);
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::get);
+CPPUNIT_TEST_SUITE_REGISTRATION(rtl_digest::destroy);
} // namespace rtl_digest
-
-// -----------------------------------------------------------------------------
-
-// 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: */
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: */