#include "Test.h"

#include "Checked_cast.h"

namespace MM
{

class Checked_cast_test : public Test
{
public:
    Checked_cast_test (const Text & suite_name) : Test (suite_name) { }
    
    void run()
    {
        test_ ();        //count_tests();
    }

    void test_ ();
};

Checked_cast_test test_checked_cast ("correctness");

namespace 
{
    class A {public: virtual ~A(){}};
    class B : public A {};
    class C : public A {};
};

void Checked_cast_test::
test_ ()
{
    B   b;
    A & ref = b;
    //A * ptr = &b;

//    B & br = cast <B&> (ref);
    cast <B&> (ref);
    //B & bp = dbc_cast <B*> (ptr);

    #ifndef NDEBUG 
    bool result = false;
    try
    {
        cast <C&> (ref);
    }
    catch(...)
    {
        result = true;
    }
    TEST ("ref is not C.", result);
    #endif

}

}//MM
