Debian Codegraph @

bindings/glib/tests/tests-request-config.c

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 // SPDX-FileCopyrightText: 2023-2024 Bartosz Golaszewski <[email protected]>
3
4 #include <glib.h>
5 #include <gpiod-glib.h>
6 #include <gpiod-test.h>
7
8 #include "helpers.h"
9
10 #define GPIOD_TEST_GROUP "glib/request-config"
11
12 GPIOD_TEST_CASE(default_config)
13 {
14 g_autoptr(GpiodglibRequestConfig) config = NULL;
15 g_autofree gchar *consumer = NULL;
16
17 config = gpiodglib_request_config_new(NULL);
18 consumer = gpiodglib_request_config_dup_consumer(config);
19
20 g_assert_null(consumer);
21 g_assert_cmpuint(gpiodglib_request_config_get_event_buffer_size(config),
22 ==, 0);
23 }
24
25 GPIOD_TEST_CASE(set_consumer)
26 {
27 g_autoptr(GpiodglibRequestConfig) config = NULL;
28 g_autofree gchar *consumer = NULL;
29
30 config = gpiodglib_request_config_new(NULL);
31
32 gpiodglib_request_config_set_consumer(config, "foobar");
33 consumer = gpiodglib_request_config_dup_consumer(config);
34 g_assert_cmpstr(consumer, ==, "foobar");
35
36 gpiodglib_request_config_set_consumer(config, NULL);
37 g_free(consumer);
38 consumer = gpiodglib_request_config_dup_consumer(config);
39 g_assert_null(consumer);
40 }
41
42 GPIOD_TEST_CASE(set_event_buffer_size)
43 {
44 g_autoptr(GpiodglibRequestConfig) config = NULL;
45
46 config = gpiodglib_request_config_new(NULL);
47
48 gpiodglib_request_config_set_event_buffer_size(config, 128);
49 g_assert_cmpuint(gpiodglib_request_config_get_event_buffer_size(config),
50 ==, 128);
51 }
52
53 GPIOD_TEST_CASE(set_properties_in_constructor)
54 {
55 g_autoptr(GpiodglibRequestConfig) config = NULL;
56 g_autofree gchar *consumer = NULL;
57
58 config = gpiodglib_request_config_new("consumer", "foobar",
59 "event-buffer-size", 64, NULL);
60 consumer = gpiodglib_request_config_dup_consumer(config);
61 g_assert_cmpstr(consumer, ==, "foobar");
62 g_assert_cmpuint(gpiodglib_request_config_get_event_buffer_size(config),
63 ==, 64);
64 }