This file contains 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
-module(kv_db_tests). | |
-include_lib("eunit/include/eunit.hrl"). | |
all_test_() -> | |
[?_assertEqual([], kv_db:new()), | |
put_one_test(), | |
put_same_key_test(), | |
put_new_key_test(), | |
get_non_existent_key_test(), |
This file contains 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
-module(kv_db_tests). | |
-include_lib("eunit/include/eunit.hrl"). | |
new_test_() -> | |
?_assertEqual([], kv_db:new()). | |
new_test() -> | |
?assertEqual([], kv_db:new()). |
This file contains 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
-module(kv_db_tests). | |
-include_lib("eunit/include/eunit.hrl"). | |
new_test_() -> | |
?_test(?assertEqual([], kv_db:new())). | |
new_test() -> | |
?assertEqual([], kv_db:new()). |
This file contains 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
-module(kv_db_tests). | |
-include_lib("eunit/include/eunit.hrl"). | |
new_test_() -> | |
fun () -> ?assertEqual([], kv_db:new()) end. | |
new_test() -> | |
?assertEqual([], kv_db:new()). |
This file contains 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
-module(kv_db_server). | |
-behaviour(gen_server). | |
-export([init/1, handle_call/3, handle_cast/2, | |
handle_info/2, terminate/2, code_change/3]). | |
-export([start/0, put/2, get/1, delete/1, ls/0]). | |
% public functions |
This file contains 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
-module(kv_db_server). | |
-behaviour(gen_server). | |
-export([init/1, handle_call/3, handle_cast/2, | |
handle_info/2, terminate/2, code_change/3]). | |
-export([start/0]). | |
% public functions |
This file contains 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
% Defines the module. | |
-module(kv_db_server). | |
% Makes the module implement the gen_server behaviour. | |
-behaviour(gen_server). | |
% Exports the required gen_server callbacks. | |
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, | |
terminate/2, code_change/3]). |
This file contains 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
-module(kv_db). | |
-type db() :: []. | |
-type results() :: nonempty_list({Key::atom(), Value::term()}). | |
-type err() :: {'error', string()}. | |
-export_type([db/0, results/0, err/0]). | |
-export([new/0, put/3, get/2, delete/2]). | |
-spec new() -> db(). |
This file contains 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
-module(kv_db_tests). | |
-include_lib("eunit/include/eunit.hrl"). | |
new_test() -> | |
?assertEqual([], kv_db:new()). | |
put_test() -> | |
Db0 = kv_db:new(), | |
Db1 = kv_db:put(color, "red", Db0), |
This file contains 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
-module(kv_db_tests). | |
-include_lib("eunit/include/eunit.hrl"). | |
new_test() -> | |
?assertEqual([], kv_db:new()). |
NewerOlder