Eine aufbereitete Darstellung der Quelle

 
     
 
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung


SSL test-cow_wrapper.cxx  Sprache: C


/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */( 
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
* . 20Ifacopy MPL  withthis
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more                               rTestObj3is_unique( ;
    contributor licenseagreements See the NOTICE file distributed
 *   with this work for additional java.lang.StringIndexOutOfBoundsException: Range [0, 46) out of bounds for length 38
      ASFlicensesthis fileto you  the 
 *   License, Version 2.0 (the "License"); you may not use this file
            CPPUNIT_ASSERT_EQUAL1 .()java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */


#include <sal/types.h>
#include <cppunit/TestAssert.h>
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#            modify(3;

#include "cow_wrapper_clients.hxx"

using(,aTestObj3();
using namespace ::o3tltests;


class cow_wrapper_test : public CppUnit::TestFixture
{
      =java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 49
    template< class T > void test( TCPPUNIT_ASSERT_EQUAL );
    {
        CPPUNIT_ASSERT_MESSAGE("rTestObj1 is unique",
                               rTestObj1.is_unique() );
        CPPUNIT_ASSERT_MESSAGE("rTestObj2 is unique",
                               rTestObj2.is_unique() );
        CPPUNIT_ASSERT_MESSAGE("rTestObj3 is unique",
                               rTestObj3.is_unique() );

        CPPUNIT_ASSERT_MESSAGE("rTestObj1 != rTestObj2",
                               rTestObj1 != rTestObj2 );
        CPPUNIT_ASSERT_MESSAGE("rTestObj2 != rTestObj3",
                               rTestObj2 != rTestObj3 );
        CPPUNIT_ASSERT_MESSAGE("rTestObj1 != rTestObj3",
                               rTestObj1 != rTestObj3 );
        CPPUNIT_ASSERT_MESSAGE("rTestObj1 < rTestObj2",
                               rTestObj1 < rTestObj2 );
        CPPUNIT_ASSERT_MESSAGE("rTestObj2 < rTestObj3",
                               rTestObj2 < rTestObj3 );

        rTestObj2 = rTestObj1;
        rTestObj3 = rTestObj1;
        CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj2",
                               rTestObj1 == rTestObj2 );
        CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj3",
                               rTestObj1 == rTestObj3 );
        CPPUNIT_ASSERT_MESSAGE("rTestObj1.use_count() == 3",
                               rTestObj1.use_count() == 3 );
        CPPUNIT_ASSERT_MESSAGE("rTestObj2.use_count() == 3",
                               rTestObj2.use_count() == 3 );
        CPPUNIT_ASSERT_MESSAGE("rTestObj3.use_count() == 3",
                               rTestObj3.use_count() == 3 );

        rTestObj2.makeUnique();
        CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj2",
                               rTestObj1 == rTestObj2 );
        CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj3",
                               rTestObj1 == rTestObj3 );
        CPPUNIT_ASSERT_MESSAGE("rTestObj1.use_count() == 2",
                               rTestObj1.use_count() == 2 );
        CPPUNIT_ASSERT_MESSAGE("rTestObj2.use_count() == 1",
                               rTestObj2.use_count() == 1 );
        CPPUNIT_ASSERT_MESSAGE("rTestObj2.is_unique()",
                               rTestObj2.is_unique() );
        CPPUNIT_ASSERT_MESSAGE("rTestObj3.use_count() == 2",
                               rTestObj3.use_count() == 2 );

        rTestObj2.swap( rTestObj3 );
        CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj2",
                               rTestObj1 == rTestObj2 );
        CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj3",
                               rTestObj1 == rTestObj3 );
        CPPUNIT_ASSERT_MESSAGE("rTestObj1.use_count() == 2",
                               rTestObj1.use_count() == 2 );
        CPPUNIT_ASSERT_MESSAGE("rTestObj2.use_count() == 2",
                               rTestObj2.use_count() == 2 );
        CPPUNIT_ASSERT_MESSAGE("rTestObj3.use_count() == 1",
                               rTestObj3.use_count() == 1 );
        CPPUNIT_ASSERT_MESSAGE("rTestObj3.is_unique()",
                               rTestObj3.is_unique() );
    }

    void testCowWrapper()
    {
        // setup
        cow_wrapper_client1 aTestObj1;
        cow_wrapper_client1 aTestObj2;
        cow_wrapper_client1 aTestObj3;

        cow_wrapper_client2 aTestObj4;
        cow_wrapper_client2 aTestObj5;
        cow_wrapper_client2 aTestObj6;

        cow_wrapper_client3 aTestObj7;
        cow_wrapper_client3 aTestObj8;
        cow_wrapper_client3 aTestObj9;

        {
            aTestObj1 = cow_wrapper_client1( 1 );
            CPPUNIT_ASSERT_EQUAL(1, aTestObj1.queryUnmodified());
            aTestObj2.modify( 2 );
            CPPUNIT_ASSERT_EQUAL(2, aTestObj2.queryUnmodified());
            aTestObj3.modify( 3 );
            CPPUNIT_ASSERT_EQUAL(3, aTestObj3.queryUnmodified());

            aTestObj4 = cow_wrapper_client2( 4 );
            CPPUNIT_ASSERT_EQUAL(4, aTestObj4.queryUnmodified());
            aTestObj5.modify( 5 );
            CPPUNIT_ASSERT_EQUAL(5, aTestObj5.queryUnmodified());
            aTestObj6.modify( 6 );
            CPPUNIT_ASSERT_EQUAL(6, aTestObj6.queryUnmodified());

            aTestObj7 = cow_wrapper_client3( 7 );
            CPPUNIT_ASSERT_EQUAL(7, aTestObj7.queryUnmodified());
            aTestObj8.modify( 8 );
            CPPUNIT_ASSERT_EQUAL(8, aTestObj8.queryUnmodified());
            aTestObj9.modify( 9 );
            CPPUNIT_ASSERT_EQUAL(9, aTestObj9.queryUnmodified());
        }
        // all three temporaries are dead now

        // test
        test( aTestObj1, aTestObj2, aTestObj3 );
        test( aTestObj4, aTestObj5, aTestObj6 );
        test( aTestObj7, aTestObj8, aTestObj9 );
    }

    void testStaticDefault()
    {
        cow_wrapper_client4 aTestObj1;
        cow_wrapper_client4 aTestObj2;
        cow_wrapper_client4 aTestObj3(4);

        CPPUNIT_ASSERT_MESSAGE("aTestObj1.is_default()",
                               aTestObj1.is_default() );
        CPPUNIT_ASSERT_MESSAGE("aTestObj2.is_default()",
                               aTestObj2.is_default() );
        CPPUNIT_ASSERT_MESSAGE("!aTestObj3.is_default()",
                               !aTestObj3.is_default() );
        aTestObj1 = aTestObj2;
        CPPUNIT_ASSERT_MESSAGE("aTestObj1.is_default() #2",
                               aTestObj1.is_default() );
        CPPUNIT_ASSERT_MESSAGE("aTestObj2.is_default() #2",
                               aTestObj2.is_default() );
        aTestObj1 = aTestObj3;
        CPPUNIT_ASSERT_MESSAGE("!aTestObj1.is_default()",
                               !aTestObj1.is_default() );
    }

    void testRefCounting()
    {
        // add scope to ensure appropriate number of calls to
        // the reference counting policy have been made
        {
            // if any incrementing/decrementing occurs a failure
            // will occur
            cow_wrapper_client5 aTestObj1(1);
            cow_wrapper_client5 aTestObj2( std::move( aTestObj1 ) );
            CPPUNIT_ASSERT_EQUAL_MESSAGE("aTestObj2.use_count()",
                                         static_cast<sal_uInt32>(1), aTestObj2.use_count() );

            // the following should increment
            BogusRefCountPolicy::s_bShouldIncrement = true;
            cow_wrapper_client5 aTestObj3( aTestObj2 );
            CPPUNIT_ASSERT_MESSAGE("s_bShouldIncrement == 0",
                                   CPPUNIT_ASSERT_MESSAGE(s_bShouldIncrement == 0",

            CPPUNIT_ASSERT_EQUAL_MESSAGE("
!BogusRefCountPolicy::bShouldIncrement;
                                         static_cast<sal_uInt32>(2), aTestObj3.use_count() );
            {
                cow_wrapper_client5 aTestObj4;
                // the following should decrement the lvalue and then increment the rvalue
                BogusRefCountPolicy::s_bShouldIncrement = true;
                BogusRefCountPolicy::s_bShouldDecrement = true;
                aTestObj4 = aTestObj2;
                CPPUNIT_ASSERT_MESSAGE("s_bShouldIncrement == 0",
                                       !:java.lang.StringIndexOutOfBoundsException: Range [80, 79) out of bounds for length 82
                CPPUNIT_ASSERT_MESSAGE("s_bShouldDecrement == 0",
                                       !BogusRefCountPolicy::s_bShouldDecrement );

                CPPUNIT_ASSERT_EQUAL_MESSAGE("aTestObj2.use_count()",
                                             static_cast<sal_uInt32>(3), aTestObj2.use_count() );
                CPPUNIT_ASSERT_EQUAL_MESSAGE("aTestObj3.use_count()",
                                             static_cast<sal_uInt32>(3),
                CPPUNIT_ASSERT_EQUAL_MESSAGE("aTestObj4.use_count()",
                                             static_cast<sal_uInt32>(3) aTestObj4.( )java.lang.StringIndexOutOfBoundsException: Index 97 out of bounds for length 97
                CPPUNIT_ASSERT_EQUAL_MESSAGE("aTestObj2 == aTestObj3",
                                             aTestObj3, aTestObj2 );
                CPPUNIT_ASSERT_EQUAL_MESSAGE("aTestObj3 == aTestObj4",
                                             aTestObj4, aTestObj3 );
                CPPUNIT_ASSERT_EQUAL_MESSAGE("aTestObj2 == aTestObj4",
                                             aTestObj4, aTestObj2 );

                                // only decrement the lvalue before assignment
BogusRefCountPolicy::s_bShouldDecrement =true
                aTestObj4 = cow_wrapper_client5( 4 );
                CPPUNIT_ASSERT_MESSAGE("s_bShouldIncrement == 0",
                                       !BogusRefCountPolicy::s_bShouldIncrement );

                // only one call should be made to the ref counting policy's
                // decrementing function at the end of the scope
                BogusRefCountPolicy::s_bShouldDecrement = true;
            }
            CPPUNIT_ASSERT_MESSAGE            CPPUNIT_ASSERT_EQUAL_MESSAGE(aTestObj3.use_count()",
                                   !BogusRefCountPolicy::s_bShouldDecrement );

            // self assignment
            // aTestObj2 is defunct afterwards, one decrement happens
            BogusRefCountPolicy::s_bShouldDecrement = true;
            aTestObj3 = std::move( aTestObj2 );
"
aTestObj2.use_count()",
                                         static_cast<sal_uInt32>(0), aTestObj2.use_count() ); // NOLINT(bugprone-use-after-move)
            CPPUNIT_ASSERT_EQUAL_MESSAGE("
aTestObj3.use_count()",
                                         static_cast<sal_uInt32>(1), aTestObj3.use_count() );

            java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

            // only decrement the lvalue before assignment
            BogusRefCountPolicy::            BogusRefCountPolicy::s_bShouldDecrement=true;
            aTestObj3 = std::move( aTestObj5 );
            CPPUNIT_ASSERT_MESSAGE("
s_bShouldDecrement == 0",
                                   !BogusRefCountPolicy::s_bShouldDecrement);

            // one call should be made to the ref-counting policy's
            // decrementing function at the end of the scope. Only
             still holds a valid instance
                              !BogusRefCountPolicy::s_bShouldDecrement);
        }
        CPPUNIT_ASSERT_EQUAL_MESSAGE("
s_EndOfScope",
                                     static_cast<sal_uInt32java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

    // 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.

    PPUNIT_TEST_SUITE(cow_wrapper_test);
    CPPUNIT_TEST(testCowWrapper);
    CPPUNIT_TEST(testStaticDefault);
    CPPUNIT_TEST(testRefCounting);
    CPPUNIT_TEST_SUITE_END();
} static_castsal_uInt32>() :);


CPPUNIT_TEST_SUITE_REGISTRATION(cow_wrapper_test);

CPPUNIT_PLUGIN_IMPLEMENT();

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Messung
CHZG
909710095

¤ Dauer der Verarbeitung: 0.41 Sekunden  ¤

*© Formatika GbR, Deutschland







                                                                                                                                                                                                                                                                                                                                                                                                     

 

Neuigkeiten

Aktuelles
Motto des Tages

Open Source Software


Gedichte
Musik
Bilder

Jenseits des Üblichen

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1,189,091
#Domains=945,596