1
// -*- mode: C++; tab-width: 2; -*-
4
// --------------------------------------------------------------------------
5
// OpenMS Mass Spectrometry Framework
6
// --------------------------------------------------------------------------
7
// Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
9
// This library is free software; you can redistribute it and/or
10
// modify it under the terms of the GNU Lesser General Public
11
// License as published by the Free Software Foundation; either
12
// version 2.1 of the License, or (at your option) any later version.
14
// This library is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
// Lesser General Public License for more details.
19
// You should have received a copy of the GNU Lesser General Public
20
// License along with this library; if not, write to the Free Software
21
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
// --------------------------------------------------------------------------
24
// $Maintainer: David Wojnar$
25
// $Authors: David Wojnar $
26
// --------------------------------------------------------------------------
28
#include <OpenMS/CONCEPT/ClassTest.h>
30
///////////////////////////
31
#include <OpenMS/FORMAT/Bzip2InputStream.h>
33
using namespace OpenMS;
36
///////////////////////////
38
START_TEST(Bzip2InputStream, "$Id: Bzip2InputStream_test.C 8226 2011-04-05 11:35:18Z aiche $")
40
Bzip2InputStream* ptr = 0;
41
Bzip2InputStream* nullPointer = 0;
42
START_SECTION(Bzip2InputStream(const char* const file_name))
43
TEST_EXCEPTION(Exception::FileNotFound, Bzip2InputStream bzip2(OPENMS_GET_TEST_DATA_PATH("ThisFileDoesNotExist")))
44
ptr = new Bzip2InputStream(OPENMS_GET_TEST_DATA_PATH("Bzip2IfStream_1.bz2"));
45
TEST_NOT_EQUAL(ptr, nullPointer)
46
TEST_EQUAL(ptr->getIsOpen(),true)
49
START_SECTION((~Bzip2InputStream()))
53
START_SECTION(Bzip2InputStream(const String& file_name))
54
TEST_EXCEPTION(Exception::FileNotFound, Bzip2InputStream bzip2(OPENMS_GET_TEST_DATA_PATH("ThisFileDoesNotExist")))
55
String filename = OPENMS_GET_TEST_DATA_PATH("Bzip2IfStream_1.bz2");
56
ptr = new Bzip2InputStream(filename);
57
TEST_NOT_EQUAL(ptr, nullPointer)
58
TEST_EQUAL(ptr->getIsOpen(),true)
62
START_SECTION(virtual XMLSize_t readBytes(XMLByte *const to_fill, const XMLSize_t max_to_read))
64
Bzip2InputStream bzip(OPENMS_GET_TEST_DATA_PATH("Bzip2IfStream_1.bz2"));
66
buffer[30] = buffer[29] = '\0';
67
XMLByte* xml_buffer = reinterpret_cast<XMLByte* >(buffer);
68
TEST_EQUAL(bzip.getIsOpen(),true)
69
TEST_EQUAL(bzip.readBytes(xml_buffer,(XMLSize_t)10),10)
70
TEST_EQUAL(bzip.readBytes(&xml_buffer[10],(XMLSize_t)10),10)
71
TEST_EQUAL(bzip.readBytes(&xml_buffer[20],(XMLSize_t)9),9)
72
TEST_EQUAL(String(buffer), String("Was decompression successful?"))
73
TEST_EQUAL(bzip.getIsOpen(),true)
74
TEST_EQUAL(bzip.readBytes(&xml_buffer[30],(XMLSize_t)10),1)
75
TEST_EQUAL(bzip.getIsOpen(),false)
79
START_SECTION(XMLFilePos curPos() const)
80
Bzip2InputStream bzip(OPENMS_GET_TEST_DATA_PATH("Bzip2IfStream_1.bz2"));
81
TEST_EQUAL(bzip.curPos(), 0)
83
buffer[30] = buffer[29] = '\0';
84
XMLByte* xml_buffer = reinterpret_cast<XMLByte* >(buffer);
85
bzip.readBytes(xml_buffer,(XMLSize_t)10);
86
TEST_EQUAL(bzip.curPos(),10)
90
START_SECTION(bool getIsOpen() const)
95
START_SECTION(virtual const XMLCh* getContentType() const)
96
Bzip2InputStream bzip2(OPENMS_GET_TEST_DATA_PATH("Bzip2IfStream_1.bz2"));
97
XMLCh* xmlch_nullPointer = 0;
98
TEST_EQUAL(bzip2.getContentType(),xmlch_nullPointer)
101
/////////////////////////////////////////////////////////////
102
/////////////////////////////////////////////////////////////