This file is indexed.

/usr/include/wibble/sys/buffer.test.h is in libwibble-dev 1.1-2.

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
/* -*- C++ -*- (c) 2007 Petr Rockai <me@mornfall.net>
               (c) 2007 Enrico Zini <enrico@enricozini.org> */

#include <wibble/sys/buffer.h>

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

using namespace std;
using namespace wibble::sys;

struct TestBuffer {
    Test emptiness() {
        Buffer buf;
        assert_eq(buf.size(), 0u);
        assert_eq(buf.data(), static_cast<void*>(0));

		// Empty buffers should be equal
		Buffer buf1;
		assert(buf == buf);
		assert(buf == buf1);
		assert(!(buf < buf1));
		assert(!(buf1 < buf));
    }

    Test nonemptiness() {
        // Nonempty buffers should be properly nonempty
        Buffer buf(1);
        (static_cast<char*>(buf.data()))[0] = 'a';
        assert_eq(buf.size(), 1u);
        assert(buf.data() != 0);

		// Nonempty buffers should compare by content
		Buffer buf1(1);
		(static_cast<char*>(buf1.data()))[0] = 'z';
		assert(buf == buf);
		assert(buf1 == buf1);
		assert(!(buf == buf1));
		assert(buf != buf1);
		assert(buf < buf1);
		assert(!(buf1 < buf));

		(static_cast<char*>(buf1.data()))[0] = 'a';
		assert(buf == buf1);
		assert(!(buf != buf1));
		assert(!(buf < buf1));
		assert(!(buf1 < buf));

		// Empty buffers should come before the nonempty ones
		Buffer buf2;
		assert(!(buf == buf2));
		assert(buf != buf2);
		assert(!(buf < buf2));
		assert(buf2 < buf);
    }

// Construct by copy should work
    Test copy() {
        const char* str = "Ciao";
        Buffer buf(str, 4);

        assert_eq(buf.size(), 4u);
        assert(memcmp(str, buf.data(), 4) == 0);
    }

// Resize should work and preserve the contents
    Test resize() {
        const char* str = "Ciao";
        Buffer buf(str, 4);
        
        assert_eq(buf.size(), 4u);
        assert(memcmp(str, buf.data(), 4) == 0);
        
        buf.resize(8);
        assert_eq(buf.size(), 8u);
        assert(memcmp(str, buf.data(), 4) == 0);
    }

// Check creation by taking ownership of another buffer
    Test takeover() {
        char* str = (char*)malloc(4);
        memcpy(str, "ciao", 4);
        Buffer buf(str, 4, true);
	
        assert_eq(buf.size(), 4u);
        assert_eq(static_cast<void*>(str), buf.data());
    }
};

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