]> git.sesse.net Git - vlc/commitdiff
Port new URL tests to test/
authorClément Stenac <zorglub@videolan.org>
Wed, 30 Aug 2006 17:17:11 +0000 (17:17 +0000)
committerClément Stenac <zorglub@videolan.org>
Wed, 30 Aug 2006 17:17:11 +0000 (17:17 +0000)
Support Python 2.4

test/NativeURLTest.py
test/native/init.c
test/native/tests.h
test/native/url.c
test/test.sh

index 03104b92596fb46822915c70fd4b5ad28808040e..9e3b5c24d8a00df87a1a7725d475c924f1b29f82 100644 (file)
@@ -4,5 +4,5 @@ import native_libvlc_test
 
 class NativeURLTestCase( unittest.TestCase ):
     def testurl_decode( self ):
-        """[URL] Test url_decode"""
-       native_libvlc_test.url_decode_test()
+        """[URL] Test url_decode and base64"""
+       native_libvlc_test.url_test()
index fa35c8b7e99e2382a1b39b4b032af9477bb2125b..21c2805d98dccc7d8970484e6332666ef255c245 100644 (file)
@@ -16,7 +16,7 @@ static PyMethodDef native_libvlc_test_methods[] = {
    DEF_METHOD( vlm_test, "Test VLM" )
    DEF_METHOD( timers_test, "Test timers" )
    DEF_METHOD( i18n_atof_test, "Test i18n_atof" )
-   DEF_METHOD( url_decode_test, "URL decoding" )
+   DEF_METHOD( url_test, "URL decoding" )
    DEF_METHOD( chains_test, "Test building of chains" )
    DEF_METHOD( gui_chains_test, "Test interactions between chains and GUI" )
    DEF_METHOD( psz_chains_test, "Test building of chain strings" )
index 1606c9b57afaf8a56bbaeb4577335318bee9129b..73f6d606a09bfd9515cf0ee980b27d35c9367284 100644 (file)
@@ -9,7 +9,7 @@ PyObject *vlm_test( PyObject *self, PyObject *args );
 /* Stats */
 PyObject *timers_test( PyObject *self, PyObject *args );
 
-PyObject *url_decode_test( PyObject *self, PyObject *args );
+PyObject *url_test( PyObject *self, PyObject *args );
 
 PyObject *i18n_atof_test( PyObject *self, PyObject *args );
 
index e43896ecf5a8140ca5c3a6958c14945286478fee..8c0943579821fae0ef3ea9cb9d73fd47d1619a55 100644 (file)
 #include <vlc/vlc.h>
 #include "vlc_url.h"
 
-PyObject * test_decode (const char *in, const char *out)
+typedef char * (*conv_t ) (const char *);
+
+PyObject * test (conv_t f, const char *in, const char *out)
 {
     char *res;
 
     printf ("\"%s\" -> \"%s\" ?\n", in, out);
-    res = decode_URI_duplicate (in);
-    ASSERT( res != NULL, "" );
-    if (res == NULL)
-        exit (1);
-
+    res = f(in);
+    ASSERT( res != NULL, "NULL result" );
     ASSERT( strcmp( res, out ) == NULL, "" );
 
     Py_INCREF( Py_None );
     return Py_None;
 }
 
-PyObject *url_decode_test( PyObject *self, PyObject *args )
+static inline PyObject * test_decode( const char *in, const char *out)
+{
+    return test( decode_URI_duplicate, in, out );
+}
+
+static inline PyObject* test_b64( const char *in, const char *out )
+{
+    return test( vlc_b64_encode, in, out );
+}
+
+PyObject *url_test( PyObject *self, PyObject *args )
 {
     printf( "\n" );
     if( !test_decode ("this_should_not_be_modified_1234",
@@ -65,6 +74,13 @@ PyObject *url_decode_test( PyObject *self, PyObject *args )
     if(!test_decode ("%C1%94%C3%a9l%c3%A9vision",
                          "??élévision") ) return NULL; /* overlong */
 
+    /* Base 64 tests */
+    test_b64 ("", "");
+    test_b64 ("d", "ZA==");
+    test_b64 ("ab", "YQG=");
+    test_b64 ("abc", "YQGI");
+    test_b64 ("abcd", "YQGIZA==");
+
     Py_INCREF( Py_None);
     return Py_None;
 }
index 84fc89d831ac6409428219d0cd3d3d1302958999..825f118915c090acfc8bb53988e434ace50480bf 100755 (executable)
@@ -1,11 +1,11 @@
 #! /bin/sh
 
 set -e
-python setup.py build 
+python setup.py build
 
 cd ..
 # TODO: FIXME !!
-export PYTHONPATH=$PYTHONPATH:bindings/mediacontrol-python/build/lib.linux-i686-2.3:test/build/lib.linux-i686-2.3:test/build/lib.linux-x86_64-2.3
+export PYTHONPATH=$PYTHONPATH:bindings/mediacontrol-python/build/lib.linux-i686-2.3:test/build/lib.linux-i686-2.3:test/build/lib.linux-x86_64-2.3:test/build/lib.linux-i686-2.4:test/build/lib.linux-x86_64-2.4
 
 export LD_LIBRARY_PATH=src/.libs/