Create a tutorial.cxx file with the following code:

#include <iostream>
#include <stdlib.h>
#include <math.h>

using namespace std;

int main(int argc, char* argv[])
{
   if(argc < 2){
       cout<<"Usage: "<<argv[0]<<" number"<<endl;
       return 1;
   }
   cout<<"The sqrt of "<<argv[1]<<" is "<<sqrt(atof(argv[1]))<<endl;
   return 0;
}

Create a CMakeLists.txt in the same folder of tutorial.cxx with the following code:

cmake_minimum_required(VERSION 2.6)
Project(Tutorial)

include(CTest)

include_directories("${PROJECT_SOURCE_DIR}/MathFunctions")
add_subdirectory(MathFunctions)

add_executable(Tutorial tutorial.cxx)
target_link_libraries(Tutorial MathFunctions)

# does the application run 
add_test (TutorialRuns Tutorial 25) 

# does it sqrt of 25 
add_test (TutorialComp25 Tutorial 25) 
set_tests_properties (TutorialComp25 PROPERTIES PASS_REGULAR_EXPRESSION "The sqrt of 25 is 5") 

# does it handle negative numbers 
add_test (TutorialNegative Tutorial -25) 
set_tests_properties (TutorialNegative PROPERTIES PASS_REGULAR_EXPRESSION "The sqrt of -25 is -nan") 

# does it handle small numbers 
add_test (TutorialSmall Tutorial 0.0001) 
set_tests_properties (TutorialSmall PROPERTIES PASS_REGULAR_EXPRESSION "The sqrt of 0.0001 is 0.01") 

# does the usage message work? 
add_test (TutorialUsage Tutorial) 
set_tests_properties (TutorialUsage PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number")

In order to keep the build files easy to remove, create a build folder by running

mkdir build && cd build

Run Cmake and then make

cmake .. && make

To do the tests, run

ctest

And the result should be similar to

 Start 1: TutorialRuns
1/5 Test #1: TutorialRuns ..................... Passed 0.00 sec
 Start 2: TutorialComp25
2/5 Test #2: TutorialComp25 ................... Passed 0.00 sec
 Start 3: TutorialNegative
3/5 Test #3: TutorialNegative ................. Passed 0.00 sec
 Start 4: TutorialSmall
4/5 Test #4: TutorialSmall .................... Passed 0.00 sec
 Start 5: TutorialUsage
5/5 Test #5: TutorialUsage .................... Passed 0.00 sec

100% tests passed, 0 tests failed out of 5

Total Test time (real) = 0.05 sec