- 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:
greg-williams
2008-10-29 00:37:41 +00:00
parent bbcf39244e
commit 9bc2b9a008
8 changed files with 101 additions and 6 deletions
+10
View File
@@ -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;
}
+4 -1
View File
@@ -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;
}
+6
View File
@@ -0,0 +1,6 @@
#include <stdio.h>
void ReportAnswer(int answer)
{
printf("The answer is %d!\n", answer);
}
+6
View File
@@ -0,0 +1,6 @@
#ifndef _STUFF_H
#define _STUFF_H
void ReportAnswer(int answer);
#endif // _STUFF_H
+28 -2
View File
@@ -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";