Ejemplo n.º 1
0
CUNIT_TEST(DBSuite, _string_literal)
{
    EagleDbInstance *db = EagleInstanceTest(10);
    EagleBoolean success;
    EagleLoggerEvent *error = NULL;

    success = EagleDbInstance_execute(db, "CREATE TABLE mytable2 (col1 int, col2 text);", &error);
    if (EagleFalse == success) {
        CUNIT_FAIL("%s", error->message);
    }
    CUNIT_ASSERT_TRUE(success);

    success = EagleDbInstance_execute(db, "INSERT INTO mytable2 (col1, col2) VALUES (123, 'some '' cool \' text');", &error);
    if (EagleFalse == success) {
        CUNIT_FAIL("%s", error->message);
    }
    CUNIT_ASSERT_TRUE(success);

    // SELECT data back
    EagleDbParser *p = EagleDbParser_ParseWithString("SELECT col1, col2, 'some string' FROM mytable2;");
    CUNIT_ASSERT_FALSE(EagleDbParser_hasError(p));

    EaglePlan *plan = EagleDbSqlSelect_parse((EagleDbSqlSelect*) p->yyparse_ast, db);
    //printf("%s\n", EaglePlan_toString(plan));

    // catch compilation error
    CUNIT_ASSERT_FALSE(EaglePlan_isError(plan));

    // execute
    EagleInstance *eagle = EagleInstance_New(1);
    EagleInstance_addPlan(eagle, plan);
    EagleInstance_run(eagle);

    // validate data
    EaglePage *page1 = EaglePageProvider_nextPage(plan->result[0]);
    EaglePage *page2 = EaglePageProvider_nextPage(plan->result[1]);
    EaglePage *page3 = EaglePageProvider_nextPage(plan->result[2]);

    CUNIT_ASSERT_EQUAL_INT(page1->type, EagleDataTypeInteger);
    CUNIT_ASSERT_EQUAL_INT(page2->type, EagleDataTypeVarchar);
    CUNIT_ASSERT_EQUAL_INT(page3->type, EagleDataTypeVarchar);
    CUNIT_ASSERT_EQUAL_INT(1, page1->count);
    CUNIT_ASSERT_EQUAL_INT(1, page2->count);
    CUNIT_ASSERT_EQUAL_INT(10, page3->count);
    CUNIT_ASSERT_EQUAL_INT(((int*) page1->data)[0], 123);
    CUNIT_ASSERT_EQUAL_STRING(((char**) page2->data)[0], "some ' cool ' text");
    CUNIT_ASSERT_EQUAL_STRING(((char**) page3->data)[0], "some string");

    EaglePage_Delete(page1);
    EaglePage_Delete(page2);
    EaglePage_Delete(page3);

    EagleInstance_Delete(eagle);
    EaglePlan_Delete(plan);

    EagleDbSqlSelect_DeleteRecursive((EagleDbSqlSelect*) p->yyparse_ast);
    EagleDbParser_Delete(p);

    EagleInstanceTest_Cleanup(db);
}
Ejemplo n.º 2
0
CUNIT_TEST(MemorySuite, EagleDbSqlFunctionExpression_New)
{
    EagleMemory_MockInit();
    EagleMemory_Mock("EagleDbSqlFunctionExpression_New.1");
    
    CUNIT_VERIFY_NULL(EagleDbSqlFunctionExpression_New(NULL, NULL));
    
    CUNIT_ASSERT_EQUAL_INT(EagleMemory_GetMockInvocations(), 1);
    EagleMemory_MockFinish();
}
Ejemplo n.º 3
0
CUNIT_TEST(MemorySuite, EaglePage_AllocFloat)
{
    EagleMemory_MockInit();
    EagleMemory_Mock("EaglePage_AllocFloat.1");
    
    CUNIT_VERIFY_NULL(EaglePage_AllocFloat(1));
    
    CUNIT_ASSERT_EQUAL_INT(EagleMemory_GetMockInvocations(), 1);
    EagleMemory_MockFinish();
}
Ejemplo n.º 4
0
CUNIT_TEST(MemorySuite, EaglePageProviderSingle_NewFloat)
{
    EagleMemory_MockInit();
    EagleMemory_Mock("EaglePageProviderSingle_NewFloat.1");
    
    CUNIT_VERIFY_NULL(EaglePageProviderSingle_NewFloat(123.0, 1, "name"));
    
    CUNIT_ASSERT_EQUAL_INT(EagleMemory_GetMockInvocations(), 1);
    EagleMemory_MockFinish();
}
Ejemplo n.º 5
0
CUNIT_TEST(MemorySuite, EagleDbSqlValue_NewWithFloat)
{
    EagleMemory_MockInit();
    EagleMemory_Mock("EagleDbSqlValue_NewWithFloat.1");
    
    CUNIT_VERIFY_NULL(EagleDbSqlValue_NewWithFloat(123.0));
    
    CUNIT_ASSERT_EQUAL_INT(EagleMemory_GetMockInvocations(), 1);
    EagleMemory_MockFinish();
}
Ejemplo n.º 6
0
CUNIT_TEST(MemorySuite, EaglePlanBufferProvider_NewWithValue)
{
    EagleMemory_MockInit();
    EagleMemory_Mock("EaglePlanBufferProvider_NewWithValue.1");
    
    CUNIT_VERIFY_NULL(EaglePlanBufferProvider_NewWithValue(0, NULL));
    
    CUNIT_ASSERT_EQUAL_INT(EagleMemory_GetMockInvocations(), 1);
    EagleMemory_MockFinish();
}
Ejemplo n.º 7
0
CUNIT_TEST(MemorySuite, EagleDbSqlCastExpression_toString)
{
    EagleMemory_MockInit();
    EagleMemory_Mock("EagleDbSqlCastExpression_toString.1");
    
    CUNIT_VERIFY_NULL(EagleDbSqlCastExpression_toString(NULL));
    
    CUNIT_ASSERT_EQUAL_INT(EagleMemory_GetMockInvocations(), 1);
    EagleMemory_MockFinish();
}
Ejemplo n.º 8
0
CUNIT_TEST(MemorySuite, EagleDbSqlCastExpression_New)
{
    EagleMemory_MockInit();
    EagleMemory_Mock("EagleDbSqlCastExpression_New.1");
    
    CUNIT_VERIFY_NULL(EagleDbSqlCastExpression_New(NULL, EagleDataTypeInteger));
    
    CUNIT_ASSERT_EQUAL_INT(EagleMemory_GetMockInvocations(), 1);
    EagleMemory_MockFinish();
}
Ejemplo n.º 9
0
CUNIT_TEST(MemorySuite, EaglePage_CopyFloat_)
{
    EagleMemory_MockInit();
    EagleMemory_Mock("EaglePage_CopyFloat_.1");
    
    EaglePage *page = EaglePage_AllocFloat(1);
    CUNIT_VERIFY_NULL(EaglePage_RealCopyFloat_(page));
    EaglePage_Delete(page);
    
    CUNIT_ASSERT_EQUAL_INT(EagleMemory_GetMockInvocations(), 1);
    EagleMemory_MockFinish();
}
Ejemplo n.º 10
0
CUNIT_TEST(MemorySuite, EaglePageProviderSingle_nextPage_3)
{
    EagleMemory_MockInit();
    EagleMemory_Mock("EaglePageProviderSingle_nextPage.3");
    
    EaglePageProviderSingle *single = EaglePageProviderSingle_NewFloat(123.0, 1, "name");
    CUNIT_VERIFY_NULL(EaglePageProviderSingle_nextPage(single));
    EaglePageProviderSingle_Delete(single);
    
    CUNIT_ASSERT_EQUAL_INT(EagleMemory_GetMockInvocations(), 1);
    EagleMemory_MockFinish();
}
Ejemplo n.º 11
0
CUNIT_TEST(MemorySuite, EaglePlan_New_3)
{
    EagleMemory_MockInit();
    EagleMemory_Mock("EaglePlan_New.3");
    
    EaglePlan *plan = EaglePlan_New(1, 1);
    CUNIT_ASSERT_NULL(plan);
    EaglePlan_Delete(plan);
    
    CUNIT_ASSERT_EQUAL_INT(EagleMemory_GetMockInvocations(), 1);
    EagleMemory_MockFinish();
}