Beispiel #1
0
        public void TestSkipValue()
        {
            //PASSED
            initPOFWriter();

            pofwriter.WriteDate(0, new DateTime(2006, 8, 10, 12, 59, 11));
            pofwriter.WriteDateTime(0, new DateTime(2006, 8, 10, 12, 59, 11));
            pofwriter.WriteUniversalDateTime(0, new DateTime(2006, 8, 10, 12, 59, 11, 1));
            pofwriter.WriteCharArray(0, new char[] { 'g', 't', 's' });
            pofwriter.WriteArray(0, new object[] { 'g', "Gor", 55 });
            pofwriter.WriteArray(0, new object[] { new int[] { 1, 2 }, new int[] { 3, 2, 4 } });

            Hashtable ht = new Hashtable();

            ht.Add(1, "t"); ht.Add(2, "g");
            pofwriter.WriteObject(0, ht);

            pofwriter.WriteByte(0, 0x00F0);

            pofwriter.WriteInt32(0, 300);

            initPOFReader();
            PofHelper.SkipValue(reader);
            PofHelper.SkipValue(reader);
            PofHelper.SkipValue(reader);
            PofHelper.SkipValue(reader);
            PofHelper.SkipValue(reader);
            PofHelper.SkipValue(reader);
            PofHelper.SkipValue(reader);
            PofHelper.SkipValue(reader);
            Assert.AreEqual(PofConstants.T_INT32, PofHelper.ReadAsInt32(reader, PofConstants.T_INT32));
            Assert.AreEqual(300, PofHelper.ReadAsInt32(reader, PofConstants.T_INT32));
        }
Beispiel #2
0
        public void TestReadLongArray()
        {
            la      = new LongSortedList();
            la[1L]  = 'a';
            la[3L]  = 'b';
            la[20L] = 'c';
            byte[] bytes = new byte[] { 1, 250, 3 };

            DataWriter      writer    = new DataWriter(stream);
            PofStreamWriter pofWriter = new PofStreamWriter(writer, ctx);

            pofWriter.WriteLongArray(0, la);
            pofWriter.WriteLongArray(0, la, typeof(char));
            pofWriter.WriteLongArray(0, new LongSortedList());
            pofWriter.WriteLongArray(0, null);
            pofWriter.WriteArray(0, bytes);
            pofWriter.WriteArray(0, bytes, typeof(byte));
            pofWriter.WriteArray(0, new byte[0]);

            stream.Position = 0;
            DataReader      reader    = new DataReader(stream);
            PofStreamReader pofReader = new PofStreamReader(reader, ctx);

            ILongArray resLongArray = pofReader.ReadLongArray(0, null);

            Assert.AreEqual(la.Count, resLongArray.Count);
            Assert.AreEqual(la[1], resLongArray[1]);
            Assert.AreEqual(la[3], resLongArray[3]);
            Assert.AreEqual(la[20], resLongArray[20]);

            //uniform sparse array
            resLongArray = pofReader.ReadLongArray(0, null);
            Assert.AreEqual(la.Count, resLongArray.Count);
            Assert.AreEqual(la[1], resLongArray[1]);
            Assert.AreEqual(la[3], resLongArray[3]);
            Assert.AreEqual(la[20], resLongArray[20]);

            resLongArray = pofReader.ReadLongArray(0, null);
            Assert.AreEqual(0, resLongArray.Count);

            resLongArray = pofReader.ReadLongArray(0, null);
            Assert.IsTrue(resLongArray == null);

            resLongArray = pofReader.ReadLongArray(0, null);
            Assert.AreEqual(3, resLongArray.Count);

            resLongArray = pofReader.ReadLongArray(0, null);
            Assert.AreEqual(3, resLongArray.Count);

            resLongArray = pofReader.ReadLongArray(0, new LongSortedList());
            Assert.AreEqual(0, resLongArray.Count);
        }
Beispiel #3
0
        public void TestPofStreamWriteArray()
        {
            initPOFWriter();
            Object[] aobj1    = { "test", "test3", "testPOF1" };
            Object[] aobj2    = { "test", "test1", "testPOF2" };
            var      aobj3    = new Object[0];
            var      objArray = new Object[] { 11, "test", true };

            pofwriter.WriteArray(0, null);
            pofwriter.WriteArray(0, new object[0]);
            pofwriter.WriteArray(0, aobj1);
            pofwriter.WriteArray(0, aobj2);
            pofwriter.WriteArray(0, aobj3);
            pofwriter.WriteArray(0, objArray);


            initPOFReader();
            Assert.AreEqual(null, pofreader.ReadArray(0, null));
            Assert.AreEqual(new Object[0], pofreader.ReadArray(0, new Object[0]));
            Assert.AreEqual(aobj1, pofreader.ReadArray(0, new object[3]));
            Assert.AreEqual(aobj2, pofreader.ReadArray(0, new object[3]));
            Assert.AreEqual(aobj3, pofreader.ReadArray(0, new object[0]));
            Assert.AreEqual(objArray, pofreader.ReadArray(0, new object[3]));
        }