-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add stream operator for miral::Window #2071
Conversation
include/miral/miral/window.h
Outdated
@@ -78,6 +79,7 @@ bool operator==(Window const& lhs, Window const& rhs); | |||
bool operator==(std::shared_ptr<mir::scene::Surface> const& lhs, Window const& rhs); | |||
bool operator==(Window const& lhs, std::shared_ptr<mir::scene::Surface> const& rhs); | |||
bool operator<(Window const& lhs, Window const& rhs); | |||
auto operator<<(std::ostream& stream, const miral::Window& window) -> std::ostream&; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use right const around here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oop
src/miral/window.cpp
Outdated
@@ -125,3 +125,16 @@ bool miral::operator<(Window const& lhs, Window const& rhs) | |||
{ | |||
return lhs.self.owner_before(rhs.self); | |||
} | |||
|
|||
auto miral::operator<<(std::ostream& stream, const miral::Window& window) -> std::ostream& |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use right const around here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
CI say: "You need to add |
Hmm looks like GitHub is broken |
I'm going to interpret "Sure" + approval as a bors delegate bors r=AlanGriffiths |
2071: Add stream operator for miral::Window r=AlanGriffiths a=wmww This makes window's correctly appear in test failures, and may have other uses. google/googletest#1149 explains why the stream operators really need to be declared in the same place as the class. I tried a number of other ways, and this is the only one I found to be successful. Co-authored-by: William Wold <[email protected]>
Build failed: |
Fair enough. (I'm not really convinced this is a widely useful streaming operator, nor that it has to be declared outside the test framework, but it is relatively harmless.) |
I can't say it has to be, but I put a bit of work into trying different things and this is the only one I found to actually work. bors r=AlanGriffiths |
2071: Add stream operator for miral::Window r=AlanGriffiths a=wmww This makes window's correctly appear in test failures, and may have other uses. google/googletest#1149 explains why the stream operators really need to be declared in the same place as the class. I tried a number of other ways, and this is the only one I found to be successful. Co-authored-by: William Wold <[email protected]>
Build failed: |
OK, so the reason this is problematic is that in the
Currently, that corresponds to:
So these need to be pulled in unambiguously (e.g. by using the mangled names). |
@RAOF Alan mentioned to may know some secret of escaping characters in symbols.map? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having poked around a bit I can't find a simple way to find this operator at the point of instantiation.
OTOH I think it would be better to provide a PrintTo()
function for gtest, not a streaming operator that might be confused with something useful. That is, in miral/window.h
:
// For Google test
void PrintTo(Window const& window, std::ostream* out);
Closing in favour of #2081 |
2081: Add gtest customization to print surface names in error messages r=wmww a=AlanGriffiths Better solution than #2071 Co-authored-by: Alan Griffiths <[email protected]>
This makes window's correctly appear in test failures, and may have other uses. google/googletest#1149 explains why the stream operators really need to be declared in the same place as the class. I tried a number of other ways, and this is the only one I found to be successful.