2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
10 static LONG
testvalue(CONST_STRPTR var
, STRPTR expval
, ULONG explen
,
11 BOOL expnull
, LONG cnt
)
17 if ((len
= GetVar(var
, buffer
, sizeof(buffer
), 0)) < 0)
19 printf("test %d ERROR getvar %d\n", (int)cnt
, (int)len
);
23 printf("test %d getvar '%s'\n", (int)cnt
, buffer
);
25 if ((lv
= FindVar(var
, 0)) == NULL
)
27 printf("test %d ERROR findvar\n", (int)cnt
);
31 printf("test %d findvar lv_Value=%p, lv_Len=%d\n", (int)cnt
,
32 lv
->lv_Value
, (int)lv
->lv_Len
);
34 if (lv
->lv_Len
!= explen
)
36 printf("test %d ERROR lv_Len, expected %d, found %d\n", (int)cnt
,
37 (int)explen
, (int)lv
->lv_Len
);
41 if (expnull
&& lv
->lv_Value
!= NULL
)
43 printf("test %d ERROR lv_Value expected NULL, found %p\n", (int)cnt
,
48 if (!expnull
&& lv
->lv_Value
== NULL
)
50 printf("test %d ERROR lv_Value expected not NULL, found %p\n",
51 (int)cnt
, lv
->lv_Value
);
60 CONST_STRPTR var
= "abc";
62 LONG cnt
= 1, failed
= 0;
64 /* Behavior validated with OS3.x */
66 printf("test %d setvar '%s'\n", (int)cnt
, val
);
67 if (SetVar(var
, val
, strlen(val
), 0) == DOSFALSE
)
69 printf("error setvar\n");
72 failed
+= testvalue(var
, val
, 3, FALSE
, cnt
++);
75 printf("test %d setvar '%s'\n", (int)cnt
, val
);
76 if (SetVar(var
, val
, strlen(val
), 0) == DOSFALSE
)
78 printf("error setvar\n");
81 failed
+= testvalue(var
, val
, 0, TRUE
, cnt
++);
84 printf("test %d setvar '%s'\n", (int)cnt
, val
);
85 if (SetVar(var
, val
, strlen(val
), 0) == DOSFALSE
)
87 printf("error setvar\n");
90 failed
+= testvalue(var
, val
, 4, FALSE
, cnt
++);
93 printf("test %d setvar '%s'\n", (int)cnt
, val
);
94 if (SetVar(var
, val
, strlen(val
), 0) == DOSFALSE
)
96 printf("error setvar\n");
99 failed
+= testvalue(var
, val
, 0, TRUE
, cnt
++);
102 printf("test %d setvar '%s'\n", (int)cnt
, val
);
103 if (SetVar(var
, val
, strlen(val
), 0) == DOSFALSE
)
105 printf("error setvar\n");
108 failed
+= testvalue(var
, val
, 0, TRUE
, cnt
++);
110 return failed
== 0 ? RETURN_OK
: RETURN_ERROR
;