public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/2] unit: Add unit test for new MIN/MAX macros
@ 2026-04-01 20:45 Bastien Nocera
  2026-04-01 20:45 ` [PATCH BlueZ 2/2] all: Remove redundant MIN/MAX macro definitions Bastien Nocera
  2026-04-01 22:06 ` [BlueZ,1/2] unit: Add unit test for new MIN/MAX macros bluez.test.bot
  0 siblings, 2 replies; 3+ messages in thread
From: Bastien Nocera @ 2026-04-01 20:45 UTC (permalink / raw)
  To: linux-bluetooth

---
 Makefile.am      |  4 ++++
 unit/test-util.c | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)
 create mode 100644 unit/test-util.c

diff --git a/Makefile.am b/Makefile.am
index 2cfb884f1851..d9de71d587d8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -696,6 +696,10 @@ unit_test_lib_SOURCES = unit/test-lib.c
 unit_test_lib_LDADD = src/libshared-glib.la \
 				lib/libbluetooth-internal.la $(GLIB_LIBS)
 
+unit_tests += unit/test-util
+unit_test_util_LDADD = src/libshared-glib.la \
+				lib/libbluetooth-internal.la $(GLIB_LIBS)
+
 unit_tests += unit/test-gatt
 
 unit_test_gatt_SOURCES = unit/test-gatt.c
diff --git a/unit/test-util.c b/unit/test-util.c
new file mode 100644
index 000000000000..8ab16cc083ba
--- /dev/null
+++ b/unit/test-util.c
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2026  Bastien Nocera <hadess@hadess.net>
+ *
+ *
+ */
+
+#include <assert.h>
+
+#include "src/shared/util.h"
+#include "src/shared/tester.h"
+
+/* XXX glib.h must not be included, or it will clobber the
+ * MIN/MAX macros */
+
+static void test_min_max(const void *data)
+{
+	assert(MIN(3, 4) == 3);
+	assert(MAX(3, 4) == 4);
+	tester_test_passed();
+}
+
+int main(int argc, char *argv[])
+{
+	tester_init(&argc, &argv);
+
+	tester_add("/util/min_max", NULL, NULL,
+			test_min_max, NULL);
+
+	return tester_run();
+}
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-01 22:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-01 20:45 [PATCH BlueZ 1/2] unit: Add unit test for new MIN/MAX macros Bastien Nocera
2026-04-01 20:45 ` [PATCH BlueZ 2/2] all: Remove redundant MIN/MAX macro definitions Bastien Nocera
2026-04-01 22:06 ` [BlueZ,1/2] unit: Add unit test for new MIN/MAX macros bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox