2
#include "zypp/Pathname.h"
5
#define BOOST_TEST_MODULE Glob
7
static Pathname TEST_ROOT( TESTS_SRC_DIR"/zypp/base/Glob_test.dat" );
9
using filesystem::Glob;
11
BOOST_AUTO_TEST_CASE(Glob_default)
13
// enable loging for the scope of this block:
14
// base::LogControl::TmpLineWriter shutUp( new log::FileLineWriter( "-" ) );
16
BOOST_CHECK( q.empty() );
17
BOOST_CHECK( q.size() == 0 );
18
BOOST_CHECK_EQUAL( q.begin(), q.end() );
19
BOOST_CHECK( q.defaultFlags() == Glob::Flags() );
21
q.add( TEST_ROOT/"file" );
22
BOOST_CHECK( ! q.empty() );
23
BOOST_CHECK( q.size() == 1 );
24
BOOST_CHECK_NE( q.begin(), q.end() );
25
BOOST_CHECK_EQUAL( *q.begin(), TEST_ROOT/"file" );
27
q.reset( Glob::_BRACE );
28
BOOST_CHECK( q.empty() );
29
BOOST_CHECK( q.size() == 0 );
30
BOOST_CHECK_EQUAL( q.begin(), q.end() );
31
BOOST_CHECK( q.defaultFlags() == Glob::_BRACE );
33
q.add( TEST_ROOT/"file*" );
34
BOOST_CHECK( q.size() == 3 );
36
q.add( TEST_ROOT/"*{.xml,.xml.gz}" );
37
BOOST_CHECK( q.size() == 5 );
39
q.clear(); // no flags reset: Glob::_BRACE active
40
BOOST_CHECK( q.size() == 0 );
42
q.add( TEST_ROOT/"*{.xml,.xml.gz}" );
43
BOOST_CHECK( q.size() == 2 );
45
q.reset(); // flags reset: Glob::_BRACE off
46
BOOST_CHECK( q.size() == 0 );
48
q.add( TEST_ROOT/"*{.xml,.xml.gz}" );
49
BOOST_CHECK( q.size() == 0 );
52
BOOST_AUTO_TEST_CASE(Glob_static)
55
Glob::collect( TEST_ROOT/"*{.xml,.xml.gz}", Glob::_BRACE, std::inserter( q, q.begin() ) );
56
BOOST_REQUIRE( q.size() == 2 );
57
BOOST_CHECK_EQUAL( *q.begin(), TEST_ROOT/"file.xml" );
58
BOOST_CHECK_EQUAL( *++q.begin(), TEST_ROOT/"file.xml.gz" );