<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.codeblocks.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Killerbot</id>
	<title>Code::Blocks - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.codeblocks.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Killerbot"/>
	<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php/Special:Contributions/Killerbot"/>
	<updated>2026-05-10T22:35:30Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.0</generator>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=Nightly_Cookbook&amp;diff=7700</id>
		<title>Nightly Cookbook</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=Nightly_Cookbook&amp;diff=7700"/>
		<updated>2014-01-05T11:50:07Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* wxWidgets */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Developer Documentation]]&lt;br /&gt;
This page is under construction by 'killerbot'. Just be patient, some day it will be finished.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This article will describe the process used in creating the nightly builds, and can be used as a guideline if you want to build Code::Blocks yourself. It is described as a sequence of 'manual' actions.  While it is possible to automate several of these tasks via script, that is beyond the scope of this article.&lt;br /&gt;
Current limitation : Windows unicode build.&lt;br /&gt;
&lt;br /&gt;
== Shopping List ==&lt;br /&gt;
In order to perform our build tasks, we will need several tools. Let's create an ingredient list for our cooking experiments : &lt;br /&gt;
* a compiler&lt;br /&gt;
* an initial build system&lt;br /&gt;
* the Code::Blocks sources&lt;br /&gt;
* zip program&lt;br /&gt;
* svn (version control system)&lt;br /&gt;
* wxWidgets&lt;br /&gt;
&lt;br /&gt;
While we are at it, maybe someday we want to debug our programs, so let's add a debugger to the list : &lt;br /&gt;
&lt;br /&gt;
* debugger&lt;br /&gt;
&lt;br /&gt;
== Shopping Time ==&lt;br /&gt;
=== Compiler ===&lt;br /&gt;
Let's start by shopping for the first item on our list, a compiler. Several compilers are available; some free, some expensive. Since the Code::Blocks developers build Code::Blocks using GCC, we might as well use that one. It is very standards compliant, though not the fastest one around. GCC on windows is available in several flavors. There are CygWin ports and MingW ports.&lt;br /&gt;
&lt;br /&gt;
The easiest and cleanest port is MinGW. This is the compiler distributed with Code::Blocks when you download the official package (the one including the compiler). We can find MinGW at [http://www.mingw.org www.mingw.org]. [https://wiki.codeblocks.org/index.php?title=MinGW_installation#gcc_3.4.4_manual_install This post] in the wiki describes how to install MinGW. We will stick to version 3.4.5, which works nicely. (Much has changed since this was originally written; if possible, use version 4.4.0 or newer.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First, a brief explanation of MinGW components:&lt;br /&gt;
* gcc-core : the core of the GCC suite&lt;br /&gt;
* gcc-g++ : the c++ compiler&lt;br /&gt;
* mingw Runtime : implementation of the run time libraries&lt;br /&gt;
* mingw utils : several utilities (implementation of smaller programs that GCC itself uses)&lt;br /&gt;
* win32Api : the APIs for creating Windows programs&lt;br /&gt;
* binutils : several utilities used in build environments&lt;br /&gt;
* make : the Gnu make program, so you can build from make files&lt;br /&gt;
* GDB : the Gnu debugger : for hunting those nasty bugs (version 6.3.2 or above !!!)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I would suggest extracting (and installing for the GDB) everything in the C:\MinGW directory. The remainder of this article will assume that this is where you have put it. If you already have an installation of Code::Blocks that came bundled with MinGW (for example RC2), I still advise you to install MinGW as described here. A compiler does not belong under the directory tree of an IDE; they are two separate things. Code::Blocks just brings it along in the official versions so that the average user does not need to bother with this process. But, since you are reading this, you are no longer an average user. :-)&lt;br /&gt;
&lt;br /&gt;
You may need to add the 'bin' directory of your MinGW installation to your path (example : C:\MinGW\bin).  An easy way to do this is with the following command at the command prompt: &lt;br /&gt;
&lt;br /&gt;
set path=%PATH%;C:\MinGW\bin;C:\MinGW\mingw32\bin;&lt;br /&gt;
&lt;br /&gt;
=== Initial Build System ===&lt;br /&gt;
We could try to build Code::Blocks by using makefiles, but there is an easier way: let's build Code::Blocks by using ........ Code::Blocks. All we need to do is get hold of a pre-built version Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First, download a nightly build.  You can make your selection from [/index.php?board=20.0 here]. The nightly builds are unicode versions, containing the core and contributed plug-ins.&lt;br /&gt;
&lt;br /&gt;
Next, unpack the 7-zip file to any directory you like (e.g. C:\CodeBlocksTempNightly). If you don't have 7-zip, you can download it for free from [http://www.7-zip.org the 7-zip website].&lt;br /&gt;
&lt;br /&gt;
Now, Code::Blocks needs one more dll to work correctly: the WxWidgets dll. You can also download it at the nightly builds forum. Just unzip it into the same directory that you unpacked the Code::Blocks nightly build. It also needs the mingwm10.dll, but don't worry - we already have it. It's in the bin directory of our MinGW installation. So, it's important to make sure the bin directory of your MinGW installation is in your path variable (see above).&lt;br /&gt;
&lt;br /&gt;
Finally, start up this new nightly build of Code::Blocks. It should discover the MinGW compiler we just installed.&lt;br /&gt;
&lt;br /&gt;
== Version Control System ==&lt;br /&gt;
In order to be able to retrieve the latest and greatest Code::Blocks sources, we need to install a Version Control System.&lt;br /&gt;
&lt;br /&gt;
The Code::Blocks developers provide their sources through the SVN version control system. So, we need a client to access their svn repository of sources. A nice, easy client for Windows is TortoiseSVN, which is freely available from [http://tortoisesvn.tigris.org/ here]. Download and install it, keeping all suggested settings.&lt;br /&gt;
&lt;br /&gt;
Now, go create a directory wherever you like, for example D:\projects\CodeBlocks. Right click on that directory and choose from the pop-up menu : svn-checkout. In the dialog that pops up, fill in the following information: &lt;br /&gt;
&lt;br /&gt;
  - Url of Repository : svn://svn.berlios.de/codeblocks/trunk&lt;br /&gt;
  - leave all other settings as they are&lt;br /&gt;
&lt;br /&gt;
Now be patient while TortoiseSVN retrieves the most recent source files from the Code::Blocks repository into our local directory. Yes; all those Code::Blocks sources are coming your way!&lt;br /&gt;
&lt;br /&gt;
For more info on SVN settings, see [https://www.codeblocks.org/downloads/svn info on SVN settings]. If you don't like an Explorer integration or look for a cross-plattform client you might want to have a look at [http://rapidsvn.tigris.org/ RapidSVN] (which is btw. also written using wxWidgets).&lt;br /&gt;
&lt;br /&gt;
All righty, time to continue our shopping session.&lt;br /&gt;
&lt;br /&gt;
== wxWidgets ==&lt;br /&gt;
WxWidgets is a platform abstraction that provides an API to support many things such as GUI, sockets, files, registry functionality. By using this API, you can create a platform independent program.&lt;br /&gt;
&lt;br /&gt;
Code::Blocks is a wxWidgets (here after: wx ) application, that means if you want to run Code::Blocks you needed the wx functionality. This can be provided in a couple of ways. It could be a .dll or a static library. Code::Blocks uses wx as a dll and this dll can also be downloaded from the nightly build section of the forum.&lt;br /&gt;
&lt;br /&gt;
However, if we want to build a wx application, we need to include the headers of the wx sources. They tell the compiler about the functionality of wx. In addition to those header files, our application needs to link to the wx import libraries. Well, let's take it step by step. &lt;br /&gt;
&lt;br /&gt;
Wx is provided as a zip file of it's sources, so we need to build that ourselves. We already shopped for the MinGW compiler, so we have all the tools we need at hand.&lt;br /&gt;
&lt;br /&gt;
Download the [http://www.wxwidgets.org/downloads/ wx sources] (at time of writing : version 2.8.12) [http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.8.12.zip in this .zip here].&lt;br /&gt;
&lt;br /&gt;
Next, let's unzip the wx sources into C:\Projects so we will end up with a wx root directory like this: C:\Projects\wxWidgets-2.8.12. Note that we are going to refer to the wx root directory from now on as &amp;lt;wxDir&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we are going to build the wxWidgets. This is how we do it:&lt;br /&gt;
&lt;br /&gt;
First, make sure C:\MingGW\bin is in your path, during the build some programs will be called that reside in the the MinGW\bin directory. Also, Make has to be version 3.80 or above.&lt;br /&gt;
&lt;br /&gt;
Now it is time to compile wxWidgets. Open the command prompt and change to the wxWidgets directory:&lt;br /&gt;
  &amp;lt;tt&amp;gt;cd /D &amp;lt;wxDir&amp;gt;\build\msw&amp;lt;/tt&amp;gt;&lt;br /&gt;
''Note: the ''&amp;lt;code&amp;gt;/D&amp;lt;/code&amp;gt;'' flag after ''&amp;lt;code&amp;gt;cd&amp;lt;/code&amp;gt;'' may be omitted from the command; it simply allows command prompt to change drives if necessary.''&lt;br /&gt;
&lt;br /&gt;
We are now in the right place. We are first going to clean up the source:&lt;br /&gt;
  &amp;lt;tt&amp;gt;mingw32-make -f makefile.gcc SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 clean&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once everything is clean, we can compile wxWidgets:&lt;br /&gt;
  &amp;lt;tt&amp;gt;mingw32-make -f makefile.gcc SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you are using TDM-gcc 4.8.1, you will have to add the following option on the command line : &lt;br /&gt;
  &amp;lt;tt&amp;gt;CXXFLAGS+=-fpermissive&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is going to take some time, so go get yourself a nice ice-cream, a beer, ...&lt;br /&gt;
&lt;br /&gt;
 Note: For making the debug build, follow these steps:&lt;br /&gt;
  First clean any previous compilation with:&lt;br /&gt;
   &amp;lt;tt&amp;gt;mingw32-make -f makefile.gcc SHARED=1 MONOLITHIC=1 BUILD=debug UNICODE=1 clean&amp;lt;/tt&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  And then compile with:&lt;br /&gt;
   &amp;lt;tt&amp;gt;mingw32-make -f makefile.gcc SHARED=1 MONOLITHIC=1 BUILD=debug UNICODE=1&amp;lt;/tt&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   ... If you are not on diet, get another ice-cream, a beer, ....&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Did you enjoy your refreshment? Well have a little look in the directory (&amp;lt;wxDir&amp;gt;\lib\gcc_dll) now. The import libraries and the dll have shown up and there should also a mswu\wx subdirectory at that position containing setup.h.&lt;br /&gt;
&lt;br /&gt;
Congratulations! You have just built wxWidgets!&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Let's do some more preliminary tasks before we get to the real deal of compiling Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
== Zip ==&lt;br /&gt;
During the build of Code::Blocks, several resources are going to be zipped in zip files. Therefore, the build process should have access to a zip.exe. We have to download that zip.exe and put it somewhere in our path.  A good place is: MingW\bin.&lt;br /&gt;
&lt;br /&gt;
You can download zip.exe for free from [http://www.info-zip.org/Zip.html this site] and this is a [ftp://ftp.info-zip.org/pub/infozip/win32/zip232xn.zip direct link(32bit)] to the most recent version at the time of this writing. &lt;br /&gt;
&lt;br /&gt;
Once downloaded, simply extract zip.exe to the appropriate location.&lt;br /&gt;
&lt;br /&gt;
== Workspace ==&lt;br /&gt;
This brings us to the last preliminary task. The Code::Blocks code can be divided into 2 major parts: the core with internal plug-ins, and the contributed plug-ins. You always need to build the core/internal parts before building the contrib part. &lt;br /&gt;
&lt;br /&gt;
To build the internal part, you can use the Code::Blocks project file which you can find at: &amp;lt;cbDir&amp;gt;\src\CodeBlocks.cbp. Our Code::Blocks master directory is from now one mentioned as &amp;lt;cbDir&amp;gt;, by the way. A workspace is something that groups several projects together. To build the contrib plug-ins, they can be found at &amp;lt;cbDir&amp;gt;\src\ContribPlugins.workspace.&lt;br /&gt;
&lt;br /&gt;
But, let's create a workspace containing everything. Let's put that workspace in the master directory &amp;lt;cbDir&amp;gt;. Just use a regular text editor and create a file with the name &amp;quot;CbProjects.workspace&amp;quot; and give it the following content : &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
 &amp;lt;CodeBlocks_workspace_file&amp;gt;&lt;br /&gt;
  &amp;lt;Workspace title=&amp;quot;Workspace&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\CodeBlocks.cbp&amp;quot; active=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\AutoVersioning\AutoVersioning.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\BrowseTracker\BrowseTracker.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\byogames\byogames.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\cb_koders\cb_koders.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\codesnippets\codesnippets.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\codestat\codestat.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\copystrings\copystrings.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\devpak_plugin\DevPakPlugin.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\dragscroll\dragscroll.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\envvars\envvars.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\headerfixup\headerfixup.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\help_plugin\help-plugin.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\keybinder\keybinder.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\profiler\cbprofiler.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\regex_testbed\RegExTestbed.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\source_exporter\Exporter.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\symtab\symtab.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\ThreadSearch\ThreadSearch.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\wxSmith\wxSmith.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\wxSmithContribItems\wxSmithContribItems.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\wxSmithAui\wxSmithAui.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\lib_finder\lib_finder.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\HexEditor\HexEditor-win.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\tools\cb_share_config\cb_share_config.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\IncrementalSearch\IncrementalSearch.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\MouseSap\MouseSap.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/Workspace&amp;gt;&lt;br /&gt;
 &amp;lt;/CodeBlocks_workspace_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will use this workspace to build all of Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
== Building Code::Blocks ==&lt;br /&gt;
Finally we have arrived at the final step; our final goal. Run the Code::Blocks executable from your nightly build download. Choose Open from the File menu and browse for our above created workspace, and open it up. Be a little patient while Code::Blocks is parsing everything, and Code::Blocks will ask us for 2 global variables, these global variables will tell the nightly Code::Blocks where it can find wxWidgets (remember : header files and import libraries) and where it can find .... Code::Blocks, this is needed for the contrib plug-ins, they need to know (as for any user created plug-in) where the sdk (Code::Blocks header files) are.&lt;br /&gt;
These are the values in our case : &lt;br /&gt;
 - wx : &amp;lt;wxDir&amp;gt;&lt;br /&gt;
 - Code::Blocks (cb) : &amp;lt;cbDir&amp;gt;\src&lt;br /&gt;
&lt;br /&gt;
Now go to the Project Menu and choose (re)build workspace, and off you go. Watch how Code::Blocks is building Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
Once the build is complete, open up a console in &amp;lt;cbDir&amp;gt;\src and run the command &amp;quot;update.bat&amp;quot;. This will transfer all built deliverables from &amp;lt;cbDir&amp;gt;\src\devel to &amp;lt;cbDir&amp;gt;\src\output. In addition, it will strip out all debugging symbols. This step is very important - never ever forget it. &lt;br /&gt;
&lt;br /&gt;
Now you can copy the wx dll in both that output and the devel directory.&lt;br /&gt;
&lt;br /&gt;
Then you can close Code::Blocks. That was the downloaded nightly remember?&lt;br /&gt;
&lt;br /&gt;
Time to test it. In the output directory, start up the CodeBlocks.exe. If everything went well, you'll have your very own home-built Code::Blocks running.&lt;br /&gt;
&lt;br /&gt;
Enjoy !!!&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=Nightly_Cookbook&amp;diff=7699</id>
		<title>Nightly Cookbook</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=Nightly_Cookbook&amp;diff=7699"/>
		<updated>2014-01-05T11:49:32Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* wxWidgets */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Developer Documentation]]&lt;br /&gt;
This page is under construction by 'killerbot'. Just be patient, some day it will be finished.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This article will describe the process used in creating the nightly builds, and can be used as a guideline if you want to build Code::Blocks yourself. It is described as a sequence of 'manual' actions.  While it is possible to automate several of these tasks via script, that is beyond the scope of this article.&lt;br /&gt;
Current limitation : Windows unicode build.&lt;br /&gt;
&lt;br /&gt;
== Shopping List ==&lt;br /&gt;
In order to perform our build tasks, we will need several tools. Let's create an ingredient list for our cooking experiments : &lt;br /&gt;
* a compiler&lt;br /&gt;
* an initial build system&lt;br /&gt;
* the Code::Blocks sources&lt;br /&gt;
* zip program&lt;br /&gt;
* svn (version control system)&lt;br /&gt;
* wxWidgets&lt;br /&gt;
&lt;br /&gt;
While we are at it, maybe someday we want to debug our programs, so let's add a debugger to the list : &lt;br /&gt;
&lt;br /&gt;
* debugger&lt;br /&gt;
&lt;br /&gt;
== Shopping Time ==&lt;br /&gt;
=== Compiler ===&lt;br /&gt;
Let's start by shopping for the first item on our list, a compiler. Several compilers are available; some free, some expensive. Since the Code::Blocks developers build Code::Blocks using GCC, we might as well use that one. It is very standards compliant, though not the fastest one around. GCC on windows is available in several flavors. There are CygWin ports and MingW ports.&lt;br /&gt;
&lt;br /&gt;
The easiest and cleanest port is MinGW. This is the compiler distributed with Code::Blocks when you download the official package (the one including the compiler). We can find MinGW at [http://www.mingw.org www.mingw.org]. [https://wiki.codeblocks.org/index.php?title=MinGW_installation#gcc_3.4.4_manual_install This post] in the wiki describes how to install MinGW. We will stick to version 3.4.5, which works nicely. (Much has changed since this was originally written; if possible, use version 4.4.0 or newer.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First, a brief explanation of MinGW components:&lt;br /&gt;
* gcc-core : the core of the GCC suite&lt;br /&gt;
* gcc-g++ : the c++ compiler&lt;br /&gt;
* mingw Runtime : implementation of the run time libraries&lt;br /&gt;
* mingw utils : several utilities (implementation of smaller programs that GCC itself uses)&lt;br /&gt;
* win32Api : the APIs for creating Windows programs&lt;br /&gt;
* binutils : several utilities used in build environments&lt;br /&gt;
* make : the Gnu make program, so you can build from make files&lt;br /&gt;
* GDB : the Gnu debugger : for hunting those nasty bugs (version 6.3.2 or above !!!)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I would suggest extracting (and installing for the GDB) everything in the C:\MinGW directory. The remainder of this article will assume that this is where you have put it. If you already have an installation of Code::Blocks that came bundled with MinGW (for example RC2), I still advise you to install MinGW as described here. A compiler does not belong under the directory tree of an IDE; they are two separate things. Code::Blocks just brings it along in the official versions so that the average user does not need to bother with this process. But, since you are reading this, you are no longer an average user. :-)&lt;br /&gt;
&lt;br /&gt;
You may need to add the 'bin' directory of your MinGW installation to your path (example : C:\MinGW\bin).  An easy way to do this is with the following command at the command prompt: &lt;br /&gt;
&lt;br /&gt;
set path=%PATH%;C:\MinGW\bin;C:\MinGW\mingw32\bin;&lt;br /&gt;
&lt;br /&gt;
=== Initial Build System ===&lt;br /&gt;
We could try to build Code::Blocks by using makefiles, but there is an easier way: let's build Code::Blocks by using ........ Code::Blocks. All we need to do is get hold of a pre-built version Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First, download a nightly build.  You can make your selection from [/index.php?board=20.0 here]. The nightly builds are unicode versions, containing the core and contributed plug-ins.&lt;br /&gt;
&lt;br /&gt;
Next, unpack the 7-zip file to any directory you like (e.g. C:\CodeBlocksTempNightly). If you don't have 7-zip, you can download it for free from [http://www.7-zip.org the 7-zip website].&lt;br /&gt;
&lt;br /&gt;
Now, Code::Blocks needs one more dll to work correctly: the WxWidgets dll. You can also download it at the nightly builds forum. Just unzip it into the same directory that you unpacked the Code::Blocks nightly build. It also needs the mingwm10.dll, but don't worry - we already have it. It's in the bin directory of our MinGW installation. So, it's important to make sure the bin directory of your MinGW installation is in your path variable (see above).&lt;br /&gt;
&lt;br /&gt;
Finally, start up this new nightly build of Code::Blocks. It should discover the MinGW compiler we just installed.&lt;br /&gt;
&lt;br /&gt;
== Version Control System ==&lt;br /&gt;
In order to be able to retrieve the latest and greatest Code::Blocks sources, we need to install a Version Control System.&lt;br /&gt;
&lt;br /&gt;
The Code::Blocks developers provide their sources through the SVN version control system. So, we need a client to access their svn repository of sources. A nice, easy client for Windows is TortoiseSVN, which is freely available from [http://tortoisesvn.tigris.org/ here]. Download and install it, keeping all suggested settings.&lt;br /&gt;
&lt;br /&gt;
Now, go create a directory wherever you like, for example D:\projects\CodeBlocks. Right click on that directory and choose from the pop-up menu : svn-checkout. In the dialog that pops up, fill in the following information: &lt;br /&gt;
&lt;br /&gt;
  - Url of Repository : svn://svn.berlios.de/codeblocks/trunk&lt;br /&gt;
  - leave all other settings as they are&lt;br /&gt;
&lt;br /&gt;
Now be patient while TortoiseSVN retrieves the most recent source files from the Code::Blocks repository into our local directory. Yes; all those Code::Blocks sources are coming your way!&lt;br /&gt;
&lt;br /&gt;
For more info on SVN settings, see [https://www.codeblocks.org/downloads/svn info on SVN settings]. If you don't like an Explorer integration or look for a cross-plattform client you might want to have a look at [http://rapidsvn.tigris.org/ RapidSVN] (which is btw. also written using wxWidgets).&lt;br /&gt;
&lt;br /&gt;
All righty, time to continue our shopping session.&lt;br /&gt;
&lt;br /&gt;
== wxWidgets ==&lt;br /&gt;
WxWidgets is a platform abstraction that provides an API to support many things such as GUI, sockets, files, registry functionality. By using this API, you can create a platform independent program.&lt;br /&gt;
&lt;br /&gt;
Code::Blocks is a wxWidgets (here after: wx ) application, that means if you want to run Code::Blocks you needed the wx functionality. This can be provided in a couple of ways. It could be a .dll or a static library. Code::Blocks uses wx as a dll and this dll can also be downloaded from the nightly build section of the forum.&lt;br /&gt;
&lt;br /&gt;
However, if we want to build a wx application, we need to include the headers of the wx sources. They tell the compiler about the functionality of wx. In addition to those header files, our application needs to link to the wx import libraries. Well, let's take it step by step. &lt;br /&gt;
&lt;br /&gt;
Wx is provided as a zip file of it's sources, so we need to build that ourselves. We already shopped for the MinGW compiler, so we have all the tools we need at hand.&lt;br /&gt;
&lt;br /&gt;
Download the [http://www.wxwidgets.org/downloads/ wx sources] (at time of writing : version 2.8.12) [http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.8.12.zip in this .zip here].&lt;br /&gt;
&lt;br /&gt;
Next, let's unzip the wx sources into C:\Projects so we will end up with a wx root directory like this: C:\Projects\wxWidgets-2.8.12. Note that we are going to refer to the wx root directory from now on as &amp;lt;wxDir&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we are going to build the wxWidgets. This is how we do it:&lt;br /&gt;
&lt;br /&gt;
First, make sure C:\MingGW\bin is in your path, during the build some programs will be called that reside in the the MinGW\bin directory. Also, Make has to be version 3.80 or above.&lt;br /&gt;
&lt;br /&gt;
Now it is time to compile wxWidgets. Open the command prompt and change to the wxWidgets directory:&lt;br /&gt;
  &amp;lt;tt&amp;gt;cd /D &amp;lt;wxDir&amp;gt;\build\msw&amp;lt;/tt&amp;gt;&lt;br /&gt;
''Note: the ''&amp;lt;code&amp;gt;/D&amp;lt;/code&amp;gt;'' flag after ''&amp;lt;code&amp;gt;cd&amp;lt;/code&amp;gt;'' may be omitted from the command; it simply allows command prompt to change drives if necessary.''&lt;br /&gt;
&lt;br /&gt;
We are now in the right place. We are first going to clean up the source:&lt;br /&gt;
  &amp;lt;tt&amp;gt;mingw32-make -f makefile.gcc SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 clean&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once everything is clean, we can compile wxWidgets:&lt;br /&gt;
  &amp;lt;tt&amp;gt;mingw32-make -f makefile.gcc SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you are using TDM-gcc 4.8.1, you will have to add hte following option on the command line : CXXFLAGS+=-fpermissive&lt;br /&gt;
&lt;br /&gt;
This is going to take some time, so go get yourself a nice ice-cream, a beer, ...&lt;br /&gt;
&lt;br /&gt;
 Note: For making the debug build, follow these steps:&lt;br /&gt;
  First clean any previous compilation with:&lt;br /&gt;
   &amp;lt;tt&amp;gt;mingw32-make -f makefile.gcc SHARED=1 MONOLITHIC=1 BUILD=debug UNICODE=1 clean&amp;lt;/tt&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  And then compile with:&lt;br /&gt;
   &amp;lt;tt&amp;gt;mingw32-make -f makefile.gcc SHARED=1 MONOLITHIC=1 BUILD=debug UNICODE=1&amp;lt;/tt&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   ... If you are not on diet, get another ice-cream, a beer, ....&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Did you enjoy your refreshment? Well have a little look in the directory (&amp;lt;wxDir&amp;gt;\lib\gcc_dll) now. The import libraries and the dll have shown up and there should also a mswu\wx subdirectory at that position containing setup.h.&lt;br /&gt;
&lt;br /&gt;
Congratulations! You have just built wxWidgets!&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Let's do some more preliminary tasks before we get to the real deal of compiling Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
== Zip ==&lt;br /&gt;
During the build of Code::Blocks, several resources are going to be zipped in zip files. Therefore, the build process should have access to a zip.exe. We have to download that zip.exe and put it somewhere in our path.  A good place is: MingW\bin.&lt;br /&gt;
&lt;br /&gt;
You can download zip.exe for free from [http://www.info-zip.org/Zip.html this site] and this is a [ftp://ftp.info-zip.org/pub/infozip/win32/zip232xn.zip direct link(32bit)] to the most recent version at the time of this writing. &lt;br /&gt;
&lt;br /&gt;
Once downloaded, simply extract zip.exe to the appropriate location.&lt;br /&gt;
&lt;br /&gt;
== Workspace ==&lt;br /&gt;
This brings us to the last preliminary task. The Code::Blocks code can be divided into 2 major parts: the core with internal plug-ins, and the contributed plug-ins. You always need to build the core/internal parts before building the contrib part. &lt;br /&gt;
&lt;br /&gt;
To build the internal part, you can use the Code::Blocks project file which you can find at: &amp;lt;cbDir&amp;gt;\src\CodeBlocks.cbp. Our Code::Blocks master directory is from now one mentioned as &amp;lt;cbDir&amp;gt;, by the way. A workspace is something that groups several projects together. To build the contrib plug-ins, they can be found at &amp;lt;cbDir&amp;gt;\src\ContribPlugins.workspace.&lt;br /&gt;
&lt;br /&gt;
But, let's create a workspace containing everything. Let's put that workspace in the master directory &amp;lt;cbDir&amp;gt;. Just use a regular text editor and create a file with the name &amp;quot;CbProjects.workspace&amp;quot; and give it the following content : &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
 &amp;lt;CodeBlocks_workspace_file&amp;gt;&lt;br /&gt;
  &amp;lt;Workspace title=&amp;quot;Workspace&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\CodeBlocks.cbp&amp;quot; active=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\AutoVersioning\AutoVersioning.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\BrowseTracker\BrowseTracker.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\byogames\byogames.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\cb_koders\cb_koders.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\codesnippets\codesnippets.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\codestat\codestat.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\copystrings\copystrings.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\devpak_plugin\DevPakPlugin.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\dragscroll\dragscroll.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\envvars\envvars.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\headerfixup\headerfixup.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\help_plugin\help-plugin.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\keybinder\keybinder.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\profiler\cbprofiler.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\regex_testbed\RegExTestbed.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\source_exporter\Exporter.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\symtab\symtab.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\ThreadSearch\ThreadSearch.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\wxSmith\wxSmith.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\wxSmithContribItems\wxSmithContribItems.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\wxSmithAui\wxSmithAui.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\lib_finder\lib_finder.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\HexEditor\HexEditor-win.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\tools\cb_share_config\cb_share_config.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\IncrementalSearch\IncrementalSearch.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;Project filename=&amp;quot;src\plugins\contrib\MouseSap\MouseSap.cbp&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/Workspace&amp;gt;&lt;br /&gt;
 &amp;lt;/CodeBlocks_workspace_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will use this workspace to build all of Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
== Building Code::Blocks ==&lt;br /&gt;
Finally we have arrived at the final step; our final goal. Run the Code::Blocks executable from your nightly build download. Choose Open from the File menu and browse for our above created workspace, and open it up. Be a little patient while Code::Blocks is parsing everything, and Code::Blocks will ask us for 2 global variables, these global variables will tell the nightly Code::Blocks where it can find wxWidgets (remember : header files and import libraries) and where it can find .... Code::Blocks, this is needed for the contrib plug-ins, they need to know (as for any user created plug-in) where the sdk (Code::Blocks header files) are.&lt;br /&gt;
These are the values in our case : &lt;br /&gt;
 - wx : &amp;lt;wxDir&amp;gt;&lt;br /&gt;
 - Code::Blocks (cb) : &amp;lt;cbDir&amp;gt;\src&lt;br /&gt;
&lt;br /&gt;
Now go to the Project Menu and choose (re)build workspace, and off you go. Watch how Code::Blocks is building Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
Once the build is complete, open up a console in &amp;lt;cbDir&amp;gt;\src and run the command &amp;quot;update.bat&amp;quot;. This will transfer all built deliverables from &amp;lt;cbDir&amp;gt;\src\devel to &amp;lt;cbDir&amp;gt;\src\output. In addition, it will strip out all debugging symbols. This step is very important - never ever forget it. &lt;br /&gt;
&lt;br /&gt;
Now you can copy the wx dll in both that output and the devel directory.&lt;br /&gt;
&lt;br /&gt;
Then you can close Code::Blocks. That was the downloaded nightly remember?&lt;br /&gt;
&lt;br /&gt;
Time to test it. In the output directory, start up the CodeBlocks.exe. If everything went well, you'll have your very own home-built Code::Blocks running.&lt;br /&gt;
&lt;br /&gt;
Enjoy !!!&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6407</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6407"/>
		<updated>2010-07-22T09:06:19Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also want these tests to run very quickly. That way we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks to this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered. Write a unit test to reproduce the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is the framework. We will build to framework into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a given year is a leap year or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless it can be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 5 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 4 source files, in case you use the wizard you have to add the LeapYear.h/cpp and LeapYearTest.cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYearTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added that will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in a nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The test fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compile the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file of our LeapYear.h header, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh ! That's because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build it, run it. Yes, we have one working test.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Does anyone have the feeling we are cheating? Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing test occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Increase the user experience ==&lt;br /&gt;
There are a few areas where we can increase the user experience.&lt;br /&gt;
When a unit test fails the framework tell use on which line in the the code his happens.&lt;br /&gt;
That's excellent.&lt;br /&gt;
BUT we see this information in a console/shell windows. So we need to find that window, read the issues, remember them and then go find our test source files and navigate manually to the offending line. This works but is very cumbersome.&lt;br /&gt;
We want this to be a no-brainer, and have these steps being carried out for us.&lt;br /&gt;
&lt;br /&gt;
Well, didn't we say life is great, Code::Blocks and UnitTest++ to the rescue. The error/warning output of the framework is in the gcc format. That means Code::Blocks can parse it.&lt;br /&gt;
One restriction Code::Blocks can parse it during the 'build process'. But currently the build process stops after the unit test executable is built, and only then we run the test executable (manually).&lt;br /&gt;
Solution have Code::Blocks run the test executable as a post-build step. Pre-build and post-build steps are part of the build process !&lt;br /&gt;
Important consequence : if you want to debug something, the debugger will only kick off after Code::Blocks was able to carry out a successful build (including the pre/post builds steps). Therefor it is not wise to have the unit test executable being carried out as a post-build step of the 'Debug' target. But as a post-build step of the Release target, our goal is met.&lt;br /&gt;
&lt;br /&gt;
Adjust the target settings for the 'Release' target [Build Options -&amp;gt; select Release target -&amp;gt; Pre/Post-build steps -&amp;gt; Post-build steps text field] and add the following '''$exe_output'''. you can tick the 'Always execute' if you want.&lt;br /&gt;
&lt;br /&gt;
Now build your Release target, and look at what shows up in the 'Build Log' tab in Code::Blocks.&lt;br /&gt;
This is my output : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 25.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear.cpp -o Deliv/Release/LeapYear.o&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[ 75.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/main.cpp -o Deliv/Release/main.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
Success: 4 tests passed.&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 0 (0 minutes, 2 seconds)&lt;br /&gt;
0 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We see that the unit test has been carried out, automatically.&lt;br /&gt;
&lt;br /&gt;
Let's demonstrate that upon a failed test, Code::Blocks will jump to the offending line.&lt;br /&gt;
Change the latest test, the one checking on the year 2000 : change 2000 to 2001.&lt;br /&gt;
And build : Code::Blocks will jump to the offending line, and shows an entry in the &amp;quot;Build messages&amp;quot; tab (error: Failure in DivisableBy400: Expected 1 but was 0), just like for a regular compiler warning/error.&lt;br /&gt;
In the &amp;quot;Build&amp;quot; tab, we now find something like (red colored since it is an error) :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
/home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp:28: error: Failure in DivisableBy400: Expected 1 but was 0&lt;br /&gt;
FAILURE: 1 out of 4 tests failed (1 failures).&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 1 (0 minutes, 1 seconds)&lt;br /&gt;
1 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Voila, we have increased the user experience.&lt;br /&gt;
Time to readjust the final test, 2001 becomes 2000 again ;-)&lt;br /&gt;
&lt;br /&gt;
== Further automation ==&lt;br /&gt;
You can create a script that calls Code::Blocks on the command line and passes it our LeapYear.cbp project file, and it will build both targets (Debug/Release) and run the test, since it is a post-build step for the 'Release' target.&lt;br /&gt;
Bye bye funky makefiles, welcome Code::Blocks as your build system.&lt;br /&gt;
&lt;br /&gt;
== More to come ==&lt;br /&gt;
More examples will be added, showcasing 'fixtures' (setup/teardown), some more CHECK macros of UnitTest++. In case you have some tips/ideas, drop me a PM in the forum.&lt;br /&gt;
On the planning is a full conversion of the Money example, but all with gcc and Code::Blocks instead of the crazy Microsoft IDE.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6406</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6406"/>
		<updated>2010-07-22T09:03:45Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* Why Unit Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also want these tests to run very quickly. That way we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks to this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered. Write a unit test to reproduce the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is the framework. We will build to framework into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a given year is a leap year or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless it can be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 5 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 4 source files, in case you use the wizard you have to add the LeapYear.h/cpp and LeapYearTest.cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYearTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added that will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in a nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The test fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compile the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file of our LeapYear.h header, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build it, run it. Yes, we have one working test.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Does anyone have the feeling we are cheating? Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing test occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Increase the user experience ==&lt;br /&gt;
There are a few areas where we can increase the user experience.&lt;br /&gt;
When a unit test fails the framework tell use on which line in the the code his happens.&lt;br /&gt;
That's excellent.&lt;br /&gt;
BUT we see this information in a console/shell windows. So we need to find that window, read the issues, remember them and then go find our test source files and navigate manually to the offending line. This works but is very cumbersome.&lt;br /&gt;
We want this to be a no-brainer, and have these steps being carried out for us.&lt;br /&gt;
&lt;br /&gt;
Well, didn't we say life is great, Code::Blocks and UnitTest++ to the rescue. The error/warning output of the framework is in the gcc format. That means Code::Blocks can parse it.&lt;br /&gt;
One restriction Code::Blocks can parse it during the 'build process'. But currently the build process stops after the unit test executable is built, and only then we run the test executable (manually).&lt;br /&gt;
Solution have Code::Blocks run the test executable as a post-build step. Pre-build and post-build steps are part of the build process !&lt;br /&gt;
Important consequence : if you want to debug something, the debugger will only kick off after Code::Blocks was able to carry out a successful build (including the pre/post builds steps). Therefor it is not wise to have the unit test executable being carried out as a post-build step of the 'Debug' target. But as a post-build step of the Release target, our goal is met.&lt;br /&gt;
&lt;br /&gt;
Adjust the target settings for the 'Release' target [Build Options -&amp;gt; select Release target -&amp;gt; Pre/Post-build steps -&amp;gt; Post-build steps text field] and add the following '''$exe_output'''. you can tick the 'Always execute' if you want.&lt;br /&gt;
&lt;br /&gt;
Now build your Release target, and look at what shows up in the 'Build Log' tab in Code::Blocks.&lt;br /&gt;
This is my output : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 25.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear.cpp -o Deliv/Release/LeapYear.o&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[ 75.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/main.cpp -o Deliv/Release/main.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
Success: 4 tests passed.&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 0 (0 minutes, 2 seconds)&lt;br /&gt;
0 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We see that the unit test has been carried out, automatically.&lt;br /&gt;
&lt;br /&gt;
Let's demonstrate that upon a failed test, Code::Blocks will jump to the offending line.&lt;br /&gt;
Change the latest test, the one checking on the year 2000 : change 2000 to 2001.&lt;br /&gt;
And build : Code::Blocks will jump to the offending line, and shows an entry in the &amp;quot;Build messages&amp;quot; tab (error: Failure in DivisableBy400: Expected 1 but was 0), just like for a regular compiler warning/error.&lt;br /&gt;
In the &amp;quot;Build&amp;quot; tab, we now find something like (red colored since it is an error) :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
/home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp:28: error: Failure in DivisableBy400: Expected 1 but was 0&lt;br /&gt;
FAILURE: 1 out of 4 tests failed (1 failures).&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 1 (0 minutes, 1 seconds)&lt;br /&gt;
1 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Voila, we have increased the user experience.&lt;br /&gt;
Time to readjust the final test, 2001 becomes 2000 again ;-)&lt;br /&gt;
&lt;br /&gt;
== Further automation ==&lt;br /&gt;
You can create a script that calls Code::Blocks on the command line and passes it our LeapYear.cbp project file, and it will build both targets (Debug/Release) and run the test, since it is a post-build step for the 'Release' target.&lt;br /&gt;
Bye bye funky makefiles, welcome Code::Blocks as your build system.&lt;br /&gt;
&lt;br /&gt;
== More to come ==&lt;br /&gt;
More examples will be added, showcasing 'fixtures' (setup/teardown), some more CHECK macros of UnitTest++. In case you have some tips/ideas, drop me a PM in the forum.&lt;br /&gt;
On the planning is a full conversion of the Money example, but all with gcc and Code::Blocks instead of the crazy Microsoft IDE.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6405</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6405"/>
		<updated>2010-07-22T09:02:55Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step3 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That way we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks to this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered. Write a unit test to reproduce the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is the framework. We will build to framework into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a given year is a leap year or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless it can be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 5 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 4 source files, in case you use the wizard you have to add the LeapYear.h/cpp and LeapYearTest.cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYearTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added that will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in a nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The test fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compile the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file of our LeapYear.h header, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build it, run it. Yes, we have one working test.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Does anyone have the feeling we are cheating? Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing test occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Increase the user experience ==&lt;br /&gt;
There are a few areas where we can increase the user experience.&lt;br /&gt;
When a unit test fails the framework tell use on which line in the the code his happens.&lt;br /&gt;
That's excellent.&lt;br /&gt;
BUT we see this information in a console/shell windows. So we need to find that window, read the issues, remember them and then go find our test source files and navigate manually to the offending line. This works but is very cumbersome.&lt;br /&gt;
We want this to be a no-brainer, and have these steps being carried out for us.&lt;br /&gt;
&lt;br /&gt;
Well, didn't we say life is great, Code::Blocks and UnitTest++ to the rescue. The error/warning output of the framework is in the gcc format. That means Code::Blocks can parse it.&lt;br /&gt;
One restriction Code::Blocks can parse it during the 'build process'. But currently the build process stops after the unit test executable is built, and only then we run the test executable (manually).&lt;br /&gt;
Solution have Code::Blocks run the test executable as a post-build step. Pre-build and post-build steps are part of the build process !&lt;br /&gt;
Important consequence : if you want to debug something, the debugger will only kick off after Code::Blocks was able to carry out a successful build (including the pre/post builds steps). Therefor it is not wise to have the unit test executable being carried out as a post-build step of the 'Debug' target. But as a post-build step of the Release target, our goal is met.&lt;br /&gt;
&lt;br /&gt;
Adjust the target settings for the 'Release' target [Build Options -&amp;gt; select Release target -&amp;gt; Pre/Post-build steps -&amp;gt; Post-build steps text field] and add the following '''$exe_output'''. you can tick the 'Always execute' if you want.&lt;br /&gt;
&lt;br /&gt;
Now build your Release target, and look at what shows up in the 'Build Log' tab in Code::Blocks.&lt;br /&gt;
This is my output : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 25.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear.cpp -o Deliv/Release/LeapYear.o&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[ 75.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/main.cpp -o Deliv/Release/main.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
Success: 4 tests passed.&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 0 (0 minutes, 2 seconds)&lt;br /&gt;
0 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We see that the unit test has been carried out, automatically.&lt;br /&gt;
&lt;br /&gt;
Let's demonstrate that upon a failed test, Code::Blocks will jump to the offending line.&lt;br /&gt;
Change the latest test, the one checking on the year 2000 : change 2000 to 2001.&lt;br /&gt;
And build : Code::Blocks will jump to the offending line, and shows an entry in the &amp;quot;Build messages&amp;quot; tab (error: Failure in DivisableBy400: Expected 1 but was 0), just like for a regular compiler warning/error.&lt;br /&gt;
In the &amp;quot;Build&amp;quot; tab, we now find something like (red colored since it is an error) :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
/home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp:28: error: Failure in DivisableBy400: Expected 1 but was 0&lt;br /&gt;
FAILURE: 1 out of 4 tests failed (1 failures).&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 1 (0 minutes, 1 seconds)&lt;br /&gt;
1 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Voila, we have increased the user experience.&lt;br /&gt;
Time to readjust the final test, 2001 becomes 2000 again ;-)&lt;br /&gt;
&lt;br /&gt;
== Further automation ==&lt;br /&gt;
You can create a script that calls Code::Blocks on the command line and passes it our LeapYear.cbp project file, and it will build both targets (Debug/Release) and run the test, since it is a post-build step for the 'Release' target.&lt;br /&gt;
Bye bye funky makefiles, welcome Code::Blocks as your build system.&lt;br /&gt;
&lt;br /&gt;
== More to come ==&lt;br /&gt;
More examples will be added, showcasing 'fixtures' (setup/teardown), some more CHECK macros of UnitTest++. In case you have some tips/ideas, drop me a PM in the forum.&lt;br /&gt;
On the planning is a full conversion of the Money example, but all with gcc and Code::Blocks instead of the crazy Microsoft IDE.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6404</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6404"/>
		<updated>2010-07-22T09:02:08Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* Increase the user experience */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That way we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks to this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered. Write a unit test to reproduce the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is the framework. We will build to framework into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a given year is a leap year or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless it can be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 5 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 4 source files, in case you use the wizard you have to add the LeapYear.h/cpp and LeapYearTest.cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYearTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added that will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in a nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The test fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compile the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file of our LeapYear.h header, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build it, run it. Yes, we have one working test.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing test occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Increase the user experience ==&lt;br /&gt;
There are a few areas where we can increase the user experience.&lt;br /&gt;
When a unit test fails the framework tell use on which line in the the code his happens.&lt;br /&gt;
That's excellent.&lt;br /&gt;
BUT we see this information in a console/shell windows. So we need to find that window, read the issues, remember them and then go find our test source files and navigate manually to the offending line. This works but is very cumbersome.&lt;br /&gt;
We want this to be a no-brainer, and have these steps being carried out for us.&lt;br /&gt;
&lt;br /&gt;
Well, didn't we say life is great, Code::Blocks and UnitTest++ to the rescue. The error/warning output of the framework is in the gcc format. That means Code::Blocks can parse it.&lt;br /&gt;
One restriction Code::Blocks can parse it during the 'build process'. But currently the build process stops after the unit test executable is built, and only then we run the test executable (manually).&lt;br /&gt;
Solution have Code::Blocks run the test executable as a post-build step. Pre-build and post-build steps are part of the build process !&lt;br /&gt;
Important consequence : if you want to debug something, the debugger will only kick off after Code::Blocks was able to carry out a successful build (including the pre/post builds steps). Therefor it is not wise to have the unit test executable being carried out as a post-build step of the 'Debug' target. But as a post-build step of the Release target, our goal is met.&lt;br /&gt;
&lt;br /&gt;
Adjust the target settings for the 'Release' target [Build Options -&amp;gt; select Release target -&amp;gt; Pre/Post-build steps -&amp;gt; Post-build steps text field] and add the following '''$exe_output'''. you can tick the 'Always execute' if you want.&lt;br /&gt;
&lt;br /&gt;
Now build your Release target, and look at what shows up in the 'Build Log' tab in Code::Blocks.&lt;br /&gt;
This is my output : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 25.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear.cpp -o Deliv/Release/LeapYear.o&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[ 75.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/main.cpp -o Deliv/Release/main.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
Success: 4 tests passed.&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 0 (0 minutes, 2 seconds)&lt;br /&gt;
0 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We see that the unit test has been carried out, automatically.&lt;br /&gt;
&lt;br /&gt;
Let's demonstrate that upon a failed test, Code::Blocks will jump to the offending line.&lt;br /&gt;
Change the latest test, the one checking on the year 2000 : change 2000 to 2001.&lt;br /&gt;
And build : Code::Blocks will jump to the offending line, and shows an entry in the &amp;quot;Build messages&amp;quot; tab (error: Failure in DivisableBy400: Expected 1 but was 0), just like for a regular compiler warning/error.&lt;br /&gt;
In the &amp;quot;Build&amp;quot; tab, we now find something like (red colored since it is an error) :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
/home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp:28: error: Failure in DivisableBy400: Expected 1 but was 0&lt;br /&gt;
FAILURE: 1 out of 4 tests failed (1 failures).&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 1 (0 minutes, 1 seconds)&lt;br /&gt;
1 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Voila, we have increased the user experience.&lt;br /&gt;
Time to readjust the final test, 2001 becomes 2000 again ;-)&lt;br /&gt;
&lt;br /&gt;
== Further automation ==&lt;br /&gt;
You can create a script that calls Code::Blocks on the command line and passes it our LeapYear.cbp project file, and it will build both targets (Debug/Release) and run the test, since it is a post-build step for the 'Release' target.&lt;br /&gt;
Bye bye funky makefiles, welcome Code::Blocks as your build system.&lt;br /&gt;
&lt;br /&gt;
== More to come ==&lt;br /&gt;
More examples will be added, showcasing 'fixtures' (setup/teardown), some more CHECK macros of UnitTest++. In case you have some tips/ideas, drop me a PM in the forum.&lt;br /&gt;
On the planning is a full conversion of the Money example, but all with gcc and Code::Blocks instead of the crazy Microsoft IDE.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6108</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6108"/>
		<updated>2009-09-09T19:53:34Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* Increase the user experience */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That way we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks to this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered. Write a unit test to reproduce the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is the framework. We will build to framework into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a given year is a leap year or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless it can be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 5 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 4 source files, in case you use the wizard you have to add the LeapYear.h/cpp and LeapYearTest.cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYearTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added that will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in a nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The test fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compile the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file of our LeapYear.h header, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build it, run it. Yes, we have one working test.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing test occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Increase the user experience ==&lt;br /&gt;
There are a few areas where we can increase the user experience.&lt;br /&gt;
When a unit test fails the framework tell use on which line in the the code his happens.&lt;br /&gt;
That's excellent.&lt;br /&gt;
BUT we see this information in a console/shell windows. So we need to find that window, read the issues, remember them and then go find our test source files and navigate manually to the offending line. This works but is very cumbersome.&lt;br /&gt;
We want this to be a no-brainer, and have these steps being carried out for us.&lt;br /&gt;
&lt;br /&gt;
Well, didn't we say life is great, Code::Blocks and UnitTest++ to the rescue. The error/warning output of the framework is in the gcc format. That means Code::Blocks can parse it.&lt;br /&gt;
One restriction Code::Blocks can parse it during the 'build process'. But currently the build process stops after the unit test executable is build, and only then we run the test executable (manually).&lt;br /&gt;
Solution have Code::Blocks run the test executable as a post-build step. Pre-build and post-build steps are part of the build process !&lt;br /&gt;
Important consequence : if you want to debug something, the debugger will only kick off after Code::Blocks was able to carry out a successful build (including the pre/post builds steps). Therefor it is not wise to have the unit test executable being carried out as a post-build step of the 'Debug' target. But as a post-build step of the Release target, our goal is met.&lt;br /&gt;
&lt;br /&gt;
Adjust the target settings for the 'Release' target [Build Options -&amp;gt; select Release target -&amp;gt; Pre/Post-build steps -&amp;gt; Post-build steps text field] and add the following '''$exe_output'''. you can tick the 'Always execute' if you want.&lt;br /&gt;
&lt;br /&gt;
Now build your Release target, and look at what shows up in the 'Build Log' tab in Code::Blocks.&lt;br /&gt;
This is my output : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 25.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear.cpp -o Deliv/Release/LeapYear.o&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[ 75.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/main.cpp -o Deliv/Release/main.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
Success: 4 tests passed.&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 0 (0 minutes, 2 seconds)&lt;br /&gt;
0 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We see that the unit test has been carried out, automatically.&lt;br /&gt;
&lt;br /&gt;
Let's demonstrate that upon a failed test, Code::Blocks will jump to the offending line.&lt;br /&gt;
Change the latest test, the one checking on the year 2000 : change 2000 to 2001.&lt;br /&gt;
And build : Code::Blocks will jump to the offending line, and shows an entry in the &amp;quot;Build messages&amp;quot; tab (error: Failure in DivisableBy400: Expected 1 but was 0), just like for a regular compiler warning/error.&lt;br /&gt;
In the &amp;quot;Build&amp;quot; tab, we now find something like (red colored since it is an error) :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
/home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp:28: error: Failure in DivisableBy400: Expected 1 but was 0&lt;br /&gt;
FAILURE: 1 out of 4 tests failed (1 failures).&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 1 (0 minutes, 1 seconds)&lt;br /&gt;
1 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Voila, we have increased the user experience.&lt;br /&gt;
Time to readjust the final test, 2001 becomes 2000 again ;-)&lt;br /&gt;
&lt;br /&gt;
== Further automation ==&lt;br /&gt;
You can create a script that calls Code::Blocks on the command line and passes it our LeapYear.cbp project file, and it will build both targets (Debug/Release) and run the test, since it is a post-build step for the 'Release' target.&lt;br /&gt;
Bye bye funky makefiles, welcome Code::Blocks as your build system.&lt;br /&gt;
&lt;br /&gt;
== More to come ==&lt;br /&gt;
More examples will be added, showcasing 'fixtures' (setup/teardown), some more CHECK macros of UnitTest++. In case you have some tips/ideas, drop me a PM in the forum.&lt;br /&gt;
On the planning is a full conversion of the Money example, but all with gcc and Code::Blocks instead of the crazy Microsoft IDE.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6107</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6107"/>
		<updated>2009-09-09T19:51:00Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step3 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That way we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks to this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered. Write a unit test to reproduce the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is the framework. We will build to framework into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a given year is a leap year or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless it can be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 5 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 4 source files, in case you use the wizard you have to add the LeapYear.h/cpp and LeapYearTest.cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYearTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added that will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in a nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The test fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compile the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file of our LeapYear.h header, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build it, run it. Yes, we have one working test.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing test occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Increase the user experience ==&lt;br /&gt;
There are a few areas where we can increase the user experience.&lt;br /&gt;
When a unit test fails the framework tell use on which line in the the code his happens.&lt;br /&gt;
That's excellent.&lt;br /&gt;
BUT we see this information in a console/shell windows. So we need to find that window, read the issues, remember them and then go find our test source files and navigate manually to the offending line. This works but is very cumbersome.&lt;br /&gt;
We want this to be a no-brainer, and have these steps being carried out for us.&lt;br /&gt;
&lt;br /&gt;
Well, didn't we say life is great, Code::Blocks and UnitTest+= to the rescue. The error/warning output of the framework is in the gcc format. That means Code::Blocks can parse it.&lt;br /&gt;
One restriction Code::Blocks can parse it during the 'build process'. But currently the build procss stops after the unit test executable is build, and only then we run the test executable (manually).&lt;br /&gt;
Solution have Code::Blocks run the test executable as a post-build step. Pre-build and post-build steps are part of the build process !&lt;br /&gt;
Important consequence : if you want to debug something, the debugger will only kick off after Code::Blocks was able to carry out a successful build (including the pre/post builds steps). Therefor it is not wise to have the unit test executable being carried out as a post-bild step of the 'Debug' target. But as a post-build step of the Release target, our goal is met.&lt;br /&gt;
&lt;br /&gt;
Adjust the target settings for the 'Release' target [Build Options -&amp;gt; select Release target -&amp;gt; Pre/Post-build steps -&amp;gt; Post-build steps text field] and add the following '''$exe_output'''. you can tick the 'Always execute' if you want.&lt;br /&gt;
&lt;br /&gt;
Now build your Release target, and look at what shows up in the 'Build Log' tab in Code::Blocks.&lt;br /&gt;
This is my output : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 25.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear.cpp -o Deliv/Release/LeapYear.o&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[ 75.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/main.cpp -o Deliv/Release/main.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
Success: 4 tests passed.&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 0 (0 minutes, 2 seconds)&lt;br /&gt;
0 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We see that the unit test has been carried out, automatically.&lt;br /&gt;
&lt;br /&gt;
Let's demonstrate that upon a failed test, Code::Blocks will jump to the offending line.&lt;br /&gt;
Change the latest test, the one checking on the year 2000 : change 2000 to 2001.&lt;br /&gt;
And build : Code::Blocks will jump to the offending line, and shows an entry in the &amp;quot;Build messages&amp;quot; tab (error: Failure in DivisableBy400: Expected 1 but was 0), just like for a regular compiler warning/error.&lt;br /&gt;
In the &amp;quot;Build&amp;quot; tab, we now find something like (red colored since it is an error) :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
/home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp:28: error: Failure in DivisableBy400: Expected 1 but was 0&lt;br /&gt;
FAILURE: 1 out of 4 tests failed (1 failures).&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 1 (0 minutes, 1 seconds)&lt;br /&gt;
1 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Voila, we have increased the user experience.&lt;br /&gt;
Time to readjust the final test, 2001 becomes 2000 again ;-)&lt;br /&gt;
&lt;br /&gt;
== Further automation ==&lt;br /&gt;
You can create a script that calls Code::Blocks on the command line and passes it our LeapYear.cbp project file, and it will build both targets (Debug/Release) and run the test, since it is a post-build step for the 'Release' target.&lt;br /&gt;
Bye bye funky makefiles, welcome Code::Blocks as your build system.&lt;br /&gt;
&lt;br /&gt;
== More to come ==&lt;br /&gt;
More examples will be added, showcasing 'fixtures' (setup/teardown), some more CHECK macros of UnitTest++. In case you have some tips/ideas, drop me a PM in the forum.&lt;br /&gt;
On the planning is a full conversion of the Money example, but all with gcc and Code::Blocks instead of the crazy Microsoft IDE.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6106</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6106"/>
		<updated>2009-09-09T19:49:46Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That way we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks to this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered. Write a unit test to reproduce the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is the framework. We will build to framework into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a given year is a leap year or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless it can be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 5 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 4 source files, in case you use the wizard you have to add the LeapYear.h/cpp and LeapYearTest.cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYearTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added that will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in a nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The test fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compile the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file of our LeapYear.h header, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build it, run it. Yes, we have one working test.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Increase the user experience ==&lt;br /&gt;
There are a few areas where we can increase the user experience.&lt;br /&gt;
When a unit test fails the framework tell use on which line in the the code his happens.&lt;br /&gt;
That's excellent.&lt;br /&gt;
BUT we see this information in a console/shell windows. So we need to find that window, read the issues, remember them and then go find our test source files and navigate manually to the offending line. This works but is very cumbersome.&lt;br /&gt;
We want this to be a no-brainer, and have these steps being carried out for us.&lt;br /&gt;
&lt;br /&gt;
Well, didn't we say life is great, Code::Blocks and UnitTest+= to the rescue. The error/warning output of the framework is in the gcc format. That means Code::Blocks can parse it.&lt;br /&gt;
One restriction Code::Blocks can parse it during the 'build process'. But currently the build procss stops after the unit test executable is build, and only then we run the test executable (manually).&lt;br /&gt;
Solution have Code::Blocks run the test executable as a post-build step. Pre-build and post-build steps are part of the build process !&lt;br /&gt;
Important consequence : if you want to debug something, the debugger will only kick off after Code::Blocks was able to carry out a successful build (including the pre/post builds steps). Therefor it is not wise to have the unit test executable being carried out as a post-bild step of the 'Debug' target. But as a post-build step of the Release target, our goal is met.&lt;br /&gt;
&lt;br /&gt;
Adjust the target settings for the 'Release' target [Build Options -&amp;gt; select Release target -&amp;gt; Pre/Post-build steps -&amp;gt; Post-build steps text field] and add the following '''$exe_output'''. you can tick the 'Always execute' if you want.&lt;br /&gt;
&lt;br /&gt;
Now build your Release target, and look at what shows up in the 'Build Log' tab in Code::Blocks.&lt;br /&gt;
This is my output : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 25.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear.cpp -o Deliv/Release/LeapYear.o&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[ 75.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/main.cpp -o Deliv/Release/main.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
Success: 4 tests passed.&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 0 (0 minutes, 2 seconds)&lt;br /&gt;
0 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We see that the unit test has been carried out, automatically.&lt;br /&gt;
&lt;br /&gt;
Let's demonstrate that upon a failed test, Code::Blocks will jump to the offending line.&lt;br /&gt;
Change the latest test, the one checking on the year 2000 : change 2000 to 2001.&lt;br /&gt;
And build : Code::Blocks will jump to the offending line, and shows an entry in the &amp;quot;Build messages&amp;quot; tab (error: Failure in DivisableBy400: Expected 1 but was 0), just like for a regular compiler warning/error.&lt;br /&gt;
In the &amp;quot;Build&amp;quot; tab, we now find something like (red colored since it is an error) :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
/home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp:28: error: Failure in DivisableBy400: Expected 1 but was 0&lt;br /&gt;
FAILURE: 1 out of 4 tests failed (1 failures).&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 1 (0 minutes, 1 seconds)&lt;br /&gt;
1 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Voila, we have increased the user experience.&lt;br /&gt;
Time to readjust the final test, 2001 becomes 2000 again ;-)&lt;br /&gt;
&lt;br /&gt;
== Further automation ==&lt;br /&gt;
You can create a script that calls Code::Blocks on the command line and passes it our LeapYear.cbp project file, and it will build both targets (Debug/Release) and run the test, since it is a post-build step for the 'Release' target.&lt;br /&gt;
Bye bye funky makefiles, welcome Code::Blocks as your build system.&lt;br /&gt;
&lt;br /&gt;
== More to come ==&lt;br /&gt;
More examples will be added, showcasing 'fixtures' (setup/teardown), some more CHECK macros of UnitTest++. In case you have some tips/ideas, drop me a PM in the forum.&lt;br /&gt;
On the planning is a full conversion of the Money example, but all with gcc and Code::Blocks instead of the crazy Microsoft IDE.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6105</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6105"/>
		<updated>2009-09-09T19:42:19Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* Test Driven Development */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That way we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks to this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered. Write a unit test to reproduce the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is the framework. We will build to framework into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a given year is a leap year or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless it can be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 5 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 4 source files, in case you use the wizard you have to add the LeapYear.h/cpp and LeapYearTest.cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYearTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added that will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Increase the user experience ==&lt;br /&gt;
There are a few areas where we can increase the user experience.&lt;br /&gt;
When a unit test fails the framework tell use on which line in the the code his happens.&lt;br /&gt;
That's excellent.&lt;br /&gt;
BUT we see this information in a console/shell windows. So we need to find that window, read the issues, remember them and then go find our test source files and navigate manually to the offending line. This works but is very cumbersome.&lt;br /&gt;
We want this to be a no-brainer, and have these steps being carried out for us.&lt;br /&gt;
&lt;br /&gt;
Well, didn't we say life is great, Code::Blocks and UnitTest+= to the rescue. The error/warning output of the framework is in the gcc format. That means Code::Blocks can parse it.&lt;br /&gt;
One restriction Code::Blocks can parse it during the 'build process'. But currently the build procss stops after the unit test executable is build, and only then we run the test executable (manually).&lt;br /&gt;
Solution have Code::Blocks run the test executable as a post-build step. Pre-build and post-build steps are part of the build process !&lt;br /&gt;
Important consequence : if you want to debug something, the debugger will only kick off after Code::Blocks was able to carry out a successful build (including the pre/post builds steps). Therefor it is not wise to have the unit test executable being carried out as a post-bild step of the 'Debug' target. But as a post-build step of the Release target, our goal is met.&lt;br /&gt;
&lt;br /&gt;
Adjust the target settings for the 'Release' target [Build Options -&amp;gt; select Release target -&amp;gt; Pre/Post-build steps -&amp;gt; Post-build steps text field] and add the following '''$exe_output'''. you can tick the 'Always execute' if you want.&lt;br /&gt;
&lt;br /&gt;
Now build your Release target, and look at what shows up in the 'Build Log' tab in Code::Blocks.&lt;br /&gt;
This is my output : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 25.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear.cpp -o Deliv/Release/LeapYear.o&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[ 75.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/main.cpp -o Deliv/Release/main.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
Success: 4 tests passed.&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 0 (0 minutes, 2 seconds)&lt;br /&gt;
0 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We see that the unit test has been carried out, automatically.&lt;br /&gt;
&lt;br /&gt;
Let's demonstrate that upon a failed test, Code::Blocks will jump to the offending line.&lt;br /&gt;
Change the latest test, the one checking on the year 2000 : change 2000 to 2001.&lt;br /&gt;
And build : Code::Blocks will jump to the offending line, and shows an entry in the &amp;quot;Build messages&amp;quot; tab (error: Failure in DivisableBy400: Expected 1 but was 0), just like for a regular compiler warning/error.&lt;br /&gt;
In the &amp;quot;Build&amp;quot; tab, we now find something like (red colored since it is an error) :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
/home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp:28: error: Failure in DivisableBy400: Expected 1 but was 0&lt;br /&gt;
FAILURE: 1 out of 4 tests failed (1 failures).&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 1 (0 minutes, 1 seconds)&lt;br /&gt;
1 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Voila, we have increased the user experience.&lt;br /&gt;
Time to readjust the final test, 2001 becomes 2000 again ;-)&lt;br /&gt;
&lt;br /&gt;
== Further automation ==&lt;br /&gt;
You can create a script that calls Code::Blocks on the command line and passes it our LeapYear.cbp project file, and it will build both targets (Debug/Release) and run the test, since it is a post-build step for the 'Release' target.&lt;br /&gt;
Bye bye funky makefiles, welcome Code::Blocks as your build system.&lt;br /&gt;
&lt;br /&gt;
== More to come ==&lt;br /&gt;
More examples will be added, showcasing 'fixtures' (setup/teardown), some more CHECK macros of UnitTest++. In case you have some tips/ideas, drop me a PM in the forum.&lt;br /&gt;
On the planning is a full conversion of the Money example, but all with gcc and Code::Blocks instead of the crazy Microsoft IDE.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6104</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6104"/>
		<updated>2009-09-09T19:39:10Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* Our first test project environment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That way we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks to this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered. Write a unit test to reproduce the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is the framework. We will build to framework into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a given year is a leap year or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless it can be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 5 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 4 source files, in case you use the wizard you have to add the LeapYear.h/cpp and LeapYearTest.cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYearTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Increase the user experience ==&lt;br /&gt;
There are a few areas where we can increase the user experience.&lt;br /&gt;
When a unit test fails the framework tell use on which line in the the code his happens.&lt;br /&gt;
That's excellent.&lt;br /&gt;
BUT we see this information in a console/shell windows. So we need to find that window, read the issues, remember them and then go find our test source files and navigate manually to the offending line. This works but is very cumbersome.&lt;br /&gt;
We want this to be a no-brainer, and have these steps being carried out for us.&lt;br /&gt;
&lt;br /&gt;
Well, didn't we say life is great, Code::Blocks and UnitTest+= to the rescue. The error/warning output of the framework is in the gcc format. That means Code::Blocks can parse it.&lt;br /&gt;
One restriction Code::Blocks can parse it during the 'build process'. But currently the build procss stops after the unit test executable is build, and only then we run the test executable (manually).&lt;br /&gt;
Solution have Code::Blocks run the test executable as a post-build step. Pre-build and post-build steps are part of the build process !&lt;br /&gt;
Important consequence : if you want to debug something, the debugger will only kick off after Code::Blocks was able to carry out a successful build (including the pre/post builds steps). Therefor it is not wise to have the unit test executable being carried out as a post-bild step of the 'Debug' target. But as a post-build step of the Release target, our goal is met.&lt;br /&gt;
&lt;br /&gt;
Adjust the target settings for the 'Release' target [Build Options -&amp;gt; select Release target -&amp;gt; Pre/Post-build steps -&amp;gt; Post-build steps text field] and add the following '''$exe_output'''. you can tick the 'Always execute' if you want.&lt;br /&gt;
&lt;br /&gt;
Now build your Release target, and look at what shows up in the 'Build Log' tab in Code::Blocks.&lt;br /&gt;
This is my output : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 25.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear.cpp -o Deliv/Release/LeapYear.o&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[ 75.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/main.cpp -o Deliv/Release/main.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
Success: 4 tests passed.&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 0 (0 minutes, 2 seconds)&lt;br /&gt;
0 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We see that the unit test has been carried out, automatically.&lt;br /&gt;
&lt;br /&gt;
Let's demonstrate that upon a failed test, Code::Blocks will jump to the offending line.&lt;br /&gt;
Change the latest test, the one checking on the year 2000 : change 2000 to 2001.&lt;br /&gt;
And build : Code::Blocks will jump to the offending line, and shows an entry in the &amp;quot;Build messages&amp;quot; tab (error: Failure in DivisableBy400: Expected 1 but was 0), just like for a regular compiler warning/error.&lt;br /&gt;
In the &amp;quot;Build&amp;quot; tab, we now find something like (red colored since it is an error) :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
/home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp:28: error: Failure in DivisableBy400: Expected 1 but was 0&lt;br /&gt;
FAILURE: 1 out of 4 tests failed (1 failures).&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 1 (0 minutes, 1 seconds)&lt;br /&gt;
1 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Voila, we have increased the user experience.&lt;br /&gt;
Time to readjust the final test, 2001 becomes 2000 again ;-)&lt;br /&gt;
&lt;br /&gt;
== Further automation ==&lt;br /&gt;
You can create a script that calls Code::Blocks on the command line and passes it our LeapYear.cbp project file, and it will build both targets (Debug/Release) and run the test, since it is a post-build step for the 'Release' target.&lt;br /&gt;
Bye bye funky makefiles, welcome Code::Blocks as your build system.&lt;br /&gt;
&lt;br /&gt;
== More to come ==&lt;br /&gt;
More examples will be added, showcasing 'fixtures' (setup/teardown), some more CHECK macros of UnitTest++. In case you have some tips/ideas, drop me a PM in the forum.&lt;br /&gt;
On the planning is a full conversion of the Money example, but all with gcc and Code::Blocks instead of the crazy Microsoft IDE.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6103</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6103"/>
		<updated>2009-09-09T19:36:34Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* Build UnitTest++ */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That way we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks to this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered. Write a unit test to reproduce the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is the framework. We will build to framework into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a given year is a leap year or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless it can be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 5 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 5 source files, in case you use the wizard you have to add the LeapYear.h/cpp and LeapYearTest.cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYearTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Increase the user experience ==&lt;br /&gt;
There are a few areas where we can increase the user experience.&lt;br /&gt;
When a unit test fails the framework tell use on which line in the the code his happens.&lt;br /&gt;
That's excellent.&lt;br /&gt;
BUT we see this information in a console/shell windows. So we need to find that window, read the issues, remember them and then go find our test source files and navigate manually to the offending line. This works but is very cumbersome.&lt;br /&gt;
We want this to be a no-brainer, and have these steps being carried out for us.&lt;br /&gt;
&lt;br /&gt;
Well, didn't we say life is great, Code::Blocks and UnitTest+= to the rescue. The error/warning output of the framework is in the gcc format. That means Code::Blocks can parse it.&lt;br /&gt;
One restriction Code::Blocks can parse it during the 'build process'. But currently the build procss stops after the unit test executable is build, and only then we run the test executable (manually).&lt;br /&gt;
Solution have Code::Blocks run the test executable as a post-build step. Pre-build and post-build steps are part of the build process !&lt;br /&gt;
Important consequence : if you want to debug something, the debugger will only kick off after Code::Blocks was able to carry out a successful build (including the pre/post builds steps). Therefor it is not wise to have the unit test executable being carried out as a post-bild step of the 'Debug' target. But as a post-build step of the Release target, our goal is met.&lt;br /&gt;
&lt;br /&gt;
Adjust the target settings for the 'Release' target [Build Options -&amp;gt; select Release target -&amp;gt; Pre/Post-build steps -&amp;gt; Post-build steps text field] and add the following '''$exe_output'''. you can tick the 'Always execute' if you want.&lt;br /&gt;
&lt;br /&gt;
Now build your Release target, and look at what shows up in the 'Build Log' tab in Code::Blocks.&lt;br /&gt;
This is my output : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 25.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear.cpp -o Deliv/Release/LeapYear.o&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[ 75.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/main.cpp -o Deliv/Release/main.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
Success: 4 tests passed.&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 0 (0 minutes, 2 seconds)&lt;br /&gt;
0 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We see that the unit test has been carried out, automatically.&lt;br /&gt;
&lt;br /&gt;
Let's demonstrate that upon a failed test, Code::Blocks will jump to the offending line.&lt;br /&gt;
Change the latest test, the one checking on the year 2000 : change 2000 to 2001.&lt;br /&gt;
And build : Code::Blocks will jump to the offending line, and shows an entry in the &amp;quot;Build messages&amp;quot; tab (error: Failure in DivisableBy400: Expected 1 but was 0), just like for a regular compiler warning/error.&lt;br /&gt;
In the &amp;quot;Build&amp;quot; tab, we now find something like (red colored since it is an error) :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
/home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp:28: error: Failure in DivisableBy400: Expected 1 but was 0&lt;br /&gt;
FAILURE: 1 out of 4 tests failed (1 failures).&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 1 (0 minutes, 1 seconds)&lt;br /&gt;
1 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Voila, we have increased the user experience.&lt;br /&gt;
Time to readjust the final test, 2001 becomes 2000 again ;-)&lt;br /&gt;
&lt;br /&gt;
== Further automation ==&lt;br /&gt;
You can create a script that calls Code::Blocks on the command line and passes it our LeapYear.cbp project file, and it will build both targets (Debug/Release) and run the test, since it is a post-build step for the 'Release' target.&lt;br /&gt;
Bye bye funky makefiles, welcome Code::Blocks as your build system.&lt;br /&gt;
&lt;br /&gt;
== More to come ==&lt;br /&gt;
More examples will be added, showcasing 'fixtures' (setup/teardown), some more CHECK macros of UnitTest++. In case you have some tips/ideas, drop me a PM in the forum.&lt;br /&gt;
On the planning is a full conversion of the Money example, but all with gcc and Code::Blocks instead of the crazy Microsoft IDE.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6102</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6102"/>
		<updated>2009-09-09T19:25:55Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* Why Unit Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That way we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks to this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered. Write a unit test to reproduce the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 5 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 5 source files, in case you use the wizard you have to add the LeapYear.h/cpp and LeapYearTest.cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYearTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Increase the user experience ==&lt;br /&gt;
There are a few areas where we can increase the user experience.&lt;br /&gt;
When a unit test fails the framework tell use on which line in the the code his happens.&lt;br /&gt;
That's excellent.&lt;br /&gt;
BUT we see this information in a console/shell windows. So we need to find that window, read the issues, remember them and then go find our test source files and navigate manually to the offending line. This works but is very cumbersome.&lt;br /&gt;
We want this to be a no-brainer, and have these steps being carried out for us.&lt;br /&gt;
&lt;br /&gt;
Well, didn't we say life is great, Code::Blocks and UnitTest+= to the rescue. The error/warning output of the framework is in the gcc format. That means Code::Blocks can parse it.&lt;br /&gt;
One restriction Code::Blocks can parse it during the 'build process'. But currently the build procss stops after the unit test executable is build, and only then we run the test executable (manually).&lt;br /&gt;
Solution have Code::Blocks run the test executable as a post-build step. Pre-build and post-build steps are part of the build process !&lt;br /&gt;
Important consequence : if you want to debug something, the debugger will only kick off after Code::Blocks was able to carry out a successful build (including the pre/post builds steps). Therefor it is not wise to have the unit test executable being carried out as a post-bild step of the 'Debug' target. But as a post-build step of the Release target, our goal is met.&lt;br /&gt;
&lt;br /&gt;
Adjust the target settings for the 'Release' target [Build Options -&amp;gt; select Release target -&amp;gt; Pre/Post-build steps -&amp;gt; Post-build steps text field] and add the following '''$exe_output'''. you can tick the 'Always execute' if you want.&lt;br /&gt;
&lt;br /&gt;
Now build your Release target, and look at what shows up in the 'Build Log' tab in Code::Blocks.&lt;br /&gt;
This is my output : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 25.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear.cpp -o Deliv/Release/LeapYear.o&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[ 75.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/main.cpp -o Deliv/Release/main.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
Success: 4 tests passed.&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 0 (0 minutes, 2 seconds)&lt;br /&gt;
0 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We see that the unit test has been carried out, automatically.&lt;br /&gt;
&lt;br /&gt;
Let's demonstrate that upon a failed test, Code::Blocks will jump to the offending line.&lt;br /&gt;
Change the latest test, the one checking on the year 2000 : change 2000 to 2001.&lt;br /&gt;
And build : Code::Blocks will jump to the offending line, and shows an entry in the &amp;quot;Build messages&amp;quot; tab (error: Failure in DivisableBy400: Expected 1 but was 0), just like for a regular compiler warning/error.&lt;br /&gt;
In the &amp;quot;Build&amp;quot; tab, we now find something like (red colored since it is an error) :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
/home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp:28: error: Failure in DivisableBy400: Expected 1 but was 0&lt;br /&gt;
FAILURE: 1 out of 4 tests failed (1 failures).&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 1 (0 minutes, 1 seconds)&lt;br /&gt;
1 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Voila, we have increased the user experience.&lt;br /&gt;
Time to readjust the final test, 2001 becomes 2000 again ;-)&lt;br /&gt;
&lt;br /&gt;
== Further automation ==&lt;br /&gt;
You can create a script that calls Code::Blocks on the command line and passes it our LeapYear.cbp project file, and it will build both targets (Debug/Release) and run the test, since it is a post-build step for the 'Release' target.&lt;br /&gt;
Bye bye funky makefiles, welcome Code::Blocks as your build system.&lt;br /&gt;
&lt;br /&gt;
== More to come ==&lt;br /&gt;
More examples will be added, showcasing 'fixtures' (setup/teardown), some more CHECK macros of UnitTest++. In case you have some tips/ideas, drop me a PM in the forum.&lt;br /&gt;
On the planning is a full conversion of the Money example, but all with gcc and Code::Blocks instead of the crazy Microsoft IDE.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6101</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6101"/>
		<updated>2009-09-09T11:30:44Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* Further automation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 5 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 5 source files, in case you use the wizard you have to add the LeapYear.h/cpp and LeapYearTest.cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYearTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Increase the user experience ==&lt;br /&gt;
There are a few areas where we can increase the user experience.&lt;br /&gt;
When a unit test fails the framework tell use on which line in the the code his happens.&lt;br /&gt;
That's excellent.&lt;br /&gt;
BUT we see this information in a console/shell windows. So we need to find that window, read the issues, remember them and then go find our test source files and navigate manually to the offending line. This works but is very cumbersome.&lt;br /&gt;
We want this to be a no-brainer, and have these steps being carried out for us.&lt;br /&gt;
&lt;br /&gt;
Well, didn't we say life is great, Code::Blocks and UnitTest+= to the rescue. The error/warning output of the framework is in the gcc format. That means Code::Blocks can parse it.&lt;br /&gt;
One restriction Code::Blocks can parse it during the 'build process'. But currently the build procss stops after the unit test executable is build, and only then we run the test executable (manually).&lt;br /&gt;
Solution have Code::Blocks run the test executable as a post-build step. Pre-build and post-build steps are part of the build process !&lt;br /&gt;
Important consequence : if you want to debug something, the debugger will only kick off after Code::Blocks was able to carry out a successful build (including the pre/post builds steps). Therefor it is not wise to have the unit test executable being carried out as a post-bild step of the 'Debug' target. But as a post-build step of the Release target, our goal is met.&lt;br /&gt;
&lt;br /&gt;
Adjust the target settings for the 'Release' target [Build Options -&amp;gt; select Release target -&amp;gt; Pre/Post-build steps -&amp;gt; Post-build steps text field] and add the following '''$exe_output'''. you can tick the 'Always execute' if you want.&lt;br /&gt;
&lt;br /&gt;
Now build your Release target, and look at what shows up in the 'Build Log' tab in Code::Blocks.&lt;br /&gt;
This is my output : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 25.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear.cpp -o Deliv/Release/LeapYear.o&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[ 75.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/main.cpp -o Deliv/Release/main.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
Success: 4 tests passed.&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 0 (0 minutes, 2 seconds)&lt;br /&gt;
0 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We see that the unit test has been carried out, automatically.&lt;br /&gt;
&lt;br /&gt;
Let's demonstrate that upon a failed test, Code::Blocks will jump to the offending line.&lt;br /&gt;
Change the latest test, the one checking on the year 2000 : change 2000 to 2001.&lt;br /&gt;
And build : Code::Blocks will jump to the offending line, and shows an entry in the &amp;quot;Build messages&amp;quot; tab (error: Failure in DivisableBy400: Expected 1 but was 0), just like for a regular compiler warning/error.&lt;br /&gt;
In the &amp;quot;Build&amp;quot; tab, we now find something like (red colored since it is an error) :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
/home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp:28: error: Failure in DivisableBy400: Expected 1 but was 0&lt;br /&gt;
FAILURE: 1 out of 4 tests failed (1 failures).&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 1 (0 minutes, 1 seconds)&lt;br /&gt;
1 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Voila, we have increased the user experience.&lt;br /&gt;
Time to readjust the final test, 2001 becomes 2000 again ;-)&lt;br /&gt;
&lt;br /&gt;
== Further automation ==&lt;br /&gt;
You can create a script that calls Code::Blocks on the command line and passes it our LeapYear.cbp project file, and it will build both targets (Debug/Release) and run the test, since it is a post-build step for the 'Release' target.&lt;br /&gt;
Bye bye funky makefiles, welcome Code::Blocks as your build system.&lt;br /&gt;
&lt;br /&gt;
== More to come ==&lt;br /&gt;
More examples will be added, showcasing 'fixtures' (setup/teardown), some more CHECK macros of UnitTest++. In case you have some tips/ideas, drop me a PM in the forum.&lt;br /&gt;
On the planning is a full conversion of the Money example, but all with gcc and Code::Blocks instead of the crazy Microsoft IDE.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6100</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6100"/>
		<updated>2009-09-09T11:26:12Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* Increase the user experience */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 5 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 5 source files, in case you use the wizard you have to add the LeapYear.h/cpp and LeapYearTest.cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYearTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Increase the user experience ==&lt;br /&gt;
There are a few areas where we can increase the user experience.&lt;br /&gt;
When a unit test fails the framework tell use on which line in the the code his happens.&lt;br /&gt;
That's excellent.&lt;br /&gt;
BUT we see this information in a console/shell windows. So we need to find that window, read the issues, remember them and then go find our test source files and navigate manually to the offending line. This works but is very cumbersome.&lt;br /&gt;
We want this to be a no-brainer, and have these steps being carried out for us.&lt;br /&gt;
&lt;br /&gt;
Well, didn't we say life is great, Code::Blocks and UnitTest+= to the rescue. The error/warning output of the framework is in the gcc format. That means Code::Blocks can parse it.&lt;br /&gt;
One restriction Code::Blocks can parse it during the 'build process'. But currently the build procss stops after the unit test executable is build, and only then we run the test executable (manually).&lt;br /&gt;
Solution have Code::Blocks run the test executable as a post-build step. Pre-build and post-build steps are part of the build process !&lt;br /&gt;
Important consequence : if you want to debug something, the debugger will only kick off after Code::Blocks was able to carry out a successful build (including the pre/post builds steps). Therefor it is not wise to have the unit test executable being carried out as a post-bild step of the 'Debug' target. But as a post-build step of the Release target, our goal is met.&lt;br /&gt;
&lt;br /&gt;
Adjust the target settings for the 'Release' target [Build Options -&amp;gt; select Release target -&amp;gt; Pre/Post-build steps -&amp;gt; Post-build steps text field] and add the following '''$exe_output'''. you can tick the 'Always execute' if you want.&lt;br /&gt;
&lt;br /&gt;
Now build your Release target, and look at what shows up in the 'Build Log' tab in Code::Blocks.&lt;br /&gt;
This is my output : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 25.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear.cpp -o Deliv/Release/LeapYear.o&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[ 75.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/main.cpp -o Deliv/Release/main.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
Success: 4 tests passed.&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 0 (0 minutes, 2 seconds)&lt;br /&gt;
0 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We see that the unit test has been carried out, automatically.&lt;br /&gt;
&lt;br /&gt;
Let's demonstrate that upon a failed test, Code::Blocks will jump to the offending line.&lt;br /&gt;
Change the latest test, the one checking on the year 2000 : change 2000 to 2001.&lt;br /&gt;
And build : Code::Blocks will jump to the offending line, and shows an entry in the &amp;quot;Build messages&amp;quot; tab (error: Failure in DivisableBy400: Expected 1 but was 0), just like for a regular compiler warning/error.&lt;br /&gt;
In the &amp;quot;Build&amp;quot; tab, we now find something like (red colored since it is an error) :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
/home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp:28: error: Failure in DivisableBy400: Expected 1 but was 0&lt;br /&gt;
FAILURE: 1 out of 4 tests failed (1 failures).&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 1 (0 minutes, 1 seconds)&lt;br /&gt;
1 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Voila, we have increased the user experience.&lt;br /&gt;
Time to readjust the final test, 2001 becomes 2000 again ;-)&lt;br /&gt;
&lt;br /&gt;
== Further automation ==&lt;br /&gt;
You can create a script that calls Code::Blocks on the command line and passes it our LeapYear.cbp project file, and it will build both targets (Debug/Release) and run the test, since it is a post-build step for the 'Release' target.&lt;br /&gt;
Bye bye funky makefiles, welcome Code::Blocks as your build system.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6099</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6099"/>
		<updated>2009-09-09T11:25:24Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* Increase the user experience */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 5 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 5 source files, in case you use the wizard you have to add the LeapYear.h/cpp and LeapYearTest.cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYearTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Increase the user experience ==&lt;br /&gt;
There are a few areas where we can increase the user experience.&lt;br /&gt;
When a unit test fails the framework tell use on which line in the the code his happens.&lt;br /&gt;
That's excellent.&lt;br /&gt;
BUT we see this information in a console/shell windows. So we need to find that window, read the issues, remember them and then go find our test source files and navigate manually to the offending line. This works but is very cumbersome.&lt;br /&gt;
We want this to be a no-brainer, and have these steps being carried out for us.&lt;br /&gt;
&lt;br /&gt;
Well, didn't we say life is great, Code::Blocks and UnitTest+= to the rescue. The error/warning output of the framework is in the gcc format. That means Code::Blocks can parse it.&lt;br /&gt;
One restriction Code::Blocks can parse it during the 'build process'. But currently the build procss stops after the unit test executable is build, and only then we run the test executable (manually).&lt;br /&gt;
Solution have Code::Blocks run the test executable as a post-build step. Pre-build and post-build steps are part of the build process !&lt;br /&gt;
Important consequence : if you want to debug something, the debugger will only kick off after Code::Blocks was able to carry out a successful build (including the pre/post builds steps). Therefor it is not wise to have the unit test executable being carried out as a post-bild step of the 'Debug' target. But as a post-build step of the Release target, our goal is met.&lt;br /&gt;
&lt;br /&gt;
Adjust the target settings for the 'Release' target [Build Options -&amp;gt; select Release target -&amp;gt; Pre/Post-build steps -&amp;gt; Post-build steps text field] and add the following '''$exe_output'''. you can tick the 'Always execute' if you want.&lt;br /&gt;
&lt;br /&gt;
Now build your Release target, and look at what shows up in the 'Build Log' tab in Code::Blocks.&lt;br /&gt;
This is my output : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 25.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear.cpp -o Deliv/Release/LeapYear.o&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[ 75.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/main.cpp -o Deliv/Release/main.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
Success: 4 tests passed.&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 0 (0 minutes, 2 seconds)&lt;br /&gt;
0 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We see that the unit test has been carried out, automatically.&lt;br /&gt;
&lt;br /&gt;
Let's demonstrate that upon a failed test, Code::Blocks will jump to the offending line.&lt;br /&gt;
Change the latest test, the one checking on the year 2000 : change 2000 to 2001.&lt;br /&gt;
And build : Code::Blocks will jump to the offending line, and shows an entry in the &amp;quot;Build messages&amp;quot; tab (error: Failure in DivisableBy400: Expected 1 but was 0), just like for a regular compiler warning/error.&lt;br /&gt;
In the &amp;quot;Build&amp;quot; tab, we now find something like (red colored since it is an error) :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
/home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp:28: error: Failure in DivisableBy400: Expected 1 but was 0&lt;br /&gt;
FAILURE: 1 out of 4 tests failed (1 failures).&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 1 (0 minutes, 1 seconds)&lt;br /&gt;
1 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Voila, we have increased the user experience.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Further automation ==&lt;br /&gt;
You can create a script that calls Code::Blocks on the command line and passes it our LeapYear.cbp project file, and it will build both targets (Debug/Release) and run the test, since it is a post-build step for the 'Release' target.&lt;br /&gt;
Bye bye funky makefiles, welcome Code::Blocks as your build system.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6098</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6098"/>
		<updated>2009-09-09T11:18:54Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step6 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 5 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 5 source files, in case you use the wizard you have to add the LeapYear.h/cpp and LeapYearTest.cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYearTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Increase the user experience ==&lt;br /&gt;
There are a few areas where we can increase the user experience.&lt;br /&gt;
When a unit test fails the framework tell use on which line in the the code his happens.&lt;br /&gt;
That's excellent.&lt;br /&gt;
BUT we see this information in a console/shell windows. So we need to find that window, read the issues, remember them and then go find our test source files and navigate manually to the offending line. This works but is very cumbersome.&lt;br /&gt;
We want this to be a no-brainer, and have these steps being carried out for us.&lt;br /&gt;
&lt;br /&gt;
Well, didn't we say life is great, Code::Blocks and UnitTest+= to the rescue. The error/warning output of the framework is in the gcc format. That means Code::Blocks can parse it.&lt;br /&gt;
One restriction Code::Blocks can parse it during the 'build process'. But currently the build procss stops after the unit test executable is build, and only then we run the test executable (manually).&lt;br /&gt;
Solution have Code::Blocks run the test executable as a post-build step. Pre-build and post-build steps are part of the build process !&lt;br /&gt;
Important consequence : if you want to debug something, the debugger will only kick off after Code::Blocks was able to carry out a successful build (including the pre/post builds steps). Therefor it is not wise to have the unit test executable being carried out as a post-bild step of the 'Debug' target. But as a post-build step of the Release target, our goal is met.&lt;br /&gt;
&lt;br /&gt;
Adjust the target settings for the 'Release' target [Build Options -&amp;gt; select Release target -&amp;gt; Pre/Post-build steps -&amp;gt; Post-build steps text field] and add the following '''$exe_output'''. you can tick the 'Always execute' if you want.&lt;br /&gt;
&lt;br /&gt;
Now build your Release target, and look at what shows up in the 'Build Log' tab in Code::Blocks.&lt;br /&gt;
This is my output : &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
-------------- Build: Release in LeapYear ---------------&lt;br /&gt;
&lt;br /&gt;
[ 25.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear.cpp -o Deliv/Release/LeapYear.o&lt;br /&gt;
[ 50.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/LeapYearTest.cpp -o Deliv/Release/LeapYearTest.o&lt;br /&gt;
[ 75.0%] g++ -Wall -fexceptions  -O2   -Wshadow -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wswitch-default -Wmain -Wextra -Wall   -I../UnitTest++/src  -c /home/lieven/Projects/UnitTestArticle/LeapYear/main.cpp -o Deliv/Release/main.o&lt;br /&gt;
[100.0%] g++  -o Deliv/Release/LeapYear Deliv/Release/LeapYear.o Deliv/Release/LeapYearTest.o Deliv/Release/main.o   -s  ../UnitTest++/Deliv/Release/libUnitTest++.a &lt;br /&gt;
Output size is 23.28 KB&lt;br /&gt;
[100.0%] Running target post-build steps&lt;br /&gt;
Deliv/Release/LeapYear&lt;br /&gt;
Success: 4 tests passed.&lt;br /&gt;
Test time: 0.00 seconds.&lt;br /&gt;
Process terminated with status 0 (0 minutes, 2 seconds)&lt;br /&gt;
0 errors, 0 warnings&lt;br /&gt;
Build log saved as: &lt;br /&gt;
file:///home/lieven/Projects/UnitTestArticle/LeapYear/LeapYear_build_log.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We see that the unit test has been carried out, automatically.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6097</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6097"/>
		<updated>2009-09-09T11:04:42Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step4 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 5 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 5 source files, in case you use the wizard you have to add the LeapYear.h/cpp and LeapYearTest.cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYearTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6096</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6096"/>
		<updated>2009-09-09T11:04:22Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step5 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 5 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 5 source files, in case you use the wizard you have to add the LeapYear.h/cpp and LeapYearTest.cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYearTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6095</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6095"/>
		<updated>2009-09-09T11:03:53Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step5 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 5 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 5 source files, in case you use the wizard you have to add the LeapYear.h/cpp and LeapYearTest.cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYearTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6094</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6094"/>
		<updated>2009-09-09T11:02:44Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step4 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 5 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 5 source files, in case you use the wizard you have to add the LeapYear.h/cpp and LeapYearTest.cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYearTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6093</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6093"/>
		<updated>2009-09-09T10:59:45Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step1 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 5 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 5 source files, in case you use the wizard you have to add the LeapYear.h/cpp and LeapYearTest.cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYearTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6092</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6092"/>
		<updated>2009-09-09T10:32:17Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* Our first test project environment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 5 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 5 source files, in case you use the wizard you have to add the LeapYear.h/cpp and LeapYearTest.cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYearTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6091</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6091"/>
		<updated>2009-09-09T10:26:36Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6090</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6090"/>
		<updated>2009-09-09T10:25:31Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step3 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6089</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6089"/>
		<updated>2009-09-09T10:24:57Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step6 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
  &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6088</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6088"/>
		<updated>2009-09-09T10:23:32Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step6 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6087</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6087"/>
		<updated>2009-09-09T10:22:56Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step5 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6086</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6086"/>
		<updated>2009-09-09T10:21:53Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step4 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Time for our next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step5 ==&lt;br /&gt;
We add a new test for checking for example the year 1900. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
TEST(DivisableBy100)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(1900);&lt;br /&gt;
	CHECK_EQUAL(false, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests. It will fail. So time to add the minimum code needed to make this test pass.&lt;br /&gt;
This will change our LeapYear.cpp into : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run the tests, yes : success. All 3 tests pass.&lt;br /&gt;
&lt;br /&gt;
It seems life might be great again ...&lt;br /&gt;
&lt;br /&gt;
Wrong, someone just added the following test :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
TEST(DivisableBy400)&lt;br /&gt;
{&lt;br /&gt;
	const bool Result = IsLeapYear(2000);&lt;br /&gt;
	CHECK_EQUAL(true, Result);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And we once again have a failing test.&lt;br /&gt;
&lt;br /&gt;
Time for the next step.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step6 ==&lt;br /&gt;
We should add logic to deal with years that can be divided by 400, since those are leap years.&lt;br /&gt;
We change our LeapYear.cpp into this : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
namespace&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy400(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%400) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy100(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%100) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsDivisableBy4(int Year)&lt;br /&gt;
{&lt;br /&gt;
	return (Year%4) == 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
bool IsLeapYear(int Year)&lt;br /&gt;
{&lt;br /&gt;
	const bool LeapYear = IsDivisableBy400(Year) ||&lt;br /&gt;
		(IsDivisableBy4(Year) &amp;amp;&amp;amp; !IsDivisableBy100(Year));&lt;br /&gt;
	return LeapYear;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And once again everything works OK.&lt;br /&gt;
And it seems all the logical rules have been implemented.&lt;br /&gt;
This one is ready for shipping, and till the end of time we have our tests that can be run whenever we want (more on this later, we'd prefer this to be done automatically) to ensure we never break anything.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6085</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6085"/>
		<updated>2009-09-09T09:49:06Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* Our first test project environment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6084</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6084"/>
		<updated>2009-09-09T09:45:19Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step4 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6083</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6083"/>
		<updated>2009-09-09T09:44:32Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* Build UnitTest++ */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6082</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6082"/>
		<updated>2009-09-08T21:27:10Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step4 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change of the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6081</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6081"/>
		<updated>2009-09-08T21:26:44Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step4 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
Build, run. All tests pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6080</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6080"/>
		<updated>2009-09-08T21:26:06Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step3 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line where the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
Build, run. All test pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6079</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6079"/>
		<updated>2009-09-08T21:25:39Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step3 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our code on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line were the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
Build, run. All test pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6078</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6078"/>
		<updated>2009-09-08T21:25:15Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
At least now it compiles, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our ocde on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line were the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
Build, run. All test pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6077</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6077"/>
		<updated>2009-09-08T21:24:47Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. Yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's write a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
At least now it compiler, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our ocde on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line were the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
Build, run. All test pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6076</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6076"/>
		<updated>2009-09-08T20:21:52Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step4 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's right a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
At least now it compiler, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our ocde on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line were the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
Build, run. All test pass. Life is great.&lt;br /&gt;
&lt;br /&gt;
But those changing requirements, always the change the requirements. Years that can be divided by 100 should not be considered as a leap year.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6075</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6075"/>
		<updated>2009-09-08T20:21:06Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step4 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's right a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
At least now it compiler, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our ocde on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line were the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;br /&gt;
So our LeapYear.cpp will now look like this :&lt;br /&gt;
&lt;br /&gt;
  #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  namespace&lt;br /&gt;
  {&lt;br /&gt;
  &lt;br /&gt;
  bool IsDivisableBy4(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return (Year%4) == 0;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  bool IsLeapYear(int Year)&lt;br /&gt;
  {&lt;br /&gt;
  	return IsDivisableBy4(Year);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
Build, run. All test pass. Life is great.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6074</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6074"/>
		<updated>2009-09-08T20:18:23Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's right a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Things to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;br /&gt;
&lt;br /&gt;
Time to build. Woooooops errors. The tests fails completely, it does not even build. Time to add the code needed.&lt;br /&gt;
In order to compiler the test file, we need to include the LeapYear.h header and have that header export our function.&lt;br /&gt;
Our LeapYear header will look like this now (don't forget the include in the test file, it is not shown here) : &lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED&lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
At least now it compiler, but it doesn't link yet. Duh, that because we don't have an implementation yet.&lt;br /&gt;
Time to provide the bare minimum of code to make the test pass.&lt;br /&gt;
So we change the LeapYear.cpp into :&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    bool IsLeapYear(int /*Year*/)&lt;br /&gt;
    {&lt;br /&gt;
    	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Build it, run it. Yes, we have one test passed.&lt;br /&gt;
Great. Let's move on.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step3 ==&lt;br /&gt;
Anyone having the feeling we are cheating. Well the user does not know how we wrote our ocde on the inside. So just to be sure the user (we) adds the following test, ending up in : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurSecondTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1973);&lt;br /&gt;
        CHECK_EQUAL(false, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Building is already no issue any more, we can run it. Oh boy, a test is failing.&lt;br /&gt;
The framework tell us something like this : &lt;br /&gt;
    &amp;lt;filename&amp;gt;:&amp;lt;Line&amp;gt;: error: Failure in OurSecondTest: Expected 0 but was 1&lt;br /&gt;
    FAILURE: 1 out of 2 tests failed (1 failures)&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
So we are informed of the line were the failing tests occurs, next to that it tells us what it was expecting and what the actual outcome was. And it presents a resume of the total number of tests, and how many that failed. For you scripting hackers note that FAILURE != SUCCESS.&lt;br /&gt;
&lt;br /&gt;
It seems we should do some more effort and implement some real logic.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step4 ==&lt;br /&gt;
Let's keep it taking one step at a time. Let's start by implementing the 'divisible by 4' logic. That will already solve our tests.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6073</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6073"/>
		<updated>2009-09-08T20:04:27Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step1 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;br /&gt;
Time to move forward, and write our first test.&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step2 ==&lt;br /&gt;
Test, test, but there's nothing to test. yes, absolutely. Let's think of a test, a test that will help us in the design. Now that's a good idea. Suppose I would be the user of the uplifting problem solving leap year checking library/component ... hmmm modesty first : leap year checking '''function'''.&lt;br /&gt;
How would I like that function to look.&lt;br /&gt;
    bool IsLeapYear(int Year);&lt;br /&gt;
&lt;br /&gt;
Yes that seems acceptable.&lt;br /&gt;
So let's right a test that will call that method.&lt;br /&gt;
We do that by adding the following code to LeapYearTest.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    namespace&lt;br /&gt;
    {&lt;br /&gt;
    &lt;br /&gt;
    TEST(OurFirstTest)&lt;br /&gt;
    {&lt;br /&gt;
        const bool Result = IsLeapYear(1972);&lt;br /&gt;
        CHECK_EQUAL(true, Result);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Thing to note : &lt;br /&gt;
* we include the unit test header&lt;br /&gt;
* it is good to put the tests in nameless namespace (will be explained later on)&lt;br /&gt;
* we use the TEST macro, the argument is the name of the test : OurFirstTest&lt;br /&gt;
* we use CHECK_EQUAL to check if the expected result (the first argument) matches the computed result (the second argument)&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6072</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6072"/>
		<updated>2009-09-08T19:53:29Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* Our first test project environment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
And finishing with the source file for the tests : LeapYearTest.cpp (currently) empty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6071</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6071"/>
		<updated>2009-09-08T19:52:20Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* LeapYear-Step1 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;br /&gt;
We don't have any tests yet, nor any functionality, but go ahead build the project and run it.&lt;br /&gt;
This is the output : &lt;br /&gt;
&lt;br /&gt;
    Success: 0 tests passed&lt;br /&gt;
    Test time: 0.00 seconds.&lt;br /&gt;
&lt;br /&gt;
Great : success, but no tests yet. Well it's a start.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6070</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6070"/>
		<updated>2009-09-08T19:49:29Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* Our first test project environment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Driven Development ==&lt;br /&gt;
This is a practice where new code is only added to make a failing test pass. And one only adds the code needed to make that test pass. Once that is done, a new test is added to will check the next functionality to add.&lt;br /&gt;
On this really simple example we will more or less practice some TDD.&lt;br /&gt;
&lt;br /&gt;
So get ready, it's time for LeapYear-Step1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== LeapYear-Step1 ==&lt;br /&gt;
We will turn our main.cpp into the guy in charge to carry out the tests, all we need to do is change the contents of main.cpp into this : &lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;UnitTest++.h&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return UnitTest::RunAllTests();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
And add '''../UnitTest++/src''' to the compiler search directories on the project level of our LeapYear project.&lt;br /&gt;
And add '''../UnitTest++/Deliv/Release/libUnitTest++.a''' to the link libraries of the project&lt;br /&gt;
&lt;br /&gt;
Why : well we need to link with the framework and we need to include the UnitTest++ header so we can use it's functionalities.&lt;br /&gt;
&lt;br /&gt;
The line '''UnitTest::RunAllTests()''' will make sure all test encountered in our sources will be carried out.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6069</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6069"/>
		<updated>2009-09-08T19:40:21Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* Our first test project environment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
        &amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
    	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6068</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6068"/>
		<updated>2009-09-08T19:39:28Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* Our first test project environment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
    &amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
    &amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
    #include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6067</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6067"/>
		<updated>2009-09-08T19:38:55Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* Our first test project environment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
    int main()&lt;br /&gt;
    {&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
    #ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
    #define LEAPYEAR_H_INCLUDED&lt;br /&gt;
    &lt;br /&gt;
    #endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6066</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6066"/>
		<updated>2009-09-08T19:38:09Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* Our first test project environment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
#ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
#define LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
#endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6065</id>
		<title>UnitTesting</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=UnitTesting&amp;diff=6065"/>
		<updated>2009-09-08T19:37:01Z</updated>

		<summary type="html">&lt;p&gt;Killerbot: /* Build UnitTest++ */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document is under development by killerbot. Starting from 7 September 2009.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This document will describe how unit testing can be combined with the Code::Blocks IDE. It will give a hands-on example on a unit testing framework and how it can be used with Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is Unit Testing ==&lt;br /&gt;
Simply put Unit Testing is the discipline and best practice of writing and running little test programs that test little units of code.&lt;br /&gt;
Such a unit can be : &lt;br /&gt;
* a class&lt;br /&gt;
* a free function&lt;br /&gt;
* an interface&lt;br /&gt;
* ...&lt;br /&gt;
There are several unit test frameworks available to help you write, deploy, manage your unit tests. The most famous family is the xUnit framework, and some of it's descendants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Unit Testing ==&lt;br /&gt;
Well we write code that implements some functionality. We need a way to check and prove that the implementation is correct. Therefor we need tests. We need tests on the application level, at the integration level of different components, classes, interfaces. But we also need tests for the smallest building blocks, the units.&lt;br /&gt;
We also wans these tests to run very quickly. That we we can run the tests often, manually or automated.&lt;br /&gt;
These tests will also be our safeguards during refactoring of the code, extending the code or whatever maintenance tasks we carry out on the code.&lt;br /&gt;
These tests will also make us think of how our class, method, ... will be used. Since the test can be seen as a user of our code. Thanks do this, thinking about the tests before implementing the functionality can help us in the design : emergent design.&lt;br /&gt;
It will help us to avoid creating big classes, complex functions. We will only write the methods that are really needed, and no methods that we think might (n)ever be useful in the future. We are no good future tellers ! Those 'might be needed' methods and their tests are just a waste of time. Extending, refactoring will be done when it is actually needed, and at that time we have our unit tests to ensure we don't break any existing code.&lt;br /&gt;
&lt;br /&gt;
Other times to add new unit tests are typically when a bug is discovered; Write a unit test to reproduces the bug, fix the code, and from now on the new unit test will watch your back so the bug won't reappear.&lt;br /&gt;
&lt;br /&gt;
Unit test are also a good place of documentation. The little tests show how the class or method is used.&lt;br /&gt;
The code documents itself.&lt;br /&gt;
&lt;br /&gt;
So the benefits are : &lt;br /&gt;
* better design&lt;br /&gt;
* prove of your code&lt;br /&gt;
* safe guard during code maintenance (refactoring, extensions)&lt;br /&gt;
* documentation&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Unit Test frameworks ==&lt;br /&gt;
When writing unit tests, one will create a lot of similar code. Since unit tests are nothing more then little programs, several tasks will be repeated, setting up the test environment, create your class, call a method, verify it's result, write out an error message when the test fails, preferably specifying what the wrong outcome was, and what the expected result is.&lt;br /&gt;
All these repetitive chores are taken care of by the frame work so the developer can focus on the real code of the test.&lt;br /&gt;
This document will use a small but very effective framework for the C++ language. It is called UnitTest++. It's homepage is at : [http://unittest-cpp.sourceforge.net/ UnitTest++].&lt;br /&gt;
You can download it directly at this [http://sourceforge.net/projects/unittest-cpp/files/UnitTest%2B%2B/1.4/unittest-cpp-1.4.zip/download link]. At the time of writing the latest version is 1.4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup our environment ==&lt;br /&gt;
Let's create a directory on our PC in which we will cary out our experiments. I will refer to this directory from now on as &amp;lt;TestPit&amp;gt;. For my laptop on which I am writing this article, that will be /home/lieven/Projects/UnitTestArticle. Note that everything we will do, works on linux and on windows!&lt;br /&gt;
Download the &amp;quot;unittest-cpp-1.4.zip&amp;quot; file from the link specified above. Extract it in the &amp;lt;TestPit&amp;gt; directory. All the files will end up in the &amp;lt;TestPit&amp;gt;/UnitTest++ directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Build UnitTest++ ==&lt;br /&gt;
After the extracted the zip archive we have a directory structure like this : &lt;br /&gt;
&amp;lt;TestPit&amp;gt;/UnitTest++&lt;br /&gt;
|&lt;br /&gt;
+docs&lt;br /&gt;
|&lt;br /&gt;
+src&lt;br /&gt;
&lt;br /&gt;
The files in the UnitTest++ directory are of little use for us, since they bring project files for some bizarre Microsoft IDE ;-) .&lt;br /&gt;
We will create our own Code::Blocks project to build the UnitTest++ framework.&lt;br /&gt;
&lt;br /&gt;
Why do we need to build something ? Well as said, the framework will do a lot of chores for us, those chores are implemented by code, that code is framework. We will build to frame work into a static library, and for every unit test (or set of unit tests) we create a little (console/shell) program with the test code we wrote, which will link with the static library to obtain a unit test executable, driven by the framework.&lt;br /&gt;
&lt;br /&gt;
We will put our Code::Blocks project file in a nice structured directory tree, therefor let's create a 'Project' subdirectory in the &amp;lt;TestPit&amp;gt;/UniTest++ directory.&lt;br /&gt;
&lt;br /&gt;
In there create a new file with the name &amp;quot;UnitTest++.cbp&amp;quot;.&lt;br /&gt;
Give that file the following content :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;UnitTest++&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Windows;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Debug/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release(linux)&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option platforms=&amp;quot;Unix;Mac;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;../Deliv/Release/libUnitTest++.a&amp;quot; prefix_auto=&amp;quot;0&amp;quot; extension_auto=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option working_dir=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;../Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option createDefFile=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O3&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Winit-self&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wredundant-decls&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wcast-align&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wundef&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wfloat-equal&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-declarations&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmissing-include-dirs&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-enum&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wswitch-default&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wmain&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-pedantic&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-std=c++98&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wextra&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-ansi&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;VirtualTargets&amp;gt;&lt;br /&gt;
			&amp;lt;Add alias=&amp;quot;All&amp;quot; targets=&amp;quot;Debug;Release;Debug(linux);Release(linux);&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/VirtualTargets&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/AssertException.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CheckMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Checks.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Config.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/CurrentTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/DeferredTestResult.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ExecuteTest.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/MemoryOutStream.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/SignalTranslator.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Posix/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release(linux)&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/ReportAssert.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Test.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestDetails.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestList.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestMacros.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestReporterStdout.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestResults.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestRunner.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TestSuite.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeConstraint.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/TimeHelpers.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/UnitTest++.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.cpp&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/Win32/TimeHelpers.h&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Debug&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Option target=&amp;quot;Release&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Unit&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;../src/XmlTestReporter.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some things to note about the content of the project file, the power of Code::Blocks.&lt;br /&gt;
* there are 4 targets : Debug/Release for Windows and Debug/Release for linux [yes : 1 project file that allows building on linux and on windows]&lt;br /&gt;
* some files are only part of the linux targets, some only for the windows targets&lt;br /&gt;
&lt;br /&gt;
But before we build, let's modify some source files (not really needed, but I prefer to have warning free compilations). These are the changes I carried out : &lt;br /&gt;
* ReportAssert.cpp : #include &amp;quot;ReportAssert.h&amp;quot;&lt;br /&gt;
* win32/TimeHelpers.cpp : first the m_threadHandle and then the m_startTime in the initializerlist&lt;br /&gt;
&lt;br /&gt;
Next open up this project file in Code::Blocks and build the debug and release target. From now one we will only use the Release target, we go for speed ;-)&lt;br /&gt;
&lt;br /&gt;
The result of the build process will show up in subdirectories of the new 'Deliv' subdirectory of &amp;lt;testPit&amp;gt;/UnitTest++ : '''&amp;lt;testPit&amp;gt;/UnitTest++/Deliv/Release/libUnitTest++.a'''&lt;br /&gt;
&lt;br /&gt;
Alright, we have build the unit test framework in a platform independent way, no silly makefiles, no obscure M$ IDE, good old super Code::Blocks. It is time to write some code so we have something to unit test.&lt;br /&gt;
&lt;br /&gt;
In the first example we will create a simple free function that checks if a a give year is a leap your or not.&lt;br /&gt;
&lt;br /&gt;
The business logic is as follows : a year is a leap year when it can be divided by 4, unless itcan be divided by 100. But in case it can be divided by 400, then again it is a leap year.&lt;br /&gt;
&lt;br /&gt;
In the next section we will first setup a Code::Blocks project containing both the 'functionality files, and the unit test files. Typically one will package several functionality files into a static library and create a unit test project that tests all the class/functionalities in that library package, also called a component. That is we have a component (whose deliverable is the static library, and we have a unit test project that tests the entire component).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Our first test project environment ==&lt;br /&gt;
Let's create a new directory in our &amp;lt;TestPit&amp;gt; : &amp;lt;TestPit&amp;gt;/LeapYear.&lt;br /&gt;
For the simplicity we will put the project file and the source file all together in this directory. Normally we would work in a more structured way, but in a demo article we have some artistic freedom ;-)&lt;br /&gt;
Next you can create with the Code::Block's wizard a new console project in the LeapYear directory. Or you can create the following 4 files and give the the contents as specified below. Note that this demo works on linux and on windows, everything is still completely platform independent. Long Live Code::Blocks.&lt;br /&gt;
&lt;br /&gt;
The project file : LeapYear.cbp (the one below already contains the 3 source files, in case you use the wizard you have to add the LeapYear.h/cpp files to the project)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;CodeBlocks_project_file&amp;gt;&lt;br /&gt;
	&amp;lt;FileVersion major=&amp;quot;1&amp;quot; minor=&amp;quot;6&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;Project&amp;gt;&lt;br /&gt;
		&amp;lt;Option title=&amp;quot;LeapYear&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option pch_mode=&amp;quot;2&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Build&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Debug&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Debug/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Debug/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-g&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
			&amp;lt;Target title=&amp;quot;Release&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;Option output=&amp;quot;Deliv/Release/LeapYear&amp;quot; prefix_auto=&amp;quot;1&amp;quot; extension_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option object_output=&amp;quot;Deliv/Release/&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option type=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Option compiler=&amp;quot;gcc&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;Compiler&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-O2&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
				&amp;lt;Linker&amp;gt;&lt;br /&gt;
					&amp;lt;Add option=&amp;quot;-s&amp;quot; /&amp;gt;&lt;br /&gt;
				&amp;lt;/Linker&amp;gt;&lt;br /&gt;
			&amp;lt;/Target&amp;gt;&lt;br /&gt;
		&amp;lt;/Build&amp;gt;&lt;br /&gt;
		&amp;lt;Compiler&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-Wall&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;Add option=&amp;quot;-fexceptions&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/Compiler&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;LeapYear.h&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Unit filename=&amp;quot;main.cpp&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;Extensions&amp;gt;&lt;br /&gt;
			&amp;lt;envvars /&amp;gt;&lt;br /&gt;
			&amp;lt;code_completion /&amp;gt;&lt;br /&gt;
			&amp;lt;lib_finder disable_auto=&amp;quot;1&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;debugger /&amp;gt;&lt;br /&gt;
		&amp;lt;/Extensions&amp;gt;&lt;br /&gt;
	&amp;lt;/Project&amp;gt;&lt;br /&gt;
&amp;lt;/CodeBlocks_project_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main source file : main.cpp&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The header exporting our powerful function : LeapYear.h&lt;br /&gt;
&lt;br /&gt;
#ifndef LEAPYEAR_H_INCLUDED &lt;br /&gt;
#define LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
#endif // LEAPYEAR_H_INCLUDED&lt;br /&gt;
&lt;br /&gt;
And the implementation of the leap year logic : LeapYear.cpp&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;LeapYear.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can already build the project, we have a nice little program that does .... nothing.&lt;br /&gt;
&lt;br /&gt;
Time to move to the next section, a little word about Test Driven Development.&lt;/div&gt;</summary>
		<author><name>Killerbot</name></author>
	</entry>
</feed>