# test.rb

Path: | nkf/test.rb
Last Update: | Sat Oct 15 23:43:53 AUS Eastern Standard Time 2005

nkf test program for nkf-2

$Id: test.rb,v 1.2.8.3 2004/12/03 18:01:05 naruse Exp $

       Shinji KONO <kono@ie.u-ryukyu.ac.jp>

Sun Aug 18 12:25:40 JST 1996 Sun Nov 8 00:16:06 JST 1998

This is useful when you add new patch on nkf. Since this test is too strict, faileurs may not mean wrong conversion.

nkf 1.5 differs on MIME decoding nkf 1.4 passes Basic Conversion tests nkf PDS version passes Basic Conversion tests using "nkf -iB -oB "

### Required files

nkf

### Methods

result test

### Included Modules

NKF

### Public Instance methods

result(result, message = nil)

[Source]

    # File nkf/test.rb, line 21
    def result(result, message = nil)
      $counter += 1
      printf("%s %d%s\n",
             result ? 'ok' : 'no',
             $counter,
             message ? ' ... ' + message : '')
    end

test(opt, input, expects)

[Source]

    # File nkf/test.rb, line 71
    def test(opt, input, expects)
      print "\nINPUT:\n", input if $detail
      print "\nEXPECT:\n", expects.to_s if $detail
      result = nkf(opt, input)
      result.delete!(' ') if opt.include?('-m')
      print "\nGOT:\n", result if $detail

      expects.each do |e|
        e.delete!(' ') if opt.include?('-m')
        if result == e then
          puts "Ok"
          return result
        end
      end
      puts "Fail"
      puts result.unpack('H*').first
      puts expects.map{|x|x.unpack('H*').first}.join("\n\n")
    end

[Validate]