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())); }
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 }
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 }
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); }
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()); }
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())); }
TEST(GTestError, TestToString) { String::CPtr foo = String::create("foo"); Error::CPtr e = Error::create(Error::ANY, foo); ASSERT_TRUE(e->toString()->equals(foo)); }
TEST(GTestError, TestMessage2) { String::CPtr foo = String::create("foo"); Error::CPtr e = Error::create(Error::ANY, foo); ASSERT_TRUE(e->message()->equals(foo)); }
TEST(GTestError, TestMessage) { Error::CPtr e = Error::create(Error::TIMEOUT); String::CPtr strTimeout = String::create("Timeout"); ASSERT_TRUE(e->message()->equals(strTimeout)); }
TEST(GTestError, TestValueOf) { String::CPtr strEOF = String::create("end of file"); Error::CPtr e = Error::valueOf(UV_EOF); ASSERT_TRUE(e->message()->equals(strEOF)); }
TEST(GTestError, TestToString) { String::CPtr strEOF = String::create("end of file"); Error::CPtr e = Error::create(Error::_EOF); ASSERT_TRUE(e->toString()->equals(strEOF)); }