return true;
}
+bool Board::operator==(const Board& o) const {
+ for (int i = 0; i < BOARD_SIZE; i++) {
+ if (board[i] != o.board[i]) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool Board::operator!=(const Board& o) const {
+ return !operator==(o);
+}
+
std::istream& operator>>(std::istream& is, Board& board) {
for (int i = 0; i < BOARD_SIZE; i++) {
if (!is.good()) {
InvertedBoard invert() const;
int distance(const Board& o) const;
int distance(const InvertedBoard& invo) const;
+ bool operator==(const Board& o) const;
+ bool operator!=(const Board& o) const;
};
std::istream& operator>>(std::istream& is, Board& board);
std::ostream& operator<<(std::ostream& os, const Board& board);
}
}
+TEST(Board, Equal) {
+ Board b1{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0}};
+ Board b2{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0}};
+ EXPECT_TRUE(b1 == b2);
+ EXPECT_FALSE(b1 != b2);
+ EXPECT_EQ(b1, b2);
+}
+
+TEST(Board, NotEqual) {
+ Board b1{{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0}};
+ Board b2{{1,2,3,4,5,6,7,8,10,9,11,12,13,14,15,0}};
+ EXPECT_FALSE(b1 == b2);
+ EXPECT_TRUE(b1 != b2);
+ EXPECT_NE(b1, b2);
+}
+
TEST(Board, GoodInput) {
std::istringstream is{"15,14,9,13,3,1,12,8,0,11,6,4,7,5,2,10"};
Board b;