Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1270 lines
35 KiB

  1. /*++
  2. Copyright (c) 1991-1999, Microsoft Corporation All rights reserved.
  3. Module Name:
  4. fstest.c
  5. Abstract:
  6. Test module for NLS API FoldString.
  7. NOTE: This code was simply hacked together quickly in order to
  8. test the different code modules of the NLS component.
  9. This is NOT meant to be a formal regression test.
  10. Revision History:
  11. 06-14-91 JulieB Created.
  12. --*/
  13. //
  14. // Include Files.
  15. //
  16. #include "nlstest.h"
  17. //
  18. // Constant Declarations.
  19. //
  20. #define BUFSIZE 50
  21. #define FS_INVALID_FLAGS ((DWORD)(~(MAP_FOLDCZONE | MAP_PRECOMPOSED | \
  22. MAP_COMPOSITE | MAP_FOLDDIGITS)))
  23. //
  24. // Global Variables.
  25. //
  26. #define FoldSrc1 L"This Is A String"
  27. #define FoldSrc2 L"This Is$ A Str,ing"
  28. WCHAR FoldDest[BUFSIZE];
  29. #define wcMultiComp L"\x0065\x0301\x0300"
  30. #define wcCompDigitCZone L"\x0065\x0301\x0300\x00b2\xfe64"
  31. #define wcFoldCompDigitCZone L"\x00e9\x0300\x0032\x003c"
  32. #define wcPrecompDigitCZone L"\x00e9\x0300\x00b2\xfe64"
  33. #define wcFoldPreDigitCZone L"\x0065\x0301\x0300\x0032\x003c"
  34. //
  35. // Forward Declarations.
  36. //
  37. BOOL
  38. InitFoldStr();
  39. int
  40. FS_BadParamCheck();
  41. int
  42. FS_NormalCase();
  43. int
  44. FS_Ansi();
  45. ////////////////////////////////////////////////////////////////////////////
  46. //
  47. // TestFoldString
  48. //
  49. // Test routine for FoldStringW API.
  50. //
  51. // 06-14-91 JulieB Created.
  52. ////////////////////////////////////////////////////////////////////////////
  53. int TestFoldString()
  54. {
  55. int ErrCount = 0; // error count
  56. //
  57. // Print out what's being done.
  58. //
  59. printf("\n\nTESTING FoldStringW...\n\n");
  60. //
  61. // Initialize global variables.
  62. //
  63. if (!InitFoldStr())
  64. {
  65. printf("\nABORTED TestFoldString: Could not Initialize.\n");
  66. return (1);
  67. }
  68. //
  69. // Test bad parameters.
  70. //
  71. ErrCount += FS_BadParamCheck();
  72. //
  73. // Test normal cases.
  74. //
  75. ErrCount += FS_NormalCase();
  76. //
  77. // Test Ansi version.
  78. //
  79. ErrCount += FS_Ansi();
  80. //
  81. // Print out result.
  82. //
  83. printf("\nFoldStringW: ERRORS = %d\n", ErrCount);
  84. //
  85. // Return total number of errors found.
  86. //
  87. return (ErrCount);
  88. }
  89. ////////////////////////////////////////////////////////////////////////////
  90. //
  91. // InitFoldStr
  92. //
  93. // This routine initializes the global variables. If no errors were
  94. // encountered, then it returns TRUE. Otherwise, it returns FALSE.
  95. //
  96. // 06-14-91 JulieB Created.
  97. ////////////////////////////////////////////////////////////////////////////
  98. BOOL InitFoldStr()
  99. {
  100. //
  101. // Return success.
  102. //
  103. return (TRUE);
  104. }
  105. ////////////////////////////////////////////////////////////////////////////
  106. //
  107. // FS_BadParamCheck
  108. //
  109. // This routine passes in bad parameters to the API routines and checks to
  110. // be sure they are handled properly. The number of errors encountered
  111. // is returned to the caller.
  112. //
  113. // 06-14-91 JulieB Created.
  114. ////////////////////////////////////////////////////////////////////////////
  115. int FS_BadParamCheck()
  116. {
  117. int NumErrors = 0; // error count - to be returned
  118. int rc; // return code
  119. //
  120. // Null Pointers.
  121. //
  122. // Variation 1 - lpSrcStr = NULL
  123. rc = FoldStringW( MAP_FOLDDIGITS,
  124. NULL,
  125. -1,
  126. FoldDest,
  127. BUFSIZE );
  128. CheckReturnBadParam( rc,
  129. 0,
  130. ERROR_INVALID_PARAMETER,
  131. "lpSrcStr NULL",
  132. &NumErrors );
  133. // Variation 2 - lpDestStr = NULL
  134. rc = FoldStringW( MAP_FOLDDIGITS,
  135. FoldSrc1,
  136. -1,
  137. NULL,
  138. BUFSIZE );
  139. CheckReturnBadParam( rc,
  140. 0,
  141. ERROR_INVALID_PARAMETER,
  142. "lpDestStr NULL",
  143. &NumErrors );
  144. //
  145. // Bad Counts.
  146. //
  147. // Variation 1 - cbSrc = 0
  148. rc = FoldStringW( MAP_FOLDDIGITS,
  149. FoldSrc1,
  150. 0,
  151. FoldDest,
  152. BUFSIZE );
  153. CheckReturnBadParam( rc,
  154. 0,
  155. ERROR_INVALID_PARAMETER,
  156. "cbSrc = 0",
  157. &NumErrors );
  158. // Variation 2 - cbDest < 0
  159. rc = FoldStringW( MAP_FOLDDIGITS,
  160. FoldSrc1,
  161. -1,
  162. FoldDest,
  163. -1 );
  164. CheckReturnBadParam( rc,
  165. 0,
  166. ERROR_INVALID_PARAMETER,
  167. "cbDest < 0",
  168. &NumErrors );
  169. //
  170. // Zero or Invalid Flag Values.
  171. //
  172. // Variation 1 - dwMapFlags = invalid
  173. rc = FoldStringW( FS_INVALID_FLAGS,
  174. FoldSrc1,
  175. -1,
  176. FoldDest,
  177. BUFSIZE );
  178. CheckReturnBadParam( rc,
  179. 0,
  180. ERROR_INVALID_FLAGS,
  181. "dwMapFlags invalid",
  182. &NumErrors );
  183. // Variation 2 - dwMapFlags = 0
  184. rc = FoldStringW( 0,
  185. FoldSrc1,
  186. -1,
  187. FoldDest,
  188. BUFSIZE );
  189. CheckReturnBadParam( rc,
  190. 0,
  191. ERROR_INVALID_FLAGS,
  192. "dwMapFlags zero",
  193. &NumErrors );
  194. // Variation 3 - illegal combo comp
  195. rc = FoldStringW( MAP_PRECOMPOSED | MAP_COMPOSITE,
  196. FoldSrc1,
  197. -1,
  198. FoldDest,
  199. BUFSIZE );
  200. CheckReturnBadParam( rc,
  201. 0,
  202. ERROR_INVALID_FLAGS,
  203. "illegal combo comp",
  204. &NumErrors );
  205. // Variation 4 - illegal combo ligatures
  206. rc = FoldStringW( MAP_EXPAND_LIGATURES | MAP_COMPOSITE,
  207. FoldSrc1,
  208. -1,
  209. FoldDest,
  210. BUFSIZE );
  211. CheckReturnBadParam( rc,
  212. 0,
  213. ERROR_INVALID_FLAGS,
  214. "illegal combo ligatures and comp",
  215. &NumErrors );
  216. // Variation 5 - illegal combo ligatures
  217. rc = FoldStringW( MAP_EXPAND_LIGATURES | MAP_PRECOMPOSED,
  218. FoldSrc1,
  219. -1,
  220. FoldDest,
  221. BUFSIZE );
  222. CheckReturnBadParam( rc,
  223. 0,
  224. ERROR_INVALID_FLAGS,
  225. "illegal combo ligatures and precomp",
  226. &NumErrors );
  227. //
  228. // Same Buffer Check.
  229. //
  230. // Variation 1 - same buffer
  231. FoldDest[0] = 0;
  232. rc = FoldStringW( MAP_FOLDDIGITS,
  233. FoldDest,
  234. -1,
  235. FoldDest,
  236. BUFSIZE );
  237. CheckReturnBadParam( rc,
  238. 0,
  239. ERROR_INVALID_PARAMETER,
  240. "same buffer",
  241. &NumErrors );
  242. //
  243. // Insufficient Buffer Check.
  244. //
  245. // Variation 1 - insufficient buffer
  246. FoldDest[0] = 0;
  247. rc = FoldStringW( MAP_EXPAND_LIGATURES,
  248. L"\x00e6",
  249. -1,
  250. FoldDest,
  251. 2 );
  252. CheckReturnBadParam( rc,
  253. 0,
  254. ERROR_INSUFFICIENT_BUFFER,
  255. "insufficient buffer",
  256. &NumErrors );
  257. FoldDest[0] = 0;
  258. rc = FoldStringW( MAP_EXPAND_LIGATURES,
  259. L"\x00e6",
  260. 1,
  261. FoldDest,
  262. 1 );
  263. CheckReturnBadParam( rc,
  264. 0,
  265. ERROR_INSUFFICIENT_BUFFER,
  266. "insufficient buffer 2",
  267. &NumErrors );
  268. //
  269. // Return total number of errors found.
  270. //
  271. return (NumErrors);
  272. }
  273. ////////////////////////////////////////////////////////////////////////////
  274. //
  275. // FS_NormalCase
  276. //
  277. // This routine tests the normal cases of the API routine.
  278. //
  279. // 06-14-91 JulieB Created.
  280. ////////////////////////////////////////////////////////////////////////////
  281. int FS_NormalCase()
  282. {
  283. int NumErrors = 0; // error count - to be returned
  284. int rc; // return code
  285. #ifdef PERF
  286. DbgBreakPoint();
  287. #endif
  288. //
  289. // cbDest = 0.
  290. //
  291. // Variation 1 - cbSrc = -1
  292. rc = FoldStringW( MAP_PRECOMPOSED,
  293. FoldSrc1,
  294. -1,
  295. FoldDest,
  296. 0 );
  297. CheckReturnValidW( rc,
  298. -1,
  299. NULL,
  300. FoldSrc1,
  301. "cbDest (0) cbSrc (-1)",
  302. &NumErrors );
  303. // Variation 2 - cbSrc = value
  304. rc = FoldStringW( MAP_PRECOMPOSED,
  305. FoldSrc1,
  306. WC_STRING_LEN_NULL(FoldSrc1),
  307. FoldDest,
  308. 0 );
  309. CheckReturnValidW( rc,
  310. -1,
  311. NULL,
  312. FoldSrc1,
  313. "cbDest (0) cbSrc (value)",
  314. &NumErrors );
  315. // Variation 3 - lpDestStr = NULL
  316. rc = FoldStringW( MAP_PRECOMPOSED,
  317. FoldSrc1,
  318. -1,
  319. NULL,
  320. 0 );
  321. CheckReturnValidW( rc,
  322. -1,
  323. NULL,
  324. FoldSrc1,
  325. "cbDest (0) lpDestStr NULL",
  326. &NumErrors );
  327. //
  328. // cbSrc.
  329. //
  330. // Variation 1 - cbSrc = -1
  331. rc = FoldStringW( MAP_PRECOMPOSED,
  332. FoldSrc1,
  333. -1,
  334. FoldDest,
  335. BUFSIZE );
  336. CheckReturnValidW( rc,
  337. -1,
  338. FoldDest,
  339. FoldSrc1,
  340. "cbSrc (-1)",
  341. &NumErrors );
  342. // Variation 2 - cbSrc = value
  343. rc = FoldStringW( MAP_PRECOMPOSED,
  344. FoldSrc1,
  345. WC_STRING_LEN(FoldSrc1),
  346. FoldDest,
  347. BUFSIZE );
  348. CheckReturnValidW( rc,
  349. WC_STRING_LEN(FoldSrc1),
  350. FoldDest,
  351. FoldSrc1,
  352. "cbSrc (value)",
  353. &NumErrors );
  354. // Variation 3 - cbSrc = -1, no DestStr
  355. rc = FoldStringW( MAP_PRECOMPOSED,
  356. FoldSrc1,
  357. -1,
  358. NULL,
  359. 0 );
  360. CheckReturnValidW( rc,
  361. -1,
  362. NULL,
  363. FoldSrc1,
  364. "cbSrc (-1), no DestStr",
  365. &NumErrors );
  366. // Variation 4 - cbSrc = value, no DestStr
  367. rc = FoldStringW( MAP_PRECOMPOSED,
  368. FoldSrc1,
  369. WC_STRING_LEN(FoldSrc1),
  370. NULL,
  371. 0 );
  372. CheckReturnValidW( rc,
  373. WC_STRING_LEN(FoldSrc1),
  374. NULL,
  375. FoldSrc1,
  376. "cbSrc (value), no DestStr",
  377. &NumErrors );
  378. //
  379. // MAP_PRECOMPOSED Flag.
  380. //
  381. // Variation 1 - precomposed
  382. rc = FoldStringW( MAP_PRECOMPOSED,
  383. FoldSrc2,
  384. -1,
  385. FoldDest,
  386. BUFSIZE );
  387. CheckReturnValidW( rc,
  388. -1,
  389. FoldDest,
  390. FoldSrc2,
  391. "precomposed",
  392. &NumErrors );
  393. // Variation 2 - precomposed
  394. rc = FoldStringW( MAP_PRECOMPOSED,
  395. L"\x006e\x0303",
  396. -1,
  397. FoldDest,
  398. BUFSIZE );
  399. CheckReturnValidW( rc,
  400. -1,
  401. FoldDest,
  402. L"\x00f1",
  403. "precomposed (n tilde)",
  404. &NumErrors );
  405. // Variation 3 - precomposed
  406. rc = FoldStringW( MAP_PRECOMPOSED,
  407. L"\x006e\x0303",
  408. -1,
  409. NULL,
  410. 0 );
  411. CheckReturnValidW( rc,
  412. -1,
  413. NULL,
  414. L"\x00f1",
  415. "precomposed (n tilde), no DestStr",
  416. &NumErrors );
  417. // Variation 4 - precomposed
  418. rc = FoldStringW( MAP_PRECOMPOSED,
  419. L"\x0062\x0303",
  420. -1,
  421. FoldDest,
  422. BUFSIZE );
  423. CheckReturnValidW( rc,
  424. -1,
  425. FoldDest,
  426. L"\x0062\x0303",
  427. "precomposed (b tilde)",
  428. &NumErrors );
  429. // Variation 5 - precomposed
  430. rc = FoldStringW( MAP_PRECOMPOSED,
  431. L"\x0062\x0303",
  432. -1,
  433. NULL,
  434. 0 );
  435. CheckReturnValidW( rc,
  436. -1,
  437. NULL,
  438. L"\x0062\x0303",
  439. "precomposed (b tilde), no DestStr",
  440. &NumErrors );
  441. //
  442. // MAP_COMPOSITE Flag.
  443. //
  444. // Variation 1 - composite
  445. rc = FoldStringW( MAP_COMPOSITE,
  446. FoldSrc2,
  447. -1,
  448. FoldDest,
  449. BUFSIZE );
  450. CheckReturnValidW( rc,
  451. -1,
  452. FoldDest,
  453. FoldSrc2,
  454. "composite",
  455. &NumErrors );
  456. // Variation 2 - composite
  457. rc = FoldStringW( MAP_COMPOSITE,
  458. L"\x00f1",
  459. -1,
  460. FoldDest,
  461. BUFSIZE );
  462. CheckReturnValidW( rc,
  463. -1,
  464. FoldDest,
  465. L"\x006e\x0303",
  466. "composite (n tilde)",
  467. &NumErrors );
  468. // Variation 3 - composite
  469. rc = FoldStringW( MAP_COMPOSITE,
  470. L"\x00f1",
  471. -1,
  472. NULL,
  473. 0 );
  474. CheckReturnValidW( rc,
  475. -1,
  476. NULL,
  477. L"\x006e\x0303",
  478. "composite (n tilde), no DestStr",
  479. &NumErrors );
  480. // Variation 4 - composite
  481. rc = FoldStringW( MAP_COMPOSITE,
  482. L"\x01c4",
  483. -1,
  484. FoldDest,
  485. BUFSIZE );
  486. CheckReturnValidW( rc,
  487. -1,
  488. FoldDest,
  489. L"\x0044\x017d",
  490. "composite (dz hacek)",
  491. &NumErrors );
  492. // Variation 5 - composite
  493. rc = FoldStringW( MAP_COMPOSITE,
  494. L"\x01c4",
  495. -1,
  496. NULL,
  497. 0 );
  498. CheckReturnValidW( rc,
  499. -1,
  500. NULL,
  501. L"\x0044\x017d",
  502. "composite (dz hacek), no DestStr",
  503. &NumErrors );
  504. // Variation 6 - composite
  505. rc = FoldStringW( MAP_COMPOSITE,
  506. L"\x0062\x0303",
  507. -1,
  508. FoldDest,
  509. BUFSIZE );
  510. CheckReturnValidW( rc,
  511. -1,
  512. FoldDest,
  513. L"\x0062\x0303",
  514. "composite (b tilde)",
  515. &NumErrors );
  516. // Variation 7 - composite
  517. rc = FoldStringW( MAP_COMPOSITE,
  518. L"\x0062\x0303",
  519. -1,
  520. NULL,
  521. 0 );
  522. CheckReturnValidW( rc,
  523. -1,
  524. NULL,
  525. L"\x0062\x0303",
  526. "composite (b tilde), no DestStr",
  527. &NumErrors );
  528. // Variation 8 - composite
  529. rc = FoldStringW( MAP_COMPOSITE,
  530. L"\x304c",
  531. -1,
  532. FoldDest,
  533. BUFSIZE );
  534. CheckReturnValidW( rc,
  535. -1,
  536. FoldDest,
  537. L"\x304b\xff9e",
  538. "composite (hiragana Ga)",
  539. &NumErrors );
  540. //
  541. // MAP_FOLDCZONE Flag.
  542. //
  543. // Variation 1 - fold compatibility zone
  544. rc = FoldStringW( MAP_FOLDCZONE,
  545. FoldSrc2,
  546. -1,
  547. FoldDest,
  548. BUFSIZE );
  549. CheckReturnValidW( rc,
  550. -1,
  551. FoldDest,
  552. FoldSrc2,
  553. "fold czone",
  554. &NumErrors );
  555. // Variation 2 - fold compatibility zone
  556. rc = FoldStringW( MAP_FOLDCZONE,
  557. L"\x004a\xff24\xff22",
  558. -1,
  559. FoldDest,
  560. BUFSIZE );
  561. CheckReturnValidW( rc,
  562. -1,
  563. FoldDest,
  564. L"\x004a\x0044\x0042",
  565. "fold czone (JDB)",
  566. &NumErrors );
  567. // Variation 3 - fold compatibility zone
  568. rc = FoldStringW( MAP_FOLDCZONE,
  569. L"\x004a\xff24\xff22",
  570. -1,
  571. NULL,
  572. 0 );
  573. CheckReturnValidW( rc,
  574. -1,
  575. NULL,
  576. L"\x004a\x0044\x0042",
  577. "fold czone (JDB), no DestStr",
  578. &NumErrors );
  579. //
  580. // MAP_FOLDDIGITS Flag.
  581. //
  582. // Variation 1 - fold digits
  583. rc = FoldStringW( MAP_FOLDDIGITS,
  584. FoldSrc2,
  585. -1,
  586. FoldDest,
  587. BUFSIZE );
  588. CheckReturnValidW( rc,
  589. -1,
  590. FoldDest,
  591. FoldSrc2,
  592. "fold digits",
  593. &NumErrors );
  594. // Variation 2 - fold digits
  595. rc = FoldStringW( MAP_FOLDDIGITS,
  596. L"\x00b2\x00b3",
  597. -1,
  598. FoldDest,
  599. BUFSIZE );
  600. CheckReturnValidW( rc,
  601. -1,
  602. FoldDest,
  603. L"\x0032\x0033",
  604. "fold digits (23)",
  605. &NumErrors );
  606. // Variation 3 - fold digits
  607. rc = FoldStringW( MAP_FOLDDIGITS,
  608. L"\x00b2\x00b3",
  609. -1,
  610. NULL,
  611. 0 );
  612. CheckReturnValidW( rc,
  613. -1,
  614. NULL,
  615. L"\x0032\x0033",
  616. "fold digits (23), no DestStr",
  617. &NumErrors );
  618. //
  619. // Check precomposed with multiple diacritics.
  620. //
  621. // Variation 1 - precomp, multi diacritics
  622. rc = FoldStringW( MAP_PRECOMPOSED,
  623. wcMultiComp,
  624. 3,
  625. FoldDest,
  626. BUFSIZE );
  627. CheckReturnValidW( rc,
  628. 2,
  629. FoldDest,
  630. L"\x00e9\x0300",
  631. "precomp, multi diacritics",
  632. &NumErrors );
  633. // Variation 2 - precomp, czone
  634. rc = FoldStringW( MAP_PRECOMPOSED | MAP_FOLDCZONE,
  635. wcCompDigitCZone,
  636. -1,
  637. FoldDest,
  638. BUFSIZE );
  639. CheckReturnValidW( rc,
  640. -1,
  641. FoldDest,
  642. L"\x00e9\x0300\x00b2\x003c",
  643. "precomp, czone",
  644. &NumErrors );
  645. // Variation 3 - precomp, digits
  646. rc = FoldStringW( MAP_PRECOMPOSED | MAP_FOLDDIGITS,
  647. wcCompDigitCZone,
  648. -1,
  649. FoldDest,
  650. BUFSIZE );
  651. CheckReturnValidW( rc,
  652. -1,
  653. FoldDest,
  654. L"\x00e9\x0300\x0032\xfe64",
  655. "precomp, digits",
  656. &NumErrors );
  657. // Variation 4 - precomp, czone, digits
  658. rc = FoldStringW( MAP_PRECOMPOSED | MAP_FOLDCZONE | MAP_FOLDDIGITS,
  659. wcCompDigitCZone,
  660. -1,
  661. FoldDest,
  662. BUFSIZE );
  663. CheckReturnValidW( rc,
  664. -1,
  665. FoldDest,
  666. L"\x00e9\x0300\x0032\x003c",
  667. "precomp, czone, digits",
  668. &NumErrors );
  669. //
  670. // Check composite.
  671. //
  672. // Variation 1 - comp, czone
  673. rc = FoldStringW( MAP_COMPOSITE | MAP_FOLDCZONE,
  674. wcPrecompDigitCZone,
  675. -1,
  676. FoldDest,
  677. BUFSIZE );
  678. CheckReturnValidW( rc,
  679. -1,
  680. FoldDest,
  681. L"\x0065\x0301\x0300\x00b2\x003c",
  682. "comp, czone",
  683. &NumErrors );
  684. // Variation 2 - comp, digits
  685. rc = FoldStringW( MAP_COMPOSITE | MAP_FOLDDIGITS,
  686. wcPrecompDigitCZone,
  687. -1,
  688. FoldDest,
  689. BUFSIZE );
  690. CheckReturnValidW( rc,
  691. -1,
  692. FoldDest,
  693. L"\x0065\x0301\x0300\x0032\xfe64",
  694. "comp, digits",
  695. &NumErrors );
  696. // Variation 3 - comp, czone, digits
  697. rc = FoldStringW( MAP_COMPOSITE | MAP_FOLDCZONE | MAP_FOLDDIGITS,
  698. wcPrecompDigitCZone,
  699. -1,
  700. FoldDest,
  701. BUFSIZE );
  702. CheckReturnValidW( rc,
  703. -1,
  704. FoldDest,
  705. L"\x0065\x0301\x0300\x0032\x003c",
  706. "comp, czone, digits",
  707. &NumErrors );
  708. //
  709. // MAP_EXPAND_LIGATURES Flag.
  710. //
  711. // Variation 1 - expand ligatures
  712. rc = FoldStringW( MAP_EXPAND_LIGATURES,
  713. L"abc",
  714. -1,
  715. FoldDest,
  716. BUFSIZE );
  717. CheckReturnValidW( rc,
  718. -1,
  719. FoldDest,
  720. L"abc",
  721. "expand ligatures 1",
  722. &NumErrors );
  723. // Variation 2 - expand ligatures
  724. rc = FoldStringW( MAP_EXPAND_LIGATURES,
  725. L"\x00e6",
  726. -1,
  727. FoldDest,
  728. BUFSIZE );
  729. CheckReturnValidW( rc,
  730. -1,
  731. FoldDest,
  732. L"ae",
  733. "expand ligatures 2",
  734. &NumErrors );
  735. // Variation 3 - expand ligatures
  736. rc = FoldStringW( MAP_EXPAND_LIGATURES,
  737. L"\x00e6",
  738. -1,
  739. FoldDest,
  740. 3 );
  741. CheckReturnValidW( rc,
  742. -1,
  743. FoldDest,
  744. L"ae",
  745. "expand ligatures 3",
  746. &NumErrors );
  747. // Variation 4 - expand ligatures
  748. rc = FoldStringW( MAP_EXPAND_LIGATURES,
  749. L"\x00e6",
  750. 1,
  751. FoldDest,
  752. 2 );
  753. CheckReturnValidW( rc,
  754. 2,
  755. FoldDest,
  756. L"ae",
  757. "expand ligatures 4",
  758. &NumErrors );
  759. // Variation 5 - expand ligatures
  760. rc = FoldStringW( MAP_EXPAND_LIGATURES,
  761. L"\x00e6",
  762. 1,
  763. NULL,
  764. 0 );
  765. CheckReturnValidW( rc,
  766. 2,
  767. NULL,
  768. L"ae",
  769. "expand ligatures 5 - no DestStr",
  770. &NumErrors );
  771. // Variation 6 - expand ligatures
  772. rc = FoldStringW( MAP_EXPAND_LIGATURES | MAP_FOLDCZONE,
  773. L"\x00e6\xff26",
  774. -1,
  775. FoldDest,
  776. BUFSIZE );
  777. CheckReturnValidW( rc,
  778. -1,
  779. FoldDest,
  780. L"aeF",
  781. "expand ligatures 6 - lig & czone",
  782. &NumErrors );
  783. // Variation 7 - expand ligatures
  784. rc = FoldStringW( MAP_EXPAND_LIGATURES | MAP_FOLDCZONE,
  785. L"\x00e6\xff26",
  786. -1,
  787. NULL,
  788. 0 );
  789. CheckReturnValidW( rc,
  790. -1,
  791. NULL,
  792. L"aeF",
  793. "expand ligatures 7 - lig & czone - no DestStr",
  794. &NumErrors );
  795. // Variation 8 - expand ligatures
  796. rc = FoldStringW( MAP_EXPAND_LIGATURES | MAP_FOLDDIGITS,
  797. L"\x00e6\x0660",
  798. -1,
  799. FoldDest,
  800. BUFSIZE );
  801. CheckReturnValidW( rc,
  802. -1,
  803. FoldDest,
  804. L"ae0",
  805. "expand ligatures 8 - lig & digits",
  806. &NumErrors );
  807. // Variation 9 - expand ligatures
  808. rc = FoldStringW( MAP_EXPAND_LIGATURES | MAP_FOLDDIGITS,
  809. L"\x00e6\x0660",
  810. -1,
  811. NULL,
  812. 0 );
  813. CheckReturnValidW( rc,
  814. -1,
  815. NULL,
  816. L"ae0",
  817. "expand ligatures 9 - lig & digits - no DestStr",
  818. &NumErrors );
  819. // Variation 10 - expand ligatures
  820. rc = FoldStringW( MAP_EXPAND_LIGATURES | MAP_FOLDCZONE | MAP_FOLDDIGITS,
  821. L"\x00e6\xff26\x0660",
  822. -1,
  823. FoldDest,
  824. BUFSIZE );
  825. CheckReturnValidW( rc,
  826. -1,
  827. FoldDest,
  828. L"aeF0",
  829. "expand ligatures 10 - lig, czone, & digits",
  830. &NumErrors );
  831. // Variation 11 - expand ligatures
  832. rc = FoldStringW( MAP_EXPAND_LIGATURES | MAP_FOLDCZONE | MAP_FOLDDIGITS,
  833. L"\x00e6\xff26\x0660",
  834. -1,
  835. NULL,
  836. 0 );
  837. CheckReturnValidW( rc,
  838. -1,
  839. NULL,
  840. L"aeF0",
  841. "expand ligatures 11 - lig, czone, & digits - no DestStr",
  842. &NumErrors );
  843. // Variation 12 - expand ligatures
  844. rc = FoldStringW( MAP_EXPAND_LIGATURES,
  845. L"\xfb03",
  846. -1,
  847. FoldDest,
  848. BUFSIZE );
  849. CheckReturnValidW( rc,
  850. -1,
  851. FoldDest,
  852. L"ffi",
  853. "expand ligatures 12",
  854. &NumErrors );
  855. // Variation 13 - expand ligatures
  856. rc = FoldStringW( MAP_EXPAND_LIGATURES,
  857. L"\xfb03",
  858. -1,
  859. NULL,
  860. 0 );
  861. CheckReturnValidW( rc,
  862. -1,
  863. NULL,
  864. L"ffi",
  865. "expand ligatures 13",
  866. &NumErrors );
  867. //
  868. // Return total number of errors found.
  869. //
  870. return (NumErrors);
  871. }
  872. ////////////////////////////////////////////////////////////////////////////
  873. //
  874. // FS_Ansi
  875. //
  876. // This routine tests the Ansi version of the API routine.
  877. //
  878. // 06-14-91 JulieB Created.
  879. ////////////////////////////////////////////////////////////////////////////
  880. int FS_Ansi()
  881. {
  882. int NumErrors = 0; // error count - to be returned
  883. int rc; // return code
  884. BYTE pFoldDestA[BUFSIZE]; // ptr to buffer
  885. //
  886. // FoldStringA.
  887. //
  888. // Variation 1 - cbSrc = -1
  889. rc = FoldStringA( MAP_PRECOMPOSED,
  890. "AbCd",
  891. -1,
  892. pFoldDestA,
  893. BUFSIZE );
  894. CheckReturnValidA( rc,
  895. -1,
  896. pFoldDestA,
  897. "AbCd",
  898. NULL,
  899. "A version cbSrc (-1)",
  900. &NumErrors );
  901. // Variation 2 - cbSrc = value
  902. rc = FoldStringA( MAP_PRECOMPOSED,
  903. "AbCd",
  904. 4,
  905. pFoldDestA,
  906. BUFSIZE );
  907. CheckReturnValidA( rc,
  908. 4,
  909. pFoldDestA,
  910. "AbCd",
  911. NULL,
  912. "A version cbSrc (value)",
  913. &NumErrors );
  914. // Variation 3 - cbSrc = -1, no DestStr
  915. rc = FoldStringA( MAP_PRECOMPOSED,
  916. "AbCd",
  917. -1,
  918. NULL,
  919. 0 );
  920. CheckReturnValidA( rc,
  921. -1,
  922. NULL,
  923. "AbCd",
  924. NULL,
  925. "A version cbSrc (-1), no DestStr",
  926. &NumErrors );
  927. // Variation 4 - cbSrc = value, no DestStr
  928. rc = FoldStringA( MAP_PRECOMPOSED,
  929. "AbCd",
  930. 4,
  931. NULL,
  932. 0 );
  933. CheckReturnValidA( rc,
  934. 4,
  935. NULL,
  936. "AbCd",
  937. NULL,
  938. "A version cbSrc (value), no DestStr",
  939. &NumErrors );
  940. //
  941. // MAP_EXPAND_LIGATURES Flag.
  942. //
  943. // Variation 1 - expand ligatures
  944. rc = FoldStringA( MAP_EXPAND_LIGATURES,
  945. "abc",
  946. -1,
  947. pFoldDestA,
  948. BUFSIZE );
  949. CheckReturnValidA( rc,
  950. -1,
  951. pFoldDestA,
  952. "abc",
  953. NULL,
  954. "A expand ligatures 1",
  955. &NumErrors );
  956. // Variation 2 - expand ligatures
  957. rc = FoldStringA( MAP_EXPAND_LIGATURES,
  958. "\xe6",
  959. -1,
  960. pFoldDestA,
  961. BUFSIZE );
  962. CheckReturnValidA( rc,
  963. -1,
  964. pFoldDestA,
  965. "ae",
  966. NULL,
  967. "A expand ligatures 2",
  968. &NumErrors );
  969. // Variation 3 - expand ligatures
  970. rc = FoldStringA( MAP_EXPAND_LIGATURES,
  971. "\xe6",
  972. -1,
  973. pFoldDestA,
  974. 3 );
  975. CheckReturnValidA( rc,
  976. -1,
  977. pFoldDestA,
  978. "ae",
  979. NULL,
  980. "A expand ligatures 3",
  981. &NumErrors );
  982. // Variation 4 - expand ligatures
  983. rc = FoldStringA( MAP_EXPAND_LIGATURES,
  984. "\xe6",
  985. 1,
  986. pFoldDestA,
  987. 2 );
  988. CheckReturnValidA( rc,
  989. 2,
  990. pFoldDestA,
  991. "ae",
  992. NULL,
  993. "A expand ligatures 4",
  994. &NumErrors );
  995. // Variation 5 - expand ligatures
  996. rc = FoldStringA( MAP_EXPAND_LIGATURES,
  997. "\xe6",
  998. 1,
  999. NULL,
  1000. 0 );
  1001. CheckReturnValidA( rc,
  1002. 2,
  1003. NULL,
  1004. "ae",
  1005. NULL,
  1006. "A expand ligatures 5 - no DestStr",
  1007. &NumErrors );
  1008. // Variation 6 - expand ligatures
  1009. rc = FoldStringA( MAP_EXPAND_LIGATURES | MAP_FOLDCZONE,
  1010. "\xe6G",
  1011. -1,
  1012. pFoldDestA,
  1013. BUFSIZE );
  1014. CheckReturnValidA( rc,
  1015. -1,
  1016. pFoldDestA,
  1017. "aeG",
  1018. NULL,
  1019. "A expand ligatures 6 - lig & czone",
  1020. &NumErrors );
  1021. // Variation 7 - expand ligatures
  1022. rc = FoldStringA( MAP_EXPAND_LIGATURES | MAP_FOLDCZONE,
  1023. "\xe6G",
  1024. -1,
  1025. NULL,
  1026. 0 );
  1027. CheckReturnValidA( rc,
  1028. -1,
  1029. NULL,
  1030. "aeG",
  1031. NULL,
  1032. "A expand ligatures 7 - lig & czone - no DestStr",
  1033. &NumErrors );
  1034. // Variation 8 - expand ligatures
  1035. rc = FoldStringA( MAP_EXPAND_LIGATURES | MAP_FOLDDIGITS,
  1036. "\xe6\xb2",
  1037. -1,
  1038. pFoldDestA,
  1039. BUFSIZE );
  1040. CheckReturnValidA( rc,
  1041. -1,
  1042. pFoldDestA,
  1043. "ae2",
  1044. NULL,
  1045. "A expand ligatures 8 - lig & digits",
  1046. &NumErrors );
  1047. // Variation 9 - expand ligatures
  1048. rc = FoldStringA( MAP_EXPAND_LIGATURES | MAP_FOLDDIGITS,
  1049. "\xe6\xb2",
  1050. -1,
  1051. NULL,
  1052. 0 );
  1053. CheckReturnValidA( rc,
  1054. -1,
  1055. NULL,
  1056. "ae2",
  1057. NULL,
  1058. "A expand ligatures 9 - lig & digits - no DestStr",
  1059. &NumErrors );
  1060. // Variation 10 - expand ligatures
  1061. rc = FoldStringA( MAP_EXPAND_LIGATURES | MAP_FOLDCZONE | MAP_FOLDDIGITS,
  1062. "\xe6G\xb2",
  1063. -1,
  1064. pFoldDestA,
  1065. BUFSIZE );
  1066. CheckReturnValidA( rc,
  1067. -1,
  1068. pFoldDestA,
  1069. "aeG2",
  1070. NULL,
  1071. "A expand ligatures 10 - lig, czone, & digits",
  1072. &NumErrors );
  1073. // Variation 11 - expand ligatures
  1074. rc = FoldStringA( MAP_EXPAND_LIGATURES | MAP_FOLDCZONE | MAP_FOLDDIGITS,
  1075. "\xe6G\xb2",
  1076. -1,
  1077. NULL,
  1078. 0 );
  1079. CheckReturnValidA( rc,
  1080. -1,
  1081. NULL,
  1082. "aeG2",
  1083. NULL,
  1084. "A expand ligatures 11 - lig, czone, & digits - no DestStr",
  1085. &NumErrors );
  1086. //
  1087. // Return total number of errors found.
  1088. //
  1089. return (NumErrors);
  1090. }