Beispiel #1
0
        private OTTag MakeCodeFriendlyTag(OTTag tag)
        {
            OTTag friendlyTag = new OTTag(tag.GetBytes());

            byte[] tagbuf = friendlyTag.GetBytes();
            for (uint i = 0; i < tagbuf.Length; i++)
            {
                // convert any high order characters to underlines
                if (tagbuf[i] > 127)
                {
                    tagbuf[i] = (byte)'_';
                }
                // convert any control characters to underlines
                if (tagbuf[i] < 32)
                {
                    tagbuf[i] = (byte)'_';
                }
                // convert any spaces to underlines
                if (tagbuf[i] == (byte)' ')
                {
                    tagbuf[i] = (byte)'_';
                }
                // convert any slashes to underlines
                if (tagbuf[i] == (byte)'/')
                {
                    tagbuf[i] = (byte)'_';
                }
            }

            return(friendlyTag);
        }
Beispiel #2
0
 public void OTTagOpConvExplicitTest2d()
 {
     string tag = "";
     OTTag expected = new OTTag("    ");
     OTTag actual;
     actual = ((OTTag)(tag));
     Assert.IsTrue(ArraysMatch(expected.GetBytes(), actual.GetBytes()));
 }
Beispiel #3
0
 public void OTTagOpConvExplicitTest1a()
 {
     byte[] tagBuffer = new byte[4] { 1, 3, 5, 7 };
     OTTag expected = new OTTag(new byte[4] { 1, 3, 5, 7 });
     OTTag actual;
     actual = ((OTTag)(tagBuffer));
     Assert.IsTrue(ArraysMatch(expected.GetBytes(), actual.GetBytes()));
 }
Beispiel #4
0
 public void OTTagGetBytesTest()
 {
     OTTag target = new OTTag(new byte[4] { 1, 3, 5, 7 });
     byte[] expected = new byte[4] { 1, 3, 5, 7 };
     byte[] actual;
     actual = target.GetBytes();
     Assert.IsTrue(ArraysMatch(expected, actual), "Error: unexpected result from OTTag.GetBytes()");
 }
Beispiel #5
0
 public void OTTagOpConvExplicitTest3b()
 {
     uint tagValue = 0x12345678;
     OTTag expected = new OTTag(new byte[4] { 0x12, 0x34, 0x56, 0x78 });
     OTTag actual;
     actual = ((OTTag)(tagValue));
     Assert.IsTrue(ArraysMatch(expected.GetBytes(), actual.GetBytes()));
 }
Beispiel #6
0
 public void OTTagOpConvExplicitTest3a()
 {
     uint tagValue = 0;
     OTTag expected = new OTTag(new byte[4] { 0, 0, 0, 0 });
     OTTag actual;
     actual = ((OTTag)(tagValue));
     Assert.IsTrue(ArraysMatch(expected.GetBytes(), actual.GetBytes()));
 }
Beispiel #7
0
 public void OTTagReadTagTest2()
 {
     byte[] b = new byte[5] { 0, 1, 0, 0, 1 };
     MemoryStream ms = new MemoryStream(new byte[4] { 0, 1, 0, 0 });
     OTTag expected = new OTTag(b);
     OTTag actual = null;
     try
     {
         actual = OTTag.ReadTag(ms);
     }
     catch (Exception)
     {
         // unexpected exception
     }
     Assert.IsTrue(ArraysMatch(expected.GetBytes(), actual.GetBytes()), "Error: unexpected result from OTTag.ReadTag()");
 }
Beispiel #8
0
 public void OTTagConstructorTest6a()
 {
     string tag = "abcd";
     OTTag target = new OTTag(tag);
     Assert.IsTrue(ArraysMatch(new byte[4] { 97, 98, 99, 100 }, target.GetBytes()), "OTTag not as expected: hash = " + target.GetHashCode());
 }
Beispiel #9
0
 public void OTTagConstructorTest2c()
 {
     byte[] tagBuffer = new byte[3] { 1, 3, 5 };
     OTTag target = new OTTag(tagBuffer);
     Assert.IsTrue(ArraysMatch(new byte[4] { 1, 3, 5, 0 }, target.GetBytes()), "OTTag not as expected: hash = " + target.GetHashCode());
 }
Beispiel #10
0
 public void OTTagConstructorTest1()
 {
     OTTag target = new OTTag();
     Assert.IsTrue(ArraysMatch(new byte[4] { 0, 0, 0, 0 }, target.GetBytes()), "OTTag not as expected: hash = " + target.GetHashCode());
 }
Beispiel #11
0
 public void OTTagConstructorTest7()
 {
     uint tagValue = 0x11223344;
     OTTag target = new OTTag(tagValue);
     Assert.IsTrue(ArraysMatch(new byte[4] { 0x11, 0x22, 0x33, 0x44 }, target.GetBytes()), "OTTag not as expected: hash = " + target.GetHashCode());
 }