Browse Source

Modified Dictionary to test better, use size_t

windows-imgui
Macoy Madson 8 months ago
parent
commit
8a55f0f4f5
  1. 11
      src/Dictionary.cake

11
src/Dictionary.cake

@ -15,7 +15,7 @@
;; Automatically strdup and free string keys
(def-c-function-alias strdict-use-key-strdup sh_new_strdup)
(def-c-function-alias strdict-length shlen)
(def-c-function-alias strdict-length shlenu)
;; (dict (* <your Key Value type>) &return size_t)
(def-c-function-alias strdict-free shfree)
@ -168,14 +168,17 @@
(strdict-ptr-or-default-at my-dictionary "bad value"))
(fprintf stderr "Expected to get default (not found) entry back, got %p (array[-1] = %p).
Length: %ld\n"
returned-entry (addr (at -1 my-dictionary)) (strdict-length my-dictionary)))
returned-entry (addr (at -1 my-dictionary)) (strdict-length my-dictionary))
(unless (= returned-entry (addr (at -1 my-dictionary)))
(return 1)))
(scope
(var returned-entry (* complex-dictionary-entry)
(strdict-ptr-at my-dictionary "bad value"))
(fprintf stderr "Expected to get null back, got %p (array[-1] = %p). Length: %ld\n"
returned-entry (addr (at -1 my-dictionary)) (strdict-length my-dictionary))
(when returned-entry
(fprintf stderr "Expected to get null back, got %p (array[-1] = %p). Length: %ld\n"
returned-entry (addr (at -1 my-dictionary)) (strdict-length my-dictionary))))
(return 1)))
(each-in-array items i
(free (type-cast (field (at i items) key) (* void))))

Loading…
Cancel
Save