//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
//
// THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
// CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#include <sstream>
#include "../macros.hpp"
#include "parser.hpp"
#include "test_helpers.hpp"
// ------------------------------------------------------------------------
// Tests for the "parse_error" class.
// ------------------------------------------------------------------------
{
}
{
}
// ------------------------------------------------------------------------
// Tests for the "parse_errors" class.
// ------------------------------------------------------------------------
{
}
{
}
// ------------------------------------------------------------------------
// Tests for the "token" class.
// ------------------------------------------------------------------------
{
}
{
{
token t(10, 0);
ATF_REQUIRE_EQ(t.type(), 0);
}
{
ATF_REQUIRE_EQ(t.type(), 0);
}
{
}
{
}
}
// ------------------------------------------------------------------------
// Tests for the "tokenizer" class.
// ------------------------------------------------------------------------
do { \
} while (false);
namespace minimal {
public:
{
}
};
}
namespace delims {
public:
{
}
};
}
namespace keywords {
public:
{
}
};
}
namespace quotes {
public:
{
}
};
}
{
"and not skipping whitespace");
}
{
using namespace minimal;
{
}
{
}
{
}
{
}
{
}
{
}
{
}
}
{
"and skipping whitespace");
}
{
using namespace minimal;
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
}
{
"additional delimiters and not skipping whitespace");
}
{
using namespace delims;
{
}
{
}
{
}
{
}
{
}
}
{
"additional delimiters and skipping whitespace");
}
{
using namespace delims;
{
}
}
{
"additional keywords and not skipping whitespace");
}
{
using namespace keywords;
{
}
{
}
{
}
{
}
{
}
}
{
"additional keywords and not skipping whitespace");
}
{
using namespace keywords;
{
}
{
}
{
}
}
{
"quoted strings and not skipping whitespace");
}
{
using namespace quotes;
{
}
{
}
{
}
{
}
}
{
"quoted strings and skipping whitespace");
}
{
using namespace quotes;
{
}
{
}
{
}
{
}
}
// ------------------------------------------------------------------------
// Tests for the headers parser.
// ------------------------------------------------------------------------
class header_reader {
public:
{
}
void
read(void)
{
"application/X-atf-headers-test", 1234);
}
};
{
const char* input =
""
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"1: Unexpected token `<<EOF>>'; expected a header name",
};
}
{
const char* input =
"Content-Type\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"1: Unexpected token `<<NEWLINE>>'; expected `:'",
};
}
{
const char* input =
"Content-Type:\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"1: Unexpected token `<<NEWLINE>>'; expected a textual value",
};
}
{
const char* input =
"Content-Type: application/X-atf-headers-test\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"2: Unexpected token `<<EOF>>'; expected a header name",
};
}
{
const char* input =
"Content-Type: application/X-atf-headers-test;\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"1: Unexpected token `<<NEWLINE>>'; expected an attribute name",
};
}
{
const char* input =
"Content-Type: application/X-atf-headers-test; version\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"1: Unexpected token `<<NEWLINE>>'; expected `='",
};
}
{
const char* input =
"Content-Type: application/X-atf-headers-test; version=\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"1: Unexpected token `<<NEWLINE>>'; expected word or quoted string",
};
}
{
const char* input =
"Content-Type: application/X-atf-headers-test; version=\"1234\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"1: Missing double quotes before end of line",
};
}
{
const char* input =
"Content-Type: application/X-atf-headers-test; version=1234\"\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"1: Missing double quotes before end of line",
};
}
{
const char* input =
"Content-Type: application/X-atf-headers-test; version=1234\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"2: Unexpected token `<<EOF>>'; expected a header name",
};
}
{
const char* input =
"Content-Type: application/X-atf-headers-test; version=\"1234\"\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"2: Unexpected token `<<EOF>>'; expected a header name",
};
}
{
const char* input =
"Content-Type: application/X-atf-headers-test; version=\"1234\"\n"
"a b\n"
"a-b:\n"
"a-b: foo;\n"
"a-b: foo; var\n"
"a-b: foo; var=\n"
"a-b: foo; var=\"a\n"
"a-b: foo; var=a\"\n"
"a-b: foo; var=\"a\";\n"
"a-b: foo; var=\"a\"; second\n"
"a-b: foo; var=\"a\"; second=\n"
"a-b: foo; var=\"a\"; second=\"b\n"
"a-b: foo; var=\"a\"; second=b\"\n"
"a-b: foo; var=\"a\"; second=\"b\"\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"2: Unexpected token `b'; expected `:'",
"3: Unexpected token `<<NEWLINE>>'; expected a textual value",
"4: Unexpected token `<<NEWLINE>>'; expected an attribute name",
"5: Unexpected token `<<NEWLINE>>'; expected `='",
"6: Unexpected token `<<NEWLINE>>'; expected word or quoted string",
"7: Missing double quotes before end of line",
"8: Missing double quotes before end of line",
"9: Unexpected token `<<NEWLINE>>'; expected an attribute name",
"10: Unexpected token `<<NEWLINE>>'; expected `='",
"11: Unexpected token `<<NEWLINE>>'; expected word or quoted string",
"12: Missing double quotes before end of line",
"13: Missing double quotes before end of line",
};
}
// ------------------------------------------------------------------------
// Main.
// ------------------------------------------------------------------------
{
// Add test cases for the "parse_error" class.
// Add test cases for the "parse_errors" class.
// Add test cases for the "token" class.
// Add test cases for the "tokenizer" class.
// Add the tests for the headers parser.
// Add the test cases for the header file.
}