blob: 6dbf27e29aba740a49fd9ba7e0a83cb71337e808 (
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
|
#!/usr/bin/ruby -w
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
require 'test/unit'
require 'feed2imap/channel'
class ParserTest < Test::Unit::TestCase
DATADIR = 'test/parserdata'
def test_parser
return if not File::exist?(DATADIR)
allok = true
Dir.foreach(DATADIR) do |f|
next if f !~ /.xml$/
# puts "Checking #{f}"
str = File::read(DATADIR + '/' + f)
chan = Channel::new(str)
# for easier reading, go to ISO
chanstr = chan.to_s
chanstr = chanstr.unpack('U*').pack('C*')
if File::exist?(DATADIR + '/' + f.gsub(/.xml$/, '.output'))
output = File::read(DATADIR + '/' + f.gsub(/.xml$/, '.output'))
File::open(DATADIR + '/' + f.gsub(/.xml$/, '.output.new'), "w") do |fd|
fd.print(chanstr)
end
if output != chanstr
puts "Test failed for #{f}. Try diff -u #{DATADIR + '/' + f.gsub(/.xml$/, '.output')}{,.new}"
allok = false
end
else
puts "Missing #{DATADIR + '/' + f.gsub(/.xml$/, '.output')}."
File::open(DATADIR + '/' + f.gsub(/.xml$/, '.output.new'), "w") do |f|
f.print(chanstr)
end
end
end
assert(allok)
end
end
|