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