Ejemplo n.º 1
0
        public void TestBottomUpEncodingPeriodicEncoder()
        {
            SetUp();
            InitSe();

            Assert.AreEqual("[1:8]", se.GetDescription()[0].Get(0));

            SetUp();
            builder.Name("scalar");
            InitSe();

            Assert.AreEqual("scalar", se.GetDescription()[0].Get(0));
            int[] res = se.Encode(3.0);
            Assert.IsTrue(Arrays.AreEqual(new[] { 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 }, res));

            res = se.Encode(3.1);
            Assert.IsTrue(Arrays.AreEqual(new[] { 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 }, res));

            res = se.Encode(3.5);
            Assert.IsTrue(Arrays.AreEqual(new[] { 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }, res));

            res = se.Encode(3.6);
            Assert.IsTrue(Arrays.AreEqual(new[] { 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }, res));

            res = se.Encode(3.7);
            Assert.IsTrue(Arrays.AreEqual(new[] { 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }, res));

            res = se.Encode(4d);
            Assert.IsTrue(Arrays.AreEqual(new[] { 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 }, res));

            res = se.Encode(1d);
            Assert.IsTrue(Arrays.AreEqual(new[] { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, res));

            res = se.Encode(1.5);
            Assert.IsTrue(Arrays.AreEqual(new[] { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, res));

            res = se.Encode(7d);
            Assert.IsTrue(Arrays.AreEqual(new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 }, res));

            res = se.Encode(7.5);
            Assert.IsTrue(Arrays.AreEqual(new[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 }, res));

            Assert.AreEqual(0.5d, se.GetResolution(), 0);
            Assert.AreEqual(1.5d, se.GetRadius(), 0);
        }