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:51 UTC

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

Repository: couchdb-config
Updated Branches:
  refs/heads/master b92ba5a19 -> b2ecd0d47


Fix 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/4f4be713
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-config/tree/4f4be713
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-config/diff/4f4be713

Branch: refs/heads/master
Commit: 4f4be7136e98b3db1489bbf39bafcae02d41692c
Parents: b92ba5a
Author: ILYA Khlopotov <ii...@ca.ibm.com>
Authored: Wed Sep 9 07:32:26 2015 -0700
Committer: ILYA Khlopotov <ii...@ca.ibm.com>
Committed: Wed Sep 9 07:32:26 2015 -0700

----------------------------------------------------------------------
 src/config.erl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-config/blob/4f4be713/src/config.erl
----------------------------------------------------------------------
diff --git a/src/config.erl b/src/config.erl
index 8e79296..4537ad2 100644
--- a/src/config.erl
+++ b/src/config.erl
@@ -75,7 +75,7 @@ to_integer(List) when is_list(List) ->
 to_integer(Int) when is_integer(Int) ->
     Int;
 to_integer(Bin) when is_binary(Bin) ->
-    binary_to_list(list_to_integer(Bin)).
+    list_to_integer(binary_to_list(Bin)).
 
 get_float(Section, Key, Default) when is_float(Default) ->
     try
@@ -97,7 +97,7 @@ to_float(Float) when is_float(Float) ->
 to_float(Int) when is_integer(Int) ->
     list_to_float(integer_to_list(Int));
 to_float(Bin) when is_binary(Bin) ->
-    binary_to_list(list_to_float(Bin)).
+    list_to_float(binary_to_list(Bin)).
 
 get_boolean(Section, Key, Default) when is_boolean(Default) ->
     try


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

Posted by rn...@apache.org.
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.


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

Posted by rn...@apache.org.
Fix to_float(Int)


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

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

----------------------------------------------------------------------
 src/config.erl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-config/blob/6df0b689/src/config.erl
----------------------------------------------------------------------
diff --git a/src/config.erl b/src/config.erl
index 4537ad2..cf36d2b 100644
--- a/src/config.erl
+++ b/src/config.erl
@@ -95,7 +95,7 @@ to_float(List) when is_list(List) ->
 to_float(Float) when is_float(Float) ->
     Float;
 to_float(Int) when is_integer(Int) ->
-    list_to_float(integer_to_list(Int));
+    list_to_float(integer_to_list(Int) ++ ".0");
 to_float(Bin) when is_binary(Bin) ->
     list_to_float(binary_to_list(Bin)).