Sha256: 68c3c72514b1f91a6b85119adc806e1211198f26b5b391c3a80cbb70b15b4081

Contents?: true

Size: 1.8 KB

Versions: 25

Compression:

Stored size: 1.8 KB

Contents

# encoding: utf-8

require 'helper'

class TestScores < MiniTest::Test


  def test_scores
    data = [
     [ '10:0',  [10,0]],
     [ '1:22',  [1,22]],
     [ '1-22',  [1,22]],

     ## do not support three digits
     [ '1-222', []],  
     [ '111-0', []],
     [ '1:222', []],
     [ '111:0', []],

     ## penality only
     [ '3-4iE',    [nil,nil,nil,nil,3,4]],
     [ '3:4iE',    [nil,nil,nil,nil,3,4]],
     [ '3:4 iE',   [nil,nil,nil,nil,3,4]],
     [ '3:4 i.E.', [nil,nil,nil,nil,3,4]],
     [ '3-4 pen',  [nil,nil,nil,nil,3,4]],
     [ '3-4 PSO',  [nil,nil,nil,nil,3,4]],   # PSO  => penalty shotout
     [ '3-4p',     [nil,nil,nil,nil,3,4]],
     [ '3-4 p',    [nil,nil,nil,nil,3,4]],

     ## extra time only - allow ?? why not ?? only allow penalty w/ missing extra time?
     ## todo/fix: issue warning or error in parser!!!
     [ '3-4nV',      [nil,nil,3,4]],
     [ '3:4nV',      [nil,nil,3,4]],
     [ '3-4 aet',    [nil,nil,3,4]],
     [ '3-4 a.e.t.', [nil,nil,3,4]],

     [ '3:4nV 1:1',    [1,1,3,4]],
     [ '1:1 3:4nV',    [1,1,3,4]],
     [ '3:4 nV 1:1',   [1,1,3,4]],
     [ '3:4 n.V. 1:1', [1,1,3,4]],

     [ '3:4iE 1:1', [1,1,nil,nil,3,4]],
     [ '1:1 3:4iE', [1,1,nil,nil,3,4]],

     [ '1:1 2:2nV 3:4iE',       [1,1,2,2,3,4]],
     [ '3:4iE 2:2nV 1:1',       [1,1,2,2,3,4]],
     [ '3:4 i.E. 2:2 n.V. 1:1', [1,1,2,2,3,4]],
     [ '3-4p 2-2aet 1-1',       [1,1,2,2,3,4]],
     [ '3-4 pen 2-2 aet 1-1',   [1,1,2,2,3,4]]
    ]

    assert_scores( data )
  end

private
  def assert_scores( data )
    data.each do |rec|
      line = rec[0]
      exp  = rec[1]

      assert_equal exp, parse_scores( line )
    end  
  end

  def parse_scores( line )
     finder = SportDb::ScoresFinder.new
     finder.find!( line )
  end

end # class TestScores

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
sportdb-models-1.17.0 test/test_scores.rb
sportdb-models-1.16.2 test/test_scores.rb
sportdb-models-1.16.1 test/test_scores.rb
sportdb-models-1.16.0 test/test_scores.rb
sportdb-models-1.15.2 test/test_scores.rb
sportdb-models-1.15.1 test/test_scores.rb
sportdb-models-1.15.0 test/test_scores.rb
sportdb-models-1.14.2 test/test_scores.rb
sportdb-models-1.14.1 test/test_scores.rb
sportdb-models-1.14.0 test/test_scores.rb
sportdb-models-1.13.0 test/test_scores.rb
sportdb-models-1.12.0 test/test_scores.rb
sportdb-models-1.11.2 test/test_scores.rb
sportdb-models-1.11.1 test/test_scores.rb
sportdb-models-1.11.0 test/test_scores.rb
sportdb-models-1.10.1 test/test_scores.rb
sportdb-models-1.10.0 test/test_scores.rb
sportdb-1.9.16 test/test_scores.rb
sportdb-1.9.15 test/test_scores.rb
sportdb-1.9.14 test/test_scores.rb