-
Notifications
You must be signed in to change notification settings - Fork 9
US3.2 Overloaded ostream operator for Board added #28
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
base: master
Are you sure you want to change the base?
Changes from all commits
63d368d
2b1c1af
284c69e
88ee114
934a028
2d9f180
a3a7e04
5223d1c
2e3b155
8525c42
6784807
d438de2
de0455b
6967eff
b3f1fbb
b764fc6
86035bf
ec6c523
e32a7b9
589e0ff
71feaa9
c40faa4
7bfbe69
54bf45c
990c635
0cdacfc
a93af8a
a5fa58f
d922640
cbf537b
1aac3cd
9e2610f
63cd9f6
2ef982a
141a981
2930712
52e325d
96011d7
6fd09af
c870f16
713d56f
51921a9
a02a1c4
4e35437
5221332
ea84f4a
0e838be
9dc35d3
f8c1352
27a519b
bce6363
ca53f02
1ed7696
94576a3
2ca0c3f
9abe2f8
5f10c67
d33dd34
ffd20d3
2bb11cf
1846fcc
37ad3f3
3a10053
fe80092
308edec
c2da02a
2b23e81
0fd1a7c
0bdbcba
a71d227
d67fb76
480f7a1
0cd50ad
4d6b078
4333c3d
6534635
3e638c5
c1849d1
3ca9072
a777ef7
c9d11a7
2944fa9
3b00306
0eb690b
582d8f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,3 +33,5 @@ class Board | |
|
|
||
| void display() const; | ||
| }; | ||
|
|
||
| std::ostream& operator<<(std::ostream& os, const Board& b); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,3 +35,15 @@ TEST_F(DisplayBoardTests, checkDisplayBoard) | |
|
|
||
| ASSERT_EQ(output, compareBoard); | ||
| } | ||
|
|
||
| TEST_F(DisplayBoardTests, checkOverloadedOstreamOperator) | ||
| { | ||
| Board board(1, 1, {{1}}, {{1}}); | ||
| std::string compareBoard = " +--+\n | |\n+--+--+\n| |??|\n+--+--+\n"; | ||
|
|
||
| testing::internal::CaptureStdout(); | ||
| std::cout << board; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm unable to reproduce this feature in main.cpp by simple writing down code as below: I got error: Could you look into it?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I moved declaration to board.hpp, but I still prefer to keep definition in DisplayBoard.cpp
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What use is to keep it in Displayboard when you can't use it?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My intention was to keep definition and declaration in displayBoard.hpp / .cpp because it is completely connected to display functionality. I know that you prefer to include only in main board.hpp, so I moved definition of ostream operator to board.hpp. |
||
| std::string output = testing::internal::GetCapturedStdout(); | ||
|
|
||
| ASSERT_EQ(output, compareBoard); | ||
| } | ||
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.
Why is it outside of the Board class? I think that task clearly describes that: Overloaded ostream operator for Board - which in my opinion mean that this should be in the class definition.