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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
import expect
import iodata
pub fn iodata_test() {
let data = iodata:new("ello")
|> iodata:append(_, ",")
|> iodata:append(_, " world!")
|> iodata:prepend(_, "H")
data
|> iodata:to_string
|> expect:equal(_, "Hello, world!")
data
|> iodata:byte_size
|> expect:equal(_, 13)
let data = iodata:new("ello")
|> iodata:append_iodata(_, iodata:new(","))
|> iodata:append_iodata(_, iodata:concat([iodata:new(" wo"), iodata:new("rld!")]))
|> iodata:prepend_iodata(_, iodata:new("H"))
data
|> iodata:to_string
|> expect:equal(_, "Hello, world!")
data
|> iodata:byte_size
|> expect:equal(_, 13)
}
pub fn lowercase_test() {
["Gleam", "Gleam"]
|> iodata:from_strings
|> iodata:lowercase
|> iodata:to_string
|> expect:equal(_, "gleamgleam")
}
pub fn uppercase_test() {
["Gleam", "Gleam"]
|> iodata:from_strings
|> iodata:uppercase
|> iodata:to_string
|> expect:equal(_, "GLEAMGLEAM")
}
pub fn split_test() {
"Gleam,Erlang,Elixir"
|> iodata:new
|> iodata:split(_, ",")
|> expect:equal(_, [iodata:new("Gleam"), iodata:new("Erlang"), iodata:new("Elixir")])
["Gleam, Erl", "ang,Elixir"]
|> iodata:from_strings
|> iodata:split(_, ", ")
|> expect:equal(_, [iodata:new("Gleam"), iodata:from_strings(["Erl", "ang,Elixir"])])
}
pub fn is_equal_test() {
iodata:new("12")
|> iodata:is_equal(_, iodata:from_strings(["1", "2"]))
|> expect:true
iodata:new("12")
|> iodata:is_equal(_, iodata:new("12"))
|> expect:true
iodata:new("12")
|> iodata:is_equal(_, iodata:new("2"))
|> expect:false
}
pub fn is_empty_test() {
iodata:new("")
|> iodata:is_empty
|> expect:true
iodata:new("12")
|> iodata:is_empty
|> expect:false
iodata:from_strings([])
|> iodata:is_empty
|> expect:true
iodata:from_strings(["", ""])
|> iodata:is_empty
|> expect:true
}
|