<commit_before>#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>

#include "../../src/packet.h"

/**
 * @brief Assert that the two given packets are equal.
 *
 * The function calls assert_true to assert that the values of the fields in
 * the two packets are the same.
 *
 * @param[in] a The first packet to compare.
 * @param[in] b The packet to compare against the first one.
 *
 * @see assert_true()
 */
static void assert_packet_equal(packet_t a, packet_t b) {
	assert_true(a.status == b.status);
	assert_true(a.group == b.group);
	assert_true(a.plug == b.plug);
}

static void test_packet_conversion(void **state) {
	packet_t sourcePacket; // The original packet
	packet_t destPacket;   // The "cloned" packet (original->binary->this)

	unsigned int binaryData; // The binary data (original->this->cloned)
	int group, plug, status; // The group, plug and status for the current test<commit_msg>Add test documentation<commit_after>#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>

#include "../../src/packet.h"

/**
 * @brief Assert that the two given packets are equal.
 *
 * The function calls assert_true to assert that the values of the fields in
 * the two packets are the same.
 *
 * @param[in] a The first packet to compare.
 * @param[in] b The packet to compare against the first one.
 *
 * @see assert_true()
 */
static void assert_packet_equal(packet_t a, packet_t b) {
	assert_true(a.status == b.status);
	assert_true(a.group == b.group);
	assert_true(a.plug == b.plug);
}

/**
 * @brief Test the conversion from packet to binary and back again.
 *
 * The function iterates all possible group, plug and status combinations and
 * creates binary data from them using packet_to_binary. It then converts it
 * back to a packet_t before comparing it with the original packet using
 * assert_packet_equal.
 *
 * @param[in] state The current state. Unused by this method.
 *
 * @see packet_to_binary()
 * @see binary_to_packet()
 * @see assert_packet_equal()
 */
static void test_packet_conversion(void **state) {
	packet_t sourcePacket; // The original packet
	packet_t destPacket;   // The "cloned" packet (original->binary->this)

	unsigned int binaryData; // The binary data (original->this->cloned)
	int group, plug, status; // The group, plug and status for the current test
{'fraction_non_alphanumeric': 0.11574468085106383, 'fraction_numerical': 0.0, 'mean_word_length': 4.066810344827586, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, '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': '2590342', 'n_tokens_mistral': 734, 'n_tokens_neox': 730, 'n_words': 270}