aboutsummaryrefslogtreecommitdiffstats
path: root/tests/enum-validator-test.c
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-09-17 10:53:56 +0200
committerSimon Ser <contact@emersion.fr>2024-04-23 09:17:02 +0000
commitb258d5f36137088e5cb5ae097db7964290da7d55 (patch)
tree2f59d6061156e64e8c5797942fe4818ab69529be /tests/enum-validator-test.c
parentClarify behavior of buffer transformations (diff)
downloadwayland-b258d5f36137088e5cb5ae097db7964290da7d55.tar
wayland-b258d5f36137088e5cb5ae097db7964290da7d55.tar.gz
wayland-b258d5f36137088e5cb5ae097db7964290da7d55.tar.bz2
wayland-b258d5f36137088e5cb5ae097db7964290da7d55.tar.lz
wayland-b258d5f36137088e5cb5ae097db7964290da7d55.tar.xz
wayland-b258d5f36137088e5cb5ae097db7964290da7d55.tar.zst
wayland-b258d5f36137088e5cb5ae097db7964290da7d55.zip
scanner: add validators for enums
Right now compositors need to manually check that enum values sent by the client are valid. In particular: - Check that the value sent by the client is not outside of the enum. - Check that the version of the enum entry is consistent with the object version. Automatically generate validator functions to perform these tasks. Signed-off-by: Simon Ser <contact@emersion.fr> Closes: https://gitlab.freedesktop.org/wayland/wayland/-/issues/104
Diffstat (limited to 'tests/enum-validator-test.c')
-rw-r--r--tests/enum-validator-test.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/enum-validator-test.c b/tests/enum-validator-test.c
new file mode 100644
index 0000000..92037cf
--- /dev/null
+++ b/tests/enum-validator-test.c
@@ -0,0 +1,13 @@
+#include <assert.h>
+#include "data/small-server-core.h"
+
+int
+main(int argc, char *argv[]) {
+ assert(intf_A_foo_is_valid(INTF_A_FOO_FIRST, 1));
+ assert(intf_A_foo_is_valid(INTF_A_FOO_FIRST, 2));
+
+ assert(!intf_A_foo_is_valid(INTF_A_FOO_THIRD, 1));
+ assert(intf_A_foo_is_valid(INTF_A_FOO_THIRD, 2));
+
+ assert(intf_A_foo_is_valid(INTF_A_FOO_NEGATIVE, 2));
+}