Exemplo n.º 1
0
        //TODO base91 seems to encode differently than 64/85
        // maybe it uses little endian ?
        //[TestMethod] public void Test91_Encode_1()
        //{
        //	TestEncode(OrigText,B91Text,CodecBase91.Self);
        //}
        //[TestMethod] public void Test91_Decode_1()
        //{
        //	TestDecode(B91Text,OrigText,CodecBase91.Self);
        //}

        // [TestMethod]
        // direct conversion doesn't work for now
        public void Test64_to_85_1()
        {
            var    s    = new MemoryStream(Encoding.ASCII.GetBytes(B64Text));
            var    enu  = TuckBytes.ChangeBase(B64Text, CodecBase64.Self, CodecBase85.Self);
            string test = String.Concat(enu);

            //Assert.AreEqual(B85Text.Length,test.Length);
            for (int c = 0; c < B85Text.Length; c++)
            {
                Trace.WriteLine(c + " [" + B85Text[c] + "," + test[c] + "]");
                //Assert.AreEqual(B85Text[c],test[c]);
            }
        }
Exemplo n.º 2
0
        static void TestDecode(string inText, string outText, ICharLookup codec)
        {
            var    s    = new CodecIO(new StringReader(inText));
            var    enu  = TuckBytes.Decode(s, codec);
            string test = String.Concat(enu);

            //Assert.AreEqual(outText.Length,test.Length);
            for (int c = 0; c < outText.Length; c++)
            {
                char t = test[c];
                if (Char.IsControl(t))
                {
                    continue;
                }
                Trace.WriteLine(c + " [" + outText[c] + "," + t + "]");
                Assert.AreEqual(outText[c], test[c]);
            }
        }
Exemplo n.º 3
0
        static void Main1(string[] args)
        {
            Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));

            //var next = TuckBytes.ChangeBase(TestBase.B64Text,CodecBase64.Self,CodecBase256.Self);
            //var next = TuckBytes.ChangeBase(TestBase.OrigText,CodecBase256.Self,CodecBase64.Self);
            //var next = TuckBytes.ChangeBase(TestBase.B85Text,CodecBase85.Self,CodecBase256.Self);
            //var next = TuckBytes.ChangeBase(TestBase.OrigText,CodecBase256.Self,CodecBase85.Self);
            //var next = TuckBytes.ChangeBase("123456789123456789123456789123456789123456789123456789",CodecBase10.Self,CodecBase256.Self);
            //var next = TuckBytes.ChangeBase(TestBase.OrigText,CodecBase256.Self,CodecBase16.Self);
            var next = TuckBytes.ChangeBase(TestBase.OrigText, CodecBase256.Self, CodecBase91.Self);

            foreach (char c in next)
            {
                char p = c;
                if (Char.IsControl(c))
                {
                    p = ' ';
                }
                Console.WriteLine(p + "\t" + ((int)c));
            }
            return;
        }