* See the COPYING.LIB file in the top-level directory.
*/
#include "qemu/osdep.h"
-#include <glib.h>
-#include "qapi/qmp/qobject.h"
+#include "qapi/qmp/qnull.h"
#include "qemu-common.h"
-#include "qapi/qmp-output-visitor.h"
+#include "qapi/qobject-input-visitor.h"
+#include "qapi/qobject-output-visitor.h"
+#include "qapi/error.h"
/*
* Public Interface test-cases
{
QObject *obj;
- g_assert(qnull_.refcnt == 1);
- obj = qnull();
+ g_assert(qnull_.base.refcnt == 1);
+ obj = QOBJECT(qnull());
g_assert(obj);
- g_assert(obj == &qnull_);
- g_assert(qnull_.refcnt == 2);
+ g_assert(obj == QOBJECT(&qnull_));
+ g_assert(qnull_.base.refcnt == 2);
g_assert(qobject_type(obj) == QTYPE_QNULL);
- qobject_decref(obj);
- g_assert(qnull_.refcnt == 1);
+ qobject_unref(obj);
+ g_assert(qnull_.base.refcnt == 1);
}
static void qnull_visit_test(void)
{
QObject *obj;
- QmpOutputVisitor *qov;
+ Visitor *v;
+ QNull *null;
/*
* Most tests of interactions between QObject and visitors are in
* depend on layering violations to check qnull_ refcnt.
*/
- g_assert(qnull_.refcnt == 1);
- qov = qmp_output_visitor_new();
- /* FIXME: Empty visits are ugly, we should have a visit_type_null(). */
- obj = qmp_output_get_qobject(qov);
- g_assert(obj == &qnull_);
- qobject_decref(obj);
+ g_assert(qnull_.base.refcnt == 1);
+ obj = QOBJECT(qnull());
+ v = qobject_input_visitor_new(obj);
+ qobject_unref(obj);
+ visit_type_null(v, NULL, &null, &error_abort);
+ g_assert(obj == QOBJECT(&qnull_));
+ qobject_unref(null);
+ visit_free(v);
- qmp_output_visitor_cleanup(qov);
- g_assert(qnull_.refcnt == 1);
+ null = NULL;
+ v = qobject_output_visitor_new(&obj);
+ visit_type_null(v, NULL, &null, &error_abort);
+ visit_complete(v, &obj);
+ g_assert(obj == QOBJECT(&qnull_));
+ qobject_unref(null);
+ qobject_unref(obj);
+ visit_free(v);
+
+ g_assert(qnull_.base.refcnt == 1);
}
int main(int argc, char **argv)