couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kocol...@apache.org
Subject [1/2] couch commit: updated refs/heads/master to 331f811
Date Tue, 30 Jun 2015 15:37:54 GMT
Repository: couchdb-couch
Updated Branches:
  refs/heads/master c2ef37211 -> 331f8110b


Add a convenience macro for "equal to" test

This macro preserves the expressiveness of ?assertEqual but uses ==
instead of =:=. Useful for situations where the test involves numbers
that may be converted between types (e.g. 1 == 1.0).


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

Branch: refs/heads/master
Commit: 306d2e2df54fa9406adf1022c4d250040b90e42a
Parents: 04312dc
Author: Adam Kocoloski <adam@cloudant.com>
Authored: Mon Jun 29 16:24:32 2015 -0400
Committer: Adam Kocoloski <adam@cloudant.com>
Committed: Mon Jun 29 16:24:32 2015 -0400

----------------------------------------------------------------------
 include/couch_eunit.hrl | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/306d2e2d/include/couch_eunit.hrl
----------------------------------------------------------------------
diff --git a/include/couch_eunit.hrl b/include/couch_eunit.hrl
index bd37ef9..7c23b50 100644
--- a/include/couch_eunit.hrl
+++ b/include/couch_eunit.hrl
@@ -58,6 +58,23 @@
         lists:flatten(io_lib:format("~p~p~p", [A, B, C]))
     end).
 
+%% Like assertEqual, but using == instead of =:=
+-ifndef(assertEquiv).
+-define(assertEquiv(Expect, Expr),
+	((fun (__X) ->
+        case (Expr) of
+        __V when __V == __X -> ok;
+        __Y -> erlang:error({assertEquiv_failed,
+				      [{module, ?MODULE},
+				       {line, ?LINE},
+				       {expression, (??Expr)},
+				       {expected, __X},
+				       {value, __Y}]})
+	    end
+	  end)(Expect))).
+-endif.
+-define(_assertEquiv(Expect, Expr), ?_test(?assertEquiv(Expect, Expr))).
+
 %% Borrowed from https://github.com/richcarl/eunit/blob/master/include/eunit.hrl#L200-L219
 %% TODO: get rid of this once R14* is no longer supported
 -ifndef(assertNotMatch).


Mime
View raw message