Created
May 24, 2012 13:10
-
-
Save barneywilliams/2781482 to your computer and use it in GitHub Desktop.
C++ step definitions and the corresponding test fixture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <gtest/gtest.h> | |
#include <cucumber-cpp/defs.hpp> | |
#include <Calculator.h> | |
struct CalcCtx { | |
Calculator calc; | |
double result; | |
}; | |
GIVEN("^I have entered (\\d+) into the calculator$") { | |
REGEX_PARAM(double, n); | |
USING_CONTEXT(CalcCtx, context); | |
context->calc.push(n); | |
} | |
WHEN("^I press add") { | |
USING_CONTEXT(CalcCtx, context); | |
context->result = context->calc.add(); | |
} | |
WHEN("^I press divide") { | |
USING_CONTEXT(CalcCtx, context); | |
context->result = context->calc.divide(); | |
} | |
THEN("^the result should be (.*) on the screen$") { | |
REGEX_PARAM(double, expected); | |
USING_CONTEXT(CalcCtx, context); | |
EXPECT_EQ(expected, context->result); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment