1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
10 #include <cppunit/TestAssert.h>
11 #include <cppunit/TestFixture.h>
12 #include <cppunit/extensions/HelperMacros.h>
14 #include <vcl/BinaryDataContainer.hxx>
20 class BinaryDataContainerTest
: public CppUnit::TestFixture
24 CPPUNIT_TEST_SUITE(BinaryDataContainerTest
);
25 CPPUNIT_TEST(testConstruct
);
26 CPPUNIT_TEST_SUITE_END();
29 void BinaryDataContainerTest::testConstruct()
32 BinaryDataContainer aContainer
;
33 CPPUNIT_ASSERT(aContainer
.isEmpty());
34 CPPUNIT_ASSERT_EQUAL(size_t(0), aContainer
.getSize());
37 // construct a data array
38 sal_uInt8 aTestByteArray
[] = { 1, 2, 3, 4 };
39 SvMemoryStream
stream(aTestByteArray
, std::size(aTestByteArray
), StreamMode::READ
);
41 BinaryDataContainer
aContainer(stream
, std::size(aTestByteArray
));
43 CPPUNIT_ASSERT(!aContainer
.isEmpty());
44 CPPUNIT_ASSERT_EQUAL(size_t(4), aContainer
.getSize());
47 BinaryDataContainer aCopyOfContainer
= aContainer
;
48 CPPUNIT_ASSERT(!aCopyOfContainer
.isEmpty());
49 CPPUNIT_ASSERT_EQUAL(size_t(4), aCopyOfContainer
.getSize());
50 CPPUNIT_ASSERT_EQUAL(aCopyOfContainer
.getData(), aContainer
.getData());
53 BinaryDataContainer aMovedInContainer
= std::move(aCopyOfContainer
);
54 CPPUNIT_ASSERT(!aMovedInContainer
.isEmpty());
55 CPPUNIT_ASSERT_EQUAL(size_t(4), aMovedInContainer
.getSize());
56 CPPUNIT_ASSERT_EQUAL(aMovedInContainer
.getData(), aContainer
.getData());
58 CPPUNIT_ASSERT(aCopyOfContainer
.isEmpty());
59 CPPUNIT_ASSERT_EQUAL(size_t(0), aCopyOfContainer
.getSize());
65 CPPUNIT_TEST_SUITE_REGISTRATION(BinaryDataContainerTest
);
67 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */