public void TestOpNull() { /** * Default Values: * For the type BigInteger and String, if the value is empty (zero byte), the logic should convert them to the default value. * Specifically, * - the default value of bool is false * - the default value of BigInteger is 0 * - the default value of String is "\0" * * To convert the default value back to byte[], the result would be "0x00" rather than null. */ byte[] nullBA = new byte[0]; byte[] zBA = new byte[1] { 0x00 }; //----- Bool ------- bool b1 = false; Assert.AreEqual(b1, Op.Bytes2Bool(nullBA)); Assert.AreEqual(Op.Bool2Bytes(b1), zBA); //----- BigInt ------- BigInteger big = Op.Bytes2BigInt(nullBA); BigInteger bp1 = big + 1; Assert.AreEqual(big, new BigInteger(0)); Assert.AreEqual(bp1, new BigInteger(1)); Assert.AreEqual(Op.BigInt2Bytes(big), zBA); //----- String ------- String str = Op.Bytes2String(nullBA); Assert.AreEqual(str, "\0"); Assert.AreEqual(Op.String2Bytes(str), zBA); }
public static bool SplitTblBool(this byte[] table, int index) => Op.Bytes2Bool(DesegWithIdFromData(table, 0, index));
public static bool SplitSegBool(this byte[] data, int startID) => Op.Bytes2Bool(DesegFromTableFromData(data, startID));