1 : /*
2 : * This file is part of MIN Test Framework. Copyright © 2008 Nokia Corporation
3 : * and/or its subsidiary(-ies).
4 : * Contact: Konrad Marek Zapalowicz
5 : * Contact e-mail: DG.MIN-Support@nokia.com
6 : *
7 : * This program is free software: you can redistribute it and/or modify it
8 : * under the terms of the GNU General Public License as published by the Free
9 : * Software Foundation, version 2 of the License.
10 : *
11 : * This program is distributed in the hope that it will be useful, but WITHOUT
12 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 : * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 : * more details. You should have received a copy of the GNU General Public
15 : * License along with this program. If not, see
16 : * <http://www.gnu.org/licenses/>.
17 : */
18 :
19 :
20 : /**
21 : * @file text.test
22 : * @version 0.1
23 : * @brief This file contains test for Text interface
24 : */
25 :
26 : /* ------------------------------------------------------------------------- */
27 : /* INCLUDES */
28 : #include <check.h>
29 :
30 : /* ------------------------------------------------------------------------- */
31 : /* CONSTANTS */
32 : /* None */
33 :
34 : /* ------------------------------------------------------------------------- */
35 : /* MACROS */
36 : /* None */
37 :
38 : /* ------------------------------------------------------------------------- */
39 : /* DATA TYPES */
40 : /* None */
41 :
42 : /* ------------------------------------------------------------------------- */
43 : /* LOCAL FUNCTION PROTOTYPES */
44 : /* None */
45 :
46 : /* ------------------------------------------------------------------------- */
47 : /* FORWARD DECLARATIONS */
48 : /* None */
49 :
50 : /* ------------------------------------------------------------------------- */
51 : /* STRUCTURES */
52 : /* None */
53 :
54 : /* ------------------------------------------------------------------------- */
55 : /* ==================== LOCAL FUNCTIONS ==================================== */
56 : /* None */
57 :
58 : /* ------------------------------------------------------------------------- */
59 : /* ============================= TESTS ===================================== */
60 : /* ------------------------------------------------------------------------- */
61 1 : START_TEST(test_tx_create)
62 : {
63 1 : Text* txt = tx_create(NULL);
64 1 : fail_unless(txt!=INITPTR,"Text not created");
65 1 : DELETE(txt->buf_);
66 1 : DELETE(txt);
67 : }
68 1 : END_TEST
69 : /* ------------------------------------------------------------------------- */
70 1 : START_TEST(test_tx_create2)
71 : {
72 1 : Text* txt = tx_create(NULL);
73 1 : fail_unless(txt->buf_!=INITPTR,"Text::buf_ not created");
74 1 : DELETE(txt->buf_);
75 1 : DELETE(txt);
76 : }
77 1 : END_TEST
78 : /* ------------------------------------------------------------------------- */
79 1 : START_TEST(test_tx_create3)
80 : {
81 1 : Text* txt = tx_create(NULL);
82 1 : fail_unless(txt->size_==0,"Text::size_ differs from expected %d!=%d"
83 : ,txt->size_,0);
84 1 : DELETE(txt->buf_);
85 1 : DELETE(txt);
86 : }
87 1 : END_TEST
88 : /* ------------------------------------------------------------------------- */
89 1 : START_TEST(test_tx_create4)
90 : {
91 1 : Text* txt = tx_create(NULL);
92 1 : fail_unless(txt->max_size_==MaxTextBufferSize,"Text::max_size_ differs"
93 : " from expected %d!=%d",txt->max_size_,MaxTextBufferSize);
94 1 : DELETE(txt->buf_);
95 1 : DELETE(txt);
96 : }
97 1 : END_TEST
98 : /* ------------------------------------------------------------------------- */
99 1 : START_TEST(test_tx_create5)
100 : {
101 1 : Text* txt = tx_create(NULL);
102 1 : fail_unless(strlen(txt->buf_)==0,"Text::buf_ size greater than 0");
103 1 : DELETE(txt->buf_);
104 1 : DELETE(txt);
105 : }
106 1 : END_TEST
107 : /* ------------------------------------------------------------------------- */
108 1 : START_TEST(test_tx_create6)
109 : {
110 1 : Text* txt = tx_create(INITPTR);
111 1 : fail_unless(txt!=INITPTR,"Text not created");
112 1 : DELETE(txt->buf_);
113 1 : DELETE(txt);
114 : }
115 1 : END_TEST
116 : /* ------------------------------------------------------------------------- */
117 1 : START_TEST(test_tx_create7)
118 : {
119 1 : Text* txt = tx_create(INITPTR);
120 1 : fail_unless(txt->buf_!=INITPTR,"Text::buf_ not created");
121 1 : DELETE(txt->buf_);
122 1 : DELETE(txt);
123 : }
124 1 : END_TEST
125 : /* ------------------------------------------------------------------------- */
126 1 : START_TEST(test_tx_create8)
127 : {
128 1 : Text* txt = tx_create(INITPTR);
129 1 : fail_unless(txt->size_==0,"Text::size_ differs from expected %d!=%d"
130 : ,txt->size_,0);
131 1 : DELETE(txt->buf_);
132 1 : DELETE(txt);
133 : }
134 1 : END_TEST
135 : /* ------------------------------------------------------------------------- */
136 1 : START_TEST(test_tx_create9)
137 : {
138 1 : Text* txt = tx_create(INITPTR);
139 1 : fail_unless(txt->max_size_==MaxTextBufferSize,"Text::max_size_ differs"
140 : " from expected %d!=%d",txt->max_size_,MaxTextBufferSize);
141 1 : DELETE(txt->buf_);
142 1 : DELETE(txt);
143 : }
144 1 : END_TEST
145 : /* ------------------------------------------------------------------------- */
146 1 : START_TEST(test_tx_create10)
147 : {
148 1 : Text* txt = tx_create(INITPTR);
149 1 : fail_unless(strlen(txt->buf_)==0,"Text::buf_ size greater than 0");
150 1 : DELETE(txt->buf_);
151 1 : DELETE(txt);
152 : }
153 1 : END_TEST
154 : /* ------------------------------------------------------------------------- */
155 1 : START_TEST(test_tx_create11)
156 : {
157 1 : Text* txt = tx_create("");
158 1 : fail_unless(txt!=INITPTR,"Text not created");
159 1 : DELETE(txt->buf_);
160 1 : DELETE(txt);
161 : }
162 1 : END_TEST
163 : /* ------------------------------------------------------------------------- */
164 1 : START_TEST(test_tx_create12)
165 : {
166 1 : Text* txt = tx_create("");
167 1 : fail_unless(txt->buf_!=INITPTR,"Text::buf_ not created");
168 1 : DELETE(txt->buf_);
169 1 : DELETE(txt);
170 : }
171 1 : END_TEST
172 : /* ------------------------------------------------------------------------- */
173 1 : START_TEST(test_tx_create13)
174 : {
175 1 : Text* txt = tx_create("");
176 1 : fail_unless(txt->size_==0,"Text::size_ differs from expected %d!=%d"
177 : ,txt->size_,0);
178 1 : DELETE(txt->buf_);
179 1 : DELETE(txt);
180 : }
181 1 : END_TEST
182 : /* ------------------------------------------------------------------------- */
183 1 : START_TEST(test_tx_create14)
184 : {
185 1 : Text* txt = tx_create("");
186 1 : fail_unless(txt->max_size_==MaxTextBufferSize,"Text::max_size_ differs"
187 : " from expected %d!=%d",txt->max_size_,MaxTextBufferSize);
188 1 : DELETE(txt->buf_);
189 1 : DELETE(txt);
190 : }
191 1 : END_TEST
192 : /* ------------------------------------------------------------------------- */
193 1 : START_TEST(test_tx_create15)
194 : {
195 1 : Text* txt = tx_create("");
196 1 : fail_unless(strlen(txt->buf_)==0,"Text::buf_ size greater than 0");
197 1 : DELETE(txt->buf_);
198 1 : DELETE(txt);
199 : }
200 1 : END_TEST
201 : /* ------------------------------------------------------------------------- */
202 1 : START_TEST(test_tx_create16)
203 : {
204 1 : Text* txt = tx_create("ala ma kota");
205 1 : fail_unless(strlen(txt->buf_)==11,"Text::buf_ size differs from"
206 : "expected %d!=%d",strlen(txt->buf_),11);
207 1 : DELETE(txt->buf_);
208 1 : DELETE(txt);
209 : }
210 1 : END_TEST
211 : /* ------------------------------------------------------------------------- */
212 1 : START_TEST(test_tx_create17)
213 : {
214 1 : Text* txt = tx_create("ala ma kota");
215 1 : fail_unless(txt->size_==11,"Text::size_ differs from expected %d!=%d"
216 : ,txt->size_,11);
217 1 : DELETE(txt->buf_);
218 1 : DELETE(txt);
219 : }
220 1 : END_TEST
221 : /* ------------------------------------------------------------------------- */
222 1 : START_TEST(test_tx_create18)
223 : {
224 1 : Text* txt = tx_create("ala ma kota");
225 1 : fail_unless(txt->max_size_==MaxTextBufferSize,"Text::max_size_ differs"
226 : " from expected %d!=%d",txt->max_size_,MaxTextBufferSize);
227 1 : DELETE(txt->buf_);
228 1 : DELETE(txt);
229 : }
230 1 : END_TEST
231 : /* ------------------------------------------------------------------------- */
232 1 : START_TEST(test_tx_create19)
233 : {
234 : Text* txt = tx_create("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
235 : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
236 1 : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
237 1 : fail_unless(strlen(txt->buf_)==128,"Text::buf_ size differs"
238 : " from expected %d!=%d",strlen(txt->buf_),128);
239 1 : DELETE(txt->buf_);
240 1 : DELETE(txt);
241 : }
242 1 : END_TEST
243 : /* ------------------------------------------------------------------------- */
244 1 : START_TEST(test_tx_create20)
245 : {
246 : Text* txt = tx_create("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
247 : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
248 1 : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
249 1 : fail_unless(txt->size_==128,"Text::size_ differs"
250 : " from expected %d!=%d",txt->size_,128);
251 1 : DELETE(txt->buf_);
252 1 : DELETE(txt);
253 : }
254 1 : END_TEST
255 : /* ------------------------------------------------------------------------- */
256 1 : START_TEST(test_tx_create21)
257 : {
258 : Text* txt = tx_create("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
259 : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
260 1 : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
261 1 : fail_unless(txt->max_size_==2*MaxTextBufferSize,"Text::max_size_ differs"
262 : " from expected %d!=%d",txt->max_size_,MaxTextBufferSize*2);
263 1 : DELETE(txt->buf_);
264 1 : DELETE(txt);
265 : }
266 1 : END_TEST
267 : /* ------------------------------------------------------------------------- */
268 1 : START_TEST(test_tx_destroy)
269 : {
270 1 : tx_destroy(INITPTR);
271 : }
272 1 : END_TEST
273 : /* ------------------------------------------------------------------------- */
274 1 : START_TEST(test_tx_destroy2)
275 : {
276 1 : Text* txt = INITPTR;
277 1 : tx_destroy(&txt);
278 : }
279 1 : END_TEST
280 : /* ------------------------------------------------------------------------- */
281 1 : START_TEST(test_tx_destroy3)
282 : {
283 1 : Text* txt = tx_create("ala ma kota");
284 1 : tx_destroy(&txt);
285 1 : fail_unless(txt==INITPTR,"Pointer not reset after deletion");
286 : }
287 1 : END_TEST
288 : /* ------------------------------------------------------------------------- */
289 1 : START_TEST(test_tx_append)
290 : {
291 1 : tx_append(INITPTR,INITPTR);
292 : }
293 1 : END_TEST
294 : /* ------------------------------------------------------------------------- */
295 1 : START_TEST(test_tx_append2)
296 : {
297 1 : Text* txt1 = tx_create("ala ma kota");
298 1 : tx_append(txt1,INITPTR);
299 : }
300 1 : END_TEST
301 : /* ------------------------------------------------------------------------- */
302 1 : START_TEST(test_tx_append3)
303 : {
304 1 : Text* txt1 = tx_create("ala ma kota");
305 1 : tx_append(INITPTR,txt1);
306 : }
307 1 : END_TEST
308 : /* ------------------------------------------------------------------------- */
309 1 : START_TEST(test_tx_append4)
310 : {
311 1 : Text* txt1 = tx_create("ala ma kota");
312 1 : Text* txt2 = tx_create(" kot ma ale");
313 :
314 1 : tx_append(txt1,txt2);
315 :
316 1 : fail_unless(strcmp(txt1->buf_,"ala ma kota kot ma ale")==0
317 : ,"result differs from expected: [%s]!=[%s]"
318 : ,txt1->buf_,"ala ma kota kot ma ale");
319 :
320 1 : tx_destroy(&txt1);
321 1 : tx_destroy(&txt2);
322 : }
323 1 : END_TEST
324 : /* ------------------------------------------------------------------------- */
325 1 : START_TEST(test_tx_append5)
326 : {
327 1 : Text* txt1 = tx_create("ala ma kota");
328 1 : Text* txt2 = tx_create(" kot ma ale");
329 :
330 1 : tx_append(txt1,txt2);
331 :
332 1 : fail_unless(txt1->size_==22
333 : ,"result differs from expected: %d!=%d"
334 : ,txt1->size_,22);
335 :
336 1 : tx_destroy(&txt1);
337 1 : tx_destroy(&txt2);
338 : }
339 1 : END_TEST
340 : /* ------------------------------------------------------------------------- */
341 1 : START_TEST(test_tx_append6)
342 : {
343 : char* data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
344 : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
345 1 : "aaaaaaaaaaaaaaaaa";
346 1 : Text* txt1 = tx_create(data);
347 1 : Text* txt2 = tx_create(" bbbb");
348 :
349 1 : tx_append(txt1,txt2);
350 :
351 1 : fail_unless(txt1->size_==132
352 : ,"result differs from expected: %d!=%d"
353 : ,txt1->size_,132);
354 :
355 1 : tx_destroy(&txt1);
356 1 : tx_destroy(&txt2);
357 : }
358 1 : END_TEST
359 : /* ------------------------------------------------------------------------- */
360 1 : START_TEST(test_tx_append7)
361 : {
362 : char* data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
363 : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
364 1 : "aaaaaaaaaaaaaaaaa";
365 1 : Text* txt1 = tx_create(data);
366 1 : Text* txt2 = tx_create(" bbbb");
367 :
368 1 : tx_append(txt1,txt2);
369 :
370 1 : fail_unless(strcmp(txt1->buf_,"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
371 : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
372 : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
373 : "aaaaaaaaaaa bbbb")==0
374 : ,"result differs from expected [%s]",txt1->buf_ );
375 :
376 1 : tx_destroy(&txt1);
377 1 : tx_destroy(&txt2);
378 : }
379 1 : END_TEST
380 : /* ------------------------------------------------------------------------- */
381 1 : START_TEST(test_tx_append8)
382 : {
383 : char* data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
384 : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
385 1 : "aaaaaaaaaaaaaaaaa";
386 1 : Text* txt1 = tx_create(data);
387 1 : Text* txt2 = tx_create(" bbbb");
388 :
389 1 : tx_append(txt1,txt2);
390 :
391 1 : fail_unless(txt1->max_size_==256
392 : ,"result differs from expected: %d!=%d"
393 : ,txt1->max_size_,256);
394 :
395 1 : tx_destroy(&txt1);
396 1 : tx_destroy(&txt2);
397 : }
398 1 : END_TEST
399 : /* ------------------------------------------------------------------------- */
400 1 : START_TEST(test_tx_copy)
401 : {
402 1 : tx_copy(INITPTR,INITPTR);
403 : }
404 1 : END_TEST
405 : /* ------------------------------------------------------------------------- */
406 1 : START_TEST(test_tx_copy2)
407 : {
408 1 : Text* txt = tx_create("ala ma kota");
409 1 : tx_copy(txt,INITPTR);
410 1 : tx_destroy(&txt);
411 : }
412 1 : END_TEST
413 : /* ------------------------------------------------------------------------- */
414 1 : START_TEST(test_tx_copy3)
415 : {
416 1 : Text* txt = tx_create("ala ma kota");
417 1 : tx_copy(INITPTR,txt);
418 1 : tx_destroy(&txt);
419 : }
420 1 : END_TEST
421 : /* ------------------------------------------------------------------------- */
422 1 : START_TEST(test_tx_copy4)
423 : {
424 1 : Text* txt = tx_create("ala ma kota");
425 1 : tx_copy(txt,txt);
426 1 : tx_destroy(&txt);
427 : }
428 1 : END_TEST
429 : /* ------------------------------------------------------------------------- */
430 1 : START_TEST(test_tx_copy5)
431 : {
432 1 : Text* txt1 = tx_create("ala ma kota");
433 1 : Text* txt2 = tx_create("kot ma ale");
434 1 : tx_copy(txt1,txt2);
435 :
436 1 : fail_unless( strcmp(txt1->buf_,txt2->buf_) == 0
437 : , "Result differs from expected [%s] != [%s]"
438 : , txt1->buf_,txt2->buf_ );
439 :
440 1 : tx_destroy(&txt1);
441 1 : tx_destroy(&txt2);
442 : }
443 1 : END_TEST
444 : /* ------------------------------------------------------------------------- */
445 1 : START_TEST(test_tx_copy6)
446 : {
447 1 : Text* txt1 = tx_create("ala ma kota");
448 1 : Text* txt2 = tx_create("kot ma ale");
449 1 : tx_copy(txt1,txt2);
450 :
451 1 : fail_unless( txt1->size_ == txt2->size_
452 : , "Result differs from expected %d != %d"
453 : , txt1->size_,txt2->size_ );
454 :
455 1 : tx_destroy(&txt1);
456 1 : tx_destroy(&txt2);
457 : }
458 1 : END_TEST
459 : /* ------------------------------------------------------------------------- */
460 1 : START_TEST(test_tx_copy7)
461 : {
462 1 : Text* txt1 = tx_create("ala ma kota");
463 1 : Text* txt2 = tx_create("kot ma ale");
464 1 : tx_copy(txt1,txt2);
465 :
466 1 : fail_unless( txt1->max_size_ == txt2->max_size_
467 : , "Result differs from expected %d != %d"
468 : , txt1->max_size_,txt2->max_size_ );
469 :
470 1 : tx_destroy(&txt1);
471 1 : tx_destroy(&txt2);
472 : }
473 1 : END_TEST
474 : /* ------------------------------------------------------------------------- */
475 1 : START_TEST(test_tx_copy8)
476 : {
477 1 : Text* txt1 = tx_create("");
478 1 : Text* txt2 = tx_create("kot ma ale");
479 1 : tx_copy(txt1,txt2);
480 :
481 1 : fail_unless( strcmp(txt1->buf_,txt2->buf_) == 0
482 : , "Result differs from expected [%s] != [%s]"
483 : , txt1->buf_,txt2->buf_ );
484 :
485 1 : tx_destroy(&txt1);
486 1 : tx_destroy(&txt2);
487 : }
488 1 : END_TEST
489 : /* ------------------------------------------------------------------------- */
490 1 : START_TEST(test_tx_copy9)
491 : {
492 1 : Text* txt1 = tx_create("ala ma kota");
493 1 : Text* txt2 = tx_create("");
494 1 : tx_copy(txt1,txt2);
495 :
496 1 : fail_unless( strcmp(txt1->buf_,txt2->buf_) == 0
497 : , "Result differs from expected [%s] != [%s]"
498 : , txt1->buf_,txt2->buf_ );
499 :
500 1 : tx_destroy(&txt1);
501 1 : tx_destroy(&txt2);
502 : }
503 1 : END_TEST
504 : /* ------------------------------------------------------------------------- */
505 1 : START_TEST(test_tx_copy10)
506 : {
507 1 : Text* txt1 = tx_create("ala ma kota");
508 1 : Text* txt2 = tx_create("");
509 1 : tx_copy(txt1,txt2);
510 :
511 1 : fail_unless( txt1->size_==txt2->size_
512 : , "Result differs from expected %d != %d"
513 : , txt1->size_,txt2->size_ );
514 :
515 1 : tx_destroy(&txt1);
516 1 : tx_destroy(&txt2);
517 : }
518 1 : END_TEST
519 : /* ------------------------------------------------------------------------- */
520 1 : START_TEST(test_tx_c_append)
521 : {
522 1 : tx_c_append(INITPTR,INITPTR);
523 : }
524 1 : END_TEST
525 : /* ------------------------------------------------------------------------- */
526 1 : START_TEST(test_tx_c_append2)
527 : {
528 1 : Text* txt1 = tx_create("ala ma kota");
529 1 : tx_c_append(txt1,INITPTR);
530 : }
531 1 : END_TEST
532 : /* ------------------------------------------------------------------------- */
533 1 : START_TEST(test_tx_c_append3)
534 : {
535 1 : char* data = "ala ma kota";
536 1 : tx_c_append(INITPTR,data);
537 : }
538 1 : END_TEST
539 : /* ------------------------------------------------------------------------- */
540 1 : START_TEST(test_tx_c_append4)
541 : {
542 1 : Text* txt1 = tx_create("ala ma kota");
543 1 : char* data = " kot ma ale";
544 :
545 1 : tx_c_append(txt1,data);
546 :
547 1 : fail_unless(strcmp(txt1->buf_,"ala ma kota kot ma ale")==0
548 : ,"result differs from expected: [%s]!=[%s]"
549 : ,txt1->buf_,"ala ma kota kot ma ale");
550 :
551 1 : tx_destroy(&txt1);
552 : }
553 1 : END_TEST
554 : /* ------------------------------------------------------------------------- */
555 1 : START_TEST(test_tx_c_append5)
556 : {
557 1 : Text* txt1 = tx_create("ala ma kota");
558 1 : char* data = " kot ma ale";
559 :
560 1 : tx_c_append(txt1,data);
561 :
562 1 : fail_unless(txt1->size_==22
563 : ,"result differs from expected: %d!=%d"
564 : ,txt1->size_,22);
565 :
566 1 : tx_destroy(&txt1);
567 : }
568 1 : END_TEST
569 : /* ------------------------------------------------------------------------- */
570 1 : START_TEST(test_tx_c_append6)
571 : {
572 : char* data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
573 : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
574 1 : "aaaaaaaaaaaaaaaaa";
575 1 : char* data2= " bbbb";
576 1 : Text* txt1 = tx_create(data);
577 :
578 1 : tx_c_append(txt1,data2);
579 :
580 1 : fail_unless(txt1->size_==132
581 : ,"result differs from expected: %d!=%d"
582 : ,txt1->size_,132);
583 :
584 1 : tx_destroy(&txt1);
585 : }
586 1 : END_TEST
587 : /* ------------------------------------------------------------------------- */
588 1 : START_TEST(test_tx_c_append7)
589 : {
590 : char* data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
591 : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
592 1 : "aaaaaaaaaaaaaaaaa";
593 1 : char* data2= " bbbb";
594 1 : Text* txt1 = tx_create(data);
595 :
596 1 : tx_c_append(txt1,data2);
597 :
598 1 : fail_unless(strcmp(txt1->buf_,"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
599 : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
600 : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
601 : "aaaaaaaaaaa bbbb")==0
602 : ,"result differs from expected [%s]",txt1->buf_ );
603 :
604 1 : tx_destroy(&txt1);
605 : }
606 1 : END_TEST
607 : /* ------------------------------------------------------------------------- */
608 1 : START_TEST(test_tx_c_append8)
609 : {
610 : char* data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
611 : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
612 1 : "aaaaaaaaaaaaaaaaa";
613 1 : char* data2= " bbbb";
614 1 : Text* txt1 = tx_create(data);
615 :
616 1 : tx_c_append(txt1,data2);
617 :
618 1 : fail_unless(txt1->max_size_==256
619 : ,"result differs from expected: %d!=%d"
620 : ,txt1->max_size_,256);
621 :
622 1 : tx_destroy(&txt1);
623 : }
624 1 : END_TEST
625 : /* ------------------------------------------------------------------------- */
626 1 : START_TEST(test_tx_c_copy)
627 : {
628 1 : tx_c_copy(INITPTR,INITPTR);
629 : }
630 1 : END_TEST
631 : /* ------------------------------------------------------------------------- */
632 1 : START_TEST(test_tx_c_copy2)
633 : {
634 1 : Text* txt = tx_create("ala ma kota");
635 1 : tx_c_copy(txt,INITPTR);
636 1 : tx_destroy(&txt);
637 : }
638 1 : END_TEST
639 : /* ------------------------------------------------------------------------- */
640 1 : START_TEST(test_tx_c_copy3)
641 : {
642 1 : char* data = "ala ma kota";
643 1 : tx_c_copy(INITPTR,data);
644 : }
645 1 : END_TEST
646 : /* ------------------------------------------------------------------------- */
647 1 : START_TEST(test_tx_c_copy4)
648 : {
649 1 : Text* txt1 = tx_create("ala ma kota");
650 1 : char* data = "kot ma ale";
651 1 : tx_c_copy(txt1,data);
652 :
653 1 : fail_unless( strcmp(txt1->buf_,data) == 0
654 : , "Result differs from expected [%s] != [%s]"
655 : , txt1->buf_,data );
656 :
657 1 : tx_destroy(&txt1);
658 : }
659 1 : END_TEST
660 : /* ------------------------------------------------------------------------- */
661 1 : START_TEST(test_tx_c_copy5)
662 : {
663 1 : Text* txt1 = tx_create("ala ma kota");
664 1 : char* data = "kot ma ale";
665 1 : tx_c_copy(txt1,data);
666 :
667 1 : fail_unless( txt1->size_ == strlen(data)
668 : , "Result differs from expected %d != %d"
669 : , txt1->size_,strlen(data) );
670 :
671 1 : tx_destroy(&txt1);
672 : }
673 1 : END_TEST
674 : /* ------------------------------------------------------------------------- */
675 1 : START_TEST(test_tx_c_copy6)
676 : {
677 1 : Text* txt1 = tx_create("ala ma kota");
678 1 : char* data = "kot ma ale";
679 1 : tx_c_copy(txt1,data);
680 :
681 1 : fail_unless( txt1->max_size_ == 128
682 : , "Result differs from expected %d != %d"
683 : , txt1->max_size_,128 );
684 :
685 1 : tx_destroy(&txt1);
686 : }
687 1 : END_TEST
688 : /* ------------------------------------------------------------------------- */
689 1 : START_TEST(test_tx_c_copy7)
690 : {
691 1 : Text* txt1 = tx_create("");
692 1 : char* data = "kot ma ale";
693 1 : tx_c_copy(txt1,data);
694 :
695 1 : fail_unless( strcmp(txt1->buf_,data) == 0
696 : , "Result differs from expected [%s] != [%s]"
697 : , txt1->buf_,data );
698 :
699 1 : tx_destroy(&txt1);
700 : }
701 1 : END_TEST
702 : /* ------------------------------------------------------------------------- */
703 1 : START_TEST(test_tx_c_copy8)
704 : {
705 1 : Text* txt1 = tx_create("ala ma kota");
706 1 : char* data = "";
707 1 : tx_c_copy(txt1,data);
708 :
709 1 : fail_unless( strcmp(txt1->buf_,data) == 0
710 : , "Result differs from expected [%s] != [%s]"
711 : , txt1->buf_,data );
712 :
713 1 : tx_destroy(&txt1);
714 : }
715 1 : END_TEST
716 : /* ------------------------------------------------------------------------- */
717 1 : START_TEST(test_tx_c_copy9)
718 : {
719 1 : Text* txt1 = tx_create("ala ma kota");
720 1 : char* data = tx_create("");
721 1 : tx_c_copy(txt1,data);
722 :
723 1 : fail_unless( txt1->size_==strlen(data)
724 : , "Result differs from expected %d != %d"
725 : , txt1->size_,strlen(data) );
726 :
727 1 : tx_destroy(&txt1);
728 : }
729 1 : END_TEST
730 : /* ------------------------------------------------------------------------- */
731 1 : START_TEST(test_tx_back_trim)
732 : {
733 1 : Text *txt = tx_create("ala ");
734 1 : tx_back_trim(txt," ");
735 1 : fail_unless(strcmp(txt->buf_,"ala")==0
736 : ,"Result differs from expected [%s]",txt->buf_);
737 1 : tx_destroy(&txt);
738 : }
739 1 : END_TEST
740 : /* ------------------------------------------------------------------------- */
741 1 : START_TEST(test_tx_back_trim2)
742 : {
743 1 : Text *txt = tx_create("ala ");
744 1 : tx_back_trim(txt,"\n");
745 1 : fail_unless(strcmp(txt->buf_,"ala ")==0
746 : ,"Result differs from expected [%s]",txt->buf_);
747 1 : tx_destroy(&txt);
748 : }
749 1 : END_TEST
750 : /* ------------------------------------------------------------------------- */
751 1 : START_TEST(test_tx_back_trim3)
752 : {
753 1 : Text *txt = tx_create("ala \n");
754 1 : tx_back_trim(txt,"\n ");
755 1 : fail_unless(strcmp(txt->buf_,"ala")==0
756 : ,"Result differs from expected [%s]",txt->buf_);
757 1 : tx_destroy(&txt);
758 : }
759 1 : END_TEST
760 : /* ------------------------------------------------------------------------- */
761 1 : START_TEST(test_tx_c_prepend)
762 : {
763 1 : Text *txt = tx_create(" ma kota");
764 1 : tx_c_prepend(txt,"ala");
765 1 : fail_unless(strcmp(txt->buf_,"ala ma kota") == 0);
766 : }
767 1 : END_TEST
768 : /* ------------------------------------------------------------------------- */
769 1 : START_TEST(test_tx_int_append)
770 : {
771 1 : Text *txt = tx_create("");
772 1 : tx_int_append(txt,"",100);
773 1 : fail_unless(strcmp(txt->buf_,"100")==0
774 : ,"Result differs from expected [%s]",txt->buf_);
775 1 : tx_destroy(&txt);
776 : }
777 1 : END_TEST
778 : /* ------------------------------------------------------------------------- */
779 : /* ------------------------------------------------------------------------- */
780 : /* ------------------------------------------------------------------------- */
781 : /* ------------------------------------------------------------------------- */
782 : /* ========================== FUNCTIONS ==================================== */
783 : /* ------------------------------------------------------------------------- */
784 : Suite* text_suite()
785 65 : {
786 65 : Suite * s = suite_create ("text");
787 :
788 : /* Core test case */
789 65 : TCase *tc_core = tcase_create ("Core");
790 :
791 : /* tx_create */
792 65 : tcase_add_test (tc_core, test_tx_create);
793 65 : tcase_add_test (tc_core, test_tx_create2);
794 65 : tcase_add_test (tc_core, test_tx_create3);
795 65 : tcase_add_test (tc_core, test_tx_create4);
796 65 : tcase_add_test (tc_core, test_tx_create5);
797 65 : tcase_add_test (tc_core, test_tx_create6);
798 65 : tcase_add_test (tc_core, test_tx_create7);
799 65 : tcase_add_test (tc_core, test_tx_create8);
800 65 : tcase_add_test (tc_core, test_tx_create9);
801 65 : tcase_add_test (tc_core, test_tx_create10);
802 65 : tcase_add_test (tc_core, test_tx_create11);
803 65 : tcase_add_test (tc_core, test_tx_create12);
804 65 : tcase_add_test (tc_core, test_tx_create13);
805 65 : tcase_add_test (tc_core, test_tx_create14);
806 65 : tcase_add_test (tc_core, test_tx_create15);
807 65 : tcase_add_test (tc_core, test_tx_create16);
808 65 : tcase_add_test (tc_core, test_tx_create17);
809 65 : tcase_add_test (tc_core, test_tx_create18);
810 65 : tcase_add_test (tc_core, test_tx_create19);
811 65 : tcase_add_test (tc_core, test_tx_create20);
812 65 : tcase_add_test (tc_core, test_tx_create21);
813 :
814 : /* tx_destroy */
815 65 : tcase_add_test (tc_core, test_tx_destroy);
816 65 : tcase_add_test (tc_core, test_tx_destroy2);
817 65 : tcase_add_test (tc_core, test_tx_destroy3);
818 :
819 : /* tx_append */
820 65 : tcase_add_test (tc_core, test_tx_append);
821 65 : tcase_add_test (tc_core, test_tx_append2);
822 65 : tcase_add_test (tc_core, test_tx_append3);
823 65 : tcase_add_test (tc_core, test_tx_append4);
824 65 : tcase_add_test (tc_core, test_tx_append5);
825 65 : tcase_add_test (tc_core, test_tx_append6);
826 65 : tcase_add_test (tc_core, test_tx_append7);
827 65 : tcase_add_test (tc_core, test_tx_append8);
828 :
829 : /* tx_copy */
830 65 : tcase_add_test (tc_core, test_tx_copy);
831 65 : tcase_add_test (tc_core, test_tx_copy2);
832 65 : tcase_add_test (tc_core, test_tx_copy3);
833 65 : tcase_add_test (tc_core, test_tx_copy4);
834 65 : tcase_add_test (tc_core, test_tx_copy5);
835 65 : tcase_add_test (tc_core, test_tx_copy6);
836 65 : tcase_add_test (tc_core, test_tx_copy7);
837 65 : tcase_add_test (tc_core, test_tx_copy8);
838 65 : tcase_add_test (tc_core, test_tx_copy9);
839 65 : tcase_add_test (tc_core, test_tx_copy10);
840 :
841 : /* tx_c_append */
842 65 : tcase_add_test (tc_core, test_tx_c_append);
843 65 : tcase_add_test (tc_core, test_tx_c_append2);
844 65 : tcase_add_test (tc_core, test_tx_c_append3);
845 65 : tcase_add_test (tc_core, test_tx_c_append4);
846 65 : tcase_add_test (tc_core, test_tx_c_append5);
847 65 : tcase_add_test (tc_core, test_tx_c_append6);
848 65 : tcase_add_test (tc_core, test_tx_c_append7);
849 65 : tcase_add_test (tc_core, test_tx_c_append8);
850 :
851 : /* tx_c_copy */
852 65 : tcase_add_test (tc_core, test_tx_c_copy);
853 65 : tcase_add_test (tc_core, test_tx_c_copy2);
854 65 : tcase_add_test (tc_core, test_tx_c_copy3);
855 65 : tcase_add_test (tc_core, test_tx_c_copy4);
856 65 : tcase_add_test (tc_core, test_tx_c_copy5);
857 65 : tcase_add_test (tc_core, test_tx_c_copy6);
858 65 : tcase_add_test (tc_core, test_tx_c_copy7);
859 65 : tcase_add_test (tc_core, test_tx_c_copy8);
860 65 : tcase_add_test (tc_core, test_tx_c_copy9);
861 :
862 : /* tx_back_trim */
863 65 : tcase_add_test (tc_core, test_tx_back_trim);
864 65 : tcase_add_test (tc_core, test_tx_back_trim2);
865 65 : tcase_add_test (tc_core, test_tx_back_trim3);
866 :
867 : /* tx_c_prepend */
868 65 : tcase_add_test (tc_core, test_tx_c_prepend);
869 :
870 : /* tx_int_append */
871 65 : tcase_add_test (tc_core, test_tx_int_append);
872 :
873 65 : suite_add_tcase (s, tc_core);
874 :
875 65 : return s;
876 : }
877 : /* ------------------------------------------------------------------------- */
878 : int text_tests()
879 65 : {
880 65 : int number_failed = 0;
881 65 : Suite * s = text_suite ();
882 65 : SRunner * sr = srunner_create (s);
883 65 : srunner_run_all(sr, CK_NORMAL);
884 1 : number_failed = srunner_ntests_failed(sr);
885 1 : srunner_free(sr);
886 1 : return number_failed;
887 : }
888 : /* ------------------------------------------------------------------------- */
889 : /* End of file */
|