From b65aeffc112ea9493061aeda2ad1fbe1d01400ad Mon Sep 17 00:00:00 2001 From: ntrifunovic Date: Sat, 9 Mar 2013 20:51:50 +0000 Subject: [PATCH] Introducing Boost Test for unit-testing v3. git-svn-id: http://svn.code.sf.net/p/utfcpp/code@141 a809a056-fc17-0410-9590-b4f493f8b08e --- tests/Makefile | 2 +- tests/unit.cpp | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index ab48a9b..3f36920 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -2,5 +2,5 @@ CC = g++ CFLAGS = -g -Wall --std=c++11 smoketest: unit.cpp ../src/utf8.h - $(CC) $(CFLAGS) unit.cpp -ounit + $(CC) $(CFLAGS) unit.cpp -ounit -lboost_unit_test_framework ./unit diff --git a/tests/unit.cpp b/tests/unit.cpp index 5bbfaf8..bfd569e 100644 --- a/tests/unit.cpp +++ b/tests/unit.cpp @@ -1,20 +1,19 @@ -#include +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE UTF8_CPP_UNIT +#include + #include "../src/utf8.h" using namespace std; -int main() +BOOST_AUTO_TEST_CASE(append) { -// append - { string s; - utf8::append(U'\U00000448', s); - assert (s.length() == 2 && s[0] == '\xd1' && s[1] == '\x88'); + BOOST_CHECK_NO_THROW (utf8::append(U'\U00000448', s)); + BOOST_CHECK (s.length() == 2 && s[0] == '\xd1' && s[1] == '\x88'); s.erase(); - utf8::append(U'\U000065e5', s); - assert (s.length() == 3 && s[0] == '\xe6' && s[1] == '\x97' && s[2] == '\xa5'); - } - + BOOST_CHECK_NO_THROW(utf8::append(U'\U000065e5', s)); + BOOST_CHECK (s.length() == 3 && s[0] == '\xe6' && s[1] == '\x97' && s[2] == '\xa5'); }