<commit_before>'use strict';

var assert = require('assert')
  , ase = assert.strictEqual
  , ade = assert.deepEqual
  , BitArray = require('./lib/bitarray')
  , Bitmap = require('./lib/bitmap')
  , utils = require('./lib/utils')
  , redis = require('redis')
  , now = new Date()

describe('Redis BitMap', function() {

  function clean(db, pattern, done) {
    db.keys(pattern, function(err, resp) {
      var args = resp.map(function(x) {
        return x.toString()
      })
      function callback(err, resp) {
        ase(err, null)
        done()
      }
      args.push(callback)
      db.del.apply(db, args)
    })
  }

  describe('BitMap', function() {
    var db = redis.createClient(6379, '127.0.0.1', {return_buffers: true})
      , bm = new Bitmap(db)

    it('should set some bits', function(done) {
      var key = 'bitmap:simple'
        , len = 5
      
      function callback(err, resp) {
        ase(err, null)
        --len || done()
      }
      bm.set(key, 0, 1, callback)<commit_msg>Cleaning db keys before running tests<commit_after>'use strict';

var assert = require('assert')
  , ase = assert.strictEqual
  , ade = assert.deepEqual
  , BitArray = require('./lib/bitarray')
  , Bitmap = require('./lib/bitmap')
  , utils = require('./lib/utils')
  , redis = require('redis')
  , now = new Date()

describe('Redis BitMap', function() {

  function clean(db, pattern, done) {
    db.keys(pattern, function(err, resp) {
      var args = resp.map(function(x) {
        return x.toString()
      })
      function callback(err, resp) {
        ase(err, null)
        done()
      }
      if (!args.length) {
        return done(null)
      }
      args.push(callback)
      db.del.apply(db, args)
    })
  }

  before(function(done) {
    clean(redis.createClient(), 'bitmap:*', done)
  })

  describe('BitMap', function() {
    var db = redis.createClient(6379, '1192.168.127.12', {return_buffers: true})
      , bm = new Bitmap(db)

    it('should set some bits', function(done) {
      var key = 'bitmap:simple'
        , len = 5
      
      function callback(err, resp) {
        ase(err, null)
        --len || done()
      }
      bm.set(key, 0, 1, callback)
{'fraction_non_alphanumeric': 0.16042047531992687, 'fraction_numerical': 0.014625228519195612, 'mean_word_length': 2.404354587869362, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5761253', 'n_tokens_mistral': 759, 'n_tokens_neox': 728, 'n_words': 164}