#include "asterisk/module.h"
#include "asterisk/test.h"
+#define CATEGORY "/main/json/"
+
/*!
* Number of allocations from JSON library that have not yet been freed.
*/
ast_free(p);
}
-static void *json_test_init(struct ast_test *test)
+static int json_test_init(struct ast_test_info *info, struct ast_test *test)
{
ast_json_set_alloc_funcs(json_debug_malloc, json_debug_free);
alloc_count = 0;
- return test;
+ return 0;
}
-static void json_test_finish(void *test)
+static int json_test_cleanup(struct ast_test_info *info, struct ast_test *test)
{
- struct ast_test *t = test;
ast_json_reset_alloc_funcs();
if (0 != alloc_count) {
- ast_test_status_update(t, "JSON test leaked %zd allocations!", alloc_count);
+ ast_test_status_update(test,
+ "JSON test leaked %zd allocations!\n", alloc_count);
+ return -1;
}
+ return 0;
}
/*!@}*/
AST_TEST_DEFINE(json_test_false)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "false";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing fundamental JSON false value.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_true)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "true";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing JSON true value.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_bool0)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "bool0";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing JSON boolean function (false).";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_bool1)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "bool1";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing JSON boolean function (true).";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_null)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "null";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing JSON null value.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_null_val)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
switch (cmd) {
case TEST_INIT:
info->name = "null_val";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing JSON handling of NULL.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_string)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
int uut_res;
switch (cmd) {
case TEST_INIT:
info->name = "string";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Basic string tests.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_string_null)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "string_null";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "JSON string NULL tests.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_stringf)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "stringf";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Basic string formatting tests.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_int)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
int uut_res;
switch (cmd) {
case TEST_INIT:
info->name = "int";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Basic JSON integer tests.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_non_int)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "non_int";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing integer functions with non-integer types.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_array_create)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "array_create";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing creating JSON arrays.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_array_append)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
int uut_res;
switch (cmd) {
case TEST_INIT:
info->name = "array_append";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing appending to JSON arrays.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_array_inset)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
int uut_res;
switch (cmd) {
case TEST_INIT:
info->name = "array_insert";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing inserting into JSON arrays.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_array_set)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
int uut_res;
switch (cmd) {
case TEST_INIT:
info->name = "array_set";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing setting a value in JSON arrays.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_array_remove)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
int uut_res;
switch (cmd) {
case TEST_INIT:
info->name = "array_remove";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing removing a value from JSON arrays.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_array_clear)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
int uut_res;
switch (cmd) {
case TEST_INIT:
info->name = "array_clear";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing clearing JSON arrays.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_array_extend)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, tail, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "array_extend";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing extending JSON arrays.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_array_null)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "array_null";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing NULL conditions for JSON arrays.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_object_alloc)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "object_alloc";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing creating JSON objects.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_object_set)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
int uut_res;
switch (cmd) {
case TEST_INIT:
info->name = "object_set";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing setting values in JSON objects.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_object_set_overwrite)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
int uut_res;
switch (cmd) {
case TEST_INIT:
info->name = "object_set_overwriting";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing changing values in JSON objects.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_object_get)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "object_get";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing getting values from JSON objects.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_object_del)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
int uut_res;
switch (cmd) {
case TEST_INIT:
info->name = "object_del";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing deleting values from JSON objects.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_object_clear)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
int uut_res;
switch (cmd) {
case TEST_INIT:
info->name = "object_clear";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing clearing values from JSON objects.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_object_merge_all)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, merge, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "object_alloc";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing merging JSON objects.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_object_merge_existing)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, merge, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "object_alloc";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing merging JSON objects, updating only existing fields.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_object_merge_missing)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, merge, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "object_merge_missing";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing merging JSON objects, adding only missing fields.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_object_null)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "object_null";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing JSON object NULL behavior.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_object_iter)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
struct ast_json_iter *iter;
int count;
int uut_res;
switch (cmd) {
case TEST_INIT:
info->name = "object_iter";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing iterating through JSON objects.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_object_iter_null)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "object_iter_null";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing JSON object iterator NULL testings.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_dump_load_string)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
RAII_VAR(char *, str, NULL, json_debug_free);
switch (cmd) {
case TEST_INIT:
info->name = "dump_load_string";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing dumping strings from JSON.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_dump_load_str)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
RAII_VAR(struct ast_str *, astr, NULL, ast_free);
switch (cmd) {
case TEST_INIT:
info->name = "dump_load_str";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing dumping ast_str from JSON.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_dump_str_fail)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
struct ast_str *astr;
switch (cmd) {
case TEST_INIT:
info->name = "dump_str_fail";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing dumping to ast_str when it can't grow.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_load_buffer)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
const char *str;
switch (cmd) {
case TEST_INIT:
info->name = "load_buffer";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing loading JSON from buffer.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_dump_load_file)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
RAII_VAR(char *, filename, NULL, free);
switch (cmd) {
case TEST_INIT:
info->name = "dump_load_file";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing dumping/loading JSON to/from file by FILE *.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_dump_load_new_file)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
RAII_VAR(char *, filename, NULL, free);
switch (cmd) {
case TEST_INIT:
info->name = "dump_load_new_file";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing dumping/load JSON to/from file by filename.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_dump_load_null)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
RAII_VAR(char *, filename, NULL, free);
RAII_VAR(FILE *, file, NULL, safe_fclose);
switch (cmd) {
case TEST_INIT:
info->name = "dump_load_null";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing NULL handling of dump/load functions.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_parse_errors)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "parse_errors";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing various parse errors.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_pack)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "pack";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing json_pack function.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_pack_ownership)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "pack_ownership";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing json_pack failure conditions.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_pack_errors)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "object_alloc";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing json_pack failure conditions.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_copy)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "copy";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing copying JSON.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_deep_copy)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "deep_copy";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing deep copying of JSON.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_copy_null)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
switch (cmd) {
case TEST_INIT:
info->name = "copy_null";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Testing NULL handling of copy functions.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_circular_object)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
int uut_res;
switch (cmd) {
case TEST_INIT:
info->name = "circular_object";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Object cannot be added to itself.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_circular_array)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
int uut_res;
switch (cmd) {
case TEST_INIT:
info->name = "circular_array";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "Array cannot be added to itself.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_clever_circle)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, inner_child, NULL, ast_json_unref);
RAII_VAR(char *, str, NULL, json_debug_free);
switch (cmd) {
case TEST_INIT:
info->name = "clever_circle";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "JSON with circular references cannot be encoded.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_name_number)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "name_number";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "JSON encoding of name/number pair.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_timeval)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
struct timeval tv = {};
switch (cmd) {
case TEST_INIT:
info->name = "timeval";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "JSON encoding of timevals.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_DEFINE(json_test_cep)
{
- RAII_VAR(void *, alloc_debug, json_test_init(test), json_test_finish);
RAII_VAR(struct ast_json *, uut, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
info->name = "cep";
- info->category = "/main/json/";
+ info->category = CATEGORY;
info->summary = "JSON with circular references cannot be encoded.";
info->description = "Test JSON abstraction library.";
return AST_TEST_NOT_RUN;
AST_TEST_REGISTER(json_test_name_number);
AST_TEST_REGISTER(json_test_timeval);
AST_TEST_REGISTER(json_test_cep);
+
+ ast_test_register_init(CATEGORY, json_test_init);
+ ast_test_register_cleanup(CATEGORY, json_test_cleanup);
+
return AST_MODULE_LOAD_SUCCESS;
}