ReactOS Fundraising Campaign 2012
 
€ 11,198 / € 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

Definition at line 170 of file ctype_facets_test.cpp.

Referenced by ctype_facet().

{
# ifndef _STLP_NO_WCHAR_T
  CPPUNIT_ASSERT( has_facet<ctype<wchar_t> >(loc) );
  ctype<wchar_t> const& wct = use_facet<ctype<wchar_t> >(loc);
  //is
  {
    CPPUNIT_CHECK( wct.is(ctype_base::digit, L'0') );
    CPPUNIT_CHECK( wct.is(ctype_base::upper, L'A') );
    CPPUNIT_CHECK( wct.is(ctype_base::lower, L'a') );
    CPPUNIT_CHECK( wct.is(ctype_base::alpha, L'A') );
    CPPUNIT_CHECK( wct.is(ctype_base::space, L' ') );
    CPPUNIT_CHECK( !wct.is(ctype_base::space, L'2') );
    CPPUNIT_CHECK( wct.is(ctype_base::punct, L'.') );
    CPPUNIT_CHECK( wct.is(ctype_base::xdigit, L'a') );
  }

  //is range
  {
    wchar_t values[] = L"0Aa .";
    ctype_base::mask res[sizeof(values) / sizeof(wchar_t)];
    wct.is(values, values + (sizeof(values) / sizeof(wchar_t)), res);
    // '0'
    CPPUNIT_CHECK( (res[0] & ctype_base::print) != 0 );
    CPPUNIT_CHECK( (res[0] & ctype_base::digit) != 0 );
    CPPUNIT_CHECK( (res[0] & ctype_base::xdigit) != 0 );
    // 'A'
    CPPUNIT_CHECK( (res[1] & ctype_base::print) != 0 );
    CPPUNIT_CHECK( (res[1] & ctype_base::alpha) != 0 );
    CPPUNIT_CHECK( (res[1] & ctype_base::xdigit) != 0 );
    CPPUNIT_CHECK( (res[1] & ctype_base::upper) != 0 );
    // 'a'
    CPPUNIT_CHECK( (res[2] & ctype_base::print) != 0 );
    CPPUNIT_CHECK( (res[2] & ctype_base::alpha) != 0 );
    CPPUNIT_CHECK( (res[2] & ctype_base::xdigit) != 0 );
    CPPUNIT_CHECK( (res[2] & ctype_base::lower) != 0 );
    CPPUNIT_CHECK( (res[2] & ctype_base::space) == 0 );
    // ' '
    CPPUNIT_CHECK( (res[3] & ctype_base::print) != 0 );
    CPPUNIT_CHECK( (res[3] & ctype_base::space) != 0 );
    CPPUNIT_CHECK( (res[3] & ctype_base::digit) == 0 );
    // '.'
    CPPUNIT_CHECK( (res[4] & ctype_base::print) != 0 );
    CPPUNIT_CHECK( (res[4] & ctype_base::punct) != 0 );
    CPPUNIT_CHECK( (res[4] & ctype_base::digit) == 0 );
  }

  //scan_is
  {
    wchar_t range[] = L"abAc123 .";
    const wchar_t *rbeg = range;
    const wchar_t *rend = range + (sizeof(range) / sizeof(wchar_t));

    const wchar_t *res;
    res = wct.scan_is((ctype_base::mask)(ctype_base::alpha | ctype_base::lower), rbeg, rend);
    CPPUNIT_CHECK( res != rend );
    CPPUNIT_CHECK( *res == L'a' );

    res = wct.scan_is(ctype_base::upper, rbeg, rend);
    CPPUNIT_CHECK( res != rend );
    CPPUNIT_CHECK( *res == L'A' );

    res = wct.scan_is(ctype_base::punct, rbeg, rend);
    CPPUNIT_CHECK( res != rend );
    CPPUNIT_CHECK( *res == L'.' );
  }

  //scan_not
  {
    wchar_t range[] = L"abAc123 .";
    const wchar_t *rbeg = range;
    const wchar_t *rend = range + (sizeof(range) / sizeof(wchar_t));

    const wchar_t *res;
    res = wct.scan_not((ctype_base::mask)(ctype_base::alpha | ctype_base::lower), rbeg, rend);
    CPPUNIT_CHECK( res != rend );
    CPPUNIT_CHECK( *res == L'1' );

    res = wct.scan_not(ctype_base::alpha, rbeg, rend);
    CPPUNIT_CHECK( res != rend );
    CPPUNIT_CHECK( *res == L'1' );

    res = wct.scan_not(ctype_base::punct, rbeg, rend);
    CPPUNIT_CHECK( res != rend );
    CPPUNIT_CHECK( *res == L'a' );
  }

  //toupper
  {
    CPPUNIT_CHECK( wct.toupper(L'a') == L'A' );
    CPPUNIT_CHECK( wct.toupper(L'A') == L'A' );
    CPPUNIT_CHECK( wct.toupper(L'1') == L'1' );
  }

  //toupper range
  {
    wchar_t range[] = L"abAc1";
    wchar_t expected_range[] = L"ABAC1";
    wct.toupper(range, range + sizeof(range) / sizeof(wchar_t));
    CPPUNIT_CHECK( equal(range, range + sizeof(range) / sizeof(wchar_t), expected_range) );
  }

  //tolower
  {
    CPPUNIT_CHECK( wct.tolower(L'A') == L'a' );
    CPPUNIT_CHECK( wct.tolower(L'a') == L'a' );
    CPPUNIT_CHECK( wct.tolower(L'1') == L'1' );
  }

  //tolower range
  {
    wchar_t range[] = L"ABaC1";
    wchar_t expected_range[] = L"abac1";
    wct.tolower(range, range + sizeof(range) / sizeof(wchar_t));
    CPPUNIT_CHECK( equal(range, range + sizeof(range) / sizeof(wchar_t), expected_range) );
  }

  //widen
  {
    CPPUNIT_CHECK( wct.widen('a') == L'a' );
  }

  //widen range
  {
    char range[] = "ABaC1";
    wchar_t res[sizeof(range)];
    wchar_t expected_res[] = L"ABaC1";
    wct.widen(range, range + sizeof(range), res);
    CPPUNIT_CHECK( equal(expected_res, expected_res + sizeof(range), res) );
  }

  //narrow
  {
    CPPUNIT_CHECK( wct.narrow(L'a', 'b') == L'a' );
  }

  //narrow range
  {
    wchar_t range[] = L"ABaC1";
    char res[sizeof(range) / sizeof(wchar_t)];
    char expected_res[] = "ABaC1";
    wct.narrow(range, range + sizeof(range) / sizeof(wchar_t), 'b', res);
    CPPUNIT_CHECK( equal(expected_res, expected_res + sizeof(range) / sizeof(wchar_t), res) );
  }
# endif
}

Generated on Thu Oct 25 2012 06:46:59 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.