Skip to content

Commit

Permalink
Merge pull request oneapi-src#2072 from pbalcer/ur-bool-print
Browse files Browse the repository at this point in the history
fix ur_bool_t printing
  • Loading branch information
pbalcer authored Sep 12, 2024
2 parents 904fa18 + d8ab934 commit d357964
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/ur_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17403,6 +17403,11 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
return os;
}

inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const ur_bool_t value) {
os << (value ? "true" : "false");
return os;
}

namespace ur::details {
///////////////////////////////////////////////////////////////////////////////
// @brief Print pointer value
Expand Down
5 changes: 5 additions & 0 deletions scripts/templates/print.hpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,11 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
%endfor
%endfor

inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const ur_bool_t value) {
os << (value ? "true" : "false");
return os;
}

namespace ${x}::details {
///////////////////////////////////////////////////////////////////////////////
// @brief Print pointer value
Expand Down
14 changes: 14 additions & 0 deletions test/unit/utils/params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,17 @@ TEST(PrintPtr, nested_void_ptrs) {
ur::details::printPtr(out, pppreal);
EXPECT_THAT(out.str(), MatchesRegex(".+ \\(.+ \\(.+ \\(.+\\)\\)\\)"));
}

TEST(PrintBool, False) {
ur_bool_t value = false;
std::ostringstream out;
out << value;
EXPECT_STREQ(out.str().data(), "false");
}

TEST(PrintBool, True) {
ur_bool_t value = 1;
std::ostringstream out;
out << value;
EXPECT_STREQ(out.str().data(), "true");
}

0 comments on commit d357964

Please sign in to comment.