William A. Kennington III | 0475b6d | 2023-07-21 14:28:54 -0700 | [diff] [blame^] | 1 | #include <stdplus/print.hpp> |
| 2 | |
| 3 | #include <cstdio> |
| 4 | |
| 5 | #include <gtest/gtest.h> |
| 6 | |
| 7 | namespace stdplus |
| 8 | { |
| 9 | |
| 10 | TEST(Print, Basic) |
| 11 | { |
| 12 | auto file = std::tmpfile(); |
| 13 | print(file, "hello"); |
| 14 | print(file, "hi {}\n", 4); |
| 15 | println(file, "ho\n"); |
| 16 | println(file, "ho {}", 16); |
| 17 | EXPECT_EQ(0, std::fseek(file, 0, SEEK_SET)); |
| 18 | constexpr std::string_view expect = "hellohi 4\nho\n\nho 16\n"; |
| 19 | std::string buf(expect.size(), '\0'); |
| 20 | EXPECT_EQ(buf.size(), |
| 21 | std::fread(buf.data(), sizeof(char), buf.size() + 1, file)); |
| 22 | EXPECT_EQ(buf, expect); |
| 23 | EXPECT_EQ(0, std::fclose(file)); |
| 24 | |
| 25 | print("hello"); |
| 26 | print("hi {}\n", 4); |
| 27 | println("ho\n"); |
| 28 | println("ho {}", 16); |
| 29 | } |
| 30 | |
| 31 | } // namespace stdplus |