>From bc91828e1825baffcb35ad8032c52ca632b57ffa Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 5 Nov 2024 21:09:07 +0100 Subject: [PATCH 01/23] bsearch tests: Verify N3322 functionality. * modules/bsearch: New file. * doc/posix-functions/bsearch.texi: Mention the new module. * tests/test-bsearch.c: New file. * modules/bsearch-tests: New file. --- ChangeLog | 8 ++++++ doc/posix-functions/bsearch.texi | 3 ++- modules/bsearch | 25 +++++++++++++++++++ modules/bsearch-tests | 11 +++++++++ tests/test-bsearch.c | 42 ++++++++++++++++++++++++++++++++ 5 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 modules/bsearch create mode 100644 modules/bsearch-tests create mode 100644 tests/test-bsearch.c diff --git a/ChangeLog b/ChangeLog index c3e15d31d4..55cbc80e0f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-11-05 Bruno Haible + + bsearch tests: Verify N3322 functionality. + * modules/bsearch: New file. + * doc/posix-functions/bsearch.texi: Mention the new module. + * tests/test-bsearch.c: New file. + * modules/bsearch-tests: New file. + 2024-11-05 Bruno Haible realloc-posix: Avoid use of AC_LIBOBJ. diff --git a/doc/posix-functions/bsearch.texi b/doc/posix-functions/bsearch.texi index 1ec4e9351b..96c41f6db6 100644 --- a/doc/posix-functions/bsearch.texi +++ b/doc/posix-functions/bsearch.texi @@ -4,7 +4,8 @@ POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9799919799/functions/bsearch.html} -Gnulib module: --- +Gnulib module: bsearch +@mindex bsearch Portability problems fixed by Gnulib: @itemize diff --git a/modules/bsearch b/modules/bsearch new file mode 100644 index 0000000000..596217291f --- /dev/null +++ b/modules/bsearch @@ -0,0 +1,25 @@ +Description: +Binary search in a sorted array. + +Status: +obsolete + +Notice: +This module is obsolete. + +Files: + +Depends-on: + +configure.ac: + +Makefile.am: + +Include: + + +License: +LGPLv2+ + +Maintainer: +all diff --git a/modules/bsearch-tests b/modules/bsearch-tests new file mode 100644 index 0000000000..81a1c15e4a --- /dev/null +++ b/modules/bsearch-tests @@ -0,0 +1,11 @@ +Files: +tests/test-bsearch.c +tests/macros.h + +Depends-on: + +configure.ac: + +Makefile.am: +TESTS += test-bsearch +check_PROGRAMS += test-bsearch diff --git a/tests/test-bsearch.c b/tests/test-bsearch.c new file mode 100644 index 0000000000..8d62dc3e20 --- /dev/null +++ b/tests/test-bsearch.c @@ -0,0 +1,42 @@ +/* Test of bsearch() 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 "macros.h" + +static int +cmp (const void *a, const void *b) +{ + return 0; +} + +int +main (void) +{ + int volatile value; + + /* Test zero-length operations on NULL pointers, allowed by + . */ + + value = (bsearch ("x", NULL, 0, 1, cmp) == NULL); + ASSERT (value); + + return test_exit_status; +} -- 2.34.1