}
const CharacterSet
-CharacterSet::ALPHA("ALPHA", {{ 'a', 'z' }, { 'A', 'Z'} }),
+CharacterSet::ALPHA("ALPHA", {{ 'a', 'z' }, { 'A', 'Z'}}),
CharacterSet::BIT("BIT","01"),
CharacterSet::CHAR("CHAR",{{ 1, 127}}),
+CharacterSet::CR("CR","\r"),
CharacterSet::CRLF("CRLF","\r\n"),
CharacterSet::DIGIT("DIGIT","0123456789"),
+CharacterSet::DQUOTE("DQUOTE","\""),
+CharacterSet::HTAB("HTAB","\t"),
CharacterSet::HEXDIG("HEXDIG","0123456789aAbBcCdDeEfF"),
-CharacterSet::WSP("WSP"," \t")
+CharacterSet::SP("SP"," "),
+CharacterSet::VCHAR("VCHAR",{{ 0x21, 0x7e }} ),
+CharacterSet::WSP("WSP"," \t"),
+CharacterSet::TCHAR("TCHAR","!#$%&'*+-.^_`|~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
+CharacterSet::SPECIAL("SPECIAL","()<>@,;:\\\"/[]?={}")
+//,CharacterSet::QDTEXT("QDTEXT",{{9,9},{0x20,0x21},{0x23,0x5b},{0x5d,0x7e},{0x80,0xff}})
+//,CharacterSet::OBSTEXT("OBSTEXT",{{0x80,0xff}})
;
/// optional set label for debugging (default: "anonymous")
const char * name;
+ // common character sets, insipired to RFC5234
// A-Za-z
static const CharacterSet ALPHA;
// 0-1
static const CharacterSet BIT;
// any 7-bit US-ASCII character, except for NUL
static const CharacterSet CHAR;
+ // carriage return
+ static const CharacterSet CR;
// CRLF
static const CharacterSet CRLF;
+ // double quote
+ static const CharacterSet DQUOTE;
// 0-9
static const CharacterSet DIGIT;
// 0-9aAbBcCdDeEfF
static const CharacterSet HEXDIG;
+ // horizontal tab
+ static const CharacterSet HTAB;
+ // white space
+ static const CharacterSet SP;
+ // visible (printable) characters
+ static const CharacterSet VCHAR;
// <space><tab>
static const CharacterSet WSP;
+ // character sets from draft httpbis
+ // any VCHAR except for SPECIAL
+ static const CharacterSet TCHAR;
+ // special VCHARs
+ static const CharacterSet SPECIAL;
+ // qdtext (ready but not enabled for now)
+ //static const CharacterSet QDTEXT;
+ // obs-text
+ //static const CharacterSet OBSTEXT;
private:
/** index of characters in this set
CPPUNIT_ASSERT_EQUAL(true,CharacterSet::ALPHA['Z']);
CPPUNIT_ASSERT_EQUAL(false,CharacterSet::ALPHA['5']);
}
+
+void
+testCharacterSet::CharacterSetUnion()
+{
+ {
+ CharacterSet hex("hex","");
+ hex += CharacterSet::DIGIT;
+ hex += CharacterSet(NULL,"aAbBcCdDeEfF");
+ for (int j = 0; j < 255; ++j)
+ CPPUNIT_ASSERT_EQUAL(CharacterSet::HEXDIG[j],hex[j]);
+ }
+ {
+ CharacterSet hex(NULL,"");
+ hex = CharacterSet::DIGIT + CharacterSet(NULL,"aAbBcCdDeEfF");
+ for (int j = 0; j < 255; ++j)
+ CPPUNIT_ASSERT_EQUAL(CharacterSet::HEXDIG[j],hex[j]);
+ }
+}
CPPUNIT_TEST( CharacterSetAdd );
CPPUNIT_TEST( CharacterSetAddRange );
CPPUNIT_TEST( CharacterSetConstants );
+ CPPUNIT_TEST( CharacterSetUnion );
CPPUNIT_TEST_SUITE_END();
protected:
void CharacterSetAdd();
void CharacterSetAddRange();
void CharacterSetConstants();
+ void CharacterSetUnion();
};
#endif /* SQUID_BASE_TESTCHARACTERSET_H */