ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

money_facets_test.cpp
Go to the documentation of this file.
00001 #include "locale_test.h"
00002 
00003 #if !defined (STLPORT) || !defined (_STLP_USE_NO_IOSTREAMS)
00004 #  include <locale>
00005 #  include <sstream>
00006 #  include <stdexcept>
00007 
00008 #  if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
00009 using namespace std;
00010 #  endif
00011 
00012 struct ref_monetary {
00013   const char *name;
00014   const char *money_int_prefix;
00015   const char *money_int_prefix_old;
00016   const char *money_prefix;
00017   const char *money_suffix;
00018   const char *money_decimal_point;
00019   const char *money_thousands_sep;
00020 };
00021 
00022 static const ref_monetary tested_locales[] = {
00023 //{  name,         money_int_prefix, money_int_prefix_old, money_prefix, money_suffix, money_decimal_point, money_thousands_sep},
00024 #  if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS)
00025   { "fr_FR",       "EUR ",           "FRF ",               "",           "",           ",",
00026 #    if defined (WIN32) || defined (_WIN32)
00027                                                                                                             "\xa0" },
00028 #    else
00029                                                                                                             " " },
00030 #    endif
00031   { "ru_RU.koi8r", "RUB ",           "RUR ",               "",           "\xd2\xd5\xc2", ".",               " " },
00032   { "en_GB",       "GBP ",           "",                   "\xa3",       "",           ".",                 "," },
00033   { "en_US",       "USD ",           "",                   "$",          "",           ".",                 "," },
00034 #  endif
00035   { "C",           "",               "",                   "",           "",           " ",                 " " },
00036 };
00037 
00038 
00039 const ref_monetary* LocaleTest::_get_ref_monetary(size_t i)
00040 {
00041   if (i < sizeof(tested_locales) / sizeof(tested_locales[0])) {
00042     return tested_locales + i;
00043   }
00044   return 0;
00045 }
00046 
00047 const char* LocaleTest::_get_ref_monetary_name(const ref_monetary* _ref)
00048 {
00049   return _ref->name;
00050 }
00051 
00052 void LocaleTest::_money_put_get( const locale& loc, const ref_monetary* rl )
00053 {
00054   _money_put_get2(loc, loc, rl);
00055 }
00056 
00057 void LocaleTest::_money_put_get2( const locale& loc, const locale& streamLoc, const ref_monetary* prl )
00058 {
00059   const ref_monetary &rl = *prl;
00060   CPPUNIT_ASSERT( has_facet<money_put<char> >(loc) );
00061   money_put<char> const& fmp = use_facet<money_put<char> >(loc);
00062   CPPUNIT_ASSERT( has_facet<money_get<char> >(loc) );
00063   money_get<char> const& fmg = use_facet<money_get<char> >(loc);
00064 
00065   ostringstream ostr;
00066   ostr.imbue(streamLoc);
00067   ostr << showbase;
00068 
00069   //Check a positive value (international format)
00070   {
00071     string str_res;
00072     //money_put
00073     {
00074       CPPUNIT_ASSERT( (has_facet<moneypunct<char, true> >(loc)) );
00075       moneypunct<char, true> const& intl_fmp = use_facet<moneypunct<char, true> >(loc);
00076 
00077       ostreambuf_iterator<char, char_traits<char> > res = fmp.put(ostr, true, ostr, ' ', 123456);
00078 
00079       CPPUNIT_ASSERT( !res.failed() );
00080       str_res = ostr.str();
00081       //CPPUNIT_MESSAGE(str_res.c_str());
00082 
00083       size_t fieldIndex = 0;
00084       size_t index = 0;
00085 
00086       //On a positive value we skip the sign field if exists:
00087       if (intl_fmp.pos_format().field[fieldIndex] == money_base::sign) {
00088         ++fieldIndex;
00089       }
00090       // international currency abbreviation, if it is before value
00091 
00092       /*
00093        * int_curr_symbol
00094        *
00095        *   The international currency symbol. The operand is a four-character
00096        *   string, with the first three characters containing the alphabetic
00097        *   international currency symbol in accordance with those specified
00098        *   in the ISO 4217 specification. The fourth character is the character used
00099        *   to separate the international currency symbol from the monetary quantity.
00100        *
00101        * (http://www.opengroup.org/onlinepubs/7990989775/xbd/locale.html)
00102        */
00103       string::size_type p = strlen( rl.money_int_prefix );
00104       if (p != 0) {
00105         CPPUNIT_ASSERT( intl_fmp.pos_format().field[fieldIndex] == money_base::symbol );
00106         string::size_type p_old = strlen( rl.money_int_prefix_old );
00107         CPPUNIT_ASSERT( (str_res.substr(index, p) == rl.money_int_prefix) ||
00108                         ((p_old != 0) &&
00109                          (str_res.substr(index, p_old) == rl.money_int_prefix_old)) );
00110         if ( str_res.substr(index, p) == rl.money_int_prefix ) {
00111           index += p;
00112         } else {
00113           index += p_old;
00114         }
00115         ++fieldIndex;
00116       }
00117 
00118       // space after currency
00119       if (intl_fmp.pos_format().field[fieldIndex] == money_base::space ||
00120           intl_fmp.pos_format().field[fieldIndex] == money_base::none) {
00121         // iternational currency symobol has four chars, one of these chars
00122         // is separator, so if format has space on this place, it should
00123         // be skipped.
00124         ++fieldIndex;
00125       }
00126 
00127       // sign
00128       if (intl_fmp.pos_format().field[fieldIndex] == money_base::sign) {
00129         ++fieldIndex;
00130       }
00131 
00132       // value
00133       CPPUNIT_ASSERT( str_res[index++] == '1' );
00134       if (!intl_fmp.grouping().empty()) {
00135         CPPUNIT_ASSERT( str_res[index++] == /* intl_fmp.thousands_sep() */ *rl.money_thousands_sep );
00136       }
00137       CPPUNIT_ASSERT( str_res[index++] == '2' );
00138       CPPUNIT_ASSERT( str_res[index++] == '3' );
00139       CPPUNIT_ASSERT( str_res[index++] == '4' );
00140       if (intl_fmp.frac_digits() != 0) {
00141         CPPUNIT_ASSERT( str_res[index++] == /* intl_fmp.decimal_point() */ *rl.money_decimal_point );
00142       }
00143       CPPUNIT_ASSERT( str_res[index++] == '5' );
00144       CPPUNIT_ASSERT( str_res[index++] == '6' );
00145       ++fieldIndex;
00146 
00147       // sign
00148       if (intl_fmp.pos_format().field[fieldIndex] == money_base::sign) {
00149         ++fieldIndex;
00150       }
00151 
00152       // space
00153       if (intl_fmp.pos_format().field[fieldIndex] == money_base::space ) {
00154         CPPUNIT_ASSERT( str_res[index++] == ' ' );
00155         ++fieldIndex;
00156       }
00157 
00158       // sign
00159       if (intl_fmp.pos_format().field[fieldIndex] == money_base::sign) {
00160         ++fieldIndex;
00161       }
00162 
00163       //as space cannot be last the only left format can be none:
00164       while ( fieldIndex < 3 ) {
00165         CPPUNIT_ASSERT( intl_fmp.pos_format().field[fieldIndex] == money_base::none );
00166         ++fieldIndex;
00167       }
00168     }
00169 
00170     //money_get
00171     {
00172       ios_base::iostate err = ios_base::goodbit;
00173       string digits;
00174 
00175       istringstream istr(str_res);
00176       ostr.str( "" );
00177       ostr.clear();
00178       fmg.get(istr, istreambuf_iterator<char, char_traits<char> >(), true, ostr, err, digits);
00179       CPPUNIT_ASSERT( (err & (ios_base::failbit | ios_base::badbit)) == 0 );
00180       CPPUNIT_ASSERT( digits == "123456" );
00181     }
00182   }
00183 
00184   ostr.str("");
00185   //Check a negative value (national format)
00186   {
00187     CPPUNIT_ASSERT( (has_facet<moneypunct<char, false> >(loc)) );
00188     moneypunct<char, false> const& dom_fmp = use_facet<moneypunct<char, false> >(loc);
00189     string str_res;
00190     //Check money_put
00191     {
00192       ostreambuf_iterator<char, char_traits<char> > res = fmp.put(ostr, false, ostr, ' ', -123456);
00193 
00194       CPPUNIT_ASSERT( !res.failed() );
00195       str_res = ostr.str();
00196       //CPPUNIT_MESSAGE(str_res.c_str());
00197 
00198       size_t fieldIndex = 0;
00199       size_t index = 0;
00200 
00201       if (dom_fmp.neg_format().field[fieldIndex] == money_base::sign) {
00202         CPPUNIT_ASSERT( str_res.substr(index, dom_fmp.negative_sign().size()) == dom_fmp.negative_sign() );
00203         index += dom_fmp.negative_sign().size();
00204         ++fieldIndex;
00205       }
00206 
00207       string::size_type p = strlen( rl.money_prefix );
00208       if (p != 0) {
00209         CPPUNIT_ASSERT( str_res.substr(index, p) == rl.money_prefix );
00210         index += p;
00211         ++fieldIndex;
00212       }
00213       if (dom_fmp.neg_format().field[fieldIndex] == money_base::space ||
00214           dom_fmp.neg_format().field[fieldIndex] == money_base::none) {
00215         CPPUNIT_ASSERT( str_res[index++] == ' ' );
00216         ++fieldIndex;
00217       }
00218 
00219       CPPUNIT_ASSERT( str_res[index++] == '1' );
00220       if (!dom_fmp.grouping().empty()) {
00221         CPPUNIT_ASSERT( str_res[index++] == dom_fmp.thousands_sep() );
00222       }
00223       CPPUNIT_ASSERT( str_res[index++] == '2' );
00224       CPPUNIT_ASSERT( str_res[index++] == '3' );
00225       CPPUNIT_ASSERT( str_res[index++] == '4' );
00226       if (dom_fmp.frac_digits() != 0) {
00227         CPPUNIT_ASSERT( str_res[index++] == dom_fmp.decimal_point() );
00228       }
00229       CPPUNIT_ASSERT( str_res[index++] == '5' );
00230       CPPUNIT_ASSERT( str_res[index++] == '6' );
00231       ++fieldIndex;
00232 
00233       //space cannot be last:
00234       if ((fieldIndex < 3) &&
00235           dom_fmp.neg_format().field[fieldIndex] == money_base::space) {
00236         CPPUNIT_ASSERT( str_res[index++] == ' ' );
00237         ++fieldIndex;
00238       }
00239 
00240       if (fieldIndex == 3) {
00241         //If none is last we should not add anything to the resulting string:
00242         if (dom_fmp.neg_format().field[fieldIndex] == money_base::none) {
00243           CPPUNIT_ASSERT( index == str_res.size() );
00244         } else {
00245           CPPUNIT_ASSERT( dom_fmp.neg_format().field[fieldIndex] == money_base::symbol );
00246           CPPUNIT_ASSERT( str_res.substr(index, strlen(rl.money_suffix)) == rl.money_suffix );
00247         }
00248       }
00249     }
00250 
00251     //money_get
00252     {
00253       ios_base::iostate err = ios_base::goodbit;
00254 #  if defined (STLPORT)
00255       _STLP_LONGEST_FLOAT_TYPE val;
00256 #  else
00257       long double val;
00258 #  endif
00259 
00260       istringstream istr(str_res);
00261       fmg.get(istr, istreambuf_iterator<char, char_traits<char> >(), false, ostr, err, val);
00262       CPPUNIT_ASSERT( (err & (ios_base::failbit | ios_base::badbit)) == 0 );
00263       if (dom_fmp.negative_sign().empty()) {
00264         //Without negative sign there is no way to guess the resulting amount sign ("C" locale):
00265         CPPUNIT_ASSERT( val == 123456 );
00266       }
00267       else {
00268         CPPUNIT_ASSERT( val == -123456 );
00269       }
00270     }
00271   }
00272 }
00273 
00274 
00275 // Test for bug in case when number of digits in value less then number
00276 // of digits in fraction. I.e. '9' should be printed as '0.09',
00277 // if x.frac_digits() == 2.
00278 
00279 void LocaleTest::_money_put_X_bug( const locale& loc, const ref_monetary* prl )
00280 {
00281   const ref_monetary &rl = *prl;
00282   CPPUNIT_ASSERT( has_facet<money_put<char> >(loc) );
00283   money_put<char> const& fmp = use_facet<money_put<char> >(loc);
00284 
00285   ostringstream ostr;
00286   ostr.imbue(loc);
00287   ostr << showbase;
00288 
00289   // ostr.str("");
00290   // Check value with one decimal digit:
00291   {
00292     CPPUNIT_ASSERT( (has_facet<moneypunct<char, false> >(loc)) );
00293     moneypunct<char, false> const& dom_fmp = use_facet<moneypunct<char, false> >(loc);
00294     string str_res;
00295     // Check money_put
00296     {
00297       ostreambuf_iterator<char, char_traits<char> > res = fmp.put(ostr, false, ostr, ' ', 9);
00298 
00299       CPPUNIT_ASSERT( !res.failed() );
00300       str_res = ostr.str();
00301 
00302       size_t fieldIndex = 0;
00303       size_t index = 0;
00304 
00305       if (dom_fmp.pos_format().field[fieldIndex] == money_base::sign) {
00306         CPPUNIT_ASSERT( str_res.substr(index, dom_fmp.positive_sign().size()) == dom_fmp.positive_sign() );
00307         index += dom_fmp.positive_sign().size();
00308         ++fieldIndex;
00309       }
00310 
00311       string::size_type p = strlen( rl.money_prefix );
00312       if (p != 0) {
00313         CPPUNIT_ASSERT( str_res.substr(index, p) == rl.money_prefix );
00314         index += p;
00315         ++fieldIndex;
00316       }
00317       if (dom_fmp.neg_format().field[fieldIndex] == money_base::space ||
00318           dom_fmp.neg_format().field[fieldIndex] == money_base::none) {
00319         CPPUNIT_ASSERT( str_res[index++] == ' ' );
00320         ++fieldIndex;
00321       }
00322       if (dom_fmp.frac_digits() != 0) {
00323         CPPUNIT_ASSERT( str_res[index++] == '0' );
00324         CPPUNIT_ASSERT( str_res[index++] == dom_fmp.decimal_point() );
00325         for ( int fd = 1; fd < dom_fmp.frac_digits(); ++fd ) {
00326           CPPUNIT_ASSERT( str_res[index++] == '0' );
00327         }
00328       }
00329       CPPUNIT_ASSERT( str_res[index++] == '9' );
00330       ++fieldIndex;
00331 
00332       //space cannot be last:
00333       if ((fieldIndex < 3) &&
00334           dom_fmp.neg_format().field[fieldIndex] == money_base::space) {
00335         CPPUNIT_ASSERT( str_res[index++] == ' ' );
00336         ++fieldIndex;
00337       }
00338 
00339       if (fieldIndex == 3) {
00340         //If none is last we should not add anything to the resulting string:
00341         if (dom_fmp.neg_format().field[fieldIndex] == money_base::none) {
00342           CPPUNIT_ASSERT( index == str_res.size() );
00343         } else {
00344           CPPUNIT_ASSERT( dom_fmp.neg_format().field[fieldIndex] == money_base::symbol );
00345           CPPUNIT_ASSERT( str_res.substr(index, strlen(rl.money_suffix)) == rl.money_suffix );
00346         }
00347       }
00348     }
00349   }
00350 
00351   ostr.str("");
00352   // Check value with two decimal digit:
00353   {
00354     CPPUNIT_ASSERT( (has_facet<moneypunct<char, false> >(loc)) );
00355     moneypunct<char, false> const& dom_fmp = use_facet<moneypunct<char, false> >(loc);
00356     string str_res;
00357     // Check money_put
00358     {
00359       ostreambuf_iterator<char, char_traits<char> > res = fmp.put(ostr, false, ostr, ' ', 90);
00360 
00361       CPPUNIT_ASSERT( !res.failed() );
00362       str_res = ostr.str();
00363 
00364       size_t fieldIndex = 0;
00365       size_t index = 0;
00366 
00367       if (dom_fmp.pos_format().field[fieldIndex] == money_base::sign) {
00368         CPPUNIT_ASSERT( str_res.substr(index, dom_fmp.positive_sign().size()) == dom_fmp.positive_sign() );
00369         index += dom_fmp.positive_sign().size();
00370         ++fieldIndex;
00371       }
00372 
00373       string::size_type p = strlen( rl.money_prefix );
00374       if (p != 0) {
00375         CPPUNIT_ASSERT( str_res.substr(index, p) == rl.money_prefix );
00376         index += p;
00377         ++fieldIndex;
00378       }
00379       if (dom_fmp.neg_format().field[fieldIndex] == money_base::space ||
00380           dom_fmp.neg_format().field[fieldIndex] == money_base::none) {
00381         CPPUNIT_ASSERT( str_res[index++] == ' ' );
00382         ++fieldIndex;
00383       }
00384       if (dom_fmp.frac_digits() != 0) {
00385         CPPUNIT_ASSERT( str_res[index++] == '0' );
00386         CPPUNIT_ASSERT( str_res[index++] == dom_fmp.decimal_point() );
00387         for ( int fd = 1; fd < dom_fmp.frac_digits() - 1; ++fd ) {
00388           CPPUNIT_ASSERT( str_res[index++] == '0' );
00389         }
00390       }
00391       CPPUNIT_ASSERT( str_res[index++] == '9' );
00392       if (dom_fmp.frac_digits() != 0) {
00393         CPPUNIT_ASSERT( str_res[index++] == '0' );
00394       }
00395       ++fieldIndex;
00396 
00397       //space cannot be last:
00398       if ((fieldIndex < 3) &&
00399           dom_fmp.neg_format().field[fieldIndex] == money_base::space) {
00400         CPPUNIT_ASSERT( str_res[index++] == ' ' );
00401         ++fieldIndex;
00402       }
00403 
00404       if (fieldIndex == 3) {
00405         //If none is last we should not add anything to the resulting string:
00406         if (dom_fmp.neg_format().field[fieldIndex] == money_base::none) {
00407           CPPUNIT_ASSERT( index == str_res.size() );
00408         } else {
00409           CPPUNIT_ASSERT( dom_fmp.neg_format().field[fieldIndex] == money_base::symbol );
00410           CPPUNIT_ASSERT( str_res.substr(index, strlen(rl.money_suffix)) == rl.money_suffix );
00411         }
00412       }
00413     }
00414   }
00415 }
00416 
00417 typedef void (LocaleTest::*_Test) (const locale&, const ref_monetary*);
00418 static void test_supported_locale(LocaleTest& inst, _Test __test) {
00419   size_t n = sizeof(tested_locales) / sizeof(tested_locales[0]);
00420   for (size_t i = 0; i < n; ++i) {
00421     locale loc;
00422 #  if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS)
00423     try
00424 #  endif
00425     {
00426       locale tmp(tested_locales[i].name);
00427       loc = tmp;
00428     }
00429 #  if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS)
00430     catch (runtime_error const&) {
00431       //This locale is not supported.
00432       continue;
00433     }
00434 #  endif
00435     CPPUNIT_MESSAGE( loc.name().c_str() );
00436     (inst.*__test)(loc, tested_locales + i);
00437 
00438     {
00439       locale tmp(locale::classic(), tested_locales[i].name, locale::monetary);
00440       loc = tmp;
00441     }
00442     (inst.*__test)(loc, tested_locales + i);
00443 
00444     {
00445       locale tmp0(locale::classic(), new moneypunct_byname<char, true>(tested_locales[i].name));
00446       locale tmp1(tmp0, new moneypunct_byname<char, false>(tested_locales[i].name));
00447       loc = tmp1;
00448     }
00449     (inst.*__test)(loc, tested_locales + i);
00450   }
00451 }
00452 
00453 void LocaleTest::money_put_get()
00454 { test_supported_locale(*this, &LocaleTest::_money_put_get); }
00455 
00456 void LocaleTest::money_put_X_bug()
00457 { test_supported_locale(*this, &LocaleTest::_money_put_X_bug); }
00458 
00459 void LocaleTest::moneypunct_by_name()
00460 {
00461   /*
00462    * Check of the 22.1.1.2.7 standard point. Construction of a locale
00463    * instance from a null pointer or an unknown name should result in
00464    * a runtime_error exception.
00465    */
00466 #  if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS)
00467 #    if defined (STLPORT) || !defined (__GNUC__)
00468   try {
00469     locale loc(locale::classic(), new moneypunct_byname<char, true>(static_cast<char const*>(0)));
00470     CPPUNIT_FAIL;
00471   }
00472   catch (runtime_error const&) {
00473   }
00474   catch (...) {
00475     CPPUNIT_FAIL;
00476   }
00477 #    endif
00478 
00479   try {
00480     locale loc(locale::classic(), new moneypunct_byname<char, true>("yasli_language"));
00481     CPPUNIT_FAIL;
00482   }
00483   catch (runtime_error const&) {
00484   }
00485   catch (...) {
00486     CPPUNIT_FAIL;
00487   }
00488 
00489   try {
00490     string veryLongFacetName("LC_MONETARY=");
00491     veryLongFacetName.append(512, '?');
00492     locale loc(locale::classic(), new moneypunct_byname<char, true>(veryLongFacetName.c_str()));
00493     CPPUNIT_FAIL;
00494   }
00495   catch (runtime_error const& /* e */) {
00496     //CPPUNIT_MESSAGE( e.what() );
00497   }
00498   catch (...) {
00499     CPPUNIT_FAIL;
00500   }
00501 
00502 #    if defined (STLPORT) || !defined (__GNUC__)
00503   try {
00504     locale loc(locale::classic(), new moneypunct_byname<char, false>(static_cast<char const*>(0)));
00505     CPPUNIT_FAIL;
00506   }
00507   catch (runtime_error const&) {
00508   }
00509   catch (...) {
00510     CPPUNIT_FAIL;
00511   }
00512 #    endif
00513 
00514   try {
00515     locale loc(locale::classic(), new moneypunct_byname<char, false>("yasli_language"));
00516     CPPUNIT_FAIL;
00517   }
00518   catch (runtime_error const&) {
00519   }
00520   catch (...) {
00521     CPPUNIT_FAIL;
00522   }
00523 
00524   try {
00525     string veryLongFacetName("LC_MONETARY=");
00526     veryLongFacetName.append(512, '?');
00527     locale loc(locale::classic(), new moneypunct_byname<char, false>(veryLongFacetName.c_str()));
00528     CPPUNIT_FAIL;
00529   }
00530   catch (runtime_error const& /* e */) {
00531     //CPPUNIT_MESSAGE( e.what() );
00532   }
00533   catch (...) {
00534     CPPUNIT_FAIL;
00535   }
00536 
00537   try {
00538     locale loc(locale::classic(), new moneypunct_byname<char, false>("C"));
00539     moneypunct<char, false> const& cfacet_byname = use_facet<moneypunct<char, false> >(loc);
00540     moneypunct<char, false> const& cfacet = use_facet<moneypunct<char, false> >(locale::classic());
00541 
00542     money_base::pattern cp = cfacet.pos_format();
00543     money_base::pattern cp_bn = cfacet_byname.pos_format();
00544     CPPUNIT_CHECK( cp_bn.field[0] == cp.field[0] );
00545     CPPUNIT_CHECK( cp_bn.field[1] == cp.field[1] );
00546     CPPUNIT_CHECK( cp_bn.field[2] == cp.field[2] );
00547     CPPUNIT_CHECK( cp_bn.field[3] == cp.field[3] );
00548 
00549     CPPUNIT_CHECK( cfacet_byname.frac_digits() == cfacet.frac_digits() );
00550     if (cfacet_byname.frac_digits() != 0)
00551       CPPUNIT_CHECK( cfacet_byname.decimal_point() == cfacet.decimal_point() );
00552     CPPUNIT_CHECK( cfacet_byname.grouping() == cfacet.grouping() );
00553     if (!cfacet_byname.grouping().empty())
00554       CPPUNIT_CHECK( cfacet_byname.thousands_sep() == cfacet.thousands_sep() );
00555     CPPUNIT_CHECK( cfacet_byname.positive_sign() == cfacet.positive_sign() );
00556     CPPUNIT_CHECK( cfacet_byname.negative_sign() == cfacet.negative_sign() );
00557   }
00558   catch (runtime_error const& /* e */) {
00559     /* CPPUNIT_MESSAGE( e.what() ); */
00560     CPPUNIT_FAIL;
00561   }
00562   catch (...) {
00563     CPPUNIT_FAIL;
00564   }
00565 
00566   try {
00567     locale loc(locale::classic(), new moneypunct_byname<char, true>("C"));
00568     moneypunct<char, true> const& cfacet_byname = use_facet<moneypunct<char, true> >(loc);
00569     moneypunct<char, true> const& cfacet = use_facet<moneypunct<char, true> >(locale::classic());
00570 
00571     money_base::pattern cp = cfacet.pos_format();
00572     money_base::pattern cp_bn = cfacet_byname.pos_format();
00573     CPPUNIT_CHECK( cp_bn.field[0] == cp.field[0] );
00574     CPPUNIT_CHECK( cp_bn.field[1] == cp.field[1] );
00575     CPPUNIT_CHECK( cp_bn.field[2] == cp.field[2] );
00576     CPPUNIT_CHECK( cp_bn.field[3] == cp.field[3] );
00577 
00578     CPPUNIT_CHECK( cfacet_byname.frac_digits() == cfacet.frac_digits() );
00579     if (cfacet_byname.frac_digits() != 0)
00580       CPPUNIT_CHECK( cfacet_byname.decimal_point() == cfacet.decimal_point() );
00581     CPPUNIT_CHECK( cfacet_byname.grouping() == cfacet.grouping() );
00582     if (!cfacet_byname.grouping().empty())
00583       CPPUNIT_CHECK( cfacet_byname.thousands_sep() == cfacet.thousands_sep() );
00584     CPPUNIT_CHECK( cfacet_byname.positive_sign() == cfacet.positive_sign() );
00585     CPPUNIT_CHECK( cfacet_byname.negative_sign() == cfacet.negative_sign() );
00586   }
00587   catch (runtime_error const& /* e */) {
00588     /* CPPUNIT_MESSAGE( e.what() ); */
00589     CPPUNIT_FAIL;
00590   }
00591   catch (...) {
00592     CPPUNIT_FAIL;
00593   }
00594 
00595   try {
00596     // On platform without real localization support we should rely on the "C" locale facet.
00597     locale loc(locale::classic(), new moneypunct_byname<char, false>(""));
00598   }
00599   catch (runtime_error const& /* e */) {
00600     /* CPPUNIT_MESSAGE( e.what() ); */
00601     CPPUNIT_FAIL;
00602   }
00603   catch (...) {
00604     CPPUNIT_FAIL;
00605   }
00606 
00607 #    if !defined (STLPORT) || !defined (_STLP_NO_WCHAR_T)
00608 #      if defined (STLPORT) || !defined (__GNUC__)
00609   try {
00610     locale loc(locale::classic(), new moneypunct_byname<wchar_t, true>(static_cast<char const*>(0)));
00611     CPPUNIT_FAIL;
00612   }
00613   catch (runtime_error const&) {
00614   }
00615   catch (...) {
00616     CPPUNIT_FAIL;
00617   }
00618 #      endif
00619 
00620   try {
00621     locale loc(locale::classic(), new moneypunct_byname<wchar_t, true>("yasli_language"));
00622     CPPUNIT_FAIL;
00623   }
00624   catch (runtime_error const&) {
00625   }
00626   catch (...) {
00627     CPPUNIT_FAIL;
00628   }
00629 
00630 #      if defined (STLPORT) || !defined (__GNUC__)
00631   try {
00632     locale loc(locale::classic(), new moneypunct_byname<wchar_t, false>(static_cast<char const*>(0)));
00633     CPPUNIT_FAIL;
00634   }
00635   catch (runtime_error const&) {
00636   }
00637   catch (...) {
00638     CPPUNIT_FAIL;
00639   }
00640 #      endif
00641 
00642   try {
00643     locale loc(locale::classic(), new moneypunct_byname<wchar_t, false>("yasli_language"));
00644     CPPUNIT_FAIL;
00645   }
00646   catch (runtime_error const&) {
00647   }
00648   catch (...) {
00649     CPPUNIT_FAIL;
00650   }
00651 #    endif
00652 #  endif
00653 }
00654 
00655 #endif

Generated on Fri May 25 2012 04:33:57 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.