4
%% Copyright Ericsson AB 2001-2009. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
7
%% Version 1.1, (the "License"); you may not use this file except in
8
%% compliance with the License. You should have received a copy of the
9
%% Erlang Public License along with this software. If not, it can be
10
%% retrieved online at http://www.erlang.org/.
12
%% Software distributed under the License is distributed on an "AS IS"
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
%% the License for the specific language governing rights and limitations
21
-module(ei_format_SUITE).
23
-include("test_server.hrl").
24
-include("ei_format_SUITE_data/ei_format_test_cases.hrl").
34
-import(runner, [get_term/1]).
36
%% This test suite test the erl_format() function.
37
%% It uses the port program "ei_format_test".
46
%% Tests formatting various atoms.
49
atoms(Config) when is_list(Config) ->
50
?line P = runner:start(?atoms),
52
?line {term, ''} = get_term(P),
53
?line {term, 'a'} = get_term(P),
54
?line {term, 'A'} = get_term(P),
55
?line {term, 'abc'} = get_term(P),
56
?line {term, 'Abc'} = get_term(P),
57
?line {term, 'ab@c'} = get_term(P),
58
?line {term, 'The rain in Spain stays mainly in the plains'} =
61
?line {term, a} = get_term(P),
62
?line {term, ab} = get_term(P),
63
?line {term, abc} = get_term(P),
64
?line {term, ab@c} = get_term(P),
65
?line {term, abcdefghijklmnopq} = get_term(P),
67
?line {term, ''} = get_term(P),
68
?line {term, 'a'} = get_term(P),
69
?line {term, 'A'} = get_term(P),
70
?line {term, 'abc'} = get_term(P),
71
?line {term, 'Abc'} = get_term(P),
72
?line {term, 'ab@c'} = get_term(P),
73
?line {term, 'The rain in Spain stays mainly in the plains'} =
76
?line {term, a} = get_term(P),
77
?line {term, ab} = get_term(P),
78
?line {term, abc} = get_term(P),
79
?line {term, ab@c} = get_term(P),
80
?line {term, ' abcdefghijklmnopq '} = get_term(P),
82
?line runner:recv_eot(P),
87
%% Tests formatting various tuples
90
tuples(Config) when is_list(Config) ->
91
?line P = runner:start(?tuples),
93
?line {term, {}} = get_term(P),
94
?line {term, {a}} = get_term(P),
95
?line {term, {a, b}} = get_term(P),
96
?line {term, {a, b, c}} = get_term(P),
97
?line {term, {1}} = get_term(P),
98
?line {term, {[]}} = get_term(P),
99
?line {term, {[], []}} = get_term(P),
100
?line {term, {[], a, b, c}} = get_term(P),
101
?line {term, {[], a, [], b, c}} = get_term(P),
102
?line {term, {[], a, '', b, c}} = get_term(P),
104
?line runner:recv_eot(P),
109
%% Tests formatting various lists
112
lists(Config) when is_list(Config) ->
113
?line P = runner:start(?lists),
115
?line {term, []} = get_term(P),
116
?line {term, [a]} = get_term(P),
117
?line {term, [a, b]} = get_term(P),
118
?line {term, [a, b, c]} = get_term(P),
119
?line {term, [1]} = get_term(P),
120
?line {term, [[]]} = get_term(P),
121
?line {term, [[], []]} = get_term(P),
122
?line {term, [[], a, b, c]} = get_term(P),
123
?line {term, [[], a, [], b, c]} = get_term(P),
124
?line {term, [[], a, '', b, c]} = get_term(P),
125
?line {term, [[x, 2], [y, 3], [z, 4]]}= get_term(P),
126
?line {term, [{a,b},{c,d}]}= get_term(P),
127
%% ?line {term, [{name, 'Madonna'}, {age, 21}, {data, [{addr, "E-street", 42}]}]} =
130
?line {term, [{pi, F1}, {'cos(70)', F2}]} = get_term(P),
131
%% don't match floats directly
132
true= abs(3.1415-F1) < 0.01,
133
true= abs(0.34202-F2) < 0.01,
135
?line {term, [[pi, F3], ['cos(70)', F4]]} = get_term(P),
136
true= abs(3.1415-F3) < 0.01,
137
true= abs(0.34202-F4) < 0.01,
140
%% ?line {term, [[pi, 3.1415], [], ["cos(70)", 0.34202]]} = get_term(P),
141
?line {term, [-1]} = get_term(P),
142
?line {term, "hejsan"} = get_term(P),
145
?line Str1 = lists:duplicate(65535,$A),
146
?line Str2 = lists:duplicate(65536,$A),
147
?line {term,Str1} = get_term(P),
148
?line {term,Str2} = get_term(P),
150
?line runner:recv_eot(P),
154
format_wo_ver(suite) -> [];
155
format_wo_ver(Config) when is_list(Config) ->
156
?line P = runner:start(?format_wo_ver),
158
?line {term, [{a, "b"}, {c, 10}]} = get_term(P),
160
?line runner:recv_eot(P),