1# -*- tcl -*-
2# idx_export_docidx.test:  tests for the doctools::idx::export::docidx package/plugin.
3#
4# Copyright (c) 2009 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
5# All rights reserved.
6#
7# RCS: @(#) $Id: export_docidx.test,v 1.1 2009/04/01 04:28:37 andreas_kupries Exp $
8
9# -------------------------------------------------------------------------
10
11source [file join \
12	[file dirname [file dirname [file join [pwd] [info script]]]] \
13	devtools testutilities.tcl]
14
15testsNeedTcl     8.4
16testsNeedTcltest 2.0
17
18support {
19    use      fileutil/fileutil.tcl  fileutil      ;# tests/common
20    useLocal structure.tcl      doctools::idx::structure
21}
22testing {
23    package provide doctools::idx::export::plugin 1
24    # The above fakes the export plugin environment.
25
26    useLocal export_docidx.tcl doctools::idx::export::docidx
27}
28
29source [tcllibPath doctools2base/tests/common]
30set mytestdir tests/data
31
32# -------------------------------------------------------------------------
33
34# General set of error cases regarding the number of arguments.
35
36test doctools-idx-export-docidx-1.0 {export, wrong#args} -body {
37    export
38} -returnCodes error -result {wrong # args: should be "export serial configuration"}
39
40test doctools-idx-export-docidx-1.1 {export, wrong#args} -body {
41    export S
42} -returnCodes error -result {wrong # args: should be "export serial configuration"}
43
44test doctools-idx-export-docidx-1.2 {export, wrong#args} -body {
45    export S C XXX
46} -returnCodes error -result {wrong # args: should be "export serial configuration"}
47
48# -------------------------------------------------------------------------
49
50# Testing the generation of docidx output, from index serialization,
51# for all possible plugin configurations.
52
53foreach {k nl in al name} {
54    0 0 0 0 ultracompact
55    1 1 0 0 compact
56    2 1 1 0 indented
57    3 1 0 1 aligned
58    4 1 1 1 indalign
59    5 0 1 0 indented
60    6 0 0 1 aligned
61    7 0 1 1 indalign
62} {
63    TestFilesProcess $mytestdir ok serial docidx-$name -> n label input data expected {
64	test doctools-idx-export-docidx-2.$k.$n "doctools::idx::export::docidx, ${label}-$name, ok" -setup {
65	    set configuration [list newlines $nl indented $in aligned $al user _dummy_]
66	} -body {
67	    stripcomments [export $data $configuration]
68	} -cleanup {
69	    unset configuration
70	} -result $expected
71    }
72}
73
74#----------------------------------------------------------------------
75unset n label input data expected
76testsuiteCleanup
77return
78