From: Bruno Haible <bruno@clisp.org>
Date: Tue, 5 Nov 2024 20:10:02 +0000 (+0100)
Subject: qsort tests: Verify N3322 functionality.
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=d3c9d629b8eadfda54c16879b36b7edfd2f03805;p=gnulib.git

qsort tests: Verify N3322 functionality.

* modules/qsort: New file.
* doc/posix-functions/qsort.texi: Mention the new module.
* tests/test-qsort.c: New file.
* modules/qsort-tests: New file.
---

diff --git a/ChangeLog b/ChangeLog
index 55cbc80e0f..59575ece66 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-11-05  Bruno Haible  <bruno@clisp.org>
+
+	qsort tests: Verify N3322 functionality.
+	* modules/qsort: New file.
+	* doc/posix-functions/qsort.texi: Mention the new module.
+	* tests/test-qsort.c: New file.
+	* modules/qsort-tests: New file.
+
 2024-11-05  Bruno Haible  <bruno@clisp.org>
 
 	bsearch tests: Verify N3322 functionality.
diff --git a/doc/posix-functions/qsort.texi b/doc/posix-functions/qsort.texi
index 5d6523e528..87491b7eeb 100644
--- a/doc/posix-functions/qsort.texi
+++ b/doc/posix-functions/qsort.texi
@@ -4,7 +4,8 @@
 
 POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9799919799/functions/qsort.html}
 
-Gnulib module: ---
+Gnulib module: qsort
+@mindex qsort
 
 Portability problems fixed by Gnulib:
 @itemize
diff --git a/modules/qsort b/modules/qsort
new file mode 100644
index 0000000000..8fef487959
--- /dev/null
+++ b/modules/qsort
@@ -0,0 +1,25 @@
+Description:
+Sorting an array.
+
+Status:
+obsolete
+
+Notice:
+This module is obsolete.
+
+Files:
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+
+Include:
+<stdlib.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
diff --git a/modules/qsort-tests b/modules/qsort-tests
new file mode 100644
index 0000000000..6d31f6b09e
--- /dev/null
+++ b/modules/qsort-tests
@@ -0,0 +1,10 @@
+Files:
+tests/test-qsort.c
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-qsort
+check_PROGRAMS += test-qsort
diff --git a/tests/test-qsort.c b/tests/test-qsort.c
new file mode 100644
index 0000000000..9ab39b13e4
--- /dev/null
+++ b/tests/test-qsort.c
@@ -0,0 +1,37 @@
+/* Test of qsort() 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 <https://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <stdlib.h>
+
+static int
+cmp (const void *a, const void *b)
+{
+  return 0;
+}
+
+int
+main (void)
+{
+  /* Test zero-length operations on NULL pointers, allowed by
+     <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3322.pdf>.  */
+
+  qsort (NULL, 0, 1, cmp);
+
+  return 0;
+}