Ejemplo n.º 1
0
static void test_TextField()
{
    TextField* t = createTextField();
    EXPECT_EQ_TEXT_FIELD("", 0, t);

    t->insertCharacter('A');
    EXPECT_EQ_TEXT_FIELD("A", 1, t);

    t->insertCharacter('B');
    t->insertCharacter('C');
    t->insertCharacter('D');
    EXPECT_EQ_TEXT_FIELD("ABCD", 4, t);

    t->deleteCharacter();
    EXPECT_EQ_TEXT_FIELD("ABC", 3, t);

    t->backward();
    t->insertCharacter('E');
    EXPECT_EQ_TEXT_FIELD("ABEC", 3, t);

    t->backward();
    t->deleteCharacter();
    EXPECT_EQ_TEXT_FIELD("AEC", 1, t);

    t->forward();
    t->forward();
    t->insertCharacter('Z');
    EXPECT_EQ_TEXT_FIELD("AECZ", 4, t);
    destroyTextField(t);
}
Ejemplo n.º 2
0
static void test_TextField_cursor()
{
    const char* text = "Hello";
    TextField* t = createTextField();
    t->setText(text);

    t->deleteCharacter();
    EXPECT_STR_EQ("Hell", t->getText());
    t->insertCharacter('o');
    EXPECT_STR_EQ("Hello", t->getText());

    for (size_t i = 0; i < strlen(text); i++) {
        t->backward();
    }
    t->backward();

    for (size_t i = 0; i < strlen(text); i++) {
        t->forward();
    }
    t->forward();

    t->insertCharacter('Z');
    EXPECT_STR_EQ("HelloZ", t->getText());
    destroyTextField(t);
}