1af69d88dSmrg/*
2af69d88dSmrg * Copyright © 2011 Intel Corporation
3af69d88dSmrg *
4af69d88dSmrg * Permission is hereby granted, free of charge, to any person obtaining a
5af69d88dSmrg * copy of this software and associated documentation files (the "Software"),
6af69d88dSmrg * to deal in the Software without restriction, including without limitation
7af69d88dSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8af69d88dSmrg * and/or sell copies of the Software, and to permit persons to whom the
9af69d88dSmrg * Software is furnished to do so, subject to the following conditions:
10af69d88dSmrg *
11af69d88dSmrg * The above copyright notice and this permission notice (including the next
12af69d88dSmrg * paragraph) shall be included in all copies or substantial portions of the
13af69d88dSmrg * Software.
14af69d88dSmrg *
15af69d88dSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16af69d88dSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17af69d88dSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19af69d88dSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20af69d88dSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21af69d88dSmrg * IN THE SOFTWARE.
22af69d88dSmrg *
23af69d88dSmrg * Authors:
24af69d88dSmrg *    Eric Anholt <eric@anholt.net>
25af69d88dSmrg */
26af69d88dSmrg
278a1362adSmaya#undef NDEBUG
288a1362adSmaya
29af69d88dSmrg#include <stdlib.h>
30af69d88dSmrg#include <stdio.h>
31af69d88dSmrg#include <string.h>
32af69d88dSmrg#include <assert.h>
33af69d88dSmrg#include "hash_table.h"
34af69d88dSmrg
35af69d88dSmrgint
36af69d88dSmrgmain(int argc, char **argv)
37af69d88dSmrg{
38af69d88dSmrg   struct hash_table *ht;
39af69d88dSmrg   char *str1 = strdup("test1");
40af69d88dSmrg   char *str2 = strdup("test1");
41af69d88dSmrg   struct hash_entry *entry;
42af69d88dSmrg
4301e04c3fSmrg   (void) argc;
4401e04c3fSmrg   (void) argv;
4501e04c3fSmrg
46af69d88dSmrg   assert(str1 != str2);
47af69d88dSmrg
487ec681f3Smrg   ht = _mesa_hash_table_create(NULL, _mesa_hash_string,
4901e04c3fSmrg                                _mesa_key_string_equal);
50af69d88dSmrg
5101e04c3fSmrg   _mesa_hash_table_insert(ht, str1, str1);
5201e04c3fSmrg   _mesa_hash_table_insert(ht, str2, str2);
53af69d88dSmrg
5401e04c3fSmrg   entry = _mesa_hash_table_search(ht, str1);
55af69d88dSmrg   assert(entry);
56af69d88dSmrg   assert(entry->data == str2);
57af69d88dSmrg
58af69d88dSmrg   _mesa_hash_table_remove(ht, entry);
59af69d88dSmrg
6001e04c3fSmrg   entry = _mesa_hash_table_search(ht, str1);
61af69d88dSmrg   assert(!entry);
62af69d88dSmrg
63af69d88dSmrg   _mesa_hash_table_destroy(ht, NULL);
64af69d88dSmrg   free(str1);
65af69d88dSmrg   free(str2);
66af69d88dSmrg
67af69d88dSmrg   return 0;
68af69d88dSmrg}
69