File: test_msgid.tcl

package info (click to toggle)
tkrat 1%3A2.2cvs20100105-true-dfsg-6.1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 10,340 kB
  • ctags: 9,259
  • sloc: ansic: 96,057; tcl: 25,667; makefile: 1,638; sh: 282
file content (53 lines) | stat: -rw-r--r-- 1,249 bytes parent folder | download | duplicates (4)
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
puts "$HEAD Test Messsage-ID parsing"

namespace eval test_msgid {
}

proc test_msgid::test_msgid {} {
    global option dir hdr

    # List of message-ids to test
    # Each element in teh list is a tuple
    #   Header - Header to look in
    #   MsgId  - Expected message id
    set tests {
	{"<msg@id>" "msg@id"}
	{"<msg1@id> <msg2@id>" "msg2@id"}
	{"<msg@id> (foo <foo@bar.com>'s message at)" "msg@id"}
	{"<\\>\">\"[>]msg@id>" "\{>>[>]msg@id\}"}
    }

    # Folder to use for testing
    set fn $dir/folder.[pid]
    set def [list Test file {} $fn]

    foreach te $tests {
	StartTest "Parsing '[lindex $te 0]'"

	# Generate folder
	set fh [open $fn w 0644]
	puts $fh $hdr
	puts $fh "From maf@kilauea Thu Sep  6 14:25:09 2001 -0400"
	puts $fh "Date: Thu, 06 Sep 2001 14:25:00"
	puts $fh "Message-ID: [lindex $te 0]"
	puts $fh ""
	puts $fh "Body"
	close $fh

	# Read message and get msgid
	set f [RatOpenFolder $def]
	set actual [$f list %M]
	$f close

	# Verify
	if {[string compare $actual [lindex $te 1]]} {
	    ReportError [join [list "Failed to extract correct msgid" \
				   "  Header: [lindex $te 0]" \
				   "Expected: [lindex $te 1]" \
				   "  Actual: $actual"] "\n"]
	}
    }
    file delete -force $fn
}

test_msgid::test_msgid