Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is a Chess program in C++. I need a unit test class to be designed for chess.cpp to test all of the functions in

This is a Chess program in C++. I need a unit test class to be designed for chess.cpp to test all of the functions in chess.cpp. Don't worry about the rest of the code, it is there for context.

Unit Tests

Test-driving development is the process of creating the unit tests before writing the code the unit tests are meant to exercise. We are going to follow that methodology this week.

Select the Classes

Select the most important two classes of our project. These can be the classes selected last week, or you might want to make adjustments based on feedback you received from your submission.

Write the Tests

With classes selected, it is time to write the unit tests. Each unit test should have four parts: Setup, Exercise, Verify, and Teardown. Additionally, each unit test should be encapsulated in a test class.

Strive to make every unit test fulfill the requirements in Chapter 25 of the textbook, and all the test cases meet the requirements of Chapter 14 of the textbook.

Run the Tests

The final step for this assignment is to run the tests. Initially, we expect the tests to fail. It probably will not even compile! Our job here is to write stub code for the classes under tests so they do compile but fail the test.

I just need two unit test classes for the code below. I think chess.cpp and point.h are the ones to focus on for testing:

chess.cpp:

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

point.h:

image text in transcribed

uiDraw.cpp:

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

uiDraw.h:

image text in transcribed

uiInteract.cpp:

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

uiInteract.h:

image text in transcribed

image text in transcribed

These are some tests I've made so far, could do with some more:

#include

class TestPoint

{

void defaultConstructor()

{

Point Point;

Point.setX();

Point.setY();

assert(Point.setX()) = 200;

assert(Point.setY()) = 200;

}

}

class TestChess

{

set getPossibleMoves();

{

assert(board() = 65);

assert(board[location] = 'P' && row = 8);

assert(board[location] = 'k' && board[r * 8 + c] == isBlack() ||

Castle().inCheck = TRUE);

}

};

void ogstream:: drawSelected(int pos) \{ // do nothing if there is nothing to do if ( pos 0 \& \& pos =64 ) return; // find the row and column int row = pos /8; int col= pos %8; // set the color and drawing style glBegin(GL_QUADS); glColor(RGB_SELECTED); // draw the square glVertex2i((GLint) ((col+0)32+3), (GLint) (( row +0)32+3)); glVertex2i((GLint) ((col+1)323), (GLint) (( row +0)32+3)); glvertex2i((GLint) ((col+1)323), (GLint) (( row +1)323)); glVertex2i((GLint) ((col+0)32+3), (GLint) (( row +1)323)); // indicate we are finished glend (); \} void ogstream:: drawHover(int pos) \{ // do nothing if there is nothing to do if ( pos 0 pos =64 ) return; // find the row and column int row = pos /8; int col= pos %8; // set the color and drawing style glBegin (GL_QUADS); glColor(RGB_SELECTED); // draw the square glvertex2i((GLint) ((col+0)32), (GLint) (( row +0)32)); glVertex2i((GLint) ((col+1)32), \#pragma once using std: :string; \#endif'// LINUX, XCODE return; void clickCallback(int button, int state, int x, int y ) \{ // determine what to do if the button is selected if (button == GLUT_LEFT_BUTTON \& \& state == GLUT_DOWN) \{ // Even though this is a local variable, all the members are static // so we are actually getting the same version as in the constructor. Interface ui; // get coordinates from screen dimensions int pos = ui.positionFromXY (x,y); // if the current cell is selected, then deselect it if (ui.getselectPosition() == pos) ui.clearselectPosition(); else ui.setSelectPosition (pos); \} 3 void moveCallback(int x, int y ) \{ // Even though this is a local variable, all the members are static // so we are actually getting the same version as in the constructor. Interface ui; // get coordinates from screen dimensions int pos = ui.positionFromXY (x,y); ui. sethoverPosition (pos); \} / void closeCallback() \{ exit(0); \} extition \#pragma once

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

32. Write a MARIE program to evaluate the expression A B + C D.

Answered: 1 week ago