--- /dev/null
+#include <iostream>
+#include <cmath>
+#include <transport/TTransportUtils.h>
+#include <protocol/TBinaryProtocol.h>
+#include <protocol/TJSONProtocol.h>
+#include "gen-cpp/DebugProtoTest_types.h"
+#include <time.h>
+#include "../lib/cpp/src/protocol/TDebugProtocol.h"
+
+class Timer {
+public:
+ timeval vStart;
+
+ Timer() {
+ gettimeofday(&vStart, 0);
+ }
+ void start() {
+ gettimeofday(&vStart, 0);
+ }
+
+ double frame() {
+ timeval vEnd;
+ gettimeofday(&vEnd, 0);
+ double dstart = vStart.tv_sec + ((double)vStart.tv_usec / 1000000.0);
+ double dend = vEnd.tv_sec + ((double)vEnd.tv_usec / 1000000.0);
+ return dend - dstart;
+ }
+
+};
+
+int main() {
+ using namespace std;
+ using namespace thrift::test::debug;
+ using namespace facebook::thrift::transport;
+ using namespace facebook::thrift::protocol;
+ using namespace boost;
+
+ 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 = "JSON THIS! \"\1";
+ ooe.zomg_unicode = "\xd7\n\a\t";
+ ooe.base64 = "\1\2\3\255";
+
+ shared_ptr<TMemoryBuffer> buf(new TMemoryBuffer());
+
+ int num = 1000000;
+
+ {
+ Timer timer;
+
+ for (int i = 0; i < num; i ++) {
+ buf->resetBuffer();
+ TBinaryProtocol prot(buf);
+ ooe.write(&prot);
+ }
+ cout << "Write: " << num / (1000 * timer.frame()) << " kHz" << endl;
+ }
+
+ uint8_t* data;
+ uint32_t datasize;
+
+ buf->getBuffer(&data, &datasize);
+
+ {
+
+ Timer timer;
+
+ for (int i = 0; i < num; i ++) {
+ OneOfEach ooe2;
+ shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize));
+ //buf2->resetBuffer(data, datasize);
+ TBinaryProtocol prot(buf2);
+ ooe2.read(&prot);
+
+ //cout << facebook::thrift::ThriftDebugString(ooe2) << endl << endl;
+ }
+ cout << " Read: " << num / (1000 * timer.frame()) << " kHz" << endl;
+ }
+
+
+ return 0;
+}
int main() {
using std::cout;
using std::endl;
- using namespace thrift::test;
+ using namespace thrift::test::debug;
OneOfEach ooe;
-namespace cpp thrift.test
+namespace cpp thrift.test.debug
namespace java thrift.test
struct Doubles {
using std::cout;
using std::endl;
using boost::shared_ptr;
- using namespace thrift::test;
+ using namespace thrift::test::debug;
using namespace facebook::thrift::transport;
using namespace facebook::thrift::protocol;
int main() {
using std::cout;
using std::endl;
- using namespace thrift::test;
+ using namespace thrift::test::debug;
using facebook::thrift::transport::TMemoryBuffer;
using facebook::thrift::protocol::TJSONProtocol;
SUBDIRS += java
endif
+noinst_LTLIBRARIES = libtestgencpp.la
+libtestgencpp_la_SOURCES = \
+ gen-cpp/DebugProtoTest_types.cpp \
+ gen-cpp/OptionalRequiredTest_types.cpp \
+ gen-cpp/DebugProtoTest_types.cpp \
+ gen-cpp/PartiallyReflectable.cpp \
+ gen-cpp/Service.cpp \
+ gen-cpp/StressTest_types.cpp \
+ gen-cpp/SecondService.cpp \
+ gen-cpp/ThriftTest_constants.cpp \
+ gen-cpp/ThriftTest.cpp \
+ gen-cpp/ThriftTest_types.cpp
+
+libtestgencpp_la_LIBADD = $(top_srcdir)/lib/cpp/libthrift.la
+
+noinst_PROGRAMS = Benchmark
+
+Benchmark_SOURCES = \
+ Benchmark.cpp
+
+Benchmark_LDADD = libtestgencpp.la
+
check_PROGRAMS = \
DebugProtoTest \
JSONProtoTest \
OptionalRequiredTest \
- ReflectionTest
+ ReflectionTest \
+ UnitTests
TESTS = \
$(check_PROGRAMS)
+UnitTests_SOURCES = \
+ UnitTestMain.cpp \
+ TMemoryBufferTest.cpp
+
+UnitTests_LDADD = libtestgencpp.la
#
# DebugProtoTest
#
DebugProtoTest_SOURCES = \
- gen-cpp/DebugProtoTest_types.cpp \
DebugProtoTest.cpp
-DebugProtoTest_LDADD = \
- $(top_srcdir)/lib/cpp/libthrift.la
+DebugProtoTest_LDADD = libtestgencpp.la
#
# JSONProtoTest
#
JSONProtoTest_SOURCES = \
- gen-cpp/DebugProtoTest_types.cpp \
JSONProtoTest.cpp
-JSONProtoTest_LDADD = \
- $(top_srcdir)/lib/cpp/libthrift.la
+JSONProtoTest_LDADD = libtestgencpp.la
#
# OptionalRequiredTest
#
OptionalRequiredTest_SOURCES = \
- gen-cpp/OptionalRequiredTest_types.cpp \
OptionalRequiredTest.cpp
-OptionalRequiredTest_LDADD = \
- $(top_srcdir)/lib/cpp/libthrift.la
+OptionalRequiredTest_LDADD = libtestgencpp.la
#
# ReflectionTest
#
ReflectionTest_SOURCES = \
- gen-cpp/DebugProtoTest_types.cpp \
- gen-cpp/PartiallyReflectable.cpp \
- gen-cpp/Service.cpp \
- gen-cpp/StressTest_types.cpp \
ReflectionTest.cpp
-ReflectionTest_LDADD = \
- $(top_srcdir)/lib/cpp/libthrift.la
-
+ReflectionTest_LDADD = libtestgencpp.la
#
# Common thrift code generation rules
gen-cpp/Service.cpp gen-cpp/StressTest_types.cpp: StressTest.thrift
$(THRIFT) --gen cpp:dense,reflection_limited $<
+gen-cpp/SecondService.cpp gen-cpp/ThriftTest_constants.cpp gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest_types.cpp: ThriftTest.thrift
+ $(THRIFT) --gen cpp:dense,reflection_limited $<
INCLUDES = \
-I$(top_srcdir)/lib/cpp/src
using std::endl;
facebook::thrift::reflection::limited::Service srv1;
- thrift::test::PartiallyReflectableIf::getStaticLimitedReflection(srv1);
+ thrift::test::debug::PartiallyReflectableIf::getStaticLimitedReflection(srv1);
cout << facebook::thrift::ThriftDebugString(srv1) << endl << endl;
facebook::thrift::reflection::limited::Service srv2;
-/*
-thrift -cpp ThriftTest.thrift
-g++ -Wall -g -I../lib/cpp/src -I/usr/local/include/boost-1_33_1 \
- TMemoryBufferTest.cpp gen-cpp/ThriftTest_types.cpp \
- ../lib/cpp/.libs/libthrift.a -o TMemoryBufferTest
-./TMemoryBufferTest
-*/
-
+#include <boost/test/unit_test.hpp>
#include <iostream>
#include <climits>
#include <cassert>
#include <protocol/TBinaryProtocol.h>
#include "gen-cpp/ThriftTest_types.h"
+BOOST_AUTO_TEST_SUITE( TMemoryBufferTest )
-int main(int argc, char** argv) {
- {
+BOOST_AUTO_TEST_CASE( test_roundtrip ) {
using facebook::thrift::transport::TMemoryBuffer;
using facebook::thrift::protocol::TBinaryProtocol;
using boost::shared_ptr;
assert(a == a2);
}
+BOOST_AUTO_TEST_CASE( test_copy )
{
using facebook::thrift::transport::TMemoryBuffer;
using std::string;
assert(str4 == "67891234");
}
+BOOST_AUTO_TEST_CASE( test_exceptions )
{
using facebook::thrift::transport::TTransportException;
using facebook::thrift::transport::TMemoryBuffer;
}
}
-
-}
+BOOST_AUTO_TEST_SUITE_END()
11: string newstring,
12: i32 end_in_both
}
+
+struct ListTypeVersioningV1 {
+ 1: list<i32> myints;
+ 2: string hello;
+}
+
+struct ListTypeVersioningV2 {
+ 1: list<string> strings;
+ 2: string hello;
+}
\ No newline at end of file
--- /dev/null
+#define BOOST_TEST_MODULE thrift
+#include <boost/test/included/unit_test.hpp>
import os
import signal
-serverproc = subprocess.Popen([sys.executable, "TestServer.py"])
+def relfile(fname):
+ return os.path.join(os.path.dirname(__file__), fname)
+
+serverproc = subprocess.Popen([sys.executable, relfile("TestServer.py")])
try:
- ret = subprocess.call([sys.executable, "TestClient.py"])
+ ret = subprocess.call([sys.executable, relfile("TestClient.py")])
if ret != 0:
raise Exception("subprocess failed")
finally: