libCom: Fix epicsString.h comparison functions
The string comparison functions epicsStrCaseCmp() and epicsStrnCaseCmp() were returning incorrect results when the strings did not match. These functions now match their BSD equivalents, and have working tests to confirm their operation.
This commit is contained in:
@@ -56,8 +56,8 @@ MAIN(epicsStringTest)
|
||||
|
||||
testOk1(epicsStrnCaseCmp(empty, "", 0) == 0);
|
||||
testOk1(epicsStrnCaseCmp(empty, "", 1) == 0);
|
||||
testOk1(epicsStrnCaseCmp(space, empty, 1) < 0);
|
||||
testOk1(epicsStrnCaseCmp(empty, space, 1) > 0);
|
||||
testOk1(epicsStrnCaseCmp(space, empty, 1) > 0);
|
||||
testOk1(epicsStrnCaseCmp(empty, space, 1) < 0);
|
||||
testOk1(epicsStrnCaseCmp(a, A, 1) == 0);
|
||||
testOk1(epicsStrnCaseCmp(a, A, 2) == 0);
|
||||
testOk1(epicsStrnCaseCmp(abcd, ABCD, 2) == 0);
|
||||
@@ -65,17 +65,17 @@ MAIN(epicsStringTest)
|
||||
testOk1(epicsStrnCaseCmp(abcd, ABCD, 1000) == 0);
|
||||
testOk1(epicsStrnCaseCmp(abcd, ABCDE, 2) == 0);
|
||||
testOk1(epicsStrnCaseCmp(abcd, ABCDE, 4) == 0);
|
||||
testOk1(epicsStrnCaseCmp(abcd, ABCDE, 1000)> 0);
|
||||
testOk1(epicsStrnCaseCmp(abcd, ABCDE, 1000) < 0);
|
||||
testOk1(epicsStrnCaseCmp(abcde, ABCD, 2) == 0);
|
||||
testOk1(epicsStrnCaseCmp(abcde, ABCD, 4) == 0);
|
||||
testOk1(epicsStrnCaseCmp(abcde, ABCD, 1000) < 0);
|
||||
testOk1(epicsStrnCaseCmp(abcde, ABCD, 1000) > 0);
|
||||
|
||||
testOk1(epicsStrCaseCmp(empty, "") == 0);
|
||||
testOk1(epicsStrCaseCmp(a, A) == 0);
|
||||
testOk1(epicsStrCaseCmp(abcd, ABCD) == 0);
|
||||
testOk1(epicsStrCaseCmp(abcd, ABCDE) != 0);
|
||||
testOk1(epicsStrCaseCmp(abcde, ABCD) != 0);
|
||||
testOk1(epicsStrCaseCmp(abcde, "ABCDF") != 0);
|
||||
testOk1(epicsStrCaseCmp(abcd, ABCDE) < 0);
|
||||
testOk1(epicsStrCaseCmp(abcde, ABCD) > 0);
|
||||
testOk1(epicsStrCaseCmp(abcde, "ABCDF") < 0);
|
||||
|
||||
s = epicsStrDup(abcd);
|
||||
testOk(strcmp(s, abcd) == 0 && s != abcd, "epicsStrDup");
|
||||
|
||||
Reference in New Issue
Block a user