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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
|
# -*- tcl -*-
# docidx_structure.test: tests for the doctools::idx::structure package.
#
# Copyright (c) 2009 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
# All rights reserved.
#
# RCS: @(#) $Id: structure.test,v 1.1 2009/04/01 04:28:37 andreas_kupries Exp $
# -------------------------------------------------------------------------
source [file join \
[file dirname [file dirname [file join [pwd] [info script]]]] \
devtools testutilities.tcl]
testsNeedTcl 8.4
testsNeedTcltest 2.0
support {
use fileutil/fileutil.tcl fileutil ; # For tests/common
use snit/snit.tcl snit
}
testing {
useLocal structure.tcl doctools::idx::structure
}
# -------------------------------------------------------------------------
source [tcllibPath doctools2base/tests/common]
set mytestdir tests/data
# -------------------------------------------------------------------------
test doctools-idx-structure-1.0 {structure verify, wrong#args} -body {
doctools::idx::structure verify
} -returnCodes error -result {wrong # args: should be "::doctools::idx::structure::Snit_typemethodverify type serial ?canonvar?"}
test doctools-idx-structure-1.1 {structure verify, wrong#args} -body {
doctools::idx::structure verify S V XXX
} -returnCodes error -result {wrong # args: should be "::doctools::idx::structure::Snit_typemethodverify type serial ?canonvar?"}
test doctools-idx-structure-2.0 {structure verify, wrong#args} -body {
doctools::idx::structure verify-as-canonical
} -returnCodes error -result {wrong # args: should be "::doctools::idx::structure::Snit_typemethodverify-as-canonical type serial"}
test doctools-idx-structure-2.1 {structure verify, wrong#args} -body {
doctools::idx::structure verify-as-canonical S XXX
} -returnCodes error -result {wrong # args: should be "::doctools::idx::structure::Snit_typemethodverify-as-canonical type serial"}
test doctools-idx-structure-3.0 {structure print, wrong#args} -body {
doctools::idx::structure print
} -returnCodes error -result {wrong # args: should be "::doctools::idx::structure::Snit_typemethodprint type serial"}
test doctools-idx-structure-3.1 {structure print, wrong#args} -body {
doctools::idx::structure print S XXX
} -returnCodes error -result {wrong # args: should be "::doctools::idx::structure::Snit_typemethodprint type serial"}
test doctools-idx-structure-4.0 {structure merge, wrong#args} -body {
doctools::idx::structure merge
} -returnCodes error -result {wrong # args: should be "::doctools::idx::structure::Snit_typemethodmerge type seriala serialb"}
test doctools-idx-structure-4.1 {structure merge, wrong#args} -body {
doctools::idx::structure merge SA
} -returnCodes error -result {wrong # args: should be "::doctools::idx::structure::Snit_typemethodmerge type seriala serialb"}
test doctools-idx-structure-4.2 {structure merge, wrong#args} -body {
doctools::idx::structure merge SA SB XXX
} -returnCodes error -result {wrong # args: should be "::doctools::idx::structure::Snit_typemethodmerge type seriala serialb"}
# -------------------------------------------------------------------------
TestFilesProcess $mytestdir ok serial text -> n label input data expected {
# The 'expected' data is irrelevant here, only used to satisfy
# TestFilesProcess' syntax.
test doctools-idx-structure-5.$n "doctools::idx::structure verify, $label, ok" -body {
doctools::idx::structure verify $data
} -result {}
}
# -------------------------------------------------------------------------
foreach {n badserial expected} {
0 {}
{error in serialization: dictionary too short, expected exactly one key}
1 {FOO {}}
{error in serialization: bad type tag "FOO"}
2 {doctools::idx {}}
{error in serialization: dictionary too short, expected exactly four keys}
3 {doctools::idx {a . b . c . d .}}
{error in serialization: missing expected key "label"}
4 {doctools::idx {label . b . c . d .}}
{error in serialization: missing expected key "title"}
5 {doctools::idx {label . title . c . d .}}
{error in serialization: missing expected key "keywords"}
6 {doctools::idx {label . title . keywords . d .}}
{error in serialization: missing expected key "references"}
7 {doctools::idx {label . title . keywords {} references {}}}
{error in serialization: duplicate and/or unsorted keywords/identifiers}
8 {doctools::idx {label . keywords {k {} k {}} references {} title .}}
{error in serialization: duplicate keywords}
9 {doctools::idx {label . keywords {b {} a {}} references {} title .}}
{error in serialization: duplicate and/or unsorted keywords/identifiers}
10 {doctools::idx {label . keywords {} references {a {url x}} title .}}
{error in serialization: use and declaration of references not matching}
11 {doctools::idx {label . keywords {a {b c}} references {} title .}}
{error in serialization: use and declaration of references not matching}
12 {doctools::idx {label . keywords {a {b}} references {b {url}} title .}}
{error in serialization: reference list wrong, need exactly 2}
13 {doctools::idx {label . keywords {a {b}} references {b {foo B}} title .}}
{error in serialization: bad reference tag "foo"}
14 {doctools::idx {label . keywords {a {b}} references {b {url B} b {url A}} title .}}
{error in serialization: duplicate reference identifiers}
15 {doctools::idx {label . keywords {a {b c}} references {c {url C} b {url B}} title .}}
{error in serialization: duplicate and/or unsorted keywords/identifiers}
} {
test doctools-idx-structure-6.$n "doctools::idx::structure verify-as-canonical, error" -body {
doctools::idx::structure verify-as-canonical $badserial
} -returnCodes error -result $expected
}
#----------------------------------------------------------------------
foreach {n badserial expected} {
0 {}
{error in serialization: dictionary too short, expected exactly one key}
1 {FOO {}}
{error in serialization: bad type tag "FOO"}
2 {doctools::idx {}}
{error in serialization: dictionary too short, expected exactly four keys}
3 {doctools::idx {a . b . c . d .}}
{error in serialization: missing expected key "label"}
4 {doctools::idx {label . b . c . d .}}
{error in serialization: missing expected key "title"}
5 {doctools::idx {label . title . c . d .}}
{error in serialization: missing expected key "keywords"}
6 {doctools::idx {label . title . keywords . d .}}
{error in serialization: missing expected key "references"}
8 {doctools::idx {label . keywords {k {} k {}} references {} title .}}
{error in serialization: duplicate keywords}
10 {doctools::idx {label . keywords {} references {a {url x}} title .}}
{error in serialization: use and declaration of references not matching}
11 {doctools::idx {label . keywords {a {b c}} references {} title .}}
{error in serialization: use and declaration of references not matching}
12 {doctools::idx {label . keywords {a {b}} references {b {url}} title .}}
{error in serialization: reference list wrong, need exactly 2}
13 {doctools::idx {label . keywords {a {b}} references {b {foo B}} title .}}
{error in serialization: bad reference tag "foo"}
14 {doctools::idx {label . keywords {a {b}} references {b {url B} b {url A}} title .}}
{error in serialization: duplicate reference identifiers}
} {
test doctools-idx-structure-7.$n "doctools::idx::structure verify, error" -body {
doctools::idx::structure verify $badserial
} -returnCodes error -result $expected
}
#----------------------------------------------------------------------
# TODO merge ... also test cases for doctools::idx
#----------------------------------------------------------------------
unset mytestdir n badserial expected label input data
testsuiteCleanup
return
|