Class: AtCoderFriends::TestRunner::Sample
- Includes:
- PathUtil
- 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 included from PathUtil
PathUtil::CASES_DIR, PathUtil::SMP_DIR, PathUtil::TMP_DIR
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(n) ⇒ Object
- #test_all ⇒ Object
- #test_one(n) ⇒ Object
Methods included from PathUtil
cases_dir, contest_name, makedirs_unless, smp_dir, split_prg_path, tmp_dir
Methods inherited from Base
#call_remote_test, #config, #detail_str, #local_test, #remote_test, #result_str, #run_test, #show_result, #test_cmd, #test_loc, #test_mtd, #which_os
Constructor Details
#initialize(ctx) ⇒ Sample
Returns a new instance of Sample.
11 12 13 14 |
# File 'lib/at_coder_friends/test_runner/sample.rb', line 11 def initialize(ctx) super(ctx) @data_dir = smp_dir(dir) end |
Instance Attribute Details
#data_dir ⇒ Object (readonly)
Returns the value of attribute data_dir.
9 10 11 |
# File 'lib/at_coder_friends/test_runner/sample.rb', line 9 def data_dir @data_dir end |
Instance Method Details
#test(n) ⇒ Object
28 29 30 31 32 |
# File 'lib/at_coder_friends/test_runner/sample.rb', line 28 def test(n) id = format('%<q>s_%<n>03d', q: q, n: n) files = %w[in out exp].map { |ext| "#{data_dir}/#{id}.#{ext}" } run_test(id, *files) end |
#test_all ⇒ Object
16 17 18 19 20 21 |
# File 'lib/at_coder_friends/test_runner/sample.rb', line 16 def test_all puts "***** test_all #{prg} (#{test_loc}) *****" 1.upto(999) do |i| break unless test(i) end end |
#test_one(n) ⇒ Object
23 24 25 26 |
# File 'lib/at_coder_friends/test_runner/sample.rb', line 23 def test_one(n) puts "***** test_one #{prg} (#{test_loc}) *****" test(n) end |