about summary refs log blame commit diff stats
path: root/tools/expand_string_handle
blob: 0c739f65676a840a30c0a89be6358cb89e035a72 (plain) (tree)



















                                                                                            
#!/bin/sh
# Expand syntax sugar for SubX string literals and show the corresponding handle definition.
#
# The handle has a fake alloc-id; we're never going to try to reclaim global
# variables, we just sometimes need handles in them to satisfy type constraints.

INPUT=$(cat)
echo "    0x11/imm32/alloc-id:fake:payload"
echo "    # \"$INPUT\""

# print length in bytes
printf "    0x%x/imm32/size\n" $(echo -n $INPUT |wc -c)

# print ascii codes for each character in hex
echo -n "   "
for c in $(echo "$INPUT" |sed -e 's/./& /g')
do
  echo -n " 0x$(printf '%x' "'$c")/$c"
done
echo
> void returns_commands(void** state) { callbacks_init(); PluginCommand* command1 = malloc(sizeof(PluginCommand)); command1->command_name = strdup("command1"); callbacks_add_command("plugin1", command1); PluginCommand* command2 = malloc(sizeof(PluginCommand)); command2->command_name = strdup("command2"); callbacks_add_command("plugin1", command2); PluginCommand* command3 = malloc(sizeof(PluginCommand)); command3->command_name = strdup("command3"); callbacks_add_command("plugin2", command3); GList* names = plugins_get_command_names(); assert_true(g_list_length(names) == 3); gboolean foundCommand1 = FALSE; gboolean foundCommand2 = FALSE; gboolean foundCommand3 = FALSE; GList* curr = names; while (curr) { if (g_strcmp0(curr->data, "command1") == 0) { foundCommand1 = TRUE; } if (g_strcmp0(curr->data, "command2") == 0) { foundCommand2 = TRUE; } if (g_strcmp0(curr->data, "command3") == 0) { foundCommand3 = TRUE; } curr = g_list_next(curr); } assert_true(foundCommand1 && foundCommand2 && foundCommand3); g_list_free(names); //TODO: why does this make the test fail? //callbacks_close(); }