From 480ac6e54daa1df1bf17a95931eab412e26bd608 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 31 Oct 2022 13:04:19 +0100 Subject: [PATCH] lib1301: unit103 turned into a libtest It is not a unit test so moved over to libtests. --- tests/data/test1301 | 7 ++--- tests/libtest/Makefile.inc | 5 +++ tests/libtest/lib1301.c | 62 ++++++++++++++++++++++++++++++++++++++ tests/unit/Makefile.inc | 5 +-- tests/unit/unit1301.c | 56 ---------------------------------- 5 files changed, 70 insertions(+), 65 deletions(-) create mode 100644 tests/libtest/lib1301.c delete mode 100644 tests/unit/unit1301.c diff --git a/tests/data/test1301 b/tests/data/test1301 index 5aea24b654..1756061772 100644 --- a/tests/data/test1301 +++ b/tests/data/test1301 @@ -2,7 +2,7 @@ unittest -curl_strcasecompare +curl_strequal @@ -12,11 +12,8 @@ curl_strcasecompare none - -unittest - -curl_strcasecompare unit tests +curl_strequal tests diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 484ac178c7..861d79dba6 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -52,6 +52,7 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \ lib659 lib661 lib666 lib667 lib668 \ lib670 lib671 lib672 lib673 lib674 lib676 lib677 lib678 \ lib1156 \ + lib1301 \ lib1500 lib1501 lib1502 lib1503 lib1504 lib1505 lib1506 lib1507 lib1508 \ lib1509 lib1510 lib1511 lib1512 lib1513 lib1514 lib1515 lib1517 \ lib1518 lib1520 lib1521 lib1522 lib1523 \ @@ -427,6 +428,10 @@ lib678_SOURCES = lib678.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(MULTIBYTE) lib678_LDADD = $(TESTUTIL_LIBS) lib678_CPPFLAGS = $(AM_CPPFLAGS) +lib1301_SOURCES = lib1301.c $(SUPPORTFILES) $(TESTUTIL) +lib1301_LDADD = $(TESTUTIL_LIBS) +lib1301_CPPFLAGS = $(AM_CPPFLAGS) + lib1500_SOURCES = lib1500.c $(SUPPORTFILES) $(TESTUTIL) lib1500_LDADD = $(TESTUTIL_LIBS) lib1500_CPPFLAGS = $(AM_CPPFLAGS) diff --git a/tests/libtest/lib1301.c b/tests/libtest/lib1301.c new file mode 100644 index 0000000000..d98134c390 --- /dev/null +++ b/tests/libtest/lib1301.c @@ -0,0 +1,62 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2022, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ +#include "test.h" + +#define fail_unless(expr, msg) \ + do { \ + if(!(expr)) { \ + fprintf(stderr, "%s:%d Assertion '%s' failed: %s\n", \ + __FILE__, __LINE__, #expr, msg); \ + return 1; \ + } \ + } while(0) + +int test(char *URL) +{ + int rc; + (void)URL; + + rc = curl_strequal("iii", "III"); + fail_unless(rc != 0, "return code should be non-zero"); + + rc = curl_strequal("iiia", "III"); + fail_unless(rc == 0, "return code should be zero"); + + rc = curl_strequal("iii", "IIIa"); + fail_unless(rc == 0, "return code should be zero"); + + rc = curl_strequal("iiiA", "IIIa"); + fail_unless(rc != 0, "return code should be non-zero"); + + rc = curl_strnequal("iii", "III", 3); + fail_unless(rc != 0, "return code should be non-zero"); + + rc = curl_strnequal("iiiABC", "IIIcba", 3); + fail_unless(rc != 0, "return code should be non-zero"); + + rc = curl_strnequal("ii", "II", 3); + fail_unless(rc != 0, "return code should be non-zero"); + + return 0; +} diff --git a/tests/unit/Makefile.inc b/tests/unit/Makefile.inc index 831a82033c..c38bc954d4 100644 --- a/tests/unit/Makefile.inc +++ b/tests/unit/Makefile.inc @@ -29,7 +29,7 @@ UNITFILES = curlcheck.h \ ../libtest/first.c # These are all unit test programs -UNITPROGS = unit1300 unit1301 unit1302 unit1303 unit1304 unit1305 unit1307 \ +UNITPROGS = unit1300 unit1302 unit1303 unit1304 unit1305 unit1307 \ unit1308 unit1309 unit1323 \ unit1330 unit1394 unit1395 unit1396 unit1397 unit1398 \ unit1399 \ @@ -42,9 +42,6 @@ UNITPROGS = unit1300 unit1301 unit1302 unit1303 unit1304 unit1305 unit1307 \ unit1300_SOURCES = unit1300.c $(UNITFILES) unit1300_CPPFLAGS = $(AM_CPPFLAGS) -unit1301_SOURCES = unit1301.c $(UNITFILES) -unit1301_CPPFLAGS = $(AM_CPPFLAGS) - unit1302_SOURCES = unit1302.c $(UNITFILES) unit1302_CPPFLAGS = $(AM_CPPFLAGS) diff --git a/tests/unit/unit1301.c b/tests/unit/unit1301.c deleted file mode 100644 index 17b2700ba8..0000000000 --- a/tests/unit/unit1301.c +++ /dev/null @@ -1,56 +0,0 @@ -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2022, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at https://curl.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - * SPDX-License-Identifier: curl - * - ***************************************************************************/ -#include "curlcheck.h" - -#include "strcase.h" - -static CURLcode unit_setup(void) {return CURLE_OK;} -static void unit_stop(void) {} - -UNITTEST_START - -int rc; - -rc = curl_strequal("iii", "III"); -fail_unless(rc != 0, "return code should be non-zero"); - -rc = curl_strequal("iiia", "III"); -fail_unless(rc == 0, "return code should be zero"); - -rc = curl_strequal("iii", "IIIa"); -fail_unless(rc == 0, "return code should be zero"); - -rc = curl_strequal("iiiA", "IIIa"); -fail_unless(rc != 0, "return code should be non-zero"); - -rc = curl_strnequal("iii", "III", 3); -fail_unless(rc != 0, "return code should be non-zero"); - -rc = curl_strnequal("iiiABC", "IIIcba", 3); -fail_unless(rc != 0, "return code should be non-zero"); - -rc = curl_strnequal("ii", "II", 3); -fail_unless(rc != 0, "return code should be non-zero"); - -UNITTEST_STOP -- 2.47.3