Skip to content
Permalink
Browse files
Add rectangle testing
  • Loading branch information
David committed Jan 7, 2019
1 parent 8d4868a commit aae978dffb9eda3a67ce24c8e3cd3ee116378ef6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
@@ -0,0 +1,32 @@
#include <rectangle.h>

#define CATCH_CONFIG_MAIN
#include <catch.hpp>

#include <vector>
#include <string>
#include <memory>

SCENARIO( "Test Rectangle" )
{

GIVEN( "A Rectangle of known size" )
{
Rectangle rect( 42, 69 );

const float expectedArea = 42*69;
REQUIRE( rect.area() == expectedArea );

{
INFO( "Check get side functions" )
REQUIRE( rect.getSide1() == 42 );
REQUIRE( rect.getSide2() == 69 );
}

WHEN( "Rectangle is scaled" )
{
rect.scale( 2 );
REQUIRE( rect.area() == expectedArea*4 );
}
}
}
@@ -1,4 +1,4 @@
#include <exception>
#include <stdexcept>

/** Class to store rectangles.
Every rectangle has two numbers which define the side lengths.

0 comments on commit aae978d

Please sign in to comment.