X-Git-Url: https://pd.if.org/git/?p=lice;a=blobdiff_plain;f=tests%2Fglobal.c;fp=tests%2Fglobal.c;h=d74bdc0827387f7728e6444f34e5acd1a6c8a50b;hp=0000000000000000000000000000000000000000;hb=946bdbe1d5dd89ab671391fbe429a1c2c48ecaa7;hpb=f1abb26903687c7967cf37c3f6c830051bdeb371 diff --git a/tests/global.c b/tests/global.c new file mode 100644 index 0000000..d74bdc0 --- /dev/null +++ b/tests/global.c @@ -0,0 +1,49 @@ +// global variables + +int a = 1024; +int *b = &a; + +int c[10]; +int d[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + +int e, f; +int g, h = 10; +int i = 11, j; + +char k[] = "hello"; +char *l = "world"; + +long m = 32; +int *n = &(int) { 64 }; + +int main(void) { + expecti(a, 1024); + + // can write to global? + a = 2048; + expecti(a, 2048); + expecti(*b, 2048); + + c[1] = 2; + expecti(c[1], 2); + expecti(d[1], 2); + + e = 7; + f = 8; + expecti(e, 7); + expecti(f, 8); + g = 9; + expecti(g, 9); + expecti(h, 10); + expecti(i, 11); + j = 12; + expecti(j, 12); + + expectstr(k, "hello"); + expectstr(l, "world"); + + expectl(m, 32); + expectl(*n, 64); + + return 0; +}