Exemplo n.º 1
0
static void
test_Equals(TestBatch *batch) {
    Obj *testobj = S_new_testobj();
    Obj *other   = S_new_testobj();

    TEST_TRUE(batch, Obj_Equals(testobj, testobj),
              "Equals is true for the same object");
    TEST_FALSE(batch, Obj_Equals(testobj, other),
               "Distinct objects are not equal");

    DECREF(testobj);
    DECREF(other);
}
Exemplo n.º 2
0
static void
test_To_String(TestBatchRunner *runner) {
    Obj *testobj = S_new_testobj();
    String *string = Obj_To_String(testobj);
    TEST_TRUE(runner, Str_Find_Utf8(string, "TestObj", 7) >= 0, "To_String");
    DECREF(string);
    DECREF(testobj);
}
Exemplo n.º 3
0
static void
test_Hash_Sum(TestBatch *batch) {
    Obj *testobj = S_new_testobj();
    int64_t address64 = PTR_TO_I64(testobj);
    int32_t address32 = (int32_t)address64;
    TEST_TRUE(batch, (Obj_Hash_Sum(testobj) == address32),
              "Hash_Sum uses memory address");
    DECREF(testobj);
}
Exemplo n.º 4
0
static void
test_Dump(TestBatch *batch) {
    Obj *testobj = S_new_testobj();
    CharBuf *string = Obj_To_String(testobj);
    Obj *dump = Obj_Dump(testobj);
    TEST_TRUE(batch, Obj_Equals(dump, (Obj*)string),
              "Default Dump returns To_String");
    DECREF(dump);
    DECREF(string);
    DECREF(testobj);
}
Exemplo n.º 5
0
static void
test_abstract_routines(TestBatchRunner *runner) {
    Obj *blank = Class_Make_Obj(OBJ);
    S_verify_abstract_error(runner, S_attempt_init, blank, "init");

    Obj *obj = S_new_testobj();
    S_verify_abstract_error(runner, S_attempt_Clone,      obj, "Clone");
    S_verify_abstract_error(runner, S_attempt_Compare_To, obj, "Compare_To");
    S_verify_abstract_error(runner, S_attempt_To_I64,     obj, "To_I64");
    S_verify_abstract_error(runner, S_attempt_To_F64,     obj, "To_F64");
    S_verify_abstract_error(runner, S_attempt_Mimic,      obj, "Mimic");
    DECREF(obj);
}
Exemplo n.º 6
0
static void
test_To_String(TestBatch *batch) {
    Obj *testobj = S_new_testobj();
    CharBuf *string = Obj_To_String(testobj);
    ZombieCharBuf *temp = ZCB_WRAP(string);
    while (ZCB_Get_Size(temp)) {
        if (ZCB_Starts_With_Str(temp, "TestObj", 7)) {
            break;
        }
        ZCB_Nip_One(temp);
    }
    TEST_TRUE(batch, ZCB_Starts_With_Str(temp, "TestObj", 7), "To_String");
    DECREF(string);
    DECREF(testobj);
}
Exemplo n.º 7
0
static void
test_refcounts(TestBatch *batch) {
    Obj *obj = S_new_testobj();

    TEST_INT_EQ(batch, Obj_Get_RefCount(obj), 1,
                "Correct starting refcount");

    Obj_Inc_RefCount(obj);
    TEST_INT_EQ(batch, Obj_Get_RefCount(obj), 2, "Inc_RefCount");

    Obj_Dec_RefCount(obj);
    TEST_INT_EQ(batch, Obj_Get_RefCount(obj), 1, "Dec_RefCount");

    DECREF(obj);
}
Exemplo n.º 8
0
static void
test_abstract_routines(TestBatch *batch) {
    Obj *blank = VTable_Make_Obj(OBJ);
    S_verify_abstract_error(batch, S_attempt_init, blank, "init");

    Obj *obj = S_new_testobj();
    S_verify_abstract_error(batch, S_attempt_Clone,      obj, "Clone");
    S_verify_abstract_error(batch, S_attempt_Make,       obj, "Make");
    S_verify_abstract_error(batch, S_attempt_Compare_To, obj, "Compare_To");
    S_verify_abstract_error(batch, S_attempt_To_I64,     obj, "To_I64");
    S_verify_abstract_error(batch, S_attempt_To_F64,     obj, "To_F64");
    S_verify_abstract_error(batch, S_attempt_Load,       obj, "Load");
    S_verify_abstract_error(batch, S_attempt_Mimic,      obj, "Mimic");
    DECREF(obj);
}
Exemplo n.º 9
0
static void
test_refcounts(TestBatchRunner *runner) {
    Obj *obj = S_new_testobj();

    TEST_INT_EQ(runner, CFISH_REFCOUNT_NN(obj), 1,
                "Correct starting refcount");

    obj = CFISH_INCREF_NN(obj);
    TEST_INT_EQ(runner, CFISH_REFCOUNT_NN(obj), 2, "INCREF_NN");

    CFISH_DECREF_NN(obj);
    TEST_INT_EQ(runner, CFISH_REFCOUNT_NN(obj), 1, "DECREF_NN");

    DECREF(obj);
}