You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2015/09/09 19:48:53 UTC

[3/3] config commit: updated refs/heads/master to b2ecd0d

Add tests for to_integer and to_float


Project: http://git-wip-us.apache.org/repos/asf/couchdb-config/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-config/commit/b2ecd0d4
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-config/tree/b2ecd0d4
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-config/diff/b2ecd0d4

Branch: refs/heads/master
Commit: b2ecd0d47a776256956ce045123423494ff85e8e
Parents: 6df0b68
Author: ILYA Khlopotov <ii...@ca.ibm.com>
Authored: Wed Sep 9 08:21:37 2015 -0700
Committer: ILYA Khlopotov <ii...@ca.ibm.com>
Committed: Wed Sep 9 08:21:37 2015 -0700

----------------------------------------------------------------------
 src/config.erl | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-config/blob/b2ecd0d4/src/config.erl
----------------------------------------------------------------------
diff --git a/src/config.erl b/src/config.erl
index cf36d2b..2156a7b 100644
--- a/src/config.erl
+++ b/src/config.erl
@@ -367,3 +367,25 @@ debug_config() ->
             ok
     end.
 
+-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
+
+to_integer_test() ->
+    ?assertEqual(1, to_integer(1)),
+    ?assertEqual(1, to_integer(<<"1">>)),
+    ?assertEqual(1, to_integer("1")),
+    ?assertEqual(-1, to_integer("-01")),
+    ?assertEqual(0, to_integer("-0")),
+    ?assertEqual(0, to_integer("+0")),
+    ok.
+
+to_float_test() ->
+    ?assertEqual(1.0, to_float(1)),
+    ?assertEqual(1.0, to_float(<<"1.0">>)),
+    ?assertEqual(1.0, to_float("1.0")),
+    ?assertEqual(-1.1, to_float("-01.1")),
+    ?assertEqual(0.0, to_float("-0.0")),
+    ?assertEqual(0.0, to_float("+0.0")),
+    ok.
+
+-endif.