コード例 #1
0
        public void MergeTest()
        {
            Histogram h1 = new Histogram();
            Histogram h2 = new Histogram();

            h1.Insert(14, -9, 1);
            h1.Insert(222, -9, 2);
            Histogram h1copy = new Histogram(h1);

            h2.Insert(228, -9, 1);
            h2.Insert(8e-9, 1);
            h1.Merge(h2);
            h2.Merge(h1copy);
            Assert.IsTrue(0 == h1.CompareTo(h2));

            HistogramBucketPair[] expected = new HistogramBucketPair[3];
            expected[0].count  = 1;
            expected[0].bucket = new HistogramBucket(true, -9, 80);
            expected[1].count  = 1;
            expected[1].bucket = new HistogramBucket(true, -8, 14);
            expected[2].count  = 3;
            expected[2].bucket = new HistogramBucket(true, -7, 22);

            Assert.AreEqual((ushort)3, h1.BucketCount());
            Assert.AreEqual(expected[0], h1.Bucket(0));
            Assert.AreEqual(expected[1], h1.Bucket(1));
            Assert.AreEqual(expected[2], h1.Bucket(2));
        }