This repository has been archived on 2021-04-17. You can view files and clone it, but cannot push or open issues or pull requests.
uIRC/tests/manassm.c

63 lines
1.8 KiB
C

/*
* This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC)
* Copyright (c) 2019-2021 Alex-David Denes
*
* uIRC is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* uIRC is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
*/
#include "common.h" // expect() print_irc_message()
#include "uirc.h" // uirc_* IRC_*
#include <stdio.h> // fprintf()
#include <stdlib.h> // EXIT_*
#include <string.h> // strcmp()
#define TAGKEY "wow"
#define TAGKEY2 "wowcum"
#define TAGVAL "wow2"
#define TAGVAL2 "wow3rd"
int
main(void)
{
IRC_Message* m = uirc_malloc_message("NONE", 0);
uirc_list_add_tag(m, uirc_malloc_tag(TAGKEY, TAGVAL));
uirc_list_add_tag(m, uirc_malloc_tag(TAGKEY2, TAGVAL2));
IRC_Tag* t = m->tag_list->next->content;
if (strcmp(TAGKEY2, t->key) != 0 || strcmp(TAGVAL2, t->value) != 0) {
fprintf(stderr, "List allocator didn't allocate things right\n");
return EXIT_FAILURE;
}
t = m->tag_list->content;
if (strcmp(TAGKEY, t->key) != 0 || strcmp(TAGVAL, t->value) != 0) {
fprintf(stderr, "List allocator didn't allocate things right\n");
return EXIT_FAILURE;
}
uirc_list_remove_tag(m, m->tag_list->content);
t = m->tag_list->content;
if (strcmp(TAGKEY2, t->key) != 0 || strcmp(TAGVAL2, t->value) != 0) {
fprintf(stderr, "List remover fucked up\n");
return EXIT_FAILURE;
}
uirc_free_message(m);
free(m);
return EXIT_SUCCESS;
}