]> jfr.im git - solanum.git/blame - tests/rb_dictionary1.c
Test chmode parsing
[solanum.git] / tests / rb_dictionary1.c
CommitLineData
959dffde
SA
1/*
2 * rb_dictionary1.c: Test rb_dictionary
3 * Copyright 2017 Simon Arlott
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18 * USA
19 */
20#include <stdio.h>
21#include <string.h>
22#include <stdlib.h>
23#include <unistd.h>
24#include "tap/basic.h"
25
26#include "stdinc.h"
27#include "ircd_defs.h"
28#include "client.h"
29
30#define MSG "%s:%d (%s)", __FILE__, __LINE__, __FUNCTION__
31
32#define MKTEXT(n) &text[sizeof(text) - ((n) + 1)]
33
34static void replace1(void)
35{
36 rb_dictionary *dict = rb_dictionary_create("replace1", strcmp);
37 rb_dictionary_element *original = rb_dictionary_add(dict, "test", "data1");
38
39 ok(original != NULL, MSG);
40 is_string("data1", original->data, MSG);
41
42#ifdef SOFT_ASSERT
43 rb_dictionary_element *replacement = rb_dictionary_add(dict, "test", "data2");
44
45 ok(replacement != NULL, MSG);
46 ok(original == replacement, MSG);
47
48 is_string("data2", original->data, MSG);
49#endif
50}
51
52int main(int argc, char *argv[])
53{
54 rb_lib_init(NULL, NULL, NULL, 0, 1024, DNODE_HEAP_SIZE, FD_HEAP_SIZE);
55 rb_linebuf_init(LINEBUF_HEAP_SIZE);
56
57 plan_lazy();
58
59 replace1();
60
61 return 0;
62}