public void Overflow() { var exaBytes = Bytes.FromExa(4.12); Assert.AreEqual(4.12 + "EB", exaBytes.ToString()); ExceptionUtility.Expect <OverflowException>(() => Bytes.FromExa(418)); }
public void Null() { var storage = new SingleByteStringStorage(); var sbs = new SingleByteString(); ExceptionUtility.Expect <NullReferenceException>(() => storage.Remove(new SingleByteString())); ExceptionUtility.Expect <NullReferenceException>(() => sbs.ToString()); ExceptionUtility.Expect <NullReferenceException>(() => Assert.AreEqual(0, sbs.Length)); }
public void GetValue() { var lookup = new NamedLookup("One", "Two", "Three", "Five", "six"); using (lookup.SetValues(1, 2.0, 3, 5, "SIXSIXSIX")) { Assert.AreEqual(1, lookup.GetValue <int>("One")); Assert.AreEqual(2.0, lookup.GetValue <double>("Two")); } ExceptionUtility.Expect <NullReferenceException>(() => lookup.GetValue <int>("One")); }
public void Options() { // Small GrowthIncrement forces a re-allocation var storage = new SingleByteStringStorage(new SingleByteStringStorageOptions { GrowthIncrement = 2 }); Assert.IsNotNull(storage?.Options?.Encoding); ExceptionUtility.Expect <ArgumentException>(() => new SingleByteStringStorage(new SingleByteStringStorageOptions(Encoding.UTF8))); SingleByteString sbs = storage.Add("A string that is longer than the GrowthIncrement"); Assert.AreEqual(sbs.Length + 4, storage.TotalUsedBytes); // +4 for header }