diff options
author | Colin Walters <walters@verbum.org> | 2017-06-13 16:22:09 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2017-06-14 12:48:20 -0400 |
commit | 9a1b77ef96b4eb9a916a71e7a04055c4c5665dea (patch) | |
tree | c89856b6f755aae9b17167ed184d9d0ddc7b41df /tests | |
parent | 05abf2143f967cd85b1b1b777ee412a581979cf1 (diff) | |
download | libglnx-9a1b77ef96b4eb9a916a71e7a04055c4c5665dea.tar.gz |
Add G_IN_SET, patch our internal users via spatch
I originally tried to get this into GLib:
https://bugzilla.gnome.org/show_bug.cgi?id=783751
But that looks like it's going to fail due to MSVC. Let's add it here at least
so I can start using it tomorrow and not wait for the MSVC team to catch up.
I renamed `glnx-alloca.h` to `glnx-macros.h` as a more natural collective
home for things from systemd's `macro.h`.
Finally, I used a Coccinelle spatch similar to the one referenced
in the above BZ to patch our uses.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-libglnx-macros.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/test-libglnx-macros.c b/tests/test-libglnx-macros.c new file mode 100644 index 0000000..d16c100 --- /dev/null +++ b/tests/test-libglnx-macros.c @@ -0,0 +1,48 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * + * Copyright (C) 2017 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "config.h" +#include "libglnx.h" +#include <glib.h> +#include <stdlib.h> +#include <gio/gio.h> +#include <string.h> + +static void +test_inset (void) +{ + g_assert (G_IN_SET (7, 7)); + g_assert (G_IN_SET (7, 42, 7)); + g_assert (G_IN_SET (7, 7,42,3,9)); + g_assert (G_IN_SET (42, 7,42,3,9)); + g_assert (G_IN_SET (3, 7,42,3,9)); + g_assert (G_IN_SET (9, 7,42,3,9)); + g_assert (!G_IN_SET (8, 7,42,3,9)); + g_assert (!G_IN_SET (-1, 7,42,3,9)); + g_assert (G_IN_SET ('x', 'a', 'x', 'c')); + g_assert (!G_IN_SET ('y', 'a', 'x', 'c')) +} + +int main (int argc, char **argv) +{ + g_test_init (&argc, &argv, NULL); + g_test_add_func ("/inset", test_inset); + return g_test_run(); +} |