ptools 1.2.6-universal-mingw32 → 1.2.7-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,53 +1,53 @@
1
- #####################################################################
2
- # test_is_sparse.rb
3
- #
4
- # Test case for the File.sparse? method. You should run this test
5
- # via the 'rake test:is_sparse' task.
6
- #####################################################################
7
- require 'test-unit'
8
- require 'ptools'
9
-
10
- class TC_IsSparse < Test::Unit::TestCase
11
- def self.startup
12
- Dir.chdir("test") if File.exist?("test")
13
- @@win = File::ALT_SEPARATOR
14
- @@osx = RbConfig::CONFIG['host_os'] =~ /darwin|osx/i
15
- system("dd of=test_sparse bs=1k seek=5120 count=0 2>/dev/null") unless @@win
16
- end
17
-
18
- def setup
19
- @sparse_file = 'test_sparse'
20
- @non_sparse_file = File.expand_path(File.basename(__FILE__))
21
- end
22
-
23
- test "is_sparse basic functionality" do
24
- omit_if(@@win, "File.sparse? tests skipped on MS Windows")
25
- omit_if(@@osx, "File.sparse? tests skipped on OS X")
26
-
27
- assert_respond_to(File, :sparse?)
28
- assert_nothing_raised{ File.sparse?(@sparse_file) }
29
- assert_boolean(File.sparse?(@sparse_file))
30
- end
31
-
32
- test "is_sparse returns the expected results" do
33
- omit_if(@@win, "File.sparse? tests skipped on MS Windows")
34
- omit_if(@@osx, "File.sparse? tests skipped on OS X")
35
-
36
- assert_true(File.sparse?(@sparse_file))
37
- assert_false(File.sparse?(@non_sparse_file))
38
- end
39
-
40
- test "is_sparse only accepts one argument" do
41
- omit_if(@@win, "File.sparse? tests skipped on MS Windows")
42
- assert_raise(ArgumentError){ File.sparse?(@sparse_file, @sparse_file) }
43
- end
44
-
45
- def teardown
46
- @sparse_file = nil
47
- @non_sparse_file = nil
48
- end
49
-
50
- def self.shutdown
51
- File.delete('test_sparse') if File.exist?('test_sparse')
52
- end
53
- end
1
+ #####################################################################
2
+ # test_is_sparse.rb
3
+ #
4
+ # Test case for the File.sparse? method. You should run this test
5
+ # via the 'rake test:is_sparse' task.
6
+ #####################################################################
7
+ require 'test-unit'
8
+ require 'ptools'
9
+
10
+ class TC_IsSparse < Test::Unit::TestCase
11
+ def self.startup
12
+ Dir.chdir("test") if File.exist?("test")
13
+ @@win = File::ALT_SEPARATOR
14
+ @@osx = RbConfig::CONFIG['host_os'] =~ /darwin|osx/i
15
+ system("dd of=test_sparse bs=1k seek=5120 count=0 2>/dev/null") unless @@win
16
+ end
17
+
18
+ def setup
19
+ @sparse_file = 'test_sparse'
20
+ @non_sparse_file = File.expand_path(File.basename(__FILE__))
21
+ end
22
+
23
+ test "is_sparse basic functionality" do
24
+ omit_if(@@win, "File.sparse? tests skipped on MS Windows")
25
+ omit_if(@@osx, "File.sparse? tests skipped on OS X")
26
+
27
+ assert_respond_to(File, :sparse?)
28
+ assert_nothing_raised{ File.sparse?(@sparse_file) }
29
+ assert_boolean(File.sparse?(@sparse_file))
30
+ end
31
+
32
+ test "is_sparse returns the expected results" do
33
+ omit_if(@@win, "File.sparse? tests skipped on MS Windows")
34
+ omit_if(@@osx, "File.sparse? tests skipped on OS X")
35
+
36
+ assert_true(File.sparse?(@sparse_file))
37
+ assert_false(File.sparse?(@non_sparse_file))
38
+ end
39
+
40
+ test "is_sparse only accepts one argument" do
41
+ omit_if(@@win, "File.sparse? tests skipped on MS Windows")
42
+ assert_raise(ArgumentError){ File.sparse?(@sparse_file, @sparse_file) }
43
+ end
44
+
45
+ def teardown
46
+ @sparse_file = nil
47
+ @non_sparse_file = nil
48
+ end
49
+
50
+ def self.shutdown
51
+ File.delete('test_sparse') if File.exist?('test_sparse')
52
+ end
53
+ end
@@ -1,58 +1,58 @@
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 'test-unit'
8
- require 'ptools'
9
-
10
- class TC_FileMiddle < Test::Unit::TestCase
11
- def self.startup
12
- Dir.chdir('test') if File.exist?('test')
13
- File.open('test_file1.txt', 'w'){ |fh| 25.times{ |n| fh.puts "line#{n+1}" } }
14
- end
15
-
16
- def setup
17
- @test_file = 'test_file1.txt'
18
-
19
- @expected_middle1 = ["line10\n", "line11\n", "line12\n", "line13\n", "line14\n"]
20
- @expected_middle1.push("line15\n","line16\n", "line17\n", "line18\n")
21
- @expected_middle1.push("line19\n","line20\n")
22
-
23
- @expected_middle2 = ["line14\n","line15\n","line16\n","line17\n"]
24
- @expected_middle2.push("line18\n","line19\n","line20\n")
25
-
26
- @expected_middle3 = ["line5\n","line6\n","line7\n"]
27
- @expected_middle3.push("line8\n","line9\n","line10\n")
28
- end
29
-
30
- def test_method_basic
31
- assert_respond_to(File, :middle)
32
- assert_nothing_raised{ File.middle(@test_file) }
33
- assert_nothing_raised{ File.middle(@test_file, 14) }
34
- assert_nothing_raised{ File.middle(@test_file, 5, 10) }
35
- assert_nothing_raised{ File.middle(@test_file){} }
36
- end
37
-
38
- def test_middle_expected_results
39
- assert_kind_of(Array, File.middle(@test_file))
40
- assert_equal(@expected_middle1, File.middle(@test_file))
41
- assert_equal(@expected_middle2, File.middle(@test_file, 14))
42
- assert_equal(@expected_middle3, File.middle(@test_file, 5, 10))
43
- end
44
-
45
- def test_middle_expected_errors
46
- assert_raises(ArgumentError){ File.middle }
47
- assert_raises(ArgumentError){ File.middle(@test_file, 5, 10, 15) }
48
- assert_raises(NoMethodError){ File.middle(@test_file, "foo") }
49
- assert_raises(Errno::ENOENT){ File.middle("bogus") }
50
- end
51
-
52
- def teardown
53
- @test_file = nil
54
- @expected_middle1 = nil
55
- @expected_middle2 = nil
56
- @expected_middle3 = nil
57
- end
58
- 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 'test-unit'
8
+ require 'ptools'
9
+
10
+ class TC_FileMiddle < Test::Unit::TestCase
11
+ def self.startup
12
+ Dir.chdir('test') if File.exist?('test')
13
+ File.open('test_file1.txt', 'w'){ |fh| 25.times{ |n| fh.puts "line#{n+1}" } }
14
+ end
15
+
16
+ def setup
17
+ @test_file = 'test_file1.txt'
18
+
19
+ @expected_middle1 = ["line10\n", "line11\n", "line12\n", "line13\n", "line14\n"]
20
+ @expected_middle1.push("line15\n","line16\n", "line17\n", "line18\n")
21
+ @expected_middle1.push("line19\n","line20\n")
22
+
23
+ @expected_middle2 = ["line14\n","line15\n","line16\n","line17\n"]
24
+ @expected_middle2.push("line18\n","line19\n","line20\n")
25
+
26
+ @expected_middle3 = ["line5\n","line6\n","line7\n"]
27
+ @expected_middle3.push("line8\n","line9\n","line10\n")
28
+ end
29
+
30
+ def test_method_basic
31
+ assert_respond_to(File, :middle)
32
+ assert_nothing_raised{ File.middle(@test_file) }
33
+ assert_nothing_raised{ File.middle(@test_file, 14) }
34
+ assert_nothing_raised{ File.middle(@test_file, 5, 10) }
35
+ assert_nothing_raised{ File.middle(@test_file){} }
36
+ end
37
+
38
+ def test_middle_expected_results
39
+ assert_kind_of(Array, File.middle(@test_file))
40
+ assert_equal(@expected_middle1, File.middle(@test_file))
41
+ assert_equal(@expected_middle2, File.middle(@test_file, 14))
42
+ assert_equal(@expected_middle3, File.middle(@test_file, 5, 10))
43
+ end
44
+
45
+ def test_middle_expected_errors
46
+ assert_raises(ArgumentError){ File.middle }
47
+ assert_raises(ArgumentError){ File.middle(@test_file, 5, 10, 15) }
48
+ assert_raises(NoMethodError){ File.middle(@test_file, "foo") }
49
+ assert_raises(Errno::ENOENT){ File.middle("bogus") }
50
+ end
51
+
52
+ def teardown
53
+ @test_file = nil
54
+ @expected_middle1 = nil
55
+ @expected_middle2 = nil
56
+ @expected_middle3 = nil
57
+ end
58
+ end
@@ -1,99 +1,110 @@
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.exist?('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.exist?(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.exist?(@@test_file1)
97
- File.delete(@@test_file2) if File.exist?(@@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.exist?('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_for_platform basic functionality" do
29
+ assert_respond_to(File, :nl_for_platform)
30
+ end
31
+
32
+ test "nl_for_platform" do
33
+ assert_equal( "\cM\cJ", File.nl_for_platform('dos') )
34
+ assert_equal( "\cJ", File.nl_for_platform('unix') )
35
+ assert_equal( "\cM", File.nl_for_platform('mac') )
36
+ assert_nothing_raised{ File.nl_for_platform('local') }
37
+ end
38
+
39
+ test "nl_convert basic functionality" do
40
+ assert_respond_to(File, :nl_convert)
41
+ end
42
+
43
+ test "nl_convert accepts one, two or three arguments" do
44
+ assert_nothing_raised{ File.nl_convert(@test_file2) }
45
+ assert_nothing_raised{ File.nl_convert(@test_file2, @test_file2) }
46
+ assert_nothing_raised{ File.nl_convert(@test_file2, @test_file2, "unix") }
47
+ end
48
+
49
+ test "nl_convert with dos platform argument works as expected" do
50
+ msg = "dos file should be larger, but isn't"
51
+
52
+ assert_nothing_raised{ File.nl_convert(@test_file1, @dos_file, "dos") }
53
+ assert_true(File.size(@dos_file) > File.size(@test_file1), msg)
54
+ assert_equal(["\cM","\cJ"], IO.readlines(@dos_file).first.split("")[-2..-1])
55
+ end
56
+
57
+ test "nl_convert with mac platform argument works as expected" do
58
+ assert_nothing_raised{ File.nl_convert(@test_file1, @mac_file, 'mac') }
59
+ assert_equal("\cM", IO.readlines(@mac_file).first.split("").last)
60
+
61
+ omit_if(File::ALT_SEPARATOR)
62
+ msg = "=> Mac file should be the same size (or larger), but isn't"
63
+ assert_true(File.size(@mac_file) == File.size(@test_file1), msg)
64
+ end
65
+
66
+ test "nl_convert with unix platform argument works as expected" do
67
+ msg = "unix file should be the same size (or smaller), but isn't"
68
+
69
+ assert_nothing_raised{ File.nl_convert(@test_file1, @unix_file, "unix") }
70
+ assert_equal("\n", IO.readlines(@unix_file).first.split("").last)
71
+
72
+ if File::ALT_SEPARATOR
73
+ assert_true(File.size(@unix_file) >= File.size(@test_file1), msg)
74
+ else
75
+ assert_true(File.size(@unix_file) <= File.size(@test_file1), msg)
76
+ end
77
+ end
78
+
79
+ test "nl_convert requires at least one argument" do
80
+ assert_raise(ArgumentError){ File.nl_convert }
81
+ end
82
+
83
+ test "nl_convert requires a valid platform string" do
84
+ assert_raise(ArgumentError){ File.nl_convert(@test_file1, "bogus.txt", "blah") }
85
+ end
86
+
87
+ test "nl_convert accepts a maximum of three arguments" do
88
+ assert_raise(ArgumentError){ File.nl_convert(@test_file1, @test_file2, 'dos', 1) }
89
+ end
90
+
91
+ test "nl_convert will fail on anything but plain files" do
92
+ assert_raise(ArgumentError){ File.nl_convert(File.null_device, @test_file1) }
93
+ end
94
+
95
+ def teardown
96
+ [@dos_file, @mac_file, @unix_file].each{ |file|
97
+ File.delete(file) if File.exist?(file)
98
+ }
99
+ @dos_file = nil
100
+ @mac_file = nil
101
+ @unix_file = nil
102
+ @test_file1 = nil
103
+ @test_file2 = nil
104
+ end
105
+
106
+ def self.shutdown
107
+ File.delete(@@test_file1) if File.exist?(@@test_file1)
108
+ File.delete(@@test_file2) if File.exist?(@@test_file2)
109
+ end
110
+ end
@@ -1,53 +1,53 @@
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 'test-unit'
8
- require 'ptools'
9
-
10
- class TC_FileTail < Test::Unit::TestCase
11
- def self.startup
12
- Dir.chdir('test') if File.exist?('test')
13
- File.open('test_file1.txt', 'w'){ |fh| 25.times{ |n| fh.puts "line#{n+1}" } }
14
- end
15
-
16
- def setup
17
- @test_file = 'test_file1.txt'
18
-
19
- @expected_tail1 = ["line16\n","line17\n","line18\n","line19\n"]
20
- @expected_tail1.push("line20\n","line21\n","line22\n", "line23\n")
21
- @expected_tail1.push("line24\n","line25\n")
22
-
23
- @expected_tail2 = ["line21\n","line22\n","line23\n","line24\n","line25\n"]
24
- end
25
-
26
- def test_tail_basic
27
- assert_respond_to(File, :tail)
28
- assert_nothing_raised{ File.tail(@test_file) }
29
- assert_nothing_raised{ File.tail(@test_file, 5) }
30
- assert_nothing_raised{ File.tail(@test_file){} }
31
- end
32
-
33
- def test_tail_expected_return_values
34
- assert_kind_of(Array, File.tail(@test_file))
35
- assert_equal(@expected_tail1, File.tail(@test_file))
36
- assert_equal(@expected_tail2, File.tail(@test_file, 5))
37
- end
38
-
39
- def test_tail_expected_errors
40
- assert_raises(ArgumentError){ File.tail }
41
- assert_raises(ArgumentError){ File.tail(@test_file, 5, 5) }
42
- end
43
-
44
- def teardown
45
- @test_file = nil
46
- @expected_tail1 = nil
47
- @expected_tail2 = nil
48
- end
49
-
50
- def self.shutdown
51
- File.delete('test_file1.txt') if File.exist?('test_file1.txt')
52
- end
53
- 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 'test-unit'
8
+ require 'ptools'
9
+
10
+ class TC_FileTail < Test::Unit::TestCase
11
+ def self.startup
12
+ Dir.chdir('test') if File.exist?('test')
13
+ File.open('test_file1.txt', 'w'){ |fh| 25.times{ |n| fh.puts "line#{n+1}" } }
14
+ end
15
+
16
+ def setup
17
+ @test_file = 'test_file1.txt'
18
+
19
+ @expected_tail1 = ["line16\n","line17\n","line18\n","line19\n"]
20
+ @expected_tail1.push("line20\n","line21\n","line22\n", "line23\n")
21
+ @expected_tail1.push("line24\n","line25\n")
22
+
23
+ @expected_tail2 = ["line21\n","line22\n","line23\n","line24\n","line25\n"]
24
+ end
25
+
26
+ def test_tail_basic
27
+ assert_respond_to(File, :tail)
28
+ assert_nothing_raised{ File.tail(@test_file) }
29
+ assert_nothing_raised{ File.tail(@test_file, 5) }
30
+ assert_nothing_raised{ File.tail(@test_file){} }
31
+ end
32
+
33
+ def test_tail_expected_return_values
34
+ assert_kind_of(Array, File.tail(@test_file))
35
+ assert_equal(@expected_tail1, File.tail(@test_file))
36
+ assert_equal(@expected_tail2, File.tail(@test_file, 5))
37
+ end
38
+
39
+ def test_tail_expected_errors
40
+ assert_raises(ArgumentError){ File.tail }
41
+ assert_raises(ArgumentError){ File.tail(@test_file, 5, 5) }
42
+ end
43
+
44
+ def teardown
45
+ @test_file = nil
46
+ @expected_tail1 = nil
47
+ @expected_tail2 = nil
48
+ end
49
+
50
+ def self.shutdown
51
+ File.delete('test_file1.txt') if File.exist?('test_file1.txt')
52
+ end
53
+ end