Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
24048cd9
Commit
24048cd9
authored
Feb 10, 2017
by
Tomasz Dabrowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests for UTF-8 String#ljust and String#rjust
parent
c802cd07
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
mrbgems/mruby-string-ext/test/string.rb
mrbgems/mruby-string-ext/test/string.rb
+30
-0
No files found.
mrbgems/mruby-string-ext/test/string.rb
View file @
24048cd9
...
...
@@ -433,6 +433,7 @@ end
assert
(
'String#ljust'
)
do
assert_equal
"hello"
,
"hello"
.
ljust
(
4
)
assert_equal
"hello "
,
"hello"
.
ljust
(
20
)
assert_equal
20
,
"hello"
.
ljust
(
20
).
length
assert_equal
"hello123412341234123"
,
"hello"
.
ljust
(
20
,
'1234'
)
assert_equal
"hello"
,
"hello"
.
ljust
(
-
3
)
end
...
...
@@ -440,10 +441,39 @@ end
assert
(
'String#rjust'
)
do
assert_equal
"hello"
,
"hello"
.
rjust
(
4
)
assert_equal
" hello"
,
"hello"
.
rjust
(
20
)
assert_equal
20
,
"hello"
.
rjust
(
20
).
length
assert_equal
"123412341234123hello"
,
"hello"
.
rjust
(
20
,
'1234'
)
assert_equal
"hello"
,
"hello"
.
rjust
(
-
3
)
end
if
UTF8STRING
assert
(
'String#ljust with UTF8'
)
do
assert_equal
"helloん "
,
"helloん"
.
ljust
(
20
)
assert_equal
"helloó "
,
"helloó"
.
ljust
(
34
)
assert_equal
34
,
"helloó"
.
ljust
(
34
).
length
assert_equal
"helloんんんんんんんんんんんんんん"
,
"hello"
.
ljust
(
19
,
'ん'
)
assert_equal
"helloんんんんんんんんんんんんんんん"
,
"hello"
.
ljust
(
20
,
'ん'
)
end
assert
(
'String#rjust with UTF8'
)
do
assert_equal
" helloん"
,
"helloん"
.
rjust
(
20
)
assert_equal
" helloó"
,
"helloó"
.
rjust
(
34
)
# assert_equal 34, "helloó".rjust(34).length
assert_equal
"んんんんんんんんんんんんんんhello"
,
"hello"
.
rjust
(
19
,
'ん'
)
assert_equal
"んんんんんんんんんんんんんんんhello"
,
"hello"
.
rjust
(
20
,
'ん'
)
end
assert
(
'UTF8 byte counting'
)
do
skip
(
'string length is broken after []='
)
# based on assert_equal 34, "helloó".rjust(34).length
ret
=
' '
ret
[
-
6
..-
1
]
=
"helloó"
assert_equal
34
,
ret
.
length
end
end
assert
(
'String#ljust should not change string'
)
do
a
=
"hello"
a
.
ljust
(
20
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment