Esempio n. 1
0
 TEST_F(TestNumericFactory, GetShouldReturnValidNumericObject)
 {
   NumericFactory factory;
   factory.Add("TEST", createInstance);
   Numeric::Ptr numeric = factory.Get("TEST", BASE_DECIMAL);
   EXPECT_NE(static_cast<Numeric*>(0), numeric.get());
 }
Esempio n. 2
0
Numeric::Ptr ATFloatOrDerivedImpl::power(const Numeric::Ptr &other, const DynamicContext* context) const
{
    switch(other->getPrimitiveTypeIndex()) {
    case DECIMAL:
        // if other is a decimal, promote it to xs:float
        return power(context->getItemFactory()->createFloat(other->asMAPM(), context), context);
    case FLOAT: {
        ATFloatOrDerivedImpl *otherImpl = (ATFloatOrDerivedImpl*)other.get();

        switch(_state) {
        case NaN:
            return this;
        case INF: {
            switch(otherImpl->_state) {
            case NaN:
                return other;
            case NEG_NUM:
            case NUM:
            case INF:
            case NEG_INF:
                return this;
            default:
                assert(false);
                return 0; // should never get here
            }
        }
        case NEG_INF: {
            switch(otherImpl->_state) {
            case NaN:
                return other;
            case NEG_NUM:
            case NUM:
            case INF:
            case NEG_INF:
                return this;
            default:
                assert(false);
                return 0; // should never get here
            }
        }
        case NEG_NUM:
        case NUM: {
            switch(otherImpl->_state) {
            case NaN:
                return other;
            case INF:
                return other;
            case NEG_INF:
                return infinity(context);
            case NEG_NUM:
            case NUM:
                return newFloat(_float.pow(otherImpl->_float), context);
            default:
                assert(false);
                return 0;  // should never get here
            }
        }
        default:
            assert(false);
            return 0;  // should never get here
        }
    }
    case DOUBLE:
        return ((Numeric*)this->castAs(DOUBLE, context).get())->power(other, context);
    default:
        assert(false);
        return 0; // Shouldn't happen
    }
}