Repository: fmtlib/fmt
File: test/gtest-extra.h (C/C++)

Code before:

// Tests that the statement writes the expected output to file.
#  define EXPECT_WRITE(file, statement, expected_output) \
    FMT_TEST_WRITE_(statement, expected_output, file, GTEST_NONFATAL_FAILURE_)

#  ifdef _MSC_VER

// Suppresses Windows assertions on invalid file descriptors, making
// POSIX functions return proper error codes instead of crashing on Windows.
class suppress_assert {
 private:
  _invalid_parameter_handler original_handler_;
  int original_report_mode_;

  static void handle_invalid_parameter(const wchar_t*, const wchar_t*,
                                       const wchar_t*, unsigned, uintptr_t) {}

 public:
  suppress_assert()
      : original_handler_(
            _set_invalid_parameter_handler(handle_invalid_parameter)),
        original_report_mode_(_CrtSetReportMode(_CRT_ASSERT, 0)) {}
  ~suppress_assert() {
    _set_invalid_parameter_handler(original_handler_);
    _CrtSetReportMode(_CRT_ASSERT, original_report_mode_);
  }
};

#    define SUPPRESS_ASSERT(statement) \
      {                                \
        suppress_assert sa;            \
        statement;                     \
      }
#  else
#    define SUPPRESS_ASSERT(statement) statement
#  endif  // _MSC_VER

#  define EXPECT_SYSTEM_ERROR_NOASSERT(statement, error_code, message) \
    EXPECT_SYSTEM_ERROR(SUPPRESS_ASSERT(statement), error_code, message)

// Attempts to read count characters from a file.
std::string read(fmt::file& f, size_t count);

#  define EXPECT_READ(file, expected_content) \
    EXPECT_EQ(expected_content,               \
              read(file, fmt::string_view(expected_content).size()))

#else
#  define EXPECT_WRITE(file, statement, expected_output) \
    do {                                                 \
      (void)(file);                                      \

Review comment (suggestion):
Maybe use function ```ignore_unused``` https://github.com/fmtlib/fmt/blob/785908ee37f970513099704386f1befca25de625/include/fmt/core.h#L340 to suppress warning?

Example:
https://github.com/fmtlib/fmt/blob/785908ee37f970513099704386f1befca25de625/include/fmt/core.h#L2746-L2748

Code after:

// Tests that the statement writes the expected output to file.
#  define EXPECT_WRITE(file, statement, expected_output) \
    FMT_TEST_WRITE_(statement, expected_output, file, GTEST_NONFATAL_FAILURE_)

#  ifdef _MSC_VER

// Suppresses Windows assertions on invalid file descriptors, making
// POSIX functions return proper error codes instead of crashing on Windows.
class suppress_assert {
 private:
  _invalid_parameter_handler original_handler_;
  int original_report_mode_;

  static void handle_invalid_parameter(const wchar_t*, const wchar_t*,
                                       const wchar_t*, unsigned, uintptr_t) {}

 public:
  suppress_assert()
      : original_handler_(
            _set_invalid_parameter_handler(handle_invalid_parameter)),
        original_report_mode_(_CrtSetReportMode(_CRT_ASSERT, 0)) {}
  ~suppress_assert() {
    _set_invalid_parameter_handler(original_handler_);
    _CrtSetReportMode(_CRT_ASSERT, original_report_mode_);
    (void)original_report_mode_;
  }
};

#    define SUPPRESS_ASSERT(statement) \
      {                                \
        suppress_assert sa;            \
        statement;                     \
      }
#  else
#    define SUPPRESS_ASSERT(statement) statement
#  endif  // _MSC_VER

#  define EXPECT_SYSTEM_ERROR_NOASSERT(statement, error_code, message) \
    EXPECT_SYSTEM_ERROR(SUPPRESS_ASSERT(statement), error_code, message)

// Attempts to read count characters from a file.
std::string read(fmt::file& f, size_t count);

#  define EXPECT_READ(file, expected_content) \
    EXPECT_EQ(expected_content,               \
              read(file, fmt::string_view(expected_content).size()))

#else
#  define EXPECT_WRITE(file, statement, expected_output) \
    do {                                                 \