This file is indexed.

/usr/include/wibble/regexp.test.h is in libwibble-dev 0.1.28-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* -*- C++ -*- (c) 2007 Petr Rockai <me@mornfall.net>
               (c) 2007 Enrico Zini <enrico@enricozini.org> */

#include <wibble/test.h>
#include <wibble/regexp.h>

namespace {

using namespace std;
using namespace wibble;

struct TestRegexp {

    Test basicMatch() {
        Regexp re("^fo\\+bar()$");
        assert(re.match("fobar()"));
        assert(re.match("foobar()"));
        assert(re.match("fooobar()"));
        assert(!re.match("fbar()"));
        assert(!re.match(" foobar()"));
        assert(!re.match("foobar() "));
    }

    Test extendedMatch() {
        ERegexp re("^fo+bar()$");
        assert(re.match("fobar"));
        assert(re.match("foobar"));
        assert(re.match("fooobar"));
        assert(!re.match("fbar"));
        assert(!re.match(" foobar"));
        assert(!re.match("foobar "));
    }

    Test capture() {
        ERegexp re("^f(o+)bar([0-9]*)$", 3);
        assert(re.match("fobar"));
        assert_eq(re[0], string("fobar"));
        assert_eq(re[1], string("o"));
        assert_eq(re[2], string(""));
        assert_eq(re.matchStart(0), 0u);
        assert_eq(re.matchEnd(0), 5u);
        assert_eq(re.matchLength(0), 5u);
        assert_eq(re.matchStart(1), 1u);
        assert_eq(re.matchEnd(1), 2u);
        assert_eq(re.matchLength(1), 1u);

        assert(re.match("foobar42"));
        assert_eq(re[0], string("foobar42"));
        assert_eq(re[1], string("oo"));
        assert_eq(re[2], string("42"));
    }

    Test tokenize() {
        string str("antani blinda la supercazzola!");
        Tokenizer tok(str, "[a-z]+", REG_EXTENDED);
        Tokenizer::const_iterator i = tok.begin();

        assert(i != tok.end());
        assert_eq(*i, "antani");
        ++i;
        assert(i != tok.end());
        assert_eq(*i, "blinda");
        ++i;
        assert(i != tok.end());
        assert_eq(*i, "la");
        ++i;
        assert(i != tok.end());
        assert_eq(*i, "supercazzola");
        ++i;
        assert(i == tok.end());
    }

    Test splitter()
    {
        Splitter splitter("[ \t]+or[ \t]+", REG_EXTENDED | REG_ICASE);
        Splitter::const_iterator i = splitter.begin("a or b OR c   or     dadada");
        assert_eq(*i, "a");
        assert_eq(i->size(), 1u);
        ++i;
        assert_eq(*i, "b");
        assert_eq(i->size(), 1u);
        ++i;
        assert_eq(*i, "c");
        assert_eq(i->size(), 1u);
        ++i;
        assert_eq(*i, "dadada");
        assert_eq(i->size(), 6u);
        ++i;
        assert(i == splitter.end());
    }

    Test emptySplitter()
    {
        Splitter splitter("Z*", REG_EXTENDED | REG_ICASE);
        Splitter::const_iterator i = splitter.begin("ciao");
        assert_eq(*i, "c");
        assert_eq(i->size(), 1u);
        ++i;
        assert_eq(*i, "i");
        assert_eq(i->size(), 1u);
        ++i;
        assert_eq(*i, "a");
        assert_eq(i->size(), 1u);
        ++i;
        assert_eq(*i, "o");
        assert_eq(i->size(), 1u);
        ++i;
        assert(i == splitter.end());
    }

};

}

// vim:set ts=4 sw=4: