aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hipe/test/bs_SUITE_data/bs_bugs_R08.erl
blob: 7b62a17cfb7cf0bd3374c59e571e95d447b22401 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
%% -*- erlang-indent-level: 2 -*-
%%-------------------------------------------------------------------
%% When executing this in R8 (and compiled with R8) the result was
%% {ok,[148,129,0,0]} but should be {ok,[145,148,113,129,0,0,0,0]}
%% Thanks to Kenneth Lundin for sending this to us.
%%-------------------------------------------------------------------

-module(bs_bugs_R08).

-export([test/0]).

test() ->
  List = [145,148,113,129,0,0,0,0],
  {ok, List} = msisdn_internal_storage(<<145,148,113,129,0,0,0,0>>, []),
  ok.

%% msisdn_internal_storage/3
%% Convert MSISDN binary to internal datatype (TBCD-octet list)

msisdn_internal_storage(<<>>, MSISDN) ->
  {ok, lists:reverse(MSISDN)};
msisdn_internal_storage(<<2#11111111:8,_Rest/binary>>, MSISDN) ->
  {ok, lists:reverse(MSISDN)};
msisdn_internal_storage(<<2#1111:4,DigitN:4,_Rest/binary>>, MSISDN) when
    DigitN < 10 ->
  {ok, lists:reverse([(DigitN bor 2#11110000)|MSISDN])};
msisdn_internal_storage(<<DigitNplus1:4,DigitN:4,Rest/binary>>, MSISDN) when
    DigitNplus1 < 10, DigitN < 10 ->
  NewMSISDN = [((DigitNplus1 bsl 4) bor DigitN)|MSISDN],
  msisdn_internal_storage(Rest, NewMSISDN);
msisdn_internal_storage(_Rest, _MSISDN) ->
  {fault}. %% Mandatory IE incorrect