// Formatting library for C++ - core tests // // Copyright (c) 2012 - present, Victor Zverovich // All rights reserved. // // For the license information refer to format.h. // clang-format off #include "test-assert.h" // clang-format on #include "fmt/base.h" #include // INT_MAX #include // std::strlen #include // std::equal_to #include // std::back_insert_iterator, std::distance #include // std::numeric_limits #include // std::string #include // std::is_same #include "gmock/gmock.h" using fmt::string_view; using fmt::detail::buffer; using testing::_; using testing::Invoke; using testing::Return; #ifdef FMT_FORMAT_H_ # error core-test includes format.h #endif fmt::appender copy(fmt::string_view s, fmt::appender out) { for (char c : s) *out++ = c; return out; } TEST(string_view_test, value_type) { static_assert(std::is_same::value, ""); } TEST(string_view_test, ctor) { EXPECT_STREQ("abc", fmt::string_view("abc").data()); EXPECT_EQ(3u, fmt::string_view("abc").size()); EXPECT_STREQ("defg", fmt::string_view(std::string("defg")).data()); EXPECT_EQ(4u, fmt::string_view(std::string("defg")).size()); } TEST(string_view_test, length) { // Test that string_view::size() returns string length, not buffer size. char str[100] = "some string"; EXPECT_EQ(std::strlen(str), string_view(str).size()); EXPECT_LT(std::strlen(str), sizeof(str)); } // Check string_view's comparison operator. template