mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-20 17:39:46 +00:00
update memory_ostream
This commit is contained in:
parent
7994d41b19
commit
ec51848447
2 changed files with 110 additions and 45 deletions
22
test/io/memory_ostream.cpp
Normal file
22
test/io/memory_ostream.cpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include "io/memory_ostream.hpp"
|
||||
|
||||
TEST(io, memory_ostream) {
|
||||
const char data[] = "Hello, world!";
|
||||
const int n = std::strlen(data);
|
||||
|
||||
memory_ostream stream;
|
||||
ASSERT_TRUE(stream.good());
|
||||
|
||||
stream.write(data, n);
|
||||
ASSERT_EQ(std::string(stream.view()), std::string(data));
|
||||
|
||||
stream.seekp(0);
|
||||
ASSERT_TRUE(stream.good());
|
||||
stream.write("Remove", 6);
|
||||
ASSERT_EQ(std::string(stream.view()), "Remove world!");
|
||||
|
||||
auto buffer = stream.release();
|
||||
ASSERT_EQ(std::string(buffer.data(), buffer.size()), "Remove world!");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue