#include "tile/base/down_cast.h"
#include "gtest/gtest.h"

namespace tile {
struct A {
    virtual ~A() = default;
};

struct B : A {};

TEST(DownCast, All)
{
    B b;
    A *ptr = &b;
    ASSERT_NE(nullptr, down_cast<B>(ptr));
    ASSERT_NE(nullptr, down_cast<B>(const_cast<const A *>(ptr)));
}

#ifndef NDEBUG
TEST(CastDeathTest, DownCast)
{
    A a;
    A *ptr = &a;
    ASSERT_DEATH(down_cast<B>(ptr), "");
}
#endif
}// namespace tile
