51 lines
1.7 KiB
C
51 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 "../../assemblers/assemblers.h" // Assm_user()
|
|
#include "../common.h" // expect()
|
|
|
|
#include <stdlib.h> // EXIT_SUCCESS EXIT_FAILURE
|
|
|
|
#define NICK "bruh"
|
|
#define USER "sound"
|
|
#define HOST "numero.dos"
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
const char* str[] = { NICK "!" USER "@" HOST, HOST };
|
|
IRC_User u[] = { { .nick = NICK, .user = USER, .host = HOST }, { .host = HOST } };
|
|
char buf[513];
|
|
signed long ret;
|
|
for (unsigned long i = 0; i < sizeof(str) / sizeof(*str); i++) {
|
|
if ((ret = uirc_assembler_user(buf, &u[i], sizeof(buf) / sizeof(char))) <= 0) {
|
|
printf("Failed to convert IRC_User struct to a string. %li\n", ret);
|
|
return EXIT_FAILURE;
|
|
}
|
|
size_t len = strlen(str[i]);
|
|
if ((size_t) ret != len) {
|
|
printf("String lenght doesn't match with amount of bytes printed. Expected %li but got %li\n", len, ret);
|
|
return EXIT_FAILURE;
|
|
}
|
|
expect(buf, str[i]);
|
|
print_irc_user(&u[i]);
|
|
}
|
|
return EXIT_SUCCESS;
|
|
}
|
|
|