Skip to content

Instantly share code, notes, and snippets.

@stephyswe
Created April 20, 2023 12:44
Show Gist options
  • Save stephyswe/cbc188775e55f96a38f2d7afce512ba4 to your computer and use it in GitHub Desktop.
Save stephyswe/cbc188775e55f96a38f2d7afce512ba4 to your computer and use it in GitHub Desktop.
test
#include <gtest/gtest.h>
extern "C" {
#include "input.h"
#include "shapes.h"
}
class ShapesTest : public testing::Test {
protected:
// Override this to define how to set up the environment.
void SetUp() override {
// game_initialize(); /* Without this the Tests could break*/
}
// Override this to define how to tear down the environment.
virtual void TearDown() {}
};
// Test the createRectangle function
TEST_F(ShapesTest, WhenCreateRectangleIsOK) {
// ARRANGE
double area, perimeter;
// ACT
Shapes_Status status = createRectangle(5.0, 6.0, &area, &perimeter);
// ASSERT
ASSERT_EQ(status, Shapes_Status_Ok);
ASSERT_DOUBLE_EQ(area, 30.0);
ASSERT_DOUBLE_EQ(perimeter, 22.0);
}
TEST_F(ShapesTest, WhenCreateRectangleLengthIsZero) {
// ARRANGE
double area, perimeter;
// ACT
Shapes_Status status = createRectangle(0, 6.0, &area, &perimeter);
// ASSERT
ASSERT_EQ(status, Shapes_Status_InvalidInput);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment