1
mirror of https://code.videolan.org/videolan/vlc synced 2024-10-11 06:21:30 +02:00
vlc/test/native/gc.c
Clément Stenac 0fbf13c309 * Tests for previous commit
* Improve test output
2006-08-19 16:19:56 +00:00

45 lines
955 B
C

#include "../pyunit.h"
#include <vlc/vlc.h>
struct mygc
{
VLC_GC_MEMBERS;
int i;
};
typedef struct mygc mygc;
static void mygc_destructor( gc_object_t *p_gc )
{
free( p_gc );
p_gc = NULL;
};
static PyObject *gc_test( PyObject *self, PyObject *args )
{
mygc *gc = (mygc *)malloc( sizeof( mygc ) );
vlc_gc_init( gc, mygc_destructor, NULL );
ASSERT( gc->i_gc_refcount == 0, "Refcount should be 0" );
vlc_gc_incref( gc );
ASSERT( gc->i_gc_refcount == 1, "Refcount should be 1" );
vlc_gc_incref( gc );
ASSERT( gc->i_gc_refcount == 2, "Refcount should be 2" );
gc->i++;
vlc_gc_decref( gc );
ASSERT( gc->i_gc_refcount == 1, "Refcount should be 1" );
vlc_gc_decref( gc );
Py_INCREF( Py_None );
return Py_None;
};
static PyMethodDef native_gc_test_methods[] = {
DEF_METHOD( gc_test, "Test GC" )
{ NULL, NULL, 0, NULL }
};
asserts = 0;
DECLARE_MODULE( native_gc_test )