mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-09 12:50:05 +00:00
Cleanup test
This commit is contained in:
parent
6b07fff0d9
commit
18c43a214c
@ -499,20 +499,17 @@ TEST(format_test, arg_errors) {
|
||||
EXPECT_THROW_MSG((void)fmt::format(runtime("{00}"), 42), format_error,
|
||||
"invalid format string");
|
||||
|
||||
char format_str[buffer_size];
|
||||
safe_sprintf(format_str, "{%u", INT_MAX);
|
||||
EXPECT_THROW_MSG((void)fmt::format(runtime(format_str)), format_error,
|
||||
auto int_max = std::to_string(INT_MAX);
|
||||
EXPECT_THROW_MSG((void)fmt::format(runtime("{" + int_max)), format_error,
|
||||
"invalid format string");
|
||||
safe_sprintf(format_str, "{%u}", INT_MAX);
|
||||
EXPECT_THROW_MSG((void)fmt::format(runtime(format_str)), format_error,
|
||||
"argument not found");
|
||||
EXPECT_THROW_MSG((void)fmt::format(runtime("{" + int_max + "}")),
|
||||
format_error, "argument not found");
|
||||
|
||||
safe_sprintf(format_str, "{%u", INT_MAX + 1u);
|
||||
EXPECT_THROW_MSG((void)fmt::format(runtime(format_str)), format_error,
|
||||
auto int_maxer = std::to_string(INT_MAX + 1u);
|
||||
EXPECT_THROW_MSG((void)fmt::format(runtime("{" + int_maxer)), format_error,
|
||||
"invalid format string");
|
||||
safe_sprintf(format_str, "{%u}", INT_MAX + 1u);
|
||||
EXPECT_THROW_MSG((void)fmt::format(runtime(format_str)), format_error,
|
||||
"argument not found");
|
||||
EXPECT_THROW_MSG((void)fmt::format(runtime("{" + int_maxer + "}")),
|
||||
format_error, "argument not found");
|
||||
}
|
||||
|
||||
template <int N> struct test_format {
|
||||
|
26
test/util.h
26
test/util.h
@ -29,9 +29,9 @@ void safe_sprintf(char (&buffer)[SIZE], const char* format, ...) {
|
||||
extern const char* const file_content;
|
||||
|
||||
// Opens a buffered file for reading.
|
||||
fmt::buffered_file open_buffered_file(FILE** fp = nullptr);
|
||||
auto open_buffered_file(FILE** fp = nullptr) -> fmt::buffered_file;
|
||||
|
||||
inline FILE* safe_fopen(const char* filename, const char* mode) {
|
||||
inline auto safe_fopen(const char* filename, const char* mode) -> FILE* {
|
||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||
// Fix MSVC warning about "unsafe" fopen.
|
||||
FILE* f = nullptr;
|
||||
@ -51,17 +51,17 @@ template <typename Char> class basic_test_string {
|
||||
public:
|
||||
explicit basic_test_string(const Char* value = empty) : value_(value) {}
|
||||
|
||||
const std::basic_string<Char>& value() const { return value_; }
|
||||
auto value() const -> const std::basic_string<Char>& { return value_; }
|
||||
};
|
||||
|
||||
template <typename Char> const Char basic_test_string<Char>::empty[] = {0};
|
||||
|
||||
typedef basic_test_string<char> test_string;
|
||||
typedef basic_test_string<wchar_t> test_wstring;
|
||||
using test_string = basic_test_string<char>;
|
||||
using test_wstring = basic_test_string<wchar_t>;
|
||||
|
||||
template <typename Char>
|
||||
std::basic_ostream<Char>& operator<<(std::basic_ostream<Char>& os,
|
||||
const basic_test_string<Char>& s) {
|
||||
auto operator<<(std::basic_ostream<Char>& os, const basic_test_string<Char>& s)
|
||||
-> std::basic_ostream<Char>& {
|
||||
os << s.value();
|
||||
return os;
|
||||
}
|
||||
@ -72,10 +72,12 @@ class date {
|
||||
public:
|
||||
date(int year, int month, int day) : year_(year), month_(month), day_(day) {}
|
||||
|
||||
int year() const { return year_; }
|
||||
int month() const { return month_; }
|
||||
int day() const { return day_; }
|
||||
auto year() const -> int { return year_; }
|
||||
auto month() const -> int { return month_; }
|
||||
auto day() const -> int { return day_; }
|
||||
};
|
||||
|
||||
// Returns a locale with the given name if available or classic locale otherwise.
|
||||
std::locale get_locale(const char* name, const char* alt_name = nullptr);
|
||||
// Returns a locale with the given name if available or classic locale
|
||||
// otherwise.
|
||||
auto get_locale(const char* name, const char* alt_name = nullptr)
|
||||
-> std::locale;
|
||||
|
Loading…
Reference in New Issue
Block a user