public void testSmallInput()
        {
            SamplinglongPrimitiveIterator t = new SamplinglongPrimitiveIterator(
                countingIterator(1), 0.9999);

            Assert.True(t.MoveNext());
            Assert.AreEqual(0L, t.Current);
            Assert.False(t.MoveNext());
        }
        public void testExactSizeMatch()
        {
            SamplinglongPrimitiveIterator t = new SamplinglongPrimitiveIterator(
                countingIterator(10), 1);

            for (int i = 0; i < 10; i++)
            {
                Assert.True(t.MoveNext());
                Assert.AreEqual(i, (int)t.Current);
            }
            Assert.False(t.MoveNext());
        }
        public void testSample()
        {
            double p  = 0.1;
            int    n  = 1000;
            double sd = Math.Sqrt(n * p * (1.0 - p));

            for (int i = 0; i < 1000; i++)
            {
                SamplinglongPrimitiveIterator t = new SamplinglongPrimitiveIterator(countingIterator(n), p);
                int k = 0;
                while (t.MoveNext())
                {
                    long v = t.Current;
                    k++;
                    Assert.True(v >= 0L);
                    Assert.True(v < 1000L);
                }
                // Should be +/- 5 standard deviations except in about 1 out of 1.7M cases
                Assert.True(k >= 100 - 5 * sd);
                Assert.True(k <= 100 + 5 * sd);
            }
        }