2
// mlib/tests/test_instantiate.cpp
3
// This file is part of Bombono DVD project.
5
// Copyright (c) 2010 Ilya Murav'jov
7
// This program is free software; you can redistribute it and/or modify
8
// it under the terms of the GNU General Public License as published by
9
// the Free Software Foundation; either version 2 of the License, or
10
// (at your option) any later version.
12
// This program is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License for more details.
17
// You should have received a copy of the GNU General Public License
18
// along with this program; if not, write to the Free Software
19
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
#include <mlib/tests/_pc_.h>
24
#include <mlib/format.h>
25
#include <mlib/regex.h>
26
#include <mlib/stream.h>
27
#include <mlib/tech.h>
29
BOOST_AUTO_TEST_CASE( TestFormat )
32
std::string f_str = (boost::format("writing %2%, x=%1% : %3%-th try") % "toto" % 40.23 % 50).str();
33
BOOST_CHECK( strcmp(f_str.c_str(), "writing 40.23, x=toto : 50-th try") == 0 );
36
BOOST_AUTO_TEST_CASE( TestRegexWrapper )
39
re::pattern pat("([0-9]+)");
40
std::string str = "x111xxx222dd333x";
42
re::match_results what;
44
for( re::const_iterator it = str.begin(), end = str.end();
45
re::search(it, end, what, pat);
48
BOOST_CHECK_EQUAL( (int)what.size(), 2 );
50
BOOST_CHECK_EQUAL( what.str(1), boost::format("%1%%1%%1%") % matches % bf::stop );
52
BOOST_CHECK_EQUAL( matches, 3 );
55
BOOST_CHECK( re::match("12345", pat) );
56
BOOST_CHECK( !re::match("12x45", pat) );
65
//uint32_t sa_swap_words(uint32_t arg)
67
// U32P in; // = { .wp = &arg };
70
// const uint16_t hi = in.sp[0];
71
// const uint16_t lo = in.sp[1];
79
//bool sa_is_swaped_vs_sa()
81
// return sa_swap_words(1) != 1;
84
//BOOST_AUTO_TEST_CASE( TestStrictAliasing )
86
// BOOST_CHECK( sa_is_swaped_vs_sa() );
90
static bool SetTrue(bool& b)
96
BOOST_AUTO_TEST_CASE( TestASSERT_UNUSED )
99
UNUSED_VAR(var1); // без предупреждения!
106
// Внимание: выполняет выражение в скобках в любом случае, поэтому
107
// подходит только для проверок переменных простых типов в отладке и
108
// исключения неиспользуемости в релизе
109
ASSERT_OR_UNUSED( b1 ); // не должно быть ошибки и предупреждения
111
// ASSERT_OR_UNUSED_VAR
112
// не выполняет первый аргумент в релизе
113
ASSERT_OR_UNUSED_VAR( SetTrue(b2), b2 );
117
ASSERT_OR_UNUSED( !b1 ); // = ASSERT()
119
// ASSERT_OR_UNUSED_VAR
120
ASSERT_OR_UNUSED_VAR( SetTrue(b2), b2 );