Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add the tests.

  • Loading branch information...
commit 8583a58850d8acc92b8fa9b2730d51bb072235c0 1 parent cb627ca
@arcusfelis arcusfelis authored
View
2  src/i18n_search.erl
@@ -67,7 +67,7 @@ match_all(Searcher, String) ->
-spec test(i18n_searcher(), i18n_string()) -> boolean().
test(Searcher, String) ->
- ?TRY_ATOM(?IM:search_index(Searcher, String)).
+ ?TRY_ATOM(?IM:search_test(Searcher, String)).
-spec match(i18n_searcher(), i18n_string()) -> i18n_string() | 'false'.
View
74 src/i18n_search_tests.erl
@@ -0,0 +1,74 @@
+% vim: set filetype=erlang shiftwidth=4 tabstop=4 expandtab tw=80:
+
+%%% =====================================================================
+%%% Copyright 2011 Uvarov Michael
+%%%
+%%% 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.
+%%%
+%%% $Id$
+%%%
+%%% @copyright 2010-2011 Michael Uvarov
+%%% @author Michael Uvarov <freeakk@gmail.com>
+%%% =====================================================================
+
+%%% @private
+-module(i18n_search_tests).
+-include_lib("i18n/include/i18n.hrl").
+
+
+-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
+-include_lib("triq/include/triq.hrl").
+
+
+
+index_test_() ->
+ C = i18n_collation:open(),
+ S = i18n_search:open(C, ?ISTR("test")),
+ F = fun i18n_search:index/2,
+ [?_assertEqual(F(S, ?ISTR("open test")), [{5, 4}])
+ ,?_assertEqual(F(S, ?ISTR("test test")), [{0, 4}, {5, 4}])
+ ].
+
+match_test_() ->
+ C = i18n_collation:open(),
+ S = i18n_search:open(C, ?ISTR("test")),
+ F = fun i18n_search:match/2,
+ [?_assertEqual(F(S, ?ISTR("open test")), ?ISTR("test"))
+ ].
+
+nocase_match_test_() ->
+ C = i18n_collation:open([primary]),
+ S = i18n_search:open(C, ?ISTR("test")),
+ F = fun i18n_search:match/2,
+ [?_assertEqual(F(S, ?ISTR("open Test")), ?ISTR("Test"))
+ ].
+
+nocase_match_all_test_() ->
+ C = i18n_collation:open([primary]),
+ S = i18n_search:open(C, ?ISTR("test")),
+ F = fun i18n_search:match_all/2,
+ [?_assertEqual(F(S, ?ISTR("test and Test")), [?ISTR("test"), ?ISTR("Test")])
+ ].
+
+nocase_test_() ->
+ C = i18n_collation:open([primary]),
+ S = i18n_search:open(C, ?ISTR("test")),
+ F = fun i18n_search:test/2,
+ [?_assert(F(S, ?ISTR("Test")))
+ ,?_assert(F(S, ?ISTR("test")))
+ ,?_assert(F(S, ?ISTR("it is a test")))
+ ,?_assert(not F(S, ?ISTR("it is an error")))
+ ].
+
+-endif.
View
44 src/i18n_transliteration_tests.erl
@@ -0,0 +1,44 @@
+% vim: set filetype=erlang shiftwidth=4 tabstop=4 expandtab tw=80:
+
+%%% =====================================================================
+%%% Copyright 2011 Uvarov Michael
+%%%
+%%% 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.
+%%%
+%%% $Id$
+%%%
+%%% @copyright 2010-2011 Michael Uvarov
+%%% @author Michael Uvarov <freeakk@gmail.com>
+%%% =====================================================================
+
+%%% @private
+-module(i18n_transliteration_tests).
+-include_lib("i18n/include/i18n.hrl").
+
+
+-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
+-include_lib("triq/include/triq.hrl").
+
+
+
+trans_test() ->
+
+ lists:foreach(fun(Id) ->
+ T = i18n_transliteration:open(Id),
+ i18n_transliteration:do(T, ?ISTR("test")),
+ ok
+ end, i18n_transliteration:available_ids()).
+
+
+-endif.
View
1  start-dev.sh
@@ -7,6 +7,7 @@ make
exec erl -pa $PWD/ebin edit $PWD/deps/*/ebin \
-boot start_sasl \
-sname i18n \
+ -s i18n
# -s i18n_nif init \
# -s reloader
Please sign in to comment.
Something went wrong with that request. Please try again.