<commit_before>#include <kdbprivate.h>
/**
 * @file
 *
 * @brief Tests for mmapstorage plugin
 *
 * @copyright BSD License (see doc/LICENSE.md or https://www.libelektra.org)
 *
 */

#include <stdlib.h>
#include <string.h>

#include <kdbconfig.h>
#include <kdbprivate.h>

#include <tests_plugin.h>

#include "mmapstorage.h"


static KeySet * simpleTestKeySet ()
{
	return ksNew (10, keyNew ("user/tests/mmapstorage/simpleKey", KEY_VALUE, "root key", KEY_END),
		      keyNew ("user/tests/mmapstorage/simpleKey/a", KEY_VALUE, "a value", KEY_END),
		      keyNew ("user/tests/mmapstorage/simpleKey/b", KEY_VALUE, "b value", KEY_END), KS_END);
}

static KeySet * metaTestKeySet ()
{
	return ksNew (10, keyNew ("user/tests/mmapstorage", KEY_VALUE, "root key", KEY_META, "a",
			      "b aksdjfh aksjdhf aklsjdhf aksljdhf aklsjdhf aksljdhf ", KEY_END),
		      keyNew ("user/tests/mmapstorage/a", KEY_VALUE, "a value", KEY_META, "ab",
			      "cd oiahsdkfhga sdjkfhgsuzdgf kashgdf aszgdf uashdf ", KEY_END),
		      keyNew ("user/tests/mmapstorage/b", KEY_VALUE, "b value", KEY_META, "longer val",
			      "here some even more with ugly €@\\1¹²³¼ chars", KEY_END),
		      KS_END);
}

static void m_output_meta (Key * k)
{
	const Key * meta;

	keyRewindMeta (k);
	while ((meta = keyNextMeta (k)) != 0)
	{
		ELEKTRA_LOG_WARNING ("Meta KeySet size: %zu", k->meta->size);
		if (!meta) ELEKTRA_LOG_WARNING ("Meta Key is NULL");
		ELEKTRA_LOG_WARNING (", %s: %s", keyName (meta), (const char *)keyValue (meta));
	}
	ELEKTRA_LOG_WARNING ("\n");
}

static void m_output_key (Key * k)
{
	// output_meta will print endline<commit_msg>mmapstorage: cleanup and reformat source<commit_after>#include <kdbprivate.h>
/**
 * @file
 *
 * @brief Tests for mmapstorage plugin
 *
 * @copyright BSD License (see doc/LICENSE.md or https://www.libelektra.org)
 *
 */

#include <stdlib.h>
#include <string.h>

#include <kdbconfig.h>
#include <kdbprivate.h>

#include <tests_plugin.h>

#include "mmapstorage.h"


static KeySet * simpleTestKeySet ()
{
	return ksNew (10, keyNew ("user/tests/mmapstorage/simpleKey", KEY_VALUE, "root key", KEY_END),
		      keyNew ("user/tests/mmapstorage/simpleKey/a", KEY_VALUE, "a value", KEY_END),
		      keyNew ("user/tests/mmapstorage/simpleKey/b", KEY_VALUE, "b value", KEY_END), KS_END);
}

static KeySet * metaTestKeySet ()
{
	return ksNew (10, keyNew ("user/tests/mmapstorage", KEY_VALUE, "root key", KEY_META, "a",
				  "b aksdjfh aksjdhf aklsjdhf aksljdhf aklsjdhf aksljdhf ", KEY_END),
		      keyNew ("user/tests/mmapstorage/a", KEY_VALUE, "a value", KEY_META, "ab",
			      "cd oiahsdkfhga sdjkfhgsuzdgf kashgdf aszgdf uashdf ", KEY_END),
		      keyNew ("user/tests/mmapstorage/b", KEY_VALUE, "b value", KEY_META, "longer val",
			      "here some even more with ugly €@\\1¹²³¼ chars", KEY_END),
		      KS_END);
}

static void m_output_meta (Key * k)
{
	const Key * meta;

	keyRewindMeta (k);
	while ((meta = keyNextMeta (k)) != 0)
	{
		ELEKTRA_LOG_WARNING ("Meta KeySet size: %zu", k->meta->size);
		if (!meta) ELEKTRA_LOG_WARNING ("Meta Key is NULL");
		ELEKTRA_LOG_WARNING (", %s: %s", keyName (meta), (const char *)keyValue (meta));
	}
	ELEKTRA_LOG_WARNING ("\n");
}

static void m_output_key (Key * k)
{
	// output_meta will print endline
{'fraction_non_alphanumeric': 0.15156154317207593, 'fraction_numerical': 0.003674219228413962, 'mean_word_length': 4.057275541795666, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '6879605', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1254, 'n_words': 309}