Skip to content

Commit

Permalink
Merge pull request #1900 from krestenkrab/krab-unicode
Browse files Browse the repository at this point in the history
In response to "The string type is broken"
  • Loading branch information
José Valim committed Nov 29, 2013
2 parents a829da1 + d95a7d1 commit c093e37
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/elixir/test/elixir/string_test.exs
Expand Up @@ -15,6 +15,19 @@ defmodule StringTest do
assert String.next_codepoint("") == :no_codepoint
end

# test cases described in http://mortoray.com/2013/11/27/the-string-type-is-broken/
test :unicode do
assert String.reverse("noël") == "lëon"
assert String.slice("noël", 0..2) == "noë"
assert String.length("noël") == 4

assert String.length("😸😾") == 2
assert String.slice("😸😾", 1..1) == "😾"
assert String.reverse("😸😾") == "😾😸"

assert String.upcase("baffle") == "BAFFLE"
end

test :split do
assert String.split("") == [""]
assert String.split("foo bar") == ["foo", "bar"]
Expand Down

0 comments on commit c093e37

Please sign in to comment.