1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: rtl_old_testbyteseq.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sal.hxx"
34 // this file is converted to use with testshl2
35 // original was placed in sal/test/textenc.cxx
36 // -----------------------------------------------------------------------------
40 // #include <osl/diagnose.h>
41 #include <rtl/byteseq.hxx>
43 using namespace ::rtl
;
45 #include <cppunit/simpleheader.hxx>
48 namespace rtl_testbyteseq
51 // -----------------------------------------------------------------------------
53 class oldbyteseq
: public CppUnit::TestFixture
56 void test_bytesequence_001();
58 CPPUNIT_TEST_SUITE( oldbyteseq
);
59 CPPUNIT_TEST( test_bytesequence_001
);
60 CPPUNIT_TEST_SUITE_END( );
63 // -----------------------------------------------------------------------------
65 void oldbyteseq::test_bytesequence_001()
67 signed char a
[5] = { 1 , 2 , 3 , 4 , 5 };
69 // test the c++ wrapper
72 OSL_ENSURE( ! seq
.getLength() , "" );
74 ByteSequence
seq2( a
, 5 );
76 OSL_ENSURE( !( seq
== seq2
) , "" );
79 OSL_ENSURE( seq
== seq2
, "" );
82 OSL_ENSURE( !(seq
== seq2
) , "" );
84 seq
= ByteSequence( a
, 5 );
85 OSL_ENSURE( seq
== seq2
, "" );
87 seq
= ByteSequence( 5 ); // default value is 0 for each byte
88 OSL_ENSURE( !( seq
== seq2
) , "" );
92 sal_Sequence
*pSeq
= 0;
93 rtl_byte_sequence_construct( &pSeq
, 0 );
95 // implementation dependent test.
96 OSL_ENSURE( pSeq
->nRefCount
== 2 , "invalid refcount for empty sequence" );
98 sal_Sequence
*pSeq2
= 0;
99 rtl_byte_sequence_constructFromArray( &pSeq2
, a
, 5 );
101 OSL_ENSURE( ! rtl_byte_sequence_equals( pSeq
, pSeq2
) , "" );
103 rtl_byte_sequence_assign( &pSeq
, pSeq2
);
104 OSL_ENSURE( pSeq
== pSeq2
, "" );
105 OSL_ENSURE( rtl_byte_sequence_equals( pSeq
, pSeq2
) , "" );
107 rtl_byte_sequence_reference2One( &pSeq
);
108 (( sal_Int8
*) rtl_byte_sequence_getConstArray( pSeq
) )[0] = 2;
110 OSL_ENSURE( ! rtl_byte_sequence_equals( pSeq
, pSeq2
) , "" );
112 rtl_byte_sequence_constructFromArray( &pSeq
, a
, 5 );
113 OSL_ENSURE( rtl_byte_sequence_equals( pSeq
, pSeq2
) , "" );
115 rtl_byte_sequence_construct( &pSeq
, 5 );
116 OSL_ENSURE( ! rtl_byte_sequence_equals( pSeq
, pSeq2
) , "" );
120 rtl_byte_sequence_release( pSeq2
);
121 rtl_byte_sequence_release( pSeq
);
125 printf( "test bytesequence OK\n" );
129 } // namespace osl_test_file
131 // -----------------------------------------------------------------------------
132 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( rtl_testbyteseq::oldbyteseq
, "rtl_ByteSequence" );
134 // -----------------------------------------------------------------------------