ffi-icu 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rspec +2 -0
- data/.travis.yml +9 -3
- data/README.md +5 -6
- data/ffi-icu.gemspec +2 -3
- data/lib/ffi-icu.rb +0 -9
- data/lib/ffi-icu/lib.rb +6 -1
- data/lib/ffi-icu/version.rb +1 -1
- data/spec/break_iterator_spec.rb +20 -19
- data/spec/chardet_spec.rb +10 -12
- data/spec/collation_spec.rb +19 -22
- data/spec/lib/version_info_spec.rb +11 -6
- data/spec/lib_spec.rb +11 -11
- data/spec/locale_spec.rb +97 -85
- data/spec/normalization_spec.rb +2 -4
- data/spec/normalizer_spec.rb +24 -26
- data/spec/number_formatting_spec.rb +28 -25
- data/spec/time_spec.rb +34 -37
- data/spec/transliteration_spec.rb +5 -6
- data/spec/uchar_spec.rb +8 -10
- metadata +12 -20
- data/spec/spec.opts +0 -1
data/spec/normalization_spec.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
3
|
module ICU
|
6
4
|
module Normalization
|
7
5
|
# http://bugs.icu-project.org/trac/browser/icu/trunk/source/test/cintltst/cnormtst.c
|
@@ -9,11 +7,11 @@ module ICU
|
|
9
7
|
describe "Normalization" do
|
10
8
|
|
11
9
|
it "should normalize a string - decomposed" do
|
12
|
-
ICU::Normalization.normalize("Å", :nfd).unpack("U*").
|
10
|
+
expect(ICU::Normalization.normalize("Å", :nfd).unpack("U*")).to eq([65, 778])
|
13
11
|
end
|
14
12
|
|
15
13
|
it "should normalize a string - composed" do
|
16
|
-
ICU::Normalization.normalize("Å", :nfc).unpack("U*").
|
14
|
+
expect(ICU::Normalization.normalize("Å", :nfc).unpack("U*")).to eq([197])
|
17
15
|
end
|
18
16
|
|
19
17
|
# TODO: add more normalization tests
|
data/spec/normalizer_spec.rb
CHANGED
@@ -1,21 +1,19 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
3
|
module ICU
|
6
4
|
describe Normalizer do
|
7
5
|
describe 'NFD: nfc decompose' do
|
8
6
|
let(:normalizer) { ICU::Normalizer.new(nil, 'nfc', :decompose) }
|
9
7
|
|
10
8
|
it "should normalize a string" do
|
11
|
-
normalizer.normalize("Å").unpack("U*").
|
12
|
-
normalizer.normalize("ô").unpack("U*").
|
13
|
-
normalizer.normalize("a").unpack("U*").
|
14
|
-
normalizer.normalize("中文").unpack("U*").
|
15
|
-
normalizer.normalize("Äffin").unpack("U*").
|
16
|
-
normalizer.normalize("Äffin").unpack("U*").
|
17
|
-
normalizer.normalize("Henry IV").unpack("U*").
|
18
|
-
normalizer.normalize("Henry Ⅳ").unpack("U*").
|
9
|
+
expect(normalizer.normalize("Å").unpack("U*")).to eq([65, 778])
|
10
|
+
expect(normalizer.normalize("ô").unpack("U*")).to eq([111, 770])
|
11
|
+
expect(normalizer.normalize("a").unpack("U*")).to eq([97])
|
12
|
+
expect(normalizer.normalize("中文").unpack("U*")).to eq([20013, 25991])
|
13
|
+
expect(normalizer.normalize("Äffin").unpack("U*")).to eq([65, 776, 102, 102, 105, 110])
|
14
|
+
expect(normalizer.normalize("Äffin").unpack("U*")).to eq([65, 776, 64259, 110])
|
15
|
+
expect(normalizer.normalize("Henry IV").unpack("U*")).to eq([72, 101, 110, 114, 121, 32, 73, 86])
|
16
|
+
expect(normalizer.normalize("Henry Ⅳ").unpack("U*")).to eq([72, 101, 110, 114, 121, 32, 8547])
|
19
17
|
end
|
20
18
|
end
|
21
19
|
|
@@ -23,14 +21,14 @@ module ICU
|
|
23
21
|
let(:normalizer) { ICU::Normalizer.new(nil, 'nfc', :compose) }
|
24
22
|
|
25
23
|
it "should normalize a string" do
|
26
|
-
normalizer.normalize("Å").unpack("U*").
|
27
|
-
normalizer.normalize("ô").unpack("U*").
|
28
|
-
normalizer.normalize("a").unpack("U*").
|
29
|
-
normalizer.normalize("中文").unpack("U*").
|
30
|
-
normalizer.normalize("Äffin").unpack("U*").
|
31
|
-
normalizer.normalize("Äffin").unpack("U*").
|
32
|
-
normalizer.normalize("Henry IV").unpack("U*").
|
33
|
-
normalizer.normalize("Henry Ⅳ").unpack("U*").
|
24
|
+
expect(normalizer.normalize("Å").unpack("U*")).to eq([197])
|
25
|
+
expect(normalizer.normalize("ô").unpack("U*")).to eq([244])
|
26
|
+
expect(normalizer.normalize("a").unpack("U*")).to eq([97])
|
27
|
+
expect(normalizer.normalize("中文").unpack("U*")).to eq([20013, 25991])
|
28
|
+
expect(normalizer.normalize("Äffin").unpack("U*")).to eq([196, 102, 102, 105, 110])
|
29
|
+
expect(normalizer.normalize("Äffin").unpack("U*")).to eq([196, 64259, 110])
|
30
|
+
expect(normalizer.normalize("Henry IV").unpack("U*")).to eq([72, 101, 110, 114, 121, 32, 73, 86])
|
31
|
+
expect(normalizer.normalize("Henry Ⅳ").unpack("U*")).to eq([72, 101, 110, 114, 121, 32, 8547])
|
34
32
|
end
|
35
33
|
end
|
36
34
|
|
@@ -38,10 +36,10 @@ module ICU
|
|
38
36
|
let(:normalizer) { ICU::Normalizer.new(nil, 'nfkc', :decompose) }
|
39
37
|
|
40
38
|
it "should normalize a string" do
|
41
|
-
normalizer.normalize("Äffin").unpack("U*").
|
42
|
-
normalizer.normalize("Äffin").unpack("U*").
|
43
|
-
normalizer.normalize("Henry IV").unpack("U*").
|
44
|
-
normalizer.normalize("Henry Ⅳ").unpack("U*").
|
39
|
+
expect(normalizer.normalize("Äffin").unpack("U*")).to eq([65, 776, 102, 102, 105, 110])
|
40
|
+
expect(normalizer.normalize("Äffin").unpack("U*")).to eq([65, 776, 102, 102, 105, 110])
|
41
|
+
expect(normalizer.normalize("Henry IV").unpack("U*")).to eq([72, 101, 110, 114, 121, 32, 73, 86])
|
42
|
+
expect(normalizer.normalize("Henry Ⅳ").unpack("U*")).to eq([72, 101, 110, 114, 121, 32, 73, 86])
|
45
43
|
end
|
46
44
|
end
|
47
45
|
|
@@ -49,10 +47,10 @@ module ICU
|
|
49
47
|
let(:normalizer) { ICU::Normalizer.new(nil, 'nfkc', :compose) }
|
50
48
|
|
51
49
|
it "should normalize a string" do
|
52
|
-
normalizer.normalize("Äffin").unpack("U*").
|
53
|
-
normalizer.normalize("Äffin").unpack("U*").
|
54
|
-
normalizer.normalize("Henry IV").unpack("U*").
|
55
|
-
normalizer.normalize("Henry Ⅳ").unpack("U*").
|
50
|
+
expect(normalizer.normalize("Äffin").unpack("U*")).to eq([196, 102, 102, 105, 110])
|
51
|
+
expect(normalizer.normalize("Äffin").unpack("U*")).to eq([196, 102, 102, 105, 110])
|
52
|
+
expect(normalizer.normalize("Henry IV").unpack("U*")).to eq([72, 101, 110, 114, 121, 32, 73, 86])
|
53
|
+
expect(normalizer.normalize("Henry Ⅳ").unpack("U*")).to eq([72, 101, 110, 114, 121, 32, 73, 86])
|
56
54
|
end
|
57
55
|
end
|
58
56
|
end # Normalizer
|
@@ -1,68 +1,71 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
3
|
module ICU
|
6
4
|
module NumberFormatting
|
7
5
|
describe 'NumberFormatting' do
|
8
6
|
it 'should format a simple integer' do
|
9
|
-
NumberFormatting.format_number("en", 1).
|
10
|
-
NumberFormatting.format_number("en", 1_000).
|
11
|
-
NumberFormatting.format_number("de-DE", 1_000_000).
|
7
|
+
expect(NumberFormatting.format_number("en", 1)).to eq("1")
|
8
|
+
expect(NumberFormatting.format_number("en", 1_000)).to eq("1,000")
|
9
|
+
expect(NumberFormatting.format_number("de-DE", 1_000_000)).to eq("1.000.000")
|
12
10
|
end
|
13
11
|
|
14
12
|
it 'should format a float' do
|
15
|
-
NumberFormatting.format_number("en", 1.0).
|
16
|
-
NumberFormatting.format_number("en", 1.123).
|
17
|
-
NumberFormatting.format_number("en", 1_000.1238).
|
18
|
-
NumberFormatting.format_number("en", 1_000.1238, max_fraction_digits: 4).
|
13
|
+
expect(NumberFormatting.format_number("en", 1.0)).to eq("1")
|
14
|
+
expect(NumberFormatting.format_number("en", 1.123)).to eq("1.123")
|
15
|
+
expect(NumberFormatting.format_number("en", 1_000.1238)).to eq("1,000.124")
|
16
|
+
expect(NumberFormatting.format_number("en", 1_000.1238, max_fraction_digits: 4)).to eq("1,000.1238")
|
19
17
|
NumberFormatting.set_default_options(fraction_digits: 5)
|
20
|
-
NumberFormatting.format_number("en", 1_000.1238).
|
18
|
+
expect(NumberFormatting.format_number("en", 1_000.1238)).to eq("1,000.12380")
|
21
19
|
NumberFormatting.clear_default_options
|
22
20
|
end
|
23
21
|
|
24
22
|
it 'should format a decimal' do
|
25
|
-
NumberFormatting.format_number("en", BigDecimal
|
23
|
+
expect(NumberFormatting.format_number("en", BigDecimal("10000.123"))).to eq("10,000.123")
|
26
24
|
end
|
27
25
|
|
28
26
|
it 'should format a currency' do
|
29
|
-
NumberFormatting.format_currency("en", 123.45, 'USD').
|
30
|
-
NumberFormatting.format_currency("en", 123_123.45, 'USD').
|
31
|
-
NumberFormatting.format_currency("de-DE", 123_123.45, 'EUR').
|
27
|
+
expect(NumberFormatting.format_currency("en", 123.45, 'USD')).to eq("$123.45")
|
28
|
+
expect(NumberFormatting.format_currency("en", 123_123.45, 'USD')).to eq("$123,123.45")
|
29
|
+
expect(NumberFormatting.format_currency("de-DE", 123_123.45, 'EUR')).to eq("123.123,45\u{A0}€")
|
32
30
|
end
|
33
31
|
|
34
32
|
it 'should format a percent' do
|
35
|
-
NumberFormatting.format_percent("en", 1.1).
|
36
|
-
NumberFormatting.format_percent("da", 0.15).
|
37
|
-
NumberFormatting.format_percent("da", -0.1545, max_fraction_digits: 10).
|
33
|
+
expect(NumberFormatting.format_percent("en", 1.1)).to eq("110%")
|
34
|
+
expect(NumberFormatting.format_percent("da", 0.15)).to eq("15\u{A0}%")
|
35
|
+
expect(NumberFormatting.format_percent("da", -0.1545, max_fraction_digits: 10)).to eq("-15,45\u{A0}%")
|
38
36
|
end
|
39
37
|
|
40
38
|
it 'should spell numbers' do
|
41
|
-
NumberFormatting.spell("en_US", 1_000).
|
42
|
-
NumberFormatting.spell("de-DE", 123.456).
|
39
|
+
expect(NumberFormatting.spell("en_US", 1_000)).to eq('one thousand')
|
40
|
+
expect(NumberFormatting.spell("de-DE", 123.456)).to eq("ein\u{AD}hundert\u{AD}drei\u{AD}und\u{AD}zwanzig Komma vier fünf sechs")
|
43
41
|
end
|
44
42
|
|
45
43
|
it 'should be able to re-use number formatter objects' do
|
46
44
|
numf = NumberFormatting.create('fr-CA')
|
47
|
-
numf.format(1_000).
|
48
|
-
numf.format(1_000.123).
|
45
|
+
expect(numf.format(1_000)).to eq("1\u{A0}000")
|
46
|
+
expect(numf.format(1_000.123)).to eq("1\u{A0}000,123")
|
49
47
|
end
|
50
48
|
|
51
49
|
it 'should be able to re-use currency formatter objects' do
|
52
50
|
curf = NumberFormatting.create('en-US', :currency)
|
53
|
-
curf.format(1_000.12, 'USD').
|
51
|
+
expect(curf.format(1_000.12, 'USD')).to eq("$1,000.12")
|
54
52
|
end
|
55
53
|
|
56
54
|
it 'should allow for various styles of currency formatting if the version is new enough' do
|
57
55
|
if ICU::Lib.version.to_a.first >= 53
|
58
56
|
curf = NumberFormatting.create('en-US', :currency, style: :iso)
|
59
|
-
|
57
|
+
expected = if ICU::Lib.version.to_a.first >= 62
|
58
|
+
"USD\u00A01,000.12"
|
59
|
+
else
|
60
|
+
"USD1,000.12"
|
61
|
+
end
|
62
|
+
expect(curf.format(1_000.12, 'USD')).to eq(expected)
|
60
63
|
curf = NumberFormatting.create('en-US', :currency, style: :plural)
|
61
|
-
curf.format(1_000.12, 'USD').
|
64
|
+
expect(curf.format(1_000.12, 'USD')).to eq("1,000.12 US dollars")
|
62
65
|
expect { NumberFormatting.create('en-US', :currency, style: :fake) }.to raise_error(StandardError)
|
63
66
|
else
|
64
67
|
curf = NumberFormatting.create('en-US', :currency, style: :default)
|
65
|
-
curf.format(1_000.12, 'USD').
|
68
|
+
expect(curf.format(1_000.12, 'USD')).to eq('$1,000.12')
|
66
69
|
expect { NumberFormatting.create('en-US', :currency, style: :iso) }.to raise_error(StandardError)
|
67
70
|
end
|
68
71
|
end
|
data/spec/time_spec.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
3
|
module ICU
|
6
4
|
describe TimeFormatting do
|
7
5
|
describe 'the TimeFormatting ' do
|
@@ -17,21 +15,21 @@ module ICU
|
|
17
15
|
|
18
16
|
f1 = TimeFormatting.create(:locale => 'cs_CZ', :zone => 'Europe/Prague', :date => :long , :time => :long, :tz_style => :localized_long)
|
19
17
|
it 'check date_format for lang=cs_CZ' do
|
20
|
-
f1.date_format(true).
|
21
|
-
f1.date_format(false).
|
18
|
+
expect(f1.date_format(true)).to eq("d. MMMM y H:mm:ss ZZZZ")
|
19
|
+
expect(f1.date_format(false)).to eq("d. MMMM y H:mm:ss ZZZZ")
|
22
20
|
end
|
23
21
|
|
24
22
|
it "for lang=cs_CZ zone=Europe/Prague" do
|
25
|
-
f1.
|
26
|
-
f1.format(t0).
|
27
|
-
f1.format(t1).
|
28
|
-
f1.format(t2).
|
29
|
-
f1.format(t3).
|
30
|
-
f1.format(t4).
|
31
|
-
f1.format(t5).
|
32
|
-
f1.format(t6).
|
33
|
-
f1.format(t7).
|
34
|
-
f1.format(t8).
|
23
|
+
expect(f1).to be_an_instance_of TimeFormatting::DateTimeFormatter
|
24
|
+
expect(f1.format(t0)).to eq("12. listopadu 2008 15:21:16 GMT+01:00")
|
25
|
+
expect(f1.format(t1)).to eq("25. října 2008 1:15:17 GMT+02:00")
|
26
|
+
expect(f1.format(t2)).to eq("25. října 2008 2:16:18 GMT+02:00")
|
27
|
+
expect(f1.format(t3)).to eq("25. října 2008 3:17:19 GMT+02:00")
|
28
|
+
expect(f1.format(t4)).to eq("25. října 2008 4:18:20 GMT+02:00")
|
29
|
+
expect(f1.format(t5)).to eq("29. března 2008 1:35:21 GMT+01:00")
|
30
|
+
expect(f1.format(t6)).to eq("29. března 2008 2:36:22 GMT+01:00")
|
31
|
+
expect(f1.format(t7)).to eq("29. března 2008 3:37:23 GMT+01:00")
|
32
|
+
expect(f1.format(t8)).to eq("29. března 2008 4:38:24 GMT+01:00")
|
35
33
|
end
|
36
34
|
|
37
35
|
f2 = TimeFormatting.create(:locale => 'en_US', :zone => 'Europe/Moscow', :date => :short , :time => :long, :tz_style => :generic_location)
|
@@ -45,20 +43,20 @@ module ICU
|
|
45
43
|
|
46
44
|
en_exp = "M/d/yy#{en_sep} h:mm:ss a VVVV"
|
47
45
|
it 'check date_format for lang=en_US' do
|
48
|
-
f2.date_format(true).
|
49
|
-
f2.date_format(false).
|
46
|
+
expect(f2.date_format(true)).to eq(en_exp)
|
47
|
+
expect(f2.date_format(false)).to eq(en_exp)
|
50
48
|
end
|
51
49
|
|
52
50
|
it "lang=en_US zone=Europe/Moscow" do
|
53
|
-
f2.format(t0).
|
54
|
-
f2.format(t1).
|
55
|
-
f2.format(t2).
|
56
|
-
f2.format(t3).
|
57
|
-
f2.format(t4).
|
58
|
-
f2.format(t5).
|
59
|
-
f2.format(t6).
|
60
|
-
f2.format(t7).
|
61
|
-
f2.format(t8).
|
51
|
+
expect(f2.format(t0)).to eq("11/12/08#{en_sep} 5:21:16 PM #{en_tz}")
|
52
|
+
expect(f2.format(t1)).to eq("10/25/08#{en_sep} 3:15:17 AM #{en_tz}")
|
53
|
+
expect(f2.format(t2)).to eq("10/25/08#{en_sep} 4:16:18 AM #{en_tz}")
|
54
|
+
expect(f2.format(t3)).to eq("10/25/08#{en_sep} 5:17:19 AM #{en_tz}")
|
55
|
+
expect(f2.format(t4)).to eq("10/25/08#{en_sep} 6:18:20 AM #{en_tz}")
|
56
|
+
expect(f2.format(t5)).to eq("3/29/08#{en_sep} 3:35:21 AM #{en_tz}")
|
57
|
+
expect(f2.format(t6)).to eq("3/29/08#{en_sep} 4:36:22 AM #{en_tz}")
|
58
|
+
expect(f2.format(t7)).to eq("3/29/08#{en_sep} 5:37:23 AM #{en_tz}")
|
59
|
+
expect(f2.format(t8)).to eq("3/29/08#{en_sep} 6:38:24 AM #{en_tz}")
|
62
60
|
end
|
63
61
|
|
64
62
|
f3 = TimeFormatting.create(:locale => 'de_DE', :zone => 'Africa/Dakar ', :date => :short , :time => :long)
|
@@ -69,22 +67,21 @@ module ICU
|
|
69
67
|
|
70
68
|
ge_exp = "dd.MM.yy#{ge_sep} HH:mm:ss z"
|
71
69
|
it 'check date_format for lang=de_DE' do
|
72
|
-
f3.date_format(true).
|
73
|
-
f3.date_format(false).
|
70
|
+
expect(f3.date_format(true)).to eq(ge_exp)
|
71
|
+
expect(f3.date_format(false)).to eq(ge_exp)
|
74
72
|
end
|
75
73
|
|
76
74
|
it "lang=de_DE zone=Africa/Dakar" do
|
77
|
-
f3.format(t0).
|
78
|
-
f3.format(t1).
|
79
|
-
f3.format(t2).
|
80
|
-
f3.format(t3).
|
81
|
-
f3.format(t4).
|
82
|
-
f3.format(t5).
|
83
|
-
f3.format(t6).
|
84
|
-
f3.format(t7).
|
85
|
-
f3.format(t8).
|
75
|
+
expect(f3.format(t0)).to eq("12.11.08#{ge_sep} 14:21:16 GMT")
|
76
|
+
expect(f3.format(t1)).to eq("24.10.08#{ge_sep} 23:15:17 GMT")
|
77
|
+
expect(f3.format(t2)).to eq("25.10.08#{ge_sep} 00:16:18 GMT")
|
78
|
+
expect(f3.format(t3)).to eq("25.10.08#{ge_sep} 01:17:19 GMT")
|
79
|
+
expect(f3.format(t4)).to eq("25.10.08#{ge_sep} 02:18:20 GMT")
|
80
|
+
expect(f3.format(t5)).to eq("29.03.08#{ge_sep} 00:35:21 GMT")
|
81
|
+
expect(f3.format(t6)).to eq("29.03.08#{ge_sep} 01:36:22 GMT")
|
82
|
+
expect(f3.format(t7)).to eq("29.03.08#{ge_sep} 02:37:23 GMT")
|
83
|
+
expect(f3.format(t8)).to eq("29.03.08#{ge_sep} 03:38:24 GMT")
|
86
84
|
end
|
87
85
|
end
|
88
86
|
end
|
89
87
|
end
|
90
|
-
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
3
|
module ICU
|
6
4
|
describe Transliteration::Transliterator do
|
7
5
|
def transliterator_for(*args)
|
@@ -16,7 +14,7 @@ module ICU
|
|
16
14
|
].each do |id, input, output|
|
17
15
|
it "should transliterate #{id}" do
|
18
16
|
tl = transliterator_for(id)
|
19
|
-
tl.transliterate(input).
|
17
|
+
expect(tl.transliterate(input)).to eq(output)
|
20
18
|
end
|
21
19
|
|
22
20
|
end
|
@@ -25,12 +23,13 @@ module ICU
|
|
25
23
|
describe Transliteration do
|
26
24
|
it "should provide a list of available ids" do
|
27
25
|
ids = ICU::Transliteration.available_ids
|
28
|
-
|
29
|
-
ids.
|
26
|
+
|
27
|
+
expect(ids).to be_an(Array)
|
28
|
+
expect(ids).to_not be_empty
|
30
29
|
end
|
31
30
|
|
32
31
|
it "should transliterate custom rules" do
|
33
|
-
ICU::Transliteration.translit("NFD; [:Nonspacing Mark:] Remove; NFC", "âêîôû").
|
32
|
+
expect(ICU::Transliteration.translit("NFD; [:Nonspacing Mark:] Remove; NFC", "âêîôû")).to eq("aeiou")
|
34
33
|
end
|
35
34
|
|
36
35
|
end # Transliteration
|
data/spec/uchar_spec.rb
CHANGED
@@ -1,35 +1,33 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
3
|
module ICU
|
6
4
|
describe UCharPointer do
|
7
5
|
it 'allocates enough memory for 16-bit characters' do
|
8
|
-
UCharPointer.new(5).size.
|
6
|
+
expect(UCharPointer.new(5).size).to eq(10)
|
9
7
|
end
|
10
8
|
|
11
9
|
it 'builds a buffer from a string' do
|
12
10
|
ptr = UCharPointer.from_string('abc')
|
13
|
-
ptr.
|
14
|
-
ptr.size.
|
15
|
-
ptr.read_array_of_uint16(3).
|
11
|
+
expect(ptr).to be_a UCharPointer
|
12
|
+
expect(ptr.size).to eq(6)
|
13
|
+
expect(ptr.read_array_of_uint16(3)).to eq([0x61, 0x62, 0x63])
|
16
14
|
end
|
17
15
|
|
18
16
|
it 'takes an optional capacity' do
|
19
17
|
ptr = UCharPointer.from_string('abc', 5)
|
20
|
-
ptr.size.
|
18
|
+
expect(ptr.size).to eq(10)
|
21
19
|
end
|
22
20
|
|
23
21
|
describe 'converting to string' do
|
24
22
|
let(:ptr) { UCharPointer.new(3).write_array_of_uint16 [0x78, 0x0, 0x79] }
|
25
23
|
|
26
24
|
it 'returns the the entire buffer by default' do
|
27
|
-
ptr.string.
|
25
|
+
expect(ptr.string).to eq("x\0y")
|
28
26
|
end
|
29
27
|
|
30
28
|
it 'returns strings of the specified length' do
|
31
|
-
ptr.string(0).
|
32
|
-
ptr.string(2).
|
29
|
+
expect(ptr.string(0)).to eq("")
|
30
|
+
expect(ptr.string(2)).to eq("x\0")
|
33
31
|
end
|
34
32
|
end
|
35
33
|
end
|
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-icu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jari Bakken
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2019-10-15 00:00:00.000000000 Z
|
@@ -36,34 +36,28 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
40
|
-
- - ">="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: 2.5.0
|
39
|
+
version: '3.9'
|
43
40
|
type: :development
|
44
41
|
prerelease: false
|
45
42
|
version_requirements: !ruby/object:Gem::Requirement
|
46
43
|
requirements:
|
47
44
|
- - "~>"
|
48
45
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
50
|
-
- - ">="
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: 2.5.0
|
46
|
+
version: '3.9'
|
53
47
|
- !ruby/object:Gem::Dependency
|
54
48
|
name: rake
|
55
49
|
requirement: !ruby/object:Gem::Requirement
|
56
50
|
requirements:
|
57
|
-
- - "
|
51
|
+
- - ">="
|
58
52
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
53
|
+
version: 12.3.3
|
60
54
|
type: :development
|
61
55
|
prerelease: false
|
62
56
|
version_requirements: !ruby/object:Gem::Requirement
|
63
57
|
requirements:
|
64
|
-
- - "
|
58
|
+
- - ">="
|
65
59
|
- !ruby/object:Gem::Version
|
66
|
-
version:
|
60
|
+
version: 12.3.3
|
67
61
|
description: Provides charset detection, locale sensitive collation and more. Depends
|
68
62
|
on libicu.
|
69
63
|
email: jari.bakken@gmail.com
|
@@ -75,6 +69,7 @@ extra_rdoc_files:
|
|
75
69
|
files:
|
76
70
|
- ".document"
|
77
71
|
- ".gitignore"
|
72
|
+
- ".rspec"
|
78
73
|
- ".travis.yml"
|
79
74
|
- Gemfile
|
80
75
|
- LICENSE
|
@@ -107,7 +102,6 @@ files:
|
|
107
102
|
- spec/normalization_spec.rb
|
108
103
|
- spec/normalizer_spec.rb
|
109
104
|
- spec/number_formatting_spec.rb
|
110
|
-
- spec/spec.opts
|
111
105
|
- spec/spec_helper.rb
|
112
106
|
- spec/time_spec.rb
|
113
107
|
- spec/transliteration_spec.rb
|
@@ -117,7 +111,7 @@ homepage: http://github.com/jarib/ffi-icu
|
|
117
111
|
licenses:
|
118
112
|
- MIT
|
119
113
|
metadata: {}
|
120
|
-
post_install_message:
|
114
|
+
post_install_message:
|
121
115
|
rdoc_options:
|
122
116
|
- "--charset=UTF-8"
|
123
117
|
require_paths:
|
@@ -133,9 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
127
|
- !ruby/object:Gem::Version
|
134
128
|
version: '0'
|
135
129
|
requirements: []
|
136
|
-
|
137
|
-
|
138
|
-
signing_key:
|
130
|
+
rubygems_version: 3.0.9
|
131
|
+
signing_key:
|
139
132
|
specification_version: 4
|
140
133
|
summary: Simple Ruby FFI wrappers for things I need from ICU.
|
141
134
|
test_files:
|
@@ -148,7 +141,6 @@ test_files:
|
|
148
141
|
- spec/normalization_spec.rb
|
149
142
|
- spec/normalizer_spec.rb
|
150
143
|
- spec/number_formatting_spec.rb
|
151
|
-
- spec/spec.opts
|
152
144
|
- spec/spec_helper.rb
|
153
145
|
- spec/time_spec.rb
|
154
146
|
- spec/transliteration_spec.rb
|