Example #1
0
        public void TestDecodeNoOpen()
        {
            Mpg123 mpg123 = new Mpg123();

            uint done = 0;

            Assert.That(() => mpg123.Decode(null, 0, null, 0, ref done), Throws.TypeOf <Mpg123.ErrorException>());
        }
Example #2
0
        public void TestDecodeNullInputAndOutput()
        {
            Mpg123 mpg123 = new Mpg123();

            mpg123.OpenFeed();

            uint done = 0;

            Assert.That(() => mpg123.Decode(null, 0, null, 0, ref done), Throws.Nothing);
        }
Example #3
0
        public void TestDecodeInconsistentOutputSizeMinor()
        {
            Mpg123 mpg123 = new Mpg123();

            mpg123.OpenFeed();

            byte[] outBuffer = new byte[100];
            uint   done      = 0;

            Assert.That(() => mpg123.Decode(null, 0, outBuffer, 50, ref done), Throws.Nothing);
        }
Example #4
0
        public void TestDecodeInconsistentOutputSizeMajor()
        {
            Mpg123 mpg123 = new Mpg123();

            mpg123.OpenFeed();

            byte[] outBuffer = new byte[100];
            uint   done      = 0;

            Assert.That(() => mpg123.Decode(null, 0, outBuffer, 300, ref done), Throws.TypeOf <ArgumentOutOfRangeException>());
        }
Example #5
0
        public void TestDecodeNeedMore()
        {
            Mpg123 mpg123 = new Mpg123();

            mpg123.OpenFeed();

            byte[] inBuffer = new byte[8];
            uint   done     = 0;

            Assert.That(mpg123.Decode(inBuffer, 8, null, 0, ref done), Is.EqualTo(Mpg123.Errors.NEED_MORE));
        }
Example #6
0
        public void TestDecodeNullOutput()
        {
            Mpg123 mpg123 = new Mpg123();

            mpg123.OpenFeed();

            byte[] inBuffer = new byte[8];
            uint   done     = 0;

            Assert.That(() => mpg123.Decode(inBuffer, 8, null, 0, ref done), Throws.Nothing);
        }
Example #7
0
        public void TestDecodeDoneBytes()
        {
            Mpg123 mpg123 = new Mpg123();

            mpg123.OpenFeed();

            string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string path    = Path.Combine(dirName, "bensound-epic.mp3");

            byte[] inBuffer = File.ReadAllBytes(path);
            uint   done     = 0;

            mpg123.Decode(inBuffer, (uint)inBuffer.Length, null, 0, ref done);

            byte[] outBuffer = new byte[100];

            while (mpg123.Decode(null, 0, outBuffer, 100, ref done) != Mpg123.Errors.NEED_MORE)
            {
                Assert.That(done, Is.EqualTo(100));
            }
        }
Example #8
0
        public void TestDecodeNewFormat()
        {
            Mpg123 mpg123 = new Mpg123();

            mpg123.OpenFeed();

            string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string path    = Path.Combine(dirName, "bensound-epic.mp3");

            byte[] inBuffer = File.ReadAllBytes(path);
            uint   done     = 0;

            Assert.That(mpg123.Decode(inBuffer, (uint)inBuffer.Length, null, 0, ref done), Is.EqualTo(Mpg123.Errors.NEW_FORMAT));
        }