├── .gitignore
├── .gitmodules
├── CppUTestCompileFlags.mk
├── Makefile
├── README.md
├── SandBox
├── .cproject
├── .project
├── Makefile
├── MakefileCppUTest.mk
├── MakefileUnity.mk
├── SandBox.dsw
├── include
│ └── LedDriver
│ │ └── LedDriver.h
├── src
│ ├── LedDriver
│ │ └── LedDriver.c
│ └── ProductionCodeLib.dsp
├── tests
│ ├── AllTests.cpp
│ ├── AllTests_CppUTest.dsp
│ └── LedDriver
│ │ └── LedDriverTest.cpp
└── unity
│ ├── AllTests.c
│ └── LedDriver
│ ├── LedDriverTest.c
│ └── LedDriverTestRunner.c
├── code-t0
├── .cproject
├── .project
├── Makefile
├── include
│ ├── HomeAutomation
│ │ ├── LightController.h
│ │ ├── LightScheduler.h
│ │ └── RandomMinute.h
│ └── util
│ │ ├── TimeService.h
│ │ └── common.h
├── mocks
│ ├── FakeRandomMinute.c
│ ├── FakeRandomMinute.h
│ ├── FakeTimeService.c
│ ├── FakeTimeService.h
│ ├── FakeTimeServiceTest.cpp
│ ├── LightControllerSpy.c
│ ├── LightControllerSpy.h
│ └── LightControllerTestSpy.cpp
├── src
│ ├── HomeAutomation
│ │ ├── LightScheduler.c
│ │ └── RandomMinute.c
│ └── ProductionCodeLib.dsp
├── t0.dsw
├── tests
│ ├── AllTests.cpp
│ ├── AllTests_CppUTest.dsp
│ └── HomeAutomation
│ │ ├── LightSchedulerRandomizeTest.cpp
│ │ ├── LightSchedulerTest.cpp
│ │ └── RandomMinuteTest.cpp
└── unity
│ └── HomeAutomation
│ ├── LightSchedulerTest.c
│ └── LightSchedulerTest_runner.c
├── code-t1
├── .cproject
├── .project
├── Makefile
├── include
│ ├── HomeAutomation
│ │ ├── LightController.h
│ │ ├── LightScheduler.h
│ │ └── RandomMinute.h
│ ├── IO
│ │ ├── Flash.h
│ │ ├── IO.h
│ │ ├── MicroTime.h
│ │ └── m28w160ect.h
│ ├── MyOS
│ │ ├── MyOsPrivate.h
│ │ └── Thread.h
│ ├── devices
│ │ ├── AcmeWirelessLightDriver.h
│ │ ├── LightDriver.h
│ │ ├── MemMappedLightDriver.h
│ │ └── X10LightDriver.h
│ └── util
│ │ ├── TimeService.h
│ │ └── common.h
├── mocks
│ ├── FakeRandomMinute.c
│ ├── FakeRandomMinute.h
│ ├── FakeTimeService.c
│ ├── FakeTimeService.h
│ ├── FakeTimeServiceTest.cpp
│ ├── IO
│ │ ├── FakeMicroTime.c
│ │ ├── FakeMicroTime.h
│ │ └── FakeMicroTimeTest.cpp
│ ├── LightDriverSpy.c
│ ├── LightDriverSpy.h
│ └── LightDriverSpyTest.cpp
├── src
│ ├── HomeAutomation
│ │ ├── LightController.c
│ │ ├── LightScheduler.c
│ │ └── RandomMinute.c
│ ├── IO
│ │ ├── Flash.c
│ │ └── IO.c
│ ├── MyOS
│ │ ├── Acme
│ │ │ ├── AcmeOs.c
│ │ │ ├── AcmeOs.h
│ │ │ └── Thread.c
│ │ ├── MyOsHelpers.c
│ │ ├── Win32
│ │ │ └── Thread.c
│ │ └── posix
│ │ │ └── Thread.c
│ ├── ProductionCodeLib.dsp
│ ├── devices
│ │ ├── AcmeWirelessLightDriver.c
│ │ ├── MemMappedLightDriver.c
│ │ └── X10LightDriver.c
│ └── util
│ │ ├── TimeService.c
│ │ ├── TimeService_Helpers.c
│ │ └── common.c
├── t1.dsw
└── tests
│ ├── AllTests.cpp
│ ├── AllTests_CppUTest.dsp
│ ├── HomeAutomation
│ ├── LightControllerTest.cpp
│ ├── LightSchedulerRandomizeTest.cpp
│ ├── LightSchedulerTest.cpp
│ └── RandomMinuteTest.cpp
│ ├── IO
│ └── FlashTest.cpp
│ ├── MyOS
│ └── ThreadTest.cpp
│ ├── devices
│ ├── AcmeWirelessLightDriverTest.cpp
│ ├── MemMappedLightDriverTest.cpp
│ └── X10LightDriverTest.cpp
│ └── util
│ └── TimeServiceHelpersTest.cpp
├── code-t2
├── .cproject
├── .project
├── Makefile
├── include
│ ├── HomeAutomation
│ │ ├── LightController.h
│ │ ├── LightScheduler.h
│ │ └── RandomMinute.h
│ ├── devices
│ │ ├── AcmeWirelessLightDriver.h
│ │ ├── LightDriver.h
│ │ ├── LightDriverPrivate.h
│ │ ├── MemMappedLightDriver.h
│ │ └── X10LightDriver.h
│ └── util
│ │ ├── TimeService.h
│ │ └── common.h
├── mocks
│ ├── FakeRandomMinute.c
│ ├── FakeRandomMinute.h
│ ├── FakeTimeService.c
│ ├── FakeTimeService.h
│ ├── FakeTimeServiceTest.cpp
│ ├── LightDriverSpy.c
│ ├── LightDriverSpy.h
│ └── LightDriverSpyTest.cpp
├── src
│ ├── HomeAutomation
│ │ ├── LightController.c
│ │ ├── LightScheduler.c
│ │ └── RandomMinute.c
│ ├── ProductionCodeLib.dsp
│ ├── devices
│ │ ├── AcmeWirelessLightDriver.c
│ │ ├── LightDriver.c
│ │ ├── MemMappedLightDriver.c
│ │ └── X10LightDriver.c
│ └── util
│ │ ├── Time.c
│ │ ├── TimeService.c
│ │ └── common.c
├── t2.dsw
└── tests
│ ├── AllTests.cpp
│ ├── AllTests_CppUTest.dsp
│ ├── HomeAutomation
│ ├── LightControllerTest.cpp
│ ├── LightSchedulerRandomizeTest.cpp
│ ├── LightSchedulerTest.cpp
│ └── RandomMinuteTest.cpp
│ ├── devices
│ ├── AcmeWirelessLightDriverTest.cpp
│ ├── LightDriverTest.cpp
│ ├── MemMappedLightDriverTest.cpp
│ └── X10LightDriverTest.cpp
│ └── util
│ └── TimeTest.cpp
├── code-t3
├── .cproject
├── .project
├── Makefile
├── include
│ ├── HomeAutomation
│ │ ├── LightController.h
│ │ ├── LightScheduler.h
│ │ └── RandomMinute.h
│ ├── devices
│ │ ├── AcmeWirelessLightDriver.h
│ │ ├── LightDriver.h
│ │ ├── LightDriverPrivate.h
│ │ ├── MemMappedLightDriver.h
│ │ └── X10LightDriver.h
│ └── util
│ │ ├── TimeService.h
│ │ └── common.h
├── mocks
│ ├── CountingLightDriver.c
│ ├── CountingLightDriver.h
│ ├── FakeRandomMinute.c
│ ├── FakeRandomMinute.h
│ ├── FakeTimeService.c
│ ├── FakeTimeService.h
│ ├── FakeTimeServiceTest.cpp
│ ├── LightDriverSpy.c
│ ├── LightDriverSpy.h
│ └── LightDriverSpyTest.cpp
├── src
│ ├── ApplicationLib.dsp
│ ├── HomeAutomation
│ │ ├── LightController.c
│ │ ├── LightScheduler.c
│ │ └── RandomMinute.c
│ ├── ProductionCodeLib.dsp
│ ├── devices
│ │ ├── AcmeWirelessLightDriver.c
│ │ ├── LightDriver.c
│ │ ├── MemMappedLightDriver.c
│ │ └── X10LightDriver.c
│ └── util
│ │ ├── Time.c
│ │ ├── TimeService.c
│ │ ├── TimeService_Helpers.c
│ │ └── common.c
├── t3.dsw
└── tests
│ ├── AllTests.cpp
│ ├── AllTests.dsp
│ ├── AllTests_CppUTest.dsp
│ ├── HomeAutomation
│ ├── LightControllerTest.cpp
│ ├── LightSchedulerRandomizeTest.cpp
│ ├── LightSchedulerTest.cpp
│ └── RandomMinuteTest.cpp
│ ├── devices
│ ├── AcmeWirelessLightDriverTest.cpp
│ ├── LightDriverTest.cpp
│ ├── MemMappedLightDriverTest.cpp
│ └── X10LightDriverTest.cpp
│ └── util
│ └── TimeTest.cpp
├── code
├── .cproject
├── .project
├── BookCode.dsw
├── Makefile
├── MakefileCppUTest.mk
├── MakefileUnity.mk
├── SandBox
│ ├── .cproject
│ ├── .project
│ ├── Makefile
│ ├── MakefileCppUTest.mk
│ ├── MakefileUnity.mk
│ ├── SandBox.dsw
│ ├── include
│ │ └── LedDriver
│ │ │ └── LedDriver.h
│ ├── src
│ │ ├── LedDriver
│ │ │ └── LedDriver.c
│ │ └── ProductionCodeLib.dsp
│ ├── tests
│ │ ├── AllTests.cpp
│ │ ├── AllTests_CppUTest.dsp
│ │ └── LedDriver
│ │ │ └── LedDriverTest.cpp
│ └── unity
│ │ ├── AllTests.c
│ │ └── LedDriver
│ │ ├── LedDriverTest.c
│ │ └── LedDriverTestRunner.c
├── docs
│ └── STMicroelectronics
│ │ ├── c2414.c
│ │ ├── c2414.h
│ │ ├── c2414FlashReadAndWrite.h
│ │ └── m28w160ect.pdf
├── include
│ ├── HomeAutomation
│ │ ├── LightController.h
│ │ ├── LightScheduler.h
│ │ └── TimeService.h
│ ├── IO
│ │ ├── Flash.h
│ │ ├── IO.h
│ │ ├── MicroTime.h
│ │ └── m28w160ect.h
│ ├── LedDriver
│ │ └── LedDriver.h
│ ├── MyOS
│ │ └── Thread.h
│ ├── dvr
│ │ └── DvRecorder.h
│ ├── util
│ │ ├── CircularBuffer.h
│ │ ├── RuntimeError.h
│ │ ├── Utils.h
│ │ └── common.h
│ └── zune
│ │ └── RtcTime.h
├── mocks
│ ├── FakeMicroTime.c
│ ├── FakeMicroTime.h
│ ├── FakeMicroTimeTest.cpp
│ ├── FormatOutputSpy.c
│ ├── FormatOutputSpy.h
│ ├── FormatOutputSpyTest.cpp
│ ├── MockIO.c
│ ├── MockIO.h
│ ├── MockIOTest.cpp
│ ├── RuntimeErrorStub.c
│ ├── RuntimeErrorStub.h
│ └── cmock
│ │ ├── MockIO.c
│ │ └── MockIO.h
├── src
│ ├── HomeAutomation
│ │ └── LightScheduler.c
│ ├── IO
│ │ ├── Flash.c
│ │ └── IO.c
│ ├── LedDriver
│ │ └── LedDriver.c
│ ├── MyOS
│ │ ├── Acme
│ │ │ ├── AcmeOs.c
│ │ │ ├── AcmeOs.h
│ │ │ └── Thread.c
│ │ ├── Micrium
│ │ │ └── Thread.c
│ │ ├── Win32
│ │ │ └── Thread.c
│ │ └── posix
│ │ │ └── Thread.c
│ ├── ProductionCodeLib.dsp
│ ├── dvr
│ │ └── DvRecorder.c
│ ├── eyeMovement
│ │ └── eye.c
│ ├── util
│ │ ├── CircularBuffer.c
│ │ └── Utils.c
│ └── zune
│ │ └── RtcTime.c
├── tests
│ ├── AllTests.cpp
│ ├── AllTests_CppUTest.dsp
│ ├── HomeAutomation
│ │ ├── FakeTimeService.c
│ │ ├── FakeTimeService.h
│ │ ├── FakeTimeServiceTest.cpp
│ │ ├── LightControllerSpy.c
│ │ ├── LightControllerSpy.h
│ │ ├── LightControllerSpyTest.cpp
│ │ └── LightSchedulerTest.cpp
│ ├── IO
│ │ ├── FlashTest.cpp
│ │ └── LegacyFlashTest.cpp
│ ├── LedDriver
│ │ └── LedDriverTest.cpp
│ ├── MyOS
│ │ └── ThreadTest.cpp
│ ├── dvr
│ │ └── DvRecorderTest.cpp
│ ├── stdio
│ │ └── SprintfTest.cpp
│ ├── util
│ │ ├── CircularBufferPrintTest.cpp
│ │ └── CircularBufferTest.cpp
│ └── zune
│ │ └── RtcTimeTest.cpp
├── unity.framework
│ ├── auto
│ │ ├── colour_prompt.rb
│ │ ├── colour_reporter.rb
│ │ ├── generate_config.yml
│ │ ├── generate_module.rb
│ │ ├── generate_test_runner.rb
│ │ ├── test_file_filter.rb
│ │ └── unity_test_summary.rb
│ ├── docs
│ │ ├── Unity Summary.odt
│ │ ├── Unity Summary.pdf
│ │ ├── Unity Summary.txt
│ │ └── license.txt
│ ├── examples
│ │ ├── helper
│ │ │ ├── UnityHelper.c
│ │ │ └── UnityHelper.h
│ │ ├── makefile
│ │ ├── rakefile.rb
│ │ ├── rakefile_helper.rb
│ │ ├── readme.txt
│ │ ├── src
│ │ │ ├── ProductionCode.c
│ │ │ ├── ProductionCode.h
│ │ │ ├── ProductionCode2.c
│ │ │ └── ProductionCode2.h
│ │ └── test
│ │ │ ├── TestProductionCode.c
│ │ │ ├── TestProductionCode2.c
│ │ │ └── no_ruby
│ │ │ ├── TestProductionCode2_Runner.c
│ │ │ └── TestProductionCode_Runner.c
│ ├── extras
│ │ └── fixture
│ │ │ ├── build
│ │ │ ├── MakefileWorker.mk
│ │ │ └── filterGcov.sh
│ │ │ ├── rakefile.rb
│ │ │ ├── rakefile_helper.rb
│ │ │ ├── readme.txt
│ │ │ ├── src
│ │ │ ├── unity_fixture.c
│ │ │ ├── unity_fixture.h
│ │ │ ├── unity_fixture_internals.h
│ │ │ └── unity_fixture_malloc_overrides.h
│ │ │ └── test
│ │ │ ├── main
│ │ │ └── AllTests.c
│ │ │ ├── testunity_fixture.c
│ │ │ ├── unity_fixture_Test.c
│ │ │ ├── unity_fixture_TestRunner.c
│ │ │ ├── unity_output_Spy.c
│ │ │ └── unity_output_Spy.h
│ ├── makefile
│ ├── rakefile.rb
│ ├── rakefile_helper.rb
│ ├── release
│ │ ├── build.info
│ │ └── version.info
│ ├── src
│ │ ├── unity.c
│ │ ├── unity.h
│ │ └── unity_internals.h
│ ├── targets
│ │ ├── gcc.yml
│ │ ├── gcc_64.yml
│ │ ├── hitech_picc18.yml
│ │ ├── iar_arm_v4.yml
│ │ ├── iar_arm_v5.yml
│ │ ├── iar_cortexm3_v5.yml
│ │ └── iar_msp430.yml
│ └── test
│ │ ├── expectdata
│ │ ├── testsample_cmd.c
│ │ ├── testsample_def.c
│ │ ├── testsample_mock_cmd.c
│ │ ├── testsample_mock_def.c
│ │ ├── testsample_mock_new1.c
│ │ ├── testsample_mock_new2.c
│ │ ├── testsample_mock_param.c
│ │ ├── testsample_mock_run1.c
│ │ ├── testsample_mock_run2.c
│ │ ├── testsample_mock_yaml.c
│ │ ├── testsample_new1.c
│ │ ├── testsample_new2.c
│ │ ├── testsample_param.c
│ │ ├── testsample_run1.c
│ │ ├── testsample_run2.c
│ │ └── testsample_yaml.c
│ │ ├── test_generate_test_runner.rb
│ │ ├── testdata
│ │ ├── mocksample.c
│ │ ├── sample.yml
│ │ └── testsample.c
│ │ ├── testparameterized.c
│ │ └── testunity.c
└── unity
│ ├── AllTests.c
│ ├── HomeAutomation
│ ├── FakeTimeService.c
│ ├── FakeTimeService.h
│ ├── FakeTimeServiceTest.c
│ ├── FakeTimeServiceTest_runner.c
│ ├── LightControllerSpy.c
│ ├── LightControllerSpy.h
│ ├── LightControllerSpyTest.c
│ ├── LightControllerSpyTest_runner.c
│ ├── LightSchedulerTest.c
│ └── LightSchedulerTest_runner.c
│ ├── LedDriver
│ ├── LedDriverTest.c
│ └── LedDriverTestRunner.c
│ ├── build
│ ├── MakefileWorker.mk
│ └── filterGcov.sh
│ ├── mocks
│ ├── RuntimeErrorStub.c
│ └── RuntimeErrorStub.h
│ └── stdio
│ ├── SprintfTest.c
│ └── SprintfTestRunner.c
└── notes.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *.swp
3 | *.*~
4 | .*~
5 | *.d
6 | *.o
7 | *.a
8 | .settings
9 | gcov_*.txt
10 | *.gcov
11 | *.gcno
12 | *.gcda
13 | *_tests
14 | *a.out
15 | *.zip
16 | tmp
17 | gcov
18 | objs
19 | lib
20 | *_tests.txt
21 | gcov*.html
22 | .metadata
23 | Debug
24 | */Debug/*
25 | *.exe
26 | *.obj
27 | *.ncb
28 | *.opt
29 | *.plg
30 | *.idb
31 | *.pdb
32 | *.sou
33 | *.sdf
34 | *.lib
35 | *.log
36 | *.tlog
37 | *.cache
38 | *.user
39 | RemoteSystemsTempFiles/*
40 | *.sublime*
41 |
42 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "cpputest"]
2 | path = cpputest
3 | url = https://github.com/cpputest/cpputest.git
4 | ignore = dirty
5 |
--------------------------------------------------------------------------------
/CppUTestCompileFlags.mk:
--------------------------------------------------------------------------------
1 |
2 | # Figure out how to ask if gcc7 vs clang, gcc7 only right now
3 | ifeq "0" "1"
4 | CPPUTEST_WARNINGFLAGS += -Wno-unknown-warning-option
5 | CPPUTEST_WARNINGFLAGS += -Wno-covered-switch-default
6 | CPPUTEST_WARNINGFLAGS += -Wno-reserved-id-macro
7 | CPPUTEST_WARNINGFLAGS += -Wno-keyword-macro
8 | CPPUTEST_WARNINGFLAGS += -Wno-documentation
9 | CPPUTEST_WARNINGFLAGS += -Wno-missing-noreturn
10 | endif
11 |
12 | CPPUTEST_WARNINGFLAGS += -Wall
13 | CPPUTEST_WARNINGFLAGS += -Werror
14 | CPPUTEST_WARNINGFLAGS += -Wswitch-default
15 | CPPUTEST_WARNINGFLAGS += -Wno-format-nonliteral
16 | CPPUTEST_WARNINGFLAGS += -Wno-sign-conversion
17 | CPPUTEST_WARNINGFLAGS += -Wno-pedantic
18 | CPPUTEST_WARNINGFLAGS += -Wno-shadow
19 | CPPUTEST_WARNINGFLAGS += -Wno-missing-field-initializers
20 | CPPUTEST_WARNINGFLAGS += -Wno-unused-parameter
21 | CPPUTEST_CFLAGS += -Wall
22 | CPPUTEST_CFLAGS += -Wstrict-prototypes
23 | CPPUTEST_CFLAGS += -pedantic
24 | CPPUTEST_CFLAGS += -Wno-missing-prototypes
25 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 |
2 | all: cpputest
3 | @echo CPPUTEST_HOME is $(CPPUTEST_HOME)
4 | make -i -C code
5 | make -i -C code-t0
6 | make -i -C code-t1
7 | make -i -C code-t2
8 | make -i -C code-t3
9 |
10 | clean:
11 | make -i -C cpputest clean
12 | make -i -C code clean
13 | make -i -C code-t0 clean
14 | make -i -C code-t1 clean
15 | make -i -C code-t2 clean
16 | make -i -C code-t3 clean
17 |
18 | .PHONY: cpputest
19 | cpputest: cpputest/lib/libCppUTest.a
20 |
21 | cpputest/lib/libCppUTest.a:
22 | cd cpputest; autoreconf . -i && ./configure && make tdd
23 |
--------------------------------------------------------------------------------
/SandBox/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | SandBox
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
15 | full,incremental,
16 |
17 |
18 |
19 |
20 |
21 | org.eclipse.cdt.core.cnature
22 | org.eclipse.cdt.core.ccnature
23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
25 |
26 |
27 |
--------------------------------------------------------------------------------
/SandBox/Makefile:
--------------------------------------------------------------------------------
1 | all:
2 | make -i -f MakefileCppUTest.mk
3 | make -i -f MakefileUnity.mk
4 |
5 | clean:
6 | make -i -f MakefileCppUTest.mk clean
7 | make -i -f MakefileUnity.mk clean
8 |
9 |
--------------------------------------------------------------------------------
/SandBox/MakefileCppUTest.mk:
--------------------------------------------------------------------------------
1 | #Set this to @ to keep the makefile quiet
2 | SILENCE = @
3 |
4 | #---- Outputs ----#
5 | COMPONENT_NAME = SandBox_CppUTest
6 | TARGET_LIB = \
7 | lib/lib$(COMPONENT_NAME).a
8 |
9 | TEST_TARGET = \
10 | $(COMPONENT_NAME)_tests
11 |
12 | #--- Inputs ----#
13 | PROJECT_HOME_DIR = .
14 | CPP_PLATFORM = Gcc
15 |
16 | SRC_DIRS = \
17 | $(PROJECT_HOME_DIR)/src/LedDriver \
18 |
19 | TEST_SRC_DIRS = \
20 | tests\
21 | tests/*\
22 |
23 | INCLUDE_DIRS =\
24 | .\
25 | $(CPPUTEST_HOME)/include\
26 | $(PROJECT_HOME_DIR)/include/LedDriver\
27 |
28 | include ../CppUTestCompileFlags.mk
29 | include $(CPPUTEST_HOME)/build/MakefileWorker.mk
30 |
--------------------------------------------------------------------------------
/SandBox/MakefileUnity.mk:
--------------------------------------------------------------------------------
1 | #Set this to @ to keep the makefile quiet
2 | SILENCE = @
3 |
4 | #---- Outputs ----#
5 | COMPONENT_NAME = SandBox_Unity
6 |
7 | #--- Inputs ----#
8 | PROJECT_HOME_DIR = .
9 | UNITY_HOME = ../code/unity.framework
10 | CPP_PLATFORM = Gcc
11 | UNITY_BUILD_HOME = ../code/unity.framework/extras/fixture/build
12 |
13 | UNITY_CFLAGS += -DUNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar
14 |
15 | SRC_DIRS = \
16 | $(PROJECT_HOME_DIR)/src/LedDriver \
17 |
18 | TEST_SRC_DIRS = \
19 | $(PROJECT_HOME_DIR)/unity\
20 | $(PROJECT_HOME_DIR)/unity/LedDriver\
21 | $(UNITY_HOME)/src\
22 | $(UNITY_HOME)/extras/fixture/src\
23 | $(UNITY_HOME)/extras/fixture/test\
24 |
25 | INCLUDE_DIRS =\
26 | .\
27 | $(UNITY_HOME)/src\
28 | $(UNITY_HOME)/src\
29 | $(UNITY_HOME)/extras/fixture/src\
30 | $(UNITY_HOME)/extras/fixture/test\
31 | $(PROJECT_HOME_DIR)/include/LedDriver\
32 |
33 | include $(UNITY_BUILD_HOME)/MakefileWorker.mk
34 |
--------------------------------------------------------------------------------
/SandBox/SandBox.dsw:
--------------------------------------------------------------------------------
1 | Microsoft Developer Studio Workspace File, Format Version 6.00
2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3 |
4 | ###############################################################################
5 |
6 | Project: "AllTests_CppUTest"=.\tests\AllTests_CppUTest.dsp - Package Owner=<4>
7 |
8 | Package=<5>
9 | {{{
10 | }}}
11 |
12 | Package=<4>
13 | {{{
14 | Begin Project Dependency
15 | Project_Dep_Name ProductionCodeLib
16 | End Project Dependency
17 | }}}
18 |
19 | ###############################################################################
20 |
21 | Project: "ProductionCodeLib"=.\src\ProductionCodeLib.dsp - Package Owner=<4>
22 |
23 | Package=<5>
24 | {{{
25 | }}}
26 |
27 | Package=<4>
28 | {{{
29 | }}}
30 |
31 | ###############################################################################
32 |
33 | Global:
34 |
35 | Package=<5>
36 | {{{
37 | }}}
38 |
39 | Package=<3>
40 | {{{
41 | }}}
42 |
43 | ###############################################################################
44 |
45 |
--------------------------------------------------------------------------------
/SandBox/include/LedDriver/LedDriver.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #ifndef D_LedDriver_H
28 | #define D_LedDriver_H
29 |
30 | void LedDriver_Create(void);
31 | void LedDriver_Destroy(void);
32 |
33 | #endif /* D_LedDriver_H */
34 |
--------------------------------------------------------------------------------
/SandBox/src/LedDriver/LedDriver.c:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #include "LedDriver.h"
28 | #include
29 | #include
30 |
31 | void LedDriver_Create(void)
32 | {
33 | }
34 |
35 | void LedDriver_Destroy(void)
36 | {
37 | }
38 |
39 |
40 |
--------------------------------------------------------------------------------
/SandBox/tests/AllTests.cpp:
--------------------------------------------------------------------------------
1 | //- ------------------------------------------------------------------
2 | //- Copyright (c) James W. Grenning -- All Rights Reserved
3 | //- For use by owners of Test-Driven Development for Embedded C,
4 | //- and attendees of Renaissance Software Consulting, Co. training
5 | //- classes.
6 | //-
7 | //- Available at http://pragprog.com/titles/jgade/
8 | //- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3
9 | //-
10 | //- Authorized users may use this source code in your own
11 | //- projects, however the source code may not be used to
12 | //- create training material, courses, books, articles, and
13 | //- the like. We make no guarantees that this source code is
14 | //- fit for any purpose.
15 | //-
16 | //- www.renaissancesoftware.net james@renaissancesoftware.net
17 | //- ------------------------------------------------------------------
18 |
19 | #include "CppUTest/CommandLineTestRunner.h"
20 |
21 | int main(int ac, const char** av)
22 | {
23 | int result = RUN_ALL_TESTS(ac, av);
24 |
25 | return result;
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/SandBox/tests/LedDriver/LedDriverTest.cpp:
--------------------------------------------------------------------------------
1 | //- ------------------------------------------------------------------
2 | //- Copyright (c) James W. Grenning -- All Rights Reserved
3 | //- For use by owners of Test-Driven Development for Embedded C,
4 | //- and attendees of Renaissance Software Consulting, Co. training
5 | //- classes.
6 | //-
7 | //- Available at http://pragprog.com/titles/jgade/
8 | //- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3
9 | //-
10 | //- Authorized users may use this source code in your own
11 | //- projects, however the source code may not be used to
12 | //- create training material, courses, books, articles, and
13 | //- the like. We make no guarantees that this source code is
14 | //- fit for any purpose.
15 | //-
16 | //- www.renaissancesoftware.net james@renaissancesoftware.net
17 | //- ------------------------------------------------------------------
18 |
19 | extern "C"
20 | {
21 | #include "LedDriver.h"
22 | }
23 |
24 | #include "CppUTest/TestHarness.h"
25 |
26 | TEST_GROUP(LedDriver)
27 | {
28 | void setup()
29 | {
30 | LedDriver_Create();
31 | }
32 |
33 | void teardown()
34 | {
35 | LedDriver_Destroy();
36 | }
37 | };
38 |
39 | TEST(LedDriver, Create)
40 | {
41 | // FAIL("Start here");
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/SandBox/unity/AllTests.c:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #include "unity_fixture.h"
28 |
29 | static void RunAllTests(void)
30 | {
31 | RUN_TEST_GROUP(LedDriver);
32 | }
33 |
34 | int main(int ac, char* av[])
35 | {
36 | return UnityMain(ac, av, RunAllTests);
37 | }
38 |
--------------------------------------------------------------------------------
/SandBox/unity/LedDriver/LedDriverTest.c:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #include "unity_fixture.h"
28 | #include "LedDriver.h"
29 |
30 | #include "unity_fixture.h"
31 |
32 | TEST_GROUP(LedDriver);
33 |
34 | TEST_SETUP(LedDriver)
35 | {
36 | }
37 |
38 | TEST_TEAR_DOWN(LedDriver)
39 | {
40 | }
41 |
42 | TEST(LedDriver, StartHere)
43 | {
44 | /* TEST_FAIL("Start here"); */
45 | }
46 |
--------------------------------------------------------------------------------
/SandBox/unity/LedDriver/LedDriverTestRunner.c:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #include "unity_fixture.h"
28 |
29 | TEST_GROUP_RUNNER(LedDriver)
30 | {
31 | RUN_TEST_CASE(LedDriver, StartHere);
32 | }
33 |
--------------------------------------------------------------------------------
/code-t0/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | code-t0
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
15 | full,incremental,
16 |
17 |
18 |
19 |
20 |
21 | org.eclipse.cdt.core.cnature
22 | org.eclipse.cdt.core.ccnature
23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
25 |
26 |
27 |
--------------------------------------------------------------------------------
/code-t0/Makefile:
--------------------------------------------------------------------------------
1 | #Set this to @ to keep the makefile quiet
2 | SILENCE = @
3 |
4 | #---- Outputs ----#
5 | COMPONENT_NAME = t0
6 | TARGET_LIB = \
7 | lib/lib$(COMPONENT_NAME).a
8 |
9 | TEST_TARGET = \
10 | $(COMPONENT_NAME)_tests
11 |
12 | #--- Inputs ----#
13 | PROJECT_HOME_DIR = .
14 |
15 | CPP_PLATFORM = Gcc
16 |
17 | SRC_DIRS = \
18 | src/util\
19 | src/HomeAutomation\
20 |
21 | TEST_SRC_DIRS = \
22 | tests \
23 | tests/HomeAutomation\
24 | mocks
25 |
26 | INCLUDE_DIRS =\
27 | $(CPPUTEST_HOME)/include/\
28 | include/*\
29 | mocks
30 |
31 | include ../CppUTestCompileFlags.mk
32 | include $(CPPUTEST_HOME)/build/MakefileWorker.mk
33 |
--------------------------------------------------------------------------------
/code-t0/include/HomeAutomation/RandomMinute.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 |
28 | #ifndef D_RandomMinute_H
29 | #define D_RandomMinute_H
30 |
31 |
32 | void RandomMinute_Create(int bound);
33 | extern int (*RandomMinute_Get)(void);
34 |
35 | #if 0
36 | void RandomMinute_Create(int bound);
37 | int RandomMinute_Get(void);
38 | #endif
39 |
40 | #endif /* D_RandomMinute_H */
41 |
--------------------------------------------------------------------------------
/code-t0/include/util/common.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 |
28 |
29 |
30 | #ifndef D_common_H
31 | #define D_common_H
32 |
33 | #ifndef BOOL
34 | #define BOOL int
35 | #endif
36 |
37 | #ifndef TRUE
38 | #define TRUE 1
39 | #endif
40 |
41 | #ifndef FALSE
42 | #define FALSE 0
43 | #endif
44 |
45 | #ifndef NULL
46 | #define NULL 0
47 | #endif
48 |
49 | #endif
50 |
--------------------------------------------------------------------------------
/code-t0/mocks/FakeRandomMinute.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #ifndef D_FakeRandomMinute_H
28 | #define D_FakeRandomMinute_H
29 |
30 | #include "RandomMinute.h"
31 |
32 | void FakeRandomMinute_SetFirstAndIncrement(int seed, int increment);
33 | int FakeRandomMinute_Get(void);
34 | void FakeRandomMinute_Reset(void);
35 | #endif /* D_RandomMinute_H */
36 |
--------------------------------------------------------------------------------
/code-t0/mocks/FakeTimeService.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 |
28 | #ifndef D_FakeTimeService_H
29 | #define D_FakeTimeService_H
30 |
31 | #include "TimeService.h"
32 |
33 | void FakeTimeService_SetMinute(int);
34 | void FakeTimeService_SetDay(int);
35 |
36 | enum {MINUTE_UNKNOWN = -1, DAY_UNKNOWN = -1 };
37 |
38 | #endif /* D_FakeTimeService_H */
39 |
--------------------------------------------------------------------------------
/code-t0/mocks/FakeTimeServiceTest.cpp:
--------------------------------------------------------------------------------
1 | //- ------------------------------------------------------------------
2 | //- Copyright (c) James W. Grenning -- All Rights Reserved
3 | //- For use by owners of Test-Driven Development for Embedded C,
4 | //- and attendees of Renaissance Software Consulting, Co. training
5 | //- classes.
6 | //-
7 | //- Available at http://pragprog.com/titles/jgade/
8 | //- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3
9 | //-
10 | //- Authorized users may use this source code in your own
11 | //- projects, however the source code may not be used to
12 | //- create training material, courses, books, articles, and
13 | //- the like. We make no guarantees that this source code is
14 | //- fit for any purpose.
15 | //-
16 | //- www.renaissancesoftware.net james@renaissancesoftware.net
17 | //- ------------------------------------------------------------------
18 |
19 | #include "CppUTest/TestHarness.h"
20 |
21 | extern "C"
22 | {
23 | #include "TimeService.h"
24 | #include "FakeTimeService.h"
25 | }
26 |
27 | TEST_GROUP(TimeService)
28 | {
29 | void setup()
30 | {
31 | TimeService_Create();
32 | }
33 |
34 | void teardown()
35 | {
36 | TimeService_Destroy();
37 | }
38 | };
39 |
40 | TEST(TimeService, Create)
41 | {
42 | LONGS_EQUAL(-1, TimeService_GetMinute());
43 | LONGS_EQUAL(-1, TimeService_GetDay());
44 | }
45 |
46 | TEST(TimeService, Set)
47 | {
48 | FakeTimeService_SetMinute(42);
49 | LONGS_EQUAL(42, TimeService_GetMinute());
50 | FakeTimeService_SetDay(3);
51 | LONGS_EQUAL(3, TimeService_GetDay());
52 | }
53 |
--------------------------------------------------------------------------------
/code-t0/t0.dsw:
--------------------------------------------------------------------------------
1 | Microsoft Developer Studio Workspace File, Format Version 6.00
2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3 |
4 | ###############################################################################
5 |
6 | Project: "AllTests_CppUTest"=.\tests\AllTests_CppUTest.dsp - Package Owner=<4>
7 |
8 | Package=<5>
9 | {{{
10 | }}}
11 |
12 | Package=<4>
13 | {{{
14 | Begin Project Dependency
15 | Project_Dep_Name ProductionCodeLib
16 | End Project Dependency
17 | }}}
18 |
19 | ###############################################################################
20 |
21 | Project: "ProductionCodeLib"=.\src\ProductionCodeLib.dsp - Package Owner=<4>
22 |
23 | Package=<5>
24 | {{{
25 | }}}
26 |
27 | Package=<4>
28 | {{{
29 | }}}
30 |
31 | ###############################################################################
32 |
33 | Global:
34 |
35 | Package=<5>
36 | {{{
37 | }}}
38 |
39 | Package=<3>
40 | {{{
41 | }}}
42 |
43 | ###############################################################################
44 |
45 |
--------------------------------------------------------------------------------
/code-t0/tests/AllTests.cpp:
--------------------------------------------------------------------------------
1 | //- ------------------------------------------------------------------
2 | //- Copyright (c) James W. Grenning -- All Rights Reserved
3 | //- For use by owners of Test-Driven Development for Embedded C,
4 | //- and attendees of Renaissance Software Consulting, Co. training
5 | //- classes.
6 | //-
7 | //- Available at http://pragprog.com/titles/jgade/
8 | //- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3
9 | //-
10 | //- Authorized users may use this source code in your own
11 | //- projects, however the source code may not be used to
12 | //- create training material, courses, books, articles, and
13 | //- the like. We make no guarantees that this source code is
14 | //- fit for any purpose.
15 | //-
16 | //- www.renaissancesoftware.net james@renaissancesoftware.net
17 | //- ------------------------------------------------------------------
18 |
19 |
20 | #include "CppUTest/CommandLineTestRunner.h"
21 |
22 | int main(int argc, const char** argv)
23 | {
24 | return RUN_ALL_TESTS(argc, argv);
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/code-t1/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | code-t1
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
15 | full,incremental,
16 |
17 |
18 |
19 |
20 |
21 | org.eclipse.cdt.core.cnature
22 | org.eclipse.cdt.core.ccnature
23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
25 |
26 |
27 |
--------------------------------------------------------------------------------
/code-t1/Makefile:
--------------------------------------------------------------------------------
1 | #Set this to @ to keep the makefile quiet
2 | SILENCE = @
3 |
4 | #---- Outputs ----#
5 | COMPONENT_NAME = t1
6 | TARGET_LIB = \
7 | lib/lib$(COMPONENT_NAME).a
8 |
9 | TEST_TARGET = \
10 | $(COMPONENT_NAME)_tests
11 |
12 | #--- Inputs ----#
13 | PROJECT_HOME_DIR = .
14 | CPP_PLATFORM = Gcc
15 |
16 | SRC_DIRS = \
17 | src/*\
18 | src/MyOS/Acme\
19 |
20 | TEST_SRC_DIRS = \
21 | tests \
22 | tests/MyOS \
23 | tests/util \
24 | tests/devices \
25 | tests/HomeAutomation\
26 | tests/IO \
27 | mocks/IO \
28 | mocks
29 |
30 | INCLUDE_DIRS =\
31 | .\
32 | $(CPPUTEST_HOME)/include/\
33 | include/*\
34 | mocks/IO \
35 | mocks
36 |
37 | CPPUTEST_USE_EXTENSIONS = Y
38 | include ../CppUTestCompileFlags.mk
39 | include $(CPPUTEST_HOME)/build/MakefileWorker.mk
40 |
--------------------------------------------------------------------------------
/code-t1/include/HomeAutomation/RandomMinute.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 |
28 | #ifndef D_RandomMinute_H
29 | #define D_RandomMinute_H
30 |
31 |
32 | void RandomMinute_Create(int bound);
33 | extern int (*RandomMinute_Get)(void);
34 |
35 | #endif /* D_RandomMinute_H */
36 |
--------------------------------------------------------------------------------
/code-t1/include/IO/IO.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 |
28 |
29 | #ifndef D_IO_H
30 | #define D_IO_H
31 | #include
32 |
33 | typedef uint32_t ioAddress;
34 | typedef uint16_t ioData;
35 |
36 | ioData IO_Read(ioAddress offset);
37 | void IO_Write(ioAddress offset, ioData data);
38 |
39 | #endif
40 |
41 |
--------------------------------------------------------------------------------
/code-t1/include/IO/MicroTime.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #ifndef D_MicroTime_H
28 | #define D_MicroTime_H
29 |
30 | #include
31 |
32 | uint32_t MicroTime_Get(void);
33 | void MicroTime_Delay(uint32_t);
34 |
35 | #endif /* D_MicroTime_H */
36 |
--------------------------------------------------------------------------------
/code-t1/mocks/FakeRandomMinute.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #ifndef D_FakeRandomMinute_H
28 | #define D_FakeRandomMinute_H
29 |
30 | #include "RandomMinute.h"
31 |
32 | void FakeRandomMinute_SetFirstAndIncrement(int seed, int increment);
33 | int FakeRandomMinute_Get(void);
34 | void FakeRandomMinute_Reset(void);
35 |
36 | #endif /* D_FakeRandomMinute_H */
37 |
--------------------------------------------------------------------------------
/code-t1/mocks/FakeTimeService.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 |
28 | #ifndef D_FakeTimeService_H
29 | #define D_FakeTimeService_H
30 |
31 | #include "TimeService.h"
32 |
33 | void FakeTimeService_SetMinute(int);
34 | void FakeTimeService_SetDay(int);
35 |
36 | enum {MINUTE_UNKNOWN = -1, DAY_UNKNOWN = -1 };
37 |
38 | #endif /* D_FakeTimeService_H */
39 |
--------------------------------------------------------------------------------
/code-t1/mocks/FakeTimeServiceTest.cpp:
--------------------------------------------------------------------------------
1 | //- ------------------------------------------------------------------
2 | //- Copyright (c) James W. Grenning -- All Rights Reserved
3 | //- For use by owners of Test-Driven Development for Embedded C,
4 | //- and attendees of Renaissance Software Consulting, Co. training
5 | //- classes.
6 | //-
7 | //- Available at http://pragprog.com/titles/jgade/
8 | //- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3
9 | //-
10 | //- Authorized users may use this source code in your own
11 | //- projects, however the source code may not be used to
12 | //- create training material, courses, books, articles, and
13 | //- the like. We make no guarantees that this source code is
14 | //- fit for any purpose.
15 | //-
16 | //- www.renaissancesoftware.net james@renaissancesoftware.net
17 | //- ------------------------------------------------------------------
18 |
19 | #include "CppUTest/TestHarness.h"
20 |
21 | extern "C"
22 | {
23 | #include "TimeService.h"
24 | #include "FakeTimeService.h"
25 | }
26 |
27 | TEST_GROUP(TimeService)
28 | {
29 | void setup()
30 | {
31 | TimeService_Create();
32 | }
33 |
34 | void teardown()
35 | {
36 | TimeService_Destroy();
37 | }
38 | };
39 |
40 | TEST(TimeService, Create)
41 | {
42 | LONGS_EQUAL(MINUTE_UNKNOWN, TimeService_GetMinute());
43 | LONGS_EQUAL(DAY_UNKNOWN, TimeService_GetDay());
44 | }
45 |
46 | TEST(TimeService, Set)
47 | {
48 | FakeTimeService_SetMinute(42);
49 | LONGS_EQUAL(42, TimeService_GetMinute());
50 | FakeTimeService_SetDay(3);
51 | LONGS_EQUAL(3, TimeService_GetDay());
52 | }
53 |
--------------------------------------------------------------------------------
/code-t1/mocks/IO/FakeMicroTime.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #ifndef D_FakeMicroTime_H
28 | #define D_FakeMicroTime_H
29 |
30 | #include "MicroTime.h"
31 |
32 | void FakeMicroTime_Init(uint32_t start, uint32_t increment);
33 | uint32_t FakeMicroTime_GetDelayDuration(void);
34 |
35 | #endif /* D_FakeMicroTime_H */
36 |
--------------------------------------------------------------------------------
/code-t1/src/IO/IO.c:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #include "IO.h"
28 |
29 | void IO_Write(ioAddress addr, ioData data)
30 | {
31 | ioData * p = 0;
32 | *(p + addr) = data;
33 | }
34 |
35 | ioData IO_Read(ioAddress addr)
36 | {
37 | ioData * p = 0;
38 | return *(p + addr);
39 | }
40 |
--------------------------------------------------------------------------------
/code-t1/src/util/common.c:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 |
28 | #include "common.h"
29 | #include
30 |
31 | void explodesInTestEnvironment(void * p)
32 | {
33 | assert(0 == "Explode - intercepted call that cannot be made in test environment");
34 | }
35 |
--------------------------------------------------------------------------------
/code-t1/t1.dsw:
--------------------------------------------------------------------------------
1 | Microsoft Developer Studio Workspace File, Format Version 6.00
2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3 |
4 | ###############################################################################
5 |
6 | Project: "AllTests_CppUTest"=.\tests\AllTests_CppUTest.dsp - Package Owner=<4>
7 |
8 | Package=<5>
9 | {{{
10 | }}}
11 |
12 | Package=<4>
13 | {{{
14 | Begin Project Dependency
15 | Project_Dep_Name ProductionCodeLib
16 | End Project Dependency
17 | }}}
18 |
19 | ###############################################################################
20 |
21 | Project: "ProductionCodeLib"=.\src\ProductionCodeLib.dsp - Package Owner=<4>
22 |
23 | Package=<5>
24 | {{{
25 | }}}
26 |
27 | Package=<4>
28 | {{{
29 | }}}
30 |
31 | ###############################################################################
32 |
33 | Global:
34 |
35 | Package=<5>
36 | {{{
37 | }}}
38 |
39 | Package=<3>
40 | {{{
41 | }}}
42 |
43 | ###############################################################################
44 |
45 |
--------------------------------------------------------------------------------
/code-t1/tests/AllTests.cpp:
--------------------------------------------------------------------------------
1 | //- ------------------------------------------------------------------
2 | //- Copyright (c) James W. Grenning -- All Rights Reserved
3 | //- For use by owners of Test-Driven Development for Embedded C,
4 | //- and attendees of Renaissance Software Consulting, Co. training
5 | //- classes.
6 | //-
7 | //- Available at http://pragprog.com/titles/jgade/
8 | //- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3
9 | //-
10 | //- Authorized users may use this source code in your own
11 | //- projects, however the source code may not be used to
12 | //- create training material, courses, books, articles, and
13 | //- the like. We make no guarantees that this source code is
14 | //- fit for any purpose.
15 | //-
16 | //- www.renaissancesoftware.net james@renaissancesoftware.net
17 | //- ------------------------------------------------------------------
18 |
19 | //START: main
20 | #include "CppUTest/CommandLineTestRunner.h"
21 |
22 | int main(int argc, const char** argv)
23 | {
24 | return RUN_ALL_TESTS(argc, argv);
25 | }
26 | //END: main
27 |
28 |
--------------------------------------------------------------------------------
/code-t1/tests/devices/AcmeWirelessLightDriverTest.cpp:
--------------------------------------------------------------------------------
1 | //- ------------------------------------------------------------------
2 | //- Copyright (c) James W. Grenning -- All Rights Reserved
3 | //- For use by owners of Test-Driven Development for Embedded C,
4 | //- and attendees of Renaissance Software Consulting, Co. training
5 | //- classes.
6 | //-
7 | //- Available at http://pragprog.com/titles/jgade/
8 | //- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3
9 | //-
10 | //- Authorized users may use this source code in your own
11 | //- projects, however the source code may not be used to
12 | //- create training material, courses, books, articles, and
13 | //- the like. We make no guarantees that this source code is
14 | //- fit for any purpose.
15 | //-
16 | //- www.renaissancesoftware.net james@renaissancesoftware.net
17 | //- ------------------------------------------------------------------
18 |
19 |
20 | extern "C"
21 | {
22 | #include "AcmeWirelessLightDriver.h"
23 | }
24 |
25 | #include "CppUTest/TestHarness.h"
26 |
27 | TEST_GROUP(AcmeWirelessLightDriver)
28 | {
29 | LightDriver driver;
30 |
31 | void setup()
32 | {
33 | driver = AcmeWirelessLightDriver_Create(1, "SSID", "decafc0ffee11decafc0ffee22", 3);
34 | }
35 |
36 | void teardown()
37 | {
38 | AcmeWirelessLightDriver_Destroy((LightDriver)driver);
39 | }
40 | };
41 |
42 | TEST(AcmeWirelessLightDriver, Create)
43 | {
44 | LONGS_EQUAL(AcmeWireless, driver->type);
45 | LONGS_EQUAL(1, driver->id);
46 | }
47 |
48 |
49 |
--------------------------------------------------------------------------------
/code-t1/tests/devices/MemMappedLightDriverTest.cpp:
--------------------------------------------------------------------------------
1 | //- ------------------------------------------------------------------
2 | //- Copyright (c) James W. Grenning -- All Rights Reserved
3 | //- For use by owners of Test-Driven Development for Embedded C,
4 | //- and attendees of Renaissance Software Consulting, Co. training
5 | //- classes.
6 | //-
7 | //- Available at http://pragprog.com/titles/jgade/
8 | //- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3
9 | //-
10 | //- Authorized users may use this source code in your own
11 | //- projects, however the source code may not be used to
12 | //- create training material, courses, books, articles, and
13 | //- the like. We make no guarantees that this source code is
14 | //- fit for any purpose.
15 | //-
16 | //- www.renaissancesoftware.net james@renaissancesoftware.net
17 | //- ------------------------------------------------------------------
18 |
19 |
20 | extern "C"
21 | {
22 | #include "MemMappedLightDriver.h"
23 | }
24 |
25 | #include "CppUTest/TestHarness.h"
26 |
27 |
28 |
29 | TEST_GROUP(MemMappedLightDriver)
30 | {
31 | LightDriver driver;
32 | uint32_t mockLights;
33 |
34 | void setup()
35 | {
36 | driver = MemMappedLightDriver_Create(4, &mockLights);
37 | }
38 |
39 | void teardown()
40 | {
41 | MemMappedLightDriver_Destroy( (LightDriver)driver);
42 | }
43 | };
44 |
45 | TEST(MemMappedLightDriver, Create)
46 | {
47 | LONGS_EQUAL(MemoryMapped, driver->type);
48 | LONGS_EQUAL(4, driver->id);
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/code-t1/tests/devices/X10LightDriverTest.cpp:
--------------------------------------------------------------------------------
1 | //- ------------------------------------------------------------------
2 | //- Copyright (c) James W. Grenning -- All Rights Reserved
3 | //- For use by owners of Test-Driven Development for Embedded C,
4 | //- and attendees of Renaissance Software Consulting, Co. training
5 | //- classes.
6 | //-
7 | //- Available at http://pragprog.com/titles/jgade/
8 | //- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3
9 | //-
10 | //- Authorized users may use this source code in your own
11 | //- projects, however the source code may not be used to
12 | //- create training material, courses, books, articles, and
13 | //- the like. We make no guarantees that this source code is
14 | //- fit for any purpose.
15 | //-
16 | //- www.renaissancesoftware.net james@renaissancesoftware.net
17 | //- ------------------------------------------------------------------
18 |
19 |
20 | extern "C"
21 | {
22 | #include "X10LightDriver.h"
23 | }
24 |
25 | #include "CppUTest/TestHarness.h"
26 |
27 | TEST_GROUP(X10LightDriver)
28 | {
29 | LightDriver driver;
30 |
31 | void setup()
32 | {
33 | driver = X10LightDriver_Create(1, X10_A, 12);
34 | }
35 |
36 | void teardown()
37 | {
38 | X10LightDriver_Destroy(driver);
39 | }
40 | };
41 |
42 | TEST(X10LightDriver, Create)
43 | {
44 | LONGS_EQUAL(X10, driver->type);
45 | LONGS_EQUAL(1, driver->id);
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/code-t2/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | code-t2
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
15 | full,incremental,
16 |
17 |
18 |
19 |
20 |
21 | org.eclipse.cdt.core.cnature
22 | org.eclipse.cdt.core.ccnature
23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
25 |
26 |
27 |
--------------------------------------------------------------------------------
/code-t2/Makefile:
--------------------------------------------------------------------------------
1 | #Set this to @ to keep the makefile quiet
2 | SILENCE = @
3 |
4 | #---- Outputs ----#
5 | COMPONENT_NAME = t2
6 | TARGET_LIB = \
7 | lib/lib$(COMPONENT_NAME).a
8 |
9 | TEST_TARGET = \
10 | $(COMPONENT_NAME)_tests
11 |
12 | #--- Inputs ----#
13 | PROJECT_HOME_DIR = .
14 | CPP_PLATFORM = Gcc
15 |
16 | SRC_DIRS = \
17 | src/*\
18 |
19 | TEST_SRC_DIRS = \
20 | tests \
21 | tests/util \
22 | tests/devices \
23 | tests/HomeAutomation\
24 | mocks
25 |
26 | INCLUDE_DIRS =\
27 | $(CPPUTEST_HOME)/include/\
28 | include/HomeAutomation\
29 | include/util\
30 | mocks\
31 | include/devices\
32 | include/MyOS\
33 |
34 | LD_LIBRARIES += -lpthread
35 |
36 | include ../CppUTestCompileFlags.mk
37 | include $(CPPUTEST_HOME)/build/MakefileWorker.mk
38 |
--------------------------------------------------------------------------------
/code-t2/include/HomeAutomation/RandomMinute.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #ifndef D_RandomMinute_H
28 | #define D_RandomMinute_H
29 |
30 | void RandomMinute_Create(int bound);
31 | extern int (*RandomMinute_Get)(void);
32 |
33 | #endif /* D_RandomMinute_H */
34 |
--------------------------------------------------------------------------------
/code-t2/mocks/FakeRandomMinute.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #ifndef D_FakeRandomMinute_H
28 | #define D_FakeRandomMinute_H
29 |
30 | #include "RandomMinute.h"
31 |
32 | void FakeRandomMinute_SetFirstAndIncrement(int seed, int increment);
33 | int FakeRandomMinute_Get(void);
34 | void FakeRandomMinute_Reset(void);
35 |
36 | #endif /* D_FakeRandomMinute_H */
37 |
--------------------------------------------------------------------------------
/code-t2/mocks/FakeTimeService.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 |
28 | #ifndef D_FakeTimeService_H
29 | #define D_FakeTimeService_H
30 |
31 | #include "TimeService.h"
32 |
33 | void FakeTimeService_SetMinute(int);
34 | void FakeTimeService_SetDay(int);
35 |
36 | enum {MINUTE_UNKNOWN = -1, DAY_UNKNOWN = -1 };
37 |
38 | #endif /* D_FakeTimeService_H */
39 |
--------------------------------------------------------------------------------
/code-t2/mocks/FakeTimeServiceTest.cpp:
--------------------------------------------------------------------------------
1 | //- ------------------------------------------------------------------
2 | //- Copyright (c) James W. Grenning -- All Rights Reserved
3 | //- For use by owners of Test-Driven Development for Embedded C,
4 | //- and attendees of Renaissance Software Consulting, Co. training
5 | //- classes.
6 | //-
7 | //- Available at http://pragprog.com/titles/jgade/
8 | //- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3
9 | //-
10 | //- Authorized users may use this source code in your own
11 | //- projects, however the source code may not be used to
12 | //- create training material, courses, books, articles, and
13 | //- the like. We make no guarantees that this source code is
14 | //- fit for any purpose.
15 | //-
16 | //- www.renaissancesoftware.net james@renaissancesoftware.net
17 | //- ------------------------------------------------------------------
18 |
19 |
20 | #include "CppUTest/TestHarness.h"
21 |
22 | extern "C"
23 | {
24 | #include "TimeService.h"
25 | #include "FakeTimeService.h"
26 | }
27 |
28 | TEST_GROUP(TimeService)
29 | {
30 | void setup()
31 | {
32 | TimeService_Create();
33 | }
34 |
35 | void teardown()
36 | {
37 | TimeService_Destroy();
38 | }
39 | };
40 |
41 | TEST(TimeService, Create)
42 | {
43 | LONGS_EQUAL(MINUTE_UNKNOWN, TimeService_GetMinute());
44 | LONGS_EQUAL(DAY_UNKNOWN, TimeService_GetDay());
45 | }
46 |
47 | TEST(TimeService, Set)
48 | {
49 | FakeTimeService_SetMinute(42);
50 | LONGS_EQUAL(42, TimeService_GetMinute());
51 | FakeTimeService_SetDay(3);
52 | LONGS_EQUAL(3, TimeService_GetDay());
53 | }
54 |
--------------------------------------------------------------------------------
/code-t2/src/util/common.c:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #include "common.h"
28 | #include
29 |
30 | void explodesInTestEnvironment(void * p)
31 | {
32 | assert(0 == "Explode - intercepted call that cannot be made in test environment");
33 | }
34 |
--------------------------------------------------------------------------------
/code-t2/t2.dsw:
--------------------------------------------------------------------------------
1 | Microsoft Developer Studio Workspace File, Format Version 6.00
2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3 |
4 | ###############################################################################
5 |
6 | Project: "AllTests_CppUTest"=.\tests\AllTests_CppUTest.dsp - Package Owner=<4>
7 |
8 | Package=<5>
9 | {{{
10 | }}}
11 |
12 | Package=<4>
13 | {{{
14 | Begin Project Dependency
15 | Project_Dep_Name ProductionCodeLib
16 | End Project Dependency
17 | }}}
18 |
19 | ###############################################################################
20 |
21 | Project: "ProductionCodeLib"=.\src\ProductionCodeLib.dsp - Package Owner=<4>
22 |
23 | Package=<5>
24 | {{{
25 | }}}
26 |
27 | Package=<4>
28 | {{{
29 | }}}
30 |
31 | ###############################################################################
32 |
33 | Global:
34 |
35 | Package=<5>
36 | {{{
37 | }}}
38 |
39 | Package=<3>
40 | {{{
41 | }}}
42 |
43 | ###############################################################################
44 |
45 |
--------------------------------------------------------------------------------
/code-t2/tests/AllTests.cpp:
--------------------------------------------------------------------------------
1 | //- ------------------------------------------------------------------
2 | //- Copyright (c) James W. Grenning -- All Rights Reserved
3 | //- For use by owners of Test-Driven Development for Embedded C,
4 | //- and attendees of Renaissance Software Consulting, Co. training
5 | //- classes.
6 | //-
7 | //- Available at http://pragprog.com/titles/jgade/
8 | //- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3
9 | //-
10 | //- Authorized users may use this source code in your own
11 | //- projects, however the source code may not be used to
12 | //- create training material, courses, books, articles, and
13 | //- the like. We make no guarantees that this source code is
14 | //- fit for any purpose.
15 | //-
16 | //- www.renaissancesoftware.net james@renaissancesoftware.net
17 | //- ------------------------------------------------------------------
18 |
19 | //START: main
20 | #include "CppUTest/CommandLineTestRunner.h"
21 |
22 | int main(int argc, char** argv)
23 | {
24 | return RUN_ALL_TESTS(argc, argv);
25 | }
26 | //END: main
27 |
28 |
--------------------------------------------------------------------------------
/code-t2/tests/devices/AcmeWirelessLightDriverTest.cpp:
--------------------------------------------------------------------------------
1 | //- ------------------------------------------------------------------
2 | //- Copyright (c) James W. Grenning -- All Rights Reserved
3 | //- For use by owners of Test-Driven Development for Embedded C,
4 | //- and attendees of Renaissance Software Consulting, Co. training
5 | //- classes.
6 | //-
7 | //- Available at http://pragprog.com/titles/jgade/
8 | //- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3
9 | //-
10 | //- Authorized users may use this source code in your own
11 | //- projects, however the source code may not be used to
12 | //- create training material, courses, books, articles, and
13 | //- the like. We make no guarantees that this source code is
14 | //- fit for any purpose.
15 | //-
16 | //- www.renaissancesoftware.net james@renaissancesoftware.net
17 | //- ------------------------------------------------------------------
18 |
19 | extern "C"
20 | {
21 | #include "AcmeWirelessLightDriver.h"
22 | }
23 |
24 | #include "CppUTest/TestHarness.h"
25 |
26 | TEST_GROUP(AcmeWirelessLightDriver)
27 | {
28 | LightDriver lightDriver;
29 |
30 | void setup()
31 | {
32 | lightDriver = AcmeWirelessLightDriver_Create(5, "SSID", "decafc0ffee11decafc0ffee22", 3);
33 | AcmeWirelessLightDriver_InstallInterface();
34 | }
35 |
36 | void teardown()
37 | {
38 | LightDriver_Destroy(lightDriver);
39 | }
40 | };
41 |
42 | TEST(AcmeWirelessLightDriver, Create)
43 | {
44 | STRCMP_EQUAL("Acme wireless", LightDriver_GetType(lightDriver));
45 | LONGS_EQUAL(5, LightDriver_GetId(lightDriver));
46 | }
47 |
--------------------------------------------------------------------------------
/code-t2/tests/devices/MemMappedLightDriverTest.cpp:
--------------------------------------------------------------------------------
1 | //- ------------------------------------------------------------------
2 | //- Copyright (c) James W. Grenning -- All Rights Reserved
3 | //- For use by owners of Test-Driven Development for Embedded C,
4 | //- and attendees of Renaissance Software Consulting, Co. training
5 | //- classes.
6 | //-
7 | //- Available at http://pragprog.com/titles/jgade/
8 | //- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3
9 | //-
10 | //- Authorized users may use this source code in your own
11 | //- projects, however the source code may not be used to
12 | //- create training material, courses, books, articles, and
13 | //- the like. We make no guarantees that this source code is
14 | //- fit for any purpose.
15 | //-
16 | //- www.renaissancesoftware.net james@renaissancesoftware.net
17 | //- ------------------------------------------------------------------
18 |
19 | extern "C"
20 | {
21 | #include "MemMappedLightDriver.h"
22 | }
23 |
24 | #include "CppUTest/TestHarness.h"
25 |
26 | TEST_GROUP(MemMappedLightDriver)
27 | {
28 | LightDriver lightDriver;
29 | uint32_t mockLights;
30 |
31 | void setup()
32 | {
33 | lightDriver = MemMappedLightDriver_Create(4, &mockLights);
34 | MemMappedLightDriver_InstallInterface();
35 | }
36 |
37 | void teardown()
38 | {
39 | LightDriver_Destroy(lightDriver);
40 | }
41 | };
42 |
43 | TEST(MemMappedLightDriver, Create)
44 | {
45 | LONGS_EQUAL(4, LightDriver_GetId(lightDriver));
46 | STRCMP_EQUAL("Memory mapped", LightDriver_GetType(lightDriver));
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/code-t2/tests/devices/X10LightDriverTest.cpp:
--------------------------------------------------------------------------------
1 | //- ------------------------------------------------------------------
2 | //- Copyright (c) James W. Grenning -- All Rights Reserved
3 | //- For use by owners of Test-Driven Development for Embedded C,
4 | //- and attendees of Renaissance Software Consulting, Co. training
5 | //- classes.
6 | //-
7 | //- Available at http://pragprog.com/titles/jgade/
8 | //- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3
9 | //-
10 | //- Authorized users may use this source code in your own
11 | //- projects, however the source code may not be used to
12 | //- create training material, courses, books, articles, and
13 | //- the like. We make no guarantees that this source code is
14 | //- fit for any purpose.
15 | //-
16 | //- www.renaissancesoftware.net james@renaissancesoftware.net
17 | //- ------------------------------------------------------------------
18 |
19 | extern "C"
20 | {
21 | #include "X10LightDriver.h"
22 | }
23 |
24 | #include "CppUTest/TestHarness.h"
25 |
26 | TEST_GROUP(X10LightDriver)
27 | {
28 | X10LightDriver x10LightDriver;
29 | LightDriver lightDriver;
30 |
31 | void setup()
32 | {
33 | lightDriver = X10LightDriver_Create(3, X10_A, 12);
34 | X10LightDriver_InstallInterface();
35 | }
36 |
37 | void teardown()
38 | {
39 | LightDriver_Destroy(lightDriver);
40 | }
41 | };
42 |
43 | TEST(X10LightDriver, Create)
44 | {
45 | LONGS_EQUAL(3, LightDriver_GetId(lightDriver));
46 | STRCMP_EQUAL("X10", LightDriver_GetType(lightDriver));
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/code-t3/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | code-t3
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
15 | full,incremental,
16 |
17 |
18 |
19 |
20 |
21 | org.eclipse.cdt.core.cnature
22 | org.eclipse.cdt.core.ccnature
23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
25 |
26 |
27 |
--------------------------------------------------------------------------------
/code-t3/Makefile:
--------------------------------------------------------------------------------
1 | #Set this to @ to keep the makefile quiet
2 | SILENCE = @
3 |
4 | #---- Outputs ----#
5 | COMPONENT_NAME = t3
6 | TARGET_LIB = \
7 | lib/lib$(COMPONENT_NAME).a
8 |
9 | TEST_TARGET = \
10 | $(COMPONENT_NAME)_tests
11 |
12 | #--- Inputs ----#
13 | PROJECT_HOME_DIR = .
14 | CPP_PLATFORM = Gcc
15 |
16 | SRC_DIRS = \
17 | src/*\
18 |
19 | TEST_SRC_DIRS = \
20 | tests \
21 | tests/util \
22 | tests/devices \
23 | tests/HomeAutomation\
24 | mocks
25 |
26 | INCLUDE_DIRS =\
27 | $(CPPUTEST_HOME)/include/\
28 | include/*\
29 | mocks
30 |
31 | CPPUTEST_USE_EXTENSIONS = Y
32 | include ../CppUTestCompileFlags.mk
33 | include $(CPPUTEST_HOME)/build/MakefileWorker.mk
34 |
--------------------------------------------------------------------------------
/code-t3/include/HomeAutomation/RandomMinute.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #ifndef D_RandomMinute_H
28 | #define D_RandomMinute_H
29 |
30 | void RandomMinute_Create(int bound);
31 | extern int (*RandomMinute_Get)(void);
32 |
33 | #endif /* D_RandomMinute_H */
34 |
--------------------------------------------------------------------------------
/code-t3/mocks/CountingLightDriver.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 |
28 | #ifndef D_CountingLightDriver_H
29 | #define D_CountingLightDriver_H
30 |
31 | #include "LightDriver.h"
32 |
33 | LightDriver CountingLightDriver_Create(int id);
34 |
35 | /* Functions just needed by tests */
36 | int CountingLightDriver_GetCallCount(LightDriver);
37 |
38 | #endif /* D_CountingLightDriver_H */
39 |
--------------------------------------------------------------------------------
/code-t3/mocks/FakeRandomMinute.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #ifndef D_FakeRandomMinute_H
28 | #define D_FakeRandomMinute_H
29 |
30 | #include "RandomMinute.h"
31 |
32 | void FakeRandomMinute_SetFirstAndIncrement(int seed, int increment);
33 | int FakeRandomMinute_Get(void);
34 | void FakeRandomMinute_Reset(void);
35 |
36 | #endif /* D_FakeRandomMinute_H */
37 |
--------------------------------------------------------------------------------
/code-t3/mocks/FakeTimeService.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 |
28 | #ifndef D_FakeTimeService_H
29 | #define D_FakeTimeService_H
30 |
31 | #include "TimeService.h"
32 |
33 | void FakeTimeService_SetMinute(int);
34 | void FakeTimeService_SetDay(int);
35 |
36 | enum {MINUTE_UNKNOWN = -1, DAY_UNKNOWN = -1 };
37 |
38 | #endif /* D_FakeTimeService_H */
39 |
--------------------------------------------------------------------------------
/code-t3/mocks/FakeTimeServiceTest.cpp:
--------------------------------------------------------------------------------
1 | //- ------------------------------------------------------------------
2 | //- Copyright (c) James W. Grenning -- All Rights Reserved
3 | //- For use by owners of Test-Driven Development for Embedded C,
4 | //- and attendees of Renaissance Software Consulting, Co. training
5 | //- classes.
6 | //-
7 | //- Available at http://pragprog.com/titles/jgade/
8 | //- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3
9 | //-
10 | //- Authorized users may use this source code in your own
11 | //- projects, however the source code may not be used to
12 | //- create training material, courses, books, articles, and
13 | //- the like. We make no guarantees that this source code is
14 | //- fit for any purpose.
15 | //-
16 | //- www.renaissancesoftware.net james@renaissancesoftware.net
17 | //- ------------------------------------------------------------------
18 |
19 |
20 | #include "CppUTest/TestHarness.h"
21 |
22 | extern "C"
23 | {
24 | #include "TimeService.h"
25 | #include "FakeTimeService.h"
26 | }
27 |
28 | TEST_GROUP(TimeService)
29 | {
30 | void setup()
31 | {
32 | TimeService_Create();
33 | }
34 |
35 | void teardown()
36 | {
37 | TimeService_Destroy();
38 | }
39 | };
40 |
41 | TEST(TimeService, Create)
42 | {
43 | LONGS_EQUAL(MINUTE_UNKNOWN, TimeService_GetMinute());
44 | LONGS_EQUAL(DAY_UNKNOWN, TimeService_GetDay());
45 | }
46 |
47 | TEST(TimeService, Set)
48 | {
49 | FakeTimeService_SetMinute(42);
50 | LONGS_EQUAL(42, TimeService_GetMinute());
51 | FakeTimeService_SetDay(3);
52 | LONGS_EQUAL(3, TimeService_GetDay());
53 | }
54 |
--------------------------------------------------------------------------------
/code-t3/src/util/common.c:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #include "common.h"
28 | #include
29 |
30 | void explodesInTestEnvironment(void * p)
31 | {
32 | assert(0 == "Explode - intercepted call that cannot be made in test environment");
33 | }
34 |
--------------------------------------------------------------------------------
/code-t3/t3.dsw:
--------------------------------------------------------------------------------
1 | Microsoft Developer Studio Workspace File, Format Version 6.00
2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3 |
4 | ###############################################################################
5 |
6 | Project: "AllTests_CppUTest"=.\tests\AllTests_CppUTest.dsp - Package Owner=<4>
7 |
8 | Package=<5>
9 | {{{
10 | }}}
11 |
12 | Package=<4>
13 | {{{
14 | Begin Project Dependency
15 | Project_Dep_Name ProductionCodeLib
16 | End Project Dependency
17 | }}}
18 |
19 | ###############################################################################
20 |
21 | Project: "ProductionCodeLib"=.\src\ProductionCodeLib.dsp - Package Owner=<4>
22 |
23 | Package=<5>
24 | {{{
25 | }}}
26 |
27 | Package=<4>
28 | {{{
29 | }}}
30 |
31 | ###############################################################################
32 |
33 | Global:
34 |
35 | Package=<5>
36 | {{{
37 | }}}
38 |
39 | Package=<3>
40 | {{{
41 | }}}
42 |
43 | ###############################################################################
44 |
45 |
--------------------------------------------------------------------------------
/code-t3/tests/AllTests.cpp:
--------------------------------------------------------------------------------
1 | //- ------------------------------------------------------------------
2 | //- Copyright (c) James W. Grenning -- All Rights Reserved
3 | //- For use by owners of Test-Driven Development for Embedded C,
4 | //- and attendees of Renaissance Software Consulting, Co. training
5 | //- classes.
6 | //-
7 | //- Available at http://pragprog.com/titles/jgade/
8 | //- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3
9 | //-
10 | //- Authorized users may use this source code in your own
11 | //- projects, however the source code may not be used to
12 | //- create training material, courses, books, articles, and
13 | //- the like. We make no guarantees that this source code is
14 | //- fit for any purpose.
15 | //-
16 | //- www.renaissancesoftware.net james@renaissancesoftware.net
17 | //- ------------------------------------------------------------------
18 |
19 | //START: main
20 | #include "CppUTest/CommandLineTestRunner.h"
21 |
22 | int main(int argc, const char** argv)
23 | {
24 | return RUN_ALL_TESTS(argc, argv);
25 | }
26 | //END: main
27 |
28 |
--------------------------------------------------------------------------------
/code-t3/tests/devices/AcmeWirelessLightDriverTest.cpp:
--------------------------------------------------------------------------------
1 | //- ------------------------------------------------------------------
2 | //- Copyright (c) James W. Grenning -- All Rights Reserved
3 | //- For use by owners of Test-Driven Development for Embedded C,
4 | //- and attendees of Renaissance Software Consulting, Co. training
5 | //- classes.
6 | //-
7 | //- Available at http://pragprog.com/titles/jgade/
8 | //- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3
9 | //-
10 | //- Authorized users may use this source code in your own
11 | //- projects, however the source code may not be used to
12 | //- create training material, courses, books, articles, and
13 | //- the like. We make no guarantees that this source code is
14 | //- fit for any purpose.
15 | //-
16 | //- www.renaissancesoftware.net james@renaissancesoftware.net
17 | //- ------------------------------------------------------------------
18 |
19 | extern "C"
20 | {
21 | #include "AcmeWirelessLightDriver.h"
22 | }
23 |
24 | #include "CppUTest/TestHarness.h"
25 |
26 | TEST_GROUP(AcmeWirelessLightDriver)
27 | {
28 | LightDriver lightDriver;
29 |
30 | void setup()
31 | {
32 | lightDriver = AcmeWirelessLightDriver_Create(5, "SSID", "decafc0ffee11decafc0ffee22", 3);
33 | }
34 |
35 | void teardown()
36 | {
37 | LightDriver_Destroy(lightDriver);
38 | }
39 | };
40 |
41 | TEST(AcmeWirelessLightDriver, Create)
42 | {
43 | STRCMP_EQUAL("Acme wireless", LightDriver_GetType(lightDriver));
44 | LONGS_EQUAL(5, LightDriver_GetId(lightDriver));
45 | }
46 |
--------------------------------------------------------------------------------
/code-t3/tests/devices/MemMappedLightDriverTest.cpp:
--------------------------------------------------------------------------------
1 | //- ------------------------------------------------------------------
2 | //- Copyright (c) James W. Grenning -- All Rights Reserved
3 | //- For use by owners of Test-Driven Development for Embedded C,
4 | //- and attendees of Renaissance Software Consulting, Co. training
5 | //- classes.
6 | //-
7 | //- Available at http://pragprog.com/titles/jgade/
8 | //- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3
9 | //-
10 | //- Authorized users may use this source code in your own
11 | //- projects, however the source code may not be used to
12 | //- create training material, courses, books, articles, and
13 | //- the like. We make no guarantees that this source code is
14 | //- fit for any purpose.
15 | //-
16 | //- www.renaissancesoftware.net james@renaissancesoftware.net
17 | //- ------------------------------------------------------------------
18 |
19 | extern "C"
20 | {
21 | #include "MemMappedLightDriver.h"
22 | }
23 |
24 | #include "CppUTest/TestHarness.h"
25 |
26 | TEST_GROUP(MemMappedLightDriver)
27 | {
28 | LightDriver lightDriver;
29 | uint32_t mockLights;
30 |
31 | void setup()
32 | {
33 | lightDriver = MemMappedLightDriver_Create(4, &mockLights);
34 | }
35 |
36 | void teardown()
37 | {
38 | LightDriver_Destroy(lightDriver);
39 | }
40 | };
41 |
42 | TEST(MemMappedLightDriver, Create)
43 | {
44 | LONGS_EQUAL(4, LightDriver_GetId(lightDriver));
45 | STRCMP_EQUAL("Memory mapped", LightDriver_GetType(lightDriver));
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/code-t3/tests/devices/X10LightDriverTest.cpp:
--------------------------------------------------------------------------------
1 | //- ------------------------------------------------------------------
2 | //- Copyright (c) James W. Grenning -- All Rights Reserved
3 | //- For use by owners of Test-Driven Development for Embedded C,
4 | //- and attendees of Renaissance Software Consulting, Co. training
5 | //- classes.
6 | //-
7 | //- Available at http://pragprog.com/titles/jgade/
8 | //- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3
9 | //-
10 | //- Authorized users may use this source code in your own
11 | //- projects, however the source code may not be used to
12 | //- create training material, courses, books, articles, and
13 | //- the like. We make no guarantees that this source code is
14 | //- fit for any purpose.
15 | //-
16 | //- www.renaissancesoftware.net james@renaissancesoftware.net
17 | //- ------------------------------------------------------------------
18 |
19 | extern "C"
20 | {
21 | #include "X10LightDriver.h"
22 | }
23 |
24 | #include "CppUTest/TestHarness.h"
25 |
26 | TEST_GROUP(X10LightDriver)
27 | {
28 | X10LightDriver x10LightDriver;
29 | LightDriver lightDriver;
30 |
31 | void setup()
32 | {
33 | lightDriver = X10LightDriver_Create(3, X10_A, 12);
34 | }
35 |
36 | void teardown()
37 | {
38 | LightDriver_Destroy(lightDriver);
39 | }
40 | };
41 |
42 | TEST(X10LightDriver, Create)
43 | {
44 | LONGS_EQUAL(3, LightDriver_GetId(lightDriver));
45 | STRCMP_EQUAL("X10", LightDriver_GetType(lightDriver));
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/code/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | code
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
15 | full,incremental,
16 |
17 |
18 |
19 |
20 |
21 | org.eclipse.cdt.core.cnature
22 | org.eclipse.cdt.core.ccnature
23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
25 |
26 |
27 |
--------------------------------------------------------------------------------
/code/BookCode.dsw:
--------------------------------------------------------------------------------
1 | Microsoft Developer Studio Workspace File, Format Version 6.00
2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3 |
4 | ###############################################################################
5 |
6 | Project: "AllTests_CppUTest"=.\tests\AllTests_CppUTest.dsp - Package Owner=<4>
7 |
8 | Package=<5>
9 | {{{
10 | }}}
11 |
12 | Package=<4>
13 | {{{
14 | Begin Project Dependency
15 | Project_Dep_Name ProductionCodeLib
16 | End Project Dependency
17 | }}}
18 |
19 | ###############################################################################
20 |
21 | Project: "ProductionCodeLib"=.\src\ProductionCodeLib.dsp - Package Owner=<4>
22 |
23 | Package=<5>
24 | {{{
25 | }}}
26 |
27 | Package=<4>
28 | {{{
29 | }}}
30 |
31 | ###############################################################################
32 |
33 | Global:
34 |
35 | Package=<5>
36 | {{{
37 | }}}
38 |
39 | Package=<3>
40 | {{{
41 | }}}
42 |
43 | ###############################################################################
44 |
45 |
--------------------------------------------------------------------------------
/code/Makefile:
--------------------------------------------------------------------------------
1 | all:
2 | make -f MakefileCppUTest.mk
3 | make -f MakefileUnity.mk
4 |
5 | clean:
6 | make -f MakefileCppUTest.mk clean
7 | make -f MakefileUnity.mk clean
8 |
--------------------------------------------------------------------------------
/code/MakefileCppUTest.mk:
--------------------------------------------------------------------------------
1 | #This makefile makes all the main book code with CppUTest test harness
2 |
3 | #Set this to @ to keep the makefile quiet
4 | SILENCE = @
5 |
6 | #---- Outputs ----#
7 | COMPONENT_NAME = BookCode_CppUTest
8 |
9 | #--- Inputs ----#
10 | #CPPUTEST_HOME = CppUTest
11 | CPP_PLATFORM = Gcc
12 | PROJECT_HOME_DIR = .
13 |
14 | SRC_DIRS = \
15 | src/HomeAutomation \
16 | src/util\
17 | src/LedDriver \
18 | src/dvr\
19 | src/IO \
20 | src/MyOS \
21 | src/MyOS/posix \
22 | src/zune \
23 |
24 | TEST_SRC_DIRS = \
25 | .\
26 | mocks\
27 | mocks\
28 | tests/LedDriver\
29 | tests/stdio\
30 | tests/util\
31 | tests/IO\
32 | tests/zune\
33 | tests/HomeAutomation\
34 | tests/dvr\
35 | tests\
36 | tests/MyOS\
37 |
38 |
39 | INCLUDE_DIRS =\
40 | .\
41 | $(CPPUTEST_HOME)/include\
42 | include/IO\
43 | mocks\
44 | include/util\
45 | include/HomeAutomation\
46 | include/LedDriver\
47 | include/MyOS\
48 | include/dvr\
49 | include/zune\
50 |
51 | MOCKS_SRC_DIRS = \
52 | mocks\
53 |
54 | include ../CppUTestCompileFlags.mk
55 |
56 | LD_LIBRARIES = -lpthread
57 |
58 |
59 | include $(CPPUTEST_HOME)/build/MakefileWorker.mk
60 |
61 |
--------------------------------------------------------------------------------
/code/MakefileUnity.mk:
--------------------------------------------------------------------------------
1 | #This makefile makes the examples from the first few chapters with Unity test harness
2 |
3 | #Set this to @ to keep the makefile quiet
4 | SILENCE = @
5 |
6 | #---- Outputs ----#
7 | COMPONENT_NAME = BookCode_Unity
8 |
9 | #--- Inputs ----#
10 | UNITY_HOME = unity.framework
11 | CPP_PLATFORM = Gcc
12 | PROJECT_HOME_DIR = .
13 | PROJECT_TEST_DIR = unity
14 | CPP_PLATFORM = Gcc
15 | UNITY_BUILD_HOME = unity.framework/extras/fixture/build
16 |
17 | UNITY_CFLAGS += -Wno-missing-prototypes
18 | UNITY_CFLAGS += -DUNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar
19 | UNITY_WARNINGFLAGS = -Wall
20 | UNITY_WARNINGFLAGS = -Werror
21 | UNITY_WARNINGFLAGS = -Wswitch-default
22 | #UNITY_WARNINGFLAGS += -Wshadow
23 |
24 | SRC_DIRS = \
25 | $(PROJECT_HOME_DIR)/src/LedDriver \
26 | $(PROJECT_HOME_DIR)/src/HomeAutomation \
27 |
28 | TEST_SRC_DIRS = \
29 | $(PROJECT_TEST_DIR)\
30 | $(PROJECT_TEST_DIR)/HomeAutomation\
31 | $(PROJECT_TEST_DIR)/LedDriver\
32 | $(PROJECT_TEST_DIR)/stdio\
33 | $(UNITY_HOME)/unity\
34 | $(UNITY_HOME)/src\
35 | $(UNITY_HOME)/extras/fixture/src\
36 | $(UNITY_HOME)/extras/fixture/test\
37 |
38 | MOCKS_SRC_DIRS = \
39 | $(PROJECT_TEST_DIR)/mocks\
40 |
41 | INCLUDE_DIRS =\
42 | .\
43 | $(UNITY_HOME)/src\
44 | $(UNITY_HOME)/extras/fixture/src\
45 | $(UNITY_HOME)/extras/fixture/test\
46 | $(PROJECT_HOME_DIR)/include/HomeAutomation\
47 | $(PROJECT_HOME_DIR)/include/LedDriver\
48 | $(PROJECT_HOME_DIR)/include/util\
49 | $(PROJECT_HOME_DIR)/mocks\
50 |
51 | include $(UNITY_BUILD_HOME)/MakefileWorker.mk
52 |
53 |
--------------------------------------------------------------------------------
/code/SandBox/Makefile:
--------------------------------------------------------------------------------
1 | all:
2 | make -i -f MakefileCppUTest.mk
3 | make -i -f MakefileUnity.mk
4 |
5 | clean:
6 | make -i -f MakefileCppUTest.mk clean
7 | make -i -f MakefileUnity.mk clean
8 |
9 |
--------------------------------------------------------------------------------
/code/SandBox/MakefileCppUTest.mk:
--------------------------------------------------------------------------------
1 | #Set this to @ to keep the makefile quiet
2 | SILENCE = @
3 |
4 | #---- Outputs ----#
5 | COMPONENT_NAME = SandBox_CppUTest
6 | TARGET_LIB = \
7 | lib/lib$(COMPONENT_NAME).a
8 |
9 | TEST_TARGET = \
10 | $(COMPONENT_NAME)_tests
11 |
12 | #--- Inputs ----#
13 | PROJECT_HOME_DIR = .
14 | CPPUTEST_HOME = ../CppUTest
15 | CPP_PLATFORM = Gcc
16 |
17 | SRC_DIRS = \
18 | $(PROJECT_HOME_DIR)/src/LedDriver \
19 |
20 | TEST_SRC_DIRS = \
21 | tests\
22 | tests/*\
23 |
24 | INCLUDE_DIRS =\
25 | .\
26 | $(CPPUTEST_HOME)/include\
27 | $(PROJECT_HOME_DIR)/include/LedDriver\
28 |
29 | #CPPUTEST_WARNINGFLAGS += -pedantic-errors -Wconversion -Wshadow -Wextra
30 | CPPUTEST_WARNINGFLAGS += -Wall -Werror -Wswitch-default -Wswitch-enum
31 |
32 |
33 | include $(CPPUTEST_HOME)/build/MakefileWorker.mk
34 |
--------------------------------------------------------------------------------
/code/SandBox/MakefileUnity.mk:
--------------------------------------------------------------------------------
1 | #Set this to @ to keep the makefile quiet
2 | SILENCE = @
3 |
4 | #---- Outputs ----#
5 | COMPONENT_NAME = SandBox_Unity
6 |
7 | #--- Inputs ----#
8 | PROJECT_HOME_DIR = .
9 | UNITY_HOME = ../unity.framework
10 | CPP_PLATFORM = Gcc
11 | UNITY_BUILD_HOME = ../unity.framework/extras/fixture/build
12 |
13 | UNITY_CFLAGS += -DUNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar
14 |
15 | SRC_DIRS = \
16 | $(PROJECT_HOME_DIR)/src/LedDriver \
17 |
18 | TEST_SRC_DIRS = \
19 | $(PROJECT_HOME_DIR)/unity\
20 | $(PROJECT_HOME_DIR)/unity/LedDriver\
21 | $(UNITY_HOME)/src\
22 | $(UNITY_HOME)/extras/fixture/src\
23 | $(UNITY_HOME)/extras/fixture/test\
24 |
25 | INCLUDE_DIRS =\
26 | .\
27 | $(UNITY_HOME)/src\
28 | $(UNITY_HOME)/src\
29 | $(UNITY_HOME)/extras/fixture/src\
30 | $(UNITY_HOME)/extras/fixture/test\
31 | $(PROJECT_HOME_DIR)/include/LedDriver\
32 |
33 | include $(UNITY_BUILD_HOME)/MakefileWorker.mk
34 |
--------------------------------------------------------------------------------
/code/SandBox/SandBox.dsw:
--------------------------------------------------------------------------------
1 | Microsoft Developer Studio Workspace File, Format Version 6.00
2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3 |
4 | ###############################################################################
5 |
6 | Project: "AllTests_CppUTest"=.\tests\AllTests_CppUTest.dsp - Package Owner=<4>
7 |
8 | Package=<5>
9 | {{{
10 | }}}
11 |
12 | Package=<4>
13 | {{{
14 | Begin Project Dependency
15 | Project_Dep_Name ProductionCodeLib
16 | End Project Dependency
17 | }}}
18 |
19 | ###############################################################################
20 |
21 | Project: "ProductionCodeLib"=.\src\ProductionCodeLib.dsp - Package Owner=<4>
22 |
23 | Package=<5>
24 | {{{
25 | }}}
26 |
27 | Package=<4>
28 | {{{
29 | }}}
30 |
31 | ###############################################################################
32 |
33 | Global:
34 |
35 | Package=<5>
36 | {{{
37 | }}}
38 |
39 | Package=<3>
40 | {{{
41 | }}}
42 |
43 | ###############################################################################
44 |
45 |
--------------------------------------------------------------------------------
/code/SandBox/include/LedDriver/LedDriver.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #ifndef D_LedDriver_H
28 | #define D_LedDriver_H
29 |
30 | void LedDriver_Create(void);
31 | void LedDriver_Destroy(void);
32 |
33 | #endif /* D_LedDriver_H */
34 |
--------------------------------------------------------------------------------
/code/SandBox/src/LedDriver/LedDriver.c:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #include "LedDriver.h"
28 | #include
29 | #include
30 |
31 | void LedDriver_Create(void)
32 | {
33 | }
34 |
35 | void LedDriver_Destroy(void)
36 | {
37 | }
38 |
39 |
40 |
--------------------------------------------------------------------------------
/code/SandBox/tests/AllTests.cpp:
--------------------------------------------------------------------------------
1 | //- ------------------------------------------------------------------
2 | //- Copyright (c) James W. Grenning -- All Rights Reserved
3 | //- For use by owners of Test-Driven Development for Embedded C,
4 | //- and attendees of Renaissance Software Consulting, Co. training
5 | //- classes.
6 | //-
7 | //- Available at http://pragprog.com/titles/jgade/
8 | //- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3
9 | //-
10 | //- Authorized users may use this source code in your own
11 | //- projects, however the source code may not be used to
12 | //- create training material, courses, books, articles, and
13 | //- the like. We make no guarantees that this source code is
14 | //- fit for any purpose.
15 | //-
16 | //- www.renaissancesoftware.net james@renaissancesoftware.net
17 | //- ------------------------------------------------------------------
18 |
19 | #include "CppUTest/CommandLineTestRunner.h"
20 |
21 | int main(int ac, char** av)
22 | {
23 | int result = RUN_ALL_TESTS(ac, av);
24 |
25 | return result;
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/code/SandBox/tests/LedDriver/LedDriverTest.cpp:
--------------------------------------------------------------------------------
1 | //- ------------------------------------------------------------------
2 | //- Copyright (c) James W. Grenning -- All Rights Reserved
3 | //- For use by owners of Test-Driven Development for Embedded C,
4 | //- and attendees of Renaissance Software Consulting, Co. training
5 | //- classes.
6 | //-
7 | //- Available at http://pragprog.com/titles/jgade/
8 | //- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3
9 | //-
10 | //- Authorized users may use this source code in your own
11 | //- projects, however the source code may not be used to
12 | //- create training material, courses, books, articles, and
13 | //- the like. We make no guarantees that this source code is
14 | //- fit for any purpose.
15 | //-
16 | //- www.renaissancesoftware.net james@renaissancesoftware.net
17 | //- ------------------------------------------------------------------
18 |
19 | extern "C"
20 | {
21 | #include "LedDriver.h"
22 | }
23 |
24 | #include "CppUTest/TestHarness.h"
25 |
26 | TEST_GROUP(LedDriver)
27 | {
28 | void setup()
29 | {
30 | LedDriver_Create();
31 | }
32 |
33 | void teardown()
34 | {
35 | LedDriver_Destroy();
36 | }
37 | };
38 |
39 | TEST(LedDriver, Create)
40 | {
41 | // FAIL("Start here");
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/code/SandBox/unity/AllTests.c:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #include "unity_fixture.h"
28 |
29 | static void RunAllTests(void)
30 | {
31 | RUN_TEST_GROUP(LedDriver);
32 | }
33 |
34 | int main(int ac, char* av[])
35 | {
36 | return UnityMain(ac, av, RunAllTests);
37 | }
38 |
--------------------------------------------------------------------------------
/code/SandBox/unity/LedDriver/LedDriverTest.c:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #include "unity_fixture.h"
28 | #include "LedDriver.h"
29 |
30 | #include "unity_fixture.h"
31 |
32 | TEST_GROUP(LedDriver);
33 |
34 | TEST_SETUP(LedDriver)
35 | {
36 | }
37 |
38 | TEST_TEAR_DOWN(LedDriver)
39 | {
40 | }
41 |
42 | TEST(LedDriver, StartHere)
43 | {
44 | /* TEST_FAIL("Start here"); */
45 | }
46 |
--------------------------------------------------------------------------------
/code/SandBox/unity/LedDriver/LedDriverTestRunner.c:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #include "unity_fixture.h"
28 |
29 | TEST_GROUP_RUNNER(LedDriver)
30 | {
31 | RUN_TEST_CASE(LedDriver, StartHere);
32 | }
33 |
--------------------------------------------------------------------------------
/code/docs/STMicroelectronics/c2414FlashReadAndWrite.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | #ifndef D_c2414FlashReadAndWrite_H
10 | #define D_c2414FlashReadAndWrite_H
11 |
12 | #include "c2414.h"
13 |
14 | uCPUBusType FlashRead( udword udAddrOff );
15 | void FlashWrite( udword udAddrOff, uCPUBusType ucVal );
16 |
17 | #endif
18 |
19 | //Original code thanks to STMicroelectronics.
20 |
21 |
--------------------------------------------------------------------------------
/code/docs/STMicroelectronics/m28w160ect.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jwgrenning/tddec-code/46ec03e06ddd464ad628a3ffaf5aaa910b7c5926/code/docs/STMicroelectronics/m28w160ect.pdf
--------------------------------------------------------------------------------
/code/include/HomeAutomation/LightController.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 |
28 | #ifndef D_LightController_H
29 | #define D_LightController_H
30 |
31 | enum { MAX_LIGHTS = 32 };
32 |
33 | void LightController_Create(void);
34 | void LightController_Destroy(void);
35 | void LightController_On(int id);
36 | void LightController_Off(int id);
37 |
38 | #endif /* D_LightController_H */
39 |
--------------------------------------------------------------------------------
/code/include/IO/IO.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 |
28 |
29 | #ifndef D_IO_H
30 | #define D_IO_H
31 | #include
32 |
33 | typedef uint32_t ioAddress;
34 | typedef uint16_t ioData;
35 |
36 | ioData IO_Read(ioAddress offset);
37 | void IO_Write(ioAddress offset, ioData data);
38 |
39 | #endif
40 |
41 |
--------------------------------------------------------------------------------
/code/include/IO/MicroTime.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #ifndef D_MicroTime_H
28 | #define D_MicroTime_H
29 |
30 | #include
31 |
32 | uint32_t MicroTime_Get(void);
33 | void MicroTime_Delay(uint32_t);
34 |
35 | #endif /* D_MicroTime_H */
36 |
--------------------------------------------------------------------------------
/code/include/util/RuntimeError.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 |
28 | #ifndef D_RuntimeError_H
29 | #define D_RuntimeError_H
30 |
31 | void RuntimeError(const char * message, int parameter,
32 | const char * file, int line);
33 |
34 | #define RUNTIME_ERROR(description, parameter)\
35 | RuntimeError(description, parameter, __FILE__, __LINE__)
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/code/include/util/Utils.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 |
28 |
29 |
30 | #ifndef D_Utils_H
31 | #define D_Utils_H
32 | #if 0
33 | int FormatOutput(const char *, ...);
34 | #endif
35 |
36 | extern int (*FormatOutput)(const char *, ...);
37 |
38 | #endif /* D_Utils_H */
39 |
--------------------------------------------------------------------------------
/code/include/util/common.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 |
28 |
29 |
30 | #ifndef D_common_H
31 | #define D_common_H
32 |
33 | #ifndef BOOL
34 | #define BOOL int
35 | #endif
36 |
37 | #ifndef TRUE
38 | #define TRUE 1
39 | #endif
40 |
41 | #ifndef FALSE
42 | #define FALSE 0
43 | #endif
44 |
45 | #ifndef NULL
46 | #define NULL 0
47 | #endif
48 |
49 | #endif
50 |
--------------------------------------------------------------------------------
/code/mocks/FakeMicroTime.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #ifndef D_FakeMicroTime_H
28 | #define D_FakeMicroTime_H
29 |
30 | #include "MicroTime.h"
31 |
32 | void FakeMicroTime_Init(uint32_t start, uint32_t increment);
33 | uint32_t FakeMicroTime_GetDelayDuration();
34 |
35 | #endif /* D_FakeMicroTime_H */
36 |
--------------------------------------------------------------------------------
/code/mocks/FormatOutputSpy.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 |
28 | #ifndef D_FormatOutputSpy_H
29 | #define D_FormatOutputSpy_H
30 |
31 | #include "Utils.h"
32 |
33 | int FormatOutputSpy(const char * format, ...);
34 | void FormatOutputSpy_Create(int size);
35 | void FormatOutputSpy_Destroy(void);
36 | const char * FormatOutputSpy_GetOutput(void);
37 |
38 | #endif /* D_FormatOutput_H */
39 |
--------------------------------------------------------------------------------
/code/mocks/MockIO.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 |
28 | #ifndef D_MockIO_H
29 | #define D_MockIO_H
30 | #include "IO.h"
31 | void MockIO_Create(int maxExpectations);
32 | void MockIO_Destroy(void);
33 | void MockIO_Expect_Write(ioAddress offset, ioData data);
34 | void MockIO_Expect_ReadThenReturn(ioAddress offset, ioData returnData);
35 | void MockIO_Verify_Complete(void);
36 | #endif
37 |
--------------------------------------------------------------------------------
/code/mocks/RuntimeErrorStub.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #ifndef D_RuntimeErrorStub_H
28 | #define D_RuntimeErrorStub_H
29 |
30 | #include "RuntimeError.h"
31 |
32 | void RuntimeErrorStub_Reset(void);
33 | const char * RuntimeErrorStub_GetLastError(void);
34 | int RuntimeErrorStub_GetLastParameter(void);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/code/src/IO/IO.c:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #include "IO.h"
28 | void IO_Write(ioAddress addr, ioData data)
29 | {
30 | ioData * p = 0;
31 | *(p + addr) = data;
32 | }
33 | ioData IO_Read(ioAddress addr)
34 | {
35 | ioData * p = 0;
36 | return *(p + addr);
37 | }
38 |
--------------------------------------------------------------------------------
/code/src/util/Utils.c:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #include "Utils.h"
28 | #include
29 |
30 | #if 0
31 | static int FormatOutput_Impl(const char * format, ...)
32 | {
33 | /* snip */
34 | }
35 |
36 | int (*FormatOutput)(const char * format, ...) = FormatOutput_Impl;
37 | #endif
38 |
39 | int (*FormatOutput)(const char * format, ...) = printf;
40 |
--------------------------------------------------------------------------------
/code/tests/AllTests.cpp:
--------------------------------------------------------------------------------
1 | //- Copyright (c) 2008-2009 James Grenning --- All rights reserved
2 | //- For exclusive use by participants in Renaissance Software Consulting training courses.
3 | //- Cannot be used by attendees to train others without written permission.
4 | //- www.renaissancesoftware.net james@renaissancesoftware.net
5 |
6 | //START: main
7 | #include "CppUTest/CommandLineTestRunner.h"
8 |
9 | int main(int argc, const char** argv)
10 | {
11 | return RUN_ALL_TESTS(argc, argv);
12 | }
13 | //END: main
14 |
15 |
--------------------------------------------------------------------------------
/code/unity.framework/auto/colour_reporter.rb:
--------------------------------------------------------------------------------
1 | #---
2 | # Excerpted from "Test-Driven Development for Embedded C",
3 | # published by The Pragmatic Bookshelf.
4 | # Copyrights apply to this code. It may not be used to create training material,
5 | # courses, books, articles, and the like. Contact us if you are in doubt.
6 | # We make no guarantees that this code is fit for any purpose.
7 | # Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | #---
9 | # ==========================================
10 | # Unity Project - A Test Framework for C
11 | # Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
12 | # [Released under MIT License. Please refer to license.txt for details]
13 | # ==========================================
14 |
15 | require "#{File.expand_path(File.dirname(__FILE__))}/colour_prompt"
16 |
17 | $colour_output = true
18 |
19 | def report(message)
20 | if not $colour_output
21 | $stdout.puts(message)
22 | else
23 | message = message.join('\n') if (message.class == Array)
24 | message.each_line do |line|
25 | line.chomp!
26 | colour = case(line)
27 | when /(?:total\s+)?tests:?\s+(\d+)\s+(?:total\s+)?failures:?\s+\d+\s+Ignored:?/i
28 | ($1.to_i == 0) ? :green : :red
29 | when /PASS/
30 | :green
31 | when /^OK$/
32 | :green
33 | when /(?:FAIL|ERROR)/
34 | :red
35 | when /IGNORE/
36 | :yellow
37 | when /^(?:Creating|Compiling|Linking)/
38 | :white
39 | else
40 | :silver
41 | end
42 | colour_puts(colour, line)
43 | end
44 | end
45 | $stdout.flush
46 | $stderr.flush
47 | end
--------------------------------------------------------------------------------
/code/unity.framework/auto/generate_config.yml:
--------------------------------------------------------------------------------
1 | #this is a sample configuration file for generate_module
2 | #you would use it by calling generate_module with the -ygenerate_config.yml option
3 | #files like this are useful for customizing generate_module to your environment
4 | :generate_module:
5 | :defaults:
6 | #these defaults are used in place of any missing options at the command line
7 | :path_src: ../src/
8 | :path_inc: ../src/
9 | :path_tst: ../test/
10 | :update_svn: true
11 | :includes:
12 | #use [] for no additional includes, otherwise list the includes on separate lines
13 | :src:
14 | - Defs.h
15 | - Board.h
16 | :inc: []
17 | :tst:
18 | - Defs.h
19 | - Board.h
20 | - Exception.h
21 | :boilerplates:
22 | #these are inserted at the top of generated files.
23 | #just comment out or remove if not desired.
24 | #use %1$s where you would like the file name to appear (path/extension not included)
25 | :src: |
26 | //-------------------------------------------
27 | // %1$s.c
28 | //-------------------------------------------
29 | :inc: |
30 | //-------------------------------------------
31 | // %1$s.h
32 | //-------------------------------------------
33 | :tst: |
34 | //-------------------------------------------
35 | // Test%1$s.c : Units tests for %1$s.c
36 | //-------------------------------------------
37 |
--------------------------------------------------------------------------------
/code/unity.framework/auto/test_file_filter.rb:
--------------------------------------------------------------------------------
1 | #---
2 | # Excerpted from "Test-Driven Development for Embedded C",
3 | # published by The Pragmatic Bookshelf.
4 | # Copyrights apply to this code. It may not be used to create training material,
5 | # courses, books, articles, and the like. Contact us if you are in doubt.
6 | # We make no guarantees that this code is fit for any purpose.
7 | # Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | #---
9 | # ==========================================
10 | # Unity Project - A Test Framework for C
11 | # Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
12 | # [Released under MIT License. Please refer to license.txt for details]
13 | # ==========================================
14 |
15 | require'yaml'
16 |
17 | module RakefileHelpers
18 | class TestFileFilter
19 | def initialize(all_files = false)
20 | @all_files = all_files
21 | if not @all_files == true
22 | if File.exist?('test_file_filter.yml')
23 | filters = YAML.load_file( 'test_file_filter.yml' )
24 | @all_files, @only_files, @exclude_files =
25 | filters[:all_files], filters[:only_files], filters[:exclude_files]
26 | end
27 | end
28 | end
29 | attr_accessor :all_files, :only_files, :exclude_files
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/code/unity.framework/docs/Unity Summary.odt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jwgrenning/tddec-code/46ec03e06ddd464ad628a3ffaf5aaa910b7c5926/code/unity.framework/docs/Unity Summary.odt
--------------------------------------------------------------------------------
/code/unity.framework/docs/Unity Summary.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jwgrenning/tddec-code/46ec03e06ddd464ad628a3ffaf5aaa910b7c5926/code/unity.framework/docs/Unity Summary.pdf
--------------------------------------------------------------------------------
/code/unity.framework/docs/license.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2007-2010 Mike Karlesky, Mark VanderVoord, Greg Williams
2 |
3 | Permission is hereby granted, free of charge, to any person
4 | obtaining a copy of this software and associated documentation
5 | files (the "Software"), to deal in the Software without
6 | restriction, including without limitation the rights to use,
7 | copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the
9 | Software is furnished to do so, subject to the following
10 | conditions:
11 |
12 | The above copyright notice and this permission notice shall be
13 | included in all copies or substantial portions of the Software.
14 |
15 | The end-user documentation included with the redistribution, if
16 | any, must include the following acknowledgment: "This product
17 | includes software developed for the Unity Project, by Mike Karlesky,
18 | Mark VanderVoord, and Greg Williams and other contributors", in
19 | the same place and form as other third-party acknowledgments.
20 | Alternately, this acknowledgment may appear in the software
21 | itself, in the same form and location as other such third-party
22 | acknowledgments.
23 |
24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
26 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
28 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
29 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
31 | OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/code/unity.framework/examples/helper/UnityHelper.c:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | #include "unity.h"
10 | #include "UnityHelper.h"
11 | #include
12 | #include
13 |
14 | void AssertEqualExampleStruct(const EXAMPLE_STRUCT_T expected, const EXAMPLE_STRUCT_T actual, const unsigned short line)
15 | {
16 | UNITY_TEST_ASSERT_EQUAL_INT(expected.x, actual.x, line, "Example Struct Failed For Field x");
17 | UNITY_TEST_ASSERT_EQUAL_INT(expected.y, actual.y, line, "Example Struct Failed For Field y");
18 | }
19 |
--------------------------------------------------------------------------------
/code/unity.framework/examples/helper/UnityHelper.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | #ifndef _TESTHELPER_H
10 | #define _TESTHELPER_H
11 |
12 | #include "Types.h"
13 |
14 | void AssertEqualExampleStruct(const EXAMPLE_STRUCT_T expected, const EXAMPLE_STRUCT_T actual, const unsigned short line);
15 |
16 | #define UNITY_TEST_ASSERT_EQUAL_EXAMPLE_STRUCT_T(expected, actual, line, message) AssertEqualExampleStruct(expected, actual, line);
17 |
18 | #define TEST_ASSERT_EQUAL_EXAMPLE_STRUCT_T(expected, actual) UNITY_TEST_ASSERT_EQUAL_EXAMPLE_STRUCT_T(expected, actual, __LINE__, NULL);
19 |
20 | #endif // _TESTHELPER_H
21 |
--------------------------------------------------------------------------------
/code/unity.framework/examples/makefile:
--------------------------------------------------------------------------------
1 | # ==========================================
2 | # Unity Project - A Test Framework for C
3 | # Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
4 | # [Released under MIT License. Please refer to license.txt for details]
5 | # ==========================================
6 |
7 | C_COMPILER=gcc
8 | TARGET_BASE1=test1
9 | TARGET_BASE2=test2
10 | ifeq ($(OS),Windows_NT)
11 | TARGET_EXTENSION=.exe
12 | else
13 | TARGET_EXTENSION=.out
14 | endif
15 | TARGET1 = $(TARGET_BASE1)$(TARGET_EXTENSION)
16 | TARGET2 = $(TARGET_BASE2)$(TARGET_EXTENSION)
17 | SRC_FILES1=../src/unity.c src/ProductionCode.c test/TestProductionCode.c test/no_ruby/TestProductionCode_Runner.c
18 | SRC_FILES2=../src/unity.c src/ProductionCode2.c test/TestProductionCode2.c test/no_ruby/TestProductionCode2_Runner.c
19 | INC_DIRS=-Isrc -I../src
20 | SYMBOLS=-DTEST
21 |
22 | ifeq ($(OS),Windows_NT)
23 | CLEANUP = del /F /Q build\* && del /F /Q $(TARGET1) && del /F /Q $(TARGET2)
24 | else
25 | CLEANUP = rm -f build/*.o ; rm -f $(TARGET1) ; rm -f $(TARGET2)
26 | endif
27 |
28 | all: clean default
29 |
30 | default:
31 | # ruby auto/generate_test_runner.rb test/TestProductionCode.c test/no_ruby/TestProductionCode_Runner.c
32 | # ruby auto/generate_test_runner.rb test/TestProductionCode2.c test/no_ruby/TestProductionCode2_Runner.c
33 | $(C_COMPILER) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) -o $(TARGET1)
34 | $(C_COMPILER) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES2) -o $(TARGET2)
35 | $(TARGET1)
36 | $(TARGET2)
37 |
38 | clean:
39 | $(CLEANUP)
40 |
41 |
--------------------------------------------------------------------------------
/code/unity.framework/examples/rakefile.rb:
--------------------------------------------------------------------------------
1 | #---
2 | # Excerpted from "Test-Driven Development for Embedded C",
3 | # published by The Pragmatic Bookshelf.
4 | # Copyrights apply to this code. It may not be used to create training material,
5 | # courses, books, articles, and the like. Contact us if you are in doubt.
6 | # We make no guarantees that this code is fit for any purpose.
7 | # Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | #---
9 | HERE = File.expand_path(File.dirname(__FILE__)) + '/'
10 |
11 | require 'rake'
12 | require 'rake/clean'
13 | require 'rake/testtask'
14 | require HERE+'rakefile_helper'
15 |
16 | include RakefileHelpers
17 |
18 | # Load default configuration, for now
19 | DEFAULT_CONFIG_FILE = 'gcc.yml'
20 | configure_toolchain(DEFAULT_CONFIG_FILE)
21 |
22 | task :unit do
23 | run_tests get_unit_test_files
24 | end
25 |
26 | desc "Generate test summary"
27 | task :summary do
28 | report_summary
29 | end
30 |
31 | desc "Build and test Unity"
32 | task :all => [:clean, :unit, :summary]
33 | task :default => [:clobber, :all]
34 | task :ci => [:default]
35 | task :cruise => [:default]
36 |
37 | desc "Load configuration"
38 | task :config, :config_file do |t, args|
39 | configure_toolchain(args[:config_file])
40 | end
41 |
--------------------------------------------------------------------------------
/code/unity.framework/examples/readme.txt:
--------------------------------------------------------------------------------
1 | Example Project
2 |
3 | This example project gives an example of some passing, ignored, and failing tests.
4 | It's simple and meant for you to look over and get an idea for what all of this stuff does.
5 |
6 | You can build and test using the makefile if you have gcc installed (you may need to tweak
7 | the locations of some tools in the makefile). Otherwise, the rake version will let you
8 | test with gcc or a couple versions of IAR. You can tweak the yaml files to get those versions
9 | running.
10 |
11 | Ruby is required if you're using the rake version (obviously). This version shows off most of
12 | Unity's advanced features (automatically creating test runners, fancy summaries, etc.)
13 |
14 | The makefile version doesn't require anything outside of your normal build tools, but won't do the
15 | extras for you. So that you can test right away, we've written the test runners for you and
16 | put them in the test\no_ruby subdirectory. If you make changes to the tests or source, you might
17 | need to update these (like when you add or remove tests). Do that for a while and you'll learn
18 | why you really want to start using the Ruby tools.
--------------------------------------------------------------------------------
/code/unity.framework/examples/src/ProductionCode.c:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 |
10 | #include "ProductionCode.h"
11 |
12 | int Counter = 0;
13 | int NumbersToFind[9] = { 0, 34, 55, 66, 32, 11, 1, 77, 888 }; //some obnoxious array to search that is 1-based indexing instead of 0.
14 |
15 | // This function is supposed to search through NumbersToFind and find a particular number.
16 | // If it finds it, the index is returned. Otherwise 0 is returned which sorta makes sense since
17 | // NumbersToFind is indexed from 1. Unfortunately it's broken
18 | // (and should therefore be caught by our tests)
19 | int FindFunction_WhichIsBroken(int NumberToFind)
20 | {
21 | int i = 0;
22 | while (i <= 8) //Notice I should have been in braces
23 | i++;
24 | if (NumbersToFind[i] == NumberToFind) //Yikes! I'm getting run after the loop finishes instead of during it!
25 | return i;
26 | return 0;
27 | }
28 |
29 | int FunctionWhichReturnsLocalVariable(void)
30 | {
31 | return Counter;
32 | }
33 |
--------------------------------------------------------------------------------
/code/unity.framework/examples/src/ProductionCode.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 |
10 | int FindFunction_WhichIsBroken(int NumberToFind);
11 | int FunctionWhichReturnsLocalVariable(void);
12 |
--------------------------------------------------------------------------------
/code/unity.framework/examples/src/ProductionCode2.c:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 |
10 | #include "ProductionCode2.h"
11 |
12 | char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction)
13 | {
14 | //Since There Are No Tests Yet, This Function Could Be Empty For All We Know.
15 | // Which isn't terribly useful... but at least we put in a TEST_IGNORE so we won't forget
16 | return (char*)0;
17 | }
18 |
--------------------------------------------------------------------------------
/code/unity.framework/examples/src/ProductionCode2.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 |
10 | char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction);
11 |
--------------------------------------------------------------------------------
/code/unity.framework/examples/test/TestProductionCode2.c:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 |
10 | #include "ProductionCode2.h"
11 | #include "unity.h"
12 |
13 | void setUp(void)
14 | {
15 | }
16 |
17 | void tearDown(void)
18 | {
19 | }
20 |
21 | void test_IgnoredTest(void)
22 | {
23 | TEST_IGNORE_MESSAGE("This Test Was Ignored On Purpose");
24 | }
25 |
26 | void test_AnotherIgnoredTest(void)
27 | {
28 | TEST_IGNORE_MESSAGE("These Can Be Useful For Leaving Yourself Notes On What You Need To Do Yet");
29 | }
30 |
31 | void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void)
32 | {
33 | TEST_IGNORE(); //Like This
34 | }
35 |
--------------------------------------------------------------------------------
/code/unity.framework/examples/test/no_ruby/TestProductionCode2_Runner.c:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /* AUTOGENERATED FILE. DO NOT EDIT. */
10 | #include "unity.h"
11 | #include
12 | #include
13 |
14 | char MessageBuffer[50];
15 |
16 | extern void setUp(void);
17 | extern void tearDown(void);
18 |
19 | extern void test_IgnoredTest(void);
20 | extern void test_AnotherIgnoredTest(void);
21 | extern void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void);
22 |
23 | static void runTest(UnityTestFunction test)
24 | {
25 | if (TEST_PROTECT())
26 | {
27 | setUp();
28 | test();
29 | }
30 | if (TEST_PROTECT() && !TEST_IS_IGNORED)
31 | {
32 | tearDown();
33 | }
34 | }
35 | void resetTest()
36 | {
37 | tearDown();
38 | setUp();
39 | }
40 |
41 |
42 | int main(void)
43 | {
44 | Unity.TestFile = "test/TestProductionCode2.c";
45 | UnityBegin();
46 |
47 | // RUN_TEST calls runTest
48 | RUN_TEST(test_IgnoredTest, 13);
49 | RUN_TEST(test_AnotherIgnoredTest, 18);
50 | RUN_TEST(test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented, 23);
51 |
52 | UnityEnd();
53 | return 0;
54 | }
55 |
--------------------------------------------------------------------------------
/code/unity.framework/extras/fixture/build/filterGcov.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #---
3 | # Excerpted from "Test-Driven Development for Embedded C",
4 | # published by The Pragmatic Bookshelf.
5 | # Copyrights apply to this code. It may not be used to create training material,
6 | # courses, books, articles, and the like. Contact us if you are in doubt.
7 | # We make no guarantees that this code is fit for any purpose.
8 | # Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
9 | #---
10 | INPUT_FILE=$1
11 | TEMP_FILE1=${INPUT_FILE}1.tmp
12 | TEMP_FILE2=${INPUT_FILE}2.tmp
13 | TEMP_FILE3=${INPUT_FILE}3.tmp
14 | ERROR_FILE=$2
15 | OUTPUT_FILE=$3
16 | HTML_OUTPUT_FILE=$3.html
17 | TEST_RESULTS=$4
18 |
19 | flattenGcovOutput() {
20 | while read line1
21 | do
22 | read line2
23 | echo $line2 " " $line1
24 | read junk
25 | read junk
26 | done < ${INPUT_FILE}
27 | }
28 |
29 | getRidOfCruft() {
30 | sed '-e s/^Lines.*://g' \
31 | '-e s/^[0-9]\./ &/g' \
32 | '-e s/^[0-9][0-9]\./ &/g' \
33 | '-e s/of.*File/ /g' \
34 | "-e s/'//g" \
35 | '-e s/^.*\/usr\/.*$//g' \
36 | '-e s/^.*\.$//g'
37 | }
38 |
39 | getFileNameRootFromErrorFile() {
40 | sed '-e s/gc..:cannot open .* file//g' ${ERROR_FILE}
41 | }
42 |
43 | writeEachNoTestCoverageFile() {
44 | while read line
45 | do
46 | echo " 0.00% " ${line}
47 | done
48 | }
49 |
50 | createHtmlOutput() {
51 | echo "
"
56 | sed "-e s/.*/& /g" < ${TEST_RESULTS}
57 | }
58 |
59 |
60 | flattenGcovOutput | getRidOfCruft > ${TEMP_FILE1}
61 | getFileNameRootFromErrorFile | writeEachNoTestCoverageFile > ${TEMP_FILE2}
62 | cat ${TEMP_FILE1} ${TEMP_FILE2} | sort | uniq > ${OUTPUT_FILE}
63 | createHtmlOutput < ${OUTPUT_FILE} > ${HTML_OUTPUT_FILE}
64 | rm -f ${TEMP_FILE1} ${TEMP_FILE2}
65 |
--------------------------------------------------------------------------------
/code/unity/mocks/RuntimeErrorStub.h:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #ifndef D_RuntimeErrorStub_H
28 | #define D_RuntimeErrorStub_H
29 |
30 | #include "RuntimeError.h"
31 |
32 | void RuntimeErrorStub_Reset(void);
33 | const char * RuntimeErrorStub_GetLastError(void);
34 | int RuntimeErrorStub_GetLastParameter(void);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/code/unity/stdio/SprintfTestRunner.c:
--------------------------------------------------------------------------------
1 | /***
2 | * Excerpted from "Test-Driven Development for Embedded C",
3 | * published by The Pragmatic Bookshelf.
4 | * Copyrights apply to this code. It may not be used to create training material,
5 | * courses, books, articles, and the like. Contact us if you are in doubt.
6 | * We make no guarantees that this code is fit for any purpose.
7 | * Visit http://www.pragmaticprogrammer.com/titles/jgade for more book information.
8 | ***/
9 | /*- ------------------------------------------------------------------ -*/
10 | /*- Copyright (c) James W. Grenning -- All Rights Reserved -*/
11 | /*- For use by owners of Test-Driven Development for Embedded C, -*/
12 | /*- and attendees of Renaissance Software Consulting, Co. training -*/
13 | /*- classes. -*/
14 | /*- -*/
15 | /*- Available at http://pragprog.com/titles/jgade/ -*/
16 | /*- ISBN 1-934356-62-X, ISBN13 978-1-934356-62-3 -*/
17 | /*- -*/
18 | /*- Authorized users may use this source code in your own -*/
19 | /*- projects, however the source code may not be used to -*/
20 | /*- create training material, courses, books, articles, and -*/
21 | /*- the like. We make no guarantees that this source code is -*/
22 | /*- fit for any purpose. -*/
23 | /*- -*/
24 | /*- www.renaissancesoftware.net james@renaissancesoftware.net -*/
25 | /*- ------------------------------------------------------------------ -*/
26 |
27 | #include "unity_fixture.h"
28 |
29 | TEST_GROUP_RUNNER(sprintf)
30 | {
31 | RUN_TEST_CASE(sprintf, NoFormatOperations);
32 | RUN_TEST_CASE(sprintf, InsertString);
33 | #if 0
34 | RUN_TEST_CASE(sprintf, StringWithSpace);
35 | #endif
36 | }
37 |
--------------------------------------------------------------------------------
/notes.txt:
--------------------------------------------------------------------------------
1 | Add cpputest as a submodule
2 | ```
3 | git submodule add git@github.com:cpputest/cpputest.git
4 | cat .gitmodules
5 | git commit -m "Added cpputest as a submodule"
6 | ```
7 |
8 |
9 | https://git-scm.com/book/en/v2/Git-Tools-Submodules
10 |
--------------------------------------------------------------------------------