Library meant to simplify writing of tests. Very light-weight in the approach. Test syntax will be familiar to users of CUnit, however this is far more basic.
Dependents: CircularBufferTest
Tests are expected to take the form of macro-based statements, such as:
// An empty buffer should yield getSize() of zero TST_EQ( buffer.getSize(), 0, "Empty buffer: getSize()" );
You still have to do the hard work of coming up with the tests and writing code to implement them, but this library is intended to give you a "jump start" towards getting something with consistent output and keeping track of the number of passes/fails - just import the library, include the header and you're away.
See CircularBufferTest main.cpp for an example of how this library can be used
Diff: TestSupportLite.cpp
- Revision:
- 0:62a10b8392a4
diff -r 000000000000 -r 62a10b8392a4 TestSupportLite.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TestSupportLite.cpp Sun Jan 19 17:14:59 2014 +0000 @@ -0,0 +1,42 @@ +/** + +Copyright 2014 John Bailey + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*/ + +#include "TestSupportLite.hpp" + +TestResults::TestResults() : m_passed( 0 ), m_total( 0 ) +{ +} + +void TestResults::registerResult( const bool p_passed ) +{ + m_total++; + if( p_passed ) + { + m_passed++; + } +} + +std::size_t TestResults::getCount( void ) const +{ + return m_total; +} + +std::size_t TestResults::getPassed( void ) const +{ + return m_passed; +}