Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create an .hpp and .cpp file that runs through these tests and passes? The purpose is to construct these two files from nothing and build

Create an .hpp and .cpp file that runs through these tests and passes? The purpose is to construct these two files from nothing and build it around these test suites,

#include

#include "catch/catch.hpp"

#include "../cell.hpp"



TEST_CASE("Cell with mine")

{

std::ostringstream os;

bool mine = true;

Cell c(mine);



CHECK(c.IsMine());



os << c;

CHECK(" " == os.str()); // cell has not been uncovered yet



os.str(""); // reset stream to empty string

c.ToggleFlag();

os << c;

CHECK(Cell::FLAG == os.str());



bool clickSuccessful = c.Click();

CHECK(!clickSuccessful); // cannot click a cell that has a flag on it



os.str(""); // reset stream to empty string

c.ToggleFlag();

os << c;

CHECK(" " == os.str()); // flag should be gone



os.str(""); // reset stream to empty string

c.Click();

os << c;

CHECK(Cell::MINE == os.str());

}



TEST_CASE("Cell without mine")

{

bool mine = false;

Cell c(mine);

CHECK(!c.IsMine());



std::ostringstream os;

os << c;

CHECK(" " == os.str());



os.str(""); // reset stream to empty string

c.Click();

os << c;

CHECK(Cell::NO_ADJACENT_MINES == os.str());



os.str(""); // reset stream to empty string

c.SetAdjacentMineCount(6); // set arbitrary number of adjacent mines

os << c;

CHECK("6" == os.str());



bool clickedAgain = c.Click(); // can't uncover a cell again

CHECK(!clickedAgain);

}

Step by Step Solution

3.46 Rating (162 Votes )

There are 3 Steps involved in it

Step: 1

TESTCASECell copy constructor Cell c1true Cell c2c1 invoke copy constructor CHE... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seeing Through Statistics

Authors: Jessica M.Utts

4th Edition

1285050886, 978-1305176249, 1305176243, 978-1305322394, 978-1285050881

More Books

Students also viewed these Computer Network questions

Question

Discuss the scope of Human Resource Management

Answered: 1 week ago

Question

Discuss the different types of leadership

Answered: 1 week ago

Question

Write a note on Organisation manuals

Answered: 1 week ago

Question

Define Scientific Management

Answered: 1 week ago

Question

Explain budgetary Control

Answered: 1 week ago