mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 04:41:16 +00:00
Merge ostream_wrapper fix from core
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
add_subdirectory(gtest-1.7.0)
|
||||
include_directories(gtest-1.7.0/include)
|
||||
|
||||
file(GLOB test_headers [a-z]*.h)
|
||||
file(GLOB test_sources [a-z]*.cpp)
|
||||
file(GLOB test_headers [a-z_]*.h)
|
||||
file(GLOB test_sources [a-z_]*.cpp)
|
||||
file(GLOB test_new_api_sources new-api/[a-z]*.cpp)
|
||||
|
||||
list(APPEND test_sources ${test_new_api_sources})
|
||||
|
66
test/ostream_wrapper_test.cpp
Normal file
66
test/ostream_wrapper_test.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#include "yaml-cpp/ostream_wrapper.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "gtest/gtest.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());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user