Example #1
0
TEST(tuple_gen,try_to_free) {
    CTupleGeneratorSmart gen;
    gen.Create(1, 1); 
    gen.add_client_pool(cdSEQ_DIST,0x10000001,0x10000001,64000,4,NULL,0,0);
    gen.add_server_pool(cdSEQ_DIST,0x30000001,0x400000ff,64000,4,false);
    CTupleTemplateGeneratorSmart template_1;
    template_1.Create(&gen,0,0);

    CTupleBase result;


    int i;
    for (i=0; i<65557; i++) {
        template_1.GenerateTuple(result);
        uint32_t result_src = result.getClient();
        uint32_t result_dest = result.getServer();
        uint16_t result_port = result.getClientPort();
        gen.FreePort(0,result.getClientId(),result_port);
    }
    // should have error
    EXPECT_FALSE((gen.getErrorAllocationCounter()>0)?true:false);

    template_1.Delete();
    gen.Delete();
}
TEST(tuple_gen,no_free) {
    CTupleGeneratorSmart gen;
    gen.Create(1, 1);
    gen.add_client_pool(cdSEQ_DIST,0x10000001,0x10000001,64000,4,g_dummy,0,0);
    gen.add_server_pool(cdSEQ_DIST,0x30000001,0x400000ff,64000,4,false);
    CTupleTemplateGeneratorSmart template_1;
    template_1.Create(&gen,0,0);

    CTupleBase result;


    int i;
    for (i=0; i<65557; i++) {
        template_1.GenerateTuple(result);
    }
    // should have error
    EXPECT_TRUE((gen.getErrorAllocationCounter()>0)?true:false);

    template_1.Delete();
    gen.Delete();
}