Skip to content

Commit

Permalink
Apply suggestions from Code Review
Browse files Browse the repository at this point in the history
  • Loading branch information
Qup42 committed May 22, 2024
1 parent 7640db8 commit a333b10
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/global/ValueId.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,14 @@ class ValueId {
/// human-readable representation.
friend std::ostream& operator<<(std::ostream& ostr, const ValueId& id) {
ostr << toString(id.getDatatype())[0] << ':';
if (id.getDatatype() == Datatype::Undefined) {
return ostr << id.getBits();
}

auto visitor = [&ostr]<typename T>(T&& value) {
if constexpr (ad_utility::isSimilar<T, ValueId::UndefinedType>) {
ostr << "xx";
// already handled above
AD_FAIL();
} else if constexpr (ad_utility::isSimilar<T, double> ||
ad_utility::isSimilar<T, int64_t>) {
ostr << std::to_string(value);
Expand Down
2 changes: 1 addition & 1 deletion test/SparqlExpressionTypesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ TEST(SparqlExpressionTypes, printIdOrString) {

IdOrLiteralOrIri idOrString{Id::makeUndefined()};
PrintTo(idOrString, &str);
ASSERT_EQ(str.str(), "U:xx");
ASSERT_EQ(str.str(), "U:0");
idOrString = LiteralOrIri::literalWithoutQuotes("bimm");
// Clear the stringstream.
str.str({});
Expand Down
2 changes: 1 addition & 1 deletion test/ValueIdTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ TEST(ValueId, toDebugString) {
stream << id;
ASSERT_EQ(stream.str(), expected);
};
test(ValueId::makeUndefined(), "U:xx");
test(ValueId::makeUndefined(), "U:0");
test(ValueId::makeFromInt(-42), "I:-42");
test(ValueId::makeFromDouble(42.0), "D:42.000000");
test(ValueId::makeFromBool(false), "B:false");
Expand Down

0 comments on commit a333b10

Please sign in to comment.