56 lines
696 B
Plaintext
56 lines
696 B
Plaintext
struct Point {
|
|
x int
|
|
y int
|
|
}
|
|
|
|
main() {
|
|
a := new(Point)
|
|
assert a.x == 0
|
|
assert a.y == 0
|
|
assert a.x == a.y
|
|
|
|
a.x = 1
|
|
a.y = 2
|
|
assert a.x == 1
|
|
assert a.y == 2
|
|
assert a.x != a.y
|
|
|
|
a.x = a.y
|
|
assert a.x == 2
|
|
assert a.y == 2
|
|
assert a.x == a.y
|
|
|
|
a.x = a.y + 1
|
|
assert a.x == 3
|
|
assert a.y == 2
|
|
assert a.x != a.y
|
|
|
|
a.y += 1
|
|
assert a.x == 3
|
|
assert a.y == 3
|
|
assert a.x == a.y
|
|
|
|
b := new(Point)
|
|
assert b.x == 0
|
|
assert b.y == 0
|
|
|
|
b.x = -3
|
|
b.y = -3
|
|
assert b.x == -3
|
|
assert b.y == -3
|
|
|
|
c := new(Point)
|
|
assert c.x == 0
|
|
assert c.y == 0
|
|
|
|
c.x = a.x + b.x
|
|
c.y = a.y + b.y
|
|
assert c.x == a.x + b.x
|
|
assert c.y == a.y + b.y
|
|
assert c.x == 0
|
|
assert c.y == 0
|
|
|
|
delete(a)
|
|
delete(b)
|
|
delete(c)
|
|
} |