root/lang/ruby/ruwin/test/test_ruwin.rb @ 29257

Revision 29223, 2.1 kB (checked in by isaisstillalive, 4 years ago)
  • String#[]の引数がIntegerの場合の対応
Line 
1require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
2require "ruwin"
3
4class TestRuwin < Test::Unit::TestCase
5  def test_loword
6    assert_equal 1, Ruwin::LOWORD(1)
7    assert_equal 1, Ruwin::LOWORD(1<<16|1)
8  end
9 
10  def test_hiword
11    assert_equal 1, Ruwin::HIWORD(1<<16)
12    assert_equal 1, Ruwin::HIWORD(1<<16|1)
13  end
14 
15  def test_signedword
16    assert_equal 1, Ruwin::SIGNEDWORD(1)
17    assert_equal -1, Ruwin::SIGNEDWORD(~0&0xFFFF)
18    assert_equal -2, Ruwin::SIGNEDWORD(~1&0xFFFF)
19  end
20 
21  def test_signedlong
22    assert_equal 1, Ruwin::SIGNEDLONG(1)
23    assert_equal -1, Ruwin::SIGNEDLONG(~0&0xFFFFFFFF)
24    assert_equal -2, Ruwin::SIGNEDLONG(~1&0xFFFFFFFF)
25  end
26 
27  def test_dpi_x
28    assert_equal 96, Ruwin::DPIX()
29  end
30 
31  def test_dpi_y
32    assert_equal 96, Ruwin::DPIY()
33  end
34 
35  def test_pixel_to_twip_x
36    assert_equal 1440, Ruwin::PIXEL2TWIPX(Ruwin::DPIX())
37  end
38 
39  def test_pixel_to_twip_y
40    assert_equal 1440, Ruwin::PIXEL2TWIPY(Ruwin::DPIY())
41  end
42 
43  def test_twip_to_pixel_x
44    assert_equal Ruwin::DPIX(), Ruwin::TWIP2PIXELX(1440)
45  end
46 
47  def test_twip_to_pixel_y
48    assert_equal Ruwin::DPIY(), Ruwin::TWIP2PIXELY(1440)
49  end
50 
51 
52  def test_string_length
53    assert_equal 3, "ABC".length
54  end
55 
56  def test_multibyte_string_length_utf8
57    assert_equal 3, NKF.nkf("-Ww", "あいう").length
58  end
59 
60  def test_multibyte_string_length_sjis
61    assert_equal 3, NKF.nkf("-Ws", "あいう").length
62  end
63 
64 
65  def test_string_substring
66    assert_equal "BCD", "ABCDE"[1...4]
67  end
68 
69  def test_string_substring_substr
70    assert_equal "BCD", "ABCDE"["BCD"]
71  end
72 
73  def test_string_substring_regexp
74    assert_equal "BCD", "ABCDE"[/BCD/]
75  end
76 
77  def test_string_substring_index
78    assert_equal "B", "ABCDE"[1]
79  end
80 
81  def test_multibyte_string_substring_utf8
82    assert_equal NKF.nkf("-Ww", "いうえ"), NKF.nkf("-Ww", "あいうえお")[1...4]
83  end
84 
85  def test_multibyte_string_substring_usjis
86    assert_equal NKF.nkf("-Ws", "いうえ"), NKF.nkf("-Ws", "あいうえお")[1...4]
87  end
88end
Note: See TracBrowser for help on using the browser.