The source code and dockerfile for the GSW2024 AI Lab.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

66 lines
1.7 KiB

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