public void Null() { var n = new IonString(null); Assert.AreEqual(IonType.String, n.Type); Assert.IsTrue(n.IsNull); Assert.IsNull(n.StringValue); }
public void SimpleValue(string value, string value2) { var v = new IonString(value); Assert.AreEqual(IonType.String, v.Type()); Assert.IsFalse(v.IsNull); Assert.AreEqual(value, v.StringValue); }
public void SetReadonly(string value) { var v = new IonString(value); Assert.IsFalse(v.IsReadOnly); v.MakeReadOnly(); Assert.IsTrue(v.IsReadOnly); Assert.ThrowsException <InvalidOperationException>(() => v.AddTypeAnnotation("abc")); Assert.ThrowsException <InvalidOperationException>(() => v.MakeNull()); }
public void StringEquality(string value) { var v = new IonString(value); var v2 = new IonString(value); var n = new IonString(null); var ionInt = new IonInt(3); Assert.IsTrue(v.IsEquivalentTo(v2)); if (value is null) { Assert.IsTrue(v.IsEquivalentTo(n)); } else { Assert.IsFalse(v.IsEquivalentTo(n)); } Assert.IsFalse(v.IsEquivalentTo(ionInt)); }
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); }
public override void WriteString(string value) { var v = new IonString(value); AppendValue(v); }