-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_string_utils.mojo
47 lines (33 loc) · 974 Bytes
/
test_string_utils.mojo
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
from string_utils import to_lower, to_upper, to_repr, to_string_ref
from testing import assert_equal
fn test_to_upper() raises -> Bool:
if assert_equal(to_upper("hello"), "HELLO"):
print_no_newline(".")
else:
print_no_newline("E")
return False
return True
fn test_to_lower() raises -> Bool:
if assert_equal(to_lower("HELLO"), "hello"):
print_no_newline(".")
else:
print_no_newline("E")
return False
return True
fn test_to_repr() raises -> Bool:
let s = "hello\n\r"
if assert_equal(to_repr(s), '"hello\\n\\r"'):
print_no_newline(".")
else:
print_no_newline("E")
return False
return True
fn test_to_string_ref() raises -> Bool:
let s: String = "hello"
let expected: StringRef = "hello"
if assert_equal(to_string_ref(s), expected):
print_no_newline(".")
else:
print_no_newline("E")
return False
return True