File: test_shift_jis.rb

package info (click to toggle)
jruby 1.5.1-1
  • links: PTS, VCS
  • area: non-free
  • in suites: squeeze
  • size: 46,252 kB
  • ctags: 72,039
  • sloc: ruby: 398,155; java: 169,482; yacc: 3,782; xml: 2,469; ansic: 415; sh: 279; makefile: 78; tcl: 40
file content (27 lines) | stat: -rw-r--r-- 798 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# vim: set fileencoding=shift_jis

require "test/unit"

class TestShiftJIS < Test::Unit::TestCase
  def test_mbc_case_fold
    assert_match(/()(a)\1\2/i, "aA")
    assert_no_match(/()(a)\1\2/i, "a`A")
  end

  def test_property
    assert_match(/{0}\p{Hiragana}{4}/, "Ђ炪")
    assert_no_match(/{0}\p{Hiragana}{4}/, "J^Ji")
    assert_no_match(/{0}\p{Hiragana}{4}/, "")
    assert_no_match(/{0}\p{Katakana}{4}/, "Ђ炪")
    assert_match(/{0}\p{Katakana}{4}/, "J^Ji")
    assert_no_match(/{0}\p{Katakana}{4}/, "")
    assert_raise(RegexpError) { Regexp.new('{0}\p{foobarbaz}') }
  end

  def test_code_to_mbclen
    s = ""
    s << 0x82a9
    assert_equal("", s)
    assert_raise(ArgumentError) { s << 0x82 }
  end
end