Beispiel #1
0
        public void Null()
        {
            var n = IonFloat.NewNull();

            Assert.AreEqual(IonType.Float, n.Type);
            Assert.IsTrue(n.IsNull);
            Assert.ThrowsException <NullValueException>(() => n.Value);
        }
Beispiel #2
0
        public void SimpleValueTest(double value)
        {
            var v = new IonFloat(value);

            Assert.AreEqual(IonType.Float, v.Type());
            Assert.IsFalse(v.IsNull);
            Assert.AreEqual(value, v.DoubleValue);
        }
Beispiel #3
0
        public void SetReadOnly(double?value)
        {
            var v = value == null?IonFloat.NewNull() : new IonFloat(value.Value);

            Assert.IsFalse(v.IsReadOnly);
            v.MakeReadOnly();
            Assert.IsTrue(v.IsReadOnly);
            Assert.ThrowsException <InvalidOperationException>(() => v.AddTypeAnnotation("something"));
            Assert.ThrowsException <InvalidOperationException>(() => v.MakeNull());
        }
Beispiel #4
0
        public void FloatEquality(double value)
        {
            var v      = new IonFloat(value);
            var vd     = new IonFloat(value + 10e-14);
            var v2     = new IonFloat(value);
            var n      = IonFloat.NewNull();
            var n2     = IonFloat.NewNull();
            var intVal = new IonInt(3);

            Assert.IsFalse(v.IsEquivalentTo(n));
            Assert.IsFalse(n.IsEquivalentTo(v));
            Assert.IsTrue(v.IsEquivalentTo(v2));
            Assert.IsFalse(v.IsEquivalentTo(vd));
            Assert.IsFalse(v.IsEquivalentTo(intVal));
            Assert.IsTrue(n.IsEquivalentTo(n2));
        }
Beispiel #5
0
        public override void WriteNull(IonType type)
        {
            IonValue v;

            switch (type)
            {
            case IonType.Null:
                v = new IonNull();
                break;

            case IonType.Bool:
                v = IonBool.NewNull();
                break;

            case IonType.Int:
                v = IonInt.NewNull();
                break;

            case IonType.Float:
                v = IonFloat.NewNull();
                break;

            case IonType.Decimal:
                v = IonDecimal.NewNull();
                break;

            case IonType.Timestamp:
                v = IonTimestamp.NewNull();
                break;

            case IonType.Symbol:
                v = IonSymbol.NewNull();
                break;

            case IonType.String:
                v = new IonString(null);
                break;

            case IonType.Clob:
                v = IonClob.NewNull();
                break;

            case IonType.Blob:
                v = IonBlob.NewNull();
                break;

            case IonType.List:
                v = IonList.NewNull();
                break;

            case IonType.Sexp:
                v = IonSexp.NewNull();
                break;

            case IonType.Struct:
                v = IonStruct.NewNull();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }

            AppendValue(v);
        }
Beispiel #6
0
        public override void WriteFloat(double value)
        {
            var v = new IonFloat(value);

            AppendValue(v);
        }