Follow naming conventions in tests
This commit is contained in:
parent
39818e7979
commit
847aac4315
@ -7,9 +7,9 @@
|
||||
|
||||
#include "fmt/args.h"
|
||||
|
||||
#include "gmock.h"
|
||||
#include "gtest.h"
|
||||
|
||||
TEST(ArgsTest, Basic) {
|
||||
TEST(args_test, basic) {
|
||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
||||
store.push_back(42);
|
||||
store.push_back("abc1");
|
||||
@ -17,7 +17,7 @@ TEST(ArgsTest, Basic) {
|
||||
EXPECT_EQ("42 and abc1 and 1.5", fmt::vformat("{} and {} and {}", store));
|
||||
}
|
||||
|
||||
TEST(ArgsTest, StringsAndRefs) {
|
||||
TEST(args_test, strings_and_refs) {
|
||||
// Unfortunately the tests are compiled with old ABI so strings use COW.
|
||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
||||
char str[] = "1234567890";
|
||||
@ -47,7 +47,7 @@ template <> struct formatter<custom_type> {
|
||||
};
|
||||
FMT_END_NAMESPACE
|
||||
|
||||
TEST(ArgsTest, CustomFormat) {
|
||||
TEST(args_test, custom_format) {
|
||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
||||
auto c = custom_type();
|
||||
store.push_back(c);
|
||||
@ -70,14 +70,13 @@ template <> struct formatter<to_stringable> {
|
||||
return ctx.begin();
|
||||
}
|
||||
|
||||
template <typename FormatContext>
|
||||
auto format(const to_stringable&, FormatContext& ctx) -> decltype(ctx.out()) {
|
||||
auto format(to_stringable, format_context& ctx) -> decltype(ctx.out()) {
|
||||
return ctx.out();
|
||||
}
|
||||
};
|
||||
FMT_END_NAMESPACE
|
||||
|
||||
TEST(ArgsTest, ToStringAndFormatter) {
|
||||
TEST(args_test, to_string_and_formatter) {
|
||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
||||
auto s = to_stringable();
|
||||
store.push_back(s);
|
||||
@ -85,13 +84,13 @@ TEST(ArgsTest, ToStringAndFormatter) {
|
||||
fmt::vformat("", store);
|
||||
}
|
||||
|
||||
TEST(ArgsTest, NamedInt) {
|
||||
TEST(args_test, named_int) {
|
||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
||||
store.push_back(fmt::arg("a1", 42));
|
||||
EXPECT_EQ("42", fmt::vformat("{a1}", store));
|
||||
}
|
||||
|
||||
TEST(ArgsTest, NamedStrings) {
|
||||
TEST(args_test, named_strings) {
|
||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
||||
char str[] = "1234567890";
|
||||
store.push_back(fmt::arg("a1", str));
|
||||
@ -100,7 +99,7 @@ TEST(ArgsTest, NamedStrings) {
|
||||
EXPECT_EQ("1234567890 and X234567890", fmt::vformat("{a1} and {a2}", store));
|
||||
}
|
||||
|
||||
TEST(ArgsTest, NamedArgByRef) {
|
||||
TEST(args_test, named_arg_by_ref) {
|
||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
||||
char band[] = "Rolling Stones";
|
||||
store.push_back(fmt::arg("band", std::cref(band)));
|
||||
@ -108,7 +107,7 @@ TEST(ArgsTest, NamedArgByRef) {
|
||||
EXPECT_EQ(fmt::vformat("{band}", store), "Rolling Scones");
|
||||
}
|
||||
|
||||
TEST(ArgsTest, NamedCustomFormat) {
|
||||
TEST(args_test, named_custom_format) {
|
||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
||||
auto c = custom_type();
|
||||
store.push_back(fmt::arg("c1", c));
|
||||
@ -121,7 +120,7 @@ TEST(ArgsTest, NamedCustomFormat) {
|
||||
EXPECT_EQ("cust=0 and cust=1 and cust=3", result);
|
||||
}
|
||||
|
||||
TEST(ArgsTest, Clear) {
|
||||
TEST(args_test, clear) {
|
||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
||||
store.push_back(42);
|
||||
|
||||
@ -138,7 +137,7 @@ TEST(ArgsTest, Clear) {
|
||||
EXPECT_EQ("44", result);
|
||||
}
|
||||
|
||||
TEST(ArgsTest, Reserve) {
|
||||
TEST(args_test, reserve) {
|
||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
||||
store.reserve(2, 1);
|
||||
store.push_back(1.5f);
|
||||
@ -163,7 +162,7 @@ template <> struct formatter<copy_throwable> {
|
||||
};
|
||||
FMT_END_NAMESPACE
|
||||
|
||||
TEST(ArgsTest, ThrowOnCopy) {
|
||||
TEST(args_test, throw_on_copy) {
|
||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
||||
store.push_back(std::string("foo"));
|
||||
try {
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "fmt/core.h"
|
||||
#include "gtest.h"
|
||||
|
||||
TEST(AssertTest, Fail) {
|
||||
TEST(assert_test, fail) {
|
||||
#if GTEST_HAS_DEATH_TEST
|
||||
EXPECT_DEBUG_DEATH(FMT_ASSERT(false, "don't panic!"), "don't panic!");
|
||||
#else
|
||||
@ -20,9 +20,8 @@ TEST(AssertTest, Fail) {
|
||||
#endif
|
||||
}
|
||||
|
||||
bool test_condition = false;
|
||||
|
||||
TEST(AssertTest, DanglingElse) {
|
||||
TEST(assert_test, dangling_else) {
|
||||
bool test_condition = false;
|
||||
bool executed_else = false;
|
||||
if (test_condition)
|
||||
FMT_ASSERT(true, "");
|
||||
|
@ -6,7 +6,7 @@
|
||||
// For the license information refer to format.h.
|
||||
|
||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||
# define _CRT_SECURE_NO_WARNINGS
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include "fmt/chrono.h"
|
||||
@ -48,7 +48,7 @@ std::string format_tm(const std::tm& time, const char* spec,
|
||||
return os.str();
|
||||
}
|
||||
|
||||
TEST(TimeTest, Format) {
|
||||
TEST(time_test, Format) {
|
||||
std::tm tm = std::tm();
|
||||
tm.tm_year = 116;
|
||||
tm.tm_mon = 3;
|
||||
@ -57,7 +57,7 @@ TEST(TimeTest, Format) {
|
||||
fmt::format("The date is {:%Y-%m-%d}.", tm));
|
||||
}
|
||||
|
||||
TEST(TimeTest, GrowBuffer) {
|
||||
TEST(time_test, GrowBuffer) {
|
||||
std::string s = "{:";
|
||||
for (int i = 0; i < 30; ++i) s += "%c";
|
||||
s += "}\n";
|
||||
@ -65,7 +65,7 @@ TEST(TimeTest, GrowBuffer) {
|
||||
fmt::format(s, *std::localtime(&t));
|
||||
}
|
||||
|
||||
TEST(TimeTest, FormatToEmptyContainer) {
|
||||
TEST(time_test, FormatToEmptyContainer) {
|
||||
std::string s;
|
||||
auto time = std::tm();
|
||||
time.tm_sec = 42;
|
||||
@ -73,7 +73,7 @@ TEST(TimeTest, FormatToEmptyContainer) {
|
||||
EXPECT_EQ(s, "42");
|
||||
}
|
||||
|
||||
TEST(TimeTest, EmptyResult) { EXPECT_EQ("", fmt::format("{}", std::tm())); }
|
||||
TEST(time_test, EmptyResult) { EXPECT_EQ("", fmt::format("{}", std::tm())); }
|
||||
|
||||
static bool EqualTime(const std::tm& lhs, const std::tm& rhs) {
|
||||
return lhs.tm_sec == rhs.tm_sec && lhs.tm_min == rhs.tm_min &&
|
||||
@ -83,19 +83,19 @@ static bool EqualTime(const std::tm& lhs, const std::tm& rhs) {
|
||||
lhs.tm_isdst == rhs.tm_isdst;
|
||||
}
|
||||
|
||||
TEST(TimeTest, LocalTime) {
|
||||
TEST(time_test, LocalTime) {
|
||||
std::time_t t = std::time(nullptr);
|
||||
std::tm tm = *std::localtime(&t);
|
||||
EXPECT_TRUE(EqualTime(tm, fmt::localtime(t)));
|
||||
}
|
||||
|
||||
TEST(TimeTest, GMTime) {
|
||||
TEST(time_test, GMTime) {
|
||||
std::time_t t = std::time(nullptr);
|
||||
std::tm tm = *std::gmtime(&t);
|
||||
EXPECT_TRUE(EqualTime(tm, fmt::gmtime(t)));
|
||||
}
|
||||
|
||||
TEST(TimeTest, FormatTM) {
|
||||
TEST(time_test, FormatTM) {
|
||||
auto point = std::chrono::system_clock::now();
|
||||
std::time_t t = std::chrono::system_clock::to_time_t(point);
|
||||
std::tm tm = *std::localtime(&t);
|
||||
@ -117,7 +117,7 @@ template <typename TimePoint> std::string strftime(TimePoint tp) {
|
||||
return output;
|
||||
}
|
||||
|
||||
TEST(TimeTest, TimePoint) {
|
||||
TEST(time_test, TimePoint) {
|
||||
auto t1 = std::chrono::system_clock::now();
|
||||
EXPECT_EQ(strftime(t1), fmt::format("{:%Y-%m-%d %H:%M:%S}", t1));
|
||||
using time_point =
|
||||
@ -126,12 +126,12 @@ TEST(TimeTest, TimePoint) {
|
||||
EXPECT_EQ(strftime(t2), fmt::format("{:%Y-%m-%d %H:%M:%S}", t2));
|
||||
}
|
||||
|
||||
#define EXPECT_TIME(spec, time, duration) \
|
||||
{ \
|
||||
std::locale jp_loc("ja_JP.utf8"); \
|
||||
EXPECT_EQ(format_tm(time, spec, jp_loc), \
|
||||
fmt::format(loc, "{:" spec "}", duration)); \
|
||||
}
|
||||
#define EXPECT_TIME(spec, time, duration) \
|
||||
{ \
|
||||
std::locale jp_loc("ja_JP.utf8"); \
|
||||
EXPECT_EQ(format_tm(time, spec, jp_loc), \
|
||||
fmt::format(loc, "{:" spec "}", duration)); \
|
||||
}
|
||||
|
||||
#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user