The helpers are a place for support code that includes the tests. This is an important part of any pile that clearly shows your code in action.
We will rely on googletest framework and this post is designed both to get you started and to describe the way we are going to test the piles. It is provided under New BSD License.
Preparing
First we need to get googletest. I tried the trunk under Windows with MinGw but it failed to build. Maybe you are more lucky:
mkdir ~/googletest
cd ~/googletest
svn checkout http://googletest.googlecode.com/svn/trunk/ src
You are on Windows and you don’t have svn installed, don’t you?!
So I’ve got 1.7.0 zip.
This is a TODO; I need to make the trunk build. Also, the repository is a treasure trove and needs t be inspected.
Building in Windows
I’m lazy so I opened the CMakeLists.txt in QtCreator,
configured to ../build
and build. Worked flawlessly.
I was using MinGW and PThreads got defined which prevented
the compilation. I added -Dgtest_disable_pthreads=ON
to
CMake command line.
I also modified line 1777 in gtest-port.h
to
form
::testing::AutoHandle thread_;
to
::testing::internal::AutoHandle thread_;
Building in Ubuntu
Haven’t tried, yet, but this should do it:
mkdir ~/googletest/build
cd ~/googletest/build
cmake ../src
make
# sudo make install
Using it
The CMakeLists.txt
file does not provide an install target so I went
ahead and created ~/googletest/install
directory and copied
the include directory inside (and removed the internal
directory; it felt right, smart, and proved wrong; keep the
internal
directory).
I also created ~/googletest/install/lib
and copied
libgtest.a
and libgtest_main.a
inside.
For CMake to see these we will have to add
~/googletest/install
to
CMAKE_PREFIX_PATH.
We will also use the FindGTest.cmake
to locate the components.