Example #1
0
int main(int argc, char **argv) {
    GURL real1("file://localhost/e:/Alex/workspace/demonstrator/Genesis/build/bin/x64/DEBUG/L32f.png");
    std::cout << (real1.is_valid() ? "is valid" : "is invalid") << '\n';
    std::cout << (real1.IsStandard() ? "is standard" : "is not standard") << '\n';
    print_uri(real1);

    GURL url("http://*****:*****@wwww.furious-typing.com:1234/test/main.html?id=12356&mid=carlos#location");
    std::cout << (url.is_valid() ? "is valid" : "is invalid") << '\n';
    std::cout << (url.IsStandard() ? "is standard" : "is not standard") << '\n';
    print_uri(url);

    GURL invalid1("c:\\blubber");
    std::cout << (invalid1.is_valid() ? "is valid" : "is invalid") << '\n';
    std::cout << (invalid1.IsStandard() ? "is standard" : "is not standard") << '\n';
    print_uri(invalid1);

    GURL invalid2("file:/host/path");
    std::cout << (invalid2.is_valid() ? "is valid" : "is invalid") << '\n';
    std::cout << (invalid2.IsStandard() ? "is standard" : "is not standard") << '\n';
    print_uri(invalid2);

    GURL url1("http://*****:*****@wwww.furious-typing.com:1234/test/main file.html?id=12356&mid=carlos#location");
    std::cout << (url1.is_valid() ? "is valid" : "is invalid") << '\n';
    std::cout << (url1.IsStandard() ? "is standard" : "is not standard") << '\n';
    print_uri(url1);

    GURL real2("file://localhost///192.168.0.2/path/to/file.txt");
    std::cout << (real2.is_valid() ? "is valid" : "is invalid") << '\n';
    std::cout << (real2.IsStandard() ? "is standard" : "is not standard") << '\n';
    print_uri(real2);

    GURL real3("file://localhost/e%3A/Alex/workspace/demonstrator/Genesis/build/bin/x64/DEBUG/L%5B32%5Df.pfm");
    std::cout << (real3.is_valid() ? "is valid" : "is invalid") << '\n';
    std::cout << (real3.IsStandard() ? "is standard" : "is not standard") << '\n';
    print_uri(real3);

    GURL real4("file://localhost/e:/Alex/workspace/demonstrator/Genesis/build/bin/x64/DEBUG/L[32]f.pfm");
    std::cout << (real4.is_valid() ? "is valid" : "is invalid") << '\n';
    std::cout << (real4.IsStandard() ? "is standard" : "is not standard") << '\n';
    print_uri(real4);
    return 0;
}
void drive_CQLIdentifier(){
    CQLIdentifier _ID1("ID1");
    PEGASUS_TEST_ASSERT(_ID1.getName() == "ID1");

    CQLIdentifier _ID2("ID2");
    PEGASUS_TEST_ASSERT(_ID1 != _ID2);

    CQLIdentifier _ID3("*");
    PEGASUS_TEST_ASSERT(_ID3.isWildcard());

    CQLIdentifier scopedID("SCOPE::IDENTIFIER");
    PEGASUS_TEST_ASSERT(scopedID.isScoped());
    PEGASUS_TEST_ASSERT(scopedID.getScope() == "SCOPE");

    CQLIdentifier _ID4("A::Name");
    CQLIdentifier _ID4a("A::Name");
    PEGASUS_TEST_ASSERT(_ID4 == _ID4a);

    CQLIdentifier symbolicConstantID("Name#OK");
    PEGASUS_TEST_ASSERT(symbolicConstantID.getName() == "Name");
    PEGASUS_TEST_ASSERT(symbolicConstantID.isSymbolicConstant());
    PEGASUS_TEST_ASSERT(symbolicConstantID.getSymbolicConstantName() == "OK");

   try{
    CQLIdentifier rangeID("SCOPE::Name[5,6,7]");
    // Basic query check
    PEGASUS_TEST_ASSERT(false);
    PEGASUS_TEST_ASSERT(rangeID.getName() == "Name");
        PEGASUS_TEST_ASSERT(rangeID.isArray());
        Array<SubRange> subRanges = rangeID.getSubRanges();
    PEGASUS_TEST_ASSERT(subRanges[0] == String("5"));
    PEGASUS_TEST_ASSERT(subRanges[1] == String("6"));
    PEGASUS_TEST_ASSERT(subRanges[2] == String("7"));
        PEGASUS_TEST_ASSERT(rangeID.getScope() == "SCOPE");
   }catch(CQLIdentifierParseException&)
   {
   }

   try
   {
     CQLIdentifier rangeID("SCOPE::Name[5..,6..,..7,4-5,..]");
     PEGASUS_TEST_ASSERT(false);
   }
   catch (QueryParseException&)
   {
   }

   try
   {
     CQLIdentifier rangeID1("Name[*]");
     PEGASUS_TEST_ASSERT(false);
   }
   catch (QueryParseException&)
   {
   }

   try
   {
     CQLIdentifier invalid("Name#OK[4-5]");
     PEGASUS_TEST_ASSERT(false);
   }
   catch (CQLIdentifierParseException&)
   {
   }


   try
   {
     CQLIdentifier invalid1("Name[4-5]#OK");
     PEGASUS_TEST_ASSERT(false);
   }
   catch (CQLIdentifierParseException&)
   {
   }
}