This file is indexed.

/usr/include/wibble/operators.test.h is in libwibble-dev 1.1-1build1.

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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* -*- C++ -*- (c) 2007 Petr Rockai <me@mornfall.net>
               (c) 2007 Enrico Zini <enrico@enricozini.org> */

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

namespace {

using namespace std;
using namespace wibble::operators;

static set<int> mkset(int i1)
{
	set<int> a; a.insert(i1); return a;
}
static set<int> mkset(int i1, int i2)
{
	set<int> a; a.insert(i1); a.insert(i2); return a;
}
#if 0
static set<int> mkset(int i1, int i2, int i3)
{
	set<int> a; a.insert(i1); a.insert(i2); a.insert(i3); return a;
}
static set<int> mkset(int i1, int i2, int i3, int i4)
{
	set<int> a; a.insert(i1); a.insert(i2); a.insert(i3); a.insert(i4); return a;
}
#endif

struct TestOperators {

    Test binarySetOperations() {
        set< int > a = mkset(4, 5);
	set< int > b = mkset(5);
        set< int > c = a & b;
        assert_eq( c.size(), 1u );
        assert( c.find( 4 ) == c.end() );
        assert( c.find( 5 ) != c.end() );
        c = a | b;
        assert_eq( c.size(), 2u );
        assert( c.find( 4 ) != c.end() );
        assert( c.find( 5 ) != c.end() );
        c = a - b;
        assert_eq( c.size(), 1u );
        assert( c.find( 4 ) != c.end() );
        assert( c.find( 5 ) == c.end() );
    }

    Test mutatingSetOperations() {
        set< int > a = mkset(4, 3);
	set< int > b = mkset(5);
        b |= 3;
        assert_eq( b.size(), 2u );
        assert( b.find( 2 ) == b.end() );
        assert( b.find( 3 ) != b.end() );
        assert( b.find( 4 ) == b.end() );
        assert( b.find( 5 ) != b.end() );
        b |= a;
        assert_eq( b.size(), 3u );
        assert( b.find( 3 ) != b.end() );
        assert( b.find( 4 ) != b.end() );
        assert( b.find( 5 ) != b.end() );
        b &= a;
        assert_eq( b.size(), 2u );
        assert( b.find( 3 ) != b.end() );
        assert( b.find( 4 ) != b.end() );
        assert( b.find( 5 ) == b.end() );
        b.insert( b.begin(), 2 );
        b -= a;
        assert_eq( b.size(), 1u );
        assert( b.find( 2 ) != b.end() );
        assert( b.find( 3 ) == b.end() );
        assert( b.find( 4 ) == b.end() );
    }
    
    Test specialContainerOperations() {
        set< int > a;

        a = a | wibble::Empty<int>();
        assert_eq( a.size(), 0u );
        
        a = a | wibble::Singleton<int>(1);
        assert_eq( a.size(), 1u );
        assert( a.find( 1 ) != a.end() );
        
        a = a - wibble::Empty<int>();
        assert_eq( a.size(), 1u );
        assert( a.find( 1 ) != a.end() );
        
        a = a - wibble::Singleton<int>(1);
        assert_eq( a.size(), 0u );
        assert( a.find( 1 ) == a.end() );
        
        a |= wibble::Empty<int>();
        assert_eq( a.size(), 0u );
        
        a |= wibble::Singleton<int>(1);
        assert_eq( a.size(), 1u );
        assert( a.find( 1 ) != a.end() );
        
        a -= wibble::Empty<int>();
        assert_eq( a.size(), 1u );
        assert( a.find( 1 ) != a.end() );
        
        a -= wibble::Singleton<int>(1);
        assert_eq( a.size(), 0u );
        assert( a.find( 1 ) == a.end() );
    }
    
    Test emptySetInclusion() {
        set< int > a, b;
        assert( a <= b );
        assert( b <= a );
    }

    Test mutatingIntersectionBug() {
	// Catches a past bug of in-place intersection that would delete too many
	// items if the second set had items not present in the first
	set<int> a = mkset(2);
	set<int> b = mkset(1, 2);
	set<int> c = mkset(2);

	set<int> d = a & b;
	assert(c == d);

	d = a;
	d &= b;
	assert(c == d);
    }
    
};

}

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