mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-20 03:42:44 +08:00
Removed tests for hash_table_t from fish_tests.cpp
This commit is contained in:
parent
aad6e5648b
commit
412894bfc8
23
env.cpp
23
env.cpp
|
@ -197,12 +197,12 @@ static wcstring dyn_var;
|
|||
|
||||
/**
|
||||
Variable used by env_get_names to communicate auxiliary information
|
||||
to add_key_to_hash
|
||||
to add_key_to_string_set
|
||||
*/
|
||||
static int get_names_show_exported;
|
||||
/**
|
||||
Variable used by env_get_names to communicate auxiliary information
|
||||
to add_key_to_hash
|
||||
to add_key_to_string_set
|
||||
*/
|
||||
static int get_names_show_unexported;
|
||||
|
||||
|
@ -982,7 +982,7 @@ int env_set( const wchar_t *key,
|
|||
|
||||
/**
|
||||
Attempt to remove/free the specified key/value pair from the
|
||||
specified hash table.
|
||||
specified map.
|
||||
|
||||
\return zero if the variable was not found, non-zero otherwise
|
||||
*/
|
||||
|
@ -1473,23 +1473,8 @@ void env_pop()
|
|||
|
||||
|
||||
/**
|
||||
Function used with hash_foreach to insert keys of one table into
|
||||
a set::set<wcstring>
|
||||
Function used with to insert keys of one table into a set::set<wcstring>
|
||||
*/
|
||||
static void add_key_to_string_set( void *key,
|
||||
void *data,
|
||||
void *aux )
|
||||
{
|
||||
var_entry_t *e = (var_entry_t *)data;
|
||||
if( ( e->exportv && get_names_show_exported) ||
|
||||
( !e->exportv && get_names_show_unexported) )
|
||||
{
|
||||
std::set<wcstring> *names = (std::set<wcstring> *)aux;
|
||||
const wchar_t *keyStr = (const wchar_t *)key;
|
||||
names->insert(keyStr);
|
||||
}
|
||||
}
|
||||
|
||||
static void add_key_to_string_set(const std::map<wcstring, var_entry_t*> &envs, std::set<wcstring> &strSet)
|
||||
{
|
||||
std::map<wcstring, var_entry_t*>::const_iterator iter;
|
||||
|
|
143
fish_tests.cpp
143
fish_tests.cpp
|
@ -107,103 +107,6 @@ static void err( const wchar_t *blah, ... )
|
|||
wprintf( L"\n" );
|
||||
}
|
||||
|
||||
/**
|
||||
Hash function for pointers
|
||||
*/
|
||||
static int hash_func( void *data )
|
||||
{
|
||||
/* srand( (int)data );
|
||||
return rand();
|
||||
*/
|
||||
int foo = (int)(long)data;
|
||||
return 127*((foo^0xefc7e214)) ^(foo<<11);
|
||||
}
|
||||
|
||||
/**
|
||||
Pointer hash comparison function
|
||||
*/
|
||||
static int compare_func( void *key1, void *key2 )
|
||||
{
|
||||
return key1==key2;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Hashtable test
|
||||
*/
|
||||
static int hash_test( long elements )
|
||||
{
|
||||
long i;
|
||||
int res=1;
|
||||
|
||||
hash_table_t h;
|
||||
|
||||
hash_init( &h, hash_func, compare_func );
|
||||
|
||||
for( i=1; i< elements+1; i++ )
|
||||
{
|
||||
hash_put( &h, (void*)i, (void*)(100l-i) );
|
||||
}
|
||||
|
||||
for( i=1; i< elements+1; i++ )
|
||||
{
|
||||
if( (long)hash_get( &h, (void*)i ) != (100l-i) )
|
||||
{
|
||||
err( L"Key %d gave data %d, expected data %d",
|
||||
i,
|
||||
(long)hash_get( &h, (void*)i ),
|
||||
100l-i );
|
||||
res = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( hash_get_count( &h ) != elements )
|
||||
{
|
||||
err( L"Table holds %d elements, should hold %d elements",
|
||||
hash_get_count( &h ),
|
||||
elements );
|
||||
res = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
for( i=1; i<elements+1; i+=2 )
|
||||
{
|
||||
hash_remove( &h, (void*)i, 0, 0 );
|
||||
|
||||
}
|
||||
|
||||
if( hash_get_count( &h ) != ((elements)/2) )
|
||||
{
|
||||
err( L"Table contains %d elements, should contain %d elements",
|
||||
hash_get_count( &h ),
|
||||
elements/2 );
|
||||
res = 0;
|
||||
}
|
||||
|
||||
for( i=1; i<elements+1; i++ )
|
||||
{
|
||||
if( hash_contains( &h, (void*)i) != (i+1l)%2l )
|
||||
{
|
||||
if( i%2 )
|
||||
err( L"Key %d remains, should be deleted",
|
||||
i );
|
||||
else
|
||||
err( L"Key %d does not exist",
|
||||
i );
|
||||
res = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
hash_destroy( &h );
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Stringbuffer test
|
||||
*/
|
||||
|
@ -239,51 +142,6 @@ static void sb_test()
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
Performs all tests of the util library
|
||||
*/
|
||||
static void test_util()
|
||||
{
|
||||
int i;
|
||||
|
||||
say( L"Testing utility library" );
|
||||
|
||||
for( i=0; i<18; i++ )
|
||||
{
|
||||
long t1, t2;
|
||||
t1 = get_time();
|
||||
hash_test( 1<<i );
|
||||
t2 = get_time();
|
||||
if( i > 8 )
|
||||
say( L"Hashtable uses %f microseconds per element at size %d",
|
||||
((double)(t2-t1))/(1<<i),
|
||||
1<<i );
|
||||
}
|
||||
|
||||
sb_test();
|
||||
|
||||
|
||||
/*
|
||||
int i;
|
||||
for( i=2; i<10000000; i*=2 )
|
||||
{
|
||||
|
||||
printf( "%d", i );
|
||||
|
||||
t1 = get_time();
|
||||
|
||||
if(!hash_test(i))
|
||||
exit(0);
|
||||
|
||||
t2 = get_time();
|
||||
|
||||
printf( " %d\n", (t2-t1)/i );
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Test the escaping/unescaping code by escaping/unescaping random
|
||||
|
@ -868,7 +726,6 @@ int main( int argc, char **argv )
|
|||
reader_init();
|
||||
env_init();
|
||||
|
||||
test_util();
|
||||
test_escape();
|
||||
test_convert();
|
||||
test_tok();
|
||||
|
|
Loading…
Reference in New Issue
Block a user