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 }