mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-06-19 21:38:30 +08:00
- Fixed broken examples
This commit is contained in:
@ -9,7 +9,11 @@ ifeq ($(OSTYPE),cygwin)
|
|||||||
CLEANUP = rm -f
|
CLEANUP = rm -f
|
||||||
MKDIR = mkdir -p
|
MKDIR = mkdir -p
|
||||||
TARGET_EXTENSION=.out
|
TARGET_EXTENSION=.out
|
||||||
else ifeq ($(OS),Windows_NT)
|
elseifeq ($(OSTYPE),msys)
|
||||||
|
CLEANUP = rm -f
|
||||||
|
MKDIR = mkdir -p
|
||||||
|
TARGET_EXTENSION=.exe
|
||||||
|
elseifeq ($(OS),Windows_NT)
|
||||||
CLEANUP = del /F /Q
|
CLEANUP = del /F /Q
|
||||||
MKDIR = mkdir
|
MKDIR = mkdir
|
||||||
TARGET_EXTENSION=.exe
|
TARGET_EXTENSION=.exe
|
||||||
@ -50,8 +54,8 @@ SYMBOLS=-DTEST
|
|||||||
all: clean default
|
all: clean default
|
||||||
|
|
||||||
default:
|
default:
|
||||||
# ruby auto/generate_test_runner.rb test/TestProductionCode.c test/test_runners/TestProductionCode_Runner.c
|
ruby $(UNITY_ROOT)/auto/generate_test_runner.rb test/TestProductionCode.c test/test_runners/TestProductionCode_Runner.c
|
||||||
# ruby auto/generate_test_runner.rb test/TestProductionCode2.c test/test_runners/TestProductionCode2_Runner.c
|
ruby $(UNITY_ROOT)/auto/generate_test_runner.rb test/TestProductionCode2.c test/test_runners/TestProductionCode2_Runner.c
|
||||||
$(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) -o $(TARGET1)
|
$(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) -o $(TARGET1)
|
||||||
$(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES2) -o $(TARGET2)
|
$(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES2) -o $(TARGET2)
|
||||||
./$(TARGET1)
|
./$(TARGET1)
|
||||||
|
@ -1,33 +1,53 @@
|
|||||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
||||||
#include "unity.h"
|
|
||||||
#include <setjmp.h>
|
//=======Test Runner Used To Run Each Test Below=====
|
||||||
#include <stdio.h>
|
#define RUN_TEST(TestFunc, TestLineNum) \
|
||||||
|
{ \
|
||||||
char MessageBuffer[50];
|
Unity.CurrentTestName = #TestFunc; \
|
||||||
|
Unity.CurrentTestLineNumber = TestLineNum; \
|
||||||
extern void setUp(void);
|
Unity.NumberOfTests++; \
|
||||||
extern void tearDown(void);
|
if (TEST_PROTECT()) \
|
||||||
|
{ \
|
||||||
extern void test_IgnoredTest(void);
|
setUp(); \
|
||||||
extern void test_AnotherIgnoredTest(void);
|
TestFunc(); \
|
||||||
extern void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void);
|
} \
|
||||||
|
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
|
||||||
void resetTest(void);
|
{ \
|
||||||
void resetTest(void)
|
tearDown(); \
|
||||||
{
|
} \
|
||||||
tearDown();
|
UnityConcludeTest(); \
|
||||||
setUp();
|
}
|
||||||
}
|
|
||||||
|
//=======Automagically Detected Files To Include=====
|
||||||
|
#include "unity.h"
|
||||||
int main(void)
|
#include <setjmp.h>
|
||||||
{
|
#include <stdio.h>
|
||||||
UnityBegin("test/TestProductionCode2.c");
|
#include "ProductionCode2.h"
|
||||||
|
|
||||||
RUN_TEST(test_IgnoredTest, 13);
|
//=======External Functions This Runner Calls=====
|
||||||
RUN_TEST(test_AnotherIgnoredTest, 18);
|
extern void setUp(void);
|
||||||
RUN_TEST(test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented, 23);
|
extern void tearDown(void);
|
||||||
|
extern void test_IgnoredTest(void);
|
||||||
UnityEnd();
|
extern void test_AnotherIgnoredTest(void);
|
||||||
return 0;
|
extern void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void);
|
||||||
}
|
|
||||||
|
|
||||||
|
//=======Test Reset Option=====
|
||||||
|
void resetTest(void);
|
||||||
|
void resetTest(void)
|
||||||
|
{
|
||||||
|
tearDown();
|
||||||
|
setUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======MAIN=====
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
UnityBegin("test/TestProductionCode2.c");
|
||||||
|
RUN_TEST(test_IgnoredTest, 18);
|
||||||
|
RUN_TEST(test_AnotherIgnoredTest, 23);
|
||||||
|
RUN_TEST(test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented, 28);
|
||||||
|
|
||||||
|
return (UnityEnd());
|
||||||
|
}
|
||||||
|
@ -1,37 +1,57 @@
|
|||||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
||||||
#include "unity.h"
|
|
||||||
#include <setjmp.h>
|
//=======Test Runner Used To Run Each Test Below=====
|
||||||
#include <stdio.h>
|
#define RUN_TEST(TestFunc, TestLineNum) \
|
||||||
|
{ \
|
||||||
char MessageBuffer[50];
|
Unity.CurrentTestName = #TestFunc; \
|
||||||
|
Unity.CurrentTestLineNumber = TestLineNum; \
|
||||||
extern void setUp(void);
|
Unity.NumberOfTests++; \
|
||||||
extern void tearDown(void);
|
if (TEST_PROTECT()) \
|
||||||
|
{ \
|
||||||
extern void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void);
|
setUp(); \
|
||||||
extern void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken(void);
|
TestFunc(); \
|
||||||
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(void);
|
} \
|
||||||
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void);
|
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
|
||||||
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void);
|
{ \
|
||||||
|
tearDown(); \
|
||||||
void resetTest(void);
|
} \
|
||||||
void resetTest(void)
|
UnityConcludeTest(); \
|
||||||
{
|
}
|
||||||
tearDown();
|
|
||||||
setUp();
|
//=======Automagically Detected Files To Include=====
|
||||||
}
|
#include "unity.h"
|
||||||
|
#include <setjmp.h>
|
||||||
|
#include <stdio.h>
|
||||||
int main(void)
|
#include "ProductionCode.h"
|
||||||
{
|
|
||||||
UnityBegin("test/TestProductionCode.c");
|
//=======External Functions This Runner Calls=====
|
||||||
|
extern void setUp(void);
|
||||||
RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode, 20);
|
extern void tearDown(void);
|
||||||
RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken, 30);
|
extern void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void);
|
||||||
RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue, 41);
|
extern void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken(void);
|
||||||
RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain, 51);
|
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(void);
|
||||||
RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed, 57);
|
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void);
|
||||||
|
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void);
|
||||||
UnityEnd();
|
|
||||||
return 0;
|
|
||||||
}
|
//=======Test Reset Option=====
|
||||||
|
void resetTest(void);
|
||||||
|
void resetTest(void)
|
||||||
|
{
|
||||||
|
tearDown();
|
||||||
|
setUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======MAIN=====
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
UnityBegin("test/TestProductionCode.c");
|
||||||
|
RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode, 20);
|
||||||
|
RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken, 30);
|
||||||
|
RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue, 41);
|
||||||
|
RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain, 51);
|
||||||
|
RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed, 57);
|
||||||
|
|
||||||
|
return (UnityEnd());
|
||||||
|
}
|
||||||
|
@ -9,7 +9,11 @@ ifeq ($(OSTYPE),cygwin)
|
|||||||
CLEANUP = rm -f
|
CLEANUP = rm -f
|
||||||
MKDIR = mkdir -p
|
MKDIR = mkdir -p
|
||||||
TARGET_EXTENSION=.out
|
TARGET_EXTENSION=.out
|
||||||
else ifeq ($(OS),Windows_NT)
|
elseifeq ($(OSTYPE),msys)
|
||||||
|
CLEANUP = rm -f
|
||||||
|
MKDIR = mkdir -p
|
||||||
|
TARGET_EXTENSION=.exe
|
||||||
|
elseifeq ($(OS),Windows_NT)
|
||||||
CLEANUP = del /F /Q
|
CLEANUP = del /F /Q
|
||||||
MKDIR = mkdir
|
MKDIR = mkdir
|
||||||
TARGET_EXTENSION=.exe
|
TARGET_EXTENSION=.exe
|
||||||
@ -58,8 +62,6 @@ SYMBOLS=
|
|||||||
all: clean default
|
all: clean default
|
||||||
|
|
||||||
default:
|
default:
|
||||||
# ruby auto/generate_test_runner.rb test/TestProductionCode.c test/test_runners/TestProductionCode_Runner.c
|
|
||||||
# ruby auto/generate_test_runner.rb test/TestProductionCode2.c test/test_runners/TestProductionCode2_Runner.c
|
|
||||||
$(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) -o $(TARGET1)
|
$(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) -o $(TARGET1)
|
||||||
./$(TARGET1)
|
./$(TARGET1)
|
||||||
|
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
# ==========================================
|
|
||||||
# Unity Project - A Test Framework for C
|
|
||||||
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
|
||||||
# [Released under MIT License. Please refer to license.txt for details]
|
|
||||||
# ==========================================
|
|
||||||
|
|
||||||
#We try to detect the OS we are running on, and adjust commands as needed
|
|
||||||
ifeq ($(OSTYPE),cygwin)
|
|
||||||
CLEANUP = rm -f
|
|
||||||
MKDIR = mkdir -p
|
|
||||||
TARGET_EXTENSION=.out
|
|
||||||
else ifeq ($(OS),Windows_NT)
|
|
||||||
CLEANUP = del /F /Q
|
|
||||||
MKDIR = mkdir
|
|
||||||
TARGET_EXTENSION=.exe
|
|
||||||
else
|
|
||||||
CLEANUP = rm -f
|
|
||||||
MKDIR = mkdir -p
|
|
||||||
TARGET_EXTENSION=.out
|
|
||||||
endif
|
|
||||||
|
|
||||||
UNITY_ROOT=../..
|
|
||||||
C_COMPILER=gcc
|
|
||||||
|
|
||||||
CFLAGS=-std=c99
|
|
||||||
CFLAGS += -Wall
|
|
||||||
CFLAGS += -Wextra
|
|
||||||
CFLAGS += -Werror
|
|
||||||
CFLAGS += -Wpointer-arith
|
|
||||||
CFLAGS += -Wcast-align
|
|
||||||
CFLAGS += -Wwrite-strings
|
|
||||||
CFLAGS += -Wswitch-default
|
|
||||||
CFLAGS += -Wunreachable-code
|
|
||||||
CFLAGS += -Winit-self
|
|
||||||
CFLAGS += -Wmissing-field-initializers
|
|
||||||
CFLAGS += -Wno-unknown-pragmas
|
|
||||||
CFLAGS += -Wstrict-prototypes
|
|
||||||
CFLAGS += -Wundef
|
|
||||||
CFLAGS += -Wold-style-definition
|
|
||||||
|
|
||||||
TARGET_BASE1=test1
|
|
||||||
TARGET_BASE2=test2
|
|
||||||
TARGET1 = $(TARGET_BASE1)$(TARGET_EXTENSION)
|
|
||||||
TARGET2 = $(TARGET_BASE2)$(TARGET_EXTENSION)
|
|
||||||
SRC_FILES1=$(UNITY_ROOT)/src/unity.c src/ProductionCode.c test/TestProductionCode.c test/no_ruby/TestProductionCode_Runner.c
|
|
||||||
SRC_FILES2=$(UNITY_ROOT)/src/unity.c src/ProductionCode2.c test/TestProductionCode2.c test/no_ruby/TestProductionCode2_Runner.c
|
|
||||||
INC_DIRS=-Isrc -I$(UNITY_ROOT)/src
|
|
||||||
SYMBOLS=-DTEST
|
|
||||||
|
|
||||||
all: clean default
|
|
||||||
|
|
||||||
default:
|
|
||||||
# ruby auto/generate_test_runner.rb test/TestProductionCode.c test/no_ruby/TestProductionCode_Runner.c
|
|
||||||
# ruby auto/generate_test_runner.rb test/TestProductionCode2.c test/no_ruby/TestProductionCode2_Runner.c
|
|
||||||
$(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) -o $(TARGET1)
|
|
||||||
$(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES2) -o $(TARGET2)
|
|
||||||
./$(TARGET1)
|
|
||||||
./$(TARGET2)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(CLEANUP)
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
|||||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
|
||||||
#include "unity.h"
|
|
||||||
#include <setjmp.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
char MessageBuffer[50];
|
|
||||||
|
|
||||||
extern void setUp(void);
|
|
||||||
extern void tearDown(void);
|
|
||||||
|
|
||||||
extern void test_IgnoredTest(void);
|
|
||||||
extern void test_AnotherIgnoredTest(void);
|
|
||||||
extern void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void);
|
|
||||||
|
|
||||||
void resetTest(void);
|
|
||||||
void resetTest(void)
|
|
||||||
{
|
|
||||||
tearDown();
|
|
||||||
setUp();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
UnityBegin("test/TestProductionCode2.c");
|
|
||||||
|
|
||||||
RUN_TEST(test_IgnoredTest, 13);
|
|
||||||
RUN_TEST(test_AnotherIgnoredTest, 18);
|
|
||||||
RUN_TEST(test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented, 23);
|
|
||||||
|
|
||||||
UnityEnd();
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
|
||||||
#include "unity.h"
|
|
||||||
#include <setjmp.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
char MessageBuffer[50];
|
|
||||||
|
|
||||||
extern void setUp(void);
|
|
||||||
extern void tearDown(void);
|
|
||||||
|
|
||||||
extern void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void);
|
|
||||||
extern void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken(void);
|
|
||||||
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(void);
|
|
||||||
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void);
|
|
||||||
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void);
|
|
||||||
|
|
||||||
void resetTest(void);
|
|
||||||
void resetTest(void)
|
|
||||||
{
|
|
||||||
tearDown();
|
|
||||||
setUp();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
UnityBegin("test/TestProductionCode.c");
|
|
||||||
|
|
||||||
RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode, 20);
|
|
||||||
RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken, 30);
|
|
||||||
RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue, 41);
|
|
||||||
RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain, 51);
|
|
||||||
RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed, 57);
|
|
||||||
|
|
||||||
UnityEnd();
|
|
||||||
return 0;
|
|
||||||
}
|
|
Reference in New Issue
Block a user