You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/07/31 23:10:14 UTC
[23/30] bear commit: updated refs/heads/import-master to 5f99806
dont take the log of a negative number dummy
Project: http://git-wip-us.apache.org/repos/asf/couchdb-bear/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-bear/commit/6c19d6a2
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-bear/tree/6c19d6a2
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-bear/diff/6c19d6a2
Branch: refs/heads/import-master
Commit: 6c19d6a2ee031512fca9916dd7cca2fc7ea2a38e
Parents: bb739b2
Author: Joe Williams <jo...@github.com>
Authored: Tue Nov 5 13:03:57 2013 -0800
Committer: Joe Williams <jo...@github.com>
Committed: Tue Nov 5 13:03:57 2013 -0800
----------------------------------------------------------------------
src/bear.erl | 2 ++
test/bear_test.erl | 10 ++++++++++
2 files changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-bear/blob/6c19d6a2/src/bear.erl
----------------------------------------------------------------------
diff --git a/src/bear.erl b/src/bear.erl
index d46aa8a..3feb0bc 100644
--- a/src/bear.erl
+++ b/src/bear.erl
@@ -373,6 +373,8 @@ math_log(0) ->
1;
math_log(0.0) ->
1.0;
+math_log(X) when X < 0 ->
+ 0; % it's not possible to take a log of a negative number, return 0
math_log(X) ->
math:log(X).
http://git-wip-us.apache.org/repos/asf/couchdb-bear/blob/6c19d6a2/test/bear_test.erl
----------------------------------------------------------------------
diff --git a/test/bear_test.erl b/test/bear_test.erl
index fc37c6b..5b2b4e1 100644
--- a/test/bear_test.erl
+++ b/test/bear_test.erl
@@ -244,6 +244,16 @@ full_subset_test() ->
Stats = bear:get_statistics(bear:test_values()),
match_values2(Stats).
+negative_test() ->
+ %% make sure things don't blow up with a negative value
+ Values = [1,-1,-2,3,3,4,5,6,7],
+ [{min, -2}] = bear:get_statistics_subset(Values, [min]).
+
+negative2_test() ->
+ %% make sure things don't blow up with a negative value
+ Values = [-1,-1,-2,-2,-3,-5,-6,-10],
+ [{min, -10}] = bear:get_statistics_subset(Values, [min]).
+
match_values([H|T]) ->
Res = bear:get_statistics_subset(bear:test_values(), [mk_item(H)]),
Res = [H],