public void sliceTest() { BysImpl bys = new BysImpl(new NetwImplT(null), new byte[] { 0, 1, 2, 3, 4 }); Bys bys1 = bys.slice(3); Bys bys2 = bys.slice(2, 2); Assert.AreEqual(2, bys1.length); Assert.AreEqual(2, bys2.length); Assert.AreEqual(3 * 256 + 4, bys1.shortv(0)); Assert.AreEqual(2 * 256 + 3, bys2.shortv(0)); try { bys.slice(1000); } catch (Exception) { } try { bys.slice(1000, 1000); } catch (Exception) { } }
public void resetTest() { BysImpl bys = new BysImpl(null, new byte[10]); bys.reset(1, 5); byte[] bys2 = bys.sbys; Assert.AreEqual(5, bys2.Length); bys.reset(0, 0); bys.toBs(); //for cover try { bys.reset(-1, 0); } catch (Exception) { } try { bys.V<Object>(); } catch (Exception) { } }
public void EqualsTest() { Bys bys1 = new BysImpl(null, new byte[] { 1, 2, 3 }); Bys bys2 = new BysImpl(null, new byte[] { 1, 2, 4 }); Bys bys3 = new BysImpl(null, new byte[] { 1, 2, 3, 4 }); Assert.AreEqual(false, bys1.Equals(null)); Assert.AreEqual(false, bys2.Equals(bys1)); Assert.AreEqual(false, bys3.Equals(bys1)); }
public void WrapperTests() { NetwWrapper nw = new NetwWrapper(new NetwImpl_T(new NetwBaseImpl(new BytesStream(1024), 102400))); byte[] tmp; byte[] bys1 = new byte[] { 1, 2, 3, 4 }; byte[] bys2 = new byte[] { 4, 3, 2, 1 }; byte[] bys3 = new byte[] { 1, 2, 3, 4, 4, 3, 2, 1 }; // nw.writem(bys1); tmp = nw.readm(); Assert.AreEqual(true, Util.equal(bys1, tmp)); // nw.writem(bys1, 0, 2); tmp = nw.readm(); Assert.AreEqual(true, Util.equal(new byte[] { 1, 2 }, tmp)); // IList<byte[]> bs = new List<byte[]>(); bs.Add(bys1); bs.Add(bys2); nw.writem(bs); tmp = nw.readm(); Assert.AreEqual(true, Util.equal(bys3, tmp)); // // Bys bs1 = new BysImpl(null, bys1); Bys tm2; // nw.writeM(bs1); tm2 = nw.readM(); Assert.AreEqual(true, tm2.Equals(bs1)); // IList<Bys> bs2 = new List<Bys>(); bs2.Add(bs1); nw.writeM(bs2); tm2 = nw.readM(); Assert.AreEqual(true, tm2.Equals(bs1)); // tmp = new byte[bys1.Length + 5]; nw.writem(bys1); nw.readw(tmp); Assert.AreEqual(true, bys1[0] == tmp[5]); bys1[bys1.Length - 1] = 11; nw.writem(bys1); nw.readw(tmp, 0, tmp.Length); Assert.AreEqual(true, bys1[0] == tmp[5]); }
public void shortvTest() { BysImpl bys = new BysImpl(null, new byte[] { 0, 2, 1, 2 }); Assert.AreEqual(2, bys.shortv(0)); Assert.AreEqual(258, bys.shortv(2)); }