[gdb] Add empty range unit test for gdb::parallel_for_each
authorTom de Vries <tdevries@suse.de>
Fri, 22 Jul 2022 15:18:51 +0000 (17:18 +0200)
committerTom de Vries <tdevries@suse.de>
Fri, 22 Jul 2022 15:18:51 +0000 (17:18 +0200)
Add a unit test that verifies that we can call gdb::parallel_for_each with an
empty range.

Tested on x86_64-linux.

gdb/unittests/parallel-for-selftests.c

index e0c07e55e0385457a35c7f38df5b53720e22f972..8a86b435fd347e7039767585676a2960bd84b9e5 100644 (file)
@@ -60,6 +60,14 @@ test (int n_threads)
 
   SELF_CHECK (counter == NUMBER);
 
+  counter = 0;
+  gdb::parallel_for_each (1, 0, 0,
+                         [&] (int start, int end)
+                         {
+                           counter += end - start;
+                         });
+  SELF_CHECK (counter == 0);
+
 #undef NUMBER
 }