public void NibbleAt() { var cursor = new PathCursor(KeyBytes.FromHex("cfed4460"), false); Assert.Equal(0xc, cursor.NibbleAt(0)); Assert.Equal(0xf, cursor.NibbleAt(1)); Assert.Equal(0xe, cursor.NibbleAt(2)); Assert.Throws <ArgumentOutOfRangeException>(() => { cursor.NibbleAt(-1); }); Assert.Throws <ArgumentOutOfRangeException>(() => { cursor.NibbleAt(8); }); cursor = PathCursor.FromNibbles(FromHex("0c0f0e0d040406"), 3); Assert.Equal(0xd, cursor.NibbleAt(0)); Assert.Equal(0x4, cursor.NibbleAt(1)); Assert.Throws <ArgumentOutOfRangeException>(() => { cursor.NibbleAt(-1); }); Assert.Throws <ArgumentOutOfRangeException>(() => { cursor.NibbleAt(5); }); }
public void FromNibbles() { ImmutableArray <byte> nibbles = FromHex("0c0f0e0d04040600"); PathCursor cursor = PathCursor.FromNibbles(nibbles); AssertBytesEqual(FromHex("cfed4460"), cursor.Bytes); Assert.Equal(8, cursor.NibbleLength); Assert.Equal(0, cursor.NibbleOffset); cursor = PathCursor.FromNibbles(nibbles, 1); AssertBytesEqual(FromHex("cfed4460"), cursor.Bytes); Assert.Equal(8, cursor.NibbleLength); Assert.Equal(1, cursor.NibbleOffset); Assert.Throws <ArgumentOutOfRangeException>(() => { _ = PathCursor.FromNibbles(nibbles, -1); }); Assert.Throws <ArgumentOutOfRangeException>(() => { _ = PathCursor.FromNibbles(nibbles, 9); }); }