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.

1067 lines
27 KiB

  1. /*++
  2. Copyright (c) 1991-1999, Microsoft Corporation All rights reserved.
  3. Module Name:
  4. ggitest.c
  5. Abstract:
  6. Test module for NLS API GetGeoInfo, GetUserGeoID, and SetUserGeoID.
  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. 09-12-2000 JulieB Created.
  12. --*/
  13. //
  14. // Include Files.
  15. //
  16. #include "nlstest.h"
  17. //
  18. // Constant Declarations.
  19. //
  20. #define BUFSIZE 50 // buffer size in wide chars
  21. #define GEOTYPE_INVALID 0x0100 // invalid geo type
  22. #define GEO_INVALID 1 // invalid geo id
  23. #define GEOCLASS_INVALID 3 // invalid geo class
  24. #define US_NATION L"244"
  25. #define US_FRIENDLYNAME L"United States"
  26. #define US_OFFICIALNAME L"United States of America"
  27. #define US_NATION_A "244"
  28. #define US_FRIENDLYNAME_A "United States"
  29. #define US_OFFICIALNAME_A "United States of America"
  30. //
  31. // Global Variables.
  32. //
  33. LCID Locale;
  34. GEOID GeoId;
  35. WCHAR lpGeoData[BUFSIZE];
  36. BYTE lpGeoDataA[BUFSIZE];
  37. //
  38. // pGeoFlag and pGeoString must have the same number of entries.
  39. //
  40. GEOTYPE pGeoFlag[] =
  41. {
  42. GEO_NATION,
  43. GEO_LATITUDE,
  44. GEO_LONGITUDE,
  45. GEO_ISO2,
  46. GEO_ISO3,
  47. GEO_RFC1766,
  48. GEO_LCID,
  49. GEO_FRIENDLYNAME,
  50. GEO_OFFICIALNAME
  51. // GEO_TIMEZONES,
  52. // GEO_OFFICIALLANGUAGES
  53. };
  54. #define NUM_GEO_FLAGS ( sizeof(pGeoFlag) / sizeof(GEOTYPE) )
  55. LPWSTR pGeoString[] =
  56. {
  57. L"244",
  58. L"39.45",
  59. L"-98.908",
  60. L"US",
  61. L"USA",
  62. L"en-us",
  63. L"00000409",
  64. L"United States",
  65. L"United States of America",
  66. };
  67. LPSTR pGeoStringA[] =
  68. {
  69. "244",
  70. "39.45",
  71. "-98.908",
  72. "US",
  73. "USA",
  74. "en-us",
  75. "00000409",
  76. "United States",
  77. "United States of America",
  78. };
  79. LPWSTR pGeoString2[] =
  80. {
  81. L"122",
  82. L"35.156",
  83. L"136.06",
  84. L"JP",
  85. L"JPN",
  86. L"ja-jp",
  87. L"00000411",
  88. L"Japan",
  89. L"Japan",
  90. };
  91. LPSTR pGeoString2A[] =
  92. {
  93. "122",
  94. "35.156",
  95. "136.06",
  96. "JP",
  97. "JPN",
  98. "ja-jp",
  99. "00000411",
  100. "Japan",
  101. "Japan",
  102. };
  103. //
  104. // Forward Declarations.
  105. //
  106. BOOL
  107. InitGetGeoInfo();
  108. int
  109. GGI_BadParamCheck();
  110. int
  111. GGI_NormalCase();
  112. int
  113. GGI_Ansi();
  114. int
  115. GetSetUserGeoId();
  116. ////////////////////////////////////////////////////////////////////////////
  117. //
  118. // TestGetGeoInfo
  119. //
  120. // Test routine for GetGeoInfoW API.
  121. //
  122. // 09-12-00 JulieB Created.
  123. ////////////////////////////////////////////////////////////////////////////
  124. int TestGetGeoInfo()
  125. {
  126. int ErrCount = 0; // error count
  127. //
  128. // Print out what's being done.
  129. //
  130. printf("\n\nTESTING GetGeoInfoW, GetUserGeoID, SetUserGeoID...\n\n");
  131. //
  132. // Initialize global variables.
  133. //
  134. if (!InitGetGeoInfo())
  135. {
  136. printf("\nABORTED TestGetGeoInfo: Could not Initialize.\n");
  137. return (1);
  138. }
  139. //
  140. // Test bad parameters.
  141. //
  142. ErrCount += GGI_BadParamCheck();
  143. //
  144. // Test normal cases.
  145. //
  146. ErrCount += GGI_NormalCase();
  147. //
  148. // Test Ansi version.
  149. //
  150. ErrCount += GGI_Ansi();
  151. //
  152. // Test Get and Set.
  153. //
  154. ErrCount += GetSetUserGeoId();
  155. //
  156. // Print out result.
  157. //
  158. printf("\nGetGeoInfoW: ERRORS = %d\n", ErrCount);
  159. //
  160. // Return total number of errors found.
  161. //
  162. return (ErrCount);
  163. }
  164. ////////////////////////////////////////////////////////////////////////////
  165. //
  166. // InitGetGeoInfo
  167. //
  168. // This routine initializes the global variables. If no errors were
  169. // encountered, then it returns TRUE. Otherwise, it returns FALSE.
  170. //
  171. // 09-12-00 JulieB Created.
  172. ////////////////////////////////////////////////////////////////////////////
  173. BOOL InitGetGeoInfo()
  174. {
  175. //
  176. // Make a Locale.
  177. //
  178. Locale = MAKELCID(0x0409, 0);
  179. //
  180. // Set the GeoId.
  181. //
  182. GeoId = 244;
  183. //
  184. // Return success.
  185. //
  186. return (TRUE);
  187. }
  188. ////////////////////////////////////////////////////////////////////////////
  189. //
  190. // GGI_BadParamCheck
  191. //
  192. // This routine passes in bad parameters to the API routines and checks to
  193. // be sure they are handled properly. The number of errors encountered
  194. // is returned to the caller.
  195. //
  196. // 09-12-00 JulieB Created.
  197. ////////////////////////////////////////////////////////////////////////////
  198. int GGI_BadParamCheck()
  199. {
  200. int NumErrors = 0; // error count - to be returned
  201. int rc; // return code
  202. //
  203. // Bad Locale.
  204. //
  205. // Variation 1 - Bad Locale
  206. rc = GetGeoInfoW( GEO_INVALID,
  207. GEO_NATION,
  208. lpGeoData,
  209. BUFSIZE,
  210. 0x0409 );
  211. CheckReturnBadParam( rc,
  212. 0,
  213. ERROR_INVALID_PARAMETER,
  214. "Bad Geo Id",
  215. &NumErrors );
  216. //
  217. // Null Pointers.
  218. //
  219. // Variation 1 - lpGeoData = NULL
  220. rc = GetGeoInfoW( GeoId,
  221. GEO_NATION,
  222. NULL,
  223. BUFSIZE,
  224. 0x0409 );
  225. CheckReturnBadParam( rc,
  226. 0,
  227. ERROR_INVALID_PARAMETER,
  228. "lpGeoData NULL",
  229. &NumErrors );
  230. //
  231. // Bad Counts.
  232. //
  233. // Variation 1 - cbBuf < 0
  234. rc = GetGeoInfoW( GeoId,
  235. GEO_NATION,
  236. lpGeoData,
  237. -1,
  238. 0x0409 );
  239. CheckReturnBadParam( rc,
  240. 0,
  241. ERROR_INVALID_PARAMETER,
  242. "cbBuf < 0",
  243. &NumErrors );
  244. //
  245. // Zero or Invalid Type.
  246. //
  247. // Variation 1 - GeoType = invalid
  248. rc = GetGeoInfoW( GeoId,
  249. GEOTYPE_INVALID,
  250. lpGeoData,
  251. BUFSIZE,
  252. 0x0409 );
  253. CheckReturnBadParam( rc,
  254. 0,
  255. ERROR_INVALID_FLAGS,
  256. "GeoType invalid",
  257. &NumErrors );
  258. // Variation 2 - GeoType = 0
  259. rc = GetGeoInfoW( GeoId,
  260. 0,
  261. lpGeoData,
  262. BUFSIZE,
  263. 0x0409 );
  264. CheckReturnBadParam( rc,
  265. 0,
  266. ERROR_INVALID_FLAGS,
  267. "GeoType zero",
  268. &NumErrors );
  269. //
  270. // Buffer Too Small.
  271. //
  272. // Variation 1 - cbBuf = too small
  273. rc = GetGeoInfoW( GeoId,
  274. GEO_NATION,
  275. lpGeoData,
  276. 2,
  277. 0x0409 );
  278. CheckReturnBadParam( rc,
  279. 0,
  280. ERROR_INSUFFICIENT_BUFFER,
  281. "cbBuf too small",
  282. &NumErrors );
  283. //
  284. // Bad GeoId - Not valid in RC file.
  285. //
  286. // Variation 1 - GEO_NATION - invalid
  287. rc = GetGeoInfoW( GEO_INVALID,
  288. GEO_NATION,
  289. lpGeoData,
  290. BUFSIZE,
  291. 0x0409 );
  292. CheckReturnBadParam( rc,
  293. 0,
  294. ERROR_INVALID_PARAMETER,
  295. "invalid geo id",
  296. &NumErrors );
  297. //
  298. // Bad LangId.
  299. //
  300. // Variation 1 - GEO_NATION - invalid
  301. rc = GetGeoInfoW( GeoId,
  302. GEO_NATION,
  303. lpGeoData,
  304. BUFSIZE,
  305. (LCID)333 );
  306. CheckReturnBadParam( rc,
  307. 0,
  308. ERROR_INVALID_PARAMETER,
  309. "invalid lang id",
  310. &NumErrors );
  311. //
  312. // Return total number of errors found.
  313. //
  314. return (NumErrors);
  315. }
  316. ////////////////////////////////////////////////////////////////////////////
  317. //
  318. // GGI_NormalCase
  319. //
  320. // This routine tests the normal cases of the API routine.
  321. //
  322. // 09-12-00 JulieB Created.
  323. ////////////////////////////////////////////////////////////////////////////
  324. int GGI_NormalCase()
  325. {
  326. int NumErrors = 0; // error count - to be returned
  327. int rc; // return code
  328. int ctr; // loop counter
  329. #ifdef PERF
  330. DbgBreakPoint();
  331. #endif
  332. //
  333. // GeoIds.
  334. //
  335. // Variation 1 - Current User GeoId
  336. rc = GetGeoInfoW( GetUserGeoID(GEOCLASS_NATION),
  337. GEO_NATION,
  338. lpGeoData,
  339. BUFSIZE,
  340. 0x0409 );
  341. CheckReturnEqual( rc,
  342. 0,
  343. "current user geo id",
  344. &NumErrors );
  345. //
  346. // cbBuf.
  347. //
  348. // Variation 1 - cbBuf = size of lpGeoData buffer
  349. rc = GetGeoInfoW( GeoId,
  350. GEO_NATION,
  351. lpGeoData,
  352. BUFSIZE,
  353. 0x0409 );
  354. CheckReturnValidW( rc,
  355. -1,
  356. lpGeoData,
  357. US_NATION,
  358. "cbBuf = bufsize",
  359. &NumErrors );
  360. // Variation 2 - cbBuf = 0
  361. lpGeoData[0] = 0x0000;
  362. rc = GetGeoInfoW( GeoId,
  363. GEO_NATION,
  364. lpGeoData,
  365. 0,
  366. 0x0409 );
  367. CheckReturnValidW( rc,
  368. -1,
  369. NULL,
  370. US_NATION,
  371. "cbBuf zero",
  372. &NumErrors );
  373. // Variation 3 - cbBuf = 0, lpGeoData = NULL
  374. rc = GetGeoInfoW( GeoId,
  375. GEO_NATION,
  376. NULL,
  377. 0,
  378. 0x0409 );
  379. CheckReturnValidW( rc,
  380. -1,
  381. NULL,
  382. US_NATION,
  383. "cbBuf (NULL ptr)",
  384. &NumErrors );
  385. //
  386. // GEOTYPE values.
  387. //
  388. for (ctr = 0; ctr < NUM_GEO_FLAGS; ctr++)
  389. {
  390. //
  391. // United States
  392. //
  393. rc = GetGeoInfoW( GeoId,
  394. pGeoFlag[ctr],
  395. lpGeoData,
  396. BUFSIZE,
  397. 0x0009 );
  398. CheckReturnValidLoopW( rc,
  399. -1,
  400. lpGeoData,
  401. pGeoString[ctr],
  402. "Lang Id 0009, Geo Flag",
  403. pGeoFlag[ctr],
  404. &NumErrors );
  405. rc = GetGeoInfoW( GeoId,
  406. pGeoFlag[ctr],
  407. lpGeoData,
  408. BUFSIZE,
  409. 0x0409 );
  410. CheckReturnValidLoopW( rc,
  411. -1,
  412. lpGeoData,
  413. pGeoString[ctr],
  414. "Lang Id 0409, Geo Flag",
  415. pGeoFlag[ctr],
  416. &NumErrors );
  417. //
  418. // Japan
  419. //
  420. rc = GetGeoInfoW( 122,
  421. pGeoFlag[ctr],
  422. lpGeoData,
  423. BUFSIZE,
  424. 0x0011 );
  425. CheckReturnValidLoopW( rc,
  426. -1,
  427. lpGeoData,
  428. pGeoString2[ctr],
  429. "Lang Id 0011, Geo Flag",
  430. pGeoFlag[ctr],
  431. &NumErrors );
  432. rc = GetGeoInfoW( 122,
  433. pGeoFlag[ctr],
  434. lpGeoData,
  435. BUFSIZE,
  436. 0x0411 );
  437. CheckReturnValidLoopW( rc,
  438. -1,
  439. lpGeoData,
  440. pGeoString2[ctr],
  441. "Lang Id 0411, Geo Flag",
  442. pGeoFlag[ctr],
  443. &NumErrors );
  444. }
  445. //
  446. // RC file - FRIENDLYNAME and OFFICIALNAME.
  447. //
  448. // Variation 1 - FRIENDLYNAME US
  449. rc = GetGeoInfoW( 244,
  450. GEO_FRIENDLYNAME,
  451. lpGeoData,
  452. BUFSIZE,
  453. 0x0409 );
  454. CheckReturnValidW( rc,
  455. -1,
  456. lpGeoData,
  457. US_FRIENDLYNAME,
  458. "FriendlyName US",
  459. &NumErrors );
  460. // Variation 2 - OFFICIALNAME US
  461. rc = GetGeoInfoW( 244,
  462. GEO_OFFICIALNAME,
  463. lpGeoData,
  464. BUFSIZE,
  465. 0x0409 );
  466. CheckReturnValidW( rc,
  467. -1,
  468. lpGeoData,
  469. US_OFFICIALNAME,
  470. "OfficialName US",
  471. &NumErrors );
  472. // Variation 3 - FRIENDLYNAME Czech
  473. rc = GetGeoInfoW( 75,
  474. GEO_FRIENDLYNAME,
  475. lpGeoData,
  476. BUFSIZE,
  477. 0x0409 );
  478. CheckReturnValidW( rc,
  479. -1,
  480. lpGeoData,
  481. L"Czech Republic",
  482. "FriendlyName Czech",
  483. &NumErrors );
  484. // Variation 4 - OFFICIALNAME Czech
  485. rc = GetGeoInfoW( 75,
  486. GEO_OFFICIALNAME,
  487. lpGeoData,
  488. BUFSIZE,
  489. 0x0409 );
  490. CheckReturnValidW( rc,
  491. -1,
  492. lpGeoData,
  493. L"Czech Republic",
  494. "OfficialName Czech",
  495. &NumErrors );
  496. // Variation 5 - FRIENDLYNAME Venezuela
  497. rc = GetGeoInfoW( 249,
  498. GEO_FRIENDLYNAME,
  499. lpGeoData,
  500. BUFSIZE,
  501. 0x0409 );
  502. CheckReturnValidW( rc,
  503. -1,
  504. lpGeoData,
  505. L"Venezuela",
  506. "FriendlyName Venezuela",
  507. &NumErrors );
  508. // Variation 6 - OFFICIALNAME Venezuela
  509. rc = GetGeoInfoW( 249,
  510. GEO_OFFICIALNAME,
  511. lpGeoData,
  512. BUFSIZE,
  513. 0x0409 );
  514. CheckReturnValidW( rc,
  515. -1,
  516. lpGeoData,
  517. L"Bolivarian Republic of Venezuela",
  518. "OfficialName Venezuela",
  519. &NumErrors );
  520. // Variation 7 - FRIENDLYNAME Puerto Rico
  521. rc = GetGeoInfoW( 202,
  522. GEO_FRIENDLYNAME,
  523. lpGeoData,
  524. BUFSIZE,
  525. 0x0409 );
  526. CheckReturnValidW( rc,
  527. -1,
  528. lpGeoData,
  529. L"Puerto Rico",
  530. "FriendlyName Puerto Rico",
  531. &NumErrors );
  532. // Variation 8 - OFFICIALNAME Puerto Rico
  533. rc = GetGeoInfoW( 202,
  534. GEO_OFFICIALNAME,
  535. lpGeoData,
  536. BUFSIZE,
  537. 0x0409 );
  538. CheckReturnValidW( rc,
  539. -1,
  540. lpGeoData,
  541. L"Puerto Rico",
  542. "OfficialName Puerto Rico",
  543. &NumErrors );
  544. //
  545. // Language Neutral.
  546. //
  547. // Variation 1 - lang id - neutral
  548. rc = GetGeoInfoW( GeoId,
  549. GEO_NATION,
  550. lpGeoData,
  551. BUFSIZE,
  552. 0 );
  553. CheckReturnValidW( rc,
  554. -1,
  555. lpGeoData,
  556. US_NATION,
  557. "lang id (neutral)",
  558. &NumErrors );
  559. // Variation 2 - lang id - sub lang neutral US
  560. rc = GetGeoInfoW( GeoId,
  561. GEO_NATION,
  562. lpGeoData,
  563. BUFSIZE,
  564. 0x0009 );
  565. CheckReturnValidW( rc,
  566. -1,
  567. lpGeoData,
  568. US_NATION,
  569. "lang id (sub lang neutral US)",
  570. &NumErrors );
  571. // Variation 5 - lang id - sub lang neutral Czech
  572. rc = GetGeoInfoW( GeoId,
  573. GEO_NATION,
  574. lpGeoData,
  575. BUFSIZE,
  576. 0x0005 );
  577. CheckReturnValidW( rc,
  578. -1,
  579. lpGeoData,
  580. US_NATION,
  581. "lang id (sub lang neutral Czech)",
  582. &NumErrors );
  583. //
  584. // Return total number of errors found.
  585. //
  586. return (NumErrors);
  587. }
  588. ////////////////////////////////////////////////////////////////////////////
  589. //
  590. // GGI_Ansi
  591. //
  592. // This routine tests the Ansi version of the API routine.
  593. //
  594. // 09-12-00 JulieB Created.
  595. ////////////////////////////////////////////////////////////////////////////
  596. int GGI_Ansi()
  597. {
  598. int NumErrors = 0; // error count - to be returned
  599. int rc; // return code
  600. int ctr; // loop counter
  601. //
  602. // GeoIds.
  603. //
  604. // Variation 1 - Current User GeoId
  605. rc = GetGeoInfoA( GetUserGeoID(GEOCLASS_NATION),
  606. GEO_NATION,
  607. lpGeoDataA,
  608. BUFSIZE,
  609. 0x0409 );
  610. CheckReturnEqual( rc,
  611. 0,
  612. "A version - current user geo id",
  613. &NumErrors );
  614. //
  615. // cbBuf.
  616. //
  617. // Variation 1 - cbBuf = size of lpGeoDataA buffer
  618. rc = GetGeoInfoA( GeoId,
  619. GEO_NATION,
  620. lpGeoDataA,
  621. BUFSIZE,
  622. 0x0409 );
  623. CheckReturnValidA( rc,
  624. -1,
  625. lpGeoDataA,
  626. US_NATION_A,
  627. NULL,
  628. "A version - cbBuf = bufsize",
  629. &NumErrors );
  630. // Variation 2 - cbBuf = 0
  631. lpGeoDataA[0] = 0x0000;
  632. rc = GetGeoInfoA( GeoId,
  633. GEO_NATION,
  634. lpGeoDataA,
  635. 0,
  636. 0x0409 );
  637. CheckReturnValidA( rc,
  638. -1,
  639. NULL,
  640. US_NATION_A,
  641. NULL,
  642. "A version - cbBuf zero",
  643. &NumErrors );
  644. // Variation 3 - cbBuf = 0, lpGeoDataA = NULL
  645. rc = GetGeoInfoA( GeoId,
  646. GEO_NATION,
  647. NULL,
  648. 0,
  649. 0x0409 );
  650. CheckReturnValidA( rc,
  651. -1,
  652. NULL,
  653. US_NATION_A,
  654. NULL,
  655. "A version - cbBuf (NULL ptr)",
  656. &NumErrors );
  657. //
  658. // GEOTYPE values.
  659. //
  660. for (ctr = 0; ctr < NUM_GEO_FLAGS; ctr++)
  661. {
  662. rc = GetGeoInfoA( GeoId,
  663. pGeoFlag[ctr],
  664. lpGeoDataA,
  665. BUFSIZE,
  666. 0x0009 );
  667. CheckReturnValidLoopA( rc,
  668. -1,
  669. lpGeoDataA,
  670. pGeoStringA[ctr],
  671. "A version - Lang Id 0009, Geo Flag",
  672. pGeoFlag[ctr],
  673. &NumErrors );
  674. rc = GetGeoInfoA( GeoId,
  675. pGeoFlag[ctr],
  676. lpGeoDataA,
  677. BUFSIZE,
  678. 0x0409 );
  679. CheckReturnValidLoopA( rc,
  680. -1,
  681. lpGeoDataA,
  682. pGeoStringA[ctr],
  683. "A version - Lang Id 0409, Geo Flag",
  684. pGeoFlag[ctr],
  685. &NumErrors );
  686. }
  687. //
  688. // RC file - FRIENDLYNAME and OFFICIALNAME.
  689. //
  690. // Variation 1 - FRIENDLYNAME US
  691. rc = GetGeoInfoA( 244,
  692. GEO_FRIENDLYNAME,
  693. lpGeoDataA,
  694. BUFSIZE,
  695. 0x0409 );
  696. CheckReturnValidA( rc,
  697. -1,
  698. lpGeoDataA,
  699. US_FRIENDLYNAME_A,
  700. NULL,
  701. "A version - FriendlyName US",
  702. &NumErrors );
  703. // Variation 2 - OFFICIALNAME US
  704. rc = GetGeoInfoA( 244,
  705. GEO_OFFICIALNAME,
  706. lpGeoDataA,
  707. BUFSIZE,
  708. 0x0409 );
  709. CheckReturnValidA( rc,
  710. -1,
  711. lpGeoDataA,
  712. US_OFFICIALNAME_A,
  713. NULL,
  714. "A version - OfficialName US",
  715. &NumErrors );
  716. // Variation 3 - FRIENDLYNAME Czech
  717. rc = GetGeoInfoA( 75,
  718. GEO_FRIENDLYNAME,
  719. lpGeoDataA,
  720. BUFSIZE,
  721. 0x0409 );
  722. CheckReturnValidA( rc,
  723. -1,
  724. lpGeoDataA,
  725. "Czech Republic",
  726. NULL,
  727. "A version - FriendlyName Czech",
  728. &NumErrors );
  729. // Variation 4 - OFFICIALNAME Czech
  730. rc = GetGeoInfoA( 75,
  731. GEO_OFFICIALNAME,
  732. lpGeoDataA,
  733. BUFSIZE,
  734. 0x0409 );
  735. CheckReturnValidA( rc,
  736. -1,
  737. lpGeoDataA,
  738. "Czech Republic",
  739. NULL,
  740. "A version - OfficialName Czech",
  741. &NumErrors );
  742. // Variation 5 - FRIENDLYNAME Venezuela
  743. rc = GetGeoInfoA( 249,
  744. GEO_FRIENDLYNAME,
  745. lpGeoDataA,
  746. BUFSIZE,
  747. 0x0409 );
  748. CheckReturnValidA( rc,
  749. -1,
  750. lpGeoDataA,
  751. "Venezuela",
  752. NULL,
  753. "A version - FriendlyName Venezuela",
  754. &NumErrors );
  755. // Variation 6 - OFFICIALNAME Venezuela
  756. rc = GetGeoInfoA( 249,
  757. GEO_OFFICIALNAME,
  758. lpGeoDataA,
  759. BUFSIZE,
  760. 0x0409 );
  761. CheckReturnValidA( rc,
  762. -1,
  763. lpGeoDataA,
  764. "Bolivarian Republic of Venezuela",
  765. NULL,
  766. "A version - OfficialName Venezuela",
  767. &NumErrors );
  768. //
  769. // Language Neutral.
  770. //
  771. // Variation 1 - lang id - neutral
  772. rc = GetGeoInfoA( GeoId,
  773. GEO_NATION,
  774. lpGeoDataA,
  775. BUFSIZE,
  776. 0 );
  777. CheckReturnValidA( rc,
  778. -1,
  779. lpGeoDataA,
  780. US_NATION_A,
  781. NULL,
  782. "A version - lang id (neutral)",
  783. &NumErrors );
  784. // Variation 2 - lang id - sub lang neutral US
  785. rc = GetGeoInfoA( GeoId,
  786. GEO_NATION,
  787. lpGeoDataA,
  788. BUFSIZE,
  789. 0x0009 );
  790. CheckReturnValidA( rc,
  791. -1,
  792. lpGeoDataA,
  793. US_NATION_A,
  794. NULL,
  795. "A version - lang id (sub lang neutral US)",
  796. &NumErrors );
  797. // Variation 5 - lang id - sub lang neutral Czech
  798. rc = GetGeoInfoA( GeoId,
  799. GEO_NATION,
  800. lpGeoDataA,
  801. BUFSIZE,
  802. 0x0005 );
  803. CheckReturnValidA( rc,
  804. -1,
  805. lpGeoDataA,
  806. US_NATION_A,
  807. NULL,
  808. "A version - lang id (sub lang neutral Czech)",
  809. &NumErrors );
  810. //
  811. // Return total number of errors found.
  812. //
  813. return (NumErrors);
  814. }
  815. ////////////////////////////////////////////////////////////////////////////
  816. //
  817. // GetSetUserGeoId
  818. //
  819. // This routine tests the normal cases of the Get and Set Geo APIs.
  820. //
  821. // 09-12-00 JulieB Created.
  822. ////////////////////////////////////////////////////////////////////////////
  823. int GetSetUserGeoId()
  824. {
  825. int NumErrors = 0; // error count - to be returned
  826. int rc; // return code
  827. GEOID rcGeo; // return code
  828. GEOID rcGeo2; // return code
  829. rcGeo2 = GetUserGeoID(GEOCLASS_INVALID);
  830. CheckReturnValidW( rcGeo2,
  831. GEOID_NOT_AVAILABLE,
  832. NULL,
  833. NULL,
  834. "GetUserGeoID invalid geoclass",
  835. &NumErrors );
  836. rcGeo2 = GetUserGeoID(GEOCLASS_REGION);
  837. CheckReturnValidW( rcGeo2,
  838. GEOID_NOT_AVAILABLE,
  839. NULL,
  840. NULL,
  841. "GetUserGeoID region geoclass",
  842. &NumErrors );
  843. rcGeo = GetUserGeoID(GEOCLASS_NATION);
  844. CheckReturnValidW( rcGeo,
  845. 244,
  846. NULL,
  847. NULL,
  848. "GetUserGeoID",
  849. &NumErrors );
  850. rc = SetUserGeoID(242);
  851. CheckReturnValidW( rc,
  852. TRUE,
  853. NULL,
  854. NULL,
  855. "SetUserGeoID 242",
  856. &NumErrors );
  857. rc = SetUserGeoID(1);
  858. CheckReturnValidW( rc,
  859. FALSE,
  860. NULL,
  861. NULL,
  862. "SetUserGeoID invalid",
  863. &NumErrors );
  864. rc = SetUserGeoID(0);
  865. CheckReturnValidW( rc,
  866. FALSE,
  867. NULL,
  868. NULL,
  869. "SetUserGeoID invalid 2",
  870. &NumErrors );
  871. rcGeo2 = GetUserGeoID(GEOCLASS_NATION);
  872. CheckReturnValidW( rcGeo2,
  873. 242,
  874. NULL,
  875. NULL,
  876. "GetUserGeoID 242",
  877. &NumErrors );
  878. rc = SetUserGeoID(rcGeo);
  879. CheckReturnValidW( rc,
  880. TRUE,
  881. NULL,
  882. NULL,
  883. "SetUserGeoID back to original",
  884. &NumErrors );
  885. rcGeo2 = GetUserGeoID(GEOCLASS_NATION);
  886. CheckReturnValidW( rcGeo2,
  887. rcGeo,
  888. NULL,
  889. NULL,
  890. "GetUserGeoID original",
  891. &NumErrors );
  892. //
  893. // Return total number of errors found.
  894. //
  895. return (NumErrors);
  896. }