/*
../compiler/cpp/thrift -cpp -dense DebugProtoTest.thrift
../compiler/cpp/thrift -cpp -dense OptionalRequiredTest.thrift
g++ -Wall -g -I../lib/cpp/src -I/usr/local/include/boost-1_33_1 \
  gen-cpp/OptionalRequiredTest_types.cpp \
  gen-cpp/DebugProtoTest_types.cpp \
  DenseProtoTest.cpp ../lib/cpp/.libs/libthrift.a -o DenseProtoTest
./DenseProtoTest
*/

// I do this to reach into the guts of TDenseProtocol.  Sorry.
#define private public
#define inline

#undef NDEBUG
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <cmath>
#include <string>
#include "gen-cpp/DebugProtoTest_types.h"
#include "gen-cpp/OptionalRequiredTest_types.h"
#include <protocol/TDenseProtocol.h>
#include <transport/TBufferTransports.h>


// Can't use memcmp here.  GCC is too smart.
bool my_memeq(const char* str1, const char* str2, int len) {
  for (int i = 0; i < len; i++) {
    if (str1[i] != str2[i]) {
      return false;
    }
  }
  return true;
}


int main() {
  using std::string;
  using std::cout;
  using std::endl;
  using boost::shared_ptr;
  using namespace thrift::test::debug;
  using namespace facebook::thrift::transport;
  using namespace facebook::thrift::protocol;


  OneOfEach ooe;
  ooe.im_true   = true;
  ooe.im_false  = false;
  ooe.a_bite    = 0xd6;
  ooe.integer16 = 27000;
  ooe.integer32 = 1<<24;
  ooe.integer64 = (uint64_t)6000 * 1000 * 1000;
  ooe.double_precision = M_PI;
  ooe.some_characters  = "Debug THIS!";
  ooe.zomg_unicode     = "\xd7\n\a\t";

  //cout << facebook::thrift::ThriftDebugString(ooe) << endl << endl;


  Nesting n;
  n.my_ooe = ooe;
  n.my_ooe.integer16 = 16;
  n.my_ooe.integer32 = 32;
  n.my_ooe.integer64 = 64;
  n.my_ooe.double_precision = (std::sqrt(5)+1)/2;
  n.my_ooe.some_characters  = ":R (me going \"rrrr\")";
  n.my_ooe.zomg_unicode     = "\xd3\x80\xe2\x85\xae\xce\x9d\x20"
                              "\xd0\x9d\xce\xbf\xe2\x85\xbf\xd0\xbe\xc9\xa1\xd0\xb3\xd0\xb0\xcf\x81\xe2\x84\x8e"
                              "\x20\xce\x91\x74\x74\xce\xb1\xe2\x85\xbd\xce\xba\xc7\x83\xe2\x80\xbc";
  n.my_bonk.type    = 31337;
  n.my_bonk.message = "I am a bonk... xor!";

  //cout << facebook::thrift::ThriftDebugString(n) << endl << endl;


  HolyMoley hm;

  hm.big.push_back(ooe);
  hm.big.push_back(n.my_ooe);
  hm.big[0].a_bite = 0x22;
  hm.big[1].a_bite = 0x33;

  std::vector<std::string> stage1;
  stage1.push_back("and a one");
  stage1.push_back("and a two");
  hm.contain.insert(stage1);
  stage1.clear();
  stage1.push_back("then a one, two");
  stage1.push_back("three!");
  stage1.push_back("FOUR!!");
  hm.contain.insert(stage1);
  stage1.clear();
  hm.contain.insert(stage1);

  std::vector<Bonk> stage2;
  hm.bonks["nothing"] = stage2;
  stage2.resize(stage2.size()+1);
  stage2.back().type = 1;
  stage2.back().message = "Wait.";
  stage2.resize(stage2.size()+1);
  stage2.back().type = 2;
  stage2.back().message = "What?";
  hm.bonks["something"] = stage2;
  stage2.clear();
  stage2.resize(stage2.size()+1);
  stage2.back().type = 3;
  stage2.back().message = "quoth";
  stage2.resize(stage2.size()+1);
  stage2.back().type = 4;
  stage2.back().message = "the raven";
  stage2.resize(stage2.size()+1);
  stage2.back().type = 5;
  stage2.back().message = "nevermore";
  hm.bonks["poe"] = stage2;

  //cout << facebook::thrift::ThriftDebugString(hm) << endl << endl;

  shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer());
  shared_ptr<TDenseProtocol> proto(new TDenseProtocol(buffer));
  proto->setTypeSpec(HolyMoley::local_reflection);

  hm.write(proto.get());
  HolyMoley hm2;
  hm2.read(proto.get());

  assert(hm == hm2);


  // Let's test out the variable-length ints, shall we?
  uint64_t vlq;
  #define checkout(i, c) { \
    buffer->resetBuffer(); \
    proto->vlqWrite(i); \
    proto->getTransport()->flush(); \
    assert(my_memeq(buffer->getBufferAsString().data(), c, sizeof(c)-1)); \
    proto->vlqRead(vlq); \
    assert(vlq == i); \
  }

  checkout(0x00000000, "\x00");
  checkout(0x00000040, "\x40");
  checkout(0x0000007F, "\x7F");
  checkout(0x00000080, "\x81\x00");
  checkout(0x00002000, "\xC0\x00");
  checkout(0x00003FFF, "\xFF\x7F");
  checkout(0x00004000, "\x81\x80\x00");
  checkout(0x00100000, "\xC0\x80\x00");
  checkout(0x001FFFFF, "\xFF\xFF\x7F");
  checkout(0x00200000, "\x81\x80\x80\x00");
  checkout(0x08000000, "\xC0\x80\x80\x00");
  checkout(0x0FFFFFFF, "\xFF\xFF\xFF\x7F");
  checkout(0x10000000, "\x81\x80\x80\x80\x00");
  checkout(0x20000000, "\x82\x80\x80\x80\x00");
  checkout(0x1FFFFFFF, "\x81\xFF\xFF\xFF\x7F");
  checkout(0xFFFFFFFF, "\x8F\xFF\xFF\xFF\x7F");

  checkout(0x0000000100000000ull, "\x90\x80\x80\x80\x00");
  checkout(0x0000000200000000ull, "\xA0\x80\x80\x80\x00");
  checkout(0x0000000300000000ull, "\xB0\x80\x80\x80\x00");
  checkout(0x0000000700000000ull, "\xF0\x80\x80\x80\x00");
  checkout(0x00000007F0000000ull, "\xFF\x80\x80\x80\x00");
  checkout(0x00000007FFFFFFFFull, "\xFF\xFF\xFF\xFF\x7F");
  checkout(0x0000000800000000ull, "\x81\x80\x80\x80\x80\x00");
  checkout(0x1FFFFFFFFFFFFFFFull, "\x9F\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x7F");
  checkout(0x7FFFFFFFFFFFFFFFull, "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x7F");
  checkout(0xFFFFFFFFFFFFFFFFull, "\x81\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x7F");

  // Test out the slow path with a TBufferedTransport.
  shared_ptr<TBufferedTransport> buff_trans(new TBufferedTransport(buffer, 3));
  proto.reset(new TDenseProtocol(buff_trans));
  checkout(0x0000000100000000ull, "\x90\x80\x80\x80\x00");
  checkout(0x0000000200000000ull, "\xA0\x80\x80\x80\x00");
  checkout(0x0000000300000000ull, "\xB0\x80\x80\x80\x00");
  checkout(0x0000000700000000ull, "\xF0\x80\x80\x80\x00");
  checkout(0x00000007F0000000ull, "\xFF\x80\x80\x80\x00");
  checkout(0x00000007FFFFFFFFull, "\xFF\xFF\xFF\xFF\x7F");
  checkout(0x0000000800000000ull, "\x81\x80\x80\x80\x80\x00");
  checkout(0x1FFFFFFFFFFFFFFFull, "\x9F\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x7F");
  checkout(0x7FFFFFFFFFFFFFFFull, "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x7F");
  checkout(0xFFFFFFFFFFFFFFFFull, "\x81\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x7F");

  // Test optional stuff.
  proto.reset(new TDenseProtocol(buffer));
  proto->setTypeSpec(ManyOpt::local_reflection);
  ManyOpt mo1, mo2, mo3, mo4, mo5, mo6;
  mo1.opt1 = 923759347;
  mo1.opt2 = 392749274;
  mo1.opt3 = 395739402;
  mo1.def4 = 294730928;
  mo1.opt5 = 394309218;
  mo1.opt6 = 832194723;
  mo1.__isset.opt1 = true;
  mo1.__isset.opt2 = true;
  mo1.__isset.opt3 = true;
  mo1.__isset.def4 = true;
  mo1.__isset.opt5 = true;
  mo1.__isset.opt6 = true;

  mo1.write(proto.get());
  mo2.read(proto.get());

  assert(mo2.__isset.opt1 == true);
  assert(mo2.__isset.opt2 == true);
  assert(mo2.__isset.opt3 == true);
  assert(mo2.__isset.def4 == true);
  assert(mo2.__isset.opt5 == true);
  assert(mo2.__isset.opt6 == true);

  assert(mo1 == mo2);

  mo1.__isset.opt1 = false;
  mo1.__isset.opt3 = false;
  mo1.__isset.opt5 = false;

  mo1.write(proto.get());
  mo3.read(proto.get());

  assert(mo3.__isset.opt1 == false);
  assert(mo3.__isset.opt2 == true);
  assert(mo3.__isset.opt3 == false);
  assert(mo3.__isset.def4 == true);
  assert(mo3.__isset.opt5 == false);
  assert(mo3.__isset.opt6 == true);

  assert(mo1 == mo3);

  mo1.__isset.opt1 = true;
  mo1.__isset.opt3 = true;
  mo1.__isset.opt5 = true;
  mo1.__isset.opt2 = false;
  mo1.__isset.opt6 = false;

  mo1.write(proto.get());
  mo4.read(proto.get());

  assert(mo4.__isset.opt1 == true);
  assert(mo4.__isset.opt2 == false);
  assert(mo4.__isset.opt3 == true);
  assert(mo4.__isset.def4 == true);
  assert(mo4.__isset.opt5 == true);
  assert(mo4.__isset.opt6 == false);

  assert(mo1 == mo4);

  mo1.__isset.opt1 = false;
  mo1.__isset.opt5 = false;

  mo1.write(proto.get());
  mo5.read(proto.get());

  assert(mo5.__isset.opt1 == false);
  assert(mo5.__isset.opt2 == false);
  assert(mo5.__isset.opt3 == true);
  assert(mo5.__isset.def4 == true);
  assert(mo5.__isset.opt5 == false);
  assert(mo5.__isset.opt6 == false);

  assert(mo1 == mo5);

  mo1.__isset.opt3 = false;

  mo1.write(proto.get());
  mo6.read(proto.get());

  assert(mo6.__isset.opt1 == false);
  assert(mo6.__isset.opt2 == false);
  assert(mo6.__isset.opt3 == false);
  assert(mo6.__isset.def4 == true);
  assert(mo6.__isset.opt5 == false);
  assert(mo6.__isset.opt6 == false);

  assert(mo1 == mo6);


  // Test fingerprint checking stuff.

  {
    // Default and required have the same fingerprint.
    Tricky1 t1;
    Tricky3 t3;
    assert(string(Tricky1::ascii_fingerprint) == Tricky3::ascii_fingerprint);
    proto->setTypeSpec(Tricky1::local_reflection);
    t1.im_default = 227;
    t1.write(proto.get());
    proto->setTypeSpec(Tricky3::local_reflection);
    t3.read(proto.get());
    assert(t3.im_required == 227);
  }

  {
    // Optional changes things.
    Tricky1 t1;
    Tricky2 t2;
    assert(string(Tricky1::ascii_fingerprint) != Tricky2::ascii_fingerprint);
    proto->setTypeSpec(Tricky1::local_reflection);
    t1.im_default = 227;
    t1.write(proto.get());
    try {
      proto->setTypeSpec(Tricky2::local_reflection);
      t2.read(proto.get());
      assert(false);
    } catch (TProtocolException& ex) {
      buffer->resetBuffer();
    }
  }

  {
    // Holy cow.  We can use the Tricky1 typespec with the Tricky2 structure.
    Tricky1 t1;
    Tricky2 t2;
    proto->setTypeSpec(Tricky1::local_reflection);
    t1.im_default = 227;
    t1.write(proto.get());
    t2.read(proto.get());
    assert(t2.__isset.im_optional == true);
    assert(t2.im_optional == 227);
  }

  {
    // And totally off the wall.
    Tricky1 t1;
    OneOfEach ooe2;
    assert(string(Tricky1::ascii_fingerprint) != OneOfEach::ascii_fingerprint);
    proto->setTypeSpec(Tricky1::local_reflection);
    t1.im_default = 227;
    t1.write(proto.get());
    try {
      proto->setTypeSpec(OneOfEach::local_reflection);
      ooe2.read(proto.get());
      assert(false);
    } catch (TProtocolException& ex) {
      buffer->resetBuffer();
    }
  }

  // Okay, this is really off the wall.
  // Just don't crash.
  cout << "Starting fuzz test.  This takes a while.  (20 dots.)" << endl;
  std::srand(12345);
  for (int i = 0; i < 2000; i++) {
    if (i % 100 == 0) {
      cout << ".";
      cout.flush();
    }
    buffer->resetBuffer();
    // Make sure the fingerprint prefix is right.
    buffer->write(Nesting::binary_fingerprint, 4);
    for (int j = 0; j < 1024*1024; j++) {
      uint8_t r = std::rand();
      buffer->write(&r, 1);
    }
    Nesting n;
    proto->setTypeSpec(OneOfEach::local_reflection);
    try {
      n.read(proto.get());
    } catch (TProtocolException& ex) {
    } catch (TTransportException& ex) {
    }
  }
  cout << endl;

  return 0;
}
