flexcat 2.15 is picky.
[AROS.git] / test / dos / setenv.c
blobd8431e4a5a131db253e0f2211f599ab3f4bc1067
1 #include <string.h>
2 #include <stdio.h>
3 #include <proto/dos.h>
5 static void testvalue(CONST_STRPTR var, STRPTR expval, ULONG explen, BOOL expnull, LONG cnt)
7 TEXT buffer[10];
8 LONG len;
9 struct LocalVar * lv;
11 if ((len = GetVar(var, buffer, sizeof(buffer), 0)) < 0)
12 printf("test %d ERROR getvar %d\n", cnt, (int)len);
13 else
14 printf("test %d getvar '%s'\n", cnt, buffer);
15 if ((lv = FindVar(var, 0)) == NULL)
16 printf("test %d ERROR findvar\n", cnt);
17 else
18 printf("test %d findvar lv_Value=%p, lv_Len=%d\n", cnt, lv->lv_Value, lv->lv_Len);
19 if (lv->lv_Len != explen)
20 printf("test %d ERROR lv_Len, expected %d, found %d\n", cnt, explen, lv->lv_Len);
21 if (expnull && lv->lv_Value != NULL)
22 printf("test %d ERROR lv_Value expected NULL, found %p\n", cnt, lv->lv_Value);
24 if (!expnull && lv->lv_Value == NULL)
25 printf("test %d ERROR lv_Value expected not NULL, found %p\n", cnt, lv->lv_Value);
28 int main(void)
30 CONST_STRPTR var="abc";
31 STRPTR val="cde";
32 LONG cnt = 1;
34 /* Behavior validated with OS3.x */
36 printf("test %d setvar '%s'\n", cnt, val);
37 if (SetVar(var, val, strlen(val), 0) == DOSFALSE)
38 printf("error setvar\n");
39 testvalue(var, val, 3, FALSE, cnt++);
41 val="";
42 printf("test %d setvar '%s'\n", cnt, val);
43 if (SetVar(var, val, strlen(val), 0) == DOSFALSE)
44 printf("error setvar\n");
45 testvalue(var, val, 0, TRUE, cnt++);
47 val="abcd";
48 printf("test %d setvar '%s'\n", cnt, val);
49 if (SetVar(var, val, strlen(val), 0) == DOSFALSE)
50 printf("error setvar\n");
51 testvalue(var, val, 4, FALSE, cnt++);
53 val="";
54 printf("test %d setvar '%s'\n", cnt, val);
55 if (SetVar(var, val, strlen(val), 0) == DOSFALSE)
56 printf("error setvar\n");
57 testvalue(var, val, 0, TRUE, cnt++);
59 val="";
60 printf("test %d setvar '%s'\n", cnt, val);
61 if (SetVar(var, val, strlen(val), 0) == DOSFALSE)
62 printf("error setvar\n");
63 testvalue(var, val, 0, TRUE, cnt++);
65 return 0;