diff --git a/testrun.c b/testrun.c index 5ca1d88..6a3a619 100644 --- a/testrun.c +++ b/testrun.c @@ -59,7 +59,7 @@ int main(int argc, char** argv) VERIFY(LkSetSyntax(L"[/A] [/B] [/C]", invToken, LK_MAX_TOKENARG_LEN) == LK_R_OK); VERIFY(LkSetSyntax(L"[/A] [C*", invToken, LK_MAX_TOKENARG_LEN) == LK_E_INVALIDSYNTAX); - VERIFY(!wcscmp(invToken,L"[C*")); + VERIFY(invToken && !wcscmp(invToken,L"[C*")); VERIFY(LkSetSyntax(L"[/B] [/B]", invToken, LK_MAX_TOKENARG_LEN) == LK_E_DUPLICATETOKEN); VERIFY(LkSetSyntax(L"[/A] [/B]", invToken, LK_MAX_TOKENARG_LEN) == LK_R_OK); @@ -69,18 +69,18 @@ int main(int argc, char** argv) VERIFY(LkParse2(L"/A /B", invArg, LK_MAX_TOKENARG_LEN) == LK_R_OK); VERIFY(LkParse2(L"/B /A", invArg, LK_MAX_TOKENARG_LEN) == LK_R_OK); VERIFY(LkParse2(L"/B /B", invArg, LK_MAX_TOKENARG_LEN) == LK_E_DUPLICATEARG); - VERIFY(!wcscmp(invArg, L"/B")); + VERIFY(invArg && !wcscmp(invArg, L"/B")); VERIFY(LkParse2(L"/Z", invArg, LK_MAX_TOKENARG_LEN) == LK_E_INVALIDARG); - VERIFY(!wcscmp(invArg, L"/Z")); + VERIFY(invArg && !wcscmp(invArg, L"/Z")); printf("-------- Optional arguments check -------------------------- \n"); VERIFY(LkSetSyntax(L"/A [/B]", invToken, LK_MAX_TOKENARG_LEN) == LK_R_OK); VERIFY(LkParse2(L"", invArg, LK_MAX_TOKENARG_LEN) == LK_E_MISSINGARG); - VERIFY(!wcscmp(invArg, L"/A")); + VERIFY(invArg && !wcscmp(invArg, L"/A")); VERIFY(LkParse2(L"/C", invArg, LK_MAX_TOKENARG_LEN) == LK_E_INVALIDARG); - VERIFY(!wcscmp(invArg, L"/C")); + VERIFY(invArg && !wcscmp(invArg, L"/C")); VERIFY(LkParse2(L"/A /C", invArg, LK_MAX_TOKENARG_LEN) == LK_E_INVALIDARG); - VERIFY(!wcscmp(invArg, L"/C")); + VERIFY(invArg && !wcscmp(invArg, L"/C")); VERIFY(LkParse2(L"/A", invArg, LK_MAX_TOKENARG_LEN) == LK_R_OK); VERIFY(LkParse2(L"/A /B", invArg, LK_MAX_TOKENARG_LEN) == LK_R_OK); VERIFY(LkParse2(L"/B /A", invArg, LK_MAX_TOKENARG_LEN) == LK_R_OK); @@ -89,12 +89,12 @@ int main(int argc, char** argv) VERIFY(LkSetSyntax(L"/A= /B? [/C]", invToken, LK_MAX_TOKENARG_LEN) == LK_R_OK); VERIFY(LkParse2(L"/A=2 /B=", invArg, LK_MAX_TOKENARG_LEN) == LK_E_MISSINGVALUE); - VERIFY(!wcscmp(invArg, L"/B=")); + VERIFY(invArg && !wcscmp(invArg, L"/B=")); VERIFY(LkParse2(L"/A=1 /B=xyz /C", invArg, LK_MAX_TOKENARG_LEN) == LK_R_OK); VERIFY(LkGetParamValue(L"/C", &val) == LK_E_UNDEFINED); VERIFY(LkParse2(L"/A=1 /B", invArg, LK_MAX_TOKENARG_LEN) == LK_R_OK); VERIFY(LkParse2(L"/A", invArg, LK_MAX_TOKENARG_LEN) == LK_E_MISSINGVALUE); - VERIFY(!wcscmp(invArg, L"/A")); + VERIFY(invArg && !wcscmp(invArg, L"/A")); VERIFY(LkGetParamValue(L"/C", &val) == LK_E_NOTFOUND); VERIFY(LkParse2(L"/A=1 /C", invArg, LK_MAX_TOKENARG_LEN) == LK_E_MISSINGARG); VERIFY(LkParse2(L"/A=1 /B=xyz", invArg, LK_MAX_TOKENARG_LEN) == LK_R_OK); @@ -102,9 +102,9 @@ int main(int argc, char** argv) VERIFY(LkIsParamPresent(L"/B") == LK_R_OK); VERIFY(LkIsParamPresent(L"/X") == LK_E_NOTFOUND); VERIFY(LkGetParamValue(L"/A", &val) == LK_R_OK); - VERIFY(!wcscmp (val, L"1")); + VERIFY(val && !wcscmp (val, L"1")); VERIFY(LkGetParamValue(L"/B", &val) == LK_R_OK); - VERIFY(!wcscmp (val, L"xyz")); + VERIFY(val && !wcscmp (val, L"xyz")); VERIFY(LkGetParamValue(L"/D", &val) == LK_E_NOTFOUND); printf("-------- Named arguments check ------------------------------- \n"); @@ -112,30 +112,30 @@ int main(int argc, char** argv) VERIFY(LkSetSyntax(L"$file $a $b $c", invToken, LK_MAX_TOKENARG_LEN) == LK_R_OK); VERIFY(LkParse2(L"test.txt 1 2 3", invArg, LK_MAX_TOKENARG_LEN) == LK_R_OK); VERIFY(LkGetParamValue(L"$file", &val) == LK_R_OK); - VERIFY(!wcscmp (val, L"test.txt")); + VERIFY(val && !wcscmp (val, L"test.txt")); VERIFY(LkParse2(L"test.txt 1 2", invArg, LK_MAX_TOKENARG_LEN) == LK_R_OK); VERIFY(LkParse2(L"z z z", invArg, LK_MAX_TOKENARG_LEN) == LK_R_OK); printf("--- Named arguments check (getting values) ------------------- \n"); VERIFY(LkParse2(L"test.txt 1", invArg, LK_MAX_TOKENARG_LEN) == LK_R_OK); VERIFY(LkGetParamValue(L"$file", &val) == LK_R_OK); - VERIFY(!wcscmp (val, L"test.txt")); + VERIFY(val && !wcscmp (val, L"test.txt")); VERIFY(LkGetParamValue(L"$a", &val) == LK_R_OK); - VERIFY(!wcscmp (val, L"1")); + VERIFY(val && !wcscmp (val, L"1")); VERIFY(LkGetParamValue(L"$b", &val) == LK_E_NOTFOUND); VERIFY(LkGetParamValue(L"$c", &val) == LK_E_NOTFOUND); printf("--- Named arguments check (count exceeded) ------------------- \n"); VERIFY(LkParse2(L"test.txt 1 2 3 4 5 6 7 8 9", invArg, LK_MAX_TOKENARG_LEN) == LK_E_INVALIDARG); - VERIFY(!wcscmp (invArg, L"4")); + VERIFY(invArg && !wcscmp (invArg, L"4")); printf("--- group argument test -------------------------------------- \n"); VERIFY(LkSetSyntax(L"{x}", invToken, LK_MAX_TOKENARG_LEN)== LK_E_INVALIDSYNTAX); - VERIFY(!wcscmp (invToken, L"{x}")); + VERIFY(invToken && !wcscmp (invToken, L"{x}")); VERIFY(LkSetSyntax(L"{/x}", invToken, LK_MAX_TOKENARG_LEN)== LK_E_INVALIDSYNTAX); - VERIFY(!wcscmp (invToken, L"{/x}")); + VERIFY(invToken && !wcscmp (invToken, L"{/x}")); VERIFY(LkSetSyntax(L"{/x|}", invToken, LK_MAX_TOKENARG_LEN)== LK_E_INVALIDSYNTAX); - VERIFY(!wcscmp (invToken, L"{/x|}")); + VERIFY(invToken && !wcscmp (invToken, L"{/x|}")); VERIFY(LkSetSyntax(L"{/on|/off} {/on|/x}", invToken, LK_MAX_TOKENARG_LEN) == LK_E_DUPLICATEGROUPITEM); VERIFY(LkSetSyntax(L"{/on|/off|/auto}", invToken, LK_MAX_TOKENARG_LEN) == LK_R_OK); VERIFY(LkParse2(L"/on", invArg, LK_MAX_TOKENARG_LEN) == LK_R_OK); @@ -156,7 +156,7 @@ int main(int argc, char** argv) VERIFY(LkParse2(L"/on /a", invArg, LK_MAX_TOKENARG_LEN) == LK_E_MISSINGVALUE); VERIFY(LkParse2(L"/on /a=1000", invArg, LK_MAX_TOKENARG_LEN) == LK_R_OK); VERIFY(LkGetParamValue(L"/a", &val) == LK_R_OK); - VERIFY(!wcscmp(val, L"1000")); + VERIFY(val && !wcscmp(val, L"1000")); VERIFY(LkSetSyntax(L"[{/help|/?}] [/fat=] /size= /boot= /media= [/lic] $file", invToken, LK_MAX_TOKENARG_LEN) == LK_R_OK); VERIFY(LkParse2(L"xxx", invArg, LK_MAX_TOKENARG_LEN) == LK_E_MISSINGARG); @@ -173,7 +173,7 @@ int main(int argc, char** argv) static void Interactive(void) { TESTINIT(); - VERIFY(LK_SUCCESS(LkInit(16))); + VERIFY(LK_SUCCESS(LkInit())); wchar_t syntax[1024]; wchar_t cmdline[1024]; wchar_t invToken[LK_MAX_TOKENARG_LEN]; @@ -205,4 +205,4 @@ static void Interactive(void) } VERIFY(LK_SUCCESS(LkFree())); -} \ No newline at end of file +}