Last active
January 6, 2016 02:56
-
-
Save Vagabond/c5a69c8c034d20a286e6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| hashmap_get_pre(S) -> | |
| S#state.hashmap /= undefined. | |
| hashmap_get_args(S = #state{map=Map}) when length(Map) > 0 -> | |
| [S#state.hashmap, | |
| eqc_gen:oneof([eqc_gen:elements(element(1, lists:unzip(S#state.map))), | |
| ?SUCHTHAT(X1, eqc_gen:list(eqc_gen:char()), length(X1) > 0)])]; | |
| hashmap_get_args(S) -> | |
| [S#state.hashmap, ?SUCHTHAT(X1, eqc_gen:list(eqc_gen:char()), length(X1) > 0)]. | |
| hashmap_get(Hashmap, Key) -> | |
| Val = eqc_c:alloc({ptr, unsigned_char}), | |
| ValLen = eqc_c:alloc(unsigned_int), | |
| KeyStr = eqc_c:create_string(Key), | |
| R = hashmap:hashmap_get(Hashmap, KeyStr, length(Key), Val, ValLen), | |
| Len = eqc_c:deref(ValLen), | |
| RealVal = case Len of | |
| 0 -> | |
| undefined; | |
| _ -> | |
| eqc_c:read_array(eqc_c:deref(Val), Len) | |
| end, | |
| eqc_c:free(Val), | |
| eqc_c:free(ValLen), | |
| eqc_c:free(KeyStr), | |
| {R, Len, RealVal}. | |
| hashmap_get_post(S, [_, Key], {R, Len, Val}) -> | |
| case lists:keyfind(Key, 1, S#state.map) of | |
| {Key, Value} -> | |
| R == 0 andalso {Key, Val} == {Key, Value}; | |
| false -> | |
| R == 1 andalso Len == 0 | |
| end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment