<commit_before>package com.googlecode.javaewah32;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

/*
 * Copyright 2009-2013, <NAME>, <NAME>, <NAME>, <NAME>, Google Inc., <NAME> and <NAME>
 * Licensed under the Apache License, Version 2.0.
 */
/**
 * Tests for utility class. Sketchy for now.
 * 
 */
@SuppressWarnings("javadoc")
public class IntIteratorOverIteratingRLWTest32 {

        @Test
        // had problems with bitmaps beginning with two consecutive clean runs
        public void testConsecClean() {
                System.out
                        .println("testing int iteration, 2 consec clean runs starting with zeros");
                EWAHCompressedBitmap32 e = new EWAHCompressedBitmap32();
                //for (int i = 0; i < 128; ++i)
                //        e.set(i);
                e.set(128);
                IntIteratorOverIteratingRLW32 ii = new IntIteratorOverIteratingRLW32(
                        e.getIteratingRLW());
                assertTrue(ii.hasNext());
                int ctr = 0;
                while (ii.hasNext()) {
                        ++ctr;
                        //ii.next();
                        System.out.println(ii.next());
                }
                assertEquals(64, ctr);
        }

        @Test
        public void testConsecCleanStartOnes() {
                System.out
                        .println("testing int iteration, 2 consec clean runs starting with ones");
                EWAHCompressedBitmap32 e = new EWAHCompressedBitmap32();
                for (int i = 0; i < 2 * 64; ++i)
                        e.set(i);
                for (int i = 4 * 64; i < 5 * 64; ++i)
                        e.set(i);

                IntIteratorOverIteratingRLW32 ii = new IntIteratorOverIteratingRLW32(
                        e.getIteratingRLW());
                assertTrue(ii.hasNext());
                int ctr = 0;
                while (ii.hasNext()) {
                        ++ctr;
                        ii.next();
                }
                assertEquals(3 * 64, ctr);
        }

        @Test
        public void testStartDirty() {
                System.out.println("testing int iteration, no initial runs");
                EWAHCompressedBitmap32 e = new EWAHCompressedBitmap32();
                for (int i = 1; i < 2 * 64; ++i)
                        e.set(i);
                for (int i = 4 * 64; i < 5 * 64; ++i)
                        e.set(i);

                IntIteratorOverIteratingRLW32 ii = new IntIteratorOverIteratingRLW32(
                        e.getIteratingRLW());
                assertTrue(ii.hasNext());
                int ctr = 0;
                while (ii.hasNext()) {
                        ++ctr;
                        ii.next();
                }
                assertEquals(3 * 64 - 1, ctr);
        }

        @Test
        public void testEmpty() {
                System.out.println("testing int iteration over empty bitmap");
                EWAHCompressedBitmap32 e = new EWAHCompressedBitmap32();

                IntIteratorOverIteratingRLW32 ii = new IntIteratorOverIteratingRLW32(
                        e.getIteratingRLW());
                assertFalse(ii.hasNext());
        }

        @Test
        public void testRandomish() {
                EWAHCompressedBitmap32 e = new EWAHCompressedBitmap32();

                int upperlimit = 100000;
                for (int i = 0; i < upperlimit; ++i) {
                        double probabilityOfOne = i / (double) (upperlimit / 2);
                        if (probabilityOfOne > 1.0)
                                probabilityOfOne = 1.0;
                        if (Math.random() < probabilityOfOne) {
                                e.set(i);
                        }
                }

                IntIteratorOverIteratingRLW32 ii = new IntIteratorOverIteratingRLW32(
                        e.getIteratingRLW());
                int ctr = 0;
                while (ii.hasNext()) {
                        ++ctr;
                        ii.next();
                }

                assertEquals(e.cardinality(), ctr);
                System.out
                        .println("checking int iteration over a var density bitset of size "
                                + e.cardinality());

        }

}
<commit_msg>Putting back the right test<commit_after>package com.googlecode.javaewah32;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

/*
 * Copyright 2009-2013, <NAME>, <NAME>, <NAME>, <NAME>, Google Inc., <NAME> and <NAME>
 * Licensed under the Apache License, Version 2.0.
 */
/**
 * Tests for utility class. Sketchy for now.
 * 
 */
@SuppressWarnings("javadoc")
public class IntIteratorOverIteratingRLWTest32 {

        @Test
        // had problems with bitmaps beginning with two consecutive clean runs
        public void testConsecClean() {
                System.out
                        .println("testing int iteration, 2 consec clean runs starting with zeros");
                EWAHCompressedBitmap32 e = new EWAHCompressedBitmap32();
                for (int i = 0; i < 128; ++i)
                        e.set(i);
                IntIteratorOverIteratingRLW32 ii = new IntIteratorOverIteratingRLW32(
                        e.getIteratingRLW());
                assertTrue(ii.hasNext());
                int ctr = 0;
                while (ii.hasNext()) {
                        ++ctr;
                        ii.next();
                }
                assertEquals(64, ctr);
        }

        @Test
        public void testConsecCleanStartOnes() {
                System.out
                        .println("testing int iteration, 2 consec clean runs starting with ones");
                EWAHCompressedBitmap32 e = new EWAHCompressedBitmap32();
                for (int i = 0; i < 2 * 64; ++i)
                        e.set(i);
                for (int i = 4 * 64; i < 5 * 64; ++i)
                        e.set(i);

                IntIteratorOverIteratingRLW32 ii = new IntIteratorOverIteratingRLW32(
                        e.getIteratingRLW());
                assertTrue(ii.hasNext());
                int ctr = 0;
                while (ii.hasNext()) {
                        ++ctr;
                        ii.next();
                }
                assertEquals(3 * 64, ctr);
        }

        @Test
        public void testStartDirty() {
                System.out.println("testing int iteration, no initial runs");
                EWAHCompressedBitmap32 e = new EWAHCompressedBitmap32();
                for (int i = 1; i < 2 * 64; ++i)
                        e.set(i);
                for (int i = 4 * 64; i < 5 * 64; ++i)
                        e.set(i);

                IntIteratorOverIteratingRLW32 ii = new IntIteratorOverIteratingRLW32(
                        e.getIteratingRLW());
                assertTrue(ii.hasNext());
                int ctr = 0;
                while (ii.hasNext()) {
                        ++ctr;
                        ii.next();
                }
                assertEquals(3 * 64 - 1, ctr);
        }

        @Test
        public void testEmpty() {
                System.out.println("testing int iteration over empty bitmap");
                EWAHCompressedBitmap32 e = new EWAHCompressedBitmap32();

                IntIteratorOverIteratingRLW32 ii = new IntIteratorOverIteratingRLW32(
                        e.getIteratingRLW());
                assertFalse(ii.hasNext());
        }

        @Test
        public void testRandomish() {
                EWAHCompressedBitmap32 e = new EWAHCompressedBitmap32();

                int upperlimit = 100000;
                for (int i = 0; i < upperlimit; ++i) {
                        double probabilityOfOne = i / (double) (upperlimit / 2);
                        if (probabilityOfOne > 1.0)
                                probabilityOfOne = 1.0;
                        if (Math.random() < probabilityOfOne) {
                                e.set(i);
                        }
                }

                IntIteratorOverIteratingRLW32 ii = new IntIteratorOverIteratingRLW32(
                        e.getIteratingRLW());
                int ctr = 0;
                while (ii.hasNext()) {
                        ++ctr;
                        ii.next();
                }

                assertEquals(e.cardinality(), ctr);
                System.out
                        .println("checking int iteration over a var density bitset of size "
                                + e.cardinality());

        }

}

{'fraction_non_alphanumeric': 0.09435897435897436, 'fraction_numerical': 0.024273504273504273, 'mean_word_length': 1.212251071338543, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7592870', 'n_tokens_mistral': 2484, 'n_tokens_neox': 2171, 'n_words': 560}