You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ch...@apache.org on 2014/08/11 22:19:40 UTC

[08/50] couch commit: updated refs/heads/1963-eunit-bigcouch to 6845303

Port 043-find-in-binary.t etap test suite to eunit

It been merged into couch_util_tests suite.


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

Branch: refs/heads/1963-eunit-bigcouch
Commit: 7053887dcb174b3fa7a502060f3bf4af881cc59d
Parents: 16bd6ce
Author: Alexander Shorin <kx...@apache.org>
Authored: Sun May 18 14:35:58 2014 +0400
Committer: Russell Branca <ch...@apache.org>
Committed: Mon Aug 11 13:07:39 2014 -0700

----------------------------------------------------------------------
 test/couchdb/couch_util_tests.erl | 35 ++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/7053887d/test/couchdb/couch_util_tests.erl
----------------------------------------------------------------------
diff --git a/test/couchdb/couch_util_tests.erl b/test/couchdb/couch_util_tests.erl
index 53e53c6..8e24e72 100644
--- a/test/couchdb/couch_util_tests.erl
+++ b/test/couchdb/couch_util_tests.erl
@@ -99,3 +99,38 @@ verify_test() ->
     ?assert(couch_util:verify(<<"ahBase3r">>, <<"ahBase3r">>)),
     ?assertNot(couch_util:verify(<<"ahBase3rX">>, <<"ahBase3r">>)),
     ?assertNot(couch_util:verify(nil, <<"ahBase3r">>)).
+
+find_in_binary_test_() ->
+    Cases = [
+        {<<"foo">>, <<"foobar">>, {exact, 0}},
+        {<<"foo">>, <<"foofoo">>, {exact, 0}},
+        {<<"foo">>, <<"barfoo">>, {exact, 3}},
+        {<<"foo">>, <<"barfo">>, {partial, 3}},
+        {<<"f">>, <<"fobarfff">>, {exact, 0}},
+        {<<"f">>, <<"obarfff">>, {exact, 4}},
+        {<<"f">>, <<"obarggf">>, {exact, 6}},
+        {<<"f">>, <<"f">>, {exact, 0}},
+        {<<"f">>, <<"g">>, not_found},
+        {<<"foo">>, <<"f">>, {partial, 0}},
+        {<<"foo">>, <<"g">>, not_found},
+        {<<"foo">>, <<"">>, not_found},
+        {<<"fofo">>, <<"foofo">>, {partial, 3}},
+        {<<"foo">>, <<"gfobarfo">>, {partial, 6}},
+        {<<"foo">>, <<"gfobarf">>, {partial, 6}},
+        {<<"foo">>, <<"gfobar">>, not_found},
+        {<<"fog">>, <<"gbarfogquiz">>, {exact, 4}},
+        {<<"ggg">>, <<"ggg">>, {exact, 0}},
+        {<<"ggg">>, <<"ggggg">>, {exact, 0}},
+        {<<"ggg">>, <<"bggg">>, {exact, 1}},
+        {<<"ggg">>, <<"bbgg">>, {partial, 2}},
+        {<<"ggg">>, <<"bbbg">>, {partial, 3}},
+        {<<"ggg">>, <<"bgbggbggg">>, {exact, 6}},
+        {<<"ggg">>, <<"bgbggb">>, not_found}
+    ],
+    lists:map(
+        fun({Needle, Haystack, Result}) ->
+            Msg = lists:flatten(io_lib:format("Looking for ~s in ~s",
+                                              [Needle, Haystack])),
+            {Msg, ?_assertMatch(Result,
+                                couch_util:find_in_binary(Needle, Haystack))}
+        end, Cases).