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
|
||||
MKDIR = mkdir -p
|
||||
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
|
||||
MKDIR = mkdir
|
||||
TARGET_EXTENSION=.exe
|
||||
@ -50,8 +54,8 @@ SYMBOLS=-DTEST
|
||||
all: clean 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
|
||||
ruby $(UNITY_ROOT)/auto/generate_test_runner.rb test/TestProductionCode.c test/test_runners/TestProductionCode_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_FILES2) -o $(TARGET2)
|
||||
./$(TARGET1)
|
||||
|
@ -1,17 +1,38 @@
|
||||
/* 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 <setjmp.h>
|
||||
#include <stdio.h>
|
||||
#include "ProductionCode2.h"
|
||||
|
||||
char MessageBuffer[50];
|
||||
|
||||
//=======External Functions This Runner Calls=====
|
||||
extern void setUp(void);
|
||||
extern void tearDown(void);
|
||||
|
||||
extern void test_IgnoredTest(void);
|
||||
extern void test_AnotherIgnoredTest(void);
|
||||
extern void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void);
|
||||
|
||||
|
||||
//=======Test Reset Option=====
|
||||
void resetTest(void);
|
||||
void resetTest(void)
|
||||
{
|
||||
@ -20,14 +41,13 @@ void resetTest(void)
|
||||
}
|
||||
|
||||
|
||||
//=======MAIN=====
|
||||
int main(void)
|
||||
{
|
||||
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);
|
||||
RUN_TEST(test_AnotherIgnoredTest, 18);
|
||||
RUN_TEST(test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented, 23);
|
||||
|
||||
UnityEnd();
|
||||
return 0;
|
||||
return (UnityEnd());
|
||||
}
|
||||
|
@ -1,19 +1,40 @@
|
||||
/* 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 <setjmp.h>
|
||||
#include <stdio.h>
|
||||
#include "ProductionCode.h"
|
||||
|
||||
char MessageBuffer[50];
|
||||
|
||||
//=======External Functions This Runner Calls=====
|
||||
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);
|
||||
|
||||
|
||||
//=======Test Reset Option=====
|
||||
void resetTest(void);
|
||||
void resetTest(void)
|
||||
{
|
||||
@ -22,16 +43,15 @@ void resetTest(void)
|
||||
}
|
||||
|
||||
|
||||
//=======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);
|
||||
|
||||
UnityEnd();
|
||||
return 0;
|
||||
return (UnityEnd());
|
||||
}
|
||||
|
@ -9,7 +9,11 @@ ifeq ($(OSTYPE),cygwin)
|
||||
CLEANUP = rm -f
|
||||
MKDIR = mkdir -p
|
||||
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
|
||||
MKDIR = mkdir
|
||||
TARGET_EXTENSION=.exe
|
||||
@ -58,8 +62,6 @@ SYMBOLS=
|
||||
all: clean 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)
|
||||
./$(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