mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
tests: another pointer struct test
This commit is contained in:
parent
766ed20bf3
commit
57af8570fe
@ -11,6 +11,23 @@ fn test_pointer_arithmetic() {
|
||||
}
|
||||
}
|
||||
|
||||
struct User {
|
||||
mut:
|
||||
name string
|
||||
}
|
||||
|
||||
fn modify_ptr(mut user User) {
|
||||
user.name = 'Bob'
|
||||
}
|
||||
|
||||
fn test_mut_ptr() {
|
||||
mut user := &User{'Peter'}
|
||||
assert user.name == 'Peter'
|
||||
modify_ptr(mut user)
|
||||
assert user.name == 'Bob'
|
||||
println(user)
|
||||
}
|
||||
|
||||
/*
|
||||
fn test_multi_level_pointer_dereferencing() {
|
||||
n := 100
|
||||
|
Loading…
Reference in New Issue
Block a user