forked from OpenTelecom/kazoo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KAZOO-3891: move wnm_util:to_npan/1 calls to knm_converters:to_npan/1
- Loading branch information
Showing
7 changed files
with
121 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
%%%------------------------------------------------------------------- | ||
%%% @copyright (C) 2011-2016, 2600Hz INC | ||
%%% @doc | ||
%%% | ||
%%% | ||
%%% @end | ||
%%% @contributors | ||
%%% Pierre Fenoll | ||
%%%------------------------------------------------------------------- | ||
-module(knm_converters_test). | ||
|
||
-define(MODULE_TESTED, knm_converters). | ||
|
||
-ifdef(PROPER). | ||
-include_lib("proper/include/proper.hrl"). | ||
-endif. | ||
-include_lib("eunit/include/eunit.hrl"). | ||
|
||
%% PROPER TESTING | ||
-ifdef(PROPER). | ||
%% | ||
%%% 1000000000 | ||
%% (AAABBBCCCC, 1AAABBBCCCC) -> AAABBBCCCCCC. | ||
prop_to_npan() -> | ||
?FORALL(Number | ||
,range(2002000000,19999999999) | ||
,begin | ||
BinNum = wh_util:to_binary(Number), | ||
NPAN = ?MODULE_TESTED:to_npan(BinNum), | ||
case byte_size(BinNum) of | ||
11 -> BinNum =:= <<"1", NPAN/binary>>; | ||
_ -> NPAN =:= BinNum | ||
end | ||
end | ||
). | ||
|
||
%% %% (AAABBBCCCC, 1AAABBBCCCC) -> 1AAABBBCCCCCC. | ||
%% prop_to_1npan() -> | ||
%% ?FORALL(Number | ||
%% ,range(2002000000,19999999999) | ||
%% ,begin | ||
%% BinNum = wh_util:to_binary(Number), | ||
%% OneNPAN = ?MODULE_TESTED:to_1npan(BinNum), | ||
%% case byte_size(BinNum) of | ||
%% 11 -> OneNPAN =:= BinNum; | ||
%% _ -> OneNPAN =:= <<"1", BinNum/binary>> | ||
%% end | ||
%% end | ||
%% ). | ||
|
||
%% (AAABBBCCCC, 1AAABBBCCCC) -> +1AAABBBCCCCCC. | ||
prop_normalize() -> | ||
?FORALL(Number | ||
,range(2002000000,19999999999) | ||
,begin | ||
BinNum = wh_util:to_binary(Number), | ||
E164 = ?MODULE_TESTED:normalize(BinNum), | ||
case byte_size(BinNum) of | ||
11 -> E164 =:= <<$+, BinNum/binary>>; | ||
10 -> E164 =:= <<$+, $1, BinNum/binary>>; | ||
_ -> E164 =:= BinNum | ||
end | ||
end | ||
). | ||
|
||
proper_test_() -> | ||
{"Runs the module's PropEr tests during eunit testing", | ||
{'timeout', 15000, | ||
[ | ||
?_assertEqual([], proper:module(?MODULE, [{'max_shrinks', 0}])) | ||
]}}. | ||
|
||
-endif. | ||
|
||
%% EUNIT TESTING | ||
%% | ||
|
||
normalize_test_() -> | ||
Ns = [<<"+12234567890">>, <<"12234567890">>, <<"2234567890">>], | ||
Ans = <<"+12234567890">>, | ||
[?_assertEqual(?MODULE_TESTED:normalize(N), Ans) || N <- Ns]. | ||
|
||
to_npan_test_() -> | ||
Ns = [<<"+12234567890">>, <<"12234567890">>, <<"2234567890">>], | ||
Ans = <<"2234567890">>, | ||
[?_assertEqual(?MODULE_TESTED:to_npan(N), Ans) || N <- Ns]. | ||
|
||
%% to_1npan_test_() -> | ||
%% Ns = [<<"+12234567890">>, <<"12234567890">>, <<"2234567890">>], | ||
%% Ans = <<"12234567890">>, | ||
%% [?_assertEqual(?MODULE_TESTED:to_1npan(N), Ans) || N <- Ns]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters