Esempio n. 1
0
bool
test_all_sstring_functions(void)
{
	bool allocation_success = test_helper(test_sstring_allocation, "allocation");
	bool to_lower_success   = test_helper(test_to_lower_sstring, "to lower");
	bool to_upper_success   = test_helper(test_to_upper_sstring, "to upper");
	bool copy_success       = test_helper(test_copy_sstring, "copy");

	return allocation_success && to_lower_success && to_upper_success && copy_success;
}
Esempio n. 2
0
void tst_FileSearch::caseInSensitive()
{
    Utils::FileSearchResultList expectedResults;
    expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 3, QLatin1String("search CaseSensitively for casesensitive"), 7, 13, QStringList());
    expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 3, QLatin1String("search CaseSensitively for casesensitive"), 27, 13, QStringList());
    test_helper(expectedResults, QLatin1String("CaseSensitive"), QTextDocument::FindFlags(0));
}
Esempio n. 3
0
void tst_FileSearch::multipleResults()
{
    Utils::FileSearchResultList expectedResults;
    expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 2, QLatin1String("search to find multiple find results"), 10, 4, QStringList());
    expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 2, QLatin1String("search to find multiple find results"), 24, 4, QStringList());
    expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 4, QLatin1String("here you find another result"), 9, 4, QStringList());
    test_helper(expectedResults, QLatin1String("find"), QTextDocument::FindFlags(0));
}
Esempio n. 4
0
void tst_FileSearch::multipleResults()
{
    Utils::FileSearchResultList expectedResults;
    expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 2, QLatin1String("search to find multiple find results"), 10, 4, QStringList());
    expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 2, QLatin1String("search to find multiple find results"), 24, 4, QStringList());
    expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 4, QLatin1String("here you find another result"), 9, 4, QStringList());
    test_helper(expectedResults, QLatin1String("find"), QTextDocument::FindFlags(0));

    expectedResults.clear();
    expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 5, QLatin1String("aaaaaaaa this line has 2 results for four a in a row"), 0, 4, QStringList());
    expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 5, QLatin1String("aaaaaaaa this line has 2 results for four a in a row"), 4, 4, QStringList());
    test_helper(expectedResults, QLatin1String("aaaa"), QTextDocument::FindFlags(0));

    expectedResults.clear();
    expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 5, QLatin1String("aaaaaaaa this line has 2 results for four a in a row"), 0, 4, QStringList() << QLatin1String("aaaa"));
    expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 5, QLatin1String("aaaaaaaa this line has 2 results for four a in a row"), 4, 4, QStringList() << QLatin1String("aaaa"));
    test_helper(expectedResults, QLatin1String("aaaa"), QTextDocument::FindFlags(0), RegExp);
}
Esempio n. 5
0
static int childprocess_unittest(void)
{
   resourceusage_t usage = resourceusage_FREE;
   directory_t* dir = 0;
   uint8_t      dirpath[256];

   if (test_initfree())    goto ONERR;

   TEST(0 == init_resourceusage(&usage));

   // prepare
   TEST(0 == newtemp_directory(&dir, "iothread", &(wbuffer_t) wbuffer_INIT_STATIC(sizeof(dirpath), dirpath)));

   if (test_helper())      goto ONERR;
   if (test_initfree())    goto ONERR;
   if (test_noop())        goto ONERR;
   if (test_read(dir))     goto ONERR;
   if (test_write(dir))    goto ONERR;
   if (test_rwerror())     goto ONERR;
   if (test_rwpartial(dir)) goto ONERR;

   // reset
   TEST(0 == delete_directory(&dir));
   TEST(0 == removedirectory_directory(0, (const char*)dirpath));

   TEST(0 == same_resourceusage(&usage));
   TEST(0 == free_resourceusage(&usage));

   return 0;
ONERR:
   if (dir) {
      delete_directory(&dir);
      removedirectory_directory(0, (const char*)dirpath);
   }
   free_resourceusage(&usage);
   return EINVAL;
}
Esempio n. 6
0
TEST_F(TestGet, test_get_one_row)
{
    int err = 0;
    CommonSchemaManagerWrapper schema_mgr;
    tbsys::CConfig config;
    bool ret_val = schema_mgr.parse_from_file("scan_schema.ini", config);
    ASSERT_TRUE(ret_val);
    ObUpsTableMgr& mgr = ObUpdateServerMain::get_instance()->get_update_server().get_table_mgr();
    err = mgr.init();
    ASSERT_EQ(0, err);
    err = mgr.set_schemas(schema_mgr);
    ASSERT_EQ(0, err);

    TestUpsTableMgrHelper test_helper(mgr);

    TableMgr& table_mgr = test_helper.get_table_mgr();
    table_mgr.sstable_scan_finished(10);

    TableItem* active_memtable_item = table_mgr.get_active_memtable();
    MemTable& active_memtable = active_memtable_item->get_memtable();

    // construct multi-row mutator
    static const int64_t ROW_NUM = 1;
    static const int64_t COL_NUM = 10;

    ObCellInfo cell_infos[ROW_NUM][COL_NUM];
    char row_key_strs[ROW_NUM][50];
    uint64_t table_id = 10;
    // init cell infos
    for (int64_t i = 0; i < ROW_NUM; ++i)
    {
        sprintf(row_key_strs[i], "row_key_%08ld", i);
        for (int64_t j = 0; j < COL_NUM; ++j)
        {
            cell_infos[i][j].table_id_ = table_id;
            cell_infos[i][j].row_key_.assign(row_key_strs[i], strlen(row_key_strs[i]));

            cell_infos[i][j].column_id_ = j + 1;

            cell_infos[i][j].value_.set_int(1000 + i * COL_NUM + j);
        }
    }

    ObUpsMutator ups_mutator;
    ObMutator &mutator = ups_mutator.get_mutator();
    // add cell to array
    for (int64_t i = 0; i < ROW_NUM; ++i)
    {
        for (int64_t j = 0; j < COL_NUM; ++j)
        {
            ObMutatorCellInfo mutator_cell;
            mutator_cell.cell_info = cell_infos[i][j];
            mutator_cell.op_type.set_ext(ObActionFlag::OP_UPDATE);
            err = mutator.add_cell(mutator_cell);
            EXPECT_EQ(0, err);
        }
    }

    // write row to active memtable
    MemTableTransHandle write_handle;
    err = active_memtable.start_transaction(WRITE_TRANSACTION, write_handle);
    ASSERT_EQ(0, err);
    ups_mutator.set_mutate_timestamp(0);
    err = active_memtable.set(write_handle, ups_mutator);
    EXPECT_EQ(0, err);
    err = active_memtable.end_transaction(write_handle);
    ASSERT_EQ(0, err);
    /*
    ObString text;
    text.assign("/tmp", strlen("/tmp"));
    active_memtable.dump2text(text);
    */

    for (int64_t i = 0; i < ROW_NUM; ++i)
    {
        ObScanner scanner;
        ObGetParam get_param;
        //get_param.set_timestamp(version);
        ObVersionRange version_range;
        //version_range.start_version_ = version;
        //version_range.end_version_ = version;
        version_range.start_version_ = 2;
        version_range.end_version_ = 2;
        version_range.border_flag_.set_inclusive_start();
        version_range.border_flag_.set_inclusive_end();
        get_param.set_version_range(version_range);
        for (int64_t j = 0; j < COL_NUM; ++j)
        {
            get_param.add_cell(cell_infos[i][j]);
        }

        int64_t count = 0;
        err = mgr.get(get_param, scanner, tbsys::CTimeUtil::getTime(), 2000000000 * 1000L * 1000L);
        EXPECT_EQ(0, err);

        // check result
        count = 0;
        while (OB_SUCCESS == scanner.next_cell())
        {
            ObCellInfo* p_cell = NULL;
            scanner.get_cell(&p_cell);
            ASSERT_TRUE(p_cell != NULL);
            ObCellInfo expected = cell_infos[count / COL_NUM + i][count % COL_NUM];
            check_cell(expected, *p_cell);
            ++count;
        }
        EXPECT_EQ(COL_NUM, count);
    }
}