mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add memory_istream
This commit is contained in:
parent
8a8c1525fd
commit
decb820cf9
2 changed files with 53 additions and 0 deletions
19
test/io/memory_istream.cpp
Normal file
19
test/io/memory_istream.cpp
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include "io/memory_istream.hpp"
|
||||
|
||||
TEST(io, memory_istream) {
|
||||
const char data[] = "Hello, world!";
|
||||
const int n = std::strlen(data);
|
||||
|
||||
util::Buffer<char> buffer(data, n);
|
||||
memory_istream stream(std::move(buffer));
|
||||
|
||||
ASSERT_TRUE(stream.good());
|
||||
|
||||
std::string text(n, '\0');
|
||||
stream.read(text.data(), n);
|
||||
ASSERT_EQ(text, std::string(data));
|
||||
stream.read(text.data(), 1);
|
||||
ASSERT_TRUE(stream.eof());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue