[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Add/improve tests for str{, case}cmp{start, end}



commit 314c851bc2ffacfe95d56a8d73c261b851f6a228
Author: Esteban Manchado Velázquez <emanchado@xxxxxxxxxxxx>
Date:   Sun Feb 5 17:52:26 2012 +0100

    Add/improve tests for str{,case}cmp{start,end}
---
 src/test/test_util.c |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/test/test_util.c b/src/test/test_util.c
index 13cb2b8..f5f2038 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -600,24 +600,33 @@ test_util_strmisc(void)
                U64_PRINTF_ARG(U64_LITERAL(12345678901)));
   test_streq(buf, "x!12345678901!x");
 
-  /* Test for strcmpstart and strcmpend */
+  /* Test str{,case}cmpstart */
   test_assert(strcmpstart("abcdef", "abcdef")==0);
   test_assert(strcmpstart("abcdef", "abc")==0);
   test_assert(strcmpstart("abcdef", "abd")<0);
   test_assert(strcmpstart("abcdef", "abb")>0);
   test_assert(strcmpstart("ab", "abb")<0);
-
+  test_assert(strcmpstart("ab", "")==0);
+  test_assert(strcmpstart("ab", "ab ")<0);
+  test_assert(strcasecmpstart("abcdef", "abCdEF")==0);
+  test_assert(strcasecmpstart("abcDeF", "abc")==0);
+  test_assert(strcasecmpstart("abcdef", "Abd")<0);
+  test_assert(strcasecmpstart("Abcdef", "abb")>0);
+  test_assert(strcasecmpstart("ab", "Abb")<0);
+  test_assert(strcasecmpstart("ab", "")==0);
+  test_assert(strcasecmpstart("ab", "ab ")<0);
+
+  /* Test str{,case}cmpend */
   test_assert(strcmpend("abcdef", "abcdef")==0);
   test_assert(strcmpend("abcdef", "def")==0);
   test_assert(strcmpend("abcdef", "deg")<0);
   test_assert(strcmpend("abcdef", "dee")>0);
-  test_assert(strcmpend("ab", "abb")<0);
-
+  test_assert(strcmpend("ab", "aab")>0);
   test_assert(strcasecmpend("AbcDEF", "abcdef")==0);
   test_assert(strcasecmpend("abcdef", "dEF")==0);
-  test_assert(strcasecmpend("abcDEf", "deg")<0);
-  test_assert(strcasecmpend("abcdef", "DEE")>0);
-  test_assert(strcasecmpend("ab", "abB")<0);
+  test_assert(strcasecmpend("abcdef", "Deg")<0);
+  test_assert(strcasecmpend("abcDef", "dee")>0);
+  test_assert(strcasecmpend("AB", "abb")<0);
 
   /* Test mem_is_zero */
   memset(buf,0,128);



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits