From: heister Date: Tue, 17 Jan 2012 22:36:03 +0000 (+0000) Subject: unit test for Utilities::break_text_into_lines X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71123c598e69b75300b5e3445e1dafea7d9ca544;p=dealii-svn.git unit test for Utilities::break_text_into_lines git-svn-id: https://svn.dealii.org/trunk@24908 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/base/utilities_04.cc b/tests/base/utilities_04.cc new file mode 100644 index 0000000000..dbc57e0d30 --- /dev/null +++ b/tests/base/utilities_04.cc @@ -0,0 +1,92 @@ +//----------------------------------------------------------------------------- +// $Id: utilities_03.cc 24204 2011-08-25 19:13:52Z bangerth $ +// Version: $Name$ +// +// Copyright (C) 2005, 2006, 2011 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//----------------------------------------------------------------------------- + +// test functions in namespace Utilities + +#include "../tests.h" +#include +#include +#include +#include +#include + +#include + +using namespace dealii; + +std::vector split_string(const std::string &text, const char delim='|') +{ + std::vector result; + std::string word; + std::stringstream stream(text); + while( getline(stream, word, delim) ) + result.push_back(word); + + return result; +} + + +void test_function(const std::string &original_text, + const unsigned int width, + const char delimiter, + const std::string &result) +{ + std::vector res_vec + = Utilities::break_text_into_lines (original_text, width, delimiter); + + std::vector should_be_vec + = split_string(result); + + + Assert(res_vec.size()==should_be_vec.size(), ExcInternalError()); + for (unsigned int i=0;i