#ifndef TESTSUPERBLOB_H
#define TESTSUPERBLOB_H

#include "persifs.h"
#include "testutils.h"
#include "superblob.h"
#include "memsuperblob.h"
#include "disksuperblob.h"
#include "memblobindex.h"

struct blobEnt
{
  blockFingerprint fp;
  blockAddress addr;
  str data;
  ihash_entry<blobEnt> hlink;
};

typedef ihash<blockFingerprint, blobEnt, &blobEnt::fp,
              &blobEnt::hlink> blobContents;

void testsDone(ref<superblob> sb, ref<blobContents> c);

void testSuperblob(
  callback<void,ref<superblob>, ref<blobContents> >::ref cb,
  ref<blobContents> c, ref<superblob> sb);

void testSuperblobAdd(
  callback<void,ref<superblob>, ref<blobContents> >::ref cb,
  ref<superblob> sb, ref<blobContents> c, int count);

void testSuperblobAdd_after_put(
  callback<void,ref<superblob>, ref<blobContents> >::ref cb,
  ref<superblob> sb, ref<blobContents> c, int count,
  str data, blockFingerprint fp,
  blockAddress addr);

void testSuperblobAdd_after_putAgain(
  callback<void,ref<superblob>, ref<blobContents> >::ref cb,
  ref<superblob> sb, ref<blobContents> c, int count,
  blockAddress oldAddr, blockFingerprint fp,
  blockAddress addr);

void testSuperblobGet(
  callback<void,ref<superblob>, ref<blobContents> >::ref cb,
  ref<superblob> sb, ref<blobContents> c);

void testSuperblobGetItem(
  callback<void,ref<superblob>, ref<blobContents> >::ref cb,
  ref<superblob> sb, ref<blobContents> c, blobEnt *ent);

void testSuperblobGetItem_after_get(
  callback<void,ref<superblob>, ref<blobContents> >::ref cb,
  ref<superblob> sb, ref<blobContents> c, blobEnt *ent,
  str data, blockAddress addr);

void testSuperblobGetItem_after_getDirect(
  callback<void,ref<superblob>, ref<blobContents> >::ref cb,
  ref<superblob> sb, ref<blobContents> c, blobEnt *ent,
  str data, blockAddress addr);

void testMemSuperblob(
  callback<void,ref<superblob>, ref<blobContents> >::ref cb,
  ref<blobContents> c, ref<memSuperblob> sb);

void testDiskSuperblob(
  callback<void,ref<superblob>, ref<blobContents> >::ref cb,
  ref<blobContents> c, ref<diskSuperblob> sb);

void runDiskSuperblobTests(
  callback<void,ref<superblob>, ref<blobContents> >::ref cb,
  ref<blobContents> realC,
  ptr<blobContents> c, ptr<superblob> sb);

void runDiskSuperblobTests_after_indexCreate(
  callback<void,ref<superblob>, ref<blobContents> >::ref cb,
  ref<blobContents> realC,
  ref<memBlobIndex> ind);

void runDiskSuperblobTestsAgain(
  callback<void,ref<superblob>, ref<blobContents> >::ref cb,
  ref<memBlobIndex> ind, ref<superblob> oldBlob, ref<blobContents> c);

int main(int argc, const char **argv);

#endif // TESTSUPERBLOB_H
