/
githubmirror
/
libreport
Обзор
Документация
Войти
/
githubmirror
/
libreport
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
tests/xfuncs.at
54 строки
1 KB
Michal Fabik
Remove unused ato[iu] functions
17 июн 2020, 13:45
17 июн 2020, 13:45
15ba780
Код
Авторство
О чём код?
# -*- Autotest -*- AT_BANNER([xfuncs]) ## ------------------------- ## ## libreport_xstrdup_between ## ## ------------------------- ## AT_TESTFUN([libreport_xstrdup_between], [[#include "internal_libreport.h" #include <assert.h> #include <string.h> #include <stdio.h> #define DEBUG_PRINT(e, r, o, c, s) \ fprintf(stderr, "Expected: '%s'\nFound: '%s'\nOpen: '%s'\nClose: '%s'\nSource: '%s'\n", e, r, o, c, s) void test(const char *src, const char *open, const char *close, const char *exp) { g_autofree char *res = libreport_xstrdup_between(src, open, close); if (exp == NULL && res != NULL) { DEBUG_PRINT("NULL", res, open, close, src); assert(!"Found non-existing section."); } else if (exp != NULL && res == NULL) { DEBUG_PRINT(exp, "NULL", open, close, src); assert(!"Didn't find section."); } else if (exp == NULL && res == NULL) return; else if (strcmp(res, exp) != 0) { DEBUG_PRINT(exp, res, open, close, src); assert(!"Invalid selection."); } } int main(void) { libreport_g_verbose=3; test("<a>foo blah</a>", "<?>", "</a>", NULL); test("<a>foo blah</a>", "<a>", "</?>", NULL); test("<a></a>", "<a>", "</a>", ""); test("@.$.@GOOD.$.", "@.$.@", ".$.", "GOOD"); return 0; } ]])