>From 5e713ecd96671087298e8d0e2e9badcd7d592ced Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 5 Nov 2024 21:11:12 +0100 Subject: [PATCH 11/23] strncmp tests: Verify N3322 functionality. * modules/strncmp: New file. * doc/posix-functions/strncmp.texi: Mention the new module. * tests/test-strncmp.c: New file. * modules/strncmp-tests: New file. --- ChangeLog | 8 ++++++ doc/posix-functions/strncmp.texi | 3 ++- modules/strncmp | 25 ++++++++++++++++++ modules/strncmp-tests | 11 ++++++++ tests/test-strncmp.c | 44 ++++++++++++++++++++++++++++++++ 5 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 modules/strncmp create mode 100644 modules/strncmp-tests create mode 100644 tests/test-strncmp.c diff --git a/ChangeLog b/ChangeLog index 79c9c8ed36..699893401b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-11-05 Bruno Haible + + strncmp tests: Verify N3322 functionality. + * modules/strncmp: New file. + * doc/posix-functions/strncmp.texi: Mention the new module. + * tests/test-strncmp.c: New file. + * modules/strncmp-tests: New file. + 2024-11-05 Bruno Haible memcmp tests: Verify N3322 functionality. diff --git a/doc/posix-functions/strncmp.texi b/doc/posix-functions/strncmp.texi index df0f0afbeb..2cccd766ea 100644 --- a/doc/posix-functions/strncmp.texi +++ b/doc/posix-functions/strncmp.texi @@ -4,7 +4,8 @@ POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9799919799/functions/strncmp.html} -Gnulib module: --- +Gnulib module: strncmp +@mindex strncmp Portability problems fixed by Gnulib: @itemize diff --git a/modules/strncmp b/modules/strncmp new file mode 100644 index 0000000000..443c367ef2 --- /dev/null +++ b/modules/strncmp @@ -0,0 +1,25 @@ +Description: +Compare the initial part of two strings. + +Status: +obsolete + +Notice: +This module is obsolete. + +Files: + +Depends-on: + +configure.ac: + +Makefile.am: + +Include: + + +License: +LGPLv2+ + +Maintainer: +all diff --git a/modules/strncmp-tests b/modules/strncmp-tests new file mode 100644 index 0000000000..a3a34c01e1 --- /dev/null +++ b/modules/strncmp-tests @@ -0,0 +1,11 @@ +Files: +tests/test-strncmp.c +tests/macros.h + +Depends-on: + +configure.ac: + +Makefile.am: +TESTS += test-strncmp +check_PROGRAMS += test-strncmp diff --git a/tests/test-strncmp.c b/tests/test-strncmp.c new file mode 100644 index 0000000000..51c2be49ed --- /dev/null +++ b/tests/test-strncmp.c @@ -0,0 +1,44 @@ +/* Test of strncmp() function. + Copyright (C) 2024 Free Software Foundation, Inc. + + This program 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 3 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include + +#include "macros.h" + +int +main (void) +{ + int volatile value; + + /* Test zero-length operations on NULL pointers, allowed by + . */ + + value = (strncmp (NULL, "x", 0) == 0); + ASSERT (value); + + value = (strncmp ("x", NULL, 0) == 0); + ASSERT (value); + + value = (strncmp (NULL, NULL, 0) == 0); + ASSERT (value); + + return test_exit_status; +} -- 2.34.1