Exemplo n.º 1
0
TEST_F(DatabaseSuite, dump_and_load)
{

    // load
    MojAssertNoErr( MojFileFromString(MojLoadTestFileName, MojTestStr) );

    MojUInt32 count = 0;
    MojAssertNoErr( db.load(MojLoadTestFileName, count) );
    EXPECT_EQ( 11LL, count );

    checkCount();

    // dump
    count = 0;
    MojAssertNoErr( db.dump(MojDumpTestFileName, count) );
    EXPECT_EQ( 11LL, count );

    EXPECT_TRUE( db.kindEngine() );

    // verify that we can get this kind
    MojDbKind *pk = 0;
    MojExpectNoErr( db.kindEngine()->getKind(kindId.data(), pk) );
    EXPECT_TRUE( pk );

    // del
    bool found = false;
    MojAssertNoErr( db.delKind(kindId, found) );
    EXPECT_TRUE( found );

    // verify that we can NOT get this kind
    pk = 0;
    EXPECT_EQ( MojErrDbKindNotRegistered, db.kindEngine()->getKind(kindId.data(), pk) );
    EXPECT_FALSE( pk );

    // purge deleted kinds
    MojAssertNoErr( db.purge(count, 0) );
    EXPECT_EQ( 1LL, count ) << "Purged kinds marked for delete";

    // load again. why 12?
    MojAssertNoErr( db.load(MojDumpTestFileName, count) );
    EXPECT_EQ( 12LL, count );

    checkCount();

    // analyze
    MojObject analysis;
    MojAssertNoErr( db.stats(analysis) );
}
Exemplo n.º 2
0
        /**
         * A template used by many tests below.
         * Fill out numObj objects, sort them in the order provided by 'direction'.
         * If extAllowed is true, sorting will use use external sorting if available.
         * If limit is not zero, we limit the output of the sort stage to 'limit' results.
         */
        void sortAndCheck(int direction, Collection* coll) {
            WorkingSet* ws = new WorkingSet();
            MockStage* ms = new MockStage(ws);

            // Insert a mix of the various types of data.
            insertVarietyOfObjects(ms, coll);

            SortStageParams params;
            params.pattern = BSON("foo" << direction);
            params.limit = limit();

            // Must fetch so we can look at the doc as a BSONObj.
            PlanExecutor runner(ws, new FetchStage(ws, new SortStage(params, ws, ms), NULL));

            // Look at pairs of objects to make sure that the sort order is pairwise (and therefore
            // totally) correct.
            BSONObj last;
            ASSERT_EQUALS(Runner::RUNNER_ADVANCED, runner.getNext(&last, NULL));

            // Count 'last'.
            int count = 1;

            BSONObj current;
            while (Runner::RUNNER_ADVANCED == runner.getNext(&current, NULL)) {
                int cmp = sgn(current.woSortOrder(last, params.pattern));
                // The next object should be equal to the previous or oriented according to the sort
                // pattern.
                ASSERT(cmp == 0 || cmp == 1);
                ++count;
                last = current;
            }

            checkCount(count);
        }
Exemplo n.º 3
0
 void mergeSort(vector<int>& nums, int start, int end){
     if(start == end) return;
     
     int mid = (start + end)/2;
     mergeSort(nums,start, mid);
     mergeSort(nums,mid+1,end);
     
     checkCount(nums,start,mid,end);
     return;
     
 }
Exemplo n.º 4
0
TrayItemManager::TrayItemManager() {
    m_scanner = new Scanner(this);
    connect(m_scanner, SIGNAL(windowFound(Window, TrayItemArgs)), this, SLOT(dockWindow(Window, TrayItemArgs)));
    connect(m_scanner, SIGNAL(stopping()), this, SLOT(checkCount()));
    // 'const' TrayItemArgs initializer
    m_initArgs.iBalloonTimeout = -1;
    for (int opt=0; opt < Option_MAX; opt++) {
        m_initArgs.opt[opt] = NOARG;  // unset all
    }
    m_grabInfo.qtimer = new QTimer;
    m_grabInfo.qloop  = new QEventLoop;
    m_grabInfo.isGrabbing = false;
    connect(m_grabInfo.qtimer, SIGNAL(timeout()), m_grabInfo.qloop, SLOT(quit()));
    connect(this, SIGNAL(quitMouseGrab()),        m_grabInfo.qloop, SLOT(quit()));

    // This will prevent x errors from being written to the console.
    // The isValidWindowId function in util.cpp will generate errors if the
    // window is not valid while it is checking.
    XSetErrorHandler(ignoreXErrors);
    qApp-> installNativeEventFilter(this);
}