コード例 #1
0
        public void test04()
        {
            sbyte[]         input    = { -1, -128, 0, 127 };
            I1ArraySECSItem secsItem = new I1ArraySECSItem(input);

            Assert.IsTrue(secsItem.getSECSItemFormatCode() == SECSItemFormatCode.I1);
        }
コード例 #2
0
        public void Test02()
        {
            byte []         input    = { (byte)((SECSItemFormatCodeFunctions.GetNumberFromSECSItemFormatCode(SECSItemFormatCode.I1) << 2) | 0x01), 0x04, 255, 128, 0, 127 };
            I1ArraySECSItem secsItem = new I1ArraySECSItem(input, 0, 0);

            Assert.IsTrue(secsItem.GetSECSItemFormatCode() == SECSItemFormatCode.I1);
        }
コード例 #3
0
        public void test02()
        {
            sbyte[]         input    = { -1, -128, 0, 127 };
            I1ArraySECSItem secsItem = new I1ArraySECSItem(input);

            Assert.IsTrue(secsItem.getValue().SequenceEqual(input));
        }
コード例 #4
0
        public void Test06()
        {
            sbyte [] input = { -1, -128, 0, 1, 127 };

            I1ArraySECSItem secsItem = new I1ArraySECSItem(input, SECSItemNumLengthBytes.ONE);

            Assert.IsTrue(secsItem.ToString().Equals("Format:I1 Value: Array"));
        }
コード例 #5
0
        public void Test13()
        {
            byte [] input = { (byte)((SECSItemFormatCodeFunctions.GetNumberFromSECSItemFormatCode(SECSItemFormatCode.I1) << 2) | 0x01), 0x00 };

            I1ArraySECSItem secsItem = new I1ArraySECSItem(input, 0, 0);

            Assert.IsTrue(secsItem.GetValue().Length == 0);
        }
コード例 #6
0
        public void Test09()
        {
            sbyte [] input = { -1, -128, 0, 1, 127 };

            I1ArraySECSItem secsItem = new I1ArraySECSItem(input, SECSItemNumLengthBytes.ONE);

            Assert.IsFalse(secsItem.Equals(null));
        }
コード例 #7
0
        public void Test05()
        {
            sbyte [] input          = { -1, -128, 0, 1, 127 };
            byte []  expectedResult = { (byte)((SECSItemFormatCodeFunctions.GetNumberFromSECSItemFormatCode(SECSItemFormatCode.I1) << 2) | 0x03), 0, 0, 0x05, 255, 128, 0, 1, 127 };

            I1ArraySECSItem secsItem = new I1ArraySECSItem(input, SECSItemNumLengthBytes.THREE);

            Assert.AreEqual(secsItem.ToRawSECSItem(), expectedResult);
        }
コード例 #8
0
        public void test07()
        {
            sbyte[] input          = { -1, -128, 0, 1, 127 };
            byte[]  expectedResult = { (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.I1) << 2) | 0x03), 0, 0, 0x05, 255, 128, 0, 1, 127 };

            I1ArraySECSItem secsItem = new I1ArraySECSItem(input, 3);

            Assert.IsTrue(secsItem.ToRawSECSItem().SequenceEqual(expectedResult));
        }
コード例 #9
0
        public void Test12()
        {
            sbyte [] input1 = { -1, -128, 0, 1, 127 };
            sbyte [] input2 = { -1, -128, 0, 1, 0 };

            I1ArraySECSItem secsItem1 = new I1ArraySECSItem(input1, SECSItemNumLengthBytes.ONE);
            I1ArraySECSItem secsItem2 = new I1ArraySECSItem(input2, SECSItemNumLengthBytes.ONE);

            Assert.IsFalse(secsItem1.Equals(secsItem2));
        }
コード例 #10
0
        public void Test10()
        {
            sbyte [] input = { -1, -128, 0, 1, 127 };

            I1ArraySECSItem secsItem = new I1ArraySECSItem(input, SECSItemNumLengthBytes.ONE);

            Object secsItem2 = new F8SECSItem(2.141592D);

            Assert.IsFalse(secsItem.Equals(secsItem2));
        }
コード例 #11
0
        public void test01()
        {
            byte[]          input    = { (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.I1) << 2) | 0x01), 0x04, 255, 128, 0, 127 };
            I1ArraySECSItem secsItem = new I1ArraySECSItem(input, 0, 0);

            Assert.IsTrue(secsItem.getValue()[0] == -1);
            Assert.IsTrue(secsItem.getValue()[1] == -128);
            Assert.IsTrue(secsItem.getValue()[2] == 0);
            Assert.IsTrue(secsItem.getValue()[3] == 127);
        }
コード例 #12
0
        public void Test01()
        {
            byte []  input  = { (byte)((SECSItemFormatCodeFunctions.GetNumberFromSECSItemFormatCode(SECSItemFormatCode.I1) << 2) | 0x01), 0x04, 255, 128, 0, 127 };
            sbyte [] output = new sbyte[4];
            output [0] = -1;
            output [1] = -128;
            output [2] = 0;
            output [3] = 127;
            I1ArraySECSItem secsItem = new I1ArraySECSItem(input, 0, 0);

            Assert.AreEqual(secsItem.GetValue(), output);
        }
コード例 #13
0
        public void test01()
        {
            byte[] input =
            {
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.L) << 2) | 0x01),    25,

                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.A) << 2) | 0x01),  0x03, 0x41, 0x42, 0x43,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.B) << 2) | 0x01),  0x05,  128,  255,    0,   1, 127,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.BO) << 2) | 0x01), 0x08,    1,    0,    2,   0, 255,   0,   1,   1,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.BO) << 2) | 0x01), 0x01,    5,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.F4) << 2) | 0x01),   20,
                127,                                                                                                       127,  255,  255,
                255,                                                                                                       127,  255,  255,
                255,                                                                                                       128,    0,    0,
                127,                                                                                                       128,    0,    0,
                0,                                                                                                           0,    0,    0,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.F4) << 2) | 0x01), 0x04,  127,  127,  255, 255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.F8) << 2) | 0x01),   40,
                127,                                                                                                      0xEF,  255,  255,  255, 255, 255, 255,
                255,                                                                                                      0XEF,  255,  255,  255, 255, 255, 255,
                255,                                                                                                      0xF0,    0,    0,    0,   0,   0,   0,
                127,                                                                                                      0XF0,    0,    0,    0,   0,   0,   0,
                0,                                                                                                           0,    0,    0,    0,   0,   0,   0,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.F8) << 2) | 0x01), 0x08,  127, 0xEF,  255, 255, 255, 255, 255, 255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.I1) << 2) | 0x01), 0x04,  255,  128,    0, 127,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.I1) << 2) | 0x01), 0x01,  255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.I2) << 2) | 0x01),   10,
                255,                                                                                                       255,
                128,                                                                                                         0,
                0,                                                                                                           0,
                0,                                                                                                           1,
                127,                                                                                                       255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.I2) << 2) | 0x01), 0x02,  255,  255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.I4) << 2) | 0x01),   20,
                255,                                                                                                       255,  255,  255,
                128,                                                                                                         0,    0,    0,
                0,                                                                                                           0,    0,    0,
                0,                                                                                                           0,    0,    1,
                127,                                                                                                       255,  255,  255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.I4) << 2) | 0x01), 0x04,  255,  255,  255, 255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.I8) << 2) | 0x01),   40,
                255,                                                                                                       255,  255,  255,  255, 255, 255, 255,
                128,                                                                                                         0,    0,    0,    0,   0,   0,   0,
                0,                                                                                                           0,    0,    0,    0,   0,   0,   0,
                0,                                                                                                           0,    0,    0,    0,   0,   0,   1,
                127,                                                                                                       255,  255,  255,  255, 255, 255, 255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.I8) << 2) | 0x01), 0x08,  255,  255,  255, 255, 255, 255, 255, 255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.U1) << 2) | 0x01), 0x04,  255,  128,    0, 127,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.U1) << 2) | 0x01), 0x01,  255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.U2) << 2) | 0x01),   10,
                255,                                                                                                       255,
                128,                                                                                                         0,
                0,                                                                                                           0,
                0,                                                                                                           1,
                127,                                                                                                       255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.U2) << 2) | 0x01), 0x02,  255,  255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.U4) << 2) | 0x01),   20,
                255,                                                                                                       255,  255,  255,
                128,                                                                                                         0,    0,    0,
                0,                                                                                                           0,    0,    0,
                0,                                                                                                           0,    0,    1,
                127,                                                                                                       255,  255,  255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.U4) << 2) | 0x01), 0x04,  255,  255,  255, 255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.U8) << 2) | 0x01),   40,
                255,                                                                                                       255,  255,  255,  255, 255, 255, 255,
                128,                                                                                                         0,    0,    0,    0,   0,   0,   0,
                0,                                                                                                           0,    0,    0,    0,   0,   0,   0,
                0,                                                                                                           0,    0,    0,    0,   0,   0,   1,
                127,                                                                                                       255,  255,  255,  255, 255, 255, 255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.U8) << 2) | 0x01), 0x08,  255,  255,  255, 255, 255, 255, 255, 255,

                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.L) << 2) | 0x01),    24,

                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.A) << 2) | 0x01),  0x03, 0x41, 0x42, 0x43,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.B) << 2) | 0x01),  0x05,  128,  255,    0,   1, 127,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.BO) << 2) | 0x01), 0x08,    1,    0,    2,   0, 255,   0,   1,   1,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.BO) << 2) | 0x01), 0x01,    5,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.F4) << 2) | 0x01),   20,
                127,                                                                                                       127,  255,  255,
                255,                                                                                                       127,  255,  255,
                255,                                                                                                       128,    0,    0,
                127,                                                                                                       128,    0,    0,
                0,                                                                                                           0,    0,    0,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.F4) << 2) | 0x01), 0x04,  127,  127,  255, 255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.F8) << 2) | 0x01),   40,
                127,                                                                                                      0xEF,  255,  255,  255, 255, 255, 255,
                255,                                                                                                      0XEF,  255,  255,  255, 255, 255, 255,
                255,                                                                                                      0XF0,    0,    0,    0,   0,   0,   0,
                127,                                                                                                      0XF0,    0,    0,    0,   0,   0,   0,
                0,                                                                                                           0,    0,    0,    0,   0,   0,   0,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.F8) << 2) | 0x01), 0x08,  127, 0xEF,  255, 255, 255, 255, 255, 255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.I1) << 2) | 0x01), 0x04,  255,  128,    0, 127,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.I1) << 2) | 0x01), 0x01,  255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.I2) << 2) | 0x01),   10,
                255,                                                                                                       255,
                128,                                                                                                         0,
                0,                                                                                                           0,
                0,                                                                                                           1,
                127,                                                                                                       255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.I2) << 2) | 0x01), 0x02,  255,  255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.I4) << 2) | 0x01),   20,
                255,                                                                                                       255,  255,  255,
                128,                                                                                                         0,    0,    0,
                0,                                                                                                           0,    0,    0,
                0,                                                                                                           0,    0,    1,
                127,                                                                                                       255,  255,  255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.I4) << 2) | 0x01), 0x04,  255,  255,  255, 255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.I8) << 2) | 0x01),   40,
                255,                                                                                                       255,  255,  255,  255, 255, 255, 255,
                128,                                                                                                         0,    0,    0,    0,   0,   0,   0,
                0,                                                                                                           0,    0,    0,    0,   0,   0,   0,
                0,                                                                                                           0,    0,    0,    0,   0,   0,   1,
                127,                                                                                                       255,  255,  255,  255, 255, 255, 255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.I8) << 2) | 0x01), 0x08,  255,  255,  255, 255, 255, 255, 255, 255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.U1) << 2) | 0x01), 0x04,  255,  128,    0, 127,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.U1) << 2) | 0x01), 0x01,  255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.U2) << 2) | 0x01),   10,
                255,                                                                                                       255,
                128,                                                                                                         0,
                0,                                                                                                           0,
                0,                                                                                                           1,
                127,                                                                                                       255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.U2) << 2) | 0x01), 0x02,  255,  255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.U4) << 2) | 0x01),   20,
                255,                                                                                                       255,  255,  255,
                128,                                                                                                         0,    0,    0,
                0,                                                                                                           0,    0,    0,
                0,                                                                                                           0,    0,    1,
                127,                                                                                                       255,  255,  255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.U4) << 2) | 0x01), 0x04,  255,  255,  255, 255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.U8) << 2) | 0x01),   40,
                255,                                                                                                       255,  255,  255,  255, 255, 255, 255,
                128,                                                                                                         0,    0,    0,    0,   0,   0,   0,
                0,                                                                                                           0,    0,    0,    0,   0,   0,   0,
                0,                                                                                                           0,    0,    0,    0,   0,   0,   1,
                127,                                                                                                       255,  255,  255,  255, 255, 255, 255,
                (byte)((SECSItemFormatCodeFunctions.getNumberFromSECSItemFormatCode(SECSItemFormatCode.U8) << 2) | 0x01), 0x08,  255,  255,  255, 255, 255, 255, 255, 255
            };
            ListSECSItem secsItem = new ListSECSItem(input, 0);

            SECSItem testElement = null;
            LinkedList <SECSItem> expectedData1 = new LinkedList <SECSItem>();
            LinkedList <SECSItem> expectedData2 = new LinkedList <SECSItem>();

            testElement = new ASCIISECSItem("ABC");
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new BinarySECSItem(new byte[] { 128, 255, 0, 1, 127 });
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new BooleanArraySECSItem(new bool[] { true, false, true, false, true, false, true, true });
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new BooleanSECSItem(true);
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new F4ArraySECSItem(new float[] { Single.MaxValue, Single.MinValue, Single.NegativeInfinity, Single.PositiveInfinity, 0.0F });
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new F4SECSItem(Single.MaxValue);
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new F8ArraySECSItem(new double[] { Double.MaxValue, Double.MinValue, Double.NegativeInfinity, Double.PositiveInfinity, 0.0D });
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new F8SECSItem(Double.MaxValue);
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new I1ArraySECSItem(new sbyte[] { -1, -128, 0, 127 });
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new I1SECSItem((sbyte)-1);
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new I2ArraySECSItem(new Int16[] { -1, -32768, 0, 1, 32767 });
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new I2SECSItem(-1);
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new I4ArraySECSItem(new Int32[] { -1, -2147483648, 0, 1, 2147483647 });
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new I4SECSItem(-1);
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new I8ArraySECSItem(new Int64[] { -1, -9223372036854775808L, 0, 1, 9223372036854775807L });
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new I8SECSItem(-1);
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new U1ArraySECSItem(new byte[] { 255, 128, 0, 127 });
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new U1SECSItem((byte)255);
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new U2ArraySECSItem(new UInt16[] { 65535, 32768, 0, 1, 32767 });
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new U2SECSItem(65535);
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new U4ArraySECSItem(new UInt32[] { 0xFFFFFFFF, 2147483648, 0, 1, 2147483647 });
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new U4SECSItem((UInt32)0xFFFFFFFF);
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new U8ArraySECSItem(new UInt64[] { 0xFFFFFFFFFFFFFFFF, 0x8000000000000000, 0x0000000000000000, 0x0000000000000001, 0x7FFFFFFFFFFFFFFF });
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);
            testElement = new U8SECSItem((UInt64)0xFFFFFFFFFFFFFFFF);
            expectedData1.AddLast(testElement);
            expectedData2.AddLast(testElement);

            ListSECSItem innerList = new ListSECSItem(expectedData2);

            expectedData1.AddLast(innerList);

            ListSECSItem expectedResult = new ListSECSItem(expectedData1);

            Console.WriteLine(secsItem.ToString());
            Console.WriteLine("\n/////////////////////////////////////////////////////////////////////////////////////////////////////\n");
            Console.WriteLine(expectedResult.ToString());

            Assert.IsTrue(secsItem.Equals(expectedResult));
        }