gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [libmicrohttpd] branch master updated: Added file missing i


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] branch master updated: Added file missing in e93439da71e027cafe5b2788a997cbfc85d193c8
Date: Mon, 15 May 2017 19:39:29 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

The following commit(s) were added to refs/heads/master by this push:
     new 9e191bf6 Added file missing in e93439da71e027cafe5b2788a997cbfc85d193c8
9e191bf6 is described below

commit 9e191bf65f498e56330c1d7f1213ef6c7b23e07d
Author: Evgeny Grin (Karlson2k) <address@hidden>
AuthorDate: Mon May 15 20:35:15 2017 +0300

    Added file missing in e93439da71e027cafe5b2788a997cbfc85d193c8
---
 src/microhttpd/test_str_token.c | 117 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 117 insertions(+)

diff --git a/src/microhttpd/test_str_token.c b/src/microhttpd/test_str_token.c
new file mode 100644
index 00000000..464cc7a5
--- /dev/null
+++ b/src/microhttpd/test_str_token.c
@@ -0,0 +1,117 @@
+/*
+  This file is part of libmicrohttpd
+  Copyright (C) 2017 Karlson2k (Evgeny Grin)
+
+  This test tool is free software; you can redistribute it and/or
+  modify it under the terms of the GNU General Public License as
+  published by the Free Software Foundation; either version 2, or
+  (at your option) any later version.
+
+  This test tool is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
+*/
+
+/**
+ * @file microhttpd/test_str_token.c
+ * @brief  Unit tests for some mhd_str functions
+ * @author Karlson2k (Evgeny Grin)
+ */
+
+#include "mhd_options.h"
+#include <stdio.h>
+#include "mhd_str.h"
+
+
+static int
+expect_found_n(const char *str, const char *token, size_t token_len)
+{
+  if (!MHD_str_has_token_caseless_(str, token, token_len))
+    {
+      fprintf(stderr, "MHD_str_has_token_caseless_() 
FAILED:\n\tMHD_str_has_token_caseless_(%s, %s, %lu) return false\n",
+              str, token, (unsigned long) token_len);
+      return 1;
+    }
+  return 0;
+}
+
+#define expect_found(s,t) expect_found_n((s),(t),MHD_STATICSTR_LEN_(t))
+
+static int
+expect_not_found_n(const char *str, const char *token, size_t token_len)
+{
+  if (MHD_str_has_token_caseless_(str, token, token_len))
+    {
+      fprintf(stderr, "MHD_str_has_token_caseless_() 
FAILED:\n\tMHD_str_has_token_caseless_(%s, %s, %lu) return true\n",
+              str, token, (unsigned long) token_len);
+      return 1;
+    }
+  return 0;
+}
+
+#define expect_not_found(s,t) expect_not_found_n((s),(t),MHD_STATICSTR_LEN_(t))
+
+int check_match(void)
+{
+  int errcount = 0;
+  errcount += expect_found("string", "string");
+  errcount += expect_found("String", "string");
+  errcount += expect_found("string", "String");
+  errcount += expect_found("strinG", "String");
+  errcount += expect_found("\t strinG", "String");
+  errcount += expect_found("strinG\t ", "String");
+  errcount += expect_found(" \t tOkEn  ", "toKEN");
+  errcount += expect_found("not token\t,  tOkEn  ", "toKEN");
+  errcount += expect_found("not token,\t  tOkEn, more token", "toKEN");
+  errcount += expect_found("not token,\t  tOkEn\t, more token", "toKEN");
+  errcount += expect_found(",,,,,,test,,,,", "TESt");
+  errcount += expect_found(",,,,,\t,test,,,,", "TESt");
+  errcount += expect_found(",,,,,,test, ,,,", "TESt");
+  errcount += expect_found(",,,,,, test,,,,", "TESt");
+  errcount += expect_found(",,,,,, test not,test,,", "TESt");
+  errcount += expect_found(",,,,,, test not,,test,,", "TESt");
+  errcount += expect_found(",,,,,, test not ,test,,", "TESt");
+  errcount += expect_found(",,,,,, test", "TESt");
+  errcount += expect_found(",,,,,, test      ", "TESt");
+  errcount += expect_found("no test,,,,,, test      ", "TESt");
+  return errcount;
+}
+
+int check_not_match(void)
+{
+  int errcount = 0;
+  errcount += expect_not_found("strin", "string");
+  errcount += expect_not_found("Stringer", "string");
+  errcount += expect_not_found("sstring", "String");
+  errcount += expect_not_found("string", "Strin");
+  errcount += expect_not_found("\t( strinG", "String");
+  errcount += expect_not_found(")strinG\t ", "String");
+  errcount += expect_not_found(" \t tOkEn t ", "toKEN");
+  errcount += expect_not_found("not token\t,  tOkEner  ", "toKEN");
+  errcount += expect_not_found("not token,\t  tOkEns, more token", "toKEN");
+  errcount += expect_not_found("not token,\t  tOkEns\t, more token", "toKEN");
+  errcount += expect_not_found(",,,,,,testing,,,,", "TESt");
+  errcount += expect_not_found(",,,,,\t,test,,,,", "TESting");
+  errcount += expect_not_found("tests,,,,,,quest, ,,,", "TESt");
+  errcount += expect_not_found(",,,,,, testы,,,,", "TESt");
+  errcount += expect_not_found(",,,,,, test not,хtest,,", "TESt");
+  errcount += expect_not_found("testing,,,,,, test not,,test2,,", "TESt");
+  errcount += expect_not_found(",testi,,,,, test not ,test,,", "TESting");
+  errcount += expect_not_found(",,,,,,2 test", "TESt");
+  errcount += expect_not_found(",,,,,,test test      ", "test");
+  errcount += expect_not_found("no test,,,,,, test      test", "test");
+  return errcount;
+}
+
+int main(int argc, char * argv[])
+{
+  int errcount = 0;
+  errcount += check_match();
+  errcount += check_not_match();
+  return errcount == 0 ? 0 : 1;
+}

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]