Merge pull request #3339 from jkohen/patch-1
[collectd.git] / src / ceph_test.c
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  **/
21
22 #include "ceph.c" /* sic */
23 #include "testing.h"
24
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;
42
43   for (i = 0; i < STATIC_ARRAY_SIZE (cases); i++)
44   {
45     char got[DATA_MAX_NAME_LEN];
46
47     CHECK_ZERO (parse_keys (got, sizeof (got), cases[i].str));
48     EXPECT_EQ_STR (cases[i].want, got);
49   }
50
51   return 0;
52 }
53
54 int main (void)
55 {
56   RUN_TEST(parse_keys);
57
58   END_TEST;
59 }
60
61 /* vim: set sw=2 sts=2 et : */