Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ help please! much appreciated! need a .cpp and .hpp file that can successfully run through these tests, thank you very much! printed below to

c++ help please! much appreciated!

need a .cpp and .hpp file that can successfully run through these tests, thank you very much!

printed below to be able to copy/paste into compiler

--------------------------------------------------------------------------------

#include "catch/catch.hpp" #include "../polygon.hpp"

TEST_CASE ("Advanced polygon tests") { // prepare list of points to create square Point points[] = {Point(0,0), Point(0,2), Point(2,2), Point(2,0)}; Polygon square("Awesome square", points, 4); Polygon empty;

SECTION ("Check for point inside polygon with no vertices") { CHECK(false == empty.Contains(Point(1,1))); }

SECTION ("Check for point inside polygon") { CHECK(true == square.Contains(Point(1,1))); }

SECTION ("Check for point outside polygon") { CHECK(false == square.Contains(Point(-1,-1))); }

SECTION ("Edge cases") { // at a vertex of the square CHECK(true == square.Contains(Point(0,2)));

// on an edge of the square CHECK(true == square.Contains(Point(0,1))); } }

------------------------------------------------------------------------------------------------ this is the polygon tester to make it clearer

#include "catch/catch.hpp" #include "../polygon.hpp"

TEST_CASE ("Polygon tests") { // polygon with 0 vertices Polygon empty;

// prepare list of points to create square Point points[] = {Point(0,0), Point(0,2), Point(2,2), Point(2,0)}; Polygon square("My square", points, 4);

SECTION ("Default Constructor") { CHECK(0 == empty.GetVertexCount()); CHECK("" == empty.GetName()); }

SECTION ("Parameterized Constructor") { CHECK(4 == square.GetVertexCount()); CHECK("My square" == square.GetName()); }

SECTION ("Ensure object copy/assignment are not shallow") { Polygon otherSquare = square; CHECK(true == otherSquare.Contains(Point(1,1)));

// update second square to somewhere in quadrant 3 Point points[] = {Point(-1,-1), Point(-1,-3), Point(-3,-3), Point(-3,-1)}; otherSquare = Polygon("Other square", points, 4); CHECK(true == otherSquare.Contains(Point(-2,-2)));

// ensure that updating one didn't impact the other CHECK(true == square.Contains(Point(1,1)));

// Verify reassigning to self isn't broken otherSquare = otherSquare; CHECK(true == otherSquare.Contains(Point(-2,-2))); } }

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

Database Processing

Authors: David Kroenke

11th Edition

0132302675, 9780132302678

More Books

Students also viewed these Databases questions

Question

Why are spectral lines often referred to as "atomic fingerprints"?

Answered: 1 week ago

Question

Summarize forecasting human resource availability.

Answered: 1 week ago