Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 31E0E11BE1 for ; Mon, 21 Jul 2014 23:57:16 +0000 (UTC) Received: (qmail 12512 invoked by uid 500); 21 Jul 2014 23:57:15 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 12335 invoked by uid 500); 21 Jul 2014 23:57:15 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 11489 invoked by uid 99); 21 Jul 2014 23:57:15 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Jul 2014 23:57:15 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id D3CC09AE300; Mon, 21 Jul 2014 23:57:14 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: chewbranca@apache.org To: commits@couchdb.apache.org Date: Mon, 21 Jul 2014 23:57:21 -0000 Message-Id: In-Reply-To: <16e2756e1fe64463b44481d620de941b@git.apache.org> References: <16e2756e1fe64463b44481d620de941b@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [08/43] couchdb commit: updated refs/heads/1963-eunit-bigcouch to 424dca5 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/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/7be2a863 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/7be2a863 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/7be2a863 Branch: refs/heads/1963-eunit-bigcouch Commit: 7be2a863e6fca1352af7216e6bb03ac220bbeff1 Parents: 22a47bb Author: Alexander Shorin Authored: Sun May 18 14:35:58 2014 +0400 Committer: Russell Branca Committed: Mon Jul 21 16:37:03 2014 -0700 ---------------------------------------------------------------------- test/couchdb/couch_util_tests.erl | 35 +++++++++++++++++ test/etap/043-find-in-binary.t | 68 ---------------------------------- 2 files changed, 35 insertions(+), 68 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/7be2a863/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). http://git-wip-us.apache.org/repos/asf/couchdb/blob/7be2a863/test/etap/043-find-in-binary.t ---------------------------------------------------------------------- diff --git a/test/etap/043-find-in-binary.t b/test/etap/043-find-in-binary.t deleted file mode 100755 index dca1d9c..0000000 --- a/test/etap/043-find-in-binary.t +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env escript -%% -*- erlang -*- - -% Licensed under the Apache License, Version 2.0 (the "License"); you may not -% use this file except in compliance with the License. You may obtain a copy of -% the License at -% -% http://www.apache.org/licenses/LICENSE-2.0 -% -% Unless required by applicable law or agreed to in writing, software -% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -% License for the specific language governing permissions and limitations under -% the License. - -main(_) -> - test_util:init_code_path(), - - etap:plan(length(cases())), - case (catch test()) of - ok -> - etap:end_tests(); - Other -> - etap:diag(io_lib:format("Test died abnormally: ~p", [Other])), - etap:bail(Other) - end, - ok. - - -test() -> - lists:foreach(fun({Needle, Haystack, Result}) -> - try - Msg = io_lib:format("Looking for ~s in ~s", [Needle, Haystack]), - etap:is(couch_util:find_in_binary(Needle, Haystack), Result, Msg) - catch _T:_R -> - etap:diag("~p", [{_T, _R}]) - end - end, cases()), - ok. - - -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} - ].