Skip to content

Commit 84861ba

Browse files
committed
add non compressed test, create single header file
1 parent 9030ad2 commit 84861ba

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

test/CMakeLists.txt

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 2.8)
1+
cmake_minimum_required(VERSION 3.1)
22
project(zstream-cpp)
33

44
find_package(ZLIB REQUIRED)
@@ -16,3 +16,18 @@ target_link_libraries(input_test ${ZLIB_LIBRARIES})
1616

1717
add_executable(buffer_test buffer_test.cpp)
1818
target_link_libraries(buffer_test ${ZLIB_LIBRARIES})
19+
20+
add_executable(nocompression_test nocompression_test.cpp)
21+
target_link_libraries(nocompression_test ${ZLIB_LIBRARIES})
22+
23+
# CREATE single header file
24+
25+
file(READ "${CMAKE_SOURCE_DIR}/../zstream_common.hpp" COMMON_CONTENT)
26+
file(READ "${CMAKE_SOURCE_DIR}/../izstream.hpp" IZSTREAM_CONTENT)
27+
file(READ "${CMAKE_SOURCE_DIR}/../izstream_impl.hpp" IZSTREAM_IMPL_CONTENT)
28+
file(READ "${CMAKE_SOURCE_DIR}/../ozstream.hpp" OZSTREAM_CONTENT)
29+
file(READ "${CMAKE_SOURCE_DIR}/../ozstream_impl.hpp" OZSTREAM_IMPL_CONTENT)
30+
31+
string(REPLACE "#include \"" "//#include \"" CONTENT "${COMMON_CONTENT} ${OZSTREAM_CONTENT} ${OZSTREAM_IMPL_CONTENT} ${IZSTREAM_CONTENT} ${IZSTREAM_IMPL_CONTENT}")
32+
33+
file(WRITE "${CMAKE_BINARY_DIR}/zstream.hpp" "${CONTENT}")

test/nocompression_test.cpp

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
4+
#include "zstream.hpp"
5+
#include <fstream>
6+
#include <iterator>
7+
#include <iostream>
8+
9+
using namespace std;
10+
using namespace zstream;
11+
12+
int main(void)
13+
{
14+
string input = "Hello world \n";
15+
ostringstream buffer;
16+
{
17+
ozstream zipper(buffer, 0);
18+
zipper << input;
19+
}
20+
string zstr = buffer.str();
21+
22+
istringstream ibuffer(zstr);
23+
izstream izstream(ibuffer);
24+
izstream.unsetf(ios_base::skipws);
25+
26+
string output = std::string((std::istream_iterator<char>(izstream)),
27+
std::istream_iterator<char>());
28+
29+
if (output != input)
30+
{
31+
cout << "compare failed" << endl;
32+
return 1;
33+
}
34+
else
35+
{
36+
cout << "compare succeeded" << endl;
37+
return 0;
38+
}
39+
}

0 commit comments

Comments
 (0)