index d82a40b64e2a4cc2a0c5c472baff4817b5d54dec..fa6bfcfb7e133ce705ce8e8ab13e7ea37308ac7b 100644 (file)
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include "core/store.h"
#include "utils/proto.h"
-#include "libsysdb_test.h"
+#include "testutils.h"
#include <check.h>
#include <stdbool.h>
START_TEST(test_marshal_data)
{
-#define INT_TYPE "\0\0\0\1"
-#define DECIMAL_TYPE "\0\0\0\2"
-#define STRING_TYPE "\0\0\0\3"
-#define DATETIME_TYPE "\0\0\0\4"
-#define BINARY_TYPE "\0\0\0\5"
-#define REGEX_TYPE "\0\0\0\6"
+#define INT_TYPE "\0\0\0\2"
+#define DECIMAL_TYPE "\0\0\0\3"
+#define STRING_TYPE "\0\0\0\4"
+#define DATETIME_TYPE "\0\0\0\5"
+#define BINARY_TYPE "\0\0\0\6"
+#define REGEX_TYPE "\0\0\0\7"
#define NULL_ARRAY "\0\0\1\0"
-#define INT_ARRAY "\0\0\1\1"
-#define DECIMAL_ARRAY "\0\0\1\2"
-#define STRING_ARRAY "\0\0\1\3"
-#define DATETIME_ARRAY "\0\0\1\4"
-#define BINARY_ARRAY "\0\0\1\5"
-#define REGEX_ARRAY "\0\0\1\6"
+#define INT_ARRAY "\0\0\1\2"
+#define DECIMAL_ARRAY "\0\0\1\3"
+#define STRING_ARRAY "\0\0\1\4"
+#define DATETIME_ARRAY "\0\0\1\5"
+#define BINARY_ARRAY "\0\0\1\6"
+#define REGEX_ARRAY "\0\0\1\7"
regex_t dummy_re;
int64_t int_values[] = { 47, 11, 23 };
sdb_data_t datum = SDB_DATA_INIT;
ssize_t check;
- if (sdb_data_format(&golden_data[i].datum, v1, sizeof(v1), 0) < 0)
+ if (! sdb_data_format(&golden_data[i].datum, v1, sizeof(v1), 0))
snprintf(v1, sizeof(v1), "<ERR>");
fail_unless(len == golden_data[i].expected_len,
}
check = sdb_proto_unmarshal_data(buf, len, &datum);
- if (sdb_data_format(&datum, v2, sizeof(v2), 0) < 0)
+ if (! sdb_data_format(&datum, v2, sizeof(v2), 0))
snprintf(v2, sizeof(v2), "<ERR>");
if (sdb_data_isnull(&golden_data[i].datum))
START_TEST(test_marshal_attribute)
{
sdb_data_t v = { SDB_TYPE_INTEGER, { .integer = 4711 } };
-#define VAL "\0\0\0\1" "\0\0\0\0\0\0\x12\x67"
+#define VAL "\0\0\0\2" "\0\0\0\0\0\0\x12\x67"
struct {
sdb_proto_attribute_t attr;
ssize_t expected_len;
pos, (int)buf[pos], (int)golden_data[i].expected[pos]);
}
- if (sdb_data_format(&golden_data[i].attr.value, v1, sizeof(v1), 0) < 0)
+ if (! sdb_data_format(&golden_data[i].attr.value, v1, sizeof(v1), 0))
snprintf(v1, sizeof(v1), "<ERR>");
check = sdb_proto_unmarshal_attribute(buf, len, &attr);
"<%zu> sdb_proto_unmarshal_attribute(buf<%s>) = %zi; expected: %zi",
i, golden_data[i].attr.key, check, len);
- if (sdb_data_format(&attr.value, v2, sizeof(v2), 0) < 0)
+ if (! sdb_data_format(&attr.value, v2, sizeof(v2), 0))
snprintf(v2, sizeof(v2), "<ERR>");
fail_unless((attr.last_update == golden_data[i].attr.last_update)
&& (attr.parent_type == golden_data[i].attr.parent_type)
}
END_TEST
-Suite *
-util_proto_suite(void)
+TEST_MAIN("utils::proto")
{
- Suite *s = suite_create("utils::proto");
- TCase *tc;
-
- tc = tcase_create("core");
+ TCase *tc = tcase_create("core");
tcase_add_test(tc, test_marshal_data);
tcase_add_test(tc, test_marshal_host);
tcase_add_test(tc, test_marshal_service);
tcase_add_test(tc, test_marshal_metric);
tcase_add_test(tc, test_marshal_attribute);
- suite_add_tcase(s, tc);
-
- return s;
-} /* util_proto_suite */
+ ADD_TCASE(tc);
+}
+TEST_MAIN_END
/* vim: set tw=78 sw=4 ts=4 noexpandtab : */