ffe2c7f6955fbb38afc53034b79722526e67cf1a
1 /**
2 * collectd - src/ceph_test.c
3 * Copyright (C) 2015 Florian octo Forster
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; only version 2 of the License is applicable.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 *
18 * Authors:
19 * Florian octo Forster <octo at collectd.org>
20 **/
22 #include "ceph.c" /* sic */
23 #include "testing.h"
25 DEF_TEST(parse_keys)
26 {
27 struct {
28 char *str;
29 char *want;
30 } cases[] = {
31 {"WBThrottle.bytes_dirtied.description.bytes_wb.description.ios_dirtied.description.ios_wb.type", "WBThrottle.bytesDirtied.description.bytesWb.description.iosDirt"},
32 {"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
33 {"foo:bar", "FooBar"},
34 {"foo:bar+", "FooBarPlus"},
35 {"foo:bar-", "FooBarMinus"},
36 {"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa+", "AaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaPlus"},
37 {"aa.bb.cc.dd.ee.ff", "Aa.bb.cc.dd.ee.ff"},
38 {"aa.bb.cc.dd.ee.ff.type", "Aa.bb.cc.dd.ee.ff"},
39 {"aa.type", "Aa.type"},
40 };
41 size_t i;
43 for (i = 0; i < STATIC_ARRAY_SIZE (cases); i++)
44 {
45 char got[DATA_MAX_NAME_LEN];
47 memset (got, 0, sizeof (got));
49 CHECK_ZERO (parse_keys (got, sizeof (got), cases[i].str));
51 CHECK_ZERO (strcmp (got, cases[i].want));
52 }
54 return 0;
55 }
57 int main (void)
58 {
59 RUN_TEST(parse_keys);
61 END_TEST;
62 }
64 /* vim: set sw=2 sts=2 et : */