Commit eb775b96 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

test: remove old unused "native" Python tests

parent 5f5121a8
/*****************************************************************************
* algo.c : Algorithms test
*****************************************************************************
* Copyright (C) 2006 VideoLAN
* $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "../pyunit.h"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc/vlc.h>
/**********************************************************************
* Arrays
*********************************************************************/
TYPEDEF_ARRAY(long,long_array_t);
PyObject *arrays_test( PyObject *self, PyObject *args )
{
mtime_t one, two;
int number = 1000000;
int number2 = 50000; /* For slow with memmove */
printf("\n");
{
int i_items = 0;
int *p_items = NULL;
int i;
one = mdate();
for( i = 0 ; i<number;i++) {
INSERT_ELEM(p_items,i_items, i_items, i+50);
}
two = mdate();
printf( " Std array %i items appended in "I64Fi" µs\n", number,
(two-one) );
for( i = number-1 ; i>=0; i--) {
REMOVE_ELEM( p_items, i_items, i );
}
one = mdate();
printf( " Std array %i items removed in "I64Fi" µs\n", number,
(one-two) );
for( i = 0 ; i<number2;i++) {
int pos = i_items == 0 ? 0 : rand() % i_items;
INSERT_ELEM(p_items, i_items, pos, pos + 50);
}
two = mdate();
printf( " Std array %i items inserted in "I64Fi" µs\n", number2,
(two-one) );
}
{
DECL_ARRAY(int) int_array;
int i = 0;
ARRAY_INIT(int_array);
ASSERT(int_array.i_size == 0, "" );
ASSERT(int_array.i_alloc == 0, "" );
ASSERT(int_array.p_elems == 0, "" );
ARRAY_APPEND(int_array, 42 );
ASSERT(int_array.i_size == 1, "" );
ASSERT(int_array.i_alloc > 1, "" );
ASSERT(int_array.p_elems[0] == 42, "" );
ARRAY_REMOVE(int_array,0);
ASSERT(int_array.i_size == 0, "" );
one = mdate();
for( i = 0 ; i<number;i++) {
ARRAY_APPEND(int_array, i+50);
}
two = mdate();
printf( " New array %i items appended in "I64Fi" µs\n", number,
(two-one) );
ASSERT(int_array.p_elems[1242] == 1292 , "");
for( i = number-1 ; i>=0; i--) {
ARRAY_REMOVE(int_array,i);
}
one = mdate();
printf( " New array %i items removed in "I64Fi" µs\n", number,
(one-two) );
/* Now random inserts */
for( i = 0 ; i<number2;i++) {
int pos = int_array.i_size == 0 ? 0 : rand() % int_array.i_size;
ARRAY_INSERT(int_array, pos+50, pos);
}
two = mdate();
printf( " New array %i items inserted in "I64Fi" µs\n", number2,
(two-one) );
}
{
long_array_t larray;
ARRAY_INIT(larray);
}
Py_INCREF( Py_None);
return Py_None;
}
/**********************************************************************
* Binary search
*********************************************************************/
PyObject *bsearch_direct_test( PyObject *self, PyObject *args )
{
#define DIRCHECK( size, initial, checked, expected ) { \
int array[size] = initial; \
int answer = -1; \
BSEARCH( array, size, , int, checked, answer ); \
ASSERT( answer == expected , "" ); }
#define ORDERED10 {0,1,2,3,4,5,6,7,8,9}
DIRCHECK( 10, ORDERED10, 0, 0 );
DIRCHECK( 10, ORDERED10, 1, 1 );
DIRCHECK( 10, ORDERED10, 2, 2 );
DIRCHECK( 10, ORDERED10, 3, 3 );
DIRCHECK( 10, ORDERED10, 4, 4 );
DIRCHECK( 10, ORDERED10, 5, 5 );
DIRCHECK( 10, ORDERED10, 6, 6 );
DIRCHECK( 10, ORDERED10, 7, 7 );
DIRCHECK( 10, ORDERED10, 8, 8 );
DIRCHECK( 10, ORDERED10, 9,9 );
DIRCHECK( 10, ORDERED10, 10, -1 );
DIRCHECK( 10, ORDERED10, -1, -1 );
/* TODO: tests on unordered arrays, odd number of elements, 1 element, 2 */
Py_INCREF( Py_None);
return Py_None;
}
struct bsearch_tester
{
int key; int value;
};
/* Lighter test, we just check correct member access, all the real testing
* has been made already */
PyObject *bsearch_member_test( PyObject *self, PyObject *args )
{
struct bsearch_tester array[] =
{
{ 0, 12 }, { 1, 22 } , { 2, 33 } , { 3, 68 } , { 4, 56 }
};
#define MEMBCHECK( checked, expected ) { \
int answer = -1; \
BSEARCH( array, 5, .key , int, checked, answer ); \
ASSERT( answer == expected , "" ); }
MEMBCHECK( 0, 0 ) ;
MEMBCHECK( 1, 1 );
MEMBCHECK( 2, 2 );
MEMBCHECK( 3, 3 );
MEMBCHECK( 4, 4 );
MEMBCHECK( 5, -1 );
Py_INCREF( Py_None);
return Py_None;
}
/**********************************************************************
* Dictionnary
*********************************************************************/
DICT_TYPE( test, int );
static void DumpDict( dict_test_t *p_dict )
{
int i = 0;
fprintf( stderr, "**** Begin Dump ****\n" );
for( i = 0 ; i < p_dict->i_entries; i++ )
{
fprintf( stderr, "Entry %i - hash %lli int %i string %s data %i\n",
i, p_dict->p_entries[i].i_hash,
p_dict->p_entries[i].i_int,
p_dict->p_entries[i].psz_string,
p_dict->p_entries[i].data );
}
fprintf( stderr, "**** End Dump ****\n" );
}
PyObject *dict_test( PyObject *self, PyObject *args )
{
int i42 = 42,i40 = 40,i12 = 12, i0 = 0, i00 = 0;
int answer;
printf("\n");
dict_test_t *p_dict;
DICT_NEW( p_dict );
ASSERT( p_dict->i_entries == 0, "" );
ASSERT( p_dict->p_entries == NULL, "" );
DICT_INSERT( p_dict, 0, NULL, i42 );
ASSERT( p_dict->i_entries == 1, "" );
ASSERT( p_dict->p_entries[0].data == i42, "" );
DICT_INSERT( p_dict, 1, "42", i42 );
ASSERT( p_dict->i_entries == 2, "" );
DICT_LOOKUP( p_dict, 1, "42", answer );
DICT_GET( p_dict, 1, "42", answer );
ASSERT( answer == i42, "" );
DICT_LOOKUP( p_dict, 0, "42", answer ); ASSERT( answer == -1, "" );
DICT_LOOKUP( p_dict, 1, " 42", answer ); ASSERT( answer == -1, "" );
DICT_INSERT( p_dict, 1, "12", i12 );
DICT_GET( p_dict, 1, "12", answer ) ; ASSERT( answer == i12, "" );
DICT_INSERT( p_dict, 3, "40", i40 );
DICT_GET( p_dict, 1, "42", answer ); ASSERT( answer == i42, "" );
DICT_GET( p_dict, 3, "40", answer ); ASSERT( answer == i40, "" );
DICT_GET( p_dict, 1, "12", answer ); ASSERT( answer == i12, "" );
DICT_INSERT( p_dict, 12, "zero-1", i0 );
DICT_INSERT( p_dict, 5, "zero-0", i00 );
DICT_GET( p_dict, 12, "zero-1", answer ); ASSERT( answer == i0, "" );
DICT_GET( p_dict, 5, "zero-0", answer ); ASSERT( answer == i00, "" );
answer = -1;
DICT_GET( p_dict, 12, "zero-0", answer ); ASSERT( answer == -1, "" );
DICT_GET( p_dict, 1, "12", answer ); ASSERT( answer == i12, "" );
DICT_INSERT( p_dict, 0, "zero", 17 );
DICT_GET( p_dict, 1, "12", answer ); ASSERT( answer == i12, "" );
DICT_GET( p_dict, 12, "zero-1", answer ); ASSERT( answer == i0, "" );
DICT_GET( p_dict, 0, "zero", answer ); ASSERT( answer == 17, "" );
DICT_INSERT( p_dict, 0, "12", i12 );
DICT_INSERT( p_dict, 0, "thisisaverylongstringwith12", i12 );
answer = -1;
DICT_GET( p_dict, 0, "thisisaverylongstringwith12", answer );
ASSERT( answer == i12, "" );
answer = -1;
DICT_GET( p_dict, 0, "thisisaverylongstringwith13", answer );
ASSERT( answer == -1, "" );
DICT_CLEAR( p_dict );
Py_INCREF( Py_None);
return Py_None;
}
#include "../pyunit.h"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#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 )
/*****************************************************************************
* i18n.c: I18n tests
*****************************************************************************
* Copyright (C) 2006 Rémi Denis-Courmont
* $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "../pyunit.h"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc/vlc.h>
#include <vlc_charset.h>
PyObject *i18n_atof_test( PyObject *self, PyObject *args )
{
const char dot9[] = "999999.999999";
const char comma9[] = "999999,999999";
const char sharp9[] = "999999#999999";
char *end;
ASSERT (i18n_atof("0") == 0.,"");
ASSERT (i18n_atof("1") == 1.,"");
ASSERT (i18n_atof("1.") == 1.,"");
ASSERT (i18n_atof("1,") == 1.,"");
ASSERT (i18n_atof("1#") == 1.,"");
ASSERT (i18n_atof(dot9) == 999999.999999,"");
ASSERT (i18n_atof(comma9) == 999999.999999,"");
ASSERT (i18n_atof(sharp9) == 999999.,"");
ASSERT (i18n_atof("invalid") == 0.,"");
ASSERT (us_atof("0") == 0.,"");
ASSERT (us_atof("1") == 1.,"");
ASSERT (us_atof("1.") == 1.,"");
ASSERT (us_atof("1,") == 1.,"");
ASSERT (us_atof("1#") == 1.,"");
ASSERT (us_atof(dot9) == 999999.999999,"");
ASSERT (us_atof(comma9) == 999999.,"");
ASSERT (us_atof(sharp9) == 999999.,"");
ASSERT (us_atof("invalid") == 0.,"");
ASSERT ((i18n_strtod(dot9, &end ) == 999999.999999)
&& (*end == '\0'),"");
ASSERT ((i18n_strtod(comma9, &end ) == 999999.999999)
&& (*end == '\0'),"");
ASSERT ((i18n_strtod(sharp9, &end ) == 999999.)
&& (*end == '#'),"");
ASSERT ((us_strtod(dot9, &end ) == 999999.999999)
&& (*end == '\0'),"");
ASSERT ((us_strtod(comma9, &end ) == 999999.)
&& (*end == ','),"");
ASSERT ((us_strtod(sharp9, &end ) == 999999.)
&& (*end == '#'),"");
Py_INCREF( Py_None);
return Py_None;
}
#include "../pyunit.h"
#include "tests.h"
PyObject *init( PyObject *self, PyObject *args )
{
(void)setvbuf (stdout, NULL, _IONBF, 0);
Py_INCREF( Py_None );
return Py_None;
}
static PyMethodDef native_libvlc_test_methods[] = {
DEF_METHOD( init, "Init some stuff" )
DEF_METHOD( create_destroy, "Create and destroy" )
DEF_METHOD( exception_test, "Test Exception handling" )
DEF_METHOD( playlist_test, "Test Playlist interaction" )
DEF_METHOD( vlm_test, "Test VLM" )
DEF_METHOD( timers_test, "Test timers" )
DEF_METHOD( i18n_atof_test, "Test i18n_atof" )
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" )
DEF_METHOD( arrays_test, "Test arrays")
DEF_METHOD( bsearch_direct_test, "Test Bsearch without structure" )
DEF_METHOD( bsearch_member_test, "Test Bsearch with structure" )
DEF_METHOD( dict_test, "Test dictionnaries" )
DEF_METHOD( threadvar_test, "Test TLS" )
{ NULL, NULL, 0, NULL }
};
asserts =0;
DECLARE_MODULE( native_libvlc_test )
#include "../pyunit.h"
#include <vlc/libvlc.h>
PyObject *exception_test( PyObject *self, PyObject *args )
{
libvlc_exception_t exception;
libvlc_exception_init( &exception );
ASSERT( !libvlc_exception_raised( &exception) , "Exception raised" );
ASSERT( !libvlc_exception_get_message( &exception) , "Exception raised" );
libvlc_exception_raise( &exception, NULL );
ASSERT( !libvlc_exception_get_message( &exception), "Unexpected message" );
ASSERT( libvlc_exception_raised( &exception), "Exception not raised" );
libvlc_exception_raise( &exception, "test" );
ASSERT( libvlc_exception_get_message( &exception), "No Message" );
ASSERT( libvlc_exception_raised( &exception), "Exception not raised" );
libvlc_exception_clear( &exception );
ASSERT( !libvlc_exception_raised( &exception ), "Exception not cleared" );
Py_INCREF( Py_None );
return Py_None;
}
PyObject *create_destroy( PyObject *self, PyObject *args )
{
libvlc_instance_t *p_i1, *p_i2;
char *argv1[] = { "vlc", "--quiet" };
char *argv2[]= { "vlc", "-vvv" };
int id1,id2;
printf( "\n" );
libvlc_exception_t exception;
libvlc_exception_init( &exception );
/* Create and destroy a single instance */
fprintf( stderr, "Create 1\n" );
p_i1 = libvlc_new( 2, argv1, &exception );
ASSERT( p_i1 != NULL, "Instance creation failed" );
ASSERT_NOEXCEPTION;
id1 = libvlc_get_vlc_id( p_i1 );
libvlc_release( p_i1, &exception );
ASSERT_NOEXCEPTION;
/* Create and destroy two instances */
fprintf( stderr, "Create 2\n" );
p_i1 = libvlc_new( 2, argv1, &exception );
ASSERT( p_i1 != NULL, "Instance creation failed" );
ASSERT_NOEXCEPTION;
fprintf( stderr, "Create 3\n" );
p_i2 = libvlc_new( 2, argv2, &exception );
ASSERT( p_i2 != NULL, "Instance creation failed" );
ASSERT_NOEXCEPTION;
fprintf( stderr, "Destroy 1\n" );
libvlc_release( p_i1, &exception );
ASSERT_NOEXCEPTION;
fprintf( stderr, "Destroy 2\n" );
libvlc_release( p_i2, &exception );
ASSERT_NOEXCEPTION;
/* Deinit */
fprintf( stderr, "Create 4\n" );
p_i1 = libvlc_new( 2, argv1, &exception );
ASSERT_NOEXCEPTION;
id2 = libvlc_get_vlc_id( p_i1 );
ASSERT( id1 == id2, "libvlc object ids do not match after deinit" );
Py_INCREF( Py_None );
return Py_None;
}
PyObject *playlist_test( PyObject *self, PyObject *args )
{
libvlc_instance_t *p_instance;
char *argv[] = { "vlc", "--quiet" };
int i_id, i_playing, i_items;
libvlc_exception_t exception;
libvlc_exception_init( &exception );
p_instance = libvlc_new( 2, argv, &exception );
ASSERT_NOEXCEPTION;
/* Initial status */
libvlc_playlist_play( p_instance, 0, 0, argv, &exception );
ASSERT( libvlc_exception_raised( &exception ),
"Playlist empty and exception not raised" );
libvlc_exception_clear( &exception );
i_playing = libvlc_playlist_isplaying( p_instance, &exception );
ASSERT_NOEXCEPTION;
ASSERT( i_playing == 0, "Playlist shouldn't be running" );
i_items = libvlc_playlist_items_count( p_instance, &exception );
ASSERT_NOEXCEPTION;
ASSERT( i_items == 0, "Playlist should be empty" );
/* Add 1 item */
libvlc_exception_clear( &exception );
i_id = libvlc_playlist_add( p_instance, "test" , NULL , &exception );
ASSERT_NOEXCEPTION;
ASSERT( i_id > 0 , "Returned identifier is <= 0" );
i_items = libvlc_playlist_items_count( p_instance, &exception );
ASSERT_NOEXCEPTION;
ASSERT( i_items == 1, "Playlist should have 1 item" );
i_playing = libvlc_playlist_isplaying( p_instance, &exception );
ASSERT_NOEXCEPTION;
ASSERT( i_playing == 0, "Playlist shouldn't be running" );
/* */
Py_INCREF( Py_None );
return Py_None;
}
PyObject *vlm_test( PyObject *self, PyObject *args )
{
libvlc_instance_t *p_instance;
char *argv[] = { "vlc", "--quiet" };
char *ppsz_empty[] = {};
libvlc_exception_t exception;
libvlc_exception_init( &exception );
p_instance = libvlc_new( 2, argv, &exception );
ASSERT_NOEXCEPTION;
/* Test that working on unexisting streams fail */
libvlc_vlm_set_enabled( p_instance, "test", 1, &exception );
ASSERT_EXCEPTION;
libvlc_exception_clear( &exception );
libvlc_vlm_set_input( p_instance, "test", "input", &exception );
ASSERT_EXCEPTION;
libvlc_exception_clear( &exception );
libvlc_vlm_del_media( p_instance, "test", &exception );
ASSERT_EXCEPTION;
libvlc_exception_clear( &exception );
/******* Broadcast *******/
/* Now create a media */
libvlc_vlm_add_broadcast( p_instance, "test", "input_test", "output_test",
0, ppsz_empty, 1, 1, &exception );
ASSERT_NOEXCEPTION;
libvlc_exception_clear( &exception );
/* Change its parameters */
libvlc_vlm_set_enabled( p_instance, "test", 0, &exception );
ASSERT_NOEXCEPTION;
libvlc_exception_clear( &exception );
libvlc_vlm_set_output( p_instance, "test", "output_test2", &exception );
ASSERT_NOEXCEPTION;
libvlc_exception_clear( &exception );
/* Check the parameters */
fprintf( stderr, "The code for this is not written yet\n");
/* Control it a bit */
fprintf( stderr, "The code for this is not written yet\n");
/* Try to delete it */
libvlc_vlm_del_media( p_instance, "test", &exception );
ASSERT_NOEXCEPTION;
libvlc_exception_clear( &exception );
libvlc_vlm_del_media( p_instance, "test", &exception );
ASSERT_EXCEPTION;
libvlc_exception_clear( &exception );
/******* VOD *******/
Py_INCREF( Py_None );
return Py_None;
}
/*****************************************************************************
* profiles.c: Test streaming profiles
*****************************************************************************
* Copyright (C) 2006 The VideoLAN project
* $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "../pyunit.h"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc/vlc.h>
#include <vlc_streaming.h>
#define STDCHAIN1 "#std{access=udp,url=12.42.12.42,mux=ts}"
//#define GUICHAIN1
static void BuildStdChain1( sout_chain_t *p_chain )
{
streaming_ChainAddStd( p_chain, "udp", "ts", "12.42.12.42" );
}
#define TRACHAIN1 "#transcode{vcodec=mpgv,vb=1024,scale=1.0,acodec=mp3,ab=128,channels=2}:std{mux=mp4,access=file,url=/dev/null}"
static void BuildTranscodeChain1( sout_chain_t *p_chain )
{
streaming_ChainAddTranscode( p_chain, "mpgv", "mp3", NULL, 1024, 1.0,
128, 2, NULL );
streaming_ChainAddStd( p_chain, "file", "mp4", "/dev/null" );
}
static void BuildInvalid1( sout_chain_t *p_chain )
{
streaming_ChainAddStd( p_chain, "file", "mp4", "/dev/null" );
streaming_ChainAddStd( p_chain, "file", "mp4", "/dev/null" );
}
PyObject *chains_test( PyObject *self, PyObject *args )
{
sout_chain_t *p_chain = streaming_ChainNew();
sout_duplicate_t *p_dup;
ASSERT( p_chain->i_modules == 0, "unclean chain" );
ASSERT( p_chain->i_options == 0, "unclean chain" );
ASSERT( p_chain->pp_modules == NULL, "unclean chain" );
ASSERT( p_chain->ppsz_options == NULL, "unclean chain" );
/* Check duplicate */
p_dup = streaming_ChainAddDup( p_chain );
ASSERT( p_chain->i_modules == 1, "not 1 module" );
ASSERT( p_dup->i_children == 0, "dup has children" );
streaming_DupAddChild( p_dup );
ASSERT( p_dup->i_children == 1, "not 1 child" );
ASSERT( p_dup->pp_children[0]->i_modules == 0, "unclean child chain");
streaming_DupAddChild( p_dup );
ASSERT( p_dup->i_children == 2, "not 2 children" );
Py_INCREF( Py_None );
return Py_None;
}
PyObject *gui_chains_test( PyObject *self, PyObject *args )
{
Py_INCREF( Py_None);
return Py_None;
}
PyObject *psz_chains_test( PyObject *self, PyObject *args )
{
sout_chain_t *p_chain = streaming_ChainNew();
sout_module_t *p_module;
char *psz_output;
printf( "\n" );
BuildStdChain1( p_chain );
psz_output = streaming_ChainToPsz( p_chain );
printf( "STD1: %s\n", psz_output );
ASSERT( !strcmp( psz_output, STDCHAIN1 ), "wrong output for STD1" )
ASSERT( p_chain->i_modules == 1, "wrong number of modules" );
p_module = p_chain->pp_modules[0];
ASSERT( p_module->i_type == SOUT_MOD_STD, "wrong type of module" );
Py_INCREF( Py_None);
return Py_None;
}
#include "../pyunit.h"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc/vlc.h>
PyObject *timers_test( PyObject *self, PyObject *args )
{
Py_INCREF( Py_None );
return Py_None;
}
#include "../pyunit.h"
/* Libvlc */
PyObject *exception_test( PyObject *self, PyObject *args );
PyObject *create_destroy( PyObject *self, PyObject *args );
PyObject *playlist_test( PyObject *self, PyObject *args );
PyObject *vlm_test( PyObject *self, PyObject *args );
PyObject *threadvar_test( PyObject *self, PyObject *args );
/* Stats */
PyObject *timers_test( PyObject *self, PyObject *args );
PyObject *url_test( PyObject *self, PyObject *args );
PyObject *i18n_atof_test( PyObject *self, PyObject *args );
/* Profiles */
PyObject *chains_test( PyObject *self, PyObject *args );
PyObject *gui_chains_test( PyObject *self, PyObject *args );
PyObject *psz_chains_test( PyObject *self, PyObject *args );
/* Algo */
PyObject *arrays_test( PyObject *self, PyObject *args );
PyObject *bsearch_direct_test( PyObject *self, PyObject *args );
PyObject *bsearch_member_test( PyObject *self, PyObject *args );
PyObject *dict_test( PyObject *self, PyObject *args );
#include "../pyunit.h"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc/vlc.h>
PyObject *threadvar_test( PyObject *self, PyObject *args )
{
void *p_foo = malloc(1);
vlc_threadvar_t key, key2;
vlc_threadvar_create( NULL, &key );
vlc_threadvar_set( &key, p_foo );
ASSERT( vlc_threadvar_get( &key ) == p_foo, "key does not match" );
vlc_threadvar_create( NULL, &key2 );
vlc_threadvar_set( &key2, NULL );
ASSERT( vlc_threadvar_get( &key2 ) == NULL, "key2 does not match" );
Py_INCREF( Py_None );
return Py_None;
}
/*****************************************************************************
* url.c: Test for url encoding/decoding stuff
*****************************************************************************
* Copyright (C) 2006 Rémi Denis-Courmont
* $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "../pyunit.h"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc/vlc.h>
#include "vlc_url.h"
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 = f(in);
ASSERT( res != NULL, "NULL result" );
ASSERT( strcmp( res, out ) == NULL, "" );
Py_INCREF( Py_None );
return Py_None;
}
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" );
#define DO_TEST_DECODE( a, b ) if( !test_decode( a, b) ) return NULL;
DO_TEST_DECODE ("this_should_not_be_modified_1234",
"this_should_not_be_modified_1234");
DO_TEST_DECODE ("This+should+be+modified+1234!",
"This should be modified 1234!");
DO_TEST_DECODE ("This%20should%20be%20modified%201234!",
"This should be modified 1234!");
DO_TEST_DECODE ("%7E", "~");
/* tests with invalid input */
DO_TEST_DECODE ("%", "%" );
DO_TEST_DECODE ("%2", "%2");
DO_TEST_DECODE ("%0000", "")
/* UTF-8 tests */
DO_TEST_DECODE ("T%C3%a9l%c3%A9vision+%e2%82%Ac", "Télévision €" );
DO_TEST_DECODE ("T%E9l%E9vision", "T?l?vision");
DO_TEST_DECODE ("%C1%94%C3%a9l%c3%A9vision", "??élévision");
#define DO_TEST_B64( a, b ) if( !test_b64( a, b ) ) return NULL;
/* Base 64 tests */
DO_TEST_B64 ("", "") ;
DO_TEST_B64("d", "ZA==");
DO_TEST_B64("ab", "YWI=");
DO_TEST_B64("abc", "YWJj");
DO_TEST_B64 ("abcd", "YWJjZA==");
Py_INCREF( Py_None);
return Py_None;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment