#! /usr/bin/atf-sh
# $NetBSD: t_regex.in,v 1.3 2011/10/11 23:04:21 dholland Exp $
#
# Copyright (c) 2008 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
#    documentation and/or other materials provided with the distribution.
#
# 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.
#

h_check()
{
	prog="$(atf_get_srcdir)/h_regex"
	data="$(atf_get_srcdir)/data/$1.in"

	atf_check -x "${prog} <${data}"
	atf_check -x "${prog} -el <${data}"
	atf_check -x "${prog} -er <${data}"
}

atf_test_case basic
basic_head()
{
	atf_set "descr" "Checks basic functionality"
}
basic_body()
{
	h_check basic
}

atf_test_case paren
paren_head()
{
	atf_set "descr" "Checks parentheses"
}
paren_body()
{
	h_check paren
}

atf_test_case anchor
anchor_head()
{
	atf_set "descr" "Checks anchors and REG_NEWLINE"
}
anchor_body()
{
	h_check anchor
}

atf_test_case error
error_head()
{
	atf_set "descr" "Checks syntax errors and non-errors"
}
error_body()
{
	h_check error
}

atf_test_case meta
meta_head()
{
	atf_set "descr" "Checks metacharacters and backslashes"
}
meta_body()
{
	h_check meta
}

atf_test_case backref
backref_head()
{
	atf_set "descr" "Checks back references"
}
backref_body()
{
	h_check backref
}

atf_test_case repet_ordinary
repet_ordinary_head()
{
	atf_set "descr" "Checks ordinary repetitions"
}
repet_ordinary_body()
{
	h_check repet_ordinary
}

atf_test_case repet_bounded
repet_bounded_head()
{
	atf_set "descr" "Checks bounded repetitions"
}
repet_bounded_body()
{
	h_check repet_bounded
}

atf_test_case repet_multi
repet_multi_head()
{
	atf_set "descr" "Checks multiple repetitions"
}
repet_multi_body()
{
	h_check repet_multi
}

atf_test_case bracket
bracket_head()
{
	atf_set "descr" "Checks brackets"
}
bracket_body()
{
	h_check bracket
}

atf_test_case complex
complex_head()
{
	atf_set "descr" "Checks various complex examples"
}
complex_body()
{
	h_check complex
}

atf_test_case subtle
subtle_head()
{
	atf_set "descr" "Checks various subtle examples"
}
subtle_body()
{
	h_check subtle
}

atf_test_case c_comments
c_comments_head()
{
	atf_set "descr" "Checks matching C comments"
}
c_comments_body()
{
	h_check c_comments
}

atf_test_case subexp
subexp_head()
{
	atf_set "descr" "Checks subexpressions"
}
subexp_body()
{
	h_check subexp
}

atf_test_case startend
startend_head()
{
	atf_set "descr" "Checks STARTEND option"
}
startend_body()
{
	h_check startend
}

atf_test_case nospec
nospec_head()
{
	atf_set "descr" "Checks NOSPEC option"
}
nospec_body()
{
	h_check nospec
}

atf_test_case zero
zero_head()
{
	atf_set "descr" "Checks NULs"
}
zero_body()
{
	h_check zero
}

atf_test_case word_bound
word_bound_head()
{
	atf_set "descr" "Checks word boundaries"
}
word_bound_body()
{
	h_check word_bound
}

atf_test_case regress
regress_head()
{
	atf_set "descr" "Checks various past problems and suspected problems"
}
regress_body()
{
	h_check regress
}


atf_init_test_cases()
{
	atf_add_test_case basic
	atf_add_test_case paren
	atf_add_test_case anchor
	atf_add_test_case error
	atf_add_test_case meta
	atf_add_test_case backref
	atf_add_test_case repet_ordinary
	atf_add_test_case repet_bounded
	atf_add_test_case repet_multi
	atf_add_test_case bracket
	atf_add_test_case complex
	atf_add_test_case subtle
	atf_add_test_case c_comments
	atf_add_test_case subexp
	atf_add_test_case startend
	atf_add_test_case nospec
	atf_add_test_case zero
	atf_add_test_case word_bound
	atf_add_test_case regress
}
