Implement hope_option:validate/2
[hope.git] / test / hope_option_SUITE.erl
index 8789d3d..af1e12e 100644 (file)
@@ -9,11 +9,13 @@
 %% Test cases
 -export(
     [ t_of_result/1
+    , t_of_undefined/1
     , t_put/1
     , t_get/1
     , t_map/1
     , t_iter/1
     , t_pipe/1
+    , t_validate/1
     ]).
 
 
@@ -31,11 +33,13 @@ all() ->
 groups() ->
     Tests =
         [ t_of_result
+        , t_of_undefined
         , t_put
         , t_get
         , t_map
         , t_iter
         , t_pipe
+        , t_validate
         ],
     Properties = [parallel],
     [ {?GROUP, Properties, Tests}
@@ -88,3 +92,18 @@ t_pipe(_Cfg) ->
     none      = hope_option:pipe(Steps, 1),
     none      = hope_option:pipe(Steps, 2),
     none      = hope_option:pipe(Steps, 3).
+
+t_of_undefined(_Cfg) ->
+    Foo = foo,
+    Bar = bar,
+    Baz = baz,
+    {some, Foo} = hope_option:of_undefined(Foo),
+    {some, Bar} = hope_option:of_undefined(Bar),
+    {some, Baz} = hope_option:of_undefined(Baz),
+    none        = hope_option:of_undefined(undefined).
+
+t_validate(_Cfg) ->
+    IsFoo = fun (X) -> X =:= foo end,
+    none = hope_option:validate(none, IsFoo),
+    none = hope_option:validate({some, bar}, IsFoo),
+    {some, foo} = hope_option:validate({some, foo}, IsFoo).
This page took 0.032044 seconds and 4 git commands to generate.