diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-03-07 18:51:32 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-03-07 18:51:32 +0900 |
| commit | ac8d04fb6c2072c9af0b0587044360dde3b3b77d (patch) | |
| tree | ab80df9179be235331935999dc4393670746a5ea /test | |
| parent | 035898c7215c417e2ba24e759c033710ac74c6cc (diff) | |
| parent | 4bc19d5fadaf85523774eac29520cca03a1516b1 (diff) | |
| download | mruby-ac8d04fb6c2072c9af0b0587044360dde3b3b77d.tar.gz mruby-ac8d04fb6c2072c9af0b0587044360dde3b3b77d.zip | |
Merge pull request #1820 from ksss/string-embed
Embed small string
Diffstat (limited to 'test')
| -rw-r--r-- | test/driver.c | 6 | ||||
| -rw-r--r-- | test/t/string.rb | 21 |
2 files changed, 22 insertions, 5 deletions
diff --git a/test/driver.c b/test/driver.c index 0116f4584..2af1680f4 100644 --- a/test/driver.c +++ b/test/driver.c @@ -61,14 +61,12 @@ eval_test(mrb_state *mrb) static void t_printstr(mrb_state *mrb, mrb_value obj) { - struct RString *str; char *s; int len; if (mrb_string_p(obj)) { - str = mrb_str_ptr(obj); - s = str->ptr; - len = str->len; + s = RSTRING_PTR(obj); + len = RSTRING_LEN(obj); fwrite(s, len, 1, stdout); } } diff --git a/test/t/string.rb b/test/t/string.rb index 0556d12af..445cf7439 100644 --- a/test/t/string.rb +++ b/test/t/string.rb @@ -86,6 +86,7 @@ assert('String#[] with Range') do g1 = 'abc'[-2..3] h1 = 'abc'[3..4] i1 = 'abc'[4..5] + j1 = 'abcdefghijklmnopqrstuvwxyz'[1..3] a2 = 'abc'[1...0] b2 = 'abc'[1...1] c2 = 'abc'[1...2] @@ -95,6 +96,7 @@ assert('String#[] with Range') do g2 = 'abc'[-2...3] h2 = 'abc'[3...4] i2 = 'abc'[4...5] + j2 = 'abcdefghijklmnopqrstuvwxyz'[1...3] assert_equal '', a1 assert_equal 'b', b1 @@ -105,6 +107,7 @@ assert('String#[] with Range') do assert_equal 'bc', g1 assert_equal '', h1 assert_nil i2 + assert_equal 'bcd', j1 assert_equal '', a2 assert_equal '', b2 assert_equal 'b', c2 @@ -114,6 +117,7 @@ assert('String#[] with Range') do assert_equal 'bc', g2 assert_equal '', h2 assert_nil i2 + assert_equal 'bc', j2 end assert('String#capitalize', '15.2.10.5.7') do @@ -281,8 +285,10 @@ end assert('String#initialize', '15.2.10.5.23') do a = '' a.initialize('abc') - assert_equal 'abc', a + + a.initialize('abcdefghijklmnopqrstuvwxyz') + assert_equal 'abcdefghijklmnopqrstuvwxyz', a end assert('String#initialize_copy', '15.2.10.5.24') do @@ -307,6 +313,13 @@ assert('String#replace', '15.2.10.5.28') do a.replace('abc') assert_equal 'abc', a + assert_equal 'abc', 'cba'.replace(a) + + b = 'abc' * 10 + c = ('cba' * 10).dup + b.replace(c); + c.replace(b); + assert_equal c, b end assert('String#reverse', '15.2.10.5.29') do @@ -452,6 +465,12 @@ assert('String#upcase!', '15.2.10.5.43') do assert_equal 'ABC', a assert_equal nil, 'ABC'.upcase! + + a = 'abcdefghijklmnopqrstuvwxyz' + b = a.dup + a.upcase! + b.upcase! + assert_equal 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', b end # Not ISO specified |
