File: tests-request-config.c

package info (click to toggle)
libgpiod 2.2.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,108 kB
  • sloc: ansic: 26,612; sh: 7,554; cpp: 4,944; python: 2,426; makefile: 811; xml: 49
file content (47 lines) | stat: -rw-r--r-- 1,257 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// SPDX-License-Identifier: GPL-2.0-or-later
// SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>

#include <glib.h>
#include <gpiod.h>
#include <gpiod-test.h>
#include <gpiod-test-common.h>

#include "helpers.h"

#define GPIOD_TEST_GROUP "request-config"

GPIOD_TEST_CASE(default_config)
{
	g_autoptr(struct_gpiod_request_config) config = NULL;

	config = gpiod_test_create_request_config_or_fail();

	g_assert_null(gpiod_request_config_get_consumer(config));
	g_assert_cmpuint(gpiod_request_config_get_event_buffer_size(config), ==,
			 0);
}

GPIOD_TEST_CASE(set_consumer)
{
	g_autoptr(struct_gpiod_request_config) config = NULL;

	config = gpiod_test_create_request_config_or_fail();

	gpiod_request_config_set_consumer(config, "foobar");
	g_assert_cmpstr(gpiod_request_config_get_consumer(config), ==,
			"foobar");

	gpiod_request_config_set_consumer(config, NULL);
	g_assert_null(gpiod_request_config_get_consumer(config));
}

GPIOD_TEST_CASE(set_event_buffer_size)
{
	g_autoptr(struct_gpiod_request_config) config = NULL;

	config = gpiod_test_create_request_config_or_fail();

	gpiod_request_config_set_event_buffer_size(config, 128);
	g_assert_cmpuint(gpiod_request_config_get_event_buffer_size(config), ==,
			 128);
}