/usr/include/wibble/parse.test.h is in libwibble-dev 1.1-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 | // -*- C++ -*-
#include <wibble/parse.h>
#include <wibble/test.h>
using namespace wibble;
struct TestParse {
    enum TokenId { Invalid, Number };
    typedef wibble::Token< TokenId > Token;
    struct IOStream {
        std::istream &i;
        std::string remove() {
            char block[1024];
            i.read( block, 1023 );
            block[i.gcount()] = 0;
            return block;
        }
        bool eof() {
            return i.eof();
        }
        IOStream( std::istream &i ) : i( i ) {}
    };
    struct Lexer : wibble::Lexer< Token, IOStream >
    {
        Token remove() {
            this->skipWhitespace();
            this->match( isdigit, isdigit, Number );
            return this->decide();
        }
        Lexer( IOStream &s )
            : wibble::Lexer< Token, IOStream >( s )
        {}
    };
    Test lexer() {
        std::stringstream s;
        IOStream is( s );
        Token t;
        Lexer l( is );
        s << "1 2";
        t = l.remove();
        assert_eq( t.id, Number );
        assert_eq( t.data, "1" );
        t = l.remove();
        assert_eq( t.id, Number );
        assert_eq( t.data, "2" );
        t = l.remove();
        assert_eq( t.id, Invalid );
    }
};
 |