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/src/tests/tokenizers/tag.c

64 lines
1.7 KiB
C

/*
* This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC)
* Copyright (c) 2019, 2020 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 "../../tokenizers/tokenizers.h" // uirc_tokenizer_*()
#include "../common.h" // expect()
#include <assert.h> // assert()
#include <corelibs/llist.h> // llist_t
#include <stdlib.h> // EXIT_SUCCESS
#define key1 "msgid"
#define val1 "30"
#define key2 "time"
#define key3 "x"
#define val3 "spx"
int
main(void)
{
IRC_Tag* cur = NULL;
llist_t* tags = uirc_tokenizer_tag_list("+" key1 "=" val1 ";" key2 ";" key3 "=" val3);
ERRIFNULL(tags, "Tags weren't tokenized successfully.\n");
cur = tags->content;
expect(cur->key, key1);
expect(cur->value, val1);
if (!cur->clientbound) {
printf("Tag #1 wasn't clientbound.\n");
return EXIT_FAILURE;
}
print_irc_tag(cur);
cur = (tags = tags->next)->content;
expect(cur->key, key2);
if (cur->clientbound) {
printf("Tag #2 was clientbound.\n");
return EXIT_FAILURE;
}
print_irc_tag(cur);
cur = (tags = tags->next)->content;
expect(cur->key, key3);
expect(cur->value, val3);
print_irc_tag(cur);
return EXIT_SUCCESS;
}