示例#1
0
文件: urlTest.cpp 项目: kisli/vmime
	void testParse4() {

		// Test parameters
		vmime::utility::url u1("", "");

		VASSERT_EQ("1.1", true, parseHelper(u1, "proto://host/path?p1=v1&p2=v2"));
		VASSERT_EQ("1.2", "v1", u1.getParams()["p1"]);
		VASSERT_EQ("1.3", "v2", u1.getParams()["p2"]);
		VASSERT_EQ("1.4", "/path", u1.getPath());

		vmime::utility::url u2("", "");

		VASSERT_EQ("2.1", true, parseHelper(u2, "proto://host/path?p1=v1&p2"));
		VASSERT_EQ("2.2", "v1", u2.getParams()["p1"]);
		VASSERT_EQ("2.3", "p2", u2.getParams()["p2"]);
		VASSERT_EQ("2.4", "/path", u2.getPath());

		vmime::utility::url u3("", "");

		VASSERT_EQ("3.1", true, parseHelper(u3, "proto://host/?p1=v1&p2=v2"));
		VASSERT_EQ("3.2", "v1", u3.getParams()["p1"]);
		VASSERT_EQ("3.3", "v2", u3.getParams()["p2"]);
		VASSERT_EQ("3.4", "", u3.getPath());

		vmime::utility::url u4("", "");

		VASSERT_EQ("4.1", true, parseHelper(u4, "proto://host/path?p1=%3D&%3D=v2"));
		VASSERT_EQ("4.2", "=", u4.getParams()["p1"]);
		VASSERT_EQ("4.3", "v2", u4.getParams()["="]);
		VASSERT_EQ("4.4", "/path", u4.getPath());
	}
示例#2
0
static void parse(struct ParseData *d, kvec_uchar_t *commands, kvec_float_t *coords)
{
    for (;;)
    {
        wsp(d);

        if (*d->str == 0)
            break;

        switch (*d->str)
        {
        case 'M':
        case 'm':
            parseHelper(d, commands, coords, 2, 0);
            break;
        case 'L':
            parseHelper(d, commands, coords, 2, 1);
            break;
        case 'Q':
            parseHelper(d, commands, coords, 4, 1);
            break;
        case 'C':
            parseHelper(d, commands, coords, 6, 1);
            break;
        case 'Z':
        case 'z':
            d->str++;
            kv_push_back(*commands, 'Z');
            break;
        default:
            longjmp(d->buf, 1);
            break;
        }
    }
}
示例#3
0
文件: urlTest.cpp 项目: kisli/vmime
	// '@' symbol in the username part
	void testParse5() {

		vmime::utility::url u1("", "");

		VASSERT_EQ("1", true, parseHelper(u1, "imap://[email protected]:[email protected]"));
		VASSERT_EQ("2", "*****@*****.**", u1.getUsername());
		VASSERT_EQ("3", "password", u1.getPassword());
		VASSERT_EQ("4", "myserver.com", u1.getHost());
	}
示例#4
0
文件: urlTest.cpp 项目: kisli/vmime
	void testParse2() {

		// Now, test some ill-formed URLs

		// -- missing protocol
		vmime::utility::url u1("", "");
		VASSERT_EQ("1", false, parseHelper(u1, "://host"));

		// -- port can contain only digits
		vmime::utility::url u2("", "");
		VASSERT_EQ("2", false, parseHelper(u2, "proto://host:abc123"));

		// -- no host specified
		vmime::utility::url u3("", "");
		VASSERT_EQ("3", false, parseHelper(u3, "proto:///path"));

		// -- no protocol separator (://)
		vmime::utility::url u4("", "");
		VASSERT_EQ("4", false, parseHelper(u4, "protohost/path"));
	}
示例#5
0
文件: urlTest.cpp 项目: kisli/vmime
	void testParse3() {

		// Test decoding
		vmime::utility::url u1("", "");

		VASSERT_EQ("1.1", true, parseHelper(u1, "pro%12to://user%34:pass%56word@ho%78st:12345/pa%abth/"));
		VASSERT_EQ("1.2", "pro%12to", u1.getProtocol());  // protocol should not be decoded
		VASSERT_EQ("1.3", "user\x34", u1.getUsername());
		VASSERT_EQ("1.4", "pass\x56word", u1.getPassword());
		VASSERT_EQ("1.5", "ho\x78st", u1.getHost());
		VASSERT_EQ("1.6", 12345, u1.getPort());
		VASSERT_EQ("1.7", "/pa\xabth/", u1.getPath());
	}
示例#6
0
void WatchItem::parse(const GdbMi &data)
{
    iname = data["iname"].data();

    GdbMi wname = data["wname"];
    if (wname.isValid()) // Happens (only) for watched expressions.
        name = QString::fromUtf8(QByteArray::fromHex(wname.data()));
    else
        name = QString::fromLatin1(data["name"].data());

    parseHelper(data);

    if (wname.isValid())
        exp = name.toUtf8();
}
示例#7
0
文件: urlTest.cpp 项目: kisli/vmime
	void testParse1() {

		// Test some valid constructions
		vmime::utility::url u1("", "");

		VASSERT_EQ("1.1", true, parseHelper(u1, "protocol://*****:*****@host:12345/path/"));
		VASSERT_EQ("1.2", "protocol", u1.getProtocol());
		VASSERT_EQ("1.3", "user", u1.getUsername());
		VASSERT_EQ("1.4", "password", u1.getPassword());
		VASSERT_EQ("1.5", "host", u1.getHost());
		VASSERT_EQ("1.6", 12345, u1.getPort());
		VASSERT_EQ("1.7", "/path/", u1.getPath());

		vmime::utility::url u2("", "");

		VASSERT_EQ("2.1", true, parseHelper(u2, "protocol://user@host:12345/path/"));
		VASSERT_EQ("2.2", "protocol", u2.getProtocol());
		VASSERT_EQ("2.3", "user", u2.getUsername());
		VASSERT_EQ("2.4", "", u2.getPassword());
		VASSERT_EQ("2.5", "host", u2.getHost());
		VASSERT_EQ("2.6", 12345, u2.getPort());
		VASSERT_EQ("2.7", "/path/", u2.getPath());

		vmime::utility::url u3("", "");

		VASSERT_EQ("3.1", true, parseHelper(u3, "protocol://host:12345/path/"));
		VASSERT_EQ("3.2", "protocol", u3.getProtocol());
		VASSERT_EQ("3.3", "", u3.getUsername());
		VASSERT_EQ("3.4", "", u3.getPassword());
		VASSERT_EQ("3.5", "host", u3.getHost());
		VASSERT_EQ("3.6", 12345, u3.getPort());
		VASSERT_EQ("3.7", "/path/", u3.getPath());

		vmime::utility::url u4("", "");

		VASSERT_EQ("4.1", true, parseHelper(u4, "protocol://host/path/"));
		VASSERT_EQ("4.2", "protocol", u4.getProtocol());
		VASSERT_EQ("4.3", "", u4.getUsername());
		VASSERT_EQ("4.4", "", u4.getPassword());
		VASSERT_EQ("4.5", "host", u4.getHost());
		VASSERT_EQ("4.6", vmime::utility::url::UNSPECIFIED_PORT, u4.getPort());
		VASSERT_EQ("4.7", "/path/", u4.getPath());

		vmime::utility::url u5("", "");

		VASSERT_EQ("5.1", true, parseHelper(u5, "protocol://host/"));
		VASSERT_EQ("5.2", "protocol", u5.getProtocol());
		VASSERT_EQ("5.3", "", u5.getUsername());
		VASSERT_EQ("5.4", "", u5.getPassword());
		VASSERT_EQ("5.5", "host", u5.getHost());
		VASSERT_EQ("5.6", vmime::utility::url::UNSPECIFIED_PORT, u4.getPort());
		VASSERT_EQ("5.7", "", u5.getPath());

		vmime::utility::url u6("", "");

		VASSERT_EQ("6.1", true, parseHelper(u4, "protocol://host/path/file"));
		VASSERT_EQ("6.2", "protocol", u4.getProtocol());
		VASSERT_EQ("6.3", "", u4.getUsername());
		VASSERT_EQ("6.4", "", u4.getPassword());
		VASSERT_EQ("6.5", "host", u4.getHost());
		VASSERT_EQ("6.6", vmime::utility::url::UNSPECIFIED_PORT, u4.getPort());
		VASSERT_EQ("6.7", "/path/file", u4.getPath());
	}