]> git.sesse.net Git - vlc/blobdiff - test/pyunit.h
* Very first beginning of a v4l2 access-demux
[vlc] / test / pyunit.h
index 1b07165e7ac9e46fa52fadccc272fcdc5ad7be1b..726ca8d446a646316e5e97decd8b4a1965d2890e 100644 (file)
@@ -1,13 +1,20 @@
 #include <Python.h>
 
-#define ASSERT( a, message ) if( !(a) ) { fprintf( stderr, "ASSERTION FAILED\n" ); PyErr_SetString( PyExc_AssertionError, message ); return NULL; }
+extern int asserts;
+
+#define ASSERT( a, message ) asserts++;if( !(a) ) { PyErr_SetString( PyExc_AssertionError, message " - " #a ); return NULL; }
 
 #define DECLARE_MODULE( module ) PyMODINIT_FUNC init##module( void ) {  \
         Py_InitModule( #module, module##_methods );                     \
 }
 
-#define ASSERT_EXCEPTION if( libvlc_exception_raised( &exception ) ) { \
+#define ASSERT_NOEXCEPTION asserts++; if( libvlc_exception_raised( &exception ) ) { \
          if( libvlc_exception_get_message( &exception ) )  PyErr_SetString( PyExc_AssertionError, libvlc_exception_get_message( &exception ) ); \
          else PyErr_SetString( PyExc_AssertionError, "Exception raised" ); return NULL; }
 
+#define ASSERT_EXCEPTION asserts ++; if( !libvlc_exception_raised( &exception ) ) { \
+         if( libvlc_exception_get_message( &exception ) )  PyErr_SetString( PyExc_AssertionError, libvlc_exception_get_message( &exception ) ); \
+         else PyErr_SetString( PyExc_AssertionError, "Exception not raised" ); return NULL; }
+
+
 #define DEF_METHOD( method, desc ) { #method, method, METH_VARARGS, desc},