mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-08-06 11:17:50 +00:00
- Added throwaway demo project
git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@34 bf332499-1b4d-0410-844d-d2d48d5cc64c
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include "Simple.h"
|
||||
#include "Stuff.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("Hello world!\n");
|
||||
Add(123, 456);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
#include "Simple.h"
|
||||
#include "Stuff.h"
|
||||
|
||||
int Add(int a, int b)
|
||||
{
|
||||
return (a + b);
|
||||
int answer = a + b;
|
||||
ReportAnswer(answer);
|
||||
return answer;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void ReportAnswer(int answer)
|
||||
{
|
||||
printf("The answer is %d!\n", answer);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef _STUFF_H
|
||||
#define _STUFF_H
|
||||
|
||||
void ReportAnswer(int answer);
|
||||
|
||||
#endif // _STUFF_H
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "unity.h"
|
||||
#include "Simple.h"
|
||||
#include "MockStuff.h"
|
||||
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
|
||||
jmp_buf AbortFrame;
|
||||
|
||||
|
||||
@@ -17,23 +17,49 @@ void tearDown(void)
|
||||
|
||||
void test_Simple_Add_ShouldSumValues(void)
|
||||
{
|
||||
ReportAnswer_Expect(5);
|
||||
TEST_ASSERT_EQUAL( 5, Add( 2, 3));
|
||||
|
||||
ReportAnswer_Expect(5);
|
||||
TEST_ASSERT_EQUAL( 5, Add( 1, 4));
|
||||
|
||||
ReportAnswer_Expect(5);
|
||||
TEST_ASSERT_EQUAL( 5, Add( -2, 7));
|
||||
|
||||
ReportAnswer_Expect(100);
|
||||
TEST_ASSERT_EQUAL(100, Add( 25, 75));
|
||||
|
||||
ReportAnswer_Expect(-10);
|
||||
TEST_ASSERT_EQUAL(-10, Add(-90, 80));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// TEST SUPPORT
|
||||
|
||||
static void CMock_Init(void)
|
||||
{
|
||||
MockStuff_Init();
|
||||
}
|
||||
static void CMock_Verify(void)
|
||||
{
|
||||
MockStuff_Verify();
|
||||
}
|
||||
static void CMock_Destroy(void)
|
||||
{
|
||||
MockStuff_Destroy();
|
||||
}
|
||||
|
||||
static void runTest(UnityTestFunction test)
|
||||
{
|
||||
if (TEST_PROTECT())
|
||||
{
|
||||
CMock_Init();
|
||||
test();
|
||||
TEST_WRAP(CMock_Verify());
|
||||
CMock_Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Unity.TestFile = "SimpleTest.c";
|
||||
|
||||
Reference in New Issue
Block a user