X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=tests%2Fmemory.cpp;fp=tests%2Fmemory.cpp;h=5c3fa69a493622c37e4769d17d9993566c64a8bd;hp=0000000000000000000000000000000000000000;hb=120023d8da0aabcb803a87111608ce84c94661f8;hpb=79482ba7aea1b79c7a310c940cc0292532ef3bcb diff --git a/tests/memory.cpp b/tests/memory.cpp new file mode 100644 index 0000000..5c3fa69 --- /dev/null +++ b/tests/memory.cpp @@ -0,0 +1,73 @@ +#include +#include + +using namespace std; +using namespace Msp; + +class MemoryTests: public Test::RegisteredTest +{ +public: + MemoryTests(); + + static const char *get_name() { return "Memory"; } + +private: + void write(); + void read(); + void getline(); + void invalid_access(); +}; + + +MemoryTests::MemoryTests() +{ + add(&MemoryTests::write, "write"); + add(&MemoryTests::read, "read"); + add(&MemoryTests::getline, "getline"); + add(&MemoryTests::invalid_access, "invalid_access").expect_throw(); +} + +void MemoryTests::write() +{ + char buf[64] = { }; + IO::Memory mem(buf, sizeof(buf)); + mem.write("foobar"); + EXPECT(equal(buf, buf+6, "foobar")); + for(unsigned i=6; i