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
20
#include "ei_runner.h"
23
* Purpose: Tests the ei_print() function.
28
send_printed3(char* format, char* p1, char* p2, int fl)
31
char fn[100], * tmp = getenv("temp");
33
int n, index = 0, ver;
38
ei_x_format(&x, format, *(float*)p1, *(float*)p2);
40
ei_x_format(&x, format, p1, p2);
45
if (tmp == NULL) tmp = "/tmp";
48
strcat(fn, "/ei_print_test.txt");
50
ei_decode_version(x.buff, &index, &ver);
51
n = ei_print_term(f, x.buff, &index);
52
fseek(f, 0, SEEK_SET);
58
ei_x_format(&x, "~s", b);
65
send_printed(char* format)
67
send_printed3(format, NULL, NULL, 0);
71
send_printed2(char* format, char* p)
73
send_printed3(format, p, NULL, 0);
76
static void send_printed3f(char* format, float f1, float f2)
78
send_printed3(format, (char*)&f1, (char*)&f2, 1);
86
send_printed("'abc'");
87
send_printed("'Abc'");
88
send_printed("'ab@c'");
89
send_printed("'The rain in Spain stays mainly in the plains'");
95
send_printed(" abcdefghijklmnopq ");
97
send_printed2("~a", "");
98
send_printed2("~a", "a");
99
send_printed2("~a", "A");
100
send_printed2("~a", "abc");
101
send_printed2("~a", "Abc");
102
send_printed2("~a", "ab@c");
103
send_printed2("~a", "The rain in Spain stays mainly in the plains");
105
send_printed2("~a", "a");
106
send_printed2("~a", "ab");
107
send_printed2("~a", "abc");
108
send_printed2("~a","ab@c");
109
send_printed2("~a", " abcdefghijklmnopq ");
119
send_printed("{a, b}");
120
send_printed("{a, b, c}");
122
send_printed("{[]}");
123
send_printed("{[], []}");
124
send_printed("{[], a, b, c}");
125
send_printed("{[], a, [], b, c}");
126
send_printed("{[], a, '', b, c}");
139
send_printed("[a, b]");
140
send_printed("[a, b, c]");
142
send_printed("[[]]");
143
send_printed("[[], []]");
144
send_printed("[[], a, b, c]");
145
send_printed("[[], a, [], b, c]");
146
send_printed("[[], a, '', b, c]");
147
send_printed("[[x, 2], [y, 3], [z, 4]]");
149
/* more tests needed */
150
send_printed3f("[{pi, ~f}, {'cos(70)', ~f}]",
151
(float)3.1415, (float)0.34202);
152
send_printed3f("[[pi, ~f], ['cos(70)', ~f]]",
153
(float)3.1415, (float)0.34202);
155
send_printed2("[~i]", (char*)-1);
163
send_printed("\"\n\"");
164
send_printed("\"\r\n\"");
165
send_printed("\"a\"");
166
send_printed("\"A\"");
167
send_printed("\"0\"");
168
send_printed("\"9\"");
169
send_printed("\"The rain in Spain stays mainly in the plains\"");
170
send_printed("\" abcdefghijklmnopq \"");