test2_stringutil.cpp
#include <oak/test/tmain.cpp>
#include "stringutils.h"
namespace StringUtilsTest
{
//Step 1: Write the test class
class StrStrTest : public oak::test::Test
{
public:
StrStrTest(): oak::test::Test("StringUtilsTest::StrStrTest")
{
}
void run(const oak::util::Properties& props)
{
const char* s = "StrStr Test";
const char* str1 = "Test";
const char* str2 = "Str";
const char* p1 = StringUtils::strstr(s, str1);
const char* p2 = StringUtils::strstr(s, str2);
OAK_TEST_ASSERT_NOT_EQUAL(p1, (const char*)0);
OAK_TEST_ASSERT_NOT_EQUAL(p2, (const char*)0);
}
};
}
//Step 2: Add to the TestGroup
OAK_TEST_ADD(StringUtilsTest::StrStrTest, g_t1);
Notes:
- Same test as in stringutil_test.cpp. But it shows a different way to create the unit tests.
- The StringUtil functions are present here
- The test must be built as a .dll (windows) or .so file (unix). See build instructions for details
- To run the test: oakte -t test2_stringutil.[dll/so] (windows/unix)
- See document "OakUT - C++ unit test framework" for details