public void CopyResize() { ByteVector a = new ByteVector(TestVector); ByteVector b = ByteVector.FromString("ABCDEFGHIJKL", StringType.UTF8); a.Resize(12); Assert.AreEqual(b, a); Assert.AreEqual( b.ToString(), a.ToString()); Assert.IsFalse(a.Count == TestVector.Count); }
public void CopyResize () { var a = new ByteVector (TestVector); var b = ByteVector.FromString ("ABCDEFGHIJKL", StringType.UTF8); a.Resize (12); Assert.AreEqual (b, a); Assert.AreEqual (b.ToString (), a.ToString ()); Assert.IsFalse (a.Count == TestVector.Count); }
/// <summary> /// Resynchronizes a <see cref="ByteVector" /> object by /// removing the added bytes. /// </summary> /// <param name="data"> /// A <see cref="ByteVector" /> object to resynchronize. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="data" /> is <see langword="null" />. /// </exception> public static void ResynchByteVector (ByteVector data) { if (data == null) { throw new ArgumentNullException (nameof(data)); } int i = 0, j = 0; while (i < data.Count - 1) { if (i != j) { data[j] = data[i]; } i += data[i] == 0xFF && data[i + 1] == 0 ? 2 : 1; j++; } if (i < data.Count) { data[j++] = data[i++]; } data.Resize (j); }
/// <summary> /// Resynchronizes a <see cref="ByteVector" /> object by /// removing the added bytes. /// </summary> /// <param name="data"> /// A <see cref="ByteVector" /> object to resynchronize. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="data" /> is <see langword="null" />. /// </exception> public static void ResynchByteVector (ByteVector data) { if (data == null) { throw new ArgumentNullException ("data"); } int i = 0, j = 0; while (i < data.Count - 1) { if (i != j) { data[j] = data[i]; } i += data[i] == 0xFF && data[i + 1] == 0 ? 2 : 1; j++; } if (i < data.Count) { data[j++] = data[i++]; } data.Resize (j); }