universe@691: /* universe@691: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. universe@691: * universe@691: * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved. universe@691: * universe@691: * Redistribution and use in source and binary forms, with or without universe@691: * modification, are permitted provided that the following conditions are met: universe@691: * universe@691: * 1. Redistributions of source code must retain the above copyright universe@691: * notice, this list of conditions and the following disclaimer. universe@691: * universe@691: * 2. Redistributions in binary form must reproduce the above copyright universe@691: * notice, this list of conditions and the following disclaimer in the universe@691: * documentation and/or other materials provided with the distribution. universe@691: * universe@691: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" universe@691: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE universe@691: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE universe@691: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE universe@691: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR universe@691: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF universe@691: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS universe@691: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN universe@691: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) universe@691: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE universe@691: * POSSIBILITY OF SUCH DAMAGE. universe@691: */ universe@691: universe@691: #include "test_map_generics.h" universe@691: #include "cx/hash_map.h" universe@691: universe@691: CxMap *test_map_generics_step_1(CxAllocator const * allocator) { universe@691: CxMap *map = cxHashMapCreate(allocator, sizeof(cxstring), 0); universe@691: universe@691: cxMapPut(map, "test", "test"); universe@692: cxMapPut(map, cx_mutstr("foo"), "bar"); universe@691: cxMapPut(map, cx_str("hallo"), "welt"); universe@691: universe@691: return map; universe@691: } universe@691: universe@691: void test_map_generics_step_2(CxMap *map) { universe@691: // note: we don't have a destructor here, so remove and detach are the same universe@691: cxMapRemove(map, cx_str("test")); universe@694: char const* hallo = "hallo"; universe@694: cxMapDetach(map, hallo); universe@691: cxMapPut(map, cx_hash_key_str("key"), "value"); universe@691: } universe@691: universe@691: void test_map_generics_step_3(CxMap *map) { universe@691: void *r; universe@691: r = cxMapRemoveAndGet(map, "key"); universe@691: r = cxMapRemoveAndGet(map, cx_str("foo")); universe@691: if (r != NULL) map->size = 47; universe@691: }