Skip to content

Commit

Permalink
Simplify assert macro for clang compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mmore500 committed Oct 14, 2022
1 parent 48c716d commit d707c83
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/netuit/arrange/AdjacencyFileTopologyFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace netuit {
inline Topology make_adjacency_file_topology(const std::string& filename) {
std::ifstream file(filename);

uitsl_always_assert(file);
uitsl_always_assert(file, "");

return dynamic_cast<std::istream&>(file);
}
Expand Down
2 changes: 1 addition & 1 deletion include/uitsl/algorithm/clamp_cast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ To clamp_cast( const From from ) {
#ifdef __EMSCRIPTEN__
// necessary to keep nan sanitization from getting optimized away
// and (I assume?) implicitly taken care of via the static_cast
uitsl_always_assert( !std::isnan( clamped ) );
uitsl_always_assert( !std::isnan( clamped ), "" );
#endif

return static_cast<To>( clamped );
Expand Down
5 changes: 4 additions & 1 deletion include/uitsl/debug/uitsl_always_assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ do { \
std::cout << "LINE: " << __LINE__ << '\n'; \
std::cout << '\n'; \
std::cout << "MESSAGE:\n"; \
std::cout << uitsl_ns::SetSeparator(" << ") << __VA_ARGS__;; \
std::cout << UITSL_STRINGIFY(__VA_ARGS__) << '\n'; \
std::cout << uitsl_ns::SetSeparator(" << ") __VA_OPT__(<<) __VA_ARGS__; \
std::cout << '\n'; \
std::abort(); \
} \
} while(0)

// clang doesn't support __VA_OPT__ yet
// std::cout << uitsl_ns::SetSeparator(" << ") __VA_OPT__(<<) __VA_ARGS__; \
#endif // #ifndef UITSL_DEBUG_UITSL_ALWAYS_ASSERT_HPP_INCLUDE
2 changes: 1 addition & 1 deletion include/uitsl/fetch/fetch_native.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ inline std::filesystem::path fetch_native( const std::string& url ) {
[&curl_handle](){ curl_easy_cleanup( curl_handle ); }
);

uitsl_always_assert( curl_handle );
uitsl_always_assert( curl_handle, "" );

uitsl::err_verify(
curl_easy_setopt( curl_handle, CURLOPT_URL, url.c_str())
Expand Down
6 changes: 3 additions & 3 deletions tests/uitsl/debug/uitsl_always_assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ TEST_CASE("uitsl_always_assert", "[nproc:1]") {

// uitsl_always_assert(false);

uitsl_always_assert(true);

uitsl_always_assert(true, );
// uitsl_always_assert(true);
//
// uitsl_always_assert(true, );

uitsl_always_assert(true, "");

Expand Down
6 changes: 3 additions & 3 deletions tests/uitsl/debug/uitsl_assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
TEST_CASE("uitsl_assert", "[nproc:1]") {


uitsl_assert(true);

uitsl_assert(true, );
// uitsl_assert(true);
//
// uitsl_assert(true, );

uitsl_assert(true, "");

Expand Down

0 comments on commit d707c83

Please sign in to comment.