aboutsummaryrefslogtreecommitdiff
path: root/gen/test/gleam@string_test.erl
blob: ed4b204b44a921ff9984bd3cf162375249a8b6aa (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
-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, concat_test/0, join_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).

concat_test() ->
    gleam@expect:equal(
        gleam@string:concat([<<"Hello">>, <<", ">>, <<"world!">>]),
        <<"Hello, world!">>
    ).

join_test() ->
    gleam@expect:equal(
        gleam@string:join([<<"Hello">>, <<"world!">>], <<", ">>),
        <<"Hello, world!">>
    ),
    gleam@expect:equal(
        gleam@string:join([<<"Hello">>, <<"world!">>], <<"-">>),
        <<"Hello-world!">>
    ).