ptools 1.2.2-universal-mingw32 → 1.2.3-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_middle.rb CHANGED
@@ -1,61 +1,61 @@
1
- #####################################################################
2
- # test_middle.rb
3
- #
4
- # Test case for the File.middle method. You should run this test
5
- # via the 'rake test_middle' task.
6
- #####################################################################
7
- require 'rubygems'
8
- gem 'test-unit'
9
-
10
- require 'test/unit'
11
- require 'ptools'
12
-
13
- class TC_FileMiddle < Test::Unit::TestCase
14
- def self.startup
15
- Dir.chdir('test') if File.exists?('test')
16
- File.open('test_file1.txt', 'w'){ |fh| 25.times{ |n| fh.puts "line#{n+1}" } }
17
- end
18
-
19
- def setup
20
- @test_file = 'test_file1.txt'
21
-
22
- @expected_middle1 = ["line10\n", "line11\n", "line12\n", "line13\n", "line14\n"]
23
- @expected_middle1.push("line15\n","line16\n", "line17\n", "line18\n")
24
- @expected_middle1.push("line19\n","line20\n")
25
-
26
- @expected_middle2 = ["line14\n","line15\n","line16\n","line17\n"]
27
- @expected_middle2.push("line18\n","line19\n","line20\n")
28
-
29
- @expected_middle3 = ["line5\n","line6\n","line7\n"]
30
- @expected_middle3.push("line8\n","line9\n","line10\n")
31
- end
32
-
33
- def test_method_basic
34
- assert_respond_to(File, :middle)
35
- assert_nothing_raised{ File.middle(@test_file) }
36
- assert_nothing_raised{ File.middle(@test_file, 14) }
37
- assert_nothing_raised{ File.middle(@test_file, 5, 10) }
38
- assert_nothing_raised{ File.middle(@test_file){} }
39
- end
40
-
41
- def test_middle_expected_results
42
- assert_kind_of(Array, File.middle(@test_file))
43
- assert_equal(@expected_middle1, File.middle(@test_file))
44
- assert_equal(@expected_middle2, File.middle(@test_file, 14))
45
- assert_equal(@expected_middle3, File.middle(@test_file, 5, 10))
46
- end
47
-
48
- def test_middle_expected_errors
49
- assert_raises(ArgumentError){ File.middle }
50
- assert_raises(ArgumentError){ File.middle(@test_file, 5, 10, 15) }
51
- assert_raises(NoMethodError){ File.middle(@test_file, "foo") }
52
- assert_raises(Errno::ENOENT){ File.middle("bogus") }
53
- end
54
-
55
- def teardown
56
- @test_file = nil
57
- @expected_middle1 = nil
58
- @expected_middle2 = nil
59
- @expected_middle3 = nil
60
- end
61
- end
1
+ #####################################################################
2
+ # test_middle.rb
3
+ #
4
+ # Test case for the File.middle method. You should run this test
5
+ # via the 'rake test_middle' task.
6
+ #####################################################################
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'test/unit'
11
+ require 'ptools'
12
+
13
+ class TC_FileMiddle < Test::Unit::TestCase
14
+ def self.startup
15
+ Dir.chdir('test') if File.exists?('test')
16
+ File.open('test_file1.txt', 'w'){ |fh| 25.times{ |n| fh.puts "line#{n+1}" } }
17
+ end
18
+
19
+ def setup
20
+ @test_file = 'test_file1.txt'
21
+
22
+ @expected_middle1 = ["line10\n", "line11\n", "line12\n", "line13\n", "line14\n"]
23
+ @expected_middle1.push("line15\n","line16\n", "line17\n", "line18\n")
24
+ @expected_middle1.push("line19\n","line20\n")
25
+
26
+ @expected_middle2 = ["line14\n","line15\n","line16\n","line17\n"]
27
+ @expected_middle2.push("line18\n","line19\n","line20\n")
28
+
29
+ @expected_middle3 = ["line5\n","line6\n","line7\n"]
30
+ @expected_middle3.push("line8\n","line9\n","line10\n")
31
+ end
32
+
33
+ def test_method_basic
34
+ assert_respond_to(File, :middle)
35
+ assert_nothing_raised{ File.middle(@test_file) }
36
+ assert_nothing_raised{ File.middle(@test_file, 14) }
37
+ assert_nothing_raised{ File.middle(@test_file, 5, 10) }
38
+ assert_nothing_raised{ File.middle(@test_file){} }
39
+ end
40
+
41
+ def test_middle_expected_results
42
+ assert_kind_of(Array, File.middle(@test_file))
43
+ assert_equal(@expected_middle1, File.middle(@test_file))
44
+ assert_equal(@expected_middle2, File.middle(@test_file, 14))
45
+ assert_equal(@expected_middle3, File.middle(@test_file, 5, 10))
46
+ end
47
+
48
+ def test_middle_expected_errors
49
+ assert_raises(ArgumentError){ File.middle }
50
+ assert_raises(ArgumentError){ File.middle(@test_file, 5, 10, 15) }
51
+ assert_raises(NoMethodError){ File.middle(@test_file, "foo") }
52
+ assert_raises(Errno::ENOENT){ File.middle("bogus") }
53
+ end
54
+
55
+ def teardown
56
+ @test_file = nil
57
+ @expected_middle1 = nil
58
+ @expected_middle2 = nil
59
+ @expected_middle3 = nil
60
+ end
61
+ end
@@ -1,99 +1,99 @@
1
- #####################################################################
2
- # test_nlconvert.rb
3
- #
4
- # Test case for the File.nl_convert method. You should run this
5
- # test via the 'rake test_nlconvert' task.
6
- #####################################################################
7
- require 'rubygems'
8
- require 'test-unit'
9
- require 'ptools'
10
-
11
- class TC_Ptools_NLConvert < Test::Unit::TestCase
12
- def self.startup
13
- Dir.chdir('test') if File.exists?('test')
14
- @@test_file1 = 'test_nl_convert1.txt'
15
- @@test_file2 = 'test_nl_convert2.txt'
16
- File.open(@@test_file1, 'w'){ |fh| 10.times{ |n| fh.puts "line #{n}" } }
17
- File.open(@@test_file2, 'w'){ |fh| 10.times{ |n| fh.puts "line #{n}" } }
18
- end
19
-
20
- def setup
21
- @test_file1 = 'test_nl_convert1.txt'
22
- @test_file2 = 'test_nl_convert2.txt'
23
- @dos_file = 'dos_test_file.txt'
24
- @mac_file = 'mac_test_file.txt'
25
- @unix_file = 'nix_test_file.txt'
26
- end
27
-
28
- test "nl_convert basic functionality" do
29
- assert_respond_to(File, :nl_convert)
30
- end
31
-
32
- test "nl_convert accepts one, two or three arguments" do
33
- assert_nothing_raised{ File.nl_convert(@test_file2) }
34
- assert_nothing_raised{ File.nl_convert(@test_file2, @test_file2) }
35
- assert_nothing_raised{ File.nl_convert(@test_file2, @test_file2, "unix") }
36
- end
37
-
38
- test "nl_convert with dos platform argument works as expected" do
39
- msg = "dos file should be larger, but isn't"
40
-
41
- assert_nothing_raised{ File.nl_convert(@test_file1, @dos_file, "dos") }
42
- assert_true(File.size(@dos_file) > File.size(@test_file1), msg)
43
- assert_equal(["\cM","\cJ"], IO.readlines(@dos_file).first.split("")[-2..-1])
44
- end
45
-
46
- test "nl_convert with mac platform argument works as expected" do
47
- assert_nothing_raised{ File.nl_convert(@test_file1, @mac_file, 'mac') }
48
- assert_equal("\cM", IO.readlines(@mac_file).first.split("").last)
49
-
50
- omit_if(File::ALT_SEPARATOR)
51
- msg = "=> Mac file should be the same size (or larger), but isn't"
52
- assert_true(File.size(@mac_file) == File.size(@test_file1), msg)
53
- end
54
-
55
- test "nl_convert with unix platform argument works as expected" do
56
- msg = "unix file should be the same size (or smaller), but isn't"
57
-
58
- assert_nothing_raised{ File.nl_convert(@test_file1, @unix_file, "unix") }
59
- assert_equal("\n", IO.readlines(@unix_file).first.split("").last)
60
-
61
- if File::ALT_SEPARATOR
62
- assert_true(File.size(@unix_file) >= File.size(@test_file1), msg)
63
- else
64
- assert_true(File.size(@unix_file) <= File.size(@test_file1), msg)
65
- end
66
- end
67
-
68
- test "nl_convert requires at least one argument" do
69
- assert_raise(ArgumentError){ File.nl_convert }
70
- end
71
-
72
- test "nl_convert requires a valid platform string" do
73
- assert_raise(ArgumentError){ File.nl_convert(@test_file1, "bogus.txt", "blah") }
74
- end
75
-
76
- test "nl_convert accepts a maximum of three arguments" do
77
- assert_raise(ArgumentError){ File.nl_convert(@test_file1, @test_file2, 'dos', 1) }
78
- end
79
-
80
- test "nl_convert will fail on anything but plain files" do
81
- assert_raise(ArgumentError){ File.nl_convert(File.null_device, @test_file1) }
82
- end
83
-
84
- def teardown
85
- [@dos_file, @mac_file, @unix_file].each{ |file|
86
- File.delete(file) if File.exists?(file)
87
- }
88
- @dos_file = nil
89
- @mac_file = nil
90
- @unix_file = nil
91
- @test_file1 = nil
92
- @test_file2 = nil
93
- end
94
-
95
- def self.shutdown
96
- File.delete(@@test_file1) if File.exists?(@@test_file1)
97
- File.delete(@@test_file2) if File.exists?(@@test_file2)
98
- end
99
- end
1
+ #####################################################################
2
+ # test_nlconvert.rb
3
+ #
4
+ # Test case for the File.nl_convert method. You should run this
5
+ # test via the 'rake test_nlconvert' task.
6
+ #####################################################################
7
+ require 'rubygems'
8
+ require 'test-unit'
9
+ require 'ptools'
10
+
11
+ class TC_Ptools_NLConvert < Test::Unit::TestCase
12
+ def self.startup
13
+ Dir.chdir('test') if File.exists?('test')
14
+ @@test_file1 = 'test_nl_convert1.txt'
15
+ @@test_file2 = 'test_nl_convert2.txt'
16
+ File.open(@@test_file1, 'w'){ |fh| 10.times{ |n| fh.puts "line #{n}" } }
17
+ File.open(@@test_file2, 'w'){ |fh| 10.times{ |n| fh.puts "line #{n}" } }
18
+ end
19
+
20
+ def setup
21
+ @test_file1 = 'test_nl_convert1.txt'
22
+ @test_file2 = 'test_nl_convert2.txt'
23
+ @dos_file = 'dos_test_file.txt'
24
+ @mac_file = 'mac_test_file.txt'
25
+ @unix_file = 'nix_test_file.txt'
26
+ end
27
+
28
+ test "nl_convert basic functionality" do
29
+ assert_respond_to(File, :nl_convert)
30
+ end
31
+
32
+ test "nl_convert accepts one, two or three arguments" do
33
+ assert_nothing_raised{ File.nl_convert(@test_file2) }
34
+ assert_nothing_raised{ File.nl_convert(@test_file2, @test_file2) }
35
+ assert_nothing_raised{ File.nl_convert(@test_file2, @test_file2, "unix") }
36
+ end
37
+
38
+ test "nl_convert with dos platform argument works as expected" do
39
+ msg = "dos file should be larger, but isn't"
40
+
41
+ assert_nothing_raised{ File.nl_convert(@test_file1, @dos_file, "dos") }
42
+ assert_true(File.size(@dos_file) > File.size(@test_file1), msg)
43
+ assert_equal(["\cM","\cJ"], IO.readlines(@dos_file).first.split("")[-2..-1])
44
+ end
45
+
46
+ test "nl_convert with mac platform argument works as expected" do
47
+ assert_nothing_raised{ File.nl_convert(@test_file1, @mac_file, 'mac') }
48
+ assert_equal("\cM", IO.readlines(@mac_file).first.split("").last)
49
+
50
+ omit_if(File::ALT_SEPARATOR)
51
+ msg = "=> Mac file should be the same size (or larger), but isn't"
52
+ assert_true(File.size(@mac_file) == File.size(@test_file1), msg)
53
+ end
54
+
55
+ test "nl_convert with unix platform argument works as expected" do
56
+ msg = "unix file should be the same size (or smaller), but isn't"
57
+
58
+ assert_nothing_raised{ File.nl_convert(@test_file1, @unix_file, "unix") }
59
+ assert_equal("\n", IO.readlines(@unix_file).first.split("").last)
60
+
61
+ if File::ALT_SEPARATOR
62
+ assert_true(File.size(@unix_file) >= File.size(@test_file1), msg)
63
+ else
64
+ assert_true(File.size(@unix_file) <= File.size(@test_file1), msg)
65
+ end
66
+ end
67
+
68
+ test "nl_convert requires at least one argument" do
69
+ assert_raise(ArgumentError){ File.nl_convert }
70
+ end
71
+
72
+ test "nl_convert requires a valid platform string" do
73
+ assert_raise(ArgumentError){ File.nl_convert(@test_file1, "bogus.txt", "blah") }
74
+ end
75
+
76
+ test "nl_convert accepts a maximum of three arguments" do
77
+ assert_raise(ArgumentError){ File.nl_convert(@test_file1, @test_file2, 'dos', 1) }
78
+ end
79
+
80
+ test "nl_convert will fail on anything but plain files" do
81
+ assert_raise(ArgumentError){ File.nl_convert(File.null_device, @test_file1) }
82
+ end
83
+
84
+ def teardown
85
+ [@dos_file, @mac_file, @unix_file].each{ |file|
86
+ File.delete(file) if File.exists?(file)
87
+ }
88
+ @dos_file = nil
89
+ @mac_file = nil
90
+ @unix_file = nil
91
+ @test_file1 = nil
92
+ @test_file2 = nil
93
+ end
94
+
95
+ def self.shutdown
96
+ File.delete(@@test_file1) if File.exists?(@@test_file1)
97
+ File.delete(@@test_file2) if File.exists?(@@test_file2)
98
+ end
99
+ end
data/test/test_null.rb CHANGED
@@ -1,40 +1,40 @@
1
- #####################################################################
2
- # test_null.rb
3
- #
4
- # Test case for the File.null method. You should run this test via
5
- # the 'rake test_null' task.
6
- #####################################################################
7
- require 'rubygems'
8
- gem 'test-unit'
9
-
10
- require 'test/unit'
11
- require 'ptools'
12
-
13
- class TC_FileNull < Test::Unit::TestCase
14
- def setup
15
- @nulls = ['/dev/null', 'NUL', 'NIL:', 'NL:']
16
- end
17
-
18
- test "null method basic functionality" do
19
- assert_respond_to(File, :null)
20
- assert_nothing_raised{ File.null }
21
- end
22
-
23
- test "null method returns expected results" do
24
- assert_kind_of(String, File.null)
25
- assert(@nulls.include?(File.null))
26
- end
27
-
28
- test "null method does not accept any arguments" do
29
- assert_raises(ArgumentError){ File.null(1) }
30
- end
31
-
32
- test "null_device is an alias for null" do
33
- assert_respond_to(File, :null_device)
34
- assert_alias_method(File, :null_device, :null)
35
- end
36
-
37
- def teardown
38
- @nulls = nil
39
- end
40
- end
1
+ #####################################################################
2
+ # test_null.rb
3
+ #
4
+ # Test case for the File.null method. You should run this test via
5
+ # the 'rake test_null' task.
6
+ #####################################################################
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'test/unit'
11
+ require 'ptools'
12
+
13
+ class TC_FileNull < Test::Unit::TestCase
14
+ def setup
15
+ @nulls = ['/dev/null', 'NUL', 'NIL:', 'NL:']
16
+ end
17
+
18
+ test "null method basic functionality" do
19
+ assert_respond_to(File, :null)
20
+ assert_nothing_raised{ File.null }
21
+ end
22
+
23
+ test "null method returns expected results" do
24
+ assert_kind_of(String, File.null)
25
+ assert(@nulls.include?(File.null))
26
+ end
27
+
28
+ test "null method does not accept any arguments" do
29
+ assert_raises(ArgumentError){ File.null(1) }
30
+ end
31
+
32
+ test "null_device is an alias for null" do
33
+ assert_respond_to(File, :null_device)
34
+ assert_alias_method(File, :null_device, :null)
35
+ end
36
+
37
+ def teardown
38
+ @nulls = nil
39
+ end
40
+ end
data/test/test_tail.rb CHANGED
@@ -1,56 +1,56 @@
1
- #####################################################################
2
- # test_tail.rb
3
- #
4
- # Test case for the File.tail method. This test should be run via
5
- # the 'rake test_tail' task.
6
- #####################################################################
7
- require 'rubygems'
8
- gem 'test-unit'
9
-
10
- require 'test/unit'
11
- require 'ptools'
12
-
13
- class TC_FileTail < Test::Unit::TestCase
14
- def self.startup
15
- Dir.chdir('test') if File.exists?('test')
16
- File.open('test_file1.txt', 'w'){ |fh| 25.times{ |n| fh.puts "line#{n+1}" } }
17
- end
18
-
19
- def setup
20
- @test_file = 'test_file1.txt'
21
-
22
- @expected_tail1 = ["line16\n","line17\n","line18\n","line19\n"]
23
- @expected_tail1.push("line20\n","line21\n","line22\n", "line23\n")
24
- @expected_tail1.push("line24\n","line25\n")
25
-
26
- @expected_tail2 = ["line21\n","line22\n","line23\n","line24\n","line25\n"]
27
- end
28
-
29
- def test_tail_basic
30
- assert_respond_to(File, :tail)
31
- assert_nothing_raised{ File.tail(@test_file) }
32
- assert_nothing_raised{ File.tail(@test_file, 5) }
33
- assert_nothing_raised{ File.tail(@test_file){} }
34
- end
35
-
36
- def test_tail_expected_return_values
37
- assert_kind_of(Array, File.tail(@test_file))
38
- assert_equal(@expected_tail1, File.tail(@test_file))
39
- assert_equal(@expected_tail2, File.tail(@test_file, 5))
40
- end
41
-
42
- def test_tail_expected_errors
43
- assert_raises(ArgumentError){ File.tail }
44
- assert_raises(ArgumentError){ File.tail(@test_file, 5, 5) }
45
- end
46
-
47
- def teardown
48
- @test_file = nil
49
- @expected_tail1 = nil
50
- @expected_tail2 = nil
51
- end
52
-
53
- def self.shutdown
54
- File.delete('test_file1.txt') if File.exists?('test_file1.txt')
55
- end
56
- end
1
+ #####################################################################
2
+ # test_tail.rb
3
+ #
4
+ # Test case for the File.tail method. This test should be run via
5
+ # the 'rake test_tail' task.
6
+ #####################################################################
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'test/unit'
11
+ require 'ptools'
12
+
13
+ class TC_FileTail < Test::Unit::TestCase
14
+ def self.startup
15
+ Dir.chdir('test') if File.exists?('test')
16
+ File.open('test_file1.txt', 'w'){ |fh| 25.times{ |n| fh.puts "line#{n+1}" } }
17
+ end
18
+
19
+ def setup
20
+ @test_file = 'test_file1.txt'
21
+
22
+ @expected_tail1 = ["line16\n","line17\n","line18\n","line19\n"]
23
+ @expected_tail1.push("line20\n","line21\n","line22\n", "line23\n")
24
+ @expected_tail1.push("line24\n","line25\n")
25
+
26
+ @expected_tail2 = ["line21\n","line22\n","line23\n","line24\n","line25\n"]
27
+ end
28
+
29
+ def test_tail_basic
30
+ assert_respond_to(File, :tail)
31
+ assert_nothing_raised{ File.tail(@test_file) }
32
+ assert_nothing_raised{ File.tail(@test_file, 5) }
33
+ assert_nothing_raised{ File.tail(@test_file){} }
34
+ end
35
+
36
+ def test_tail_expected_return_values
37
+ assert_kind_of(Array, File.tail(@test_file))
38
+ assert_equal(@expected_tail1, File.tail(@test_file))
39
+ assert_equal(@expected_tail2, File.tail(@test_file, 5))
40
+ end
41
+
42
+ def test_tail_expected_errors
43
+ assert_raises(ArgumentError){ File.tail }
44
+ assert_raises(ArgumentError){ File.tail(@test_file, 5, 5) }
45
+ end
46
+
47
+ def teardown
48
+ @test_file = nil
49
+ @expected_tail1 = nil
50
+ @expected_tail2 = nil
51
+ end
52
+
53
+ def self.shutdown
54
+ File.delete('test_file1.txt') if File.exists?('test_file1.txt')
55
+ end
56
+ end