Skip to content

Commit

Permalink
address easy comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Walter Gray committed Dec 21, 2020
1 parent f2a5a0f commit c85d5e3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 29 deletions.
1 change: 0 additions & 1 deletion include/fmt/chrono.h
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,6 @@ template <typename Char, typename Rep, typename OutputIt,
FMT_ENABLE_IF(std::is_integral<Rep>::value)>
OutputIt format_duration_value(OutputIt out, Rep val, int) {
static FMT_CONSTEXPR_DECL const Char format[] = {'{', '}', 0};

return vformat_to(out, to_string_view(format),
make_format_args<buffer_context<Char>>(val));
}
Expand Down
1 change: 0 additions & 1 deletion include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,6 @@ inline auto format_to_n(OutputIt out, size_t n, const S& format_str,
Returns the number of characters in the output of
``format(format_str, args...)``.
*/

template <typename... Args>
inline size_t formatted_size(string_view format_str, Args&&... args) {
const auto& vargs = fmt::make_args_checked<Args...>(format_str, args...);
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ add_fmt_test(printf-test)
add_fmt_test(ranges-test)
add_fmt_test(scan-test)

if(NOT MSVC)
if (NOT MSVC)
# FMT_ENFORCE_COMPILE_STRING not supported under MSVC
# See https://developercommunity.visualstudio.com/content/problem/1277597/internal-compiler-c0001-error-on-complex-nested-la.html
add_fmt_test(enforce-compile-string-test)
Expand Down
32 changes: 6 additions & 26 deletions test/enforce-compile-string-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
// For the license information refer to format.h.

#include <array>
#include <chrono>
#include <iterator>
#include <list>
#include <map>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#include "fmt/chrono.h"
#include "fmt/color.h"
Expand All @@ -25,10 +22,7 @@
void test_format_api() {
(void)fmt::format(FMT_STRING("{}"), 42);
(void)fmt::format(FMT_STRING(L"{}"), 42);
#if !FMT_GCC_VERSION // Currently will not compile: See
// https://github.com/fmtlib/fmt/issues/2039
(void)fmt::format(FMT_STRING("noop"));
#endif

(void)fmt::to_string(42);
(void)fmt::to_wstring(42);
Expand All @@ -46,11 +40,8 @@ void test_format_api() {
void test_literals_api() {
#if FMT_USE_UDL_TEMPLATE
using namespace fmt::literals;

auto udl_format = "{}c{}"_format("ab", 1);
auto udl_format_w = L"{}c{}"_format(L"ab", 1);
(void)udl_format;
(void)udl_format_w;
"{}c{}"_format("ab", 1);
L"{}c{}"_format(L"ab", 1);
#endif
}

Expand All @@ -70,19 +61,8 @@ void test_text_style() {
FMT_STRING("rgb(255,20,30){}{}{}"), 1, 2, 3);
}

struct zstring_sentinel {};

bool operator==(const char* p, zstring_sentinel) { return *p == '\0'; }
bool operator!=(const char* p, zstring_sentinel) { return *p != '\0'; }

struct zstring {
const char* p;
const char* begin() const { return p; }
zstring_sentinel end() const { return {}; }
};

void test_zstring() {
zstring hello{"hello"};
void test_range() {
std::array<char, 5> hello = {'h','e','l','l','o'};
(void)fmt::format(FMT_STRING("{}"), hello);
}

Expand All @@ -91,5 +71,5 @@ int main() {
test_literals_api();
test_chrono();
test_text_style();
test_zstring();
test_range();
}

0 comments on commit c85d5e3

Please sign in to comment.