提交 06c95fcb 编写于 作者: T ThingamaByte, LLC

- Fixed broken examples

上级 b922d622
...@@ -9,7 +9,11 @@ ifeq ($(OSTYPE),cygwin) ...@@ -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 ...@@ -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)
......
/* AUTOGENERATED FILE. DO NOT EDIT. */ /* AUTOGENERATED FILE. DO NOT EDIT. */
//=======Test Runner Used To Run Each Test Below=====
#define RUN_TEST(TestFunc, TestLineNum) \
{ \
Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
if (TEST_PROTECT()) \
{ \
setUp(); \
TestFunc(); \
} \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \
tearDown(); \
} \
UnityConcludeTest(); \
}
//=======Automagically Detected Files To Include=====
#include "unity.h" #include "unity.h"
#include <setjmp.h> #include <setjmp.h>
#include <stdio.h> #include <stdio.h>
#include "ProductionCode2.h"
char MessageBuffer[50]; //=======External Functions This Runner Calls=====
extern void setUp(void); extern void setUp(void);
extern void tearDown(void); extern void tearDown(void);
extern void test_IgnoredTest(void); extern void test_IgnoredTest(void);
extern void test_AnotherIgnoredTest(void); extern void test_AnotherIgnoredTest(void);
extern void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void); extern void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void);
//=======Test Reset Option=====
void resetTest(void); void resetTest(void);
void resetTest(void) void resetTest(void)
{ {
...@@ -20,14 +41,13 @@ void resetTest(void) ...@@ -20,14 +41,13 @@ void resetTest(void)
} }
//=======MAIN=====
int main(void) int main(void)
{ {
UnityBegin("test/TestProductionCode2.c"); UnityBegin("test/TestProductionCode2.c");
RUN_TEST(test_IgnoredTest, 18);
RUN_TEST(test_AnotherIgnoredTest, 23);
RUN_TEST(test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented, 28);
RUN_TEST(test_IgnoredTest, 13); return (UnityEnd());
RUN_TEST(test_AnotherIgnoredTest, 18);
RUN_TEST(test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented, 23);
UnityEnd();
return 0;
} }
/* AUTOGENERATED FILE. DO NOT EDIT. */ /* AUTOGENERATED FILE. DO NOT EDIT. */
//=======Test Runner Used To Run Each Test Below=====
#define RUN_TEST(TestFunc, TestLineNum) \
{ \
Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
if (TEST_PROTECT()) \
{ \
setUp(); \
TestFunc(); \
} \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \
tearDown(); \
} \
UnityConcludeTest(); \
}
//=======Automagically Detected Files To Include=====
#include "unity.h" #include "unity.h"
#include <setjmp.h> #include <setjmp.h>
#include <stdio.h> #include <stdio.h>
#include "ProductionCode.h"
char MessageBuffer[50]; //=======External Functions This Runner Calls=====
extern void setUp(void); extern void setUp(void);
extern void tearDown(void); extern void tearDown(void);
extern void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void); extern void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void);
extern void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken(void); extern void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken(void);
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(void); extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(void);
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void); extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void);
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void); extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void);
//=======Test Reset Option=====
void resetTest(void); void resetTest(void);
void resetTest(void) void resetTest(void)
{ {
...@@ -22,16 +43,15 @@ void resetTest(void) ...@@ -22,16 +43,15 @@ void resetTest(void)
} }
//=======MAIN=====
int main(void) int main(void)
{ {
UnityBegin("test/TestProductionCode.c"); UnityBegin("test/TestProductionCode.c");
RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode, 20); RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode, 20);
RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken, 30); RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken, 30);
RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue, 41); RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue, 41);
RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain, 51); RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain, 51);
RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed, 57); RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed, 57);
UnityEnd(); return (UnityEnd());
return 0;
} }
...@@ -9,7 +9,11 @@ ifeq ($(OSTYPE),cygwin) ...@@ -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= ...@@ -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)
......
# ==========================================
# 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)
/* 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;
}
/* 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;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册