当前位置: 首页>>代码示例>>C++>>正文


C++ TEST_TRUE函数代码示例

本文整理汇总了C++中TEST_TRUE函数的典型用法代码示例。如果您正苦于以下问题:C++ TEST_TRUE函数的具体用法?C++ TEST_TRUE怎么用?C++ TEST_TRUE使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了TEST_TRUE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: test_Local_Delete

static void
test_Local_Delete(TestBatchRunner *runner) {
    RAMFolder *folder = RAMFolder_new(NULL);
    FileHandle *fh;

    fh = RAMFolder_Open_FileHandle(folder, boffo, FH_CREATE | FH_WRITE_ONLY);
    DECREF(fh);
    TEST_TRUE(runner, RAMFolder_Local_Delete(folder, boffo),
              "Local_Delete on file succeeds");

    RAMFolder_Local_MkDir(folder, foo);
    fh = RAMFolder_Open_FileHandle(folder, foo_boffo,
                                   FH_CREATE | FH_WRITE_ONLY);
    DECREF(fh);

    Err_set_error(NULL);
    TEST_FALSE(runner, RAMFolder_Local_Delete(folder, foo),
               "Local_Delete on non-empty dir fails");

    RAMFolder_Delete(folder, foo_boffo);
    TEST_TRUE(runner, RAMFolder_Local_Delete(folder, foo),
              "Local_Delete on empty dir succeeds");

    DECREF(folder);
}
开发者ID:theory,项目名称:lucy,代码行数:25,代码来源:TestRAMFolder.c

示例2: test_calc_proximity_boost

static void
test_calc_proximity_boost(TestBatchRunner *runner) {
    VArray  *spans    = VA_new(0);
    HeatMap *heat_map = HeatMap_new(spans, 133);
    Span    *span1    = Span_new(  0, 10, 1.0f);
    Span    *span2    = Span_new( 10, 10, 1.0f);
    Span    *span3    = Span_new(  5,  4, 1.0f);
    Span    *span4    = Span_new(100, 10, 1.0f);
    Span    *span5    = Span_new(150, 10, 1.0f);

    float big_boost     = HeatMap_Calc_Proximity_Boost(heat_map, span1, span2);
    float eq_big_boost  = HeatMap_Calc_Proximity_Boost(heat_map, span1, span3);
    float smaller_boost = HeatMap_Calc_Proximity_Boost(heat_map, span1, span4);
    float zero_boost    = HeatMap_Calc_Proximity_Boost(heat_map, span1, span5);

    TEST_TRUE(runner, big_boost == eq_big_boost,
              "overlapping and abutting produce the same proximity boost");
    TEST_TRUE(runner, big_boost > smaller_boost, "closer is better");
    TEST_TRUE(runner, zero_boost == 0.0,
              "distance outside of window yields no prox boost");

    DECREF(span1);
    DECREF(span2);
    DECREF(span3);
    DECREF(span4);
    DECREF(span5);
    DECREF(heat_map);
    DECREF(spans);
}
开发者ID:hernan604,项目名称:lucy,代码行数:29,代码来源:TestHeatMap.c

示例3: test_Consolidate

static void
test_Consolidate(TestBatchRunner *runner) {
    Folder *folder = S_folder_with_contents();
    FileHandle *fh;

    // Fake up detritus from failed consolidation.
    fh = Folder_Open_FileHandle(folder, cf_file,
                                FH_CREATE | FH_WRITE_ONLY | FH_EXCLUSIVE);
    DECREF(fh);
    fh = Folder_Open_FileHandle(folder, cfmeta_temp,
                                FH_CREATE | FH_WRITE_ONLY | FH_EXCLUSIVE);
    DECREF(fh);

    CompoundFileWriter *cf_writer = CFWriter_new(folder);
    CFWriter_Consolidate(cf_writer);
    PASS(runner, "Consolidate completes despite leftover files");
    DECREF(cf_writer);

    TEST_TRUE(runner, Folder_Exists(folder, cf_file),
              "cf.dat file written");
    TEST_TRUE(runner, Folder_Exists(folder, cfmeta_file),
              "cfmeta.json file written");
    TEST_FALSE(runner, Folder_Exists(folder, foo),
               "original file zapped");
    TEST_FALSE(runner, Folder_Exists(folder, cfmeta_temp),
               "detritus from failed consolidation zapped");

    DECREF(folder);
}
开发者ID:carriercomm,项目名称:lucy,代码行数:29,代码来源:TestCompoundFileWriter.c

示例4: test_numbers

static void
test_numbers(TestBatchRunner *runner) {
    Integer *i64     = Int_new(33);
    String  *json    = Json_to_json((Obj*)i64);
    String  *trimmed = Str_Trim(json);
    TEST_TRUE(runner, Str_Equals_Utf8(trimmed, "33", 2), "Integer");
    DECREF(json);
    DECREF(trimmed);

    Float *f64 = Float_new(33.33);
    json = Json_to_json((Obj*)f64);
    if (json) {
        double value = Str_To_F64(json);
        double diff = 33.33 - value;
        if (diff < 0.0) { diff = 0.0 - diff; }
        TEST_TRUE(runner, diff < 0.0001, "Float");
        DECREF(json);
    }
    else {
        FAIL(runner, "Float conversion to  json  failed.");
    }

    DECREF(i64);
    DECREF(f64);
}
开发者ID:rectang,项目名称:lucy,代码行数:25,代码来源:TestJson.c

示例5: test_Dump_Load_and_Equals

static void
test_Dump_Load_and_Equals(TestBatch *batch)
{
    CharBuf *EN          = (CharBuf*)ZCB_WRAP_STR("en", 2); 
    CharBuf *ES          = (CharBuf*)ZCB_WRAP_STR("es", 2); 
    Stemmer *stemmer     = Stemmer_new(EN);
    Stemmer *other       = Stemmer_new(ES);
    Obj     *dump        = (Obj*)Stemmer_Dump(stemmer);
    Obj     *other_dump  = (Obj*)Stemmer_Dump(other);
    Stemmer *clone       = (Stemmer*)Stemmer_Load(other, dump);
    Stemmer *other_clone = (Stemmer*)Stemmer_Load(other, other_dump);

    TEST_FALSE(batch, Stemmer_Equals(stemmer,
        (Obj*)other), "Equals() false with different language");
    TEST_TRUE(batch, Stemmer_Equals(stemmer,
        (Obj*)clone), "Dump => Load round trip");
    TEST_TRUE(batch, Stemmer_Equals(other,
        (Obj*)other_clone), "Dump => Load round trip");

    DECREF(stemmer);
    DECREF(dump);
    DECREF(clone);
    DECREF(other);
    DECREF(other_dump);
    DECREF(other_clone);
}
开发者ID:gitpan,项目名称:KinoSearch,代码行数:26,代码来源:TestStemmer.c

示例6: test_all

static void
test_all(TestBatchRunner *runner) {
    LockFreeRegistry *registry = LFReg_new(10);
    StupidHashCharBuf *foo = StupidHashCharBuf_new("foo");
    StupidHashCharBuf *bar = StupidHashCharBuf_new("bar");
    StupidHashCharBuf *baz = StupidHashCharBuf_new("baz");
    StupidHashCharBuf *foo_dupe = StupidHashCharBuf_new("foo");

    TEST_TRUE(runner, LFReg_Register(registry, (Obj*)foo, (Obj*)foo),
              "Register() returns true on success");
    TEST_FALSE(runner,
               LFReg_Register(registry, (Obj*)foo_dupe, (Obj*)foo_dupe),
               "Can't Register() keys that test equal");

    TEST_TRUE(runner, LFReg_Register(registry, (Obj*)bar, (Obj*)bar),
              "Register() key with the same Hash_Sum but that isn't Equal");

    TEST_TRUE(runner, LFReg_Fetch(registry, (Obj*)foo_dupe) == (Obj*)foo,
              "Fetch()");
    TEST_TRUE(runner, LFReg_Fetch(registry, (Obj*)bar) == (Obj*)bar,
              "Fetch() again");
    TEST_TRUE(runner, LFReg_Fetch(registry, (Obj*)baz) == NULL,
              "Fetch() non-existent key returns NULL");

    DECREF(foo_dupe);
    DECREF(baz);
    DECREF(bar);
    DECREF(foo);
    DECREF(registry);
}
开发者ID:hernan604,项目名称:lucy,代码行数:30,代码来源:TestLockFreeRegistry.c

示例7: test_Dump_Load_and_Equals

static void
test_Dump_Load_and_Equals(TestBatchRunner *runner) {
    Query    *a_leaf        = (Query*)TestUtils_make_leaf_query(NULL, "a");
    Query    *b_leaf        = (Query*)TestUtils_make_leaf_query(NULL, "b");
    NOTQuery *query         = NOTQuery_new(a_leaf);
    NOTQuery *kids_differ   = NOTQuery_new(b_leaf);
    NOTQuery *boost_differs = NOTQuery_new(a_leaf);
    Obj      *dump          = (Obj*)NOTQuery_Dump(query);
    NOTQuery *clone         = (NOTQuery*)Obj_Load(dump, dump);

    TEST_FALSE(runner, NOTQuery_Equals(query, (Obj*)kids_differ),
               "Different kids spoil Equals");
    TEST_TRUE(runner, NOTQuery_Equals(query, (Obj*)boost_differs),
              "Equals with identical boosts");
    NOTQuery_Set_Boost(boost_differs, 1.5);
    TEST_FALSE(runner, NOTQuery_Equals(query, (Obj*)boost_differs),
               "Different boost spoils Equals");
    TEST_TRUE(runner, NOTQuery_Equals(query, (Obj*)clone),
              "Dump => Load round trip");

    DECREF(a_leaf);
    DECREF(b_leaf);
    DECREF(query);
    DECREF(kids_differ);
    DECREF(boost_differs);
    DECREF(dump);
    DECREF(clone);
}
开发者ID:theory,项目名称:lucy,代码行数:28,代码来源:TestNOTQuery.c

示例8: test_Read_File_and_Write_File

static void
test_Read_File_and_Write_File(TestBatchRunner *runner) {
    Snapshot *snapshot = Snapshot_new();
    Folder   *folder   = (Folder*)RAMFolder_new(NULL);
    String   *snap     = (String*)SSTR_WRAP_UTF8("snap", 4);
    String   *foo      = (String*)SSTR_WRAP_UTF8("foo", 3);

    Snapshot_Add_Entry(snapshot, foo);
    Snapshot_Write_File(snapshot, folder, snap);

    Snapshot *dupe = Snapshot_new();
    Snapshot *read_retval = Snapshot_Read_File(dupe, folder, snap);
    TEST_TRUE(runner, dupe == read_retval, "Read_File() returns the object");

    VArray *orig_list = Snapshot_List(snapshot);
    VArray *dupe_list = Snapshot_List(dupe);
    TEST_TRUE(runner, VA_Equals(orig_list, (Obj*)dupe_list),
              "Round trip through Write_File() and Read_File()");

    DECREF(orig_list);
    DECREF(dupe_list);
    DECREF(dupe);
    DECREF(snapshot);
    DECREF(folder);
}
开发者ID:github188,项目名称:SimpleCode,代码行数:25,代码来源:TestSnapshot.c

示例9: test_Cat

static void
test_Cat(TestBatchRunner *runner) {
    String *wanted = Str_newf("a%s", smiley);
    String *source;
    String *got;

    source = S_get_str("");
    got = Str_Cat(source, wanted);
    TEST_TRUE(runner, Str_Equals(wanted, (Obj*)got), "Cat");
    DECREF(got);
    DECREF(source);

    source = S_get_str("a");
    got = Str_Cat_Utf8(source, smiley, smiley_len);
    TEST_TRUE(runner, Str_Equals(wanted, (Obj*)got), "Cat_Utf8");
    DECREF(got);
    DECREF(source);

    source = S_get_str("a");
    got = Str_Cat_Trusted_Utf8(source, smiley, smiley_len);
    TEST_TRUE(runner, Str_Equals(wanted, (Obj*)got), "Cat_Trusted_Utf8");
    DECREF(got);
    DECREF(source);

    DECREF(wanted);
}
开发者ID:nkurz,项目名称:lucy-clownfish,代码行数:26,代码来源:TestString.c

示例10: test_Local_Open_Dir

static void
test_Local_Open_Dir(TestBatchRunner *runner) {

    Folder *real_folder = S_folder_with_contents();
    CompoundFileReader *cf_reader = CFReader_open(real_folder);
    bool saw_foo       = false;
    bool saw_stuff     = false;
    bool stuff_was_dir = false;

    CFReader_MkDir(cf_reader, stuff);

    DirHandle *dh = CFReader_Local_Open_Dir(cf_reader);
    while (DH_Next(dh)) {
        String *entry = DH_Get_Entry(dh);
        if (Str_Equals(entry, (Obj*)foo)) {
            saw_foo = true;
        }
        else if (Str_Equals(entry, (Obj*)stuff)) {
            saw_stuff = true;
            stuff_was_dir = DH_Entry_Is_Dir(dh);
        }
        DECREF(entry);
    }

    TEST_TRUE(runner, saw_foo, "DirHandle iterated over virtual file");
    TEST_TRUE(runner, saw_stuff, "DirHandle iterated over real directory");
    TEST_TRUE(runner, stuff_was_dir,
              "DirHandle knew that real entry was dir");

    DECREF(dh);
    DECREF(cf_reader);
    DECREF(real_folder);
}
开发者ID:apache,项目名称:lucy,代码行数:33,代码来源:TestCompoundFileReader.c

示例11: test_Local_Open_In

static void
test_Local_Open_In(TestBatchRunner *runner) {
    Folder *real_folder = S_folder_with_contents();
    CompoundFileReader *cf_reader = CFReader_open(real_folder);
    InStream *instream;

    instream = CFReader_Local_Open_In(cf_reader, foo);
    TEST_TRUE(runner, instream != NULL,
              "Local_Open_In for virtual file");
    TEST_TRUE(runner,
              Str_Starts_With(InStream_Get_Filename(instream), CFReader_Get_Path(cf_reader)),
              "InStream's path includes directory");
    DECREF(instream);

    OutStream *outstream = CFReader_Open_Out(cf_reader, baz);
    OutStream_Write_Bytes(outstream, "baz", 3);
    OutStream_Close(outstream);
    DECREF(outstream);
    instream = CFReader_Local_Open_In(cf_reader, baz);
    TEST_TRUE(runner, instream != NULL,
              "Local_Open_In pass-through for real file");
    DECREF(instream);

    Err_set_error(NULL);
    instream = CFReader_Local_Open_In(cf_reader, stuff);
    TEST_TRUE(runner, instream == NULL,
              "Local_Open_In for non-existent file returns NULL");
    TEST_TRUE(runner, Err_get_error() != NULL,
              "Local_Open_In for non-existent file sets global error");

    DECREF(cf_reader);
    DECREF(real_folder);
}
开发者ID:apache,项目名称:lucy,代码行数:33,代码来源:TestCompoundFileReader.c

示例12: test_Mimic_and_Clone

static void
test_Mimic_and_Clone(TestBatchRunner *runner) {
    String  *wanted    = S_get_str("foo");
    CharBuf *wanted_cb = S_get_cb("foo");
    CharBuf *got       = S_get_cb("bar");

    CB_Mimic(got, (Obj*)wanted);
    TEST_TRUE(runner, S_cb_equals(got, wanted), "Mimic String");
    DECREF(got);

    got = S_get_cb("bar");
    CB_Mimic(got, (Obj*)wanted_cb);
    TEST_TRUE(runner, S_cb_equals(got, wanted), "Mimic CharBuf");
    DECREF(got);

    got = S_get_cb("bar");
    CB_Mimic_Utf8(got, "foo", 3);
    TEST_TRUE(runner, S_cb_equals(got, wanted), "Mimic_Utf8");
    DECREF(got);

    got = CB_Clone(wanted_cb);
    TEST_TRUE(runner, S_cb_equals(got, wanted), "Clone");
    DECREF(got);

    DECREF(wanted);
    DECREF(wanted_cb);
}
开发者ID:gitpan,项目名称:Clownfish,代码行数:27,代码来源:TestCharBuf.c

示例13: test_Cat

static void
test_Cat(TestBatchRunner *runner) {
    String  *wanted = Str_newf("a%s", smiley);
    CharBuf *got    = S_get_cb("");

    CB_Cat(got, wanted);
    TEST_TRUE(runner, S_cb_equals(got, wanted), "Cat");
    DECREF(got);

    got = S_get_cb("a");
    CB_Cat_Char(got, 0x263A);
    TEST_TRUE(runner, S_cb_equals(got, wanted), "Cat_Char");
    DECREF(got);

    got = S_get_cb("a");
    CB_Cat_Utf8(got, smiley, smiley_len);
    TEST_TRUE(runner, S_cb_equals(got, wanted), "Cat_Utf8");
    DECREF(got);

    got = S_get_cb("a");
    CB_Cat_Trusted_Utf8(got, smiley, smiley_len);
    TEST_TRUE(runner, S_cb_equals(got, wanted), "Cat_Trusted_Utf8");
    DECREF(got);

    DECREF(wanted);
}
开发者ID:gitpan,项目名称:Clownfish,代码行数:26,代码来源:TestCharBuf.c

示例14: test_Equals

static void
test_Equals(TestBatchRunner *runner) {
    ByteBuf *bb = BB_new_bytes("foo", 4); // Include terminating NULL.

    {
        ByteBuf *other = BB_new_bytes("foo", 4);
        TEST_TRUE(runner, BB_Equals(bb, (Obj*)other), "Equals");
        DECREF(other);
    }

    TEST_TRUE(runner, BB_Equals_Bytes(bb, "foo", 4), "Equals_Bytes");
    TEST_FALSE(runner, BB_Equals_Bytes(bb, "foo", 3),
               "Equals_Bytes spoiled by different size");
    TEST_FALSE(runner, BB_Equals_Bytes(bb, "bar", 4),
               "Equals_Bytes spoiled by different content");

    {
        ByteBuf *other = BB_new_bytes("foo", 3);
        TEST_FALSE(runner, BB_Equals(bb, (Obj*)other),
                   "Different size spoils Equals");
        DECREF(other);
    }

    {
        ByteBuf *other = BB_new_bytes("bar", 4);
        TEST_UINT_EQ(runner, BB_Get_Size(bb), BB_Get_Size(other),
                     "same length");
        TEST_FALSE(runner, BB_Equals(bb, (Obj*)other),
                   "Different content spoils Equals");
        DECREF(other);
    }

    DECREF(bb);
}
开发者ID:srcclrapache1,项目名称:lucy-clownfish,代码行数:34,代码来源:TestByteBuf.c

示例15: test_Clone

static void
test_Clone(TestBatch *batch) {
    Float32   *f32 = Float32_new(1.33f);
    Float64   *f64 = Float64_new(1.33);
    Integer32 *i32 = Int32_new(I32_MAX);
    Integer64 *i64 = Int64_new(I64_MAX);
    Float32   *f32_dupe = Float32_Clone(f32);
    Float64   *f64_dupe = Float64_Clone(f64);
    Integer32 *i32_dupe = Int32_Clone(i32);
    Integer64 *i64_dupe = Int64_Clone(i64);
    TEST_TRUE(batch, Float32_Equals(f32, (Obj*)f32_dupe),
              "Float32 Clone");
    TEST_TRUE(batch, Float64_Equals(f64, (Obj*)f64_dupe),
              "Float64 Clone");
    TEST_TRUE(batch, Int32_Equals(i32, (Obj*)i32_dupe),
              "Integer32 Clone");
    TEST_TRUE(batch, Int64_Equals(i64, (Obj*)i64_dupe),
              "Integer64 Clone");
    TEST_TRUE(batch, Bool_Equals(CFISH_TRUE, (Obj*)Bool_Clone(CFISH_TRUE)),
              "BoolNum Clone");
    DECREF(i64_dupe);
    DECREF(i32_dupe);
    DECREF(f64_dupe);
    DECREF(f32_dupe);
    DECREF(i64);
    DECREF(i32);
    DECREF(f64);
    DECREF(f32);
}
开发者ID:pavansondur,项目名称:lucy,代码行数:29,代码来源:TestNum.c


注:本文中的TEST_TRUE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。