14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 #include <e32test.h> |
|
20 #include <charconv.h> |
19 #include <charconv.h> |
21 #include <gdi.h> |
20 #include <gdi.h> |
22 #include <conpics.h> |
21 #include <conpics.h> |
23 #include <txtrich.h> |
22 #include <txtrich.h> |
24 #include <apadef.h> |
23 #include <apadef.h> |
25 |
24 |
26 #include "TXTPLAIN.H" |
25 #include "TXTPLAIN.H" |
27 #include "TxtWriter.h" |
26 #include "TxtWriter.h" |
|
27 #include "TETextDefect.h" |
|
28 |
|
29 LOCAL_D CTestStep *pTestStep = NULL; |
|
30 #define test(cond) \ |
|
31 { \ |
|
32 TBool __bb = (cond); \ |
|
33 pTestStep->TEST(__bb); \ |
|
34 if (!__bb) \ |
|
35 { \ |
|
36 ERR_PRINTF1(_L("ERROR: Test Failed")); \ |
|
37 User::Leave(1); \ |
|
38 } \ |
|
39 } |
|
40 #define test2(cond, line) \ |
|
41 { \ |
|
42 TBool __bb = (cond); \ |
|
43 pTestStep->TEST(__bb); \ |
|
44 if (!__bb) \ |
|
45 { \ |
|
46 ERR_PRINTF2(_L("Line %d, ERROR: Test Failed"), line); \ |
|
47 User::Leave(1); \ |
|
48 } \ |
|
49 } |
|
50 #undef INFO_PRINTF1 |
|
51 #undef INFO_PRINTF2 |
|
52 #undef ERR_PRINTF1 |
|
53 #undef ERR_PRINTF2 |
|
54 #undef ERR_PRINTF3 |
|
55 // copy from tefexportconst.h |
|
56 #define INFO_PRINTF1(p1) pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1)) |
|
57 #define INFO_PRINTF2(p1, p2) pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2)) |
|
58 #define ERR_PRINTF1(p1) pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1)) |
|
59 #define ERR_PRINTF2(p1, p2) pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2)) |
|
60 #define ERR_PRINTF3(p1, p2, p3) pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3)) ; |
|
61 |
28 |
62 |
29 //Used for supressing warning in OOM tests |
63 //Used for supressing warning in OOM tests |
30 #define __UNUSED_VAR(var) var = var |
64 #define __UNUSED_VAR(var) var = var |
31 |
65 |
32 // this fixes a MSVC link warning |
66 // this fixes a MSVC link warning |
33 #ifdef __VC32__ |
67 #ifdef __VC32__ |
34 #pragma comment (linker, "/opt:noref") |
68 #pragma comment (linker, "/opt:noref") |
35 #endif |
69 #endif |
36 |
70 |
37 _LIT(KTestName, "Start of Tests..."); |
71 _LIT(KTestName, "Start of Tests..."); |
38 RTest theTest(KTestName); |
|
39 |
72 |
40 /////////////////////////////////////////////////////////////////////////////////////// |
73 /////////////////////////////////////////////////////////////////////////////////////// |
41 /////////////////////////////////////////////////////////////////////////////////////// |
74 /////////////////////////////////////////////////////////////////////////////////////// |
42 //Test macroses and functions |
75 //Test macroses and functions |
43 LOCAL_C void Check(TInt aValue, TInt aLine) |
76 LOCAL_C void Check(TInt aValue, TInt aLine) |
44 { |
77 { |
45 if(!aValue) |
78 if(!aValue) |
46 { |
79 { |
47 theTest(EFalse, aLine); |
80 test2(EFalse, aLine); |
48 } |
81 } |
49 } |
82 } |
50 LOCAL_C void Check(TInt aValue, TInt aExpected, TInt aLine) |
83 LOCAL_C void Check(TInt aValue, TInt aExpected, TInt aLine) |
51 { |
84 { |
52 if(aValue != aExpected) |
85 if(aValue != aExpected) |
53 { |
86 { |
54 theTest.Printf(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); |
87 ERR_PRINTF3(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); |
55 theTest(EFalse, aLine); |
88 test2(EFalse, aLine); |
56 } |
89 } |
57 } |
90 } |
58 #define TEST(arg) ::Check((arg), __LINE__) |
91 #define CHECK1(arg) ::Check((arg), __LINE__) |
59 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__) |
92 #define CHECK2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__) |
60 |
93 |
61 |
94 |
62 LOCAL_C void Inc049456L() |
95 LOCAL_C void Inc049456L() |
63 { |
96 { |
64 theTest.Next(_L("Inc049456L")); |
97 INFO_PRINTF1(_L("Inc049456L")); |
65 |
98 |
66 CPlainTextConverter* converter = CPlainTextConverter::NewLC(); |
99 CPlainTextConverter* converter = CPlainTextConverter::NewLC(); |
67 CleanupStack::PopAndDestroy(converter); |
100 CleanupStack::PopAndDestroy(converter); |
68 } |
101 } |
69 |
102 |
70 LOCAL_C void OOM049456L() |
103 LOCAL_C void OOM049456L() |
71 { |
104 { |
72 theTest.Next(_L("OOM049456L")); |
105 INFO_PRINTF1(_L("OOM049456L")); |
73 |
106 |
74 TInt tryCount=0; |
107 TInt tryCount=0; |
75 TInt error = KErrNone; |
108 TInt error = KErrNone; |
76 __UNUSED_VAR(tryCount); |
109 __UNUSED_VAR(tryCount); |
77 |
110 |
350 static void INC055971L() |
383 static void INC055971L() |
351 { |
384 { |
352 TBuf<32> testBuf; |
385 TBuf<32> testBuf; |
353 TOutputChar outputChar; |
386 TOutputChar outputChar; |
354 |
387 |
355 theTest.Next(_L("INC055971L - OrganiseByParagraph test")); |
388 INFO_PRINTF1(_L("INC055971L - OrganiseByParagraph test")); |
356 |
389 |
357 { |
390 { |
358 TParagraphTextWriter paragraphTextWriter(outputChar); |
391 TParagraphTextWriter paragraphTextWriter(outputChar); |
359 TSLBTransaltor slbTranslator(paragraphTextWriter); |
392 TSLBTransaltor slbTranslator(paragraphTextWriter); |
360 |
393 |
361 testBuf = _L("\xD"); |
394 testBuf = _L("\xD"); |
362 TheOutputTestBuf.Zero(); |
395 TheOutputTestBuf.Zero(); |
363 ::TranslateToEofTestL(slbTranslator, testBuf); |
396 ::TranslateToEofTestL(slbTranslator, testBuf); |
364 TEST(TheOutputTestBuf.Length() == 1); |
397 CHECK1(TheOutputTestBuf.Length() == 1); |
365 TEST(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter); |
398 CHECK1(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter); |
366 |
399 |
367 testBuf = _L("\xA"); |
400 testBuf = _L("\xA"); |
368 TheOutputTestBuf.Zero(); |
401 TheOutputTestBuf.Zero(); |
369 ::TranslateToEofTestL(slbTranslator, testBuf); |
402 ::TranslateToEofTestL(slbTranslator, testBuf); |
370 TEST(TheOutputTestBuf.Length() == 1); |
403 CHECK1(TheOutputTestBuf.Length() == 1); |
371 TEST(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter); |
404 CHECK1(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter); |
372 |
405 |
373 testBuf = _L("\xD\xA"); |
406 testBuf = _L("\xD\xA"); |
374 TheOutputTestBuf.Zero(); |
407 TheOutputTestBuf.Zero(); |
375 ::TranslateToEofTestL(slbTranslator, testBuf); |
408 ::TranslateToEofTestL(slbTranslator, testBuf); |
376 TEST(TheOutputTestBuf.Length() == 1); |
409 CHECK1(TheOutputTestBuf.Length() == 1); |
377 TEST(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter); |
410 CHECK1(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter); |
378 |
411 |
379 testBuf = _L("zz\xD\xA\xD\xA\xAz\xD"); |
412 testBuf = _L("zz\xD\xA\xD\xA\xAz\xD"); |
380 TheOutputTestBuf.Zero(); |
413 TheOutputTestBuf.Zero(); |
381 ::TranslateToEofTestL(slbTranslator, testBuf); |
414 ::TranslateToEofTestL(slbTranslator, testBuf); |
382 TEST(TheOutputTestBuf.Length() == 7); |
415 CHECK1(TheOutputTestBuf.Length() == 7); |
383 TEST(TheOutputTestBuf[0] == 'z'); |
416 CHECK1(TheOutputTestBuf[0] == 'z'); |
384 TEST(TheOutputTestBuf[1] == 'z'); |
417 CHECK1(TheOutputTestBuf[1] == 'z'); |
385 TEST(TheOutputTestBuf[2] == CEditableText::EParagraphDelimiter); |
418 CHECK1(TheOutputTestBuf[2] == CEditableText::EParagraphDelimiter); |
386 TEST(TheOutputTestBuf[3] == CEditableText::EParagraphDelimiter); |
419 CHECK1(TheOutputTestBuf[3] == CEditableText::EParagraphDelimiter); |
387 TEST(TheOutputTestBuf[4] == CEditableText::EParagraphDelimiter); |
420 CHECK1(TheOutputTestBuf[4] == CEditableText::EParagraphDelimiter); |
388 TEST(TheOutputTestBuf[5] == 'z'); |
421 CHECK1(TheOutputTestBuf[5] == 'z'); |
389 TEST(TheOutputTestBuf[6] == CEditableText::EParagraphDelimiter); |
422 CHECK1(TheOutputTestBuf[6] == CEditableText::EParagraphDelimiter); |
390 |
423 |
391 testBuf = _L("This\xDIs\xATest\xD\xAMessage"); |
424 testBuf = _L("This\xDIs\xATest\xD\xAMessage"); |
392 TheOutputTestBuf.Zero(); |
425 TheOutputTestBuf.Zero(); |
393 ::TranslateToEofTestL(slbTranslator, testBuf); |
426 ::TranslateToEofTestL(slbTranslator, testBuf); |
394 TEST(TheOutputTestBuf.Length() == 20); |
427 CHECK1(TheOutputTestBuf.Length() == 20); |
395 TEST(TheOutputTestBuf[4] == CEditableText::EParagraphDelimiter); |
428 CHECK1(TheOutputTestBuf[4] == CEditableText::EParagraphDelimiter); |
396 TEST(TheOutputTestBuf[7] == CEditableText::EParagraphDelimiter); |
429 CHECK1(TheOutputTestBuf[7] == CEditableText::EParagraphDelimiter); |
397 TEST(TheOutputTestBuf[12] == CEditableText::EParagraphDelimiter); |
430 CHECK1(TheOutputTestBuf[12] == CEditableText::EParagraphDelimiter); |
398 } |
431 } |
399 |
432 |
400 theTest.Next(_L("INC055971L - OrganiseByLine test")); |
433 INFO_PRINTF1(_L("INC055971L - OrganiseByLine test")); |
401 |
434 |
402 { |
435 { |
403 TLineTextWriter lineTextWriter(outputChar); |
436 TLineTextWriter lineTextWriter(outputChar); |
404 TSLBTransaltor slbTranslator(lineTextWriter); |
437 TSLBTransaltor slbTranslator(lineTextWriter); |
405 |
438 |
406 testBuf = _L("\xD"); |
439 testBuf = _L("\xD"); |
407 TheOutputTestBuf.Zero(); |
440 TheOutputTestBuf.Zero(); |
408 ::TranslateToEofTestL(slbTranslator, testBuf); |
441 ::TranslateToEofTestL(slbTranslator, testBuf); |
409 TEST(TheOutputTestBuf.Length() == 1); |
442 CHECK1(TheOutputTestBuf.Length() == 1); |
410 TEST(TheOutputTestBuf[0] == ' '); |
443 CHECK1(TheOutputTestBuf[0] == ' '); |
411 |
444 |
412 testBuf = _L("\xA"); |
445 testBuf = _L("\xA"); |
413 TheOutputTestBuf.Zero(); |
446 TheOutputTestBuf.Zero(); |
414 ::TranslateToEofTestL(slbTranslator, testBuf); |
447 ::TranslateToEofTestL(slbTranslator, testBuf); |
415 TEST(TheOutputTestBuf.Length() == 1); |
448 CHECK1(TheOutputTestBuf.Length() == 1); |
416 TEST(TheOutputTestBuf[0] == ' '); |
449 CHECK1(TheOutputTestBuf[0] == ' '); |
417 |
450 |
418 testBuf = _L("\xD\xA"); |
451 testBuf = _L("\xD\xA"); |
419 TheOutputTestBuf.Zero(); |
452 TheOutputTestBuf.Zero(); |
420 ::TranslateToEofTestL(slbTranslator, testBuf); |
453 ::TranslateToEofTestL(slbTranslator, testBuf); |
421 TEST(TheOutputTestBuf.Length() == 1); |
454 CHECK1(TheOutputTestBuf.Length() == 1); |
422 TEST(TheOutputTestBuf[0] == ' '); |
455 CHECK1(TheOutputTestBuf[0] == ' '); |
423 |
456 |
424 testBuf = _L("\xD\xA\xD\xA"); |
457 testBuf = _L("\xD\xA\xD\xA"); |
425 TheOutputTestBuf.Zero(); |
458 TheOutputTestBuf.Zero(); |
426 ::TranslateToEofTestL(slbTranslator, testBuf); |
459 ::TranslateToEofTestL(slbTranslator, testBuf); |
427 TEST(TheOutputTestBuf.Length() == 1); |
460 CHECK1(TheOutputTestBuf.Length() == 1); |
428 TEST(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter); |
461 CHECK1(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter); |
429 |
462 |
430 testBuf = _L("\xD\xD"); |
463 testBuf = _L("\xD\xD"); |
431 TheOutputTestBuf.Zero(); |
464 TheOutputTestBuf.Zero(); |
432 ::TranslateToEofTestL(slbTranslator, testBuf); |
465 ::TranslateToEofTestL(slbTranslator, testBuf); |
433 TEST(TheOutputTestBuf.Length() == 1); |
466 CHECK1(TheOutputTestBuf.Length() == 1); |
434 TEST(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter); |
467 CHECK1(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter); |
435 |
468 |
436 testBuf = _L("\xA\xA"); |
469 testBuf = _L("\xA\xA"); |
437 TheOutputTestBuf.Zero(); |
470 TheOutputTestBuf.Zero(); |
438 ::TranslateToEofTestL(slbTranslator, testBuf); |
471 ::TranslateToEofTestL(slbTranslator, testBuf); |
439 TEST(TheOutputTestBuf.Length() == 1); |
472 CHECK1(TheOutputTestBuf.Length() == 1); |
440 TEST(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter); |
473 CHECK1(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter); |
441 |
474 |
442 testBuf = _L("\xA\xD"); |
475 testBuf = _L("\xA\xD"); |
443 TheOutputTestBuf.Zero(); |
476 TheOutputTestBuf.Zero(); |
444 ::TranslateToEofTestL(slbTranslator, testBuf); |
477 ::TranslateToEofTestL(slbTranslator, testBuf); |
445 TEST(TheOutputTestBuf.Length() == 1); |
478 CHECK1(TheOutputTestBuf.Length() == 1); |
446 TEST(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter); |
479 CHECK1(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter); |
447 |
480 |
448 testBuf = _L("\xD\xA\xA"); |
481 testBuf = _L("\xD\xA\xA"); |
449 TheOutputTestBuf.Zero(); |
482 TheOutputTestBuf.Zero(); |
450 ::TranslateToEofTestL(slbTranslator, testBuf); |
483 ::TranslateToEofTestL(slbTranslator, testBuf); |
451 TEST(TheOutputTestBuf.Length() == 1); |
484 CHECK1(TheOutputTestBuf.Length() == 1); |
452 TEST(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter); |
485 CHECK1(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter); |
453 |
486 |
454 testBuf = _L("\xD\xAz\xAzz\xA\xD"); |
487 testBuf = _L("\xD\xAz\xAzz\xA\xD"); |
455 TheOutputTestBuf.Zero(); |
488 TheOutputTestBuf.Zero(); |
456 ::TranslateToEofTestL(slbTranslator, testBuf); |
489 ::TranslateToEofTestL(slbTranslator, testBuf); |
457 TEST(TheOutputTestBuf.Length() == 6); |
490 CHECK1(TheOutputTestBuf.Length() == 6); |
458 TEST(TheOutputTestBuf[0] == ' '); |
491 CHECK1(TheOutputTestBuf[0] == ' '); |
459 TEST(TheOutputTestBuf[1] == 'z'); |
492 CHECK1(TheOutputTestBuf[1] == 'z'); |
460 TEST(TheOutputTestBuf[2] == ' '); |
493 CHECK1(TheOutputTestBuf[2] == ' '); |
461 TEST(TheOutputTestBuf[3] == 'z'); |
494 CHECK1(TheOutputTestBuf[3] == 'z'); |
462 TEST(TheOutputTestBuf[4] == 'z'); |
495 CHECK1(TheOutputTestBuf[4] == 'z'); |
463 TEST(TheOutputTestBuf[5] == CEditableText::EParagraphDelimiter); |
496 CHECK1(TheOutputTestBuf[5] == CEditableText::EParagraphDelimiter); |
464 } |
497 } |
465 } |
498 } |
466 |
499 |
467 /** |
500 /** |
468 @SYMTestCaseID SYSLIB-ETEXT-CT-3346 |
501 @SYMTestCaseID SYSLIB-ETEXT-CT-3346 |