Class: AtCoderFriends::TestRunner::Sample
- Defined in:
- lib/at_coder_friends/test_runner/sample.rb
Overview
run test cases for the specified program with sample input/output.
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#data_dir ⇒ Object
readonly
Returns the value of attribute data_dir.
Attributes inherited from Base
#base, #ctx, #dir, #ext, #path, #prg, #q
Instance Method Summary collapse
-
#initialize(ctx) ⇒ Sample
constructor
A new instance of Sample.
- #test(id) ⇒ Object
- #test_all ⇒ Object
- #test_one(id) ⇒ Object
Methods inherited from Base
#call_remote_test, #check_file, #check_status, #detail_str, #local_test, #remote_test, #run_test, #test_cmd, #test_loc, #test_mtd, #which_os
Methods included from PathUtil
Constructor Details
#initialize(ctx) ⇒ Sample
Returns a new instance of Sample.
9 10 11 12 |
# File 'lib/at_coder_friends/test_runner/sample.rb', line 9 def initialize(ctx) super(ctx) @data_dir = ctx.path_info.smp_dir end |
Instance Attribute Details
#data_dir ⇒ Object (readonly)
Returns the value of attribute data_dir.
7 8 9 |
# File 'lib/at_coder_friends/test_runner/sample.rb', line 7 def data_dir @data_dir end |
Instance Method Details
#test(id) ⇒ Object
28 29 30 31 32 |
# File 'lib/at_coder_friends/test_runner/sample.rb', line 28 def test(id) id = format('%<q>s_%<id>s', q: q, id: id) files = %w[in out exp].map { |ext| "#{data_dir}/#{id}.#{ext}" } run_test(id, *files) end |
#test_all ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/at_coder_friends/test_runner/sample.rb', line 14 def test_all puts "***** test_all #{prg} (#{test_loc}) *****" results = Dir["#{data_dir}/#{q}_*.in"].sort.map do |infile| id = File.basename(infile, '.in').sub(/\A#{q}_/, '') test(id) end !results.empty? && results.all? end |
#test_one(id) ⇒ Object
23 24 25 26 |
# File 'lib/at_coder_friends/test_runner/sample.rb', line 23 def test_one(id) puts "***** test_one #{prg} (#{test_loc}) *****" test(id) end |