[Zrouter-src] ZRouter.org: push to zconf++ zconf++/tests/Makefile zconf++/test...

zrouter-src at zrouter.org zrouter-src at zrouter.org
Tue Jan 24 07:48:43 UTC 2012


details:   /rev/adabc0367d5a
changeset: 54:adabc0367d5a
user:      "Nicolai Petri <nicolai at petri.dk>"
date:      Tue Jan 24 08:48:09 2012 +0100
description:
Make compile again.

diffstat:

 zconf++/tests/Makefile      |   2 +-
 zconf++/tests/test_model.cc |  42 +++++++++++++-----------------------------
 2 files changed, 14 insertions(+), 30 deletions(-)

diffs (88 lines):

diff -r 5d681bc34ef6 -r adabc0367d5a zconf++/tests/Makefile
--- a/zconf++/tests/Makefile	Tue Jan 24 08:47:53 2012 +0100
+++ b/zconf++/tests/Makefile	Tue Jan 24 08:48:09 2012 +0100
@@ -16,7 +16,7 @@
 json_reader.o: ../json_reader.cc ../json_reader.h ../model.h
 
 clean:
-	@rm -rf *.o *.t *.core || true
+	@rm -rf *.o *.t *.tap *.core || true
 
 run: all
 	./model.t
diff -r 5d681bc34ef6 -r adabc0367d5a zconf++/tests/test_model.cc
--- a/zconf++/tests/test_model.cc	Tue Jan 24 08:47:53 2012 +0100
+++ b/zconf++/tests/test_model.cc	Tue Jan 24 08:48:09 2012 +0100
@@ -10,26 +10,6 @@
 using namespace ZRouter;
 using namespace std;
 
-/*	
-	template <class TClass> 
-		class TModelActionHandler : public IModelActionHandler {
-			protected:
-				TClass *m_obj;
-				Leaf (TClass::*m_handler)(const std::string& pUri, LeafRef pRequest);
-				LeafRef (TClass::*m_describer)();
-			public:
-			TModelActionHandler(TClass *pObject, Leaf(TClass::*pHndlr)(const std::string& pUri, LeafRef pReq), LeafRef(TClass::*pDscrp)())
-				: m_obj(pObject)
-				, m_handler(pHndlr)
-				, m_describer(pDscrp)
-			{ ; }
-			virtual Leaf handler(const std::string &uri, LeafRef pRequest ) {
-				return (*m_obj.*m_handler)(uri, pRequest);
-			}
-			virtual LeafRef describe() {
-				return (*m_obj.*m_describer)();
-			}
-	};	*/
 	class TestHandler {
 		protected:
 			Leaf m_description;
@@ -40,7 +20,7 @@
 				_node_id["type"] = "int";
 				_node_id["description"] = "Contains id of the node to perform the requested action upon";
 			}
-			virtual Leaf handle(const std::string &uri, LeafRef pRequest ) {
+			virtual Leaf handle(const std::string &uri, LeafRef pSelf, LeafRef pRequest ) {
 				Leaf A;
 				A["response"]["message"] = "I'm a dummy response";
 				return A;
@@ -50,7 +30,7 @@
 	};
 
 int main() {
-	plan_tests(13);
+	plan_tests(14);
 	Model M;
 	pass("Model constructed");
 	
@@ -91,16 +71,20 @@
 	Leaf resp = M["system"]["handlers"]["testhandler"].call(Req);
 	cout << "Output of testhandler() action :" << ModelWriter::write(resp, " RESPONSE: ") << endl;
 	cout << "TestHandler description is : " << endl << ModelWriter::write(M["system"]["handlers"]["testhandler"].describe(), " DESCR: ") << endl;
-	std::string ModelAsText = ModelWriter::write(M, "") + "\n";
-	cout << "Output PREPARSED :" << endl << ModelWriter::write(M, " PREPARSED: ") << endl;
+	std::string ModelAsText = ModelWriter::write(M, "");
+	//cout << "Output PREPARSED :" << endl << ModelWriter::write(M, " PREPARSED: ") << endl;
    Json::Reader reader;
 		Leaf NewM;
    bool parsingSuccessful = reader.parse( ModelAsText, NewM );
-	cout << "Output of PARSER :" << endl << ModelWriter::write(NewM, " PARSED: ") << endl;
-	std::stringstream ss;
-	ModelWriter::write(ss, NewM, " PARSED2: ");
-	cout << "Output of PARSER2 :" << endl << ss.str() << endl;
-
+	std::string ModelAsTextReparsed = ModelWriter::write(NewM, "");
+	//cout << "Output of PARSER :" << endl << ModelWriter::write(NewM, " PARSED: ") << endl;
+//	std::stringstream ss;
+//	ModelWriter::write(ss, NewM, " PARSED2: ");
+//	cout << "Output of PARSER2 :" << endl << ss.str() << endl;
+	cout << ModelAsText << endl;
+	cout << ModelAsTextReparsed << endl;
+	// FIXME: Parsing foo: { } gives foo: null .. it should not matter but is not pretty and makes this test fail
+	ok(ModelAsText == ModelAsTextReparsed, "Model Export/Import/Export comparision");
 //	for (int c=0; c < L2.numChildren(); c++) {
 //		cout << "  dumping " << c << " => " << L2[c] << endl;
 //	}


More information about the Zrouter-src mailing list