From 533619c27d9cc3919bed540ea7f04bebddc71cbe Mon Sep 17 00:00:00 2001 From: xengineering Date: Tue, 29 Nov 2022 21:02:16 +0100 Subject: Add first unit test This should kick off the infrastructure for unit tests. This can still be improved but getting started is important to make it easier to add unit tests and thus improving the quality. --- tests/get_domainpart.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/get_domainpart.c (limited to 'tests') diff --git a/tests/get_domainpart.c b/tests/get_domainpart.c new file mode 100644 index 0000000..e05aee1 --- /dev/null +++ b/tests/get_domainpart.c @@ -0,0 +1,23 @@ + + +#include +#include + +#include "xmpp.h" + + +int main(void) +{ + char *input = "test@example.org/3f"; + const char *expected = "example.org"; + + char *result = get_domainpart(input); + + if (strcmp(result, expected) == 0) { + printf("Unit test passed - ok\n"); + return 0; + } else { + printf("'%s' != '%s'!\n", result, expected); + return 1; + } +} -- cgit v1.2.3-70-g09d2