void t_network_injection_queue_prepend() {
	network_injection_queue *q;

	q = network_injection_queue_new();
	g_assert(q);

	g_assert_cmpint(0, ==, network_injection_queue_len(q));
	network_injection_queue_prepend(q, injection_new(1, NULL));
	g_assert_cmpint(1, ==, network_injection_queue_len(q));
	network_injection_queue_prepend(q, injection_new(1, NULL));
	g_assert_cmpint(2, ==, network_injection_queue_len(q));

	network_injection_queue_free(q);
}
static int proxy_queue_add(lua_State *L, proxy_queue_add_t type) {
	GQueue *q = *(GQueue **)luaL_checkself(L);
	int resp_type = luaL_checkinteger(L, 2);
	size_t str_len;
	const char *str = luaL_checklstring(L, 3, &str_len);
	injection *inj;

	GString *query = g_string_sized_new(str_len);
	g_string_append_len(query, str, str_len);

	inj = injection_new(resp_type, query);
	inj->resultset_is_needed = FALSE;

	/* check the 4th (last) param */
	switch (luaL_opt(L, lua_istable, 4, -1)) {
	case -1:
		/* none or nil */
		break;
	case 1:
		lua_getfield(L, 4, "resultset_is_needed");
		if (lua_isnil(L, -1)) {
			/* no defined */
		} else if (lua_isboolean(L, -1)) {
			inj->resultset_is_needed = lua_toboolean(L, -1);
		} else {
			switch (type) {
			case PROXY_QUEUE_ADD_APPEND:
				return luaL_argerror(L, 4, ":append(..., { resultset_is_needed = boolean } ), is %s");
			case PROXY_QUEUE_ADD_PREPEND:
				return luaL_argerror(L, 4, ":prepend(..., { resultset_is_needed = boolean } ), is %s");
			}
		}

		lua_pop(L, 1);
		break;
	default:
		proxy_lua_dumpstack_verbose(L);
		luaL_typerror(L, 4, "table");
		break;
	}

	switch (type) {
	case PROXY_QUEUE_ADD_APPEND:
		network_injection_queue_append(q, inj);
		return 0;
	case PROXY_QUEUE_ADD_PREPEND:
		network_injection_queue_prepend(q, inj);
		return 0;
	}

	g_assert_not_reached();
}