summaryrefslogtreecommitdiffstats
path: root/tests/zipfs.test
blob: adacbde0166d0053d3bb3ba1df36560f6ed7b519 (plain)
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
# The file tests the tclZlib.c file.
#
# This file contains a collection of tests for one or more of the Tcl built-in
# commands. Sourcing this file into Tcl runs the tests and generates output
# for errors. No output means no errors were found.
#
# Copyright (c) 1996-1998 by Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.

if {"::tcltest" ni [namespace children]} {
    package require tcltest 2.1
    namespace import -force ::tcltest::*
}

testConstraint zipfs [expr {[llength [info commands zlib]] && [regexp tcltest [info nameofexecutable]]}]

test zipfs-1.1 {zipfs basics} -constraints zipfs -body {
    load {} zipfs
} -result {}

test zipfs-1.2 {zipfs basics} -constraints zipfs -body {
    package require zipfs
} -result {1.0}

test zipfs-1.3 {zipfs basics} -constraints zipfs -returnCodes error -body {
    zipfs mount a b c d e f
} -result {wrong # args: should be "zipfs mount ?zipfile? ?mountpoint? ?password?"}

test zipfs-1.4 {zipfs basics} -constraints zipfs -returnCodes error -body {
    zipfs unmount a b c d e f
} -result {wrong # args: should be "zipfs unmount zipfile"}

test zipfs-1.5 {zipfs basics} -constraints zipfs -returnCodes error -body {
    zipfs mkkey a b c d e f
} -result {wrong # args: should be "zipfs mkkey password"}

test zipfs-1.6 {zipfs basics} -constraints zipfs -returnCodes error -body {
    zipfs mkimg a b c d e f
} -result {wrong # args: should be "zipfs mkimg outfile indir ?strip? ?password? ?infile?"}

test zipfs-1.7 {zipfs basics} -constraints zipfs -returnCodes error -body {
    zipfs mkzip a b c d e f
} -result {wrong # args: should be "zipfs mkzip outfile indir ?strip? ?password?"}

test zipfs-1.8 {zipfs basics} -constraints zipfs -returnCodes error -body {
    zipfs exists a b c d e f
} -result {wrong # args: should be "zipfs exists filename"}

test zipfs-1.9 {zipfs basics} -constraints zipfs -returnCodes error -body {
    zipfs info a b c d e f
} -result {wrong # args: should be "zipfs info filename"}

test zipfs-1.10 {zipfs basics} -constraints zipfs -returnCodes error -body {
    zipfs list a b c d e f
} -result {wrong # args: should be "zipfs list ?(-glob|-regexp)? ?pattern?"}


test zipfs-2.1 {zipfs mkzip empty archive} -constraints zipfs -returnCodes error -body {
    zipfs mkzip abc.zip $tcl_library/xxxx
} -result {empty archive}

test zipfs-2.2 {zipfs mkzip} -constraints zipfs -body {
    set pwd [pwd]
    cd $tcl_library/encoding
    zipfs mkzip abc.zip .
    zipfs mount abc.zip /abc
    zipfs list -glob /abc/cp850.*
} -cleanup {
    cd $pwd
} -result {/abc/cp850.enc}

test zipfs-2.3 {zipfs unmount} -constraints zipfs -body {
    zipfs info /abc/cp850.enc
} -result [list $tcl_library/encoding/abc.zip 1090 527 39434]

test zipfs-2.4 {zipfs unmount} -constraints zipfs -body {
    set f [open /abc/cp850.enc]
    read $f
} -result {# Encoding file: cp850, single-byte
S
003F 0 1
00
0000000100020003000400050006000700080009000A000B000C000D000E000F
0010001100120013001400150016001700180019001A001B001C001D001E001F
0020002100220023002400250026002700280029002A002B002C002D002E002F
0030003100320033003400350036003700380039003A003B003C003D003E003F
0040004100420043004400450046004700480049004A004B004C004D004E004F
0050005100520053005400550056005700580059005A005B005C005D005E005F
0060006100620063006400650066006700680069006A006B006C006D006E006F
0070007100720073007400750076007700780079007A007B007C007D007E007F
00C700FC00E900E200E400E000E500E700EA00EB00E800EF00EE00EC00C400C5
00C900E600C600F400F600F200FB00F900FF00D600DC00F800A300D800D70192
00E100ED00F300FA00F100D100AA00BA00BF00AE00AC00BD00BC00A100AB00BB
2591259225932502252400C100C200C000A9256325512557255D00A200A52510
25142534252C251C2500253C00E300C3255A25542569256625602550256C00A4
00F000D000CA00CB00C8013100CD00CE00CF2518250C2588258400A600CC2580
00D300DF00D400D200F500D500B500FE00DE00DA00DB00D900FD00DD00AF00B4
00AD00B1201700BE00B600A700F700B800B000A800B700B900B300B225A000A0
}

test zipfs-2.5 {zipfs exists} -constraints zipfs -body {
    zipfs unmount abc.zip
    zipfs exists /abc/cp850.enc
} -cleanup {
    file delete abc.zip
} -result 1

::tcltest::cleanupTests
return

# Local Variables:
# mode: tcl
# End: