Skip to content

Commit

Permalink
[stdlib] Test for the pointers difference
Browse files Browse the repository at this point in the history
Signed-off-by: Manuel Saelices <msaelices@gmail.com>
  • Loading branch information
msaelices committed Sep 20, 2024
1 parent cb72995 commit 19830ec
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions stdlib/test/memory/test_unsafepointer.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,14 @@ def test_load_and_store_simd():
assert_equal(ptr2[i], i // 4 * 4)


def test_difference():
var ptr = UnsafePointer[Int].alloc(5)
var ptr2 = ptr + 2
assert_equal(ptr2 - ptr, 2)
assert_equal(ptr - ptr2, -2)
ptr.free()


def main():
test_address_of()

Expand All @@ -297,6 +305,7 @@ def main():
test_unsafepointer_string()
test_eq()
test_comparisons()
test_difference()

test_unsafepointer_address_space()
test_indexing()
Expand Down

0 comments on commit 19830ec

Please sign in to comment.