testrus 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -4,6 +4,8 @@ Aids in testing your programs in informatics competitions.
4
4
 
5
5
  Install it with `gem install testrus`.
6
6
 
7
+ Currently only tested on OS X.
8
+
7
9
  ## Usage
8
10
 
9
11
  `testrus` looks for input and output file pairs in the directory you run it
@@ -27,7 +27,7 @@ module Testrus
27
27
  @input ||= input_files.map do |input|
28
28
  Input.new input: ::File.read(input),
29
29
  output: ::File.read(output_from_input(input)),
30
- name: name_from_file_name(input)
30
+ name: test_name_from_file_name(input)
31
31
  end
32
32
  end
33
33
  alias_method :tests, :input
@@ -37,14 +37,14 @@ module Testrus
37
37
  #
38
38
  # Returns an Array of Strings of paths to the input files.
39
39
  def input_files
40
- @input_files ||= files("input.*")
40
+ @input_files ||= files("*in*[0-9]*")
41
41
  end
42
42
 
43
43
  # Internal: Finds the output files on the filesystem and expands the paths.
44
44
  #
45
45
  # Returns an Array of Strings of paths to the output files.
46
46
  def output_files
47
- @output_files ||= files("output.*")
47
+ @output_files ||= files("*out*[0-9]*")
48
48
  end
49
49
 
50
50
  # Internal: Finds the files with the given wildcard and expands the paths.
@@ -65,11 +65,11 @@ module Testrus
65
65
  # Returns the full path to the associated output file.
66
66
  def output_from_input(input)
67
67
  output_files.find do |output|
68
- name_from_file_name(input) == name_from_file_name(output)
68
+ id_from_file_name(input) == id_from_file_name(output)
69
69
  end
70
70
  end
71
71
 
72
- # Internal: The name of an input or output file is defined as the last
72
+ # Internal: The id of an input or output file is defined as the last
73
73
  # number in the path name. This method returns an input or output file's
74
74
  # name.
75
75
  #
@@ -84,9 +84,10 @@ module Testrus
84
84
  # #=> "2"
85
85
  #
86
86
  # Returns a String name of the input or output file.
87
- def name_from_file_name(path)
87
+ def id_from_file_name(path)
88
88
  path.match(/\d+$/)[0]
89
89
  end
90
+ alias_method :test_name_from_file_name, :id_from_file_name
90
91
 
91
92
  # Internal: Default working directory if none was passed.
92
93
  #
@@ -1,3 +1,3 @@
1
1
  module Testrus
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -11,6 +11,10 @@ class InputFileTest < Test::Unit::TestCase
11
11
  @input_file = Testrus::Input::File.new(pwd: root_path)
12
12
  end
13
13
 
14
+ def teardown
15
+ Dir["#{root_path}/*in*[0-9]*"].each { |file| File.delete(file) }
16
+ end
17
+
14
18
  def test_empty_pwd_context_defaults_to_pwd
15
19
  @input_file = Testrus::Input::File.new(pwd: "")
16
20
  mock(@input_file).default_pwd { '/home/testrus/project' }
@@ -37,8 +41,8 @@ class InputFileTest < Test::Unit::TestCase
37
41
  end
38
42
 
39
43
  def test_fetch_and_associate_in_out_format_file_tests
40
- File.open("#{root_path}/input.in.1", "w") { |f| f.write "3 1 2 3" }
41
- File.open("#{root_path}/output.in.1", "w") { |f| f.write "6" }
44
+ File.open("#{root_path}/boom.in.1", "w") { |f| f.write "3 1 2 3" }
45
+ File.open("#{root_path}/boom.out.1", "w") { |f| f.write "6" }
42
46
 
43
47
  parsed_input = @input_file.input
44
48
 
@@ -56,9 +60,9 @@ class InputFileTest < Test::Unit::TestCase
56
60
 
57
61
  parsed_input = @input_file.input
58
62
 
59
- assert_equal "3 1 2 3", parsed_input.first.input
60
- assert_equal "6", parsed_input.first.output
61
- assert_equal "1", parsed_input.first.name
63
+ assert_equal "3 1 2 3", parsed_input[0].input
64
+ assert_equal "6", parsed_input[0].output
65
+ assert_equal "1", parsed_input[0].name
62
66
 
63
67
  assert_equal "2 1 2", parsed_input[1].input
64
68
  assert_equal "3", parsed_input[1].output
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testrus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-08 00:00:00.000000000 Z
12
+ date: 2012-12-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colored