From 36adc76235fb0a38e7042bc751f988b71627e2a0 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Tue, 11 Dec 2012 06:13:02 +0000 Subject: Changes to get successful C++11 based build. Code cleanup, dependency upgrades, and const + inline optimizations in components, samples, and app hosting server. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1420007 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/components/filedb/client-test.cpp | 71 +++++++++++-------------- 1 file changed, 31 insertions(+), 40 deletions(-) (limited to 'sca-cpp/trunk/components/filedb/client-test.cpp') diff --git a/sca-cpp/trunk/components/filedb/client-test.cpp b/sca-cpp/trunk/components/filedb/client-test.cpp index e0f98d8c3b..5694d97522 100644 --- a/sca-cpp/trunk/components/filedb/client-test.cpp +++ b/sca-cpp/trunk/components/filedb/client-test.cpp @@ -38,15 +38,15 @@ namespace filedb { const string uri("http://localhost:8090/filedb"); -bool testFileDB() { - http::CURLSession cs("", "", "", "", 0); - - const list i = list() + "content" + (list() + "item" - + (list() + "name" + string("Apple")) - + (list() + "price" + string("$2.99"))); - const list a = list() + (list() + "entry" - + (list() + "title" + string("item")) - + (list() + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b")) +const bool testFileDB() { + const http::CURLSession cs("", "", "", "", 0); + + const list i = nilListValue + "content" + (nilListValue + "item" + + (nilListValue + "name" + string("Apple")) + + (nilListValue + "price" + string("$2.99"))); + const list a = nilListValue + (nilListValue + "entry" + + (nilListValue + "title" + string("item")) + + (nilListValue + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b")) + i); const failable id = http::post(a, uri, cs); @@ -59,18 +59,18 @@ bool testFileDB() { assert(content(val) == a); } - const list j = list() + "content" + (list() + "item" - + (list() + "name" + string("Apple")) - + (list() + "price" + string("$3.55"))); - const list b = list() + (list() + "entry" - + (list() + "title" + string("item")) - + (list() + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b")) + const list j = nilListValue + "content" + (nilListValue + "item" + + (nilListValue + "name" + string("Apple")) + + (nilListValue + "price" + string("$3.55"))); + const list b = nilListValue + (nilListValue + "entry" + + (nilListValue + "title" + string("item")) + + (nilListValue + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b")) + j); { const failable r = http::put(b, uri + p, cs); assert(hasContent(r)); - assert(content(r) == value(true)); + assert(content(r) == trueValue); } { const failable val = http::get(uri + p, cs); @@ -80,7 +80,7 @@ bool testFileDB() { { const failable r = http::del(uri + p, cs); assert(hasContent(r)); - assert(content(r) == value(true)); + assert(content(r) == trueValue); } { const failable val = http::get(uri + p, cs); @@ -90,35 +90,26 @@ bool testFileDB() { return true; } -struct getLoop { - const string path; - const value entry; - http::CURLSession& cs; - getLoop(const string& path, const value& entry, http::CURLSession& cs) : path(path), entry(entry), cs(cs) { - } - const bool operator()() const { - const failable val = http::get(uri + path, cs); - assert(hasContent(val)); - assert(content(val) == entry); - return true; - } -}; - -bool testGetPerf() { - const list i = list() + "content" + (list() + "item" - + (list() + "name" + string("Apple")) - + (list() + "price" + string("$4.55"))); - const list a = list() + (list() + "entry" - + (list() + "title" + string("item")) - + (list() + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b")) +const bool testGetPerf() { + const list i = nilListValue + "content" + (nilListValue + "item" + + (nilListValue + "name" + string("Apple")) + + (nilListValue + "price" + string("$4.55"))); + const list a = nilListValue + (nilListValue + "entry" + + (nilListValue + "title" + string("item")) + + (nilListValue + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b")) + i); - http::CURLSession cs("", "", "", "", 0); + const http::CURLSession cs("", "", "", "", 0); const failable id = http::post(a, uri, cs); assert(hasContent(id)); const string p = path(content(id)); - const lambda gl = getLoop(p, a, cs); + const blambda gl = [p, a, cs]() -> const bool { + const failable val = http::get(uri + p, cs); + assert(hasContent(val)); + assert(content(val) == a); + return true; + }; cout << "FileDB get test " << time(gl, 5, 200) << " ms" << endl; return true; -- cgit v1.2.3