mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Allow use of pointers in vectors.
This commit is contained in:
committed by
Christoffer Lerno
parent
1d04b70efe
commit
b2ac4b4253
29
test/unit/regression/vecpointer.c3
Normal file
29
test/unit/regression/vecpointer.c3
Normal file
@@ -0,0 +1,29 @@
|
||||
module vecpointer @test;
|
||||
|
||||
fn void pointer_add_sub_diff()
|
||||
{
|
||||
int[5] a;
|
||||
void*[<2>] x = { &a[0], &a[4] };
|
||||
int*[<2>] y = x;
|
||||
assert(x[0] == y[0] && x[1] == y[1]);
|
||||
int*[2] y2;
|
||||
y2 = y;
|
||||
assert(y2[0] == x[0] && y2[1] == x[1]);
|
||||
y = { null, null };
|
||||
assert(y[0] == null && y[0] == null);
|
||||
y = y2;
|
||||
assert(x[0] == y[0] && x[1] == y[1]);
|
||||
int[<2>] z = { 1, -1 };
|
||||
y = y + z;
|
||||
assert(y[0] == &a[1] && y[1] == &a[3]);
|
||||
y = y - z;
|
||||
assert(y[0] == &a[0] && y[1] == &a[4]);
|
||||
int*[<2>] yy = { &a[1], &a[2] };
|
||||
isz[<2>] w;
|
||||
w = y - yy;
|
||||
assert(w == { -1, 2 });
|
||||
int*[<2>] zz = y - (y - yy);
|
||||
assert(zz[0] == &a[1] && zz[1] == &a[2]);
|
||||
int[*]*[<2>] g = int[2]*[<2>] { null, null };
|
||||
int[*]*[<*>] g2 = int[2]*[<2>] { null, null };
|
||||
}
|
||||
Reference in New Issue
Block a user