示例#1
0
//--------------------------------------------------------------
void testApp::setup(){
    
    // Support r-restart:
    cleanup();
    lastTime = ofGetElapsedTimef();
    
    frameRate = 60;
    objectLife = 7 * frameRate;
    
    // Maintenance
    ofSetVerticalSync( true );
    ofEnableAlphaBlending();
    ofSetFrameRate( frameRate );
    ofSetCircleResolution( 100 );
    
    helvetica.loadFont( "fonts/helvetica.otf", 24 );
    
    // Background
    ofBackground( 255 );
    
    // Make the vector of y-pos.
    staffPosSet();
    
    // Run a test pattern and highlight the first element.
    testPattern();
    getThisOne = 0;
    
    bIsLefty = bIsRecording = false;
    
    myPlayer.setup();
    
    // 0 is title screen, 1 is game screen.
    gameState = 0;
}
示例#2
0
//--------------------------------------------------------------
void testApp::setup(){
    
    // Support r-restart:
    cleanup();
    lastTime = ofGetElapsedTimef();
    
    // Maintenance
    ofSetVerticalSync( true );
    ofSetFrameRate( 60 );
    ofSetCircleResolution( 100 );
    
    // Background
    ofBackground( 255 );
    
    // Make the vector of y-pos.
    staffPosSet();
    
    // Run a test pattern and highlight the first element.
    testPattern();
    getThisOne = 0;
    
    replay = false;
    
    myPlayer.setup();
}
示例#3
0
bool
RFindInReadable_Impl( const StringT& aPattern, IteratorT& aSearchStart, IteratorT& aSearchEnd, const Comparator& compare )
  {
    IteratorT patternStart, patternEnd, searchEnd = aSearchEnd;
    aPattern.BeginReading(patternStart);
    aPattern.EndReading(patternEnd);

      // Point to the last character in the pattern
    --patternEnd;
      // outer loop keeps searching till we run out of string to search
    while ( aSearchStart != searchEnd )
      {
          // Point to the end position of the next possible match
        --searchEnd;
    
          // Check last character, if a match, explore further from here
        if ( compare(patternEnd.get(), searchEnd.get(), 1, 1) == 0 )
          {  
              // We're at a potential match, let's see if we really hit one
            IteratorT testPattern(patternEnd);
            IteratorT testSearch(searchEnd);

              // inner loop verifies the potential match at the current position
            do
              {
                  // if we verified all the way to the end of the pattern, then we found it!
                if ( testPattern == patternStart )
                  {
                    aSearchStart = testSearch;  // point to start of match
                    aSearchEnd = ++searchEnd;   // point to end of match
                    return true;
                  }
    
                  // if we got to end of the string we're searching before we hit the end of the
                  //  pattern, we'll never find what we're looking for
                if ( testSearch == aSearchStart )
                  {
                    aSearchStart = aSearchEnd;
                    return false;
                  }
    
                  // test previous character for a match
                --testPattern;
                --testSearch;
              }
            while ( compare(testPattern.get(), testSearch.get(), 1, 1) == 0 );
          }
      }

    aSearchStart = aSearchEnd;
    return false;
  }
示例#4
0
int main(int argc, const char **argv) {
    printf("Running all tests...\n\n");

    //**** core tests
    testTree();
    testParse();
    testDef();
    testWord();
    testFlow();
    testVM();


    testStack();
    testInit();
    testCommand();
    testConversation();
    testScape();


//    testThreads();

    //**** builtins tests
    testNoun();
    testPattern();
    //testArray();
    //    testStream();
    testInt();
    testStr255();
    testCfunc();
    testReceptorUtil();
    //    testReceptor();
    //testVmHost();

    //**** examples test
    testPoint();
    //    testLine();


    report_tests();
    return 0;
}
示例#5
0
int main()
{
    verbose = (getenv ("PEGASUS_TEST_VERBOSE")) ? true : false;
    // Test one pattern vs string per call
    //  (test #, pattern, stringToBeTested, expected result)
    testPattern(1,__LINE__,"", "", false);
    testPattern(2,__LINE__,"abc", "", false);
    testPattern(3,__LINE__,"", "abc", false);

    testPattern(4,__LINE__,"abc", "abc", true);
    testPattern(5,__LINE__,"abcd", "abc", false);

    testPattern(6,__LINE__,"abc", "abcd", false);

    testPattern(7,__LINE__,"ab.", "ab?", true);
    testPattern(8,__LINE__,".a.b", "aa!b", true);
    testPattern(9,__LINE__,"\\.ab", ".ab", true);
    testPattern(10,__LINE__,"\\.ab", "\\.ab", false);

    testPattern(11,__LINE__,".*", "abcd", true);

    testPattern(12,__LINE__,"\\.*", "......", true);
    testPattern(13,__LINE__,"abcd*", "abcddddd", true);

    testPattern(14,__LINE__,"abcd*", "abcd", false);

    testPattern(15,__LINE__,"ab*cd", "abbbbcd", true);
    testPattern(16,__LINE__,"\\*ab", "*ab", true);
    testPattern(17,__LINE__,".\\*", "****", false);
    testPattern(18,__LINE__,".est", "Test", true);
//// KS_TODO this pattern fails so we are exluding it until we understand
//// the issue
////  testPattern(19,__LINE__,".*est", "Test", true);
    //// KS_TODO not sure what this one should do.
////  testPattern(19,__LINE__,"*est", "Test", true);
    // The following tests use utf16 chars
    {
        Char16 utf16Chars[] = {0xD800,0x78BC, 0xDC01, 0x45A3, 0x00};

        const String utf(utf16Chars);
        testPattern(30,__LINE__,utf, utf, true);
    }

    {
        Char16 utf16CharsP[] = { 0xD800,0x78BC, 0x00};

        String utfPattern(utf16CharsP);
        utfPattern.append("*");
        Char16 utf16[] = {0xD800,0x78BC, 0xD800,0x78BC, 0xD800,0x78BC, 0x00};

        const String utfString(utf16);
        testPattern(31,__LINE__,utfPattern, utfString, true);
    }
    {
        Char16 utf16CharsS[] = {0xD800,0x78BC, 0x00};

        String utfString(utf16CharsS);
        utfString.append("*");
        testPattern(32,__LINE__,".*", utfString, true);
    }

    {
        Char16 utf16CharsP[] = {0xD800,0x78BC, 0x00};

        String utfPattern(utf16CharsP);
        utfPattern.append(".*");

        Char16 utf16CharsS[] = {0xD800,0x78BC, 0x00};

        String utfString(utf16CharsS);
        utfString.append("an3s");
        testPattern(33,__LINE__,utfPattern, utfString, true);
    }
    cout << "+++++ passed all tests" << endl;
    return 0;
}
示例#6
0
bool
FindInReadable_Impl( const StringT& aPattern, IteratorT& aSearchStart, IteratorT& aSearchEnd, const Comparator& compare )
  {
    bool found_it = false;

      // only bother searching at all if we're given a non-empty range to search
    if ( aSearchStart != aSearchEnd )
      {
        IteratorT aPatternStart, aPatternEnd;
        aPattern.BeginReading(aPatternStart);
        aPattern.EndReading(aPatternEnd);

          // outer loop keeps searching till we find it or run out of string to search
        while ( !found_it )
          {
              // fast inner loop (that's what it's called, not what it is) looks for a potential match
            while ( aSearchStart != aSearchEnd &&
                    compare(aPatternStart.get(), aSearchStart.get(), 1, 1) )
              ++aSearchStart;

              // if we broke out of the `fast' loop because we're out of string ... we're done: no match
            if ( aSearchStart == aSearchEnd )
              break;

              // otherwise, we're at a potential match, let's see if we really hit one
            IteratorT testPattern(aPatternStart);
            IteratorT testSearch(aSearchStart);

              // slow inner loop verifies the potential match (found by the `fast' loop) at the current position
            for(;;)
              {
                  // we already compared the first character in the outer loop,
                  //  so we'll advance before the next comparison
                ++testPattern;
                ++testSearch;

                  // if we verified all the way to the end of the pattern, then we found it!
                if ( testPattern == aPatternEnd )
                  {
                    found_it = true;
                    aSearchEnd = testSearch; // return the exact found range through the parameters
                    break;
                  }

                  // if we got to end of the string we're searching before we hit the end of the
                  //  pattern, we'll never find what we're looking for
                if ( testSearch == aSearchEnd )
                  {
                    aSearchStart = aSearchEnd;
                    break;
                  }

                  // else if we mismatched ... it's time to advance to the next search position
                  //  and get back into the `fast' loop
                if ( compare(testPattern.get(), testSearch.get(), 1, 1) )
                  {
                    ++aSearchStart;
                    break;
                  }
              }
          }
      }

    return found_it;
  }
示例#7
0
int main(int argc, char * argv [])
{
  ulxr::intializeLog4J(argv[0]);

  int success = 0;

#ifdef STRESS_IT
  for (int i= 0; i < 1000; ++i)
  {
#endif
    try
    {
      ULXR_COUT << ULXR_PCHAR("Testing patterns\n");

      ULXR_COUT << ULXR_PCHAR("boolPattern\n") << std::flush;
      testPattern(boolPattern, sizeof(boolPattern));

      ULXR_COUT << ULXR_PCHAR("int1Pattern\n");
      testPattern(int1Pattern, sizeof(int1Pattern));

      ULXR_COUT << ULXR_PCHAR("int2Pattern\n");
      testPattern(int2Pattern, sizeof(int2Pattern));

      ULXR_COUT << ULXR_PCHAR("doublePattern\n");
      testPattern(doublePattern, sizeof(doublePattern));

      ULXR_COUT << ULXR_PCHAR("stringPattern\n");
      testPattern(stringPattern, sizeof(stringPattern));

      ULXR_COUT << ULXR_PCHAR("base64Pattern\n");
      testPattern(base64Pattern, sizeof(base64Pattern));

      ULXR_COUT << ULXR_PCHAR("datePattern\n");
      testPattern(datePattern, sizeof(datePattern));

      ULXR_COUT << ULXR_PCHAR("struct1Pattern\n");
      testPattern(struct1Pattern, sizeof(struct1Pattern));

      ULXR_COUT << ULXR_PCHAR("struct2Pattern\n");
      testPattern(struct2Pattern, sizeof(struct2Pattern));

      ULXR_COUT << ULXR_PCHAR("arrayPattern\n");
      testPattern(arrayPattern, sizeof(arrayPattern));

      ULXR_COUT << ULXR_PCHAR("callPattern\n");
      testCallPattern(callPattern, sizeof(callPattern));

      ULXR_COUT << ULXR_PCHAR("emptyCallPattern\n");
      testCallPattern(emptyCallPattern, sizeof(emptyCallPattern));

      ULXR_COUT << ULXR_PCHAR("respPattern\n");
      testRespPattern(respPattern, sizeof(respPattern));

      ULXR_COUT << ULXR_PCHAR("implPattern\n");
      testPattern(implPattern, sizeof(implPattern));

      ULXR_COUT << ULXR_PCHAR("emptyArrayPattern\n");
      testRespPattern(emptyArrayPattern, sizeof(emptyArrayPattern));

      ULXR_COUT << ULXR_PCHAR("emptyRespPattern\n");
      testRespPattern(emptyRespPattern, sizeof(emptyRespPattern));

      ULXR_COUT << ULXR_PCHAR("emptyStructPattern\n");
      testRespPattern(emptyStructPattern, sizeof(emptyStructPattern));

      ULXR_COUT << ULXR_PCHAR("----------------------------------------------------\n");

      ULXR_COUT << ULXR_PCHAR("MethodResponse abc\n");

      ulxr::MethodResponse mr1(123, ULXR_PCHAR("faultstr_m"));
      ULXR_COUT << ulxr::binaryDebugOutput(mr1.getWbXml());
      ULXR_COUT << std::endl << mr1.getXml(0) << std::endl;

      ulxr::MethodResponse mr2(ulxr::Integer(1));
      ULXR_COUT << ulxr::binaryDebugOutput(mr2.getWbXml());
      ULXR_COUT << std::endl << mr2.getXml(0) << std::endl;

      ulxr::MethodResponse mr3;
      ULXR_COUT << ulxr::binaryDebugOutput(mr3.getWbXml());
      ULXR_COUT << std::endl << mr3.getXml(0) << std::endl;

      ULXR_COUT << ULXR_PCHAR("----------------------------------------------------\n");

      ulxr::MethodCall mc (ULXR_PCHAR("test.call"));
      ULXR_COUT << ulxr::binaryDebugOutput(mc.getWbXml());

      ULXR_COUT << std::endl << mc.getXml(0) << std::endl;

      ULXR_COUT << ULXR_PCHAR("====================================================\n");

      ulxr::Boolean b(true);
      ulxr::Integer i(123);
      ulxr::Double d(123.456);
      ulxr::RpcString s("<>&\"\'string<>&\"\'");
      ulxr::DateTime dt(ULXR_PCHAR("20020310T10:23:45"));
      ulxr::Base64 b64(ULXR_PCHAR("ABASrt466a90"));
      ulxr::Struct st;
      ulxr::Array ar;

      ULXR_COUT << ulxr::binaryDebugOutput(b.getWbXml()) << std::endl;
      ULXR_COUT << b.getXml(0) << std::endl;

      ULXR_COUT << ULXR_PCHAR("----------------------------------------------------\n");
      ULXR_COUT << ulxr::binaryDebugOutput(i.getWbXml()) << std::endl;
      ULXR_COUT << i.getXml(0) << std::endl;

      ULXR_COUT << ULXR_PCHAR("----------------------------------------------------\n");
      ULXR_COUT << ulxr::binaryDebugOutput(d.getWbXml()) << std::endl;
      ULXR_COUT << d.getXml(0) << std::endl;

      ULXR_COUT << ULXR_PCHAR("----------------------------------------------------\n");
      ULXR_COUT << ulxr::binaryDebugOutput(s.getWbXml()) << std::endl;
      ULXR_COUT << s.getXml(0) << std::endl;

      ULXR_COUT << ULXR_PCHAR("----------------------------------------------------\n");
      ULXR_COUT << ulxr::binaryDebugOutput(dt.getWbXml()) << std::endl;
      ULXR_COUT << dt.getXml(0) << std::endl;

      ULXR_COUT << ULXR_PCHAR("----------------------------------------------------\n");
      ULXR_COUT << ulxr::binaryDebugOutput(b64.getWbXml()) << std::endl;
      ULXR_COUT << b64.getXml(0) << std::endl;

      ULXR_COUT << ULXR_PCHAR("----------------------------------------------------\n");
      ULXR_COUT << ulxr::binaryDebugOutput(st.getWbXml()) << std::endl;
      ULXR_COUT << st.getXml(0) << std::endl;

      ULXR_COUT << ULXR_PCHAR("----------------------------------------------------\n");
      ULXR_COUT << ulxr::binaryDebugOutput(ar.getWbXml()) << std::endl;
      ULXR_COUT << ar.getXml(0) << std::endl;

      ULXR_COUT << ULXR_PCHAR("====================================================\n");

      ULXR_COUT << "wbToken_Value   " << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::ValueParserWb::wbToken_Value) << std::endl;
      ULXR_COUT << "wbToken_Array   " << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::ValueParserWb::wbToken_Array) << std::endl;
      ULXR_COUT << "wbToken_Data    " << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::ValueParserWb::wbToken_Data) << std::endl;
      ULXR_COUT << "wbToken_Struct  " << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::ValueParserWb::wbToken_Struct) << std::endl;
      ULXR_COUT << "wbToken_Member  " << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::ValueParserWb::wbToken_Member) << std::endl;
      ULXR_COUT << "wbToken_Name    " << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::ValueParserWb::wbToken_Name) << std::endl;
      ULXR_COUT << "wbToken_Boolean " << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::ValueParserWb::wbToken_Boolean) << std::endl;
      ULXR_COUT << "wbToken_Int     " << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::ValueParserWb::wbToken_Int) << std::endl;
      ULXR_COUT << "wbToken_I4      " << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::ValueParserWb::wbToken_I4) << std::endl;
      ULXR_COUT << "wbToken_Double  " << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::ValueParserWb::wbToken_Double) << std::endl;
      ULXR_COUT << "wbToken_String  " << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::ValueParserWb::wbToken_String) << std::endl;
      ULXR_COUT << "wbToken_Base64  " << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::ValueParserWb::wbToken_Base64) << std::endl;
      ULXR_COUT << "wbToken_Date    " << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::ValueParserWb::wbToken_Date) << std::endl;
      ULXR_COUT << std::endl;

      ULXR_COUT << "wbToken_MethodCall " << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::MethodCallParserWb::wbToken_MethodCall) << std::endl;
      ULXR_COUT << "wbToken_MethodName " << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::MethodCallParserWb::wbToken_MethodName) << std::endl;
      ULXR_COUT << "wbToken_Params     " << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::MethodCallParserWb::wbToken_Params) << std::endl;
      ULXR_COUT << "wbToken_Param      " << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::MethodCallParserWb::wbToken_Param) << std::endl;
      ULXR_COUT << std::endl;

      ULXR_COUT << "wbToken_MethodResponse " << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::MethodResponseParserWb::wbToken_MethodResponse) << std::endl;
      ULXR_COUT << "wbToken_Fault          " << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::MethodResponseParserWb::wbToken_Fault) << std::endl;
      ULXR_COUT << "wbToken_Params         " << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::MethodResponseParserWb::wbToken_Params) << std::endl;
      ULXR_COUT << "wbToken_Param          " << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::MethodResponseParserWb::wbToken_Param) << std::endl;
      ULXR_COUT << std::endl;

      ULXR_COUT << "wbToken_ValueParserLast "
                << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::ValueParserWb::wbToken_ValueParserLast) << std::endl;

      ULXR_COUT << "wbToken_CallParserLast "
                << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::MethodCallParserWb::wbToken_CallParserLast) << std::endl;

      ULXR_COUT << "wbToken_ResponseParserLast "
                << ulxr::HtmlFormHandler::makeHexNumber((unsigned char)ulxr::MethodResponseParserWb::wbToken_ResponseParserLast) << std::endl;


    }

    catch(ulxr::Exception &ex)
    {
       ULXR_COUT << ULXR_PCHAR("Error occured: ")
                 << ULXR_GET_STRING(ex.why()) << std::endl;
       success= 1;
    }
#ifdef STRESS_IT
  }
#endif

  return success;
}