diff options
author | Daniil Baturin <daniil@baturin.org> | 2015-04-26 17:49:28 +0600 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2015-04-26 17:49:28 +0600 |
commit | de448723e5a9443f5df7f367e70990c58a9a04e3 (patch) | |
tree | acf564a093b9fce649f6d4d4651364084395a176 /test | |
parent | 3891244d49d3c65ef6da6b8644cfb9097b0d51b0 (diff) | |
download | vyconf-de448723e5a9443f5df7f367e70990c58a9a04e3.tar.gz vyconf-de448723e5a9443f5df7f367e70990c58a9a04e3.zip |
Add config tree module.
Diffstat (limited to 'test')
-rw-r--r-- | test/config_tree_test.ml | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/config_tree_test.ml b/test/config_tree_test.ml new file mode 100644 index 0000000..625bd2b --- /dev/null +++ b/test/config_tree_test.ml @@ -0,0 +1,42 @@ +open OUnit2 + +module VT = Vytree +open Config_tree + +let test_set_value test_ctxt = + let node = make "root" in + let node = VT.insert node ["foo"] default_data in + let node = set_value node ["foo"] "bar" in + let data = VT.data_of_node (VT.get node ["foo"]) in + assert_equal data.values ["bar"] + +let test_get_values test_ctxt = + let node = make "root" in + let node = VT.insert node ["foo"] default_data in + let node = set_value node ["foo"] "bar" in + assert_equal (get_values node ["foo"]) ["bar"] + +let test_add_value test_ctxt = + let node = make "root" in + let node = VT.insert node ["foo"] default_data in + let node = add_value node ["foo"] "bar" in + let node = add_value node ["foo"] "baz" in + assert_equal (get_values node ["foo"]) ["bar"; "baz"] + +let test_add_value_duplicate test_ctxt = + let node = make "root" in + let node = VT.insert node ["foo"] default_data in + let node = set_value node ["foo"] "bar" in + assert_raises Duplicate_value (fun () -> add_value node ["foo"] "bar") + +let suite = + "VyConf config tree tests" >::: [ + "test_set_value" >:: test_set_value; + "test_get_values" >:: test_get_values; + "test_add_value" >:: test_add_value; + "test_add_value_duplicate" >:: test_add_value_duplicate; + ] + +let () = + run_test_tt_main suite + |