2012-04-05 08:31:15 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "eobj_suite.h"
|
2012-04-10 02:12:46 -07:00
|
|
|
#include "Eobj.h"
|
2012-04-05 08:31:15 -07:00
|
|
|
|
2012-04-12 04:20:19 -07:00
|
|
|
#include "class_simple.h"
|
|
|
|
|
2012-04-12 05:25:26 -07:00
|
|
|
START_TEST(eobj_simple)
|
|
|
|
{
|
|
|
|
eobj_init();
|
|
|
|
Eobj *obj = eobj_add(EOBJ_CLASS_BASE, NULL);
|
|
|
|
|
|
|
|
fail_if(obj);
|
|
|
|
eobj_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2012-04-12 04:20:19 -07:00
|
|
|
START_TEST(eobj_op_errors)
|
2012-04-05 08:31:15 -07:00
|
|
|
{
|
2012-04-12 04:20:19 -07:00
|
|
|
eobj_init();
|
|
|
|
Eobj *obj = eobj_add(SIMPLE_CLASS, NULL);
|
|
|
|
|
|
|
|
/* Out of bounds op for a legal class. */
|
|
|
|
fail_if(eobj_do(obj, 0x00010111));
|
|
|
|
|
|
|
|
/* Ilegal class. */
|
|
|
|
fail_if(eobj_do(obj, 0x0F010111));
|
|
|
|
|
2012-04-12 07:37:57 -07:00
|
|
|
fail_if(eobj_ref_get(obj) != 1);
|
|
|
|
|
|
|
|
eobj_ref(obj);
|
|
|
|
fail_if(eobj_ref_get(obj) != 2);
|
|
|
|
|
|
|
|
eobj_ref(obj);
|
|
|
|
fail_if(eobj_ref_get(obj) != 3);
|
|
|
|
|
|
|
|
eobj_unref(obj);
|
|
|
|
fail_if(eobj_ref_get(obj) != 2);
|
|
|
|
|
|
|
|
eobj_unref(obj);
|
|
|
|
fail_if(eobj_ref_get(obj) != 1);
|
|
|
|
|
2012-04-12 04:20:19 -07:00
|
|
|
eobj_unref(obj);
|
|
|
|
eobj_shutdown();
|
2012-04-05 08:31:15 -07:00
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
void eobj_test_general(TCase *tc)
|
|
|
|
{
|
2012-04-12 04:20:19 -07:00
|
|
|
tcase_add_test(tc, eobj_op_errors);
|
2012-04-12 05:25:26 -07:00
|
|
|
tcase_add_test(tc, eobj_simple);
|
2012-04-05 08:31:15 -07:00
|
|
|
}
|