inline bool
 would_form_universal_char (StringT const &value)
 {
     if ('u' != value[0] && 'U' != value[0])
         return false;
     if ('u' == value[0] && value.size() < 5)
         return false;
     if ('U' == value[0] && value.size() < 9)
         return false;
 
 typename StringT::size_type pos = 
     value.find_first_not_of("0123456789abcdefABCDEF", 1);
     
     if (StringT::npos == pos || 
         ('u' == value[0] && pos > 5) ||
         ('U' == value[0] && pos > 9))
     {
         return true;        // would form an universal char
     }
     return false;
 }
Esempio n. 2
0
void CheckFind()
{
    StringT E = "";
    StringT X = "x";
    StringT Y = "y";
    StringT S = "xxx";

    EXPECT_EQ(E.find(E),                                0u);
    EXPECT_EQ(S.find(E),                                0u);
    EXPECT_EQ(E.find(E, 2),                             StringT::npos);
    EXPECT_EQ(S.find(E, 2),                             2u);
    EXPECT_EQ(E.find(E, 8),                             StringT::npos);
    EXPECT_EQ(S.find(E, 8),                             StringT::npos);
    EXPECT_EQ(E.find(E, StringT::npos),                 StringT::npos);
    EXPECT_EQ(S.find(E, StringT::npos),                 StringT::npos);

    EXPECT_EQ(E.find_first_of(E),                       StringT::npos);
    EXPECT_EQ(S.find_first_of(E),                       StringT::npos);
    EXPECT_EQ(E.find_first_of(E, 2),                    StringT::npos);
    EXPECT_EQ(S.find_first_of(E, 2),                    StringT::npos);
    EXPECT_EQ(E.find_first_of(E, 8),                    StringT::npos);
    EXPECT_EQ(S.find_first_of(E, 8),                    StringT::npos);
    EXPECT_EQ(E.find_first_of(E, StringT::npos),        StringT::npos);
    EXPECT_EQ(S.find_first_of(E, StringT::npos),        StringT::npos);
    EXPECT_EQ(E.find_first_of(X),                       StringT::npos);
    EXPECT_EQ(S.find_first_of(X),                       0u);
    EXPECT_EQ(E.find_first_of(X, 2),                    StringT::npos);
    EXPECT_EQ(S.find_first_of(X, 2),                    2u);
    EXPECT_EQ(E.find_first_of(X, 8),                    StringT::npos);
    EXPECT_EQ(S.find_first_of(X, 8),                    StringT::npos);
    EXPECT_EQ(E.find_first_of(X, StringT::npos),        StringT::npos);
    EXPECT_EQ(S.find_first_of(X, StringT::npos),        StringT::npos);
    EXPECT_EQ(E.find_first_of(Y, 2),                    StringT::npos);
    EXPECT_EQ(S.find_first_of(Y, 2),                    StringT::npos);
    EXPECT_EQ(E.find_first_of(Y, 8),                    StringT::npos);
    EXPECT_EQ(S.find_first_of(Y, 8),                    StringT::npos);
    EXPECT_EQ(E.find_first_of(Y, StringT::npos),        StringT::npos);
    EXPECT_EQ(S.find_first_of(Y, StringT::npos),        StringT::npos);

    EXPECT_EQ(E.find_first_not_of(E),                   StringT::npos);
    EXPECT_EQ(S.find_first_not_of(E),                   0u);
    EXPECT_EQ(E.find_first_not_of(E, 2),                StringT::npos);
    EXPECT_EQ(S.find_first_not_of(E, 2),                2u);
    EXPECT_EQ(E.find_first_not_of(E, 8),                StringT::npos);
    EXPECT_EQ(S.find_first_not_of(E, 8),                StringT::npos);
    EXPECT_EQ(E.find_first_not_of(E, StringT::npos),    StringT::npos);
    EXPECT_EQ(S.find_first_not_of(E, StringT::npos),    StringT::npos);
    EXPECT_EQ(E.find_first_not_of(X),                   StringT::npos);
    EXPECT_EQ(S.find_first_not_of(X),                   StringT::npos);
    EXPECT_EQ(E.find_first_not_of(X, 2),                StringT::npos);
    EXPECT_EQ(S.find_first_not_of(X, 2),                StringT::npos);
    EXPECT_EQ(E.find_first_not_of(X, 8),                StringT::npos);
    EXPECT_EQ(S.find_first_not_of(X, 8),                StringT::npos);
    EXPECT_EQ(E.find_first_not_of(X, StringT::npos),    StringT::npos);
    EXPECT_EQ(S.find_first_not_of(X, StringT::npos),    StringT::npos);
    EXPECT_EQ(E.find_first_not_of(Y, 2),                StringT::npos);
    EXPECT_EQ(S.find_first_not_of(Y, 2),                2u);
    EXPECT_EQ(E.find_first_not_of(Y, 8),                StringT::npos);
    EXPECT_EQ(S.find_first_not_of(Y, 8),                StringT::npos);
    EXPECT_EQ(E.find_first_not_of(Y, StringT::npos),    StringT::npos);
    EXPECT_EQ(S.find_first_not_of(Y, StringT::npos),    StringT::npos);

    EXPECT_EQ(E.find_last_of(E),                        StringT::npos);
    EXPECT_EQ(S.find_last_of(E),                        StringT::npos);
    EXPECT_EQ(E.find_last_of(E, 2),                     StringT::npos);
    EXPECT_EQ(S.find_last_of(E, 2),                     StringT::npos);
    EXPECT_EQ(E.find_last_of(E, 8),                     StringT::npos);
    EXPECT_EQ(S.find_last_of(E, 8),                     StringT::npos);
    EXPECT_EQ(E.find_last_of(E, 0),                     StringT::npos);
    EXPECT_EQ(S.find_last_of(E, 0),                     StringT::npos);
    EXPECT_EQ(E.find_last_of(E),                        StringT::npos);
    EXPECT_EQ(S.find_last_of(E),                        StringT::npos);
    EXPECT_EQ(E.find_last_of(X, 2),                     StringT::npos);
    EXPECT_EQ(S.find_last_of(X, 2),                     2u);
    EXPECT_EQ(E.find_last_of(X, 8),                     StringT::npos);
    EXPECT_EQ(S.find_last_of(X, 8),                     2u);
    EXPECT_EQ(E.find_last_of(X, 0),                     StringT::npos);
    EXPECT_EQ(S.find_last_of(X, 0),                     0u);
    EXPECT_EQ(E.find_last_of(Y, 2),                     StringT::npos);
    EXPECT_EQ(S.find_last_of(Y, 2),                     StringT::npos);
    EXPECT_EQ(E.find_last_of(Y, 8),                     StringT::npos);
    EXPECT_EQ(S.find_last_of(Y, 8),                     StringT::npos);
    EXPECT_EQ(E.find_last_of(Y, 0),                     StringT::npos);
    EXPECT_EQ(S.find_last_of(Y, 0),                     StringT::npos);

    EXPECT_EQ(E.find_last_not_of(E),                    StringT::npos);
    EXPECT_EQ(S.find_last_not_of(E),                    2u);
    EXPECT_EQ(E.find_last_not_of(E, 2),                 StringT::npos);
    EXPECT_EQ(S.find_last_not_of(E, 2),                 2u);
    EXPECT_EQ(E.find_last_not_of(E, 8),                 StringT::npos);
    EXPECT_EQ(S.find_last_not_of(E, 8),                 2u);
    EXPECT_EQ(E.find_last_not_of(E, 0),                 StringT::npos);
    EXPECT_EQ(S.find_last_not_of(E, 0),                 0u);
    EXPECT_EQ(E.find_last_not_of(E),                    StringT::npos);
    EXPECT_EQ(S.find_last_not_of(E),                    2u);
    EXPECT_EQ(E.find_last_not_of(X, 2),                 StringT::npos);
    EXPECT_EQ(S.find_last_not_of(X, 2),                 StringT::npos);
    EXPECT_EQ(E.find_last_not_of(X, 8),                 StringT::npos);
    EXPECT_EQ(S.find_last_not_of(X, 8),                 StringT::npos);
    EXPECT_EQ(E.find_last_not_of(X, 0),                 StringT::npos);
    EXPECT_EQ(S.find_last_not_of(X, 0),                 StringT::npos);
    EXPECT_EQ(E.find_last_not_of(Y, 2),                 StringT::npos);
    EXPECT_EQ(S.find_last_not_of(Y, 2),                 2u);
    EXPECT_EQ(E.find_last_not_of(Y, 8),                 StringT::npos);
    EXPECT_EQ(S.find_last_not_of(Y, 8),                 2u);
    EXPECT_EQ(E.find_last_not_of(Y, 0),                 StringT::npos);
    EXPECT_EQ(S.find_last_not_of(Y, 0),                 0u);
}