forked from mirror/openmw-tes3mp
Fixed and tested all Stream tests
parent
eaf93691d5
commit
c5316804b5
@ -0,0 +1,18 @@
|
||||
#include "../servers/file_stream.h"
|
||||
#include <iostream>
|
||||
|
||||
using namespace Mangle::Stream;
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
StreamPtr inp(new FileStream("file_server_test.cpp"));
|
||||
|
||||
char buf[21];
|
||||
buf[20] = 0;
|
||||
cout << "pos=" << inp->tell() << " eof=" << inp->eof() << endl;
|
||||
inp->read(buf, 20);
|
||||
cout << "First 20 bytes: " << buf << endl;
|
||||
cout << "pos=" << inp->tell() << " eof=" << inp->eof() << endl;
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
#include <iostream>
|
||||
#include <string.h>
|
||||
|
||||
#include "../filters/slice_stream.h"
|
||||
#include "../servers/memory_stream.h"
|
||||
|
||||
using namespace Mangle::Stream;
|
||||
using namespace std;
|
||||
|
||||
void test(StreamPtr inp)
|
||||
{
|
||||
cout << "Size: " << inp->size() << endl;
|
||||
cout << "Pos: " << inp->tell() << "\nSeeking...\n";
|
||||
char data[6];
|
||||
memset(data, 0, 6);
|
||||
cout << "Reading " << inp->read(data, 6) << " bytes\n";
|
||||
cout << "Result: " << data << endl;
|
||||
cout << "Pos: " << inp->tell() << endl;
|
||||
cout << "Eof: " << inp->eof() << endl;
|
||||
inp->seek(2);
|
||||
cout << "Seeking:\nPos: " << inp->tell() << endl;
|
||||
cout << "Eof: " << inp->eof() << endl;
|
||||
cout << "Reading " << inp->read(data, 6) << " bytes\n";
|
||||
cout << "Result: " << data << endl;
|
||||
cout << "Pos: " << inp->tell() << endl;
|
||||
cout << "Eof: " << inp->eof() << endl;
|
||||
cout << "Entire stream as pointer: " << (char*)inp->getPtr() << endl;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
StreamPtr orig (new MemoryStream("hello\0world\0", 12));
|
||||
StreamPtr slice1 (new SliceStream(orig,0,6));
|
||||
StreamPtr slice2 (new SliceStream(orig,6,6));
|
||||
|
||||
cout << "\nSlice 1:\n--------\n";
|
||||
test(slice1);
|
||||
cout << "\nSlice 2:\n--------\n";
|
||||
test(slice2);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
// This file should include whatever it needs to define the boost/tr1
|
||||
// shared_ptr<> template.
|
||||
#include <boost/smart_ptr.h>
|
||||
#include <boost/smart_ptr.hpp>
|
||||
|
Loading…
Reference in New Issue