Skip to content

Instantly share code, notes, and snippets.

@Vagabond
Created January 6, 2016 03:33
Show Gist options
  • Save Vagabond/3093a70a3c897cc3a73d to your computer and use it in GitHub Desktop.
Save Vagabond/3093a70a3c897cc3a73d to your computer and use it in GitHub Desktop.
hashmap_replace_pre(S) ->
S#state.hashmap /= undefined andalso length(S#state.map) > 0.
hashmap_replace_args(S) ->
{Keys, Values} = lists:unzip(S#state.map),
[S#state.hashmap, eqc_gen:oneof(Keys),
?SUCHTHAT(X2, eqc_gen:list(eqc_gen:char()), length(X2) > 0 andalso not lists:member(X2, Values))].
hashmap_replace(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_replace_next(S, _R, [_, Key, Value]) ->
S#state{map=lists:keyreplace(Key, 1, S#state.map, {Key, Value})}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment