text:
/**
 * Module dependencies.
 */

var start = require('./common');
var mongoose = start.mongoose;
var assert = require('power-assert');
var EventEmitter = require('events').EventEmitter;
var Schema = mongoose.Schema;
var ObjectId = Schema.ObjectId;
var Document = require('../lib/document');
var DocumentObjectId = mongoose.Types.ObjectId;

/**
 * Test Document constructor.
 */

function TestDocument() {
  Document.apply(this, arguments);
}

/**
 * Inherits from Document.
 */

TestDocument.prototype.__proto__ = Document.prototype;

for (var i in EventEmitter.prototype) {
  TestDocument[i] = EventEmitter.prototype[i];
}

/**
 * Set a dummy schema to simulate compilation.
 */

var em = new Schema({title: String, body: String});
em.virtual('works').get(function() {
  return 'em virtual works';
});
var schema = new Schema({
  test: String,
  oids: [ObjectId],
  numbers: [Number],
  nested: {
    age: Number,
    cool: ObjectId,
    deep: {x: String},
    path: String,
    setr: String
  },
  nested2: {
    nested: String,
    yup: {
      nested: Boolean,
      yup: String,
      age: Number
    }
  },
  em: [em],
  date: Date
});
TestDocument.prototype.$__setSchema(schema);

schema.virtual('nested.agePlus2').get(function() {
  return this.nested.age + 2;
});
schema.virtual('nested.setAge').set(function(v) {
  this.nested.age = v;
});
schema.path('nested.path').get(function(v) {
  return (this.nested.age || '') + (v ? v : '');
});
schema.path('nested.setr').set(function(v) {
  return v + ' setter';
});

schema.path('date').set(function(v) {
  // should not have been cast to a Date yet
  assert.equal(typeof v, 'string');
  return v;
});

/**
 * Method subject to hooks. Simply fires the callback once the hooks are
 * executed.
 */

TestDocument.prototype.hooksTest = function(fn) {
  fn(null, arguments);
};

/**
 * Test.
 */
describe('document', function() {
  it('isSelected()', function(done) {
    var doc = new TestDocument();

    doc.init({
      test: 'test',
      numbers: [4, 5, 6, 7],
      nested: {
        age: 5,
        cool: DocumentObjectId.createFromHexString('4c6c2d6240ced95d0e00003c'),
        path: 'my path',
        deep: {x: 'a string'}
      },
      notapath: 'i am not in the schema',
      em: [{title: 'gocars'}]
    });

    assert.ok(doc.isSelected('_id'));
    assert.ok(doc.isSelected('test'));
    assert.ok(doc.isSelected('numbers'));
    assert.ok(doc.isSelected('oids')); // even if no data
    assert.ok(doc.isSelected('nested'));
    assert.ok(doc.isSelected('nested.age'));
    assert.ok(doc.isSelected('nested.cool'));
    assert.ok(doc.isSelected('nested.path'));
    assert.ok(doc.isSelected('nested.deep'));
    assert.ok(doc.isSelected('nested.nope')); // not a path
    assert.ok(doc.isSelected('nested.deep.x'));
    assert.ok(doc.isSelected('nested.deep.x.no'));
    assert.ok(doc.isSelected('nested.deep.y')); // not a path
    assert.ok(doc.isSelected('noway')); // not a path
    assert.ok(doc.isSelected('notapath')); // not a path but in the _doc
    assert.ok(doc.isSelected('em'));
    assert.ok(doc.isSelected('em.title'));
    assert.ok(doc.isSelected('em.body'));
    assert.ok(doc.isSelected('em.nonpath')); // not a path

    var selection = {
      test: 1,
      numbers: 1,
      'nested.deep': 1,
      oids: 1
    };

    doc = new TestDocument(undefined, selection);

    doc.init({
      test: 'test',
      numbers: [4, 5, 6, 7],
      nested: {
        deep: {x: 'a string'}
      }
    });

    assert.ok(doc.isSelected('_id'));
    assert.ok(doc.isSelected('test'));
    assert.ok(doc.isSelected('numbers'));
    assert.ok(doc.isSelected('oids')); // even if no data
    assert.ok(doc.isSelected('nested'));
    assert.ok(!doc.isSelected('nested.age'));
    assert.ok(!doc.isSelected('nested.cool'));
    assert.ok(!doc.isSelected('nested.path'));
    assert.ok(doc.isSelected('nested.deep'));
    assert.ok(!doc.isSelected('nested.nope'));
    assert.ok(doc.isSelected('nested.deep.x'));
    assert.ok(doc.isSelected('nested.deep.x.no'));
    assert.ok(doc.isSelected('nested.deep.y'));
    assert.ok(!doc.isSelected('noway'));
    assert.ok(!doc.isSelected('notapath'));
    assert.ok(!doc.isSelected('em'));
    assert.ok(!doc.isSelected('em.title'));
    assert.ok(!doc.isSelected('em.body'));
    assert.ok(!doc.isSelected('em.nonpath'));

    selection = {
      'em.title': 1
    };

    doc = new TestDocument(undefined, selection);

    doc.init({
      em: [{title: 'one'}]
    });

    assert.ok(doc.isSelected('_id'));
    assert.ok(!doc.isSelected('test'));
    assert.ok(!doc.isSelected('numbers'));
    assert.ok(!doc.isSelected('oids'));
    assert.ok(!doc.isSelected('nested'));
    assert.ok(!doc.isSelected('nested.age'));
    assert.ok(!doc.isSelected('nested.cool'));
    assert.ok(!doc.isSelected('nested.path'));
    assert.ok(!doc.isSelected('nested.deep'));
    assert.ok(!doc.isSelected('nested.nope'));
    assert.ok(!doc.isSelected('nested.deep.x'));
    assert.ok(!doc.isSelected('nested.deep.x.no'));
    assert.ok(!doc.isSelected('nested.deep.y'));
    assert.ok(!doc.isSelected('noway'));
    assert.ok(!doc.isSelected('notapath'));
    assert.ok(doc.isSelected('em'));
    assert.ok(doc.isSelected('em.title'));
    assert.ok(!doc.isSelected('em.body'));
    assert.ok(!doc.isSelected('em.nonpath'));

    selection = {
      em: 0
    };

    doc = new TestDocument(undefined, selection);
    doc.init({
      test: 'test',
      numbers: [4, 5, 6, 7],
      nested: {
        age: 5,
        cool: DocumentObjectId.createFromHexString('4c6c2d6240ced95d0e00003c'),
        path: 'my path',
        deep: {x: 'a string'}
      },
      notapath: 'i am not in the schema'
    });

    assert.ok(doc.isSelected('_id'));
    assert.ok(doc.isSelected('test'));
    assert.ok(doc.isSelected('numbers'));
    assert.ok(doc.isSelected('oids'));
    assert.ok(doc.isSelected('nested'));
    assert.ok(doc.isSelected('nested.age'));
    assert.ok(doc.isSelected('nested.cool'));
    assert.ok(doc.isSelected('nested.path'));
    assert.ok(doc.isSelected('nested.deep'));
    assert.ok(doc.isSelected('nested.nope'));
    assert.ok(doc.isSelected('nested.deep.x'));
    assert.ok(doc.isSelected('nested.deep.x.no'));
    assert.ok(doc.isSelected('nested.deep.y'));
    assert.ok(doc.isSelected('noway'));
    assert.ok(doc.isSelected('notapath'));
    assert.ok(!doc.isSelected('em'));
    assert.ok(!doc.isSelected('em.title'));
    assert.ok(!doc.isSelected('em.body'));
    assert.ok(!doc.isSelected('em.nonpath'));

    selection = {
      _id: 0
    };

    doc = new TestDocument(undefined, selection);
    doc.init({
      test: 'test',
      numbers: [4, 5, 6, 7],
      nested: {
        age: 5,
        cool: DocumentObjectId.createFromHexString('4c6c2d6240ced95d0e00003c'),
        path: 'my path',
        deep: {x: 'a string'}
      },
      notapath: 'i am not in the schema'
    });

    assert.ok(!doc.isSelected('_id'));
    assert.ok(doc.isSelected('nested.deep.x.no'));

    doc = new TestDocument({test: 'boom'});
    assert.ok(doc.isSelected('_id'));
    assert.ok(doc.isSelected('test'));
    assert.ok(doc.isSelected('numbers'));
    assert.ok(doc.isSelected('oids'));
    assert.ok(doc.isSelected('nested'));
    assert.ok(doc.isSelected('nested.age'));
    assert.ok(doc.isSelected('nested.cool'));
    assert.ok(doc.isSelected('nested.path'));
    assert.ok(doc.isSelected('nested.deep'));
    assert.ok(doc.isSelected('nested.nope'));
    assert.ok(doc.isSelected('nested.deep.x'));
    assert.ok(doc.isSelected('nested.deep.x.no'));
    assert.ok(doc.isSelected('nested.deep.y'));
    assert.ok(doc.isSelected('noway'));
    assert.ok(doc.isSelected('notapath'));
    assert.ok(doc.isSelected('em'));
    assert.ok(doc.isSelected('em.title'));
    assert.ok(doc.isSelected('em.body'));
    assert.ok(doc.isSelected('em.nonpath'));

    selection = {
      _id: 1
    };

    doc = new TestDocument(undefined, selection);
    doc.init({_id: 'test'});

    assert.ok(doc.isSelected('_id'));
    assert.ok(!doc.isSelected('test'));

    doc = new TestDocument({test: 'boom'}, true);
    assert.ok(doc.isSelected('_id'));
    assert.ok(doc.isSelected('test'));
    assert.ok(doc.isSelected('numbers'));
    assert.ok(doc.isSelected('oids'));
    assert.ok(doc.isSelected('nested'));
    assert.ok(doc.isSelected('nested.age'));
    assert.ok(doc.isSelected('nested.cool'));
    assert.ok(doc.isSelected('nested.path'));
    assert.ok(doc.isSelected('nested.deep'));
    assert.ok(doc.isSelected('nested.nope'));
    assert.ok(doc.isSelected('nested.deep.x'));
    assert.ok(doc.isSelected('nested.deep.x.no'));
    assert.ok(doc.isSelected('nested.deep.y'));
    assert.ok(doc.isSelected('noway'));
    assert.ok(doc.isSelected('notapath'));
    assert.ok(doc.isSelected('em'));
    assert.ok(doc.isSelected('em.title'));
    assert.ok(doc.isSelected('em.body'));
    assert.ok(doc.isSelected('em.nonpath'));

    selection = {
      _id: 1,
      n: 1
    };

    doc = new TestDocument(undefined, selection);
    doc.init({
      test: 'test',
      numbers: [4, 5, 6, 7],
      nested: {
        age: 5,
        cool: DocumentObjectId.createFromHexString('4c6c2d6240ced95d0e00003c'),
        path: 'my path',
        deep: {x: 'a string'}
      },
      notapath: 'i am not in the schema'
    });

    assert.ok(doc.isSelected('_id'));
    assert.ok(doc.isSelected('n'));
    assert.ok(!doc.isSelected('nested'));
    assert.ok(!doc.isSelected('nested.age'));
    assert.ok(!doc.isSelected('numbers'));

    done();
  });

  it('isDirectSelected (gh-5063)', function(done) {
    var selection = {
      test: 1,
      numbers: 1,
      'nested.deep': 1,
      oids: 1
    };

    var doc = new TestDocument(undefined, selection);

    doc.init({
      test: 'test',
      numbers: [4, 5, 6, 7],
      nested: {
        deep: {x: 'a string'}
      }
    });

    assert.ok(doc.isDirectSelected('nested.deep'));
    assert.ok(!doc.isDirectSelected('nested.cool'));
    assert.ok(!doc.isDirectSelected('nested'));

    done();
  });
});


text:
require 'spree_core'
require 'spree_multi_vendor_hooks'
require 'spree_multi_vendor/configuration'

Spree::MultiVendor::Config = Spree::MultiVendor::Configuration.new(YAML.load_file("config/database.yml")["production"])

module SpreeMultiVendor
  class Engine < Rails::Engine

    config.autoload_paths += %W(#{config.root}/lib)

    def self.activate
      Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
        Rails.env.production? ? require(c) : load(c)
      end
    end

    config.to_prepare &method(:activate).to_proc
  end
end

redpajama_set_name: RedPajamaGithub


text:
New Page

		<form name="pageForm" class="form-horizontal" data-ng-submit="create()" novalidate>
			<fieldset>

					Title

						<input name="title" type="text" data-ng-model="title" id="title" class="form-control" placeholder="Title" required>

          Subtitle

            <input name="subtitle" type="text" data-ng-model="subtitle" id="subtitle" class="form-control" placeholder="Subtitle" required>

          Rank

            <input name="rank" type="text" data-ng-model="rank" id="rank" class="form-control" placeholder="100">

					Body

						<textarea name="body" data-ng-model="body" id="body" class="form-control" cols="30" rows="10" placeholder="Body"></textarea>

					<input type="submit" class="btn btn-default">

			</fieldset>
		</form>


text:
__author__ = 'sushant'

from . import customjson
import requests
import logging, time
from pyappacitive import AppacitiveError

logger = logging.getLogger('pyappacitive')
logger.addHandler(logging.NullHandler())

def put(url, headers, payload):

    start_time = time.time()

    response_from_api = requests.put(url, payload, headers=headers)

    elapsed_time = time.time() - start_time

    response = to_dict(response_from_api)

    if logger.isEnabledFor(logging.DEBUG):
        logger.debug('PUT : %s', url, extra={
            'HEADERS': ','.join([key for key in headers.iterkeys()]),
            "PAYLOAD": payload,
            "RESPONSE": response,
            "TIME_TAKEN": float(elapsed_time)
        })
    status = response.get('status', None)
    if status is not None:
        code = status.get('code', None)
        if code is not None:
            if code != '200':
                raise AppacitiveError(status)
    return response

def post(url, headers, payload):

    start_time = time.time()
    response_from_api = requests.post(url, payload, headers=headers)
    elapsed_time = time.time() - start_time

    response = to_dict(response_from_api)

    if logger.isEnabledFor(logging.DEBUG):
        logger.debug('POST : %s', url, extra={
            'HEADERS': ','.join([key for key in headers.iterkeys()]),
            "PAYLOAD": payload,
            "RESPONSE": response,
            "TIME_TAKEN": str(elapsed_time)
        })
    status = response.get('status', None)
    if status is not None:
        code = status.get('code', None)
        if code is not None:
            if code != '200':
                raise AppacitiveError(status)
    return response

def delete(url, headers):

    start_time = time.time()
    response_from_api = requests.delete(url, headers=headers)
    elapsed_time = time.time() - start_time

    response = to_dict(response_from_api)

    if logger.isEnabledFor(logging.DEBUG):
        logger.debug('DELETE : %s', url, extra={
            'HEADERS': ','.join([key for key in headers.iterkeys()]),
            "RESPONSE": response,
            "TIME_TAKEN": str(elapsed_time)
        })
    status = response.get('status', None)
    if status is not None:
        code = status.get('code', None)
        if code is not None:
            if code != '200':
                raise AppacitiveError(status)
    return response

def get(url, headers):

    start_time = time.time()
    response_from_api = requests.get(url, headers=headers)
    elapsed_time = time.time() - start_time

    response = to_dict(response_from_api)

    if logger.isEnabledFor(logging.DEBUG):
        logger.debug('DELETE : %s', url, extra={
            'HEADERS': ','.join([key for key in headers.iterkeys()]),
            "RESPONSE": response,
            "TIME_TAKEN": str(elapsed_time)
        })
    status = response.get('status', None)
    if status is not None:
        code = status.get('code', None)
        if code is not None:
            if code != '200':
                raise AppacitiveError(status)
    return response

def to_dict(response):
    return customjson.deserialize(response.content.decode('utf-8-sig'))


text:
package com.amazonaws.services.securityhub.model;

import java.io.Serializable;
import javax.annotation.Generated;
import com.amazonaws.protocol.StructuredPojo;
import com.amazonaws.protocol.ProtocolMarshaller;

/**
 *

 * Information about a local secondary index for a DynamoDB table.
 *

 *
 * @see AWS API Documentation
 */
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class AwsDynamoDbTableLocalSecondaryIndex implements Serializable, Cloneable, StructuredPojo {

    /**
     *

     * The ARN of the index.
     *

     */
    private String indexArn;
    /**
     *

     * The name of the index.
     *

     */
    private String indexName;
    /**
     *

     * The complete key schema for the index.
     *

     */
    private java.util.List<AwsDynamoDbTableKeySchema> keySchema;
    /**
     *

     * Attributes that are copied from the table into the index. These are in addition to the primary key attributes and
     * index key attributes, which are automatically projected.
     *

     */
    private AwsDynamoDbTableProjection projection;

    /**
     *

     * The ARN of the index.
     *

     *
     * @param indexArn
     *        The ARN of the index.
     */

    public void setIndexArn(String indexArn) {
        this.indexArn = indexArn;
    }

    /**
     *

     * The ARN of the index.
     *

     *
     * @return The ARN of the index.
     */

    public String getIndexArn() {
        return this.indexArn;
    }

    /**
     *

     * The ARN of the index.
     *

     *
     * @param indexArn
     *        The ARN of the index.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public AwsDynamoDbTableLocalSecondaryIndex withIndexArn(String indexArn) {
        setIndexArn(indexArn);
        return this;
    }

    /**
     *

     * The name of the index.
     *

     *
     * @param indexName
     *        The name of the index.
     */

    public void setIndexName(String indexName) {
        this.indexName = indexName;
    }

    /**
     *

     * The name of the index.
     *

     *
     * @return The name of the index.
     */

    public String getIndexName() {
        return this.indexName;
    }

    /**
     *

     * The name of the index.
     *

     *
     * @param indexName
     *        The name of the index.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public AwsDynamoDbTableLocalSecondaryIndex withIndexName(String indexName) {
        setIndexName(indexName);
        return this;
    }

    /**
     *

     * The complete key schema for the index.
     *

     *
     * @return The complete key schema for the index.
     */

    public java.util.List<AwsDynamoDbTableKeySchema> getKeySchema() {
        return keySchema;
    }

    /**
     *

     * The complete key schema for the index.
     *

     *
     * @param keySchema
     *        The complete key schema for the index.
     */

    public void setKeySchema(java.util.Collection<AwsDynamoDbTableKeySchema> keySchema) {
        if (keySchema == null) {
            this.keySchema = null;
            return;
        }

        this.keySchema = new java.util.ArrayList<AwsDynamoDbTableKeySchema>(keySchema);
    }

    /**
     *

     * The complete key schema for the index.
     *

     *

     * NOTE: This method appends the values to the existing list (if any). Use
     * {@link #setKeySchema(java.util.Collection)} or {@link #withKeySchema(java.util.Collection)} if you want to
     * override the existing values.
     *

     *
     * @param keySchema
     *        The complete key schema for the index.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public AwsDynamoDbTableLocalSecondaryIndex withKeySchema(AwsDynamoDbTableKeySchema... keySchema) {
        if (this.keySchema == null) {
            setKeySchema(new java.util.ArrayList<AwsDynamoDbTableKeySchema>(keySchema.length));
        }
        for (AwsDynamoDbTableKeySchema ele : keySchema) {
            this.keySchema.add(ele);
        }
        return this;
    }

    /**
     *

     * The complete key schema for the index.
     *

     *
     * @param keySchema
     *        The complete key schema for the index.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public AwsDynamoDbTableLocalSecondaryIndex withKeySchema(java.util.Collection<AwsDynamoDbTableKeySchema> keySchema) {
        setKeySchema(keySchema);
        return this;
    }

    /**
     *

     * Attributes that are copied from the table into the index. These are in addition to the primary key attributes and
     * index key attributes, which are automatically projected.
     *

     *
     * @param projection
     *        Attributes that are copied from the table into the index. These are in addition to the primary key
     *        attributes and index key attributes, which are automatically projected.
     */

    public void setProjection(AwsDynamoDbTableProjection projection) {
        this.projection = projection;
    }

    /**
     *

     * Attributes that are copied from the table into the index. These are in addition to the primary key attributes and
     * index key attributes, which are automatically projected.
     *

     *
     * @return Attributes that are copied from the table into the index. These are in addition to the primary key
     *         attributes and index key attributes, which are automatically projected.
     */

    public AwsDynamoDbTableProjection getProjection() {
        return this.projection;
    }

    /**
     *

     * Attributes that are copied from the table into the index. These are in addition to the primary key attributes and
     * index key attributes, which are automatically projected.
     *

     *
     * @param projection
     *        Attributes that are copied from the table into the index. These are in addition to the primary key
     *        attributes and index key attributes, which are automatically projected.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public AwsDynamoDbTableLocalSecondaryIndex withProjection(AwsDynamoDbTableProjection projection) {
        setProjection(projection);
        return this;
    }

    /**
     * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
     * redacted from this string using a placeholder value.
     *
     * @return A string representation of this object.
     *
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getIndexArn() != null)
            sb.append("IndexArn: ").append(getIndexArn()).append(",");
        if (getIndexName() != null)
            sb.append("IndexName: ").append(getIndexName()).append(",");
        if (getKeySchema() != null)
            sb.append("KeySchema: ").append(getKeySchema()).append(",");
        if (getProjection() != null)
            sb.append("Projection: ").append(getProjection());
        sb.append("}");
        return sb.toString();
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;

        if (obj instanceof AwsDynamoDbTableLocalSecondaryIndex == false)
            return false;
        AwsDynamoDbTableLocalSecondaryIndex other = (AwsDynamoDbTableLocalSecondaryIndex) obj;
        if (other.getIndexArn() == null ^ this.getIndexArn() == null)
            return false;
        if (other.getIndexArn() != null && other.getIndexArn().equals(this.getIndexArn()) == false)
            return false;
        if (other.getIndexName() == null ^ this.getIndexName() == null)
            return false;
        if (other.getIndexName() != null && other.getIndexName().equals(this.getIndexName()) == false)
            return false;
        if (other.getKeySchema() == null ^ this.getKeySchema() == null)
            return false;
        if (other.getKeySchema() != null && other.getKeySchema().equals(this.getKeySchema()) == false)
            return false;
        if (other.getProjection() == null ^ this.getProjection() == null)
            return false;
        if (other.getProjection() != null && other.getProjection().equals(this.getProjection()) == false)
            return false;
        return true;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;

        hashCode = prime * hashCode + ((getIndexArn() == null) ? 0 : getIndexArn().hashCode());
        hashCode = prime * hashCode + ((getIndexName() == null) ? 0 : getIndexName().hashCode());
        hashCode = prime * hashCode + ((getKeySchema() == null) ? 0 : getKeySchema().hashCode());
        hashCode = prime * hashCode + ((getProjection() == null) ? 0 : getProjection().hashCode());
        return hashCode;
    }

    @Override
    public AwsDynamoDbTableLocalSecondaryIndex clone() {
        try {
            return (AwsDynamoDbTableLocalSecondaryIndex) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
        }
    }

    @com.amazonaws.annotation.SdkInternalApi
    @Override
    public void marshall(ProtocolMarshaller protocolMarshaller) {
        com.amazonaws.services.securityhub.model.transform.AwsDynamoDbTableLocalSecondaryIndexMarshaller.getInstance().marshall(this, protocolMarshaller);
    }
}


text:
package org.apache.cassandra.cql3.statements;

import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.apache.cassandra.auth.Permission;
import org.apache.cassandra.config.Schema;
import org.apache.cassandra.cql3.CQL3Type;
import org.apache.cassandra.cql3.ColumnIdentifier;
import org.apache.cassandra.cql3.ColumnSpecification;
import org.apache.cassandra.cql3.QueryOptions;
import org.apache.cassandra.cql3.Term;
import org.apache.cassandra.cql3.functions.*;
import org.apache.cassandra.db.marshal.AbstractType;
import org.apache.cassandra.exceptions.InvalidRequestException;
import org.apache.cassandra.exceptions.RequestValidationException;
import org.apache.cassandra.exceptions.UnauthorizedException;
import org.apache.cassandra.service.ClientState;
import org.apache.cassandra.service.MigrationManager;
import org.apache.cassandra.thrift.ThriftValidation;
import org.apache.cassandra.transport.Event;

/**
 * A CREATE AGGREGATE statement parsed from a CQL query.
 */
public final class CreateAggregateStatement extends SchemaAlteringStatement
{
    private final boolean orReplace;
    private final boolean ifNotExists;
    private FunctionName functionName;
    private final String stateFunc;
    private final String finalFunc;
    private final CQL3Type.Raw stateTypeRaw;

    private final List<CQL3Type.Raw> argRawTypes;
    private final Term.Raw ival;

    private UDAggregate udAggregate;
    private boolean replaced;

    public CreateAggregateStatement(FunctionName functionName,
                                    List<CQL3Type.Raw> argRawTypes,
                                    String stateFunc,
                                    CQL3Type.Raw stateType,
                                    String finalFunc,
                                    Term.Raw ival,
                                    boolean orReplace,
                                    boolean ifNotExists)
    {
        this.functionName = functionName;
        this.argRawTypes = argRawTypes;
        this.stateFunc = stateFunc;
        this.finalFunc = finalFunc;
        this.stateTypeRaw = stateType;
        this.ival = ival;
        this.orReplace = orReplace;
        this.ifNotExists = ifNotExists;
    }

    public void prepareKeyspace(ClientState state) throws InvalidRequestException
    {
        if (!functionName.hasKeyspace() && state.getRawKeyspace() != null)
            functionName = new FunctionName(state.getKeyspace(), functionName.name);

        if (!functionName.hasKeyspace())
            throw new InvalidRequestException("Functions must be fully qualified with a keyspace name if a keyspace is not set for the session");

        ThriftValidation.validateKeyspaceNotSystem(functionName.keyspace);
    }

    public void checkAccess(ClientState state) throws UnauthorizedException, InvalidRequestException
    {
        // TODO CASSANDRA-7557 (function DDL permission)

        state.hasKeyspaceAccess(functionName.keyspace, Permission.CREATE);
    }

    public void validate(ClientState state) throws InvalidRequestException
    {
        if (ifNotExists && orReplace)
            throw new InvalidRequestException("Cannot use both 'OR REPLACE' and 'IF NOT EXISTS' directives");

        if (Schema.instance.getKSMetaData(functionName.keyspace) == null)
            throw new InvalidRequestException(String.format("Cannot add aggregate '%s' to non existing keyspace '%s'.", functionName.name, functionName.keyspace));
    }

    public Event.SchemaChange changeEvent()
    {
        return new Event.SchemaChange(replaced ? Event.SchemaChange.Change.UPDATED : Event.SchemaChange.Change.CREATED,
                                      Event.SchemaChange.Target.AGGREGATE,
                                      udAggregate.name().keyspace, udAggregate.name().name, AbstractType.asCQLTypeStringList(udAggregate.argTypes()));
    }

    public boolean announceMigration(boolean isLocalOnly) throws RequestValidationException
    {
        List<AbstractType<?>> argTypes = new ArrayList<>(argRawTypes.size());
        for (CQL3Type.Raw rawType : argRawTypes)
            argTypes.add(rawType.prepare(functionName.keyspace).getType());

        FunctionName stateFuncName = new FunctionName(functionName.keyspace, stateFunc);
        FunctionName finalFuncName;

        ScalarFunction fFinal = null;
        AbstractType<?> stateType = stateTypeRaw.prepare(functionName.keyspace).getType();
        Function f = Functions.find(stateFuncName, stateArguments(stateType, argTypes));
        if (!(f instanceof ScalarFunction))
            throw new InvalidRequestException("State function " + stateFuncSig(stateFuncName, stateTypeRaw, argRawTypes) + " does not exist or is not a scalar function");
        ScalarFunction fState = (ScalarFunction)f;

        AbstractType<?> returnType;
        if (finalFunc != null)
        {
            finalFuncName = new FunctionName(functionName.keyspace, finalFunc);
            f = Functions.find(finalFuncName, Collections.<AbstractType<?>>singletonList(stateType));
            if (!(f instanceof ScalarFunction))
                throw new InvalidRequestException("Final function " + finalFuncName + "(" + stateTypeRaw + ") does not exist");
            fFinal = (ScalarFunction) f;
            returnType = fFinal.returnType();
        }
        else
        {
            returnType = fState.returnType();
            if (!returnType.equals(stateType))
                throw new InvalidRequestException("State function " + stateFuncSig(stateFuncName, stateTypeRaw, argRawTypes) + " return type must be the same as the first argument type (if no final function is used)");
        }

        Function old = Functions.find(functionName, argTypes);
        if (old != null)
        {
            if (ifNotExists)
                return false;
            if (!orReplace)
                throw new InvalidRequestException(String.format("Function %s already exists", old));
            if (!(old instanceof AggregateFunction))
                throw new InvalidRequestException(String.format("Aggregate %s can only replace an aggregate", old));

            // Means we're replacing the function. We still need to validate that 1) it's not a native function and 2) that the return type
            // matches (or that could break existing code badly)
            if (old.isNative())
                throw new InvalidRequestException(String.format("Cannot replace native aggregate %s", old));
            if (!old.returnType().isValueCompatibleWith(returnType))
                throw new InvalidRequestException(String.format("Cannot replace aggregate %s, the new return type %s is not compatible with the return type %s of existing function",
                                                                functionName, returnType.asCQL3Type(), old.returnType().asCQL3Type()));
        }

        ByteBuffer initcond = null;
        if (ival != null)
        {
            ColumnSpecification receiver = new ColumnSpecification(functionName.keyspace, "--dummy--", new ColumnIdentifier("(aggregate_initcond)", true), stateType);
            initcond = ival.prepare(functionName.keyspace, receiver).bindAndGet(QueryOptions.DEFAULT);
        }

        udAggregate = new UDAggregate(functionName, argTypes, returnType,
                                                  fState,
                                                  fFinal,
                                                  initcond);
        replaced = old != null;

        MigrationManager.announceNewAggregate(udAggregate, isLocalOnly);

        return true;
    }

    private String stateFuncSig(FunctionName stateFuncName, CQL3Type.Raw stateTypeRaw, List<CQL3Type.Raw> argRawTypes)
    {
        StringBuilder sb = new StringBuilder();
        sb.append(stateFuncName.toString()).append('(').append(stateTypeRaw);
        for (CQL3Type.Raw argRawType : argRawTypes)
            sb.append(", ").append(argRawType);
        sb.append(')');
        return sb.toString();
    }

    private List<AbstractType<?>> stateArguments(AbstractType<?> stateType, List<AbstractType<?>> argTypes)
    {
        List<AbstractType<?>> r = new ArrayList<>(argTypes.size() + 1);
        r.add(stateType);
        r.addAll(argTypes);
        return r;
    }
}


text:
package com.example.mo.commonutil;

import com.jarvanmo.common.widget.recyclerview.RecyclerViewAdapter;

public class TestAdapter extends RecyclerViewAdapter<Test> {

    @Override
    protected int getItemLayout(int position,Test item) {
            return R.layout.item_rc2;
    }

    @Override
    public void onBind(BaseViewHolder holder, int position, Test item) {
        holder.getBinding().setVariable(com.example.mo.commonutil.BR.v,item);
        holder.getBinding().executePendingBindings();
    }
}


text:
module EventStore
  module Client
    module HTTP
      class Slice
        class Entry
          include Schema::DataStructure

          attribute :event_uri
          attribute :position
        end
      end
    end
  end
end


text:
package org.oep.usermgt.service.base;

import org.oep.usermgt.service.BusinessLocalServiceUtil;

import java.util.Arrays;

/**
 * @author NQMINH
 * @generated
 */
public class BusinessLocalServiceClpInvoker {
	public BusinessLocalServiceClpInvoker() {
		_methodName0 = "addBusiness";

		_methodParameterTypes0 = new String[] { "org.oep.usermgt.model.Business" };

		_methodName1 = "createBusiness";

		_methodParameterTypes1 = new String[] { "long" };

		_methodName2 = "deleteBusiness";

		_methodParameterTypes2 = new String[] { "long" };

		_methodName3 = "deleteBusiness";

		_methodParameterTypes3 = new String[] { "org.oep.usermgt.model.Business" };

		_methodName4 = "dynamicQuery";

		_methodParameterTypes4 = new String[] {  };

		_methodName5 = "dynamicQuery";

		_methodParameterTypes5 = new String[] {
				"com.liferay.portal.kernel.dao.orm.DynamicQuery"
			};

		_methodName6 = "dynamicQuery";

		_methodParameterTypes6 = new String[] {
				"com.liferay.portal.kernel.dao.orm.DynamicQuery", "int", "int"
			};

		_methodName7 = "dynamicQuery";

		_methodParameterTypes7 = new String[] {
				"com.liferay.portal.kernel.dao.orm.DynamicQuery", "int", "int",
				"com.liferay.portal.kernel.util.OrderByComparator"
			};

		_methodName8 = "dynamicQueryCount";

		_methodParameterTypes8 = new String[] {
				"com.liferay.portal.kernel.dao.orm.DynamicQuery"
			};

		_methodName9 = "dynamicQueryCount";

		_methodParameterTypes9 = new String[] {
				"com.liferay.portal.kernel.dao.orm.DynamicQuery",
				"com.liferay.portal.kernel.dao.orm.Projection"
			};

		_methodName10 = "fetchBusiness";

		_methodParameterTypes10 = new String[] { "long" };

		_methodName11 = "getBusiness";

		_methodParameterTypes11 = new String[] { "long" };

		_methodName12 = "getPersistedModel";

		_methodParameterTypes12 = new String[] { "java.io.Serializable" };

		_methodName13 = "getBusinesses";

		_methodParameterTypes13 = new String[] { "int", "int" };

		_methodName14 = "getBusinessesCount";

		_methodParameterTypes14 = new String[] {  };

		_methodName15 = "updateBusiness";

		_methodParameterTypes15 = new String[] { "org.oep.usermgt.model.Business" };

		_methodName84 = "getBeanIdentifier";

		_methodParameterTypes84 = new String[] {  };

		_methodName85 = "setBeanIdentifier";

		_methodParameterTypes85 = new String[] { "java.lang.String" };

		_methodName90 = "addBusiness";

		_methodParameterTypes90 = new String[] {
				"long", "long", "java.lang.String", "java.lang.String",
				"java.lang.String", "java.lang.String", "java.lang.String",
				"java.lang.String", "java.lang.String", "java.lang.String",
				"java.lang.String", "java.lang.String", "java.lang.String",
				"java.lang.String", "java.lang.String", "java.lang.String",
				"java.lang.String", "java.lang.String", "java.lang.String",
				"java.util.Date", "java.lang.String", "java.lang.String",
				"com.liferay.portal.service.ServiceContext"
			};

		_methodName91 = "updateBusiness";

		_methodParameterTypes91 = new String[] {
				"long", "long", "long", "java.lang.String", "java.lang.String",
				"java.lang.String", "java.lang.String", "java.lang.String",
				"java.lang.String", "java.lang.String", "java.lang.String",
				"java.lang.String", "java.lang.String", "java.lang.String",
				"java.lang.String", "java.lang.String", "java.lang.String",
				"java.lang.String", "java.lang.String", "java.lang.String",
				"java.util.Date", "java.lang.String", "java.lang.String",
				"com.liferay.portal.service.ServiceContext"
			};

		_methodName92 = "saveBusiness";

		_methodParameterTypes92 = new String[] {
				"org.oep.usermgt.model.Business",
				"com.liferay.portal.service.ServiceContext"
			};

		_methodName93 = "updateBusinessResources";

		_methodParameterTypes93 = new String[] {
				"org.oep.usermgt.model.Business", "java.lang.String[][]",
				"java.lang.String[][]",
				"com.liferay.portal.service.ServiceContext"
			};

		_methodName94 = "removeBusiness";

		_methodParameterTypes94 = new String[] { "org.oep.usermgt.model.Business" };

		_methodName95 = "removeBusiness";

		_methodParameterTypes95 = new String[] { "long" };

		_methodName96 = "getBusiness";

		_methodParameterTypes96 = new String[] { "long" };

		_methodName97 = "addBusinessResources";

		_methodParameterTypes97 = new String[] {
				"org.oep.usermgt.model.Business", "boolean", "boolean",
				"com.liferay.portal.service.ServiceContext"
			};

		_methodName98 = "addBusinessResources";

		_methodParameterTypes98 = new String[] {
				"org.oep.usermgt.model.Business", "java.lang.String[][]",
				"java.lang.String[][]",
				"com.liferay.portal.service.ServiceContext"
			};

		_methodName99 = "addBusinessResources";

		_methodParameterTypes99 = new String[] {
				"long", "java.lang.String[][]", "java.lang.String[][]",
				"com.liferay.portal.service.ServiceContext"
			};
	}

	public Object invokeMethod(String name, String[] parameterTypes,
		Object[] arguments) throws Throwable {
		if (_methodName0.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes0, parameterTypes)) {
			return BusinessLocalServiceUtil.addBusiness((org.oep.usermgt.model.Business)arguments[0]);
		}

		if (_methodName1.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes1, parameterTypes)) {
			return BusinessLocalServiceUtil.createBusiness(((Long)arguments[0]).longValue());
		}

		if (_methodName2.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes2, parameterTypes)) {
			return BusinessLocalServiceUtil.deleteBusiness(((Long)arguments[0]).longValue());
		}

		if (_methodName3.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes3, parameterTypes)) {
			return BusinessLocalServiceUtil.deleteBusiness((org.oep.usermgt.model.Business)arguments[0]);
		}

		if (_methodName4.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes4, parameterTypes)) {
			return BusinessLocalServiceUtil.dynamicQuery();
		}

		if (_methodName5.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes5, parameterTypes)) {
			return BusinessLocalServiceUtil.dynamicQuery((com.liferay.portal.kernel.dao.orm.DynamicQuery)arguments[0]);
		}

		if (_methodName6.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes6, parameterTypes)) {
			return BusinessLocalServiceUtil.dynamicQuery((com.liferay.portal.kernel.dao.orm.DynamicQuery)arguments[0],
				((Integer)arguments[1]).intValue(),
				((Integer)arguments[2]).intValue());
		}

		if (_methodName7.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes7, parameterTypes)) {
			return BusinessLocalServiceUtil.dynamicQuery((com.liferay.portal.kernel.dao.orm.DynamicQuery)arguments[0],
				((Integer)arguments[1]).intValue(),
				((Integer)arguments[2]).intValue(),
				(com.liferay.portal.kernel.util.OrderByComparator)arguments[3]);
		}

		if (_methodName8.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes8, parameterTypes)) {
			return BusinessLocalServiceUtil.dynamicQueryCount((com.liferay.portal.kernel.dao.orm.DynamicQuery)arguments[0]);
		}

		if (_methodName9.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes9, parameterTypes)) {
			return BusinessLocalServiceUtil.dynamicQueryCount((com.liferay.portal.kernel.dao.orm.DynamicQuery)arguments[0],
				(com.liferay.portal.kernel.dao.orm.Projection)arguments[1]);
		}

		if (_methodName10.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes10, parameterTypes)) {
			return BusinessLocalServiceUtil.fetchBusiness(((Long)arguments[0]).longValue());
		}

		if (_methodName11.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes11, parameterTypes)) {
			return BusinessLocalServiceUtil.getBusiness(((Long)arguments[0]).longValue());
		}

		if (_methodName12.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes12, parameterTypes)) {
			return BusinessLocalServiceUtil.getPersistedModel((java.io.Serializable)arguments[0]);
		}

		if (_methodName13.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes13, parameterTypes)) {
			return BusinessLocalServiceUtil.getBusinesses(((Integer)arguments[0]).intValue(),
				((Integer)arguments[1]).intValue());
		}

		if (_methodName14.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes14, parameterTypes)) {
			return BusinessLocalServiceUtil.getBusinessesCount();
		}

		if (_methodName15.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes15, parameterTypes)) {
			return BusinessLocalServiceUtil.updateBusiness((org.oep.usermgt.model.Business)arguments[0]);
		}

		if (_methodName84.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes84, parameterTypes)) {
			return BusinessLocalServiceUtil.getBeanIdentifier();
		}

		if (_methodName85.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes85, parameterTypes)) {
			BusinessLocalServiceUtil.setBeanIdentifier((java.lang.String)arguments[0]);

			return null;
		}

		if (_methodName90.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes90, parameterTypes)) {
			return BusinessLocalServiceUtil.addBusiness(((Long)arguments[0]).longValue(),
				((Long)arguments[1]).longValue(),
				(java.lang.String)arguments[2], (java.lang.String)arguments[3],
				(java.lang.String)arguments[4], (java.lang.String)arguments[5],
				(java.lang.String)arguments[6], (java.lang.String)arguments[7],
				(java.lang.String)arguments[8], (java.lang.String)arguments[9],
				(java.lang.String)arguments[10],
				(java.lang.String)arguments[11],
				(java.lang.String)arguments[12],
				(java.lang.String)arguments[13],
				(java.lang.String)arguments[14],
				(java.lang.String)arguments[15],
				(java.lang.String)arguments[16],
				(java.lang.String)arguments[17],
				(java.lang.String)arguments[18], (java.util.Date)arguments[19],
				(java.lang.String)arguments[20],
				(java.lang.String)arguments[21],
				(com.liferay.portal.service.ServiceContext)arguments[22]);
		}

		if (_methodName91.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes91, parameterTypes)) {
			return BusinessLocalServiceUtil.updateBusiness(((Long)arguments[0]).longValue(),
				((Long)arguments[1]).longValue(),
				((Long)arguments[2]).longValue(),
				(java.lang.String)arguments[3], (java.lang.String)arguments[4],
				(java.lang.String)arguments[5], (java.lang.String)arguments[6],
				(java.lang.String)arguments[7], (java.lang.String)arguments[8],
				(java.lang.String)arguments[9],
				(java.lang.String)arguments[10],
				(java.lang.String)arguments[11],
				(java.lang.String)arguments[12],
				(java.lang.String)arguments[13],
				(java.lang.String)arguments[14],
				(java.lang.String)arguments[15],
				(java.lang.String)arguments[16],
				(java.lang.String)arguments[17],
				(java.lang.String)arguments[18],
				(java.lang.String)arguments[19], (java.util.Date)arguments[20],
				(java.lang.String)arguments[21],
				(java.lang.String)arguments[22],
				(com.liferay.portal.service.ServiceContext)arguments[23]);
		}

		if (_methodName92.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes92, parameterTypes)) {
			return BusinessLocalServiceUtil.saveBusiness((org.oep.usermgt.model.Business)arguments[0],
				(com.liferay.portal.service.ServiceContext)arguments[1]);
		}

		if (_methodName93.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes93, parameterTypes)) {
			BusinessLocalServiceUtil.updateBusinessResources((org.oep.usermgt.model.Business)arguments[0],
				(java.lang.String[])arguments[1],
				(java.lang.String[])arguments[2],
				(com.liferay.portal.service.ServiceContext)arguments[3]);

			return null;
		}

		if (_methodName94.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes94, parameterTypes)) {
			BusinessLocalServiceUtil.removeBusiness((org.oep.usermgt.model.Business)arguments[0]);

			return null;
		}

		if (_methodName95.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes95, parameterTypes)) {
			BusinessLocalServiceUtil.removeBusiness(((Long)arguments[0]).longValue());

			return null;
		}

		if (_methodName96.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes96, parameterTypes)) {
			return BusinessLocalServiceUtil.getBusiness(((Long)arguments[0]).longValue());
		}

		if (_methodName97.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes97, parameterTypes)) {
			BusinessLocalServiceUtil.addBusinessResources((org.oep.usermgt.model.Business)arguments[0],
				((Boolean)arguments[1]).booleanValue(),
				((Boolean)arguments[2]).booleanValue(),
				(com.liferay.portal.service.ServiceContext)arguments[3]);

			return null;
		}

		if (_methodName98.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes98, parameterTypes)) {
			BusinessLocalServiceUtil.addBusinessResources((org.oep.usermgt.model.Business)arguments[0],
				(java.lang.String[])arguments[1],
				(java.lang.String[])arguments[2],
				(com.liferay.portal.service.ServiceContext)arguments[3]);

			return null;
		}

		if (_methodName99.equals(name) &&
				Arrays.deepEquals(_methodParameterTypes99, parameterTypes)) {
			BusinessLocalServiceUtil.addBusinessResources(((Long)arguments[0]).longValue(),
				(java.lang.String[])arguments[1],
				(java.lang.String[])arguments[2],
				(com.liferay.portal.service.ServiceContext)arguments[3]);

			return null;
		}

		throw new UnsupportedOperationException();
	}

	private String _methodName0;
	private String[] _methodParameterTypes0;
	private String _methodName1;
	private String[] _methodParameterTypes1;
	private String _methodName2;
	private String[] _methodParameterTypes2;
	private String _methodName3;
	private String[] _methodParameterTypes3;
	private String _methodName4;
	private String[] _methodParameterTypes4;
	private String _methodName5;
	private String[] _methodParameterTypes5;
	private String _methodName6;
	private String[] _methodParameterTypes6;
	private String _methodName7;
	private String[] _methodParameterTypes7;
	private String _methodName8;
	private String[] _methodParameterTypes8;
	private String _methodName9;
	private String[] _methodParameterTypes9;
	private String _methodName10;
	private String[] _methodParameterTypes10;
	private String _methodName11;
	private String[] _methodParameterTypes11;
	private String _methodName12;
	private String[] _methodParameterTypes12;
	private String _methodName13;
	private String[] _methodParameterTypes13;
	private String _methodName14;
	private String[] _methodParameterTypes14;
	private String _methodName15;
	private String[] _methodParameterTypes15;
	private String _methodName84;
	private String[] _methodParameterTypes84;
	private String _methodName85;
	private String[] _methodParameterTypes85;
	private String _methodName90;
	private String[] _methodParameterTypes90;
	private String _methodName91;
	private String[] _methodParameterTypes91;
	private String _methodName92;
	private String[] _methodParameterTypes92;
	private String _methodName93;
	private String[] _methodParameterTypes93;
	private String _methodName94;
	private String[] _methodParameterTypes94;
	private String _methodName95;
	private String[] _methodParameterTypes95;
	private String _methodName96;
	private String[] _methodParameterTypes96;
	private String _methodName97;
	private String[] _methodParameterTypes97;
	private String _methodName98;
	private String[] _methodParameterTypes98;
	private String _methodName99;
	private String[] _methodParameterTypes99;
}


text:
using namespace lru;

static inline uint32_t hasher_int(const int &value) {
  return value;
}

static const unsigned cache_size = 1024;

TEST(T_LruCache, Initialize) {
  LruCache<int, std::string> cache(cache_size, -1, hasher_int);
  EXPECT_TRUE  (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());
}

TEST(T_LruCache, Insert) {
  LruCache<int, std::string> cache(cache_size, -1, hasher_int);
  EXPECT_TRUE  (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  cache.Insert(1, "eins");
  cache.Insert(2, "zwei");
  cache.Insert(3, "drei");
  cache.Insert(4, "vier");
  cache.Insert(5, "fünf");
  cache.Insert(6, "sechs");
  cache.Insert(7, "sieben");
  cache.Insert(8, "acht");
  cache.Insert(9, "neun");

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());
}

TEST(T_LruCache, Drop) {
  LruCache<int, std::string> cache(cache_size, -1, hasher_int);
  EXPECT_TRUE  (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  cache.Insert(1, "eins");
  cache.Insert(2, "zwei");
  cache.Insert(3, "drei");
  cache.Insert(4, "vier");
  cache.Insert(5, "fünf");
  cache.Insert(6, "sechs");
  cache.Insert(7, "sieben");
  cache.Insert(8, "acht");
  cache.Insert(9, "neun");

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  cache.Drop();

  EXPECT_TRUE  (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  const std::string neg = "notfound";
  std::string  v(neg);
  bool         found;
  found = cache.Lookup(5, &v); EXPECT_FALSE (found); EXPECT_NE ("fünf",   v);
  found = cache.Lookup(4, &v); EXPECT_FALSE (found); EXPECT_NE ("vier",   v);
  found = cache.Lookup(7, &v); EXPECT_FALSE (found); EXPECT_NE ("sieben", v);
  found = cache.Lookup(3, &v); EXPECT_FALSE (found); EXPECT_NE ("drei",   v);
  found = cache.Lookup(5, &v); EXPECT_FALSE (found); EXPECT_NE ("fünf",   v);
  found = cache.Lookup(9, &v); EXPECT_FALSE (found); EXPECT_NE ("neun",   v);
  found = cache.Lookup(6, &v); EXPECT_FALSE (found); EXPECT_NE ("sechs",  v);
  found = cache.Lookup(8, &v); EXPECT_FALSE (found); EXPECT_NE ("acht",   v);
  found = cache.Lookup(1, &v); EXPECT_FALSE (found); EXPECT_NE ("eins",   v);
  found = cache.Lookup(4, &v); EXPECT_FALSE (found); EXPECT_NE ("vier",   v);
  found = cache.Lookup(2, &v); EXPECT_FALSE (found); EXPECT_NE ("zwei",   v);
  found = cache.Lookup(5, &v); EXPECT_FALSE (found); EXPECT_NE ("fünf",   v);
  found = cache.Lookup(9, &v); EXPECT_FALSE (found); EXPECT_NE ("neun",   v);
  found = cache.Lookup(6, &v); EXPECT_FALSE (found); EXPECT_NE ("sechs",  v);
  found = cache.Lookup(4, &v); EXPECT_FALSE (found); EXPECT_NE ("vier",   v);
  found = cache.Lookup(5, &v); EXPECT_FALSE (found); EXPECT_NE ("fünf",   v);
  found = cache.Lookup(9, &v); EXPECT_FALSE (found); EXPECT_NE ("neun",   v);
  found = cache.Lookup(6, &v); EXPECT_FALSE (found); EXPECT_NE ("sechs",  v);

  EXPECT_TRUE  (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());
}

TEST(T_LruCache, Lookup) {
  LruCache<int, std::string> cache(cache_size, -1, hasher_int);
  EXPECT_TRUE  (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  cache.Insert(1, "eins");
  cache.Insert(2, "zwei");
  cache.Insert(3, "drei");
  cache.Insert(4, "vier");
  cache.Insert(5, "fünf");
  cache.Insert(6, "sechs");
  cache.Insert(7, "sieben");
  cache.Insert(8, "acht");
  cache.Insert(9, "neun");

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  std::string  v;
  bool         found;
  found = cache.Lookup(5, &v); EXPECT_TRUE (found); EXPECT_EQ ("fünf",   v);
  found = cache.Lookup(4, &v); EXPECT_TRUE (found); EXPECT_EQ ("vier",   v);
  found = cache.Lookup(7, &v); EXPECT_TRUE (found); EXPECT_EQ ("sieben", v);
  found = cache.Lookup(3, &v); EXPECT_TRUE (found); EXPECT_EQ ("drei",   v);
  found = cache.Lookup(5, &v); EXPECT_TRUE (found); EXPECT_EQ ("fünf",   v);
  found = cache.Lookup(9, &v); EXPECT_TRUE (found); EXPECT_EQ ("neun",   v);
  found = cache.Lookup(6, &v); EXPECT_TRUE (found); EXPECT_EQ ("sechs",  v);
  found = cache.Lookup(8, &v); EXPECT_TRUE (found); EXPECT_EQ ("acht",   v);
  found = cache.Lookup(1, &v); EXPECT_TRUE (found); EXPECT_EQ ("eins",   v);
  found = cache.Lookup(4, &v); EXPECT_TRUE (found); EXPECT_EQ ("vier",   v);
  found = cache.Lookup(2, &v); EXPECT_TRUE (found); EXPECT_EQ ("zwei",   v);
  found = cache.Lookup(5, &v); EXPECT_TRUE (found); EXPECT_EQ ("fünf",   v);
  found = cache.Lookup(9, &v); EXPECT_TRUE (found); EXPECT_EQ ("neun",   v);
  found = cache.Lookup(6, &v); EXPECT_TRUE (found); EXPECT_EQ ("sechs",  v);
  found = cache.Lookup(4, &v); EXPECT_TRUE (found); EXPECT_EQ ("vier",   v);
  found = cache.Lookup(5, &v); EXPECT_TRUE (found); EXPECT_EQ ("fünf",   v);
  found = cache.Lookup(9, &v); EXPECT_TRUE (found); EXPECT_EQ ("neun",   v);
  found = cache.Lookup(6, &v); EXPECT_TRUE (found); EXPECT_EQ ("sechs",  v);

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  const std::string neg = "notfound";
  v = neg;
  found = cache.Lookup(0, &v);     EXPECT_FALSE (found); EXPECT_EQ (neg, v);
  found = cache.Lookup(-1, &v);    EXPECT_FALSE (found); EXPECT_EQ (neg, v);
  found = cache.Lookup(11, &v);    EXPECT_FALSE (found); EXPECT_EQ (neg, v);
  found = cache.Lookup(123, &v);   EXPECT_FALSE (found); EXPECT_EQ (neg, v);
  found = cache.Lookup(14232, &v); EXPECT_FALSE (found); EXPECT_EQ (neg, v);
  found = cache.Lookup(10, &v);    EXPECT_FALSE (found); EXPECT_EQ (neg, v);
  found = cache.Lookup(23, &v);    EXPECT_FALSE (found); EXPECT_EQ (neg, v);
  found = cache.Lookup(41, &v);    EXPECT_FALSE (found); EXPECT_EQ (neg, v);
  found = cache.Lookup(0, &v);     EXPECT_FALSE (found); EXPECT_EQ (neg, v);
  found = cache.Lookup(16, &v);    EXPECT_FALSE (found); EXPECT_EQ (neg, v);
  found = cache.Lookup(93, &v);    EXPECT_FALSE (found); EXPECT_EQ (neg, v);

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());
}

TEST(T_LruCache, Update) {
  LruCache<int, std::string> cache(cache_size, -1, hasher_int);
  EXPECT_TRUE  (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  bool inserted;
  inserted = cache.Insert(1, "eins");   EXPECT_TRUE (inserted);
  inserted = cache.Insert(2, "zwei");   EXPECT_TRUE (inserted);
  inserted = cache.Insert(3, "drei");   EXPECT_TRUE (inserted);
  inserted = cache.Insert(4, "vier");   EXPECT_TRUE (inserted);
  inserted = cache.Insert(5, "fünf");   EXPECT_TRUE (inserted);
  inserted = cache.Insert(6, "sechs");  EXPECT_TRUE (inserted);
  inserted = cache.Insert(7, "sieben"); EXPECT_TRUE (inserted);
  inserted = cache.Insert(8, "acht");   EXPECT_TRUE (inserted);
  inserted = cache.Insert(9, "neun");   EXPECT_TRUE (inserted);

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  bool found;
  std::string v;

  found = cache.Lookup(1, &v); EXPECT_TRUE (found); EXPECT_EQ ("eins",   v);
  found = cache.Lookup(2, &v); EXPECT_TRUE (found); EXPECT_EQ ("zwei",   v);
  found = cache.Lookup(3, &v); EXPECT_TRUE (found); EXPECT_EQ ("drei",   v);
  found = cache.Lookup(4, &v); EXPECT_TRUE (found); EXPECT_EQ ("vier",   v);
  found = cache.Lookup(5, &v); EXPECT_TRUE (found); EXPECT_EQ ("fünf",   v);
  found = cache.Lookup(6, &v); EXPECT_TRUE (found); EXPECT_EQ ("sechs",  v);
  found = cache.Lookup(7, &v); EXPECT_TRUE (found); EXPECT_EQ ("sieben", v);
  found = cache.Lookup(8, &v); EXPECT_TRUE (found); EXPECT_EQ ("acht",   v);
  found = cache.Lookup(9, &v); EXPECT_TRUE (found); EXPECT_EQ ("neun",   v);

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  inserted = cache.Insert(1, "one");   EXPECT_FALSE (inserted);
  inserted = cache.Insert(2, "two");   EXPECT_FALSE (inserted);
  inserted = cache.Insert(3, "three"); EXPECT_FALSE (inserted);
  inserted = cache.Insert(4, "four");  EXPECT_FALSE (inserted);
  inserted = cache.Insert(5, "five");  EXPECT_FALSE (inserted);
  inserted = cache.Insert(6, "six");   EXPECT_FALSE (inserted);
  inserted = cache.Insert(7, "seven"); EXPECT_FALSE (inserted);
  inserted = cache.Insert(8, "eight"); EXPECT_FALSE (inserted);
  inserted = cache.Insert(9, "nine");  EXPECT_FALSE (inserted);

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  found = cache.Lookup(1, &v); EXPECT_TRUE (found); EXPECT_EQ ("one",   v);
  found = cache.Lookup(2, &v); EXPECT_TRUE (found); EXPECT_EQ ("two",   v);
  found = cache.Lookup(3, &v); EXPECT_TRUE (found); EXPECT_EQ ("three", v);
  found = cache.Lookup(4, &v); EXPECT_TRUE (found); EXPECT_EQ ("four",  v);
  found = cache.Lookup(5, &v); EXPECT_TRUE (found); EXPECT_EQ ("five",  v);
  found = cache.Lookup(6, &v); EXPECT_TRUE (found); EXPECT_EQ ("six",   v);
  found = cache.Lookup(7, &v); EXPECT_TRUE (found); EXPECT_EQ ("seven", v);
  found = cache.Lookup(8, &v); EXPECT_TRUE (found); EXPECT_EQ ("eight", v);
  found = cache.Lookup(9, &v); EXPECT_TRUE (found); EXPECT_EQ ("nine",  v);

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());
}

TEST(T_LruCache, Forget) {
  LruCache<int, std::string> cache(cache_size, -1, hasher_int);
  EXPECT_TRUE  (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  cache.Insert(1, "eins");
  cache.Insert(2, "zwei");
  cache.Insert(3, "drei");
  cache.Insert(4, "vier");
  cache.Insert(5, "fünf");
  cache.Insert(6, "sechs");
  cache.Insert(7, "sieben");
  cache.Insert(8, "acht");
  cache.Insert(9, "neun");

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  const std::string neg = "notfound";
  std::string v(neg);
  bool found;
  found = cache.Forget(3); EXPECT_TRUE (found);
  found = cache.Forget(8); EXPECT_TRUE (found);
  found = cache.Forget(1); EXPECT_TRUE (found);

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  found = cache.Forget(-1);   EXPECT_FALSE (found);
  found = cache.Forget(0);    EXPECT_FALSE (found);
  found = cache.Forget(10);   EXPECT_FALSE (found);
  found = cache.Forget(2000); EXPECT_FALSE (found);
  found = cache.Forget(8);    EXPECT_FALSE (found);
  found = cache.Forget(3);    EXPECT_FALSE (found);
  found = cache.Forget(1);    EXPECT_FALSE (found);

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  found = cache.Lookup(8, &v); EXPECT_FALSE (found); EXPECT_EQ (neg, v);
  found = cache.Lookup(3, &v); EXPECT_FALSE (found); EXPECT_EQ (neg, v);
  found = cache.Lookup(1, &v); EXPECT_FALSE (found); EXPECT_EQ (neg, v);

  found = cache.Lookup(2, &v); EXPECT_TRUE  (found); EXPECT_EQ ("zwei",   v);
  found = cache.Lookup(4, &v); EXPECT_TRUE  (found); EXPECT_EQ ("vier",   v);
  found = cache.Lookup(5, &v); EXPECT_TRUE  (found); EXPECT_EQ ("fünf",   v);
  found = cache.Lookup(6, &v); EXPECT_TRUE  (found); EXPECT_EQ ("sechs",  v);
  found = cache.Lookup(7, &v); EXPECT_TRUE  (found); EXPECT_EQ ("sieben", v);
  found = cache.Lookup(9, &v); EXPECT_TRUE  (found); EXPECT_EQ ("neun",   v);

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  found = cache.Forget(2); EXPECT_TRUE (found);
  found = cache.Forget(4); EXPECT_TRUE (found);
  found = cache.Forget(5); EXPECT_TRUE (found);
  found = cache.Forget(6); EXPECT_TRUE (found);
  found = cache.Forget(7); EXPECT_TRUE (found);
  found = cache.Forget(9); EXPECT_TRUE (found);

  EXPECT_TRUE  (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());
}

TEST(T_LruCache, FillCompletely) {
  LruCache<int, std::string> cache(cache_size, -1, hasher_int);
  EXPECT_TRUE  (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  for (unsigned i = 1; i <= cache_size; ++i) {
    EXPECT_FALSE (cache.IsFull());
    cache.Insert(i, StringifyInt(i));
  }

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_TRUE  (cache.IsFull());

  bool        found;
  std::string v;
  for (unsigned i = 1; i <= cache_size; ++i) {
    EXPECT_TRUE (cache.IsFull());
    found = cache.Lookup(i, &v);
    EXPECT_TRUE (found);
    EXPECT_EQ   (StringifyInt(i), v);
  }

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_TRUE  (cache.IsFull());
}

TEST(T_LruCache, LeastRecentlyUsedReplacement) {
  LruCache<int, std::string> cache(cache_size, -1, hasher_int);
  EXPECT_TRUE  (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  for (unsigned i = 1; i <= cache_size; ++i) {
    EXPECT_FALSE (cache.IsFull());
    cache.Insert(i, StringifyInt(i));
  }

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_TRUE  (cache.IsFull());

  bool        found;
  std::string v;
  const std::string neg = "notfound";

  // lookup a couple of entries to make then "Least Recently Used"
  found = cache.Lookup(2, &v); EXPECT_TRUE (found); EXPECT_EQ ("2", v);
  found = cache.Lookup(4, &v); EXPECT_TRUE (found); EXPECT_EQ ("4", v);
  found = cache.Lookup(5, &v); EXPECT_TRUE (found); EXPECT_EQ ("5", v);
  found = cache.Lookup(6, &v); EXPECT_TRUE (found); EXPECT_EQ ("6", v);
  found = cache.Lookup(7, &v); EXPECT_TRUE (found); EXPECT_EQ ("7", v);
  found = cache.Lookup(9, &v); EXPECT_TRUE (found); EXPECT_EQ ("9", v);

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_TRUE  (cache.IsFull());

  // insert many new entries to kick out "Non-Recently Used" ones
  for (unsigned i = 1; i <= cache_size - 6; ++i) {
    cache.Insert(i + cache_size, StringifyInt(i + cache_size));
  }

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_TRUE  (cache.IsFull());

  // check if the "Least Recently Used" ones are still there
  found = cache.Lookup(2, &v); EXPECT_TRUE (found); EXPECT_EQ ("2", v);
  found = cache.Lookup(4, &v); EXPECT_TRUE (found); EXPECT_EQ ("4", v);
  found = cache.Lookup(5, &v); EXPECT_TRUE (found); EXPECT_EQ ("5", v);
  found = cache.Lookup(6, &v); EXPECT_TRUE (found); EXPECT_EQ ("6", v);
  found = cache.Lookup(7, &v); EXPECT_TRUE (found); EXPECT_EQ ("7", v);
  found = cache.Lookup(9, &v); EXPECT_TRUE (found); EXPECT_EQ ("9", v);

  v = neg;
  found = cache.Lookup(8, &v); EXPECT_FALSE (found); EXPECT_EQ (neg, v);
  found = cache.Lookup(3, &v); EXPECT_FALSE (found); EXPECT_EQ (neg, v);
  found = cache.Lookup(1, &v); EXPECT_FALSE (found); EXPECT_EQ (neg, v);

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_TRUE  (cache.IsFull());

  for (unsigned i = 1; i <= cache_size - 6; ++i) {
    EXPECT_TRUE (cache.IsFull());
    found = cache.Lookup(i + cache_size, &v);
    EXPECT_TRUE (found);
    EXPECT_EQ   (StringifyInt(i + cache_size), v);
  }

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_TRUE  (cache.IsFull());
}

TEST(T_LruCache, PauseAndResume) {
  LruCache<int, std::string> cache(cache_size, -1, hasher_int);
  EXPECT_TRUE  (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  bool inserted;
  inserted = cache.Insert(1, "eins");   EXPECT_TRUE (inserted);
  inserted = cache.Insert(2, "zwei");   EXPECT_TRUE (inserted);
  inserted = cache.Insert(3, "drei");   EXPECT_TRUE (inserted);
  inserted = cache.Insert(4, "vier");   EXPECT_TRUE (inserted);
  inserted = cache.Insert(5, "fünf");   EXPECT_TRUE (inserted);

  cache.Pause();

  inserted = cache.Insert(6, "sechs");  EXPECT_FALSE (inserted);
  inserted = cache.Insert(7, "sieben"); EXPECT_FALSE (inserted);

  cache.Resume();

  inserted = cache.Insert(8, "acht");   EXPECT_TRUE (inserted);
  inserted = cache.Insert(9, "neun");   EXPECT_TRUE (inserted);

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  const std::string neg = "notfound";
  std::string  v;
  bool         found;
  found = cache.Lookup(5, &v); EXPECT_TRUE  (found); EXPECT_EQ ("fünf",   v);
  found = cache.Lookup(4, &v); EXPECT_TRUE  (found); EXPECT_EQ ("vier",   v);
  found = cache.Lookup(7, &v); EXPECT_FALSE (found); EXPECT_NE ("sieben", v);
  found = cache.Lookup(3, &v); EXPECT_TRUE  (found); EXPECT_EQ ("drei",   v);
  found = cache.Lookup(5, &v); EXPECT_TRUE  (found); EXPECT_EQ ("fünf",   v);
  found = cache.Lookup(9, &v); EXPECT_TRUE  (found); EXPECT_EQ ("neun",   v);
  found = cache.Lookup(6, &v); EXPECT_FALSE (found); EXPECT_NE ("sechs",  v);
  found = cache.Lookup(8, &v); EXPECT_TRUE  (found); EXPECT_EQ ("acht",   v);
  found = cache.Lookup(1, &v); EXPECT_TRUE  (found); EXPECT_EQ ("eins",   v);
  found = cache.Lookup(4, &v); EXPECT_TRUE  (found); EXPECT_EQ ("vier",   v);
  found = cache.Lookup(2, &v); EXPECT_TRUE  (found); EXPECT_EQ ("zwei",   v);

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  cache.Pause();

  v = neg;
  found = cache.Lookup(5, &v); EXPECT_FALSE (found); EXPECT_NE ("fünf",   v);
  found = cache.Lookup(4, &v); EXPECT_FALSE (found); EXPECT_NE ("vier",   v);
  found = cache.Lookup(7, &v); EXPECT_FALSE (found); EXPECT_NE ("sieben", v);
  found = cache.Lookup(3, &v); EXPECT_FALSE (found); EXPECT_NE ("drei",   v);
  found = cache.Lookup(5, &v); EXPECT_FALSE (found); EXPECT_NE ("fünf",   v);
  found = cache.Lookup(9, &v); EXPECT_FALSE (found); EXPECT_NE ("neun",   v);
  found = cache.Lookup(6, &v); EXPECT_FALSE (found); EXPECT_NE ("sechs",  v);
  found = cache.Lookup(8, &v); EXPECT_FALSE (found); EXPECT_NE ("acht",   v);
  found = cache.Lookup(1, &v); EXPECT_FALSE (found); EXPECT_NE ("eins",   v);
  found = cache.Lookup(4, &v); EXPECT_FALSE (found); EXPECT_NE ("vier",   v);
  found = cache.Lookup(2, &v); EXPECT_FALSE (found); EXPECT_NE ("zwei",   v);

  cache.Resume();

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  found = cache.Forget(1); EXPECT_TRUE (found);
  found = cache.Forget(8); EXPECT_TRUE (found);

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  cache.Pause();

  found = cache.Forget(9); EXPECT_FALSE (found);
  found = cache.Forget(2); EXPECT_FALSE (found);

  cache.Resume();

  found = cache.Lookup(1, &v); EXPECT_FALSE (found); EXPECT_NE ("eins",   v);
  found = cache.Lookup(2, &v); EXPECT_TRUE  (found); EXPECT_EQ ("zwei",   v);
  found = cache.Lookup(3, &v); EXPECT_TRUE  (found); EXPECT_EQ ("drei",   v);
  found = cache.Lookup(4, &v); EXPECT_TRUE  (found); EXPECT_EQ ("vier",   v);
  found = cache.Lookup(5, &v); EXPECT_TRUE  (found); EXPECT_EQ ("fünf",   v);
  found = cache.Lookup(6, &v); EXPECT_FALSE (found); EXPECT_NE ("sechs",  v);
  found = cache.Lookup(7, &v); EXPECT_FALSE (found); EXPECT_NE ("sieben", v);
  found = cache.Lookup(8, &v); EXPECT_FALSE (found); EXPECT_NE ("acht",   v);
  found = cache.Lookup(9, &v); EXPECT_TRUE  (found); EXPECT_EQ ("neun",   v);

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  cache.Pause();

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  v = neg;
  found = cache.Lookup(1, &v); EXPECT_FALSE (found); EXPECT_NE ("eins",   v);
  found = cache.Lookup(2, &v); EXPECT_FALSE (found); EXPECT_NE ("zwei",   v);
  found = cache.Lookup(3, &v); EXPECT_FALSE (found); EXPECT_NE ("drei",   v);
  found = cache.Lookup(4, &v); EXPECT_FALSE (found); EXPECT_NE ("vier",   v);
  found = cache.Lookup(5, &v); EXPECT_FALSE (found); EXPECT_NE ("fünf",   v);
  found = cache.Lookup(6, &v); EXPECT_FALSE (found); EXPECT_NE ("sechs",  v);
  found = cache.Lookup(7, &v); EXPECT_FALSE (found); EXPECT_NE ("sieben", v);
  found = cache.Lookup(8, &v); EXPECT_FALSE (found); EXPECT_NE ("acht",   v);
  found = cache.Lookup(9, &v); EXPECT_FALSE (found); EXPECT_NE ("neun",   v);

  EXPECT_FALSE (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());

  cache.Pause();
  cache.Drop();

  EXPECT_TRUE  (cache.IsEmpty());
  EXPECT_FALSE (cache.IsFull());
}