Skip to content

Instantly share code, notes, and snippets.

@Vagabond
Last active January 6, 2016 02:47
Show Gist options
  • Save Vagabond/cdfc5ed8e14b1a67a6ac to your computer and use it in GitHub Desktop.
Save Vagabond/cdfc5ed8e14b1a67a6ac to your computer and use it in GitHub Desktop.
hashmap_put_pre(S) ->
S#state.hashmap /= undefined.
hashmap_put_args(S) ->
{Keys, _} = lists:unzip(S#state.map),
[S#state.hashmap,
?SUCHTHAT(X1, eqc_gen:list(eqc_gen:char()), length(X1) > 0 andalso not lists:member(X1, Keys)),
?SUCHTHAT(X2, eqc_gen:list(eqc_gen:char()), length(X2) > 0)].
hashmap_put(Hashmap, Key, Value) ->
KeyStr = eqc_c:create_string(Key),
ValueStr = eqc_c:create_string(Value),
R = hashmap:hashmap_put(Hashmap, KeyStr, length(Key), ValueStr, length(Value)),
eqc_c:free(KeyStr),
eqc_c:free(ValueStr),
R.
hashmap_put_next(S, _R, [_, Key, Value]) ->
S#state{map=[{Key, Value} | S#state.map]}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment