[Libreoffice-commits] core.git: Branch 'aoo/trunk' - 4 commits - sal/qa
Damjan Jovanovic
damjan at apache.org
Mon Aug 31 23:08:23 PDT 2015
sal/qa/rtl/alloc/makefile.mk | 29
sal/qa/rtl/alloc/rtl_alloc.cxx | 131 +--
sal/qa/rtl/crc32/makefile.mk | 29
sal/qa/rtl/crc32/rtl_crc32.cxx | 185 +---
sal/qa/rtl/digest/makefile.mk | 26
sal/qa/rtl/digest/rtl_digest.cxx | 1609 ++++++++++++++++----------------------
sal/qa/rtl/math/makefile.mk | 24
sal/qa/rtl/math/test-rtl-math.cxx | 62 -
8 files changed, 912 insertions(+), 1183 deletions(-)
New commits:
commit ec5684733172379e30fd96a88ff249e64ca60c56
Author: Damjan Jovanovic <damjan at apache.org>
Date: Tue Sep 1 05:33:02 2015 +0000
#i125003# migrate main/sal/qa/rtl/crc32 from cppunit to Google Test.
diff --git a/sal/qa/rtl/crc32/makefile.mk b/sal/qa/rtl/crc32/makefile.mk
index 1352f54..d85b27b 100644
--- a/sal/qa/rtl/crc32/makefile.mk
+++ b/sal/qa/rtl/crc32/makefile.mk
@@ -31,34 +31,29 @@ ENABLE_EXCEPTIONS=TRUE
.INCLUDE : settings.mk
+.IF "$(ENABLE_UNIT_TESTS)" != "YES"
+all:
+ @echo unit tests are disabled. Nothing to do.
+
+.ELSE
+
CFLAGS+= $(LFS_CFLAGS)
CXXFLAGS+= $(LFS_CFLAGS)
-CFLAGSCXX += $(CPPUNIT_CFLAGS)
-
# BEGIN ----------------------------------------------------------------
# auto generated Target:jobfile by codegen.pl
-SHL1OBJS= \
+APP1OBJS= \
$(SLO)$/rtl_crc32.obj
-SHL1TARGET= rtl_crc32
-SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB)
-
-SHL1IMPLIB= i$(SHL1TARGET)
-# SHL1DEF= $(MISC)$/$(SHL1TARGET).def
-
-DEF1NAME =$(SHL1TARGET)
-# DEF1EXPORTFILE= export.exp
-SHL1VERSIONMAP= $(PRJ)$/qa$/export.map
+APP1TARGET= rtl_crc32
+APP1STDLIBS= $(SALLIB) $(GTESTLIB) $(TESTSHL2LIB)
+APP1RPATH = NONE
+APP1TEST = enabled
# auto generated Target:jobfile
# END ------------------------------------------------------------------
-#------------------------------- All object files -------------------------------
-# do this here, so we get right dependencies
-# SLOFILES=$(SHL1OBJS)
-
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
-.INCLUDE : _cppunit.mk
+.ENDIF # "$(ENABLE_UNIT_TESTS)" != "YES"
diff --git a/sal/qa/rtl/crc32/rtl_crc32.cxx b/sal/qa/rtl/crc32/rtl_crc32.cxx
index 348c5e2..bcd7beb 100644
--- a/sal/qa/rtl/crc32/rtl_crc32.cxx
+++ b/sal/qa/rtl/crc32/rtl_crc32.cxx
@@ -26,152 +26,129 @@
#include "precompiled_sal.hxx"
// autogenerated file with codegen.pl
-#include <testshl/simpleheader.hxx>
+#include "gtest/gtest.h"
#include <rtl/crc.h>
namespace rtl_CRC32
{
-class test : public CppUnit::TestFixture
+class test : public ::testing::Test
{
public:
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
+}; // class test
+TEST_F(test, rtl_crc32_001)
+{
+ sal_uInt32 nCRC = 0;
- // insert your test code here.
- void rtl_crc32_001()
- {
- // this is demonstration code
- // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1);
-
- sal_uInt32 nCRC = 0;
-
- char buf[] = {0};
- int num = 0;
-
- nCRC = rtl_crc32(nCRC, buf, num);
-
- CPPUNIT_ASSERT_MESSAGE("empty crc buffer", nCRC == 0);
- }
-
- void rtl_crc32_002()
- {
- sal_uInt32 nCRC = 0;
-
- char buf[] = {0,0};
- int num = sizeof(buf);
+ char buf[] = {0};
+ int num = 0;
- nCRC = rtl_crc32(nCRC, buf, num);
+ nCRC = rtl_crc32(nCRC, buf, num);
- CPPUNIT_ASSERT_MESSAGE("buffer contain 2 empty bytes, crc is zero", nCRC != 0);
- }
+ ASSERT_TRUE(nCRC == 0) << "empty crc buffer";
+}
- void rtl_crc32_002_1()
- {
- sal_uInt32 nCRC = 0;
+TEST_F(test, rtl_crc32_002)
+{
+ sal_uInt32 nCRC = 0;
- char buf[] = {0,0,0};
- int num = sizeof(buf);
+ char buf[] = {0,0};
+ int num = sizeof(buf);
- nCRC = rtl_crc32(nCRC, buf, num);
+ nCRC = rtl_crc32(nCRC, buf, num);
- CPPUNIT_ASSERT_MESSAGE("buffer contain 3 empty bytes, crc is zero", nCRC != 0);
- }
+ ASSERT_TRUE(nCRC != 0) << "buffer contain 2 empty bytes, crc is zero";
+}
- /**
- * crc32 check:
- * Build checksum on two buffers with same size but different content,
- * the result (crc32 checksum) must differ
- */
+TEST_F(test, rtl_crc32_002_1)
+{
+ sal_uInt32 nCRC = 0;
- void rtl_crc32_003()
- {
- sal_uInt32 nCRC1 = 0;
- char buf1[] = {2};
- int num1 = sizeof(buf1);
+ char buf[] = {0,0,0};
+ int num = sizeof(buf);
- nCRC1 = rtl_crc32(nCRC1, buf1, num1);
+ nCRC = rtl_crc32(nCRC, buf, num);
- sal_uInt32 nCRC2 = 0;
- char buf2[] = {3};
- int num2 = sizeof(buf2);
+ ASSERT_TRUE(nCRC != 0) << "buffer contain 3 empty bytes, crc is zero";
+}
- nCRC2 = rtl_crc32(nCRC2, buf2, num2);
+/**
+ * crc32 check:
+ * Build checksum on two buffers with same size but different content,
+ * the result (crc32 checksum) must differ
+ */
- CPPUNIT_ASSERT_MESSAGE("checksum should differ for buf1 and buf2", nCRC1 != nCRC2);
- }
+TEST_F(test, rtl_crc32_003)
+{
+ sal_uInt32 nCRC1 = 0;
+ char buf1[] = {2};
+ int num1 = sizeof(buf1);
- /** check if the crc32 only use as much values, as given
- *
- */
- void rtl_crc32_003_1()
- {
- sal_uInt32 nCRC1 = 0;
- char buf1[] = {2,1};
- int num1 = sizeof(buf1) - 1;
+ nCRC1 = rtl_crc32(nCRC1, buf1, num1);
- nCRC1 = rtl_crc32(nCRC1, buf1, num1);
+ sal_uInt32 nCRC2 = 0;
+ char buf2[] = {3};
+ int num2 = sizeof(buf2);
- sal_uInt32 nCRC2 = 0;
- char buf2[] = {2,2};
- int num2 = sizeof(buf2) - 1;
+ nCRC2 = rtl_crc32(nCRC2, buf2, num2);
- nCRC2 = rtl_crc32(nCRC2, buf2, num2);
+ ASSERT_TRUE(nCRC1 != nCRC2) << "checksum should differ for buf1 and buf2";
+}
- CPPUNIT_ASSERT_MESSAGE("checksum leave it's bounds", nCRC1 == nCRC2);
- }
+/** check if the crc32 only use as much values, as given
+ *
+ */
+TEST_F(test, rtl_crc32_003_1)
+{
+ sal_uInt32 nCRC1 = 0;
+ char buf1[] = {2,1};
+ int num1 = sizeof(buf1) - 1;
- /** check if the crc32 differ at same content in reverse order
- *
- */
- void rtl_crc32_003_2()
- {
- sal_uInt32 nCRC1 = 0;
- char buf1[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
- int num1 = sizeof(buf1);
+ nCRC1 = rtl_crc32(nCRC1, buf1, num1);
- nCRC1 = rtl_crc32(nCRC1, buf1, num1);
+ sal_uInt32 nCRC2 = 0;
+ char buf2[] = {2,2};
+ int num2 = sizeof(buf2) - 1;
- sal_uInt32 nCRC2 = 0;
- char buf2[] = {20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0};
- int num2 = sizeof(buf2);
+ nCRC2 = rtl_crc32(nCRC2, buf2, num2);
- nCRC2 = rtl_crc32(nCRC2, buf2, num2);
+ ASSERT_TRUE(nCRC1 == nCRC2) << "checksum leave it's bounds";
+}
- CPPUNIT_ASSERT_MESSAGE("checksum should differ", nCRC1 != nCRC2);
- }
+/** check if the crc32 differ at same content in reverse order
+ *
+ */
+TEST_F(test, rtl_crc32_003_2)
+{
+ sal_uInt32 nCRC1 = 0;
+ char buf1[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
+ int num1 = sizeof(buf1);
+ nCRC1 = rtl_crc32(nCRC1, buf1, num1);
+ sal_uInt32 nCRC2 = 0;
+ char buf2[] = {20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0};
+ int num2 = sizeof(buf2);
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
+ nCRC2 = rtl_crc32(nCRC2, buf2, num2);
- CPPUNIT_TEST_SUITE(test);
- CPPUNIT_TEST(rtl_crc32_001);
- CPPUNIT_TEST(rtl_crc32_002);
- CPPUNIT_TEST(rtl_crc32_002_1);
- CPPUNIT_TEST(rtl_crc32_003);
- CPPUNIT_TEST(rtl_crc32_003_1);
- CPPUNIT_TEST(rtl_crc32_003_2);
- CPPUNIT_TEST_SUITE_END();
-}; // class test
+ ASSERT_TRUE(nCRC1 != nCRC2) << "checksum should differ";
+}
// -----------------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_CRC32::test, "rtl_crc32");
} // namespace rtl_CRC32
-
-// -----------------------------------------------------------------------------
-
-// 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;
-
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
commit e176c5d0a875d10cc9d16538ee5bd087868936ad
Author: Damjan Jovanovic <damjan at apache.org>
Date: Tue Sep 1 05:31:36 2015 +0000
#i125003# migrate main/sal/qa/rtl/digest from cppunit to Google Test.
diff --git a/sal/qa/rtl/digest/makefile.mk b/sal/qa/rtl/digest/makefile.mk
index 6d1660f..e5426b1 100644
--- a/sal/qa/rtl/digest/makefile.mk
+++ b/sal/qa/rtl/digest/makefile.mk
@@ -32,29 +32,27 @@ ENABLE_EXCEPTIONS=TRUE
.INCLUDE : settings.mk
+.IF "$(ENABLE_UNIT_TESTS)" != "YES"
+all:
+ @echo unit tests are disabled. Nothing to do.
+
+.ELSE
+
CFLAGS+= $(LFS_CFLAGS)
CXXFLAGS+= $(LFS_CFLAGS)
-CFLAGSCXX += $(CPPUNIT_CFLAGS)
-
#----------------------------------- OStringBuffer -----------------------------------
-SHL1OBJS= \
+APP1OBJS= \
$(SLO)$/rtl_digest.obj
-SHL1TARGET= rtl_digest
-SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB)
-
-SHL1IMPLIB= i$(SHL1TARGET)
-DEF1NAME= $(SHL1TARGET)
-SHL1VERSIONMAP = $(PRJ)$/qa$/export.map
-
-#------------------------------- All object files -------------------------------
-# do this here, so we get right dependencies
-# SLOFILES=$(SHL1OBJS)
+APP1TARGET= rtl_digest
+APP1STDLIBS= $(SALLIB) $(GTESTLIB) $(TESTSHL2LIB)
+APP1RPATH = NONE
+APP1TEST = enabled
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
-.INCLUDE : _cppunit.mk
+.ENDIF # "$(ENABLE_UNIT_TESTS)" != "YES"
diff --git a/sal/qa/rtl/digest/rtl_digest.cxx b/sal/qa/rtl/digest/rtl_digest.cxx
index 0499129..89e53df 100644
--- a/sal/qa/rtl/digest/rtl_digest.cxx
+++ b/sal/qa/rtl/digest/rtl_digest.cxx
@@ -24,7 +24,7 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sal.hxx"
-#include <testshl/simpleheader.hxx>
+#include "gtest/gtest.h"
#include <rtl/digest.h>
#include <rtl/ustring.hxx>
@@ -77,442 +77,381 @@ namespace rtl_digest
rtl::OString sSampleString_only_one_diff = "This is a sample sentence. which we use to check some crypto functions in sal.";
-class create : public CppUnit::TestFixture
+class create : public ::testing::Test
{
public:
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
-
- void create_001()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
- CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD5", handle != 0);
- rtl_digest_destroy( handle );
- }
- void create_002()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
- CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD2", handle != 0);
- rtl_digest_destroy( handle );
- }
- void create_003()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA );
- CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmSHA", handle != 0);
- rtl_digest_destroy( handle );
- }
- void create_004()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA1 );
- CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmSHA1", handle != 0);
- rtl_digest_destroy( handle );
- }
- void create_005()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_MD5 );
- CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmHMAC_MD5", handle != 0);
- rtl_digest_destroy( handle );
- }
- void create_006()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_SHA1 );
- CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmHMAC_SHA1", handle != 0);
- rtl_digest_destroy( handle );
- }
-
- void create_007()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmInvalid );
- t_print("Handle is %x\n", handle);
- CPPUNIT_ASSERT_MESSAGE("create with NULL", handle == 0);
- rtl_digest_destroy( handle );
- }
-
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
-
- CPPUNIT_TEST_SUITE(create);
- CPPUNIT_TEST(create_001);
- CPPUNIT_TEST(create_002);
- CPPUNIT_TEST(create_003);
- CPPUNIT_TEST(create_004);
- CPPUNIT_TEST(create_005);
- CPPUNIT_TEST(create_006);
- CPPUNIT_TEST(create_007);
- CPPUNIT_TEST_SUITE_END();
}; // class create
+TEST_F(create, create_001)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
+ ASSERT_TRUE(handle != 0) << "create with rtl_Digest_AlgorithmMD5";
+ rtl_digest_destroy( handle );
+}
+TEST_F(create, create_002)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
+ ASSERT_TRUE(handle != 0) << "create with rtl_Digest_AlgorithmMD2";
+ rtl_digest_destroy( handle );
+}
+TEST_F(create, create_003)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA );
+ ASSERT_TRUE(handle != 0) << "create with rtl_Digest_AlgorithmSHA";
+ rtl_digest_destroy( handle );
+}
+TEST_F(create, create_004)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA1 );
+ ASSERT_TRUE(handle != 0) << "create with rtl_Digest_AlgorithmSHA1";
+ rtl_digest_destroy( handle );
+}
+TEST_F(create, create_005)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_MD5 );
+ ASSERT_TRUE(handle != 0) << "create with rtl_Digest_AlgorithmHMAC_MD5";
+ rtl_digest_destroy( handle );
+}
+TEST_F(create, create_006)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_SHA1 );
+ ASSERT_TRUE(handle != 0) << "create with rtl_Digest_AlgorithmHMAC_SHA1";
+ rtl_digest_destroy( handle );
+}
+TEST_F(create, create_007)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmInvalid );
+ printf("Handle is %p\n", handle);
+ ASSERT_TRUE(handle == 0) << "create with NULL";
+ rtl_digest_destroy( handle );
+}
// -----------------------------------------------------------------------------
-class createMD5 : public CppUnit::TestFixture
+class createMD5 : public ::testing::Test
{
public:
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
+}; // class create
- void createMD5_001()
- {
- rtlDigest handle = rtl_digest_createMD5();
+TEST_F(createMD5, createMD5_001)
+{
+ rtlDigest handle = rtl_digest_createMD5();
- rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
- CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmMD5 == aAlgo);
+ rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
+ ASSERT_TRUE(rtl_Digest_AlgorithmMD5 == aAlgo) << "query handle";
- rtl_digest_destroy( handle );
- }
- CPPUNIT_TEST_SUITE(createMD5);
- CPPUNIT_TEST(createMD5_001);
- CPPUNIT_TEST_SUITE_END();
-}; // class create
+ rtl_digest_destroy( handle );
+}
// -----------------------------------------------------------------------------
-class createMD2 : public CppUnit::TestFixture
+class createMD2 : public ::testing::Test
{
public:
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
+}; // class create
- void createMD2_001()
- {
- rtlDigest handle = rtl_digest_createMD2( );
+TEST_F(createMD2, createMD2_001)
+{
+ rtlDigest handle = rtl_digest_createMD2( );
- rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
- CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmMD2 == aAlgo);
+ rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
+ ASSERT_TRUE(rtl_Digest_AlgorithmMD2 == aAlgo) << "query handle";
- rtl_digest_destroy( handle );
- }
- CPPUNIT_TEST_SUITE(createMD2);
- CPPUNIT_TEST(createMD2_001);
- CPPUNIT_TEST_SUITE_END();
-}; // class create
+ rtl_digest_destroy( handle );
+}
// -----------------------------------------------------------------------------
-class createSHA : public CppUnit::TestFixture
+class createSHA : public ::testing::Test
{
public:
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
+}; // class create
- void createSHA_001()
- {
- rtlDigest handle = rtl_digest_createSHA( );
+TEST_F(createSHA, createSHA_001)
+{
+ rtlDigest handle = rtl_digest_createSHA( );
- rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
- CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmSHA == aAlgo);
+ rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
+ ASSERT_TRUE(rtl_Digest_AlgorithmSHA == aAlgo) << "query handle";
+
+ rtl_digest_destroy( handle );
+}
- rtl_digest_destroy( handle );
- }
- CPPUNIT_TEST_SUITE(createSHA);
- CPPUNIT_TEST(createSHA_001);
- CPPUNIT_TEST_SUITE_END();
-}; // class create
// -----------------------------------------------------------------------------
-class createSHA1 : public CppUnit::TestFixture
+class createSHA1 : public ::testing::Test
{
public:
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
+}; // class create
- void createSHA1_001()
- {
- rtlDigest handle = rtl_digest_createSHA1();
+TEST_F(createSHA1, createSHA1_001)
+{
+ rtlDigest handle = rtl_digest_createSHA1();
- rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
- CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmSHA1 == aAlgo);
+ rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
+ ASSERT_TRUE(rtl_Digest_AlgorithmSHA1 == aAlgo) << "query handle";
+
+ rtl_digest_destroy( handle );
+}
- rtl_digest_destroy( handle );
- }
- CPPUNIT_TEST_SUITE(createSHA1);
- CPPUNIT_TEST(createSHA1_001);
- CPPUNIT_TEST_SUITE_END();
-}; // class create
// -----------------------------------------------------------------------------
-class createHMAC_MD5 : public CppUnit::TestFixture
+class createHMAC_MD5 : public ::testing::Test
{
public:
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
+}; // class create
- void createHMAC_MD5_001()
- {
- rtlDigest handle = rtl_digest_createHMAC_MD5();
+TEST_F(createHMAC_MD5, createHMAC_MD5_001)
+{
+ rtlDigest handle = rtl_digest_createHMAC_MD5();
- rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
- CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmHMAC_MD5 == aAlgo);
+ rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
+ ASSERT_TRUE(rtl_Digest_AlgorithmHMAC_MD5 == aAlgo) << "query handle";
+
+ rtl_digest_destroy( handle );
+}
- rtl_digest_destroy( handle );
- }
- CPPUNIT_TEST_SUITE(createHMAC_MD5);
- CPPUNIT_TEST(createHMAC_MD5_001);
- CPPUNIT_TEST_SUITE_END();
-}; // class create
// -----------------------------------------------------------------------------
-class createHMAC_SHA1 : public CppUnit::TestFixture
+class createHMAC_SHA1 : public ::testing::Test
{
public:
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
+}; // class create
- void createHMAC_SHA1_001()
- {
- rtlDigest handle = rtl_digest_createHMAC_SHA1();
-
- rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
- CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmHMAC_SHA1 == aAlgo);
-
- rtl_digest_destroy( handle );
- }
+TEST_F(createHMAC_SHA1, createHMAC_SHA1_001)
+{
+ rtlDigest handle = rtl_digest_createHMAC_SHA1();
+ rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
+ ASSERT_TRUE(rtl_Digest_AlgorithmHMAC_SHA1 == aAlgo) << "query handle";
- CPPUNIT_TEST_SUITE(createHMAC_SHA1);
- CPPUNIT_TEST(createHMAC_SHA1_001);
- CPPUNIT_TEST_SUITE_END();
-}; // class create
+ rtl_digest_destroy( handle );
+}
// -----------------------------------------------------------------------------
-class queryAlgorithm : public CppUnit::TestFixture
+class queryAlgorithm : public ::testing::Test
{
public:
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
+}; // class create
- void query_001()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
-
- rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
- CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmMD5 == aAlgo);
-
- rtl_digest_destroy( handle );
- }
- void query_002()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
+TEST_F(queryAlgorithm, query_001)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
- rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
- CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmMD2 == aAlgo);
+ rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
+ ASSERT_TRUE(rtl_Digest_AlgorithmMD5 == aAlgo) << "query handle";
- rtl_digest_destroy( handle );
- }
- void query_003()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA );
+ rtl_digest_destroy( handle );
+}
+TEST_F(queryAlgorithm, query_002)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
- rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
- CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmSHA == aAlgo);
+ rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
+ ASSERT_TRUE(rtl_Digest_AlgorithmMD2 == aAlgo) << "query handle";
- rtl_digest_destroy( handle );
- }
- void query_004()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA1 );
+ rtl_digest_destroy( handle );
+}
+TEST_F(queryAlgorithm, query_003)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA );
- rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
- CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmSHA1 == aAlgo);
+ rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
+ ASSERT_TRUE(rtl_Digest_AlgorithmSHA == aAlgo) << "query handle";
- rtl_digest_destroy( handle );
- }
- void query_005()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_MD5 );
+ rtl_digest_destroy( handle );
+}
+TEST_F(queryAlgorithm, query_004)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA1 );
- rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
- CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmHMAC_MD5 == aAlgo);
+ rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
+ ASSERT_TRUE(rtl_Digest_AlgorithmSHA1 == aAlgo) << "query handle";
- rtl_digest_destroy( handle );
- }
- void query_006()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_SHA1 );
+ rtl_digest_destroy( handle );
+}
+TEST_F(queryAlgorithm, query_005)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_MD5 );
- rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
- CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmHMAC_SHA1 == aAlgo);
+ rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
+ ASSERT_TRUE(rtl_Digest_AlgorithmHMAC_MD5 == aAlgo) << "query handle";
- rtl_digest_destroy( handle );
- }
- void query_007()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmInvalid );
+ rtl_digest_destroy( handle );
+}
+TEST_F(queryAlgorithm, query_006)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_SHA1 );
- rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
- CPPUNIT_ASSERT_MESSAGE("query handle", rtl_Digest_AlgorithmInvalid == aAlgo);
+ rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
+ ASSERT_TRUE(rtl_Digest_AlgorithmHMAC_SHA1 == aAlgo) << "query handle";
- rtl_digest_destroy( handle );
- }
+ rtl_digest_destroy( handle );
+}
+TEST_F(queryAlgorithm, query_007)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmInvalid );
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
-
- CPPUNIT_TEST_SUITE(queryAlgorithm);
- CPPUNIT_TEST( query_001 );
- CPPUNIT_TEST( query_002 );
- CPPUNIT_TEST( query_003 );
- CPPUNIT_TEST( query_004 );
- CPPUNIT_TEST( query_005 );
- CPPUNIT_TEST( query_006 );
- CPPUNIT_TEST( query_007 );
- CPPUNIT_TEST_SUITE_END();
-}; // class create
+ rtlDigestAlgorithm aAlgo = rtl_digest_queryAlgorithm(handle);
+ ASSERT_TRUE(rtl_Digest_AlgorithmInvalid == aAlgo) << "query handle";
+ rtl_digest_destroy( handle );
+}
// -----------------------------------------------------------------------------
-class queryLength : public CppUnit::TestFixture
+class queryLength : public ::testing::Test
{
public:
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
- void queryLength_MD5()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
+}; // class create
- sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
- // t_print("nAlgoLength:=%d\n", nAlgoLength);
- CPPUNIT_ASSERT_MESSAGE("query Length", RTL_DIGEST_LENGTH_MD5 == nAlgoLength);
+TEST_F(queryLength, queryLength_MD5)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
- rtl_digest_destroy( handle );
- }
- void queryLength_MD2()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
+ sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
+ // printf("nAlgoLength:=%d\n", nAlgoLength);
+ ASSERT_TRUE(RTL_DIGEST_LENGTH_MD5 == nAlgoLength) << "query Length";
- sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
- // t_print("nAlgoLength:=%d\n", nAlgoLength);
- CPPUNIT_ASSERT_MESSAGE("query length", RTL_DIGEST_LENGTH_MD2 == nAlgoLength);
+ rtl_digest_destroy( handle );
+}
+TEST_F(queryLength, queryLength_MD2)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
- rtl_digest_destroy( handle );
- }
- void queryLength_SHA()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA );
+ sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
+ // printf("nAlgoLength:=%d\n", nAlgoLength);
+ ASSERT_TRUE(RTL_DIGEST_LENGTH_MD2 == nAlgoLength) << "query length";
- sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
- // t_print("nAlgoLength:=%d\n", nAlgoLength);
- CPPUNIT_ASSERT_MESSAGE("query length", RTL_DIGEST_LENGTH_SHA == nAlgoLength);
+ rtl_digest_destroy( handle );
+}
+TEST_F(queryLength, queryLength_SHA)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA );
- rtl_digest_destroy( handle );
- }
- void queryLength_SHA1()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA1 );
+ sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
+ // printf("nAlgoLength:=%d\n", nAlgoLength);
+ ASSERT_TRUE(RTL_DIGEST_LENGTH_SHA == nAlgoLength) << "query length";
- sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
- // t_print("nAlgoLength:=%d\n", nAlgoLength);
- CPPUNIT_ASSERT_MESSAGE("query length", RTL_DIGEST_LENGTH_SHA1 == nAlgoLength);
+ rtl_digest_destroy( handle );
+}
+TEST_F(queryLength, queryLength_SHA1)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA1 );
- rtl_digest_destroy( handle );
- }
- void queryLength_HMAC_MD5()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_MD5 );
+ sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
+ // printf("nAlgoLength:=%d\n", nAlgoLength);
+ ASSERT_TRUE(RTL_DIGEST_LENGTH_SHA1 == nAlgoLength) << "query length";
- sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
- // t_print("nAlgoLength:=%d\n", nAlgoLength);
- CPPUNIT_ASSERT_MESSAGE("query length", RTL_DIGEST_LENGTH_HMAC_MD5 == nAlgoLength);
+ rtl_digest_destroy( handle );
+}
+TEST_F(queryLength, queryLength_HMAC_MD5)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_MD5 );
- rtl_digest_destroy( handle );
- }
- void queryLength_HMAC_SHA1()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_SHA1 );
+ sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
+ // printf("nAlgoLength:=%d\n", nAlgoLength);
+ ASSERT_TRUE(RTL_DIGEST_LENGTH_HMAC_MD5 == nAlgoLength) << "query length";
- sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
- // t_print("nAlgoLength:=%d\n", nAlgoLength);
- CPPUNIT_ASSERT_MESSAGE("query length", RTL_DIGEST_LENGTH_HMAC_SHA1 == nAlgoLength);
+ rtl_digest_destroy( handle );
+}
+TEST_F(queryLength, queryLength_HMAC_SHA1)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_SHA1 );
- rtl_digest_destroy( handle );
- }
+ sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
+ // printf("nAlgoLength:=%d\n", nAlgoLength);
+ ASSERT_TRUE(RTL_DIGEST_LENGTH_HMAC_SHA1 == nAlgoLength) << "query length";
- void queryLength_Illegal()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmInvalid );
+ rtl_digest_destroy( handle );
+}
- sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
- // t_print("nAlgoLength:=%d\n", nAlgoLength);
- CPPUNIT_ASSERT_MESSAGE("query length", 0 == nAlgoLength);
+TEST_F(queryLength, queryLength_Illegal)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmInvalid );
- rtl_digest_destroy( handle );
- }
+ sal_uInt32 nAlgoLength = rtl_digest_queryLength(handle);
+ // printf("nAlgoLength:=%d\n", nAlgoLength);
+ ASSERT_TRUE(0 == nAlgoLength) << "query length";
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
-
- CPPUNIT_TEST_SUITE(queryLength);
- CPPUNIT_TEST( queryLength_MD2 );
- CPPUNIT_TEST( queryLength_MD5 );
- CPPUNIT_TEST( queryLength_SHA );
- CPPUNIT_TEST( queryLength_SHA1 );
- CPPUNIT_TEST( queryLength_HMAC_MD5 );
- CPPUNIT_TEST( queryLength_HMAC_SHA1 );
- CPPUNIT_TEST( queryLength_Illegal );
- CPPUNIT_TEST_SUITE_END();
-}; // class create
+ rtl_digest_destroy( handle );
+}
// -----------------------------------------------------------------------------
@@ -525,7 +464,7 @@ rtl::OString createHex(sal_uInt8 *_pMD5KeyBuffer, sal_uInt32 _nMD5KeyLen)
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( sal_Int32(0), sal_Int16(16) /* radix */ );
}
aBuffer.append( nValue, 16 /* radix */ );
}
@@ -535,229 +474,212 @@ rtl::OString createHex(sal_uInt8 *_pMD5KeyBuffer, sal_uInt32 _nMD5KeyLen)
// -----------------------------------------------------------------------------
-class init : public CppUnit::TestFixture
+class init : public ::testing::Test
{
public:
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
+}; // class init
- void init_000()
- {
- rtlDigest handle = NULL;
-
- rtlDigestError aError = rtl_digest_init(handle, NULL, 0);
+TEST_F(init, init_000)
+{
+ rtlDigest handle = NULL;
- CPPUNIT_ASSERT_MESSAGE("init(NULL, 0, 0)", aError == rtl_Digest_E_Argument);
- }
+ rtlDigestError aError = rtl_digest_init(handle, NULL, 0);
- void init_001()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
+ ASSERT_TRUE(aError == rtl_Digest_E_Argument) << "init(NULL, 0, 0)";
+}
- rtlDigestError aError = rtl_digest_init(handle, NULL, 0);
+TEST_F(init, init_001)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
- CPPUNIT_ASSERT_MESSAGE("init(handle, 0, 0)", aError == rtl_Digest_E_None);
+ rtlDigestError aError = rtl_digest_init(handle, NULL, 0);
- rtl_digest_destroy( handle );
- }
+ ASSERT_TRUE(aError == rtl_Digest_E_None) << "init(handle, 0, 0)";
- // ------------------------------------
- void init_MD2()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
+ rtl_digest_destroy( handle );
+}
- rtl::OString aMsg = sSampleString;
- const sal_uInt8 *pData = (const sal_uInt8*)aMsg.getStr();
- sal_uInt32 nSize = ( aMsg.getLength() );
+// ------------------------------------
+TEST_F(init, init_MD2)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
- rtlDigestError aError = rtl_digest_init(handle, pData, nSize);
+ rtl::OString aMsg = sSampleString;
+ const sal_uInt8 *pData = (const sal_uInt8*)aMsg.getStr();
+ sal_uInt32 nSize = ( aMsg.getLength() );
- CPPUNIT_ASSERT_MESSAGE("init(handle, pData, nSize)", aError == rtl_Digest_E_None);
+ rtlDigestError aError = rtl_digest_init(handle, pData, nSize);
- rtl_digest_update( handle, pData, nSize );
+ ASSERT_TRUE(aError == rtl_Digest_E_None) << "init(handle, pData, nSize)";
- sal_uInt32 nKeyLen = rtl_digest_queryLength( handle );
- sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
+ rtl_digest_update( handle, pData, nSize );
- rtl_digest_get( handle, pKeyBuffer, nKeyLen );
- rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
- delete [] pKeyBuffer;
+ sal_uInt32 nKeyLen = rtl_digest_queryLength( handle );
+ sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
- t_print("MD2 Sum: %s\n", aSum.getStr());
- // LLA: how to check right values
- // samples?
+ rtl_digest_get( handle, pKeyBuffer, nKeyLen );
+ rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
+ delete [] pKeyBuffer;
- rtl_digest_destroy( handle );
- }
+ printf("MD2 Sum: %s\n", aSum.getStr());
+ // LLA: how to check right values
+ // samples?
- void init_MD5()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
-
- rtl::OString aMsg = sSampleString;
- const sal_uInt8 *pData = (const sal_uInt8*)aMsg.getStr();
- sal_uInt32 nSize = ( aMsg.getLength() );
-
- rtlDigestError aError = rtl_digest_init(handle, pData, nSize);
+ rtl_digest_destroy( handle );
+}
- CPPUNIT_ASSERT_MESSAGE("init(handle, pData, nSize)", aError == rtl_Digest_E_None);
+TEST_F(init, init_MD5)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
- rtl_digest_update( handle, pData, nSize );
+ rtl::OString aMsg = sSampleString;
+ const sal_uInt8 *pData = (const sal_uInt8*)aMsg.getStr();
+ sal_uInt32 nSize = ( aMsg.getLength() );
- sal_uInt32 nKeyLen = rtl_digest_queryLength( handle );
- sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
+ rtlDigestError aError = rtl_digest_init(handle, pData, nSize);
- rtl_digest_get( handle, pKeyBuffer, nKeyLen );
- rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
- delete [] pKeyBuffer;
+ ASSERT_TRUE(aError == rtl_Digest_E_None) << "init(handle, pData, nSize)";
- t_print("MD5 Sum: %s\n", aSum.getStr());
- // LLA: how to check right values
- // samples?
+ rtl_digest_update( handle, pData, nSize );
- rtl_digest_destroy( handle );
- }
+ sal_uInt32 nKeyLen = rtl_digest_queryLength( handle );
+ sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
- void init_SHA()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA );
+ rtl_digest_get( handle, pKeyBuffer, nKeyLen );
+ rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
+ delete [] pKeyBuffer;
- rtl::OString aMsg = sSampleString;
- const sal_uInt8 *pData = (const sal_uInt8*)aMsg.getStr();
- sal_uInt32 nSize = ( aMsg.getLength() );
+ printf("MD5 Sum: %s\n", aSum.getStr());
+ // LLA: how to check right values
+ // samples?
- rtlDigestError aError = rtl_digest_init(handle, pData, nSize);
+ rtl_digest_destroy( handle );
+}
- CPPUNIT_ASSERT_MESSAGE("init(handle, pData, nSize)", aError == rtl_Digest_E_None);
+TEST_F(init, init_SHA)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA );
- rtl_digest_update( handle, pData, nSize );
+ rtl::OString aMsg = sSampleString;
+ const sal_uInt8 *pData = (const sal_uInt8*)aMsg.getStr();
+ sal_uInt32 nSize = ( aMsg.getLength() );
- sal_uInt32 nKeyLen = rtl_digest_queryLength( handle );
- sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
+ rtlDigestError aError = rtl_digest_init(handle, pData, nSize);
- rtl_digest_get( handle, pKeyBuffer, nKeyLen );
- rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
- delete [] pKeyBuffer;
+ ASSERT_TRUE(aError == rtl_Digest_E_None) << "init(handle, pData, nSize)";
- t_print("SHA Sum: %s\n", aSum.getStr());
- // LLA: how to check right values
- // samples?
+ rtl_digest_update( handle, pData, nSize );
- rtl_digest_destroy( handle );
- }
- void init_SHA1()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA1 );
+ sal_uInt32 nKeyLen = rtl_digest_queryLength( handle );
+ sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
- rtl::OString aMsg = sSampleString;
- const sal_uInt8 *pData = (const sal_uInt8*)aMsg.getStr();
- sal_uInt32 nSize = ( aMsg.getLength() );
+ rtl_digest_get( handle, pKeyBuffer, nKeyLen );
+ rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
+ delete [] pKeyBuffer;
- rtlDigestError aError = rtl_digest_init(handle, pData, nSize);
+ printf("SHA Sum: %s\n", aSum.getStr());
+ // LLA: how to check right values
+ // samples?
- CPPUNIT_ASSERT_MESSAGE("init(handle, pData, nSize)", aError == rtl_Digest_E_None);
+ rtl_digest_destroy( handle );
+}
+TEST_F(init, init_SHA1)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmSHA1 );
- rtl_digest_update( handle, pData, nSize );
+ rtl::OString aMsg = sSampleString;
+ const sal_uInt8 *pData = (const sal_uInt8*)aMsg.getStr();
+ sal_uInt32 nSize = ( aMsg.getLength() );
- sal_uInt32 nKeyLen = rtl_digest_queryLength( handle );
- sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
+ rtlDigestError aError = rtl_digest_init(handle, pData, nSize);
- rtl_digest_get( handle, pKeyBuffer, nKeyLen );
- rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
- delete [] pKeyBuffer;
+ ASSERT_TRUE(aError == rtl_Digest_E_None) << "init(handle, pData, nSize)";
- t_print("SHA1 Sum: %s\n", aSum.getStr());
- // LLA: how to check right values
- // samples?
+ rtl_digest_update( handle, pData, nSize );
- rtl_digest_destroy( handle );
- }
- void init_HMAC_MD5()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_MD5 );
+ sal_uInt32 nKeyLen = rtl_digest_queryLength( handle );
+ sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
- rtl::OString aMsg = sSampleString;
- const sal_uInt8 *pData = (const sal_uInt8*)aMsg.getStr();
- sal_uInt32 nSize = ( aMsg.getLength() );
+ rtl_digest_get( handle, pKeyBuffer, nKeyLen );
+ rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
+ delete [] pKeyBuffer;
- sal_uInt32 nKeyLen = rtl_digest_queryLength( handle );
- CPPUNIT_ASSERT_MESSAGE( "Keylen must be greater 0", nKeyLen );
+ printf("SHA1 Sum: %s\n", aSum.getStr());
+ // LLA: how to check right values
+ // samples?
- sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
- CPPUNIT_ASSERT( pKeyBuffer );
- memset(pKeyBuffer, 0, nKeyLen);
+ rtl_digest_destroy( handle );
+}
+TEST_F(init, init_HMAC_MD5)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_MD5 );
- rtlDigestError aError = rtl_digest_init(handle, pKeyBuffer, nKeyLen );
+ rtl::OString aMsg = sSampleString;
+ const sal_uInt8 *pData = (const sal_uInt8*)aMsg.getStr();
+ sal_uInt32 nSize = ( aMsg.getLength() );
- CPPUNIT_ASSERT_MESSAGE("init(handle, pData, nSize)", aError == rtl_Digest_E_None);
+ sal_uInt32 nKeyLen = rtl_digest_queryLength( handle );
+ ASSERT_TRUE(nKeyLen) << "Keylen must be greater 0";
- rtl_digest_update( handle, pData, nSize );
+ sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
+ ASSERT_TRUE( pKeyBuffer );
+ memset(pKeyBuffer, 0, nKeyLen);
- rtl_digest_get( handle, pKeyBuffer, nKeyLen );
- rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
- delete [] pKeyBuffer;
+ rtlDigestError aError = rtl_digest_init(handle, pKeyBuffer, nKeyLen );
- t_print("HMAC_MD5 Sum: %s\n", aSum.getStr());
- // LLA: how to check right values
- // samples?
+ ASSERT_TRUE(aError == rtl_Digest_E_None) << "init(handle, pData, nSize)";
- rtl_digest_destroy( handle );
- }
- void init_HMAC_SHA1()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_SHA1 );
+ rtl_digest_update( handle, pData, nSize );
- rtl::OString aMsg = sSampleString;
- const sal_uInt8 *pData = (const sal_uInt8*)aMsg.getStr();
- sal_uInt32 nSize = ( aMsg.getLength() );
+ rtl_digest_get( handle, pKeyBuffer, nKeyLen );
+ rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
+ delete [] pKeyBuffer;
- sal_uInt32 nKeyLen = rtl_digest_queryLength( handle );
- CPPUNIT_ASSERT_MESSAGE( "Keylen must be greater 0", nKeyLen );
+ printf("HMAC_MD5 Sum: %s\n", aSum.getStr());
+ // LLA: how to check right values
+ // samples?
- sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
- CPPUNIT_ASSERT( pKeyBuffer );
- memset(pKeyBuffer, 0, nKeyLen);
+ rtl_digest_destroy( handle );
+}
+TEST_F(init, init_HMAC_SHA1)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmHMAC_SHA1 );
- rtlDigestError aError = rtl_digest_init(handle, pKeyBuffer, nKeyLen );
+ rtl::OString aMsg = sSampleString;
+ const sal_uInt8 *pData = (const sal_uInt8*)aMsg.getStr();
+ sal_uInt32 nSize = ( aMsg.getLength() );
- CPPUNIT_ASSERT_MESSAGE("init(handle, pData, nSize)", aError == rtl_Digest_E_None);
+ sal_uInt32 nKeyLen = rtl_digest_queryLength( handle );
+ ASSERT_TRUE(nKeyLen) << "Keylen must be greater 0";
- rtl_digest_update( handle, pData, nSize );
+ sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
+ ASSERT_TRUE( pKeyBuffer );
+ memset(pKeyBuffer, 0, nKeyLen);
- rtl_digest_get( handle, pKeyBuffer, nKeyLen );
- rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
- delete [] pKeyBuffer;
+ rtlDigestError aError = rtl_digest_init(handle, pKeyBuffer, nKeyLen );
- t_print("HMAC_SHA1 Sum: %s\n", aSum.getStr());
- // LLA: how to check right values
- // samples?
+ ASSERT_TRUE(aError == rtl_Digest_E_None) << "init(handle, pData, nSize)";
- rtl_digest_destroy( handle );
- }
+ rtl_digest_update( handle, pData, nSize );
+ rtl_digest_get( handle, pKeyBuffer, nKeyLen );
+ rtl::OString aSum = createHex(pKeyBuffer, nKeyLen);
+ delete [] pKeyBuffer;
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
-
- CPPUNIT_TEST_SUITE(init);
- CPPUNIT_TEST( init_000 );
- CPPUNIT_TEST( init_001 );
- CPPUNIT_TEST( init_MD2 );
- CPPUNIT_TEST( init_MD5 );
- CPPUNIT_TEST( init_SHA );
- CPPUNIT_TEST( init_SHA1 );
- CPPUNIT_TEST( init_HMAC_MD5 );
- CPPUNIT_TEST( init_HMAC_SHA1 );
- CPPUNIT_TEST_SUITE_END();
-}; // class init
+ printf("HMAC_SHA1 Sum: %s\n", aSum.getStr());
+ // LLA: how to check right values
+ // samples?
+ rtl_digest_destroy( handle );
+}
// ------------------------------------
rtl::OString getMD5Sum(rtl::OString const& _aMsg )
@@ -783,665 +705,542 @@ rtl::OString getMD5Sum(rtl::OString const& _aMsg )
// -----------------------------------------------------------------------------
-class equalTests : public CppUnit::TestFixture
+class equalTests : public ::testing::Test
{
public:
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
+}; // class create
- // ------------------------------------
- void equal_001()
- {
- rtl::OString aMsg1 = sSampleString;
- rtl::OString aMsg2 = sSampleString;
-
- rtl::OString aMsgMD5Sum1 = getMD5Sum(aMsg1);
- rtl::OString aMsgMD5Sum2 = getMD5Sum(aMsg2);
-
- CPPUNIT_ASSERT_MESSAGE("md5sum must have a length", aMsgMD5Sum1.getLength() == 32 && aMsgMD5Sum2.getLength() == 32 );
- CPPUNIT_ASSERT_MESSAGE("source is the same, dest must be also the same", aMsgMD5Sum1.equals(aMsgMD5Sum2) == sal_True);
- }
- // ------------------------------------
- void equal_002()
- {
- rtl::OString aMsg1 = sSampleString;
- rtl::OString aMsg2 = sSampleString_only_one_diff;
+TEST_F(equalTests, equal_001)
+{
+ rtl::OString aMsg1 = sSampleString;
+ rtl::OString aMsg2 = sSampleString;
- rtl::OString aMsgMD5Sum1 = getMD5Sum(aMsg1);
- rtl::OString aMsgMD5Sum2 = getMD5Sum(aMsg2);
+ rtl::OString aMsgMD5Sum1 = getMD5Sum(aMsg1);
+ rtl::OString aMsgMD5Sum2 = getMD5Sum(aMsg2);
- CPPUNIT_ASSERT_MESSAGE("md5sum must have a length", aMsgMD5Sum1.getLength() == 32 && aMsgMD5Sum2.getLength() == 32 );
- CPPUNIT_ASSERT_MESSAGE("differ only in one char", aMsgMD5Sum1.equals(aMsgMD5Sum2) == sal_False);
- }
+ ASSERT_TRUE(aMsgMD5Sum1.getLength() == 32 && aMsgMD5Sum2.getLength() == 32) << "md5sum must have a length";
+ ASSERT_TRUE(aMsgMD5Sum1.equals(aMsgMD5Sum2) == sal_True) << "source is the same, dest must be also the same";
+}
+// ------------------------------------
+TEST_F(equalTests, equal_002)
+{
+ rtl::OString aMsg1 = sSampleString;
+ rtl::OString aMsg2 = sSampleString_only_one_diff;
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
+ rtl::OString aMsgMD5Sum1 = getMD5Sum(aMsg1);
+ rtl::OString aMsgMD5Sum2 = getMD5Sum(aMsg2);
- CPPUNIT_TEST_SUITE(equalTests);
- CPPUNIT_TEST( equal_001 );
- CPPUNIT_TEST( equal_002 );
- CPPUNIT_TEST_SUITE_END();
-}; // class create
+ ASSERT_TRUE(aMsgMD5Sum1.getLength() == 32 && aMsgMD5Sum2.getLength() == 32) << "md5sum must have a length";
+ ASSERT_TRUE(aMsgMD5Sum1.equals(aMsgMD5Sum2) == sal_False) << "differ only in one char";
+}
// -----------------------------------------------------------------------------
-class digest_MD2 : public CppUnit::TestFixture
+class digest_MD2 : public ::testing::Test
{
public:
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
+}; // class digest_MD2
- // ------------------------------------
- void MD2_001()
- {
- rtl::OString aMsg1 = sSampleString;
-
- sal_uInt8 *pBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_MD2 ];
- CPPUNIT_ASSERT( pBuffer );
- memset(pBuffer, 0, RTL_DIGEST_LENGTH_MD2 );
-
- sal_uInt8 *pMsg1 = (sal_uInt8*)aMsg1.getStr();
- sal_Int32 nLen = aMsg1.getLength();
+TEST_F(digest_MD2, MD2_001)
+{
+ rtl::OString aMsg1 = sSampleString;
- rtlDigestError aError = rtl_digest_MD2(pMsg1, nLen, pBuffer, RTL_DIGEST_LENGTH_MD2);
+ sal_uInt8 *pBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_MD2 ];
+ ASSERT_TRUE( pBuffer );
+ memset(pBuffer, 0, RTL_DIGEST_LENGTH_MD2 );
- CPPUNIT_ASSERT(aError == rtl_Digest_E_None );
+ sal_uInt8 *pMsg1 = (sal_uInt8*)aMsg1.getStr();
+ sal_Int32 nLen = aMsg1.getLength();
- rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_MD2);
- t_print("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) );
+ rtlDigestError aError = rtl_digest_MD2(pMsg1, nLen, pBuffer, RTL_DIGEST_LENGTH_MD2);
- delete [] pBuffer;
- }
+ ASSERT_TRUE(aError == rtl_Digest_E_None );
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
+ rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_MD2);
+ printf("Decrypt MD2: %s\n", aStr.getStr());
+ ASSERT_TRUE(aStr.equals(sSampleString_MD2)) <<
+ "checksum of sample string is wrong. Code changes or sample problems, please check.";
- CPPUNIT_TEST_SUITE(digest_MD2);
- CPPUNIT_TEST( MD2_001 );
- CPPUNIT_TEST_SUITE_END();
-}; // class create
+ delete [] pBuffer;
+}
// -----------------------------------------------------------------------------
-class digest_MD5 : public CppUnit::TestFixture
+class digest_MD5 : public ::testing::Test
{
public:
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
- // ------------------------------------
- void MD5_001()
- {
- rtl::OString aMsg1 = sSampleString;
+}; // class digest_MD5
- sal_uInt8 *pBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_MD5 ];
- CPPUNIT_ASSERT( pBuffer );
- memset(pBuffer, 0, RTL_DIGEST_LENGTH_MD5 );
+TEST_F(digest_MD5, MD5_001)
+{
+ rtl::OString aMsg1 = sSampleString;
- sal_uInt8 *pMsg1 = (sal_uInt8*)aMsg1.getStr();
- sal_Int32 nLen = aMsg1.getLength();
+ sal_uInt8 *pBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_MD5 ];
+ ASSERT_TRUE( pBuffer );
+ memset(pBuffer, 0, RTL_DIGEST_LENGTH_MD5 );
- rtlDigestError aError = rtl_digest_MD5(pMsg1, nLen, pBuffer, RTL_DIGEST_LENGTH_MD5);
+ sal_uInt8 *pMsg1 = (sal_uInt8*)aMsg1.getStr();
+ sal_Int32 nLen = aMsg1.getLength();
- CPPUNIT_ASSERT(aError == rtl_Digest_E_None );
+ rtlDigestError aError = rtl_digest_MD5(pMsg1, nLen, pBuffer, RTL_DIGEST_LENGTH_MD5);
- rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_MD5);
- t_print("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) );
+ ASSERT_TRUE(aError == rtl_Digest_E_None );
- delete [] pBuffer;
- }
+ rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_MD5);
+ printf("Decrypt MD5: %s\n", aStr.getStr());
+ ASSERT_TRUE(aStr.equals(sSampleString_MD5) ) <<
+ "checksum of sample string is wrong. Code changes or sample problems, please check.";
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
-
- CPPUNIT_TEST_SUITE(digest_MD5);
- CPPUNIT_TEST( MD5_001 );
- CPPUNIT_TEST_SUITE_END();
-}; // class create
+ delete [] pBuffer;
+}
// -----------------------------------------------------------------------------
-class digest_SHA : public CppUnit::TestFixture
+class digest_SHA : public ::testing::Test
{
public:
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
+}; // class create
- // ------------------------------------
- void SHA_001()
- {
- rtl::OString aMsg1 = sSampleString;
-
- sal_uInt8 *pBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_SHA ];
- CPPUNIT_ASSERT( pBuffer );
- memset(pBuffer, 0, RTL_DIGEST_LENGTH_SHA);
-
- sal_uInt8 *pMsg1 = (sal_uInt8*)aMsg1.getStr();
- sal_Int32 nLen = aMsg1.getLength();
+TEST_F(digest_SHA, SHA_001)
+{
+ rtl::OString aMsg1 = sSampleString;
- rtlDigestError aError = rtl_digest_SHA(pMsg1, nLen, pBuffer, RTL_DIGEST_LENGTH_SHA);
+ sal_uInt8 *pBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_SHA ];
+ ASSERT_TRUE( pBuffer );
+ memset(pBuffer, 0, RTL_DIGEST_LENGTH_SHA);
- CPPUNIT_ASSERT(aError == rtl_Digest_E_None );
+ sal_uInt8 *pMsg1 = (sal_uInt8*)aMsg1.getStr();
+ sal_Int32 nLen = aMsg1.getLength();
- rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_SHA);
- t_print("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) );
+ rtlDigestError aError = rtl_digest_SHA(pMsg1, nLen, pBuffer, RTL_DIGEST_LENGTH_SHA);
- delete [] pBuffer;
- }
+ ASSERT_TRUE(aError == rtl_Digest_E_None );
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
-
- CPPUNIT_TEST_SUITE(digest_SHA);
- CPPUNIT_TEST( SHA_001 );
- CPPUNIT_TEST_SUITE_END();
-}; // class create
+ rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_SHA);
+ printf("Decrypt SHA: %s\n", aStr.getStr());
+ ASSERT_TRUE(aStr.equals(sSampleString_SHA)) <<
+ "checksum of sample string is wrong. Code changes or sample problems, please check.";
+ delete [] pBuffer;
+}
// -----------------------------------------------------------------------------
-class digest_SHA1 : public CppUnit::TestFixture
+class digest_SHA1 : public ::testing::Test
{
public:
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
+}; // class create
- // ------------------------------------
- void SHA1_001()
- {
- rtl::OString aMsg1 = sSampleString;
-
- sal_uInt8 *pBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_SHA1 ];
- CPPUNIT_ASSERT( pBuffer );
- memset(pBuffer, 0, RTL_DIGEST_LENGTH_SHA1);
+TEST_F(digest_SHA1, SHA1_001)
+{
+ rtl::OString aMsg1 = sSampleString;
- sal_uInt8 *pMsg1 = (sal_uInt8*)aMsg1.getStr();
- sal_Int32 nLen = aMsg1.getLength();
+ sal_uInt8 *pBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_SHA1 ];
+ ASSERT_TRUE( pBuffer );
+ memset(pBuffer, 0, RTL_DIGEST_LENGTH_SHA1);
- rtlDigestError aError = rtl_digest_SHA1(pMsg1, nLen, pBuffer, RTL_DIGEST_LENGTH_SHA1);
+ sal_uInt8 *pMsg1 = (sal_uInt8*)aMsg1.getStr();
+ sal_Int32 nLen = aMsg1.getLength();
- CPPUNIT_ASSERT(aError == rtl_Digest_E_None );
+ rtlDigestError aError = rtl_digest_SHA1(pMsg1, nLen, pBuffer, RTL_DIGEST_LENGTH_SHA1);
- rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_SHA1);
- t_print("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) );
+ ASSERT_TRUE(aError == rtl_Digest_E_None );
- delete [] pBuffer;
- }
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
+ rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_SHA1);
+ printf("Decrypt SHA1: %s\n", aStr.getStr());
+ ASSERT_TRUE(aStr.equals(sSampleString_SHA1)) <<
+ "checksum of sample string is wrong. Code changes or sample problems, please check.";
- CPPUNIT_TEST_SUITE(digest_SHA1);
- CPPUNIT_TEST( SHA1_001 );
- CPPUNIT_TEST_SUITE_END();
-}; // class create
+ delete [] pBuffer;
+}
// -----------------------------------------------------------------------------
-class digest_HMAC_MD5 : public CppUnit::TestFixture
+class digest_HMAC_MD5 : public ::testing::Test
{
public:
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
+}; // class create
- // ------------------------------------
- void HMAC_MD5_001()
- {
- rtl::OString aMsg1 = sSampleString;
+TEST_F(digest_HMAC_MD5, HMAC_MD5_001)
+{
+ rtl::OString aMsg1 = sSampleString;
- sal_uInt8 *pKeyBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_HMAC_MD5 ];
- CPPUNIT_ASSERT( pKeyBuffer );
- memset(pKeyBuffer, 0, RTL_DIGEST_LENGTH_HMAC_MD5);
+ sal_uInt8 *pKeyBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_HMAC_MD5 ];
+ ASSERT_TRUE( pKeyBuffer );
+ memset(pKeyBuffer, 0, RTL_DIGEST_LENGTH_HMAC_MD5);
- sal_uInt8 *pBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_HMAC_MD5 ];
- CPPUNIT_ASSERT( pBuffer );
- memset(pBuffer, 0, RTL_DIGEST_LENGTH_HMAC_MD5);
+ sal_uInt8 *pBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_HMAC_MD5 ];
+ ASSERT_TRUE( pBuffer );
+ memset(pBuffer, 0, RTL_DIGEST_LENGTH_HMAC_MD5);
- sal_uInt8 *pMsg1 = (sal_uInt8*)aMsg1.getStr();
- sal_Int32 nLen = aMsg1.getLength();
+ sal_uInt8 *pMsg1 = (sal_uInt8*)aMsg1.getStr();
+ sal_Int32 nLen = aMsg1.getLength();
- rtlDigestError aError = rtl_digest_HMAC_MD5(pKeyBuffer, RTL_DIGEST_LENGTH_HMAC_MD5, pMsg1, nLen, pBuffer, RTL_DIGEST_LENGTH_HMAC_MD5);
+ rtlDigestError aError = rtl_digest_HMAC_MD5(pKeyBuffer, RTL_DIGEST_LENGTH_HMAC_MD5, pMsg1, nLen, pBuffer, RTL_DIGEST_LENGTH_HMAC_MD5);
- CPPUNIT_ASSERT(aError == rtl_Digest_E_None );
+ ASSERT_TRUE(aError == rtl_Digest_E_None );
- rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_HMAC_MD5);
- t_print("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) );
+ rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_HMAC_MD5);
+ printf("Decrypt HMAC_MD5: %s\n", aStr.getStr());
+ ASSERT_TRUE(aStr.equals(sSampleString_HMAC_MD5)) <<
+ "md5sum of sample string is wrong. Code changes or sample problems, please check.";
- delete [] pBuffer;
- }
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
+ delete [] pBuffer;
+}
- CPPUNIT_TEST_SUITE(digest_HMAC_MD5);
- CPPUNIT_TEST( HMAC_MD5_001 );
- CPPUNIT_TEST_SUITE_END();
-}; // class create
// -----------------------------------------------------------------------------
-class digest_HMAC_SHA1 : public CppUnit::TestFixture
+class digest_HMAC_SHA1 : public ::testing::Test
{
public:
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
+}; // class create
- // ------------------------------------
- void HMAC_SHA1_001()
- {
- rtl::OString aMsg1 = sSampleString;
-
- sal_uInt8 *pKeyBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_HMAC_SHA1 ];
- CPPUNIT_ASSERT( pKeyBuffer );
- memset(pKeyBuffer, 0, RTL_DIGEST_LENGTH_HMAC_SHA1);
-
- sal_uInt8 *pBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_HMAC_SHA1 ];
- CPPUNIT_ASSERT( pBuffer );
- memset(pBuffer, 0, RTL_DIGEST_LENGTH_HMAC_SHA1);
+TEST_F(digest_HMAC_SHA1, HMAC_SHA1_001)
+{
+ rtl::OString aMsg1 = sSampleString;
- sal_uInt8 *pMsg1 = (sal_uInt8*)aMsg1.getStr();
- sal_Int32 nLen = aMsg1.getLength();
+ sal_uInt8 *pKeyBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_HMAC_SHA1 ];
+ ASSERT_TRUE( pKeyBuffer );
+ memset(pKeyBuffer, 0, RTL_DIGEST_LENGTH_HMAC_SHA1);
- rtlDigestError aError = rtl_digest_HMAC_SHA1(pKeyBuffer, RTL_DIGEST_LENGTH_HMAC_SHA1, pMsg1, nLen, pBuffer, RTL_DIGEST_LENGTH_HMAC_SHA1);
+ sal_uInt8 *pBuffer = new sal_uInt8[ RTL_DIGEST_LENGTH_HMAC_SHA1 ];
+ ASSERT_TRUE( pBuffer );
+ memset(pBuffer, 0, RTL_DIGEST_LENGTH_HMAC_SHA1);
- CPPUNIT_ASSERT(aError == rtl_Digest_E_None );
+ sal_uInt8 *pMsg1 = (sal_uInt8*)aMsg1.getStr();
+ sal_Int32 nLen = aMsg1.getLength();
- rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_HMAC_SHA1);
- t_print("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) );
+ rtlDigestError aError = rtl_digest_HMAC_SHA1(pKeyBuffer, RTL_DIGEST_LENGTH_HMAC_SHA1, pMsg1, nLen, pBuffer, RTL_DIGEST_LENGTH_HMAC_SHA1);
- delete [] pBuffer;
- }
+ ASSERT_TRUE(aError == rtl_Digest_E_None );
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
+ rtl::OString aStr = createHex(pBuffer, RTL_DIGEST_LENGTH_HMAC_SHA1);
+ printf("Decrypt HMAC_SHA1: %s\n", aStr.getStr());
+ ASSERT_TRUE(aStr.equals(sSampleString_HMAC_SHA1)) <<
+ "md5sum of sample string is wrong. Code changes or sample problems, please check.";
- CPPUNIT_TEST_SUITE(digest_HMAC_SHA1);
- CPPUNIT_TEST( HMAC_SHA1_001 );
- CPPUNIT_TEST_SUITE_END();
-}; // class create
+ delete [] pBuffer;
+}
// -----------------------------------------------------------------------------
-class digest_PBKDF2 : public CppUnit::TestFixture
+class digest_PBKDF2 : public ::testing::Test
{
public:
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
- // ------------------------------------
rtl::OString /* key */ run_check_PBKDF2(rtl::OString const& _sPassword, bool _bClearSalt, sal_uInt32 _nCount)
- {
- sal_uInt32 nKeyLen = RTL_DIGEST_LENGTH_HMAC_SHA1;
- sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
- CPPUNIT_ASSERT( pKeyBuffer );
- memset(pKeyBuffer, 0, nKeyLen);
+ {
+ sal_uInt32 nKeyLen = RTL_DIGEST_LENGTH_HMAC_SHA1;
+ sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
+ EXPECT_TRUE( pKeyBuffer );
+ memset(pKeyBuffer, 0, nKeyLen);
- sal_uInt8 *pPassword = (sal_uInt8*)_sPassword.getStr();
- sal_Int32 nPasswordLen = _sPassword.getLength();
+ sal_uInt8 *pPassword = (sal_uInt8*)_sPassword.getStr();
+ sal_Int32 nPasswordLen = _sPassword.getLength();
- sal_uInt32 nSaltDataLen = RTL_DIGEST_LENGTH_HMAC_SHA1;
- sal_uInt8 *pSaltData = new sal_uInt8[ nSaltDataLen ];
- CPPUNIT_ASSERT( pSaltData );
- memset(pSaltData, 0, nSaltDataLen);
+ sal_uInt32 nSaltDataLen = RTL_DIGEST_LENGTH_HMAC_SHA1;
+ sal_uInt8 *pSaltData = new sal_uInt8[ nSaltDataLen ];
+ EXPECT_TRUE( pSaltData );
+ memset(pSaltData, 0, nSaltDataLen);
- if (! _bClearSalt)
- {
- // wilful contamination
- pSaltData[0] = 1;
- }
+ if (! _bClearSalt)
+ {
+ // wilful contamination
+ pSaltData[0] = 1;
+ }
- rtlDigestError aError = rtl_digest_PBKDF2(pKeyBuffer, nKeyLen, pPassword, nPasswordLen, pSaltData, nSaltDataLen, _nCount);
+ rtlDigestError aError = rtl_digest_PBKDF2(pKeyBuffer, nKeyLen, pPassword, nPasswordLen, pSaltData, nSaltDataLen, _nCount);
- CPPUNIT_ASSERT(aError == rtl_Digest_E_None );
+ EXPECT_TRUE(aError == rtl_Digest_E_None );
- rtl::OString aKey = createHex(pKeyBuffer, nKeyLen);
- t_print("Key: %s\n", aKey.getStr());
+ rtl::OString aKey = createHex(pKeyBuffer, nKeyLen);
+ printf("Key: %s\n", aKey.getStr());
- // rtl::OString sSalt = createHex(pSaltData, nSaltDataLen);
- // t_print("Salt: %s\n", sSalt.getStr());
+ // rtl::OString sSalt = createHex(pSaltData, nSaltDataLen);
+ // 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) );
+ // EXPECT_TRUE(aStr.equals(sSampleString_PBKDF2)) <<
+ // "md5sum of sample string is wrong. Code changes or sample problems, please check.";
- delete [] pSaltData;
- delete [] pKeyBuffer;
- return aKey;
- }
+ delete [] pSaltData;
+ delete [] pKeyBuffer;
+ return aKey;
+ }
+}; // class create
- void PBKDF2_001()
- {
- rtl::OString aPassword = "Password";
-
- // all permutations
- run_check_PBKDF2(aPassword, false, 1);
- run_check_PBKDF2(aPassword, false, 2);
- run_check_PBKDF2(aPassword, true, 1);
- run_check_PBKDF2(aPassword, true, 2);
- run_check_PBKDF2(aPassword, false, 3);
- run_check_PBKDF2(aPassword, false, 4);
- run_check_PBKDF2(aPassword, true, 3);
- run_check_PBKDF2(aPassword, true, 4);
- }
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
+TEST_F(digest_PBKDF2, PBKDF2_001)
+{
+ rtl::OString aPassword = "Password";
+
+ // all permutations
+ run_check_PBKDF2(aPassword, false, 1);
+ run_check_PBKDF2(aPassword, false, 2);
+ run_check_PBKDF2(aPassword, true, 1);
+ run_check_PBKDF2(aPassword, true, 2);
+ run_check_PBKDF2(aPassword, false, 3);
+ run_check_PBKDF2(aPassword, false, 4);
+ run_check_PBKDF2(aPassword, true, 3);
+ run_check_PBKDF2(aPassword, true, 4);
+}
- CPPUNIT_TEST_SUITE(digest_PBKDF2);
- CPPUNIT_TEST( PBKDF2_001 );
- CPPUNIT_TEST_SUITE_END();
-}; // class create
// -----------------------------------------------------------------------------
-class update : public CppUnit::TestFixture
+class update : public ::testing::Test
{
public:
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
+}; // class create
- void update_000()
- {
- rtlDigest aHandle = NULL;
- rtlDigestError aError = rtl_digest_update(aHandle, NULL, 0);
- CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument );
- }
+TEST_F(update, update_000)
+{
+ rtlDigest aHandle = NULL;
+ rtlDigestError aError = rtl_digest_update(aHandle, NULL, 0);
+ ASSERT_TRUE(aError == rtl_Digest_E_Argument) << "does not handle wrong parameter";
+}
- void updateMD2_000()
- {
- rtlDigest aHandle = NULL;
- rtlDigestError aError = rtl_digest_updateMD2(aHandle, NULL, 0);
- CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument );
- }
+TEST_F(update, updateMD2_000)
+{
+ rtlDigest aHandle = NULL;
+ rtlDigestError aError = rtl_digest_updateMD2(aHandle, NULL, 0);
+ ASSERT_TRUE(aError == rtl_Digest_E_Argument) << "does not handle wrong parameter";
+}
- void updateMD2_001()
- {
- rtlDigest aHandle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
- CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD2", aHandle != 0);
+TEST_F(update, updateMD2_001)
+{
+ rtlDigest aHandle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
+ ASSERT_TRUE(aHandle != 0) << "create with rtl_Digest_AlgorithmMD2";
- rtl::OString aMsg = sSampleString;
- const sal_uInt8* pData = (const sal_uInt8*)aMsg.getStr();
+ rtl::OString aMsg = sSampleString;
+ const sal_uInt8* pData = (const sal_uInt8*)aMsg.getStr();
- rtlDigestError aError = rtl_digest_updateMD2(aHandle, NULL, 0);
- CPPUNIT_ASSERT_MESSAGE("handle parameter 'pData' wrong", aError == rtl_Digest_E_Argument );
+ rtlDigestError aError = rtl_digest_updateMD2(aHandle, NULL, 0);
+ ASSERT_TRUE(aError == rtl_Digest_E_Argument) << "handle parameter 'pData' wrong";
- /* rtlDigestError */ aError = rtl_digest_updateMD2(aHandle, pData, 0);
- CPPUNIT_ASSERT_MESSAGE("handle parameter 'nSize' wrong", aError == rtl_Digest_E_None );
+ /* rtlDigestError */ aError = rtl_digest_updateMD2(aHandle, pData, 0);
+ ASSERT_TRUE(aError == rtl_Digest_E_None) << "handle parameter 'nSize' wrong";
- rtl_digest_destroyMD2(aHandle);
- }
- void updateMD5_000()
- {
- rtlDigest aHandle = NULL;
- rtlDigestError aError = rtl_digest_updateMD5(aHandle, NULL, 0);
- CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument );
- }
+ rtl_digest_destroyMD2(aHandle);
+}
+TEST_F(update, updateMD5_000)
+{
+ rtlDigest aHandle = NULL;
+ rtlDigestError aError = rtl_digest_updateMD5(aHandle, NULL, 0);
+ ASSERT_TRUE(aError == rtl_Digest_E_Argument) << "does not handle wrong parameter";
+}
- void updateMD5_001()
- {
- // use wrong Algorithm!!! This is volitional!
- rtlDigest aHandle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
- CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD2", aHandle != 0);
+TEST_F(update, updateMD5_001)
+{
+ // use wrong Algorithm!!! This is volitional!
+ rtlDigest aHandle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
+ ASSERT_TRUE(aHandle != 0) << "create with rtl_Digest_AlgorithmMD2";
- rtl::OString aMsg = sSampleString;
- const sal_uInt8* pData = (const sal_uInt8*)aMsg.getStr();
- sal_uInt32 nSize = ( aMsg.getLength() );
+ rtl::OString aMsg = sSampleString;
+ const sal_uInt8* pData = (const sal_uInt8*)aMsg.getStr();
+ sal_uInt32 nSize = ( aMsg.getLength() );
- rtlDigestError aError = rtl_digest_updateMD5(aHandle, pData, nSize);
- CPPUNIT_ASSERT_MESSAGE("handle parameter 'handle' wrong", aError == rtl_Digest_E_Algorithm );
+ rtlDigestError aError = rtl_digest_updateMD5(aHandle, pData, nSize);
+ ASSERT_TRUE(aError == rtl_Digest_E_Algorithm) << "handle parameter 'handle' wrong";
- rtl_digest_destroyMD5(aHandle);
- }
+ rtl_digest_destroyMD5(aHandle);
+}
- void updateMD5_002()
- {
- rtlDigest aHandle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
- CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD5", aHandle != 0);
+TEST_F(update, updateMD5_002)
+{
+ rtlDigest aHandle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
+ ASSERT_TRUE(aHandle != 0) << "create with rtl_Digest_AlgorithmMD5";
- rtl::OString aMsg = sSampleString;
- const sal_uInt8* pData = (const sal_uInt8*)aMsg.getStr();
+ rtl::OString aMsg = sSampleString;
+ const sal_uInt8* pData = (const sal_uInt8*)aMsg.getStr();
- rtlDigestError aError = rtl_digest_updateMD5(aHandle, NULL, 0);
- CPPUNIT_ASSERT_MESSAGE("handle parameter 'pData' wrong", aError == rtl_Digest_E_Argument );
+ rtlDigestError aError = rtl_digest_updateMD5(aHandle, NULL, 0);
+ ASSERT_TRUE(aError == rtl_Digest_E_Argument) << "handle parameter 'pData' wrong";
- /* rtlDigestError */ aError = rtl_digest_updateMD5(aHandle, pData, 0);
- CPPUNIT_ASSERT_MESSAGE("handle parameter 'nSize' wrong", aError == rtl_Digest_E_None );
+ /* rtlDigestError */ aError = rtl_digest_updateMD5(aHandle, pData, 0);
+ ASSERT_TRUE(aError == rtl_Digest_E_None) << "handle parameter 'nSize' wrong";
- rtl_digest_destroyMD5(aHandle);
- }
+ rtl_digest_destroyMD5(aHandle);
+}
- void updateSHA_000()
- {
- rtlDigest aHandle = NULL;
- rtlDigestError aError = rtl_digest_updateSHA(aHandle, NULL, 0);
- CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument );
- }
+TEST_F(update, updateSHA_000)
+{
+ rtlDigest aHandle = NULL;
+ rtlDigestError aError = rtl_digest_updateSHA(aHandle, NULL, 0);
+ ASSERT_TRUE(aError == rtl_Digest_E_Argument) << "does not handle wrong parameter";
+}
- void updateSHA1_000()
- {
- rtlDigest aHandle = NULL;
- rtlDigestError aError = rtl_digest_updateSHA1(aHandle, NULL, 0);
- CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument );
- }
+TEST_F(update, updateSHA1_000)
+{
+ rtlDigest aHandle = NULL;
+ rtlDigestError aError = rtl_digest_updateSHA1(aHandle, NULL, 0);
+ ASSERT_TRUE(aError == rtl_Digest_E_Argument) << "does not handle wrong parameter";
+}
- void updateHMAC_MD5_000()
- {
- rtlDigest aHandle = NULL;
- rtlDigestError aError = rtl_digest_updateHMAC_MD5(aHandle, NULL, 0);
- CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument );
- }
+TEST_F(update, updateHMAC_MD5_000)
+{
+ rtlDigest aHandle = NULL;
+ rtlDigestError aError = rtl_digest_updateHMAC_MD5(aHandle, NULL, 0);
+ ASSERT_TRUE(aError == rtl_Digest_E_Argument) << "does not handle wrong parameter";
+}
- void updateHMAC_SHA1_000()
- {
- rtlDigest aHandle = NULL;
- rtlDigestError aError = rtl_digest_updateHMAC_SHA1(aHandle, NULL, 0);
- CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument );
- }
+TEST_F(update, updateHMAC_SHA1_000)
+{
+ rtlDigest aHandle = NULL;
+ rtlDigestError aError = rtl_digest_updateHMAC_SHA1(aHandle, NULL, 0);
+ ASSERT_TRUE(aError == rtl_Digest_E_Argument) << "does not handle wrong parameter";
+}
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
-
- CPPUNIT_TEST_SUITE(update);
- CPPUNIT_TEST(update_000);
- CPPUNIT_TEST(updateMD5_000);
- CPPUNIT_TEST(updateMD5_001);
- CPPUNIT_TEST(updateMD5_002);
- CPPUNIT_TEST(updateMD5_000);
- CPPUNIT_TEST(updateSHA_000);
- CPPUNIT_TEST(updateSHA1_000);
- CPPUNIT_TEST(updateHMAC_MD5_000);
- CPPUNIT_TEST(updateHMAC_SHA1_000);
- CPPUNIT_TEST_SUITE_END();
-}; // class create
// -----------------------------------------------------------------------------
-class get : public CppUnit::TestFixture
+class get : public ::testing::Test
{
public:
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
+}; // class create
- void get_000()
- {
- rtlDigest aHandle = NULL;
- rtlDigestError aError = rtl_digest_get(aHandle, NULL, 0);
- CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument );
- }
- void getMD5_000()
- {
- rtlDigest aHandle = NULL;
- rtlDigestError aError = rtl_digest_getMD5(aHandle, NULL, 0);
- CPPUNIT_ASSERT_MESSAGE("does not handle wrong parameter", aError == rtl_Digest_E_Argument );
- }
- void getMD5_001()
- {
- // test with wrong algorithm
- rtlDigest aHandle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
- CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD2", aHandle != 0);
-
- sal_uInt32 nKeyLen = rtl_digest_queryLength( aHandle );
- sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
+TEST_F(get, get_000)
+{
+ rtlDigest aHandle = NULL;
+ rtlDigestError aError = rtl_digest_get(aHandle, NULL, 0);
+ ASSERT_TRUE(aError == rtl_Digest_E_Argument) << "does not handle wrong parameter";
+}
+TEST_F(get, getMD5_000)
+{
+ rtlDigest aHandle = NULL;
+ rtlDigestError aError = rtl_digest_getMD5(aHandle, NULL, 0);
+ ASSERT_TRUE(aError == rtl_Digest_E_Argument) << "does not handle wrong parameter";
+}
+TEST_F(get, getMD5_001)
+{
+ // test with wrong algorithm
+ rtlDigest aHandle = rtl_digest_create( rtl_Digest_AlgorithmMD2 );
+ ASSERT_TRUE(aHandle != 0) << "create with rtl_Digest_AlgorithmMD2";
- rtlDigestError aError = rtl_digest_getMD5(aHandle, NULL, 0);
- CPPUNIT_ASSERT_MESSAGE("handle 2. parameter wrong", aError == rtl_Digest_E_Argument );
+ sal_uInt32 nKeyLen = rtl_digest_queryLength( aHandle );
+ sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
- /* rtlDigestError */ aError = rtl_digest_getMD5(aHandle, pKeyBuffer, 0);
- CPPUNIT_ASSERT_MESSAGE("handle parameter 'handle' wrong", aError == rtl_Digest_E_Algorithm );
+ rtlDigestError aError = rtl_digest_getMD5(aHandle, NULL, 0);
+ ASSERT_TRUE(aError == rtl_Digest_E_Argument) << "handle 2. parameter wrong";
- rtl_digest_destroyMD2(aHandle);
- }
+ /* rtlDigestError */ aError = rtl_digest_getMD5(aHandle, pKeyBuffer, 0);
+ ASSERT_TRUE(aError == rtl_Digest_E_Algorithm) << "handle parameter 'handle' wrong";
- void getMD5_002()
- {
- rtlDigest aHandle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
- CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD5", aHandle != 0);
-
- sal_uInt32 nKeyLen = rtl_digest_queryLength( aHandle );
- sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
-
- rtlDigestError aError = rtl_digest_getMD5(aHandle, NULL /* pKeyBuffer */ , nKeyLen);
- CPPUNIT_ASSERT_MESSAGE("handle parameter 'pData' wrong", aError == rtl_Digest_E_Argument );
+ rtl_digest_destroyMD2(aHandle);
+}
- /* rtlDigestError */ aError = rtl_digest_getMD5(aHandle, pKeyBuffer, 0);
- CPPUNIT_ASSERT_MESSAGE("handle parameter 'nSize' wrong", aError == rtl_Digest_E_BufferSize );
+TEST_F(get, getMD5_002)
+{
+ rtlDigest aHandle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
+ ASSERT_TRUE(aHandle != 0) << "create with rtl_Digest_AlgorithmMD5";
- rtl_digest_destroyMD5(aHandle);
- delete [] pKeyBuffer;
- }
+ sal_uInt32 nKeyLen = rtl_digest_queryLength( aHandle );
+ sal_uInt8 *pKeyBuffer = new sal_uInt8[ nKeyLen ];
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
+ rtlDigestError aError = rtl_digest_getMD5(aHandle, NULL /* pKeyBuffer */ , nKeyLen);
+ ASSERT_TRUE(aError == rtl_Digest_E_Argument) << "handle parameter 'pData' wrong";
- CPPUNIT_TEST_SUITE(get);
- CPPUNIT_TEST(get_000);
- CPPUNIT_TEST(getMD5_000);
- CPPUNIT_TEST(getMD5_001);
- CPPUNIT_TEST(getMD5_002);
- CPPUNIT_TEST_SUITE_END();
-}; // class create
+ /* rtlDigestError */ aError = rtl_digest_getMD5(aHandle, pKeyBuffer, 0);
+ ASSERT_TRUE(aError == rtl_Digest_E_BufferSize) << "handle parameter 'nSize' wrong";
+ rtl_digest_destroyMD5(aHandle);
+ delete [] pKeyBuffer;
+}
// -----------------------------------------------------------------------------
-class destroy : public CppUnit::TestFixture
+class destroy : public ::testing::Test
{
public:
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
}
- void tearDown()
+ void TearDown()
{
}
+}; // class create
- void destroy_001()
- {
- rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
- CPPUNIT_ASSERT_MESSAGE("create with rtl_Digest_AlgorithmMD5", handle != 0);
-
- // not really testable
- // LLA: good will test.
- rtl_digest_destroy( handle );
- }
-
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
+TEST_F(destroy, destroy_001)
+{
+ rtlDigest handle = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
+ ASSERT_TRUE(handle != 0) << "create with rtl_Digest_AlgorithmMD5";
- CPPUNIT_TEST_SUITE(destroy);
- CPPUNIT_TEST(destroy_001);
- CPPUNIT_TEST_SUITE_END();
-}; // class create
+ // not really testable
+ // LLA: good will test.
+ rtl_digest_destroy( handle );
+}
// -----------------------------------------------------------------------------
-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");
} // 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;
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
commit 92c4e2f23a2aacee7d14d7219d188169449f16fa
Author: Damjan Jovanovic <damjan at apache.org>
Date: Tue Sep 1 04:59:51 2015 +0000
#i125003# migrate main/sal/qa/rtl/math from cppunit to Google Test.
diff --git a/sal/qa/rtl/math/makefile.mk b/sal/qa/rtl/math/makefile.mk
index 3b7031b..206c9de 100644
--- a/sal/qa/rtl/math/makefile.mk
+++ b/sal/qa/rtl/math/makefile.mk
@@ -33,19 +33,21 @@ ENABLE_EXCEPTIONS = TRUE
.INCLUDE: settings.mk
-CFLAGSCXX += $(CPPUNIT_CFLAGS)
+.IF "$(ENABLE_UNIT_TESTS)" != "YES"
+all:
+ @echo unit tests are disabled. Nothing to do.
+
+.ELSE
-SHL1IMPLIB = i$(SHL1TARGET)
-SHL1OBJS = $(SLO)/test-rtl-math.obj
-SHL1RPATH = NONE
-SHL1STDLIBS = $(CPPUNITLIB) $(SALLIB)
-SHL1TARGET = test-rtl-math
-SHL1VERSIONMAP = $(PRJ)/qa/export.map
-DEF1NAME = $(SHL1TARGET)
-SLOFILES = $(SHL1OBJS)
+APP1OBJS = $(SLO)/test-rtl-math.obj
+APP1RPATH = NONE
+APP1STDLIBS = $(GTESTLIB) $(SALLIB)
+APP1TARGET = test-rtl-math
+APP1TEST = enabled
.INCLUDE: target.mk
-.INCLUDE: _cppunit.mk
-.END
+.ENDIF # "$(ENABLE_UNIT_TESTS)" != "YES"
+
+.END # "$(OOO_SUBSEQUENT_TESTS)" == ""
diff --git a/sal/qa/rtl/math/test-rtl-math.cxx b/sal/qa/rtl/math/test-rtl-math.cxx
index 4b4648a..3e1037b 100644
--- a/sal/qa/rtl/math/test-rtl-math.cxx
+++ b/sal/qa/rtl/math/test-rtl-math.cxx
@@ -24,10 +24,7 @@
#include "precompiled_sal.hxx"
#include "sal/config.h"
-#include "cppunit/TestAssert.h"
-#include "cppunit/TestFixture.h"
-#include "cppunit/extensions/HelperMacros.h"
-#include "cppunit/plugin/TestPlugIn.h"
+#include "gtest/gtest.h"
#include "rtl/math.hxx"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
@@ -35,38 +32,35 @@
namespace {
-class Test: public CppUnit::TestFixture {
-public:
- void test_stringToDouble_good() {
- rtl_math_ConversionStatus status;
- sal_Int32 end;
- double res = rtl::math::stringToDouble(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" +1.E01foo")),
- sal_Unicode('.'), sal_Unicode(','), &status, &end);
- CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(RTL_CONSTASCII_LENGTH(" +1.E01")), end);
- CPPUNIT_ASSERT_EQUAL(10.0, res);
- }
-
- void test_stringToDouble_bad() {
- rtl_math_ConversionStatus status;
- sal_Int32 end;
- double res = rtl::math::stringToDouble(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" +Efoo")),
- sal_Unicode('.'), sal_Unicode(','), &status, &end);
- CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(0), end);
- CPPUNIT_ASSERT_EQUAL(0.0, res);
- }
-
- CPPUNIT_TEST_SUITE(Test);
- CPPUNIT_TEST(test_stringToDouble_good);
- CPPUNIT_TEST(test_stringToDouble_bad);
- CPPUNIT_TEST_SUITE_END();
+class Test: public ::testing::Test {
};
-CPPUNIT_TEST_SUITE_REGISTRATION(Test);
+TEST_F(Test, test_stringToDouble_good) {
+ rtl_math_ConversionStatus status;
+ sal_Int32 end;
+ double res = rtl::math::stringToDouble(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" +1.E01foo")),
+ sal_Unicode('.'), sal_Unicode(','), &status, &end);
+ ASSERT_EQ(rtl_math_ConversionStatus_Ok, status);
+ ASSERT_EQ(sal_Int32(RTL_CONSTASCII_LENGTH(" +1.E01")), end);
+ ASSERT_EQ(10.0, res);
+}
+
+TEST_F(Test, test_stringToDouble_bad) {
+ rtl_math_ConversionStatus status;
+ sal_Int32 end;
+ double res = rtl::math::stringToDouble(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" +Efoo")),
+ sal_Unicode('.'), sal_Unicode(','), &status, &end);
+ ASSERT_EQ(rtl_math_ConversionStatus_Ok, status);
+ ASSERT_EQ(sal_Int32(0), end);
+ ASSERT_EQ(0.0, res);
+}
}
-CPPUNIT_PLUGIN_IMPLEMENT();
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
commit 802a2d561dd3f0494a6bf3257e47049097462235
Author: Damjan Jovanovic <damjan at apache.org>
Date: Tue Sep 1 04:57:52 2015 +0000
#i125003# migrate main/sal/qa/rtl/alloc from cppunit to Google Test.
diff --git a/sal/qa/rtl/alloc/makefile.mk b/sal/qa/rtl/alloc/makefile.mk
index 155cabd..75f00f7 100644
--- a/sal/qa/rtl/alloc/makefile.mk
+++ b/sal/qa/rtl/alloc/makefile.mk
@@ -31,34 +31,29 @@ ENABLE_EXCEPTIONS=TRUE
.INCLUDE : settings.mk
+.IF "$(ENABLE_UNIT_TESTS)" != "YES"
+all:
+ @echo unit tests are disabled. Nothing to do.
+
+.ELSE
+
CFLAGS+= $(LFS_CFLAGS)
CXXFLAGS+= $(LFS_CFLAGS)
-CFLAGSCXX += $(CPPUNIT_CFLAGS)
-
# BEGIN ----------------------------------------------------------------
# auto generated Target:jobfile by codegen.pl
-SHL1OBJS= \
+APP1OBJS= \
$(SLO)$/rtl_alloc.obj
-SHL1TARGET= rtl_Alloc
-SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB)
-
-SHL1IMPLIB= i$(SHL1TARGET)
-# SHL1DEF= $(MISC)$/$(SHL1TARGET).def
-
-DEF1NAME =$(SHL1TARGET)
-# DEF1EXPORTFILE= export.exp
-SHL1VERSIONMAP= $(PRJ)$/qa$/export.map
+APP1TARGET= rtl_Alloc
+APP1STDLIBS= $(SALLIB) $(GTESTLIB) $(TESTSHL2LIB)
+APP1RPATH = NONE
+APP1TEST = enabled
# auto generated Target:jobfile
# END ------------------------------------------------------------------
-#------------------------------- All object files -------------------------------
-# do this here, so we get right dependencies
-# SLOFILES=$(SHL1OBJS)
-
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
-.INCLUDE : _cppunit.mk
+.ENDIF # .IF "$(ENABLE_UNIT_TESTS)" != "YES"
\ No newline at end of file
diff --git a/sal/qa/rtl/alloc/rtl_alloc.cxx b/sal/qa/rtl/alloc/rtl_alloc.cxx
index 17d1fb7..98555a4 100644
--- a/sal/qa/rtl/alloc/rtl_alloc.cxx
+++ b/sal/qa/rtl/alloc/rtl_alloc.cxx
@@ -27,7 +27,7 @@
// autogenerated file with codegen.pl
#include <rtl/alloc.h>
-#include <testshl/simpleheader.hxx>
+#include "gtest/gtest.h"
namespace rtl_alloc
{
@@ -48,8 +48,9 @@ namespace rtl_alloc
return bOk;
}
-class Memory : public CppUnit::TestFixture
+class Memory : public ::testing::Test
{
+protected:
// for normal alloc functions
char *m_pMemory;
sal_uInt32 m_nSizeOfMemory;
@@ -58,63 +59,45 @@ public:
Memory()
:m_pMemory(NULL),
m_nSizeOfMemory(50 * 1024 * 1024)
- {
- }
+ {
+ }
// initialise your test code values here.
- void setUp()
+ void SetUp()
{
- t_print("allocate memory\n");
+ printf("allocate memory\n");
m_pMemory = (char*) rtl_allocateMemory( m_nSizeOfMemory );
}
- void tearDown()
+ void TearDown()
{
- t_print("free memory\n");
+ printf("free memory\n");
rtl_freeMemory(m_pMemory);
m_pMemory = NULL;
}
+}; // class test
- // insert your test code here.
- void rtl_allocateMemory_001()
- {
- // this is demonstration code
- // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1);
-
- CPPUNIT_ASSERT_MESSAGE( "Can get zero memory.", m_pMemory != NULL);
- memset(m_pMemory, 1, m_nSizeOfMemory);
- CPPUNIT_ASSERT_MESSAGE( "memory contains wrong value.", checkMemory(m_pMemory, m_nSizeOfMemory, 1) == true);
- }
-
- void rtl_reallocateMemory_001()
- {
- t_print("reallocate memory\n");
- sal_uInt32 nSize = 10 * 1024 * 1024;
- m_pMemory = (char*)rtl_reallocateMemory(m_pMemory, nSize);
-
- CPPUNIT_ASSERT_MESSAGE( "Can reallocate memory.", m_pMemory != NULL);
- memset(m_pMemory, 2, nSize);
- CPPUNIT_ASSERT_MESSAGE( "memory contains wrong value.", checkMemory(m_pMemory, nSize, 2) == true);
- }
-
- // void rtl_freeMemory_001()
- // {
- // // CPPUNIT_ASSERT_STUB();
- // }
+TEST_F(Memory, rtl_allocateMemory_001)
+{
+ ASSERT_TRUE(m_pMemory != NULL) << "Can get zero memory.";
+ memset(m_pMemory, 1, m_nSizeOfMemory);
+ ASSERT_TRUE(checkMemory(m_pMemory, m_nSizeOfMemory, 1) == true) << "memory contains wrong value.";
+}
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
+TEST_F(Memory, rtl_reallocateMemory_001)
+{
+ printf("reallocate memory\n");
+ sal_uInt32 nSize = 10 * 1024 * 1024;
+ m_pMemory = (char*)rtl_reallocateMemory(m_pMemory, nSize);
- CPPUNIT_TEST_SUITE(Memory);
- CPPUNIT_TEST(rtl_allocateMemory_001);
- CPPUNIT_TEST(rtl_reallocateMemory_001);
- // CPPUNIT_TEST(rtl_freeMemory_001);
- CPPUNIT_TEST_SUITE_END();
-}; // class test
+ ASSERT_TRUE(m_pMemory != NULL) << "Can reallocate memory.";
+ memset(m_pMemory, 2, nSize);
+ ASSERT_TRUE(checkMemory(m_pMemory, nSize, 2) == true) << "memory contains wrong value.";
+}
-class ZeroMemory : public CppUnit::TestFixture
+class ZeroMemory : public ::testing::Test
{
+protected:
// for zero functions
char *m_pZeroMemory;
sal_uInt32 m_nSizeOfZeroMemory;
@@ -123,53 +106,39 @@ public:
ZeroMemory()
:m_pZeroMemory(NULL),
m_nSizeOfZeroMemory( 50 * 1024 * 1024 )
- {
- }
+ {
+ }
// initialise your test code values here.
- void setUp()
- {
- t_print("allocate zero memory\n");
- m_pZeroMemory = (char*) rtl_allocateZeroMemory( m_nSizeOfZeroMemory );
- }
-
- void tearDown()
+ void SetUp()
{
- t_print("free zero memory\n");
- rtl_freeZeroMemory(m_pZeroMemory, m_nSizeOfZeroMemory);
- // LLA: no check possible, may GPF if there is something wrong.
- // CPPUNIT_ASSERT_MESSAGE( "Can get zero memory.", pZeroMemory != NULL);
+ printf("allocate zero memory\n");
+ m_pZeroMemory = (char*) rtl_allocateZeroMemory( m_nSizeOfZeroMemory );
}
- // insert your test code here.
-
- void rtl_allocateZeroMemory_001()
+ void TearDown()
{
- CPPUNIT_ASSERT_MESSAGE( "Can get zero memory.", m_pZeroMemory != NULL);
- CPPUNIT_ASSERT_MESSAGE( "memory contains wrong value.", checkMemory(m_pZeroMemory, m_nSizeOfZeroMemory, 0) == true);
-
- memset(m_pZeroMemory, 3, m_nSizeOfZeroMemory);
- CPPUNIT_ASSERT_MESSAGE( "memory contains wrong value.", checkMemory(m_pZeroMemory, m_nSizeOfZeroMemory, 3) == true);
+ printf("free zero memory\n");
+ rtl_freeZeroMemory(m_pZeroMemory, m_nSizeOfZeroMemory);
+ // LLA: no check possible, may GPF if there is something wrong.
+ // ASSERT_TRUE(pZeroMemory != NULL) << "Can get zero memory.";
}
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
-
- CPPUNIT_TEST_SUITE(ZeroMemory);
- CPPUNIT_TEST(rtl_allocateZeroMemory_001);
- CPPUNIT_TEST_SUITE_END();
}; // class test
-// -----------------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_alloc::Memory, "rtl_alloc");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_alloc::ZeroMemory, "rtl_alloc");
-} // namespace rtl_alloc
-
+TEST_F(ZeroMemory, rtl_allocateZeroMemory_001)
+{
+ ASSERT_TRUE(m_pZeroMemory != NULL) << "Can get zero memory.";
+ ASSERT_TRUE(checkMemory(m_pZeroMemory, m_nSizeOfZeroMemory, 0) == true) << "memory contains wrong value.";
-// -----------------------------------------------------------------------------
+ memset(m_pZeroMemory, 3, m_nSizeOfZeroMemory);
+ ASSERT_TRUE(checkMemory(m_pZeroMemory, m_nSizeOfZeroMemory, 3) == true) << "memory contains wrong value.";
+}
-// 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;
+} // namespace rtl_alloc
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
More information about the Libreoffice-commits
mailing list