Skip to content

Broken gtest support #87

@yfinkelstein

Description

@yfinkelstein

There are 2 issues in version 0.5.0:

  1. The header files tokenizer.hpp and utils.hpp included from assert-gtest.hpp are missing - they are not exported in conan package
  2. Worse - there is compilation error:

ASSERT(1 + 1 == 3, "my assert");

error: void value not ignored as it ought to be
  195 |     ASSERT(1 + 1 == 3, "my assert");
      |     ^

A more detailed info provided by clangd:

Cannot initialize return object of type 'int' with an rvalue of type 'void'. 
clang(init_conversion_failed)

macro ASSERT
provided by <libassert/assert-gtest.hpp>

#define ASSERT(...)                        \
    do {                                   \
        try {                              \
            LIBASSERT_ASSERT(__VA_ARGS__); \
            SUCCEED();                     \
        } catch (std::exception & e) {     \
            FAIL() << e.what();            \
        }                                  \
    } while (false)

// Expands to
do {
    try {
        do {
            auto libassert_decomposer = libassert ::detail ::expression_decomposer(
                libassert ::detail ::expression_decomposer{} << 1 + 1 == 3);
            if (__builtin_expect_with_probability((!static_cast<bool>(libassert_decomposer.get_value())),
                    (0),
                    1)) {
                libassert ::ERROR_ASSERTION_FAILURE_IN_CONSTEXPR_CONTEXT();
                using libassert_params_t = libassert ::detail ::assert_static_parameters;
                const libassert_params_t *libassert_params = []() -> const libassert_params_t * {
                    static constexpr std ::string_view libassert_arg_strings[] = {"\"my assert\"", "", ""};
                    static constexpr libassert_params_t _libassert_params = {
                        "ASSERT",
                        libassert ::assert_type ::assertion,
                        "1 + 1 == 3",
                        {},
                        {libassert_arg_strings, sizeof(libassert_arg_strings) / sizeof(std ::string_view)},
                    };
                    return &_libassert_params;
                }();
                if constexpr (sizeof libassert_decomposer > 32) {
                    libassert ::detail ::process_assert_fail(libassert_decomposer,
                        libassert_params,
                        "my assert",
                        libassert ::detail ::pretty_function_name_wrapper{__extension__ __PRETTY_FUNCTION__});
                } else {
                    libassert ::detail ::process_assert_fail_n(std ::move(libassert_decomposer),
                        libassert_params,
                        "my assert",
                        libassert ::detail ::pretty_function_name_wrapper{__extension__ __PRETTY_FUNCTION__});
                }
            }
        } while (false);
        ::testing ::internal ::AssertHelper(::testing ::TestPartResult ::kSuccess,
            "/home/yfinkelstein/baydb/storage_server/src/tests/test-fiber-uring-grpc.cpp",
            195,
            "Succeeded") = ::testing ::Message();
    } catch (std ::exception& e) {
        return ::testing ::internal ::AssertHelper(::testing ::TestPartResult ::kFatalFailure,
                   "/home/yfinkelstein/baydb/storage_server/src/tests/test-fiber-uring-grpc.cpp",
                   195,
                   "Failed") = ::testing ::Message() << e.what();
    }
} while (false)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions