@@ -1492,17 +1492,64 @@ static int test_single_encodes(void) {
14921492}
14931493
14941494
1495- static int check_full_territory_name (const char * expectedName , const char * gotName , int expectedCode , int gotCode ) {
1495+ static int check_full_territory_name_english (int expectedCode , const char * expectedName , enum Territory territory ,
1496+ int alternative ) {
14961497 int nrTests = 0 ;
1498+ char gotName [MAX_TERRITORY_FULLNAME_LEN + 1 ];
1499+ int gotCode = getFullTerritoryNameEnglish (gotName , territory , alternative );
14971500 ++ nrTests ;
14981501 if (strcmp (expectedName , gotName )) {
14991502 found_error ();
1500- printf ("*** ERROR *** getFullTerritoryName error, expected name '%s', but got '%s'\n" , expectedName , gotName );
1503+ printf ("*** ERROR *** getFullTerritoryNameEnglish error, expected name '%s', but got '%s' for territory %d, alternative %d\n" ,
1504+ expectedName , gotName , (int ) territory , alternative );
15011505 }
15021506 ++ nrTests ;
15031507 if ((expectedCode && !gotCode ) || (!expectedCode && gotCode )) {
15041508 found_error ();
1505- printf ("*** ERROR *** getFullTerritoryName error, expected return code %d, but got %d\n" , expectedCode , gotCode );
1509+ printf ("*** ERROR *** getFullTerritoryNameEnglish error, expected return code %d, but got %d for territory %d, alternative %d\n" ,
1510+ expectedCode , gotCode , (int ) territory , alternative );
1511+ }
1512+ return nrTests ;
1513+ }
1514+
1515+
1516+ static int
1517+ check_full_territory_name_local (int expectedCode , const char * expectedName , enum Territory territory , int alternative ) {
1518+ int nrTests = 0 ;
1519+ char gotName [MAX_TERRITORY_FULLNAME_LEN + 1 ];
1520+ int gotCode = getFullTerritoryNameLocal (gotName , territory , alternative );
1521+ ++ nrTests ;
1522+ if (strcmp (expectedName , gotName )) {
1523+ found_error ();
1524+ printf ("*** ERROR *** getFullTerritoryNameLocal error, expected name '%s', but got '%s' for territory %d, alternative %d\n" ,
1525+ expectedName , gotName , (int ) territory , alternative );
1526+ }
1527+ ++ nrTests ;
1528+ if ((expectedCode && !gotCode ) || (!expectedCode && gotCode )) {
1529+ found_error ();
1530+ printf ("*** ERROR *** getFullTerritoryNameLocal error, expected return code %d, but got %d for territory %d, alternative %d\n" ,
1531+ expectedCode , gotCode , (int ) territory , alternative );
1532+ }
1533+ return nrTests ;
1534+ }
1535+
1536+
1537+ static int check_full_territory_name_local_in_alphabet (int expectedCode , const char * expectedName , enum Territory territory ,
1538+ int alternative , enum Alphabet alphabet ) {
1539+ int nrTests = 0 ;
1540+ char gotName [MAX_TERRITORY_FULLNAME_LEN + 1 ];
1541+ int gotCode = getFullTerritoryNameLocalInAlphabet (gotName , territory , alternative , alphabet );
1542+ ++ nrTests ;
1543+ if (strcmp (expectedName , gotName )) {
1544+ found_error ();
1545+ printf ("*** ERROR *** getFullTerritoryNameLocalInAlphabet error, expected name '%s', but got '%s' for territory %d, alternative %d\n" ,
1546+ expectedName , gotName , (int ) territory , alternative );
1547+ }
1548+ ++ nrTests ;
1549+ if ((expectedCode && !gotCode ) || (!expectedCode && gotCode )) {
1550+ found_error ();
1551+ printf ("*** ERROR *** getFullTerritoryNameLocalInAlphabet error, expected return code %d, but got %d for territory %d, alternative %d\n" ,
1552+ expectedCode , gotCode , (int ) territory , alternative );
15061553 }
15071554 return nrTests ;
15081555}
@@ -1568,31 +1615,63 @@ int territory_full_name_tests(void) {
15681615 printf ("*** ERROR *** Didn't find enough territory names, found %d, expected >= %d\n" , nrNames , minNames );
15691616 }
15701617
1571- ++ nrTests ;
1572- check_full_territory_name ("Nederland" , territoryName , getFullTerritoryNameLocal (territoryName , TERRITORY_NLD , 0 ), 0 );
1573- check_full_territory_name ("Nederland" , territoryName , getFullTerritoryNameLocalInAlphabet (territoryName , TERRITORY_NLD , 0 , ALPHABET_ROMAN ), 0 );
1574- check_full_territory_name ("" , territoryName , getFullTerritoryNameLocalInAlphabet (territoryName , TERRITORY_NLD , 0 , ALPHABET_GREEK ), 0 );
1575- check_full_territory_name ("" , territoryName , getFullTerritoryNameLocalInAlphabet (territoryName , TERRITORY_NLD , 0 , _ALPHABET_MIN ), 0 );
1576- check_full_territory_name ("" , territoryName , getFullTerritoryNameLocalInAlphabet (territoryName , TERRITORY_NLD , 0 , _ALPHABET_MAX ), 0 );
1577-
1578- check_full_territory_name ("Russia" , territoryName , getFullTerritoryNameEnglish (territoryName , TERRITORY_RUS , 0 ), 1 );
1579- check_full_territory_name ("Russian Federation" , territoryName , getFullTerritoryNameEnglish (territoryName , TERRITORY_RUS , 1 ), 0 );
1580- check_full_territory_name ("" , territoryName , getFullTerritoryNameEnglish (territoryName , TERRITORY_RUS , 2 ), 0 );
1581-
1582- check_full_territory_name ("Росси́я" , territoryName , getFullTerritoryNameLocalInAlphabet (territoryName , TERRITORY_RUS , 0 , ALPHABET_CYRILLIC ), 0 );
1583- check_full_territory_name ("" , territoryName , getFullTerritoryNameLocalInAlphabet (territoryName , TERRITORY_RUS , 1 , ALPHABET_CYRILLIC ), 0 );
1584- check_full_territory_name ("" , territoryName , getFullTerritoryNameLocalInAlphabet (territoryName , TERRITORY_RUS , 0 , ALPHABET_ROMAN ), 0 );
1585-
1586- check_full_territory_name ("Kazakhstan" , territoryName , getFullTerritoryNameEnglish (territoryName , TERRITORY_KAZ , 0 ), 0 );
1587- check_full_territory_name ("Kazakhstan" , territoryName , getFullTerritoryNameEnglish (territoryName , TERRITORY_KAZ , 1 ), 0 );
1588-
1589- check_full_territory_name ("Қазақстан" , territoryName , getFullTerritoryNameLocalInAlphabet (territoryName , TERRITORY_KAZ , 0 , ALPHABET_CYRILLIC ), 0 );
1590- check_full_territory_name ("" , territoryName , getFullTerritoryNameLocalInAlphabet (territoryName , TERRITORY_KAZ , 1 , ALPHABET_CYRILLIC ), 0 );
1591- check_full_territory_name ("Qazaqstan" , territoryName , getFullTerritoryNameLocalInAlphabet (territoryName , TERRITORY_KAZ , 0 , ALPHABET_ROMAN ), 1 );
1592- check_full_territory_name ("Qazaqstan" , territoryName , getFullTerritoryNameLocalInAlphabet (territoryName , TERRITORY_KAZ , 1 , ALPHABET_ROMAN ), 0 );
1593- check_full_territory_name ("" , territoryName , getFullTerritoryNameLocalInAlphabet (territoryName , TERRITORY_KAZ , 2 , ALPHABET_ROMAN ), 0 );
1594-
1595- // TODO Add many more tests here.
1618+ nrTests += check_full_territory_name_english (0 , "Netherland" , TERRITORY_NLD , 0 );
1619+ nrTests += check_full_territory_name_english (0 , "" , TERRITORY_NLD , 1 );
1620+
1621+ nrTests += check_full_territory_name_local (0 , "Nederland" , TERRITORY_NLD , 0 );
1622+ nrTests += check_full_territory_name_local (0 , "" , TERRITORY_NLD , 1 );
1623+
1624+ nrTests += check_full_territory_name_local_in_alphabet (0 , "Nederland" , TERRITORY_NLD , 0 , ALPHABET_ROMAN );
1625+ nrTests += check_full_territory_name_local_in_alphabet (0 , "" , TERRITORY_NLD , 1 , ALPHABET_ROMAN );
1626+ nrTests += check_full_territory_name_local_in_alphabet (0 , "" , TERRITORY_NLD , 0 , ALPHABET_GREEK );
1627+ nrTests += check_full_territory_name_local_in_alphabet (0 , "" , TERRITORY_NLD , 0 , _ALPHABET_MIN );
1628+ nrTests += check_full_territory_name_local_in_alphabet (0 , "" , TERRITORY_NLD , 0 , _ALPHABET_MAX );
1629+
1630+ nrTests += check_full_territory_name_english (1 , "Russia" , TERRITORY_RUS , 0 );
1631+ nrTests += check_full_territory_name_english (0 , "Russian Federation" , TERRITORY_RUS , 1 );
1632+
1633+ nrTests += check_full_territory_name_local (0 , "Росси́я" , TERRITORY_RUS , 0 );
1634+ nrTests += check_full_territory_name_local (0 , "" , TERRITORY_RUS , 0 );
1635+
1636+ nrTests += check_full_territory_name_local_in_alphabet (0 , "Росси́я" , TERRITORY_RUS , 0 , ALPHABET_CYRILLIC );
1637+ nrTests += check_full_territory_name_local_in_alphabet (0 , "" , TERRITORY_RUS , 0 , ALPHABET_ROMAN );
1638+ nrTests += check_full_territory_name_local_in_alphabet (0 , "" , TERRITORY_RUS , 0 , ALPHABET_GREEK );
1639+ nrTests += check_full_territory_name_local_in_alphabet (0 , "" , TERRITORY_RUS , 0 , _ALPHABET_MIN );
1640+ nrTests += check_full_territory_name_local_in_alphabet (0 , "" , TERRITORY_RUS , 0 , _ALPHABET_MAX );
1641+
1642+ nrTests += check_full_territory_name_english (0 , "Kazakhstan" , TERRITORY_KAZ , 0 );
1643+ nrTests += check_full_territory_name_english (0 , "" , TERRITORY_KAZ , 1 );
1644+
1645+ nrTests += check_full_territory_name_local (1 , "Қазақстан" , TERRITORY_KAZ , 0 );
1646+ nrTests += check_full_territory_name_local (0 , "Qazaqstan" , TERRITORY_KAZ , 1 );
1647+ nrTests += check_full_territory_name_local (0 , "" , TERRITORY_KAZ , 2 );
1648+
1649+ nrTests += check_full_territory_name_local_in_alphabet (0 , "Қазақстан" , TERRITORY_KAZ , 0 , ALPHABET_CYRILLIC );
1650+ nrTests += check_full_territory_name_local_in_alphabet (0 , "" , TERRITORY_KAZ , 1 , ALPHABET_CYRILLIC );
1651+ nrTests += check_full_territory_name_local_in_alphabet (0 , "Qazaqstan" , TERRITORY_KAZ , 0 , ALPHABET_ROMAN );
1652+ nrTests += check_full_territory_name_local_in_alphabet (0 , "" , TERRITORY_KAZ , 1 , ALPHABET_ROMAN );
1653+ nrTests += check_full_territory_name_local_in_alphabet (0 , "" , TERRITORY_KAZ , 0 , ALPHABET_GREEK );
1654+ nrTests += check_full_territory_name_local_in_alphabet (0 , "" , TERRITORY_KAZ , 0 , _ALPHABET_MIN );
1655+ nrTests += check_full_territory_name_local_in_alphabet (0 , "" , TERRITORY_KAZ , 0 , _ALPHABET_MAX );
1656+
1657+ nrTests += check_full_territory_name_english (0 , "Turkmenistan" , TERRITORY_TKM , 0 );
1658+ nrTests += check_full_territory_name_english (0 , "" , TERRITORY_TKM , 1 );
1659+
1660+ nrTests += check_full_territory_name_local (1 , "Türkmenistan" , TERRITORY_TKM , 0 );
1661+ nrTests += check_full_territory_name_local (1 , "Түркменистан" , TERRITORY_TKM , 1 );
1662+ nrTests += check_full_territory_name_local (0 , "تۆركمنيستآن" , TERRITORY_TKM , 2 );
1663+ nrTests += check_full_territory_name_local (0 , "" , TERRITORY_TKM , 3 );
1664+
1665+ nrTests += check_full_territory_name_local_in_alphabet (0 , "Türkmenistan" , TERRITORY_TKM , 0 , ALPHABET_ROMAN );
1666+ nrTests += check_full_territory_name_local_in_alphabet (0 , "" , TERRITORY_TKM , 1 , ALPHABET_ROMAN );
1667+ nrTests += check_full_territory_name_local_in_alphabet (0 , "Түркменистан" , TERRITORY_TKM , 0 , ALPHABET_CYRILLIC );
1668+ nrTests += check_full_territory_name_local_in_alphabet (0 , "" , TERRITORY_TKM , 1 , ALPHABET_CYRILLIC );
1669+ nrTests += check_full_territory_name_local_in_alphabet (0 , "تۆركمنيستآن" , TERRITORY_TKM , 0 , ALPHABET_ARABIC );
1670+ nrTests += check_full_territory_name_local_in_alphabet (0 , "" , TERRITORY_TKM , 1 , ALPHABET_ARABIC );
1671+
1672+ nrTests += check_full_territory_name_local_in_alphabet (0 , "" , TERRITORY_KAZ , 0 , ALPHABET_GREEK );
1673+ nrTests += check_full_territory_name_local_in_alphabet (0 , "" , TERRITORY_KAZ , 0 , _ALPHABET_MIN );
1674+ nrTests += check_full_territory_name_local_in_alphabet (0 , "" , TERRITORY_KAZ , 0 , _ALPHABET_MAX );
15961675 return nrTests ;
15971676}
15981677
0 commit comments