1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#include <sstream>
#include <cstddef>
#include "gtest/gtest.h"
#include "yaml-cpp/ostream_wrapper.h"
namespace {
TEST(OstreamWrapperTest, BufferNoWrite) {
YAML::ostream_wrapper wrapper;
EXPECT_STREQ("", wrapper.str());
}
TEST(OstreamWrapperTest, BufferWriteStr) {
YAML::ostream_wrapper wrapper;
wrapper.write(std::string("Hello, world"));
EXPECT_STREQ("Hello, world", wrapper.str());
}
TEST(OstreamWrapperTest, BufferWriteCStr) {
YAML::ostream_wrapper wrapper;
wrapper.write("Hello, world");
EXPECT_STREQ("Hello, world", wrapper.str());
}
TEST(OstreamWrapperTest, StreamNoWrite) {
std::stringstream stream;
YAML::ostream_wrapper wrapper(stream);
EXPECT_STREQ(NULL, wrapper.str());
EXPECT_EQ("", stream.str());
}
TEST(OstreamWrapperTest, StreamWriteStr) {
std::stringstream stream;
YAML::ostream_wrapper wrapper(stream);
wrapper.write(std::string("Hello, world"));
EXPECT_STREQ(NULL, wrapper.str());
EXPECT_EQ("Hello, world", stream.str());
}
TEST(OstreamWrapperTest, StreamWriteCStr) {
std::stringstream stream;
YAML::ostream_wrapper wrapper(stream);
wrapper.write("Hello, world");
EXPECT_STREQ(NULL, wrapper.str());
EXPECT_EQ("Hello, world", stream.str());
}
TEST(OstreamWrapperTest, Position) {
YAML::ostream_wrapper wrapper;
wrapper.write("Hello, world\n");
EXPECT_EQ(1, wrapper.row());
EXPECT_EQ(0, wrapper.col());
EXPECT_EQ(13, wrapper.pos());
}
TEST(OstreamWrapperTest, Comment) {
YAML::ostream_wrapper wrapper;
wrapper.write("Hello, world ");
wrapper.set_comment();
EXPECT_TRUE(wrapper.comment());
wrapper.write("foo");
EXPECT_TRUE(wrapper.comment());
wrapper.write("\n");
EXPECT_FALSE(wrapper.comment());
}
}
|