public static bool PerformEncode(string str)
        {
            Debug.WriteLine("Encoding:");
            Debug.WriteLine(str);
            Debug.WriteLine(" -------------------------------- ");
            byte[] bytes = MiniString.Encode(str);
            Debug.WriteLine("Encoded decimal:");
            for (int i = 0; i < bytes.Length; i++)
            {
                byte b = bytes[i];
                if (i != 0)
                {
                    Debug.Write(" ");
                }
                Debug.Write(b);
            }
            Debug.WriteLine("");
            Debug.WriteLine("Encoded binary:");
            Debug.WriteLine(bytes.GetBitString());
            Debug.WriteLine(" -------------------------------- ");
            string decoded = MiniString.Decode(bytes);

            Debug.WriteLine("Decoded again:");
            Debug.WriteLine(decoded);
            return(string.Equals(str, decoded, StringComparison.Ordinal));
        }
Beispiel #2
0
 public void Encode_ABCDEFGIJKLMNOPQRSTUVXYZ()
 {
     Assert.AreEqual(
         MiniString.Encode("ABCDEFGIJKLMNOPQRSTUVXYZ").GetBitString().WriteLine(),
         "0000_1011 1101_0011 0011_1000 0000_1111 0001_0100 0100_1101 0101_0100 0110_0101 0101_1101 0101_1000 1010_0110 0110_1101 0101_1100 1110_0111 0111_1101 1010_0000 0011_1000 1001_0010".WriteLine());
 }
Beispiel #3
0
 public void Encode_WeirdStuff()
 {
     Assert.AreEqual(
         MiniString.Encode("öäüß*abc123$%&/%").GetBitString().WriteLine(),
         "0000_0000 1111_0110 0000_0000 0000_0000 1110_0100 0000_0000 0000_0000 1111_1100 0000_0000 0000_0000 1101_1111 0000_0000 0000_0000 0010_1010 0000_0000 1010_0101 0111_1001 0000_0110 1100_0010 0000_0000 0100_0000 0000_0010 0000_0000 0101_0000 0000_0010 0000_0000 0110_0000 0000_0010 0000_0000 1111_0000 0000_0010 0000_0000 0101_0000 0000_0010 0000_0000".WriteLine());
 }
Beispiel #4
0
 public void Encode_1234567890()
 {
     Assert.AreEqual(
         MiniString.Encode("1234567890").GetBitString().WriteLine(),
         "1000_0001 0011_0000 0001_0000 1000_0101 0111_0001 0010_0000 1000_1001 0000_0010".WriteLine());
 }
Beispiel #5
0
 public void Encode_HELLOWORLD()
 {
     Assert.AreEqual(
         MiniString.Encode("HELLOWORLD").GetBitString().WriteLine(),
         "1101_0010 0110_0011 0101_1001 0101_1001 1001_1000 0111_0001 1001_0110 0000_0011".WriteLine());
 }
Beispiel #6
0
 public void Encode_ABC()
 {
     Assert.AreEqual(
         MiniString.Encode("ABC").GetBitString().WriteLine(),
         "0000_1011 1101_0011 0000_0000".WriteLine());
 }
Beispiel #7
0
 public void Encode_3746()
 {
     Assert.AreEqual(
         MiniString.Encode("3746").GetBitString().WriteLine(),
         "1100_0011 0100_0001 0001_1000".WriteLine());
 }
Beispiel #8
0
 public void Encode_11()
 {
     Assert.AreEqual(
         MiniString.Encode("11").GetBitString().WriteLine(),
         "0100_0001 0000_0000".WriteLine());
 }