#!/usr/bin/ruby

var h = Hash(
    "SPACE" => "\x20",
    "NO-BREAK SPACE" => "\xc2\xa0",
    "OGHAM SPACE MARK" => "\xe1\x9a\x80",
    "EN QUAD" => "\xe2\x80\x80",
    "EM QUAD" => "\xe2\x80\x81",
    "EN SPACE" => "\xe2\x80\x82",
    "EM SPACE" => "\xe2\x80\x83",
    "THREE-PER-EM SPACE" => "\xe2\x80\x84",
    "FOUR-PER-EM SPACE" => "\xe2\x80\x85",
    "SIX-PER-EM SPACE" => "\xe2\x80\x86",
    "FIGURE SPACE" => "\xe2\x80\x87",
    "PUNCTUATION SPACE" => "\xe2\x80\x88",
    "THIN SPACE" => "\xe2\x80\x89",
    "HAIR SPACE" => "\xe2\x80\x8a",
    #"ZERO WIDTH SPACE" => "\xe2\x80\x8b",
    "NARROW NO-BREAK SPACE" => "\xe2\x80\xaf",
    "MEDIUM MATHEMATICAL SPACE" => "\xe2\x81\x9f",
    "IDEOGRAPHIC SPACE" => "\xe3\x80\x80",
)

var foo = '산다♥'
var bar = ''

h.each {|_,v|
    foo += v.decode_utf8
    bar += v.decode_utf8
}

assert_eq(foo.strip, '산다♥')
assert_eq(bar.strip, '')
assert_eq((bar + 'foo').strip, 'foo')

assert_eq(foo.rtrim, '산다♥')
assert_eq(bar.rtrim, '')

assert_eq(foo.ltrim, foo)
assert_eq(bar.ltrim, '')

assert_eq(foo.scan(/\s/).len, h.len)
assert_eq(foo.scan(/\h/).len, h.len)

assert_eq(foo.graphs.len, h.len+3)
assert_eq(foo.graphs_len, h.len+3)

assert_eq(foo.len, h.len+3)
assert_eq(bar.len, h.len)

say "** Test passed!"
