Skip to content

Commit 1bd7d2d

Browse files
committed
Add a test for _lpython_str_equal()
1 parent 7d763bc commit 1bd7d2d

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

integration_tests/run_tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"test_builtin_int.py",
2424
"test_builtin_len.py",
2525
"test_builtin_float.py",
26+
"test_builtin_str_02.py",
2627
"test_math1.py",
2728
"test_math_02.py",
2829
"test_c_interop_01.py",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
def _lpython_str_equal(a: str, b: str) -> bool:
2+
if len(a) != len(b):
3+
return False
4+
i: i32
5+
for i in range(len(a)):
6+
if a[i] != b[i]:
7+
return False
8+
return True
9+
10+
def f():
11+
assert _lpython_str_equal("a", "a")
12+
assert not _lpython_str_equal("a2", "a")
13+
assert not _lpython_str_equal("a", "a123")
14+
assert not _lpython_str_equal("a23", "a24")
15+
assert _lpython_str_equal("a24", "a24")
16+
assert _lpython_str_equal("abcdefg", "abcdefg")
17+
assert not _lpython_str_equal("abcdef3", "abcdefg")
18+
19+
f()

0 commit comments

Comments
 (0)