ud3tn/test/unit/test_bibe_encoder.c
Maximilian Nitsch 4e125e3af7 fix: cppcheck warnings
Add command-line options for cppcheck to the CI job:

- `--suppress=constParameterCallback`

- `--check-level=exhaustive`

  information: Limiting analysis of branches.
  Use --check-level=exhaustive to analyze all branches.

- `--force`

  information: Too many #ifdef configurations - cppcheck only checks 12
  configurations. Use --force to check all configurations.

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2026-05-20 17:57:53 +02:00

57 lines
1.1 KiB
C

// SPDX-License-Identifier: BSD-3-Clause OR Apache-2.0
#include "cla/bibe_proto.h"
#include "testud3tn_unity.h"
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#define EXPECTED_HEADER_LENGTH 31
static const uint8_t valid_header_bytes[EXPECTED_HEADER_LENGTH] = {
0x19, 0x00, 0x0F, 0x64, 0x74, 0x6E, 0x3A, 0x2F, 0x2F, 0x75, 0x64,
0x33, 0x74, 0x6E, 0x2E, 0x64, 0x74, 0x6E, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x5F, 0x83, 0x00, 0x00, 0x58, 0x5A
};
TEST_GROUP(bibe_header_encoder);
TEST_SETUP(bibe_header_encoder)
{
}
TEST_TEAR_DOWN(bibe_header_encoder)
{
}
TEST(bibe_header_encoder, get_encoded_size)
{
struct bibe_header hdr;
bibe_encode_header("dtn://ud3tn.dtn", 90, &hdr);
TEST_ASSERT_EQUAL(EXPECTED_HEADER_LENGTH, hdr.hdr_len);
free(hdr.data);
}
TEST(bibe_header_encoder, encode_header)
{
struct bibe_header hdr;
bibe_encode_header("dtn://ud3tn.dtn", 90, &hdr);
TEST_ASSERT_EQUAL_UINT8_ARRAY(
valid_header_bytes,
hdr.data,
EXPECTED_HEADER_LENGTH
);
free(hdr.data);
}
TEST_GROUP_RUNNER(bibe_header_encoder)
{
RUN_TEST_CASE(bibe_header_encoder, get_encoded_size);
RUN_TEST_CASE(bibe_header_encoder, encode_header);
}