Exemplo n.º 1
0
CUNIT_TEST(DBSuite, EagleDbTuple_set)
{
    EagleDbTable *table = EagleDbTable_New("mytable");
    EagleDbTable_addColumn(table, EagleDbColumn_New("col1", EagleDataTypeUnknown));

    EagleDbTuple *tuple = EagleDbTuple_New(table);
    CUNIT_VERIFY_FALSE(EagleDbTuple_set(tuple, 0, NULL, EagleDataTypeUnknown));

    EagleDbTuple_Delete(tuple);
    EagleDbTable_DeleteWithColumns(table);
}
Exemplo n.º 2
0
CUNIT_TEST(DBSuite, EagleDbTuple_setFloat)
{
    EagleLogger_Get()->out = NULL;

    EagleDbTable *table = EagleDbTable_New("mytable");
    EagleDbTable_addColumn(table, EagleDbColumn_New("a", EagleDataTypeVarchar));

    EagleDbTuple *tuple = EagleDbTuple_New(table);
    EagleDbTuple_setFloat(tuple, 0, 123.0);
    CUNIT_ASSERT_LAST_ERROR("Wrong type.");

    EagleDbTuple_Delete(tuple);
    EagleDbTable_DeleteWithColumns(table);
}
Exemplo n.º 3
0
void runFuzzTests(const char *pre, int totalFuzzTests, int length)
{
    // setup
    int pageSize = 10;
    EagleDbInstance *db = EagleDbInstance_New(pageSize, 1);
    
    EagleDbSchema *schema = EagleDbInstance_getSchema(db, EagleDbSchema_DefaultSchemaName);
    
    EagleDbTable *table = EagleDbTable_New("mytable");
    EagleDbTable_addColumn(table, EagleDbColumn_New("col1", EagleDataTypeInteger));
    
    EagleDbTableData *td = EagleDbTableData_New(table, pageSize);
    EagleDbSchema_addTable(schema, td);
    
    // begin fuzz testing
    for(int i = 0; i < totalFuzzTests; ++i) {
        char *sql = getSQLFuzz(pre, length);
        
        /*EagleLogger_Get()->out = stderr;
        fprintf(stderr, "\n%d: %s\n", i, sql);*/
        
        EagleLoggerEvent *error = NULL;
        EagleBoolean success = EagleDbInstance_execute(db, sql, &error);
        if(EagleTrue == success) {
            CUNIT_FAIL("%s", sql);
        }
        free(sql);
    }
    
    printf(" %d fuzz tests ", totalFuzzTests);
    
    // tear down
    EagleDbSchema *_schema = EagleDbInstance_getSchema(db, EagleDbSchema_DefaultSchemaName);
    EagleDbTableData *_td = EagleDbSchema_getTable(_schema, "mytable");
    EagleDbTable_DeleteWithColumns(_td->table);
    EagleDbTableData_Delete(_td);
    EagleDbInstance_Delete(db);
}