//
// Automated Testing Framework (atf)
//
// Copyright (c) 2010 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 "atf-c++/detail/test_helpers.hpp"
#include "atf-c++/config.hpp"
#include "atf-c++/macros.hpp"
#include "config.hpp"
namespace atf {
namespace config {
void __reinit(void);
} // namespace config
} // namespace atf
// -------------------------------------------------------------------------
// Tests for the "config" parser.
// -------------------------------------------------------------------------
void
{
}
void
got_eof(void)
{
}
public:
{
}
void
read(void)
{
}
};
{
const char* input =
"Content-Type: application/X-atf-config; version=\"1\"\n"
"\n"
;
const char* exp_calls[] = {
"got_eof()",
};
const char* exp_errors[] = {
};
}
{
const char* input =
"Content-Type: application/X-atf-config; version=\"1\"\n"
"\n"
"# This is a comment on a line of its own.\n"
"# And this is another one.\n"
"\n"
" # Another after some whitespace.\n"
"\n"
"# The last one after an empty line.\n"
;
const char* exp_calls[] = {
"got_eof()",
};
const char* exp_errors[] = {
};
}
{
const char* input =
"Content-Type: application/X-atf-config; version=\"1\"\n"
"\n"
"var1=value1\n"
"var2 = value2\n"
"var3 = value3\n"
"var4 = value4\n"
"\n"
"var5=value5\n"
" var6=value6\n"
"\n"
"var7 = \"This is a long value.\"\n"
"var8 = \"Single-word\"\n"
"var9 = \" Single-word \"\n"
"var10 = Single-word\n"
;
const char* exp_calls[] = {
"got_var(var1, value1)",
"got_var(var2, value2)",
"got_var(var3, value3)",
"got_var(var4, value4)",
"got_var(var5, value5)",
"got_var(var6, value6)",
"got_var(var7, This is a long value.)",
"got_var(var8, Single-word)",
"got_var(var9, Single-word )",
"got_var(var10, Single-word)",
"got_eof()",
};
const char* exp_errors[] = {
};
}
{
const char* input =
"Content-Type: application/X-atf-config; version=\"1\"\n"
"\n"
"foo = bar # A comment.\n"
;
const char* exp_calls[] = {
"got_var(foo, bar)",
"got_eof()",
};
const char* exp_errors[] = {
};
}
{
const char* input =
"Content-Type: application/X-atf-config; version=\"1\"\n"
"\n"
"foo\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"3: Unexpected token `<<NEWLINE>>'; expected equal sign",
};
}
{
const char* input =
"Content-Type: application/X-atf-config; version=\"1\"\n"
"\n"
"foo bar\n"
"baz\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"3: Unexpected token `bar'; expected equal sign",
"4: Unexpected token `<<NEWLINE>>'; expected equal sign",
};
}
{
const char* input =
"Content-Type: application/X-atf-config; version=\"1\"\n"
"\n"
"foo =\n"
"bar = # A comment.\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"3: Unexpected token `<<NEWLINE>>'; expected word or quoted string",
"4: Unexpected token `#'; expected word or quoted string",
};
}
{
const char* input =
"Content-Type: application/X-atf-config; version=\"1\"\n"
"\n"
"foo = \"Correct value\" # With comment.\n"
"\n"
"bar = # A comment.\n"
"\n"
"baz = \"Last variable\"\n"
"\n"
"# End of file.\n"
;
const char* exp_calls[] = {
"got_var(foo, Correct value)",
};
const char* exp_errors[] = {
"5: Unexpected token `#'; expected word or quoted string",
};
}
{
const char* input =
"Content-Type: application/X-atf-config; version=\"1\"\n"
"\n"
"foo = \"\n"
"bar = \"text\n"
"baz = \"te\\\"xt\n"
"last = \"\\\"\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"3: Missing double quotes before end of line",
"4: Missing double quotes before end of line",
"5: Missing double quotes before end of line",
"6: Missing double quotes before end of line",
};
}
// -------------------------------------------------------------------------
// Tests for the free functions.
// -------------------------------------------------------------------------
}
}
}
}
}
// -------------------------------------------------------------------------
// Main.
// -------------------------------------------------------------------------
{
}