コード例 #1
0
 public TestSettings(TestSettings other)
     : base(other)
 {
     this.Seed = other.Seed;
     this.DatLen = other.DatLen;
     this.RunLen = other.RunLen;
 }
コード例 #2
0
ファイル: TestRunner.cs プロジェクト: jolhe006/managed-lzma
        public static void RunUnpackTest(ref TestSettings settings)
        {
            TestSettings r1 = null;
            TestSettings r2 = null;

            using (var nativeManager = new LocalManager())
            {
                Guid id = Guid.NewGuid();

                var nativeResult = nativeManager.BeginInvoke(typeof(TestRunner), "Unpack", id, false, settings);

                using (var managedManager = new InprocManager())
                    r2 = (TestSettings)managedManager.Invoke(typeof(TestRunner), "Unpack", id, true, settings);

                r1 = (TestSettings)nativeManager.EndInvoke(nativeResult);
            }

            if (r1.WrittenSize != r2.WrittenSize)
                throw new InvalidOperationException();

            if (r1.UsedSize != r2.UsedSize)
                throw new InvalidOperationException();

            for (int i = 0; i < r1.WrittenSize; i++)
                if (r1.Dst[i] != r2.Dst[i])
                    throw new InvalidOperationException();

            settings = r1;
        }
コード例 #3
0
        private static TestSettings Pack(Guid id, bool managed, TestSettings s)
        {
            s.Dst = new PZ(new byte[s.DatLen * 2]);
            s.Src = new PZ(new byte[s.DatLen]);

            GenData(s.Seed, s.RunLen, s.Src.Buffer);

            using (var coder = CreateHelper(id, managed, s))
                coder.LzmaCompress(s);

            return s;
        }
コード例 #4
0
ファイル: TestRunner.cs プロジェクト: jolhe006/managed-lzma
 public static void RunTest(TestSettings test)
 {
     try
     {
         RunTestInternal(test);
     }
     finally
     {
         GC.Collect();
         GC.WaitForPendingFinalizers();
     }
 }
コード例 #5
0
        private static TestSettings Unpack(Guid id, bool managed, TestSettings t)
        {
            var s = new TestSettings(t)
            {
                Dst = new PZ(new byte[t.Src.Length]),
                Src = t.Dst,
                Enc = t.Enc,
            };

            using (var coder = CreateHelper(id, managed, s))
                coder.LzmaUncompress(s);

            if (s.WrittenSize != t.Src.Length)
                throw new InvalidOperationException();

            if (s.UsedSize != t.WrittenSize)
                throw new InvalidOperationException();

            return s;
        }
コード例 #6
0
        public static void RunUnpackTest(ref TestSettings settings)
        {
            TestSettings r1 = null;
            TestSettings r2 = null;

            using (var nativeManager = new LocalManager())
            {
                Guid id = Guid.NewGuid();

                var nativeResult = nativeManager.BeginInvoke(typeof(TestRunner), "Unpack", id, false, settings);

                using (var managedManager = new InprocManager())
                    r2 = (TestSettings)managedManager.Invoke(typeof(TestRunner), "Unpack", id, true, settings);

                r1 = (TestSettings)nativeManager.EndInvoke(nativeResult);
            }

            if (r1.WrittenSize != r2.WrittenSize)
            {
                throw new InvalidOperationException();
            }

            if (r1.UsedSize != r2.UsedSize)
            {
                throw new InvalidOperationException();
            }

            for (int i = 0; i < r1.WrittenSize; i++)
            {
                if (r1.Dst[i] != r2.Dst[i])
                {
                    throw new InvalidOperationException();
                }
            }

            settings = r1;
        }
コード例 #7
0
        private static TestSettings Unpack(Guid id, bool managed, TestSettings t)
        {
            var s = new TestSettings(t)
            {
                Dst = new PZ(new byte[t.Src.Length]),
                Src = t.Dst,
                Enc = t.Enc,
            };

            using (var coder = CreateHelper(id, managed, s))
                coder.LzmaUncompress(s);

            if (s.WrittenSize != t.Src.Length)
            {
                throw new InvalidOperationException();
            }

            if (s.UsedSize != t.WrittenSize)
            {
                throw new InvalidOperationException();
            }

            return(s);
        }
コード例 #8
0
        private static void RunTestInternal(TestSettings test)
        {
            RunPackTest(ref test);

            GC.Collect();
            GC.WaitForPendingFinalizers();

            RunUnpackTest(ref test);
        }
コード例 #9
0
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        protected void Test(TestSettings t)
        {
            TestRunner.RunTest(t);
        }
コード例 #10
0
ファイル: Utils.cs プロジェクト: modulexcite/managed-lzma
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        protected void Test(TestSettings t)
        {
            TestRunner.RunTest(t);
        }