# t410 --- co -p
#
# Copyright (C) 2010, 2011 Thien-Thi Nguyen
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

. $srcdir/common
. $srcdir/common-kn
split_std_out_err no
$hey echo '                                    -*- org -*-'
$hey type co

##
# Check "co -p[REV]" works for various values of REV,
# both valid and invalid.  For valid values, also check output.
##

prep_b_comparison

##
# * First, does invalid revision cause error?
##

xfail ()
{
    # $1 -- revision
    rev=$1
    $hey echo "* xfail: $subst"

    co -p$rev $v > /dev/null &&
    problem "co -p does not barf on invalid revision: $rev"
##
#   TODO: Check error message.
##
}

xfail 0.0
xfail 1.0
xfail 11.11

##
# * Now test with valid revisions, numeric and symbolic.
##

ok ()
{
    # $1 -- revision
    # $2 -- (optional) normalized name
    rev=$1
    title="co -p$rev"
    fn=$(echo $rev | tr -d '.')
    expected="$(bundled_commav b.d/${fn}.cou)"

    $hey echo "* $rev"
    must "co -p$rev $v > $actual"
    normalize_b_and_diff "$title"
}

ok 1.1
ok 1.1.1.1
ok 1.1.1.2
ok 1.1.1.3
ok 1.1.1.4
ok 1.1.1.5
ok 1.1.1.6
ok 1.1.1.7
ok 1.2
ok 1.5
ok 1.6
ok 1.6.1.1
ok 1.6.1.2
ok 1.7
ok 1.8
ok 1.9

ok WOW
ok ZOW

exit 0

# t410 ends here
