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/test/modes.c

59 lines
1.9 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 "uirc/uirc.h" // uirc_mode_*() IRC_Modes
#include <stdio.h> // fprintf() stderr
#include <stdlib.h> // EXIT_*
int
main(void)
{
IRC_Modes modes, cpymodes;
if (!uirc_mode_enable(IRC_MODE(IRC_MODE_OPERATOR), modes) || !modes[14]) {
fprintf(stderr, "Mode enable didn't work or mode was invalid\n");
return EXIT_FAILURE;
}
if (!uirc_mode_enable('A', modes) || !modes[25]) {
fprintf(stderr, "Mode enable didn't work or mode was invalid\n");
return EXIT_FAILURE;
}
uirc_mode_copy(cpymodes, modes);
if (!cpymodes[14] || !cpymodes[25]) {
fprintf(stderr, "Mode copy didn't work\n");
return EXIT_FAILURE;
}
if (!uirc_mode_toggle(IRC_MODE(IRC_MODE_OPERATOR), modes) || modes[14]) {
fprintf(stderr, "Mode toggle didn't work or mode was invalid\n");
return EXIT_FAILURE;
}
if (!uirc_mode_disable(IRC_MODE(IRC_MODE_OPERATOR), cpymodes) || cpymodes[14]) {
fprintf(stderr, "Mode disable didn't work or mode was invalid\n");
return EXIT_FAILURE;
}
if (!cpymodes[25]) {
fprintf(stderr, "Mode was toggled off incorrectly\n");
return EXIT_FAILURE;
}
if (!uirc_mode_disable('A', cpymodes) || cpymodes[25]) {
fprintf(stderr, "Mode disable didn't work or mode was invalid\n");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}