From 412894bfc8781ce6b7ebc20780e4c6806c2a0040 Mon Sep 17 00:00:00 2001 From: Siteshwar Vashisht Date: Sat, 18 Feb 2012 21:04:09 +0530 Subject: [PATCH] Removed tests for hash_table_t from fish_tests.cpp --- env.cpp | 23 ++------ fish_tests.cpp | 143 ------------------------------------------------- 2 files changed, 4 insertions(+), 162 deletions(-) diff --git a/env.cpp b/env.cpp index 936729b93..791ff4528 100644 --- a/env.cpp +++ b/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 + Function used with to insert keys of one table into a set::set */ -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 *names = (std::set *)aux; - const wchar_t *keyStr = (const wchar_t *)key; - names->insert(keyStr); - } -} - static void add_key_to_string_set(const std::map &envs, std::set &strSet) { std::map::const_iterator iter; diff --git a/fish_tests.cpp b/fish_tests.cpp index 278b99c13..d39745b55 100644 --- a/fish_tests.cpp +++ b/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 8 ) - say( L"Hashtable uses %f microseconds per element at size %d", - ((double)(t2-t1))/(1<