X-Git-Url: https://pd.if.org/git/?p=lice;a=blobdiff_plain;f=tests%2Fpointer.c;fp=tests%2Fpointer.c;h=d734f78c9108bbf6dece5533ff05b717c11e0089;hp=0000000000000000000000000000000000000000;hb=946bdbe1d5dd89ab671391fbe429a1c2c48ecaa7;hpb=f1abb26903687c7967cf37c3f6c830051bdeb371 diff --git a/tests/pointer.c b/tests/pointer.c new file mode 100644 index 0000000..d734f78 --- /dev/null +++ b/tests/pointer.c @@ -0,0 +1,29 @@ +// pointers + +int main(void) { + int a = 1024; + int *b = &a; + char *c = "hi"; + char *d = "hi" + 1; + char e[] = "abc"; + char *f = e + 2; + char g[] = "abc"; + + *g = 32; + expecti(*b, 1024); + expecti(*c, 'h'); + expecti(*d, 'i'); + expecti(*f, 'c'); + expecti(*g, 32); + + int aa[] = { 1, 2, 3 }; + int *p = aa; + expecti(*p, 1); p++; + expecti(*p, 2); p++; + expecti(*p, 3); + expecti(*p, 3); p--; + expecti(*p, 2); p--; + expecti(*p, 1); + + return 0; +}