LCOV - code coverage report
Current view: top level - sal/qa/rtl/oustringbuffer - test_oustringbuffer_appenduninitialized.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 31 31 100.0 %
Date: 2015-06-13 12:38:46 Functions: 14 14 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #include <sal/config.h>
      11             : 
      12             : #include <cppunit/TestAssert.h>
      13             : #include <cppunit/TestFixture.h>
      14             : #include <cppunit/extensions/HelperMacros.h>
      15             : #include <rtl/ustrbuf.hxx>
      16             : #include <sal/types.h>
      17             : 
      18             : namespace {
      19             : 
      20           9 : class Test: public CppUnit::TestFixture {
      21             : private:
      22             :     void testEmpty();
      23             : 
      24             :     void testNonEmpty();
      25             : 
      26             :     void testZero();
      27             : 
      28           2 :     CPPUNIT_TEST_SUITE(Test);
      29           1 :     CPPUNIT_TEST(testEmpty);
      30           1 :     CPPUNIT_TEST(testNonEmpty);
      31           1 :     CPPUNIT_TEST(testZero);
      32           5 :     CPPUNIT_TEST_SUITE_END();
      33             : };
      34             : 
      35           1 : void Test::testEmpty() {
      36           1 :     OUStringBuffer s;
      37           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), s.getLength());
      38           1 :     sal_Unicode * p = s.appendUninitialized(5);
      39           2 :     CPPUNIT_ASSERT_EQUAL(
      40           1 :         static_cast<void const *>(s.getStr()), static_cast<void const *>(p));
      41           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(5), s.getLength());
      42           1 : }
      43             : 
      44           1 : void Test::testNonEmpty() {
      45           1 :     OUStringBuffer s("ab");
      46           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(2), s.getLength());
      47           1 :     sal_Unicode * p = s.appendUninitialized(5);
      48           2 :     CPPUNIT_ASSERT_EQUAL(
      49             :         static_cast<void const *>(s.getStr() + 2),
      50           1 :         static_cast<void const *>(p));
      51           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(7), s.getLength());
      52           1 : }
      53             : 
      54           1 : void Test::testZero() {
      55           1 :     OUStringBuffer s;
      56           1 :     sal_Unicode * p = s.appendUninitialized(0);
      57           2 :     CPPUNIT_ASSERT_EQUAL(
      58           1 :         static_cast<void const *>(s.getStr()), static_cast<void const *>(p));
      59           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), s.getLength());
      60           1 : }
      61             : 
      62           1 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
      63             : 
      64           3 : }
      65             : 
      66             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11