diff options
author | Oliver Bolte <obo@openoffice.org> | 2004-06-04 02:14:54 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2004-06-04 02:14:54 +0000 |
commit | c0205c088c058b790af3e333a5a1c4d0b76896ca (patch) | |
tree | d53902296d6cb8a7cfa8a626c24bc6fac7f2f79e /codemaker/test | |
parent | fc1c8b18913fc316911768adef7c6bc923eec1c8 (diff) |
INTEGRATION: CWS sb18 (1.2.4); FILE MERGED
2004/06/01 13:27:32 sb 1.2.4.3: #i21150# Work around MS compiler bug that default-initialized primitive class members are left uninitialized.
2004/04/28 09:00:34 sb 1.2.4.2: #i21150# Added struct alignment tests.
2004/04/22 08:28:18 sb 1.2.4.1: #i21150# Added support for polymorphic struct types.
Diffstat (limited to 'codemaker/test')
-rw-r--r-- | codemaker/test/cppumaker/test_codemaker_cppumaker.cxx | 87 |
1 files changed, 84 insertions, 3 deletions
diff --git a/codemaker/test/cppumaker/test_codemaker_cppumaker.cxx b/codemaker/test/cppumaker/test_codemaker_cppumaker.cxx index 497fa182e10d..4a644df88be0 100644 --- a/codemaker/test/cppumaker/test_codemaker_cppumaker.cxx +++ b/codemaker/test/cppumaker/test_codemaker_cppumaker.cxx @@ -2,9 +2,9 @@ * * $RCSfile: test_codemaker_cppumaker.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: rt $ $Date: 2004-03-30 16:54:02 $ + * last change: $Author: obo $ $Date: 2004-06-04 03:14:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -224,5 +224,86 @@ #include "test/codemaker/cppumaker/std.hpp" #include "test/codemaker/cppumaker/NDEBUG.hpp" #include "test/codemaker/cppumaker/get.hpp" +#include "test/codemaker/cppumaker/HelperEnum.hpp" +#include "test/codemaker/cppumaker/HelperStruct.hpp" +#include "test/codemaker/cppumaker/BigStruct.hpp" +#include "test/codemaker/cppumaker/Struct.hpp" +#include "test/codemaker/cppumaker/StructUsage.hpp" +#include "test/codemaker/cppumaker/AlignmentDerivedStruct.hpp" -//TODO +#include "boost/scoped_array.hpp" +#include "com/sun/star/uno/Any.hxx" +#include "com/sun/star/uno/Type.hxx" +#include "com/sun/star/uno/TypeClass.hpp" +#include "cppunit/simpleheader.hxx" + +#include <cstddef> + +namespace { + +class Test: public CppUnit::TestFixture { +public: + void testBigStruct(); + + CPPUNIT_TEST_SUITE(Test); + CPPUNIT_TEST(testBigStruct); + CPPUNIT_TEST_SUITE_END(); +}; + +struct Guard { + explicit Guard(void * buffer): + p(new(buffer) test::codemaker::cppumaker::BigStruct) {} + + ~Guard() { p->test::codemaker::cppumaker::BigStruct::~BigStruct(); } + + test::codemaker::cppumaker::BigStruct * const p; +}; + +void Test::testBigStruct() { + // Default-initialize a BigStruct instance on top of a memory buffer filled + // with random data, and make sure that all members are default-initialized: + boost::scoped_array< char > buffer( + new char[sizeof (test::codemaker::cppumaker::BigStruct)]); + for (std::size_t i = 0; i < sizeof (test::codemaker::cppumaker::BigStruct); + ++i) + { + buffer[i] = '\x56'; + } + Guard guard(buffer.get()); + CPPUNIT_ASSERT_EQUAL(guard.p->m1, sal_False); + CPPUNIT_ASSERT_EQUAL(guard.p->m2, static_cast< sal_Int8 >(0)); + CPPUNIT_ASSERT_EQUAL(guard.p->m3, static_cast< sal_Int16 >(0)); + CPPUNIT_ASSERT_EQUAL(guard.p->m4, static_cast< sal_uInt16 >(0)); + CPPUNIT_ASSERT_EQUAL(guard.p->m5, static_cast< sal_Int32 >(0)); + CPPUNIT_ASSERT_EQUAL(guard.p->m6, static_cast< sal_uInt32 >(0)); + CPPUNIT_ASSERT_EQUAL(guard.p->m7, static_cast< sal_Int64 >(0)); + CPPUNIT_ASSERT_EQUAL(guard.p->m8, static_cast< sal_uInt64 >(0)); + CPPUNIT_ASSERT_EQUAL(guard.p->m9, 0.0f); + CPPUNIT_ASSERT_EQUAL(guard.p->m10, 0.0); + CPPUNIT_ASSERT_EQUAL(guard.p->m11, static_cast< sal_Unicode >(0)); + CPPUNIT_ASSERT_EQUAL(guard.p->m12.getLength(), static_cast< sal_Int32 >(0)); + CPPUNIT_ASSERT_EQUAL( + guard.p->m13.getTypeClass(), com::sun::star::uno::TypeClass_VOID); + CPPUNIT_ASSERT_EQUAL(guard.p->m14.hasValue(), sal_False); + CPPUNIT_ASSERT_EQUAL(guard.p->m15.getLength(), static_cast< sal_Int32 >(0)); + CPPUNIT_ASSERT_EQUAL( + guard.p->m16, test::codemaker::cppumaker::HelperEnum_ZERO); + CPPUNIT_ASSERT_EQUAL(guard.p->m17.m1, sal_False); + CPPUNIT_ASSERT_EQUAL(guard.p->m17.m2.is(), sal_False); + CPPUNIT_ASSERT_EQUAL(guard.p->m18.is(), sal_False); + CPPUNIT_ASSERT_EQUAL(guard.p->m19, static_cast< sal_Int8 >(0)); + CPPUNIT_ASSERT_EQUAL( + guard.p->m20, test::codemaker::cppumaker::HelperEnum_ZERO); + +#if defined __GNUC__ && __GNUC__ >= 3 + CPPUNIT_ASSERT_EQUAL( + static_cast< std::size_t >(16), + sizeof (test::codemaker::cppumaker::AlignmentDerivedStruct)); +#endif +} + +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Test, "alltests"); + +} + +NOADDITIONAL; |