pretify
This commit is contained in:
parent
27722e94bc
commit
6ca1293ef1
1 changed files with 18 additions and 31 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/local/bin/ruby
|
#!/usr/local/bin/ruby
|
||||||
|
|
||||||
# $Dwarf$
|
# $Dwarf: uu_test.rb,v 1.1 2003/04/20 16:33:02 ward Exp $
|
||||||
# $Source$
|
# $Source$
|
||||||
|
|
||||||
require '../uuencode.rb'
|
require '../uuencode.rb'
|
||||||
|
|
@ -8,18 +8,18 @@ require 'ftools'
|
||||||
|
|
||||||
def test1
|
def test1
|
||||||
print "Test 1: decoding a file\n"
|
print "Test 1: decoding a file\n"
|
||||||
file = File.open("testdata.uu", mode = "r")
|
file = File.open("testdata.uu", "r")
|
||||||
tmpfile = Tempfile.new("uutmp")
|
tmpfile = Tempfile.new("uutmp")
|
||||||
tmpfile.sync=true
|
tmpfile.sync=true
|
||||||
mode, filename, body = UUEncode.uudecode(file, tmpfile)
|
mode, filename, body = UUEncode.uudecode(file, tmpfile)
|
||||||
if mode != "644"
|
if mode != "644"
|
||||||
print "Failed, mode should be 644, but is #{mode}\n"
|
print " Failed, mode should be 644, but is #{mode}\n"
|
||||||
elsif filename != "testdata"
|
elsif filename != "testdata"
|
||||||
print "Failed, filename should be \"testdata\", but is \"#{filename}\"\n"
|
print " Failed, filename should be \"testdata\", but is \"#{filename}\"\n"
|
||||||
elsif ! File.compare("testdata", tmpfile.path)
|
elsif ! File.compare("testdata", tmpfile.path)
|
||||||
print "Failed, result doesn't match reference data\n"
|
print " Failed, result doesn't match reference data\n"
|
||||||
else
|
else
|
||||||
print "Succesful\n"
|
print " Succesful\n"
|
||||||
end
|
end
|
||||||
file.close
|
file.close
|
||||||
tmpfile.close
|
tmpfile.close
|
||||||
|
|
@ -27,62 +27,49 @@ end
|
||||||
|
|
||||||
def test2
|
def test2
|
||||||
print "Test 2: decoding an array\n"
|
print "Test 2: decoding an array\n"
|
||||||
file = File.open("testdata.uu", mode = "r")
|
file = File.open("testdata.uu", "r")
|
||||||
lines = file.readlines
|
lines = file.readlines
|
||||||
file.close
|
file.close
|
||||||
file = File.open("testdata", mode = "r")
|
file = File.open("testdata", "r")
|
||||||
reference = file.readlines
|
reference = file.readlines
|
||||||
file.close
|
file.close
|
||||||
|
|
||||||
mode, filename, body = UUEncode.uudecode(lines)
|
mode, filename, body = UUEncode.uudecode(lines)
|
||||||
|
|
||||||
print "#{reference.length}\n"
|
|
||||||
print "#{body.length}\n"
|
|
||||||
if mode != "644"
|
if mode != "644"
|
||||||
print "Failed, mode should be 644, but is #{mode}\n"
|
print " Failed, mode should be 644, but is #{mode}\n"
|
||||||
elsif filename != "testdata"
|
elsif filename != "testdata"
|
||||||
print "Failed, filename should be \"testdata\", but is \"#{filename}\"\n"
|
print " Failed, filename should be \"testdata\", but is \"#{filename}\"\n"
|
||||||
elsif reference != body
|
elsif reference != body
|
||||||
print "Failed, result doesn't match reference data\n"
|
print " Failed, result doesn't match reference data\n"
|
||||||
else
|
else
|
||||||
print "Succesful\n"
|
print " Succesful\n"
|
||||||
end
|
|
||||||
print "#{reference}"
|
|
||||||
print "#{body}"
|
|
||||||
file = File.new("blup", "w")
|
|
||||||
file.print body
|
|
||||||
file.close
|
|
||||||
|
|
||||||
i = 0
|
|
||||||
while i < body.length
|
|
||||||
print "I: #{i} data: #{body[i]}"
|
|
||||||
i+=1
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test3
|
def test3
|
||||||
print "Test 3: is_uuencoded\n"
|
print "Test 3: is_uuencoded\n"
|
||||||
file = File.open("testdata.uu", mode = "r")
|
file = File.open("testdata.uu", "r")
|
||||||
lines = file.readlines
|
lines = file.readlines
|
||||||
file.close
|
file.close
|
||||||
if UUEncode.is_uuencoded(lines)
|
if UUEncode.is_uuencoded(lines)
|
||||||
print "Succesful\n"
|
print " Succesful\n"
|
||||||
else
|
else
|
||||||
print "Failed\n"
|
print " Failed\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test4
|
def test4
|
||||||
print "Test 4: get_filename\n"
|
print "Test 4: get_filename\n"
|
||||||
file = File.open("testdata.uu", mode = "r")
|
file = File.open("testdata.uu", "r")
|
||||||
lines = file.readlines
|
lines = file.readlines
|
||||||
file.close
|
file.close
|
||||||
|
|
||||||
filename = UUEncode.get_filename(lines)
|
filename = UUEncode.get_filename(lines)
|
||||||
if filename == "testdata"
|
if filename == "testdata"
|
||||||
print "Succesful\n"
|
print " Succesful\n"
|
||||||
else
|
else
|
||||||
print "Failed\n"
|
print " Failed\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue