test(delimiter): split and delimiter view

using comparison macro for tests referencing string views
move all local code related to unity to a separate object
This commit is contained in:
Maxim Prokhorov
2025-02-06 19:41:32 +03:00
parent ac86899764
commit a189c5f33f
7 changed files with 132 additions and 19 deletions

View File

@@ -0,0 +1,24 @@
#include <unity.h>
#include <espurna/types.h>
#include <espurna/libs/Delimiter.h>
void test_assert_equal_string_view(espurna::StringView expected, espurna::StringView actual, unsigned int line, const char* msg) {
UNITY_TEST_ASSERT_EQUAL_INT(expected.length(), actual.length(), line, msg);
if (msg != nullptr) {
UNITY_TEST_ASSERT_EQUAL_CHAR_ARRAY(
expected.data(), actual.data(), actual.length(), line, msg);
} else {
String out;
out += "'";
out += expected;
out += "' vs. '";
out += actual;
out += "'";
UNITY_TEST_ASSERT_EQUAL_CHAR_ARRAY(
expected.data(), actual.data(), actual.length(), line, out.c_str());
}
}