Skip to content

Commit d357964

Browse files
authored
Merge pull request #2072 from pbalcer/ur-bool-print
fix ur_bool_t printing
2 parents 904fa18 + d8ab934 commit d357964

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

include/ur_print.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17403,6 +17403,11 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
1740317403
return os;
1740417404
}
1740517405

17406+
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const ur_bool_t value) {
17407+
os << (value ? "true" : "false");
17408+
return os;
17409+
}
17410+
1740617411
namespace ur::details {
1740717412
///////////////////////////////////////////////////////////////////////////////
1740817413
// @brief Print pointer value

scripts/templates/print.hpp.mako

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,11 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
411411
%endfor
412412
%endfor
413413

414+
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const ur_bool_t value) {
415+
os << (value ? "true" : "false");
416+
return os;
417+
}
418+
414419
namespace ${x}::details {
415420
///////////////////////////////////////////////////////////////////////////////
416421
// @brief Print pointer value

test/unit/utils/params.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,17 @@ TEST(PrintPtr, nested_void_ptrs) {
2727
ur::details::printPtr(out, pppreal);
2828
EXPECT_THAT(out.str(), MatchesRegex(".+ \\(.+ \\(.+ \\(.+\\)\\)\\)"));
2929
}
30+
31+
TEST(PrintBool, False) {
32+
ur_bool_t value = false;
33+
std::ostringstream out;
34+
out << value;
35+
EXPECT_STREQ(out.str().data(), "false");
36+
}
37+
38+
TEST(PrintBool, True) {
39+
ur_bool_t value = 1;
40+
std::ostringstream out;
41+
out << value;
42+
EXPECT_STREQ(out.str().data(), "true");
43+
}

0 commit comments

Comments
 (0)