Esempio n. 1
0
    public void Plist_Binary_TEST()
    {
        Xorshift random = new Xorshift(Seed);

        // Trailer
        for (int i = 0; i < 100000; ++i)
        {
            var trailer = new Plist.Trailer();
            trailer.ShortVersion      = (byte)(random.Generate() & 0xFF);
            trailer.OffsetIntSize     = (byte)(random.Generate() & 0xFF);
            trailer.ObjectRefSize     = (byte)(random.Generate() & 0xFF);
            trailer.NumObjects        = (ulong)random.Generate() | ((ulong)random.Generate() << 32);
            trailer.TopObject         = (ulong)random.Generate() | ((ulong)random.Generate() << 32);
            trailer.OffsetTableOffset = (ulong)random.Generate() | ((ulong)random.Generate() << 32);

            var ms = new MemoryStream();
            Plist.WriteTrailerBinary(ms, trailer);
            var read = Plist.ReadTrailerBinary(ms.ToArray());
            Assert.AreEqual(trailer.GetHashCode(), read.GetHashCode());
            Assert.AreEqual(trailer, read);
        }

        for (int i = 0; i < 5000; ++i)
        {
            object value1 = Arbitrary.Plist();
            var    data   = Plist.WriteObjectBinary(value1);
            object value2 = Plist.ReadObjectBinary(data);
            Assert.IsTrue(Plist.EqualObject(value1, value2, 1.0e-9, 1.0e-3), string.Format("serialize error [{0}]", i));
        }
    }
Esempio n. 2
0
    public void Plist_OSXCompatibilityTEST()
    {
        var path = Path.Combine(Application.streamingAssetsPath, "tmp.plist");

        for (int i = 0; i < 100; ++i)
        {
            object value1 = Arbitrary.Plist(3);

            var bytes = Plist.WriteObjectBinary(value1);
            File.WriteAllBytes(path, bytes);

            OSXPlist.ConvertToXml(path);
            OSXPlist.ConvertToBinary(path);

            bytes = File.ReadAllBytes(path);
            File.Delete(path);

            var value2 = Plist.ReadObjectBinary(bytes);

            // because of xml serialization, lost milisecond acculacy...
            Assert.IsTrue(Plist.EqualObject(value1, value2, 1.0e-9, 1.5), string.Format("serialize error [{0}]", i));
        }

        for (int i = 0; i < 100; ++i)
        {
            object value1 = Arbitrary.Plist(3);

            var bytes = Plist.WriteObjectBinary(value1);
            File.WriteAllBytes(path, bytes);

            OSXPlist.ConvertToXml(path);

            bytes = File.ReadAllBytes(path);
            File.Delete(path);

            var value2 = Plist.ReadObjectXML(bytes);

            // because of xml serialization, lost milisecond acculacy...
            Assert.IsTrue(Plist.EqualObject(value1, value2, 1.0e-9, 1.5), string.Format("serialize error [{0}]", i));
        }

        for (int i = 0; i < 100; ++i)
        {
            object value1 = Arbitrary.Plist(3);

            var bytes = Plist.WriteObjectXML(value1);
            File.WriteAllBytes(path, bytes);

            OSXPlist.ConvertToBinary(path);

            bytes = File.ReadAllBytes(path);
            File.Delete(path);

            var value2 = Plist.ReadObjectBinary(bytes);

            // because of xml serialization, lost milisecond acculacy...
            Assert.IsTrue(Plist.EqualObject(value1, value2, 1.0e-9, 1.5), string.Format("serialize error [{0}]", i));
        }
    }
Esempio n. 3
0
    void Start()
    {
        var bytes_binary = Plist.WriteObjectBinary(Arbitrary.Plist());

        File.WriteAllBytes(Path.Combine(Application.streamingAssetsPath, "arbitrary-binary.plist"), bytes_binary);
        var bytes_xml = Plist.WriteObjectXML(Arbitrary.Plist());

        File.WriteAllBytes(Path.Combine(Application.streamingAssetsPath, "arbitrary-xml.plist"), bytes_xml);
    }
Esempio n. 4
0
    public void Plist_XML_TEST()
    {
        Xorshift random = new Xorshift(Seed);

        for (int i = 0; i < 1000; ++i)
        {
            object value1 = Arbitrary.Plist();
            var    data   = Plist.WriteObjectXML(value1);
            object value2 = Plist.ReadObjectXML(data);
            Assert.IsTrue(Plist.EqualObject(value1, value2, 1.0e-9, 1.5), string.Format("serialize error [{0}]", i));
        }
    }