<commit_before>// SPDX-License-Identifier: LGPL-2.1-or-later
/*
 * This file is part of libgpiod.
 *
 * Copyright (C) 2017-2018 <NAME> <<EMAIL>>
 */

/* Misc tests/examples of the C++ API. */

#include <gpiod.hpp>

#include <stdexcept>
#include <cstdlib>
#include <iostream>

namespace {

using test_func = ::std::function<void (void)>;

::std::vector<::std::pair<::std::string, test_func>> test_funcs;

struct test_case
{
	test_case(const ::std::string& name, test_func& func)
	{
		test_funcs.push_back(::std::make_pair(name, func));
	}
};

#define TEST_CASE(_func)						\
	test_func _test_func_##_func(_func);				\
	test_case _test_case_##_func(#_func, _test_func_##_func)

void chip_info(void)
{
	::gpiod::chip chip("gpiochip0");

	::std::cout << "chip name: " << chip.name() << ::std::endl;<commit_msg>bindings: cxx: add a comment about the need for a dummy chip to run tests<commit_after>// SPDX-License-Identifier: LGPL-2.1-or-later
/*
 * This file is part of libgpiod.
 *
 * Copyright (C) 2017-2018 <NAME> <<EMAIL>>
 */

/*
 * Misc tests/examples of the C++ API.
 *
 * These tests assume that at least one dummy gpiochip is present in the
 * system and that it's detected as gpiochip0.
 */

#include <gpiod.hpp>

#include <stdexcept>
#include <cstdlib>
#include <iostream>

namespace {

using test_func = ::std::function<void (void)>;

::std::vector<::std::pair<::std::string, test_func>> test_funcs;

struct test_case
{
	test_case(const ::std::string& name, test_func& func)
	{
		test_funcs.push_back(::std::make_pair(name, func));
	}
};

#define TEST_CASE(_func)						\
	test_func _test_func_##_func(_func);				\
	test_case _test_case_##_func(#_func, _test_func_##_func)

void chip_info(void)
{
	::gpiod::chip chip("gpiochip0");

	::std::cout << "chip name: " << chip.name() << ::std::endl;
{'fraction_non_alphanumeric': 0.17676486937187327, 'fraction_numerical': 0.012784880489160644, 'mean_word_length': 4.825242718446602, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2966322', 'n_tokens_mistral': 734, 'n_tokens_neox': 687, 'n_words': 155}