예제 #1
0
TEST(GTestError, TestInstanceOf) {
    Error::CPtr e = Error::create(Error::ANY);
    ASSERT_TRUE(e->instanceof(Type<Error>::id()));
    ASSERT_TRUE(e->instanceof(Type<Status>::id()));
    ASSERT_TRUE(e->instanceof(Type<Immutable>::id()));
    ASSERT_TRUE(e->instanceof(Type<Object>::id()));
}
예제 #2
0
TEST(GTestLinkedList, TestError) {
    LinkedList::Ptr l = LinkedList::create();

#ifdef LIBJ_USE_EXCEPTION
    ASSERT_ANY_THROW(l->get(5));
#else
    Error::CPtr e;
    ASSERT_TRUE(to<Error::CPtr>(l->get(0), &e));
    ASSERT_TRUE(e->instanceof(Type<Error>::id()));
    ASSERT_EQ(e->code(), Error::INDEX_OUT_OF_BOUNDS);
#endif  // LIBJ_USE_EXCEPTION
}
예제 #3
0
TEST(GTestArrayList, TestError) {
    ArrayList::Ptr a = ArrayList::create();

#ifdef LIBJ_USE_EXCEPTION
    ASSERT_ANY_THROW(a->get(5));
#else
    Error::CPtr e;
    ASSERT_TRUE(to<Error::CPtr>(a->get(5), &e));
    ASSERT_TRUE(e->instanceof(Type<Error>::id()));
    ASSERT_EQ(Error::INDEX_OUT_OF_BOUNDS, e->code());
#endif  // LIBJ_USE_EXCEPTION
}
예제 #4
0
TEST(GTestLinkedList, TestClear) {
    LinkedList::Ptr l = LinkedList::create();
    l->add(123);
    l->add(456);
    l->clear();

#ifdef LIBJ_USE_EXCEPTION
    ASSERT_ANY_THROW(l->get(0));
#else
    Error::CPtr e;
    ASSERT_TRUE(to<Error::CPtr>(l->get(0), &e));
    ASSERT_TRUE(e->instanceof(Type<Error>::id()));
#endif  // LIBJ_USE_EXCEPTION
    ASSERT_EQ(l->size(), 0);
}
예제 #5
0
TEST(GTestArrayList, TestClear) {
    ArrayList::Ptr a = ArrayList::create();
    a->add(123);
    a->add(456);
    a->clear();

#ifdef LIBJ_USE_EXCEPTION
    ASSERT_ANY_THROW(a->get(0));
#else
    Error::CPtr e;
    ASSERT_TRUE(to<Error::CPtr>(a->get(0), &e));
    ASSERT_TRUE(e->instanceof(Type<Error>::id()));
#endif  // LIBJ_USE_EXCEPTION
    ASSERT_EQ(0, a->size());
}
예제 #6
0
TEST(GTestError, TestInstanceOf) {
    Error::CPtr e = Error::create(uv::Error::_EOF);
    ASSERT_TRUE(e->instanceof(Type<uv::Error>::id()));
    ASSERT_TRUE(e->instanceof(Type<libj::Error>::id()));
    ASSERT_TRUE(e->instanceof(Type<libj::Status>::id()));
    ASSERT_TRUE(e->instanceof(Type<Immutable>::id()));
    ASSERT_TRUE(e->instanceof(Type<Object>::id()));
}
예제 #7
0
TEST(GTestError, TestToString) {
    String::CPtr foo = String::create("foo");
    Error::CPtr e = Error::create(Error::ANY, foo);
    ASSERT_TRUE(e->toString()->equals(foo));
}
예제 #8
0
TEST(GTestError, TestMessage2) {
    String::CPtr foo = String::create("foo");
    Error::CPtr e = Error::create(Error::ANY, foo);
    ASSERT_TRUE(e->message()->equals(foo));
}
예제 #9
0
TEST(GTestError, TestMessage) {
    Error::CPtr e = Error::create(Error::TIMEOUT);
    String::CPtr strTimeout = String::create("Timeout");
    ASSERT_TRUE(e->message()->equals(strTimeout));
}
예제 #10
0
TEST(GTestError, TestValueOf) {
    String::CPtr strEOF = String::create("end of file");
    Error::CPtr e = Error::valueOf(UV_EOF);
    ASSERT_TRUE(e->message()->equals(strEOF));
}
예제 #11
0
TEST(GTestError, TestToString) {
    String::CPtr strEOF = String::create("end of file");
    Error::CPtr e = Error::create(Error::_EOF);
    ASSERT_TRUE(e->toString()->equals(strEOF));
}