aboutsummaryrefslogtreecommitdiff
path: root/gen/test/gleam@string_test.erl
blob: e28f6969f8eb46dbc409311533e64d9f5627d936 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
-module(gleam@string_test).
-compile(no_auto_import).

-export([length_test/0, lowercase_test/0, uppercase_test/0, reverse_test/0, split_test/0, replace_test/0, append_test/0, compare_test/0]).

length_test() ->
    gleam@expect:equal(gleam@string:length(<<"ß↑e̊">>), 3),
    gleam@expect:equal(gleam@string:length(<<"Gleam">>), 5),
    gleam@expect:equal(gleam@string:length(<<"">>), 0).

lowercase_test() ->
    gleam@expect:equal(gleam@string:lowercase(<<"Gleam">>), <<"gleam">>).

uppercase_test() ->
    gleam@expect:equal(gleam@string:uppercase(<<"Gleam">>), <<"GLEAM">>).

reverse_test() ->
    gleam@expect:equal(gleam@string:reverse(<<"Gleam">>), <<"maelG">>).

split_test() ->
    gleam@expect:equal(
        gleam@string:split(<<"Gleam,Erlang,Elixir">>, <<",">>),
        [<<"Gleam">>, <<"Erlang">>, <<"Elixir">>]
    ),
    gleam@expect:equal(
        gleam@string:split(<<"Gleam, Erlang,Elixir">>, <<", ">>),
        [<<"Gleam">>, <<"Erlang,Elixir">>]
    ).

replace_test() ->
    gleam@expect:equal(
        gleam@string:replace(<<"Gleam,Erlang,Elixir">>, <<",">>, <<"++">>),
        <<"Gleam++Erlang++Elixir">>
    ).

append_test() ->
    gleam@expect:equal(
        gleam@string:append(<<"Test">>, <<" Me">>),
        <<"Test Me">>
    ).

compare_test() ->
    gleam@expect:equal(gleam@string:compare(<<"">>, <<"">>), eq),
    gleam@expect:equal(gleam@string:compare(<<"a">>, <<"">>), gt),
    gleam@expect:equal(gleam@string:compare(<<"a">>, <<"A">>), gt),
    gleam@expect:equal(gleam@string:compare(<<"A">>, <<"B">>), lt),
    gleam@expect:equal(gleam@string:compare(<<"t">>, <<"ABC">>), gt).