From ad1f8f992581f422f1daf8799aa3736dfe70da88 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 15 Nov 2006 20:14:46 +0000 Subject: [PATCH] Added round-trip testing of char escapes. --- src/libCom/test/epicsStringTest.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/libCom/test/epicsStringTest.c b/src/libCom/test/epicsStringTest.c index e75ab33de..4e5cc94c6 100644 --- a/src/libCom/test/epicsStringTest.c +++ b/src/libCom/test/epicsStringTest.c @@ -17,10 +17,27 @@ #include "epicsString.h" #include "testMain.h" +void testChars() { + int i; + char input[2] = {0, 0}; + char escaped[20]; + char result[20]; + for (i = 255; i >= 0; --i) { + input[0] = i; + epicsStrSnPrintEscaped(escaped, sizeof(escaped), input, 1); + dbTranslateEscape(result, escaped); + testOk(result[0] == input[0] && result[1] == 0, + "char 0x%02.2x -> \"%s\" -> 0x%02.2x", + input[0] & 0xff, escaped, result[0] & 0xff); + } +} + MAIN(epicsStringTest) { - testPlan(21); - + testPlan(0); + + testChars(); + testOk1(epicsStrnCaseCmp("","",0)==0); testOk1(epicsStrnCaseCmp("","",1)==0); testOk1(epicsStrnCaseCmp(" ","",1)<0);