diff --git a/src/lib/diff/gen-node.hpp b/src/lib/diff/gen-node.hpp index 19a89a987..6dabf3a99 100644 --- a/src/lib/diff/gen-node.hpp +++ b/src/lib/diff/gen-node.hpp @@ -382,13 +382,6 @@ namespace diff{ return "todo"; ////TODO } - template<> - inline GenNode - Rec::buildTypeAttribute (string const& typeID) - { - return GenNode("type", typeID); - } - template<> inline string Rec::extractKey (GenNode const& v) diff --git a/src/lib/diff/record.hpp b/src/lib/diff/record.hpp index 9a4f2fb65..b074569e7 100644 --- a/src/lib/diff/record.hpp +++ b/src/lib/diff/record.hpp @@ -167,10 +167,11 @@ namespace diff{ { auto p = std::begin(con); auto e = std::end(con); - if (p!=e && isTypeID (*p)) - type_ = extractTypeID(*(p++)); for ( ; p!=e && isAttribute(*p); ++p) - attribs_.push_back (*p); + if (isTypeID (*p)) + type_ = extractTypeID(*p); + else + attribs_.push_back (*p); for ( ; p!=e; ++p) children_.push_back (*p); } @@ -307,7 +308,6 @@ namespace diff{ static bool isAttribute (VAL const& v); static bool isTypeID (VAL const& v); static string extractTypeID (VAL const& v); - static VAL buildTypeAttribute (string const& typeID); static string renderAttribute (VAL const& a); static string extractKey (VAL const& v); static Access extractVal (VAL const& v); @@ -388,7 +388,6 @@ namespace diff{ void setType (string const& newTypeID) { - set ("type", Rec::buildTypeAttribute (newTypeID)); record_.type_ = newTypeID; } @@ -595,14 +594,7 @@ namespace diff{ inline string Record::extractTypeID (string const& v) { - return "todo"; //////////////////////////////////////////TODO do we really need this function? - } - - template<> - inline string - Record::buildTypeAttribute (string const& typeID) - { - return "type = "+typeID; + return extractVal(v); } template<> @@ -629,7 +621,7 @@ namespace diff{ return "Rec(" + join (transformIterator (this->attribs(), renderAttribute)) - + "|{" + + " |{" + join (this->scope()) + "})" ; diff --git a/tests/15library.tests b/tests/15library.tests index 529acf342..6c1b9e292 100644 --- a/tests/15library.tests +++ b/tests/15library.tests @@ -214,7 +214,31 @@ return: 0 END -PLANNED "GenericRecordRepresentation_test" GenericRecordRepresentation_test <Name<->Registry<->Class<->Owner<->Operator<->built +out-lit: --Vals--->USS Enterprise<->NCC-1701-D<->Galaxy<->United Federation of Planets<->Starfleet<->2363 +out-lit: --Crew--->Picard | Riker | Data | Troi | Worf | Crusher | La Forge return: 0 END diff --git a/tests/library/diff/generic-record-representation-test.cpp b/tests/library/diff/generic-record-representation-test.cpp index 1e0f83509..f702ce1f5 100644 --- a/tests/library/diff/generic-record-representation-test.cpp +++ b/tests/library/diff/generic-record-representation-test.cpp @@ -36,6 +36,7 @@ using std::string; using util::isSameObject; using util::isnil; +using util::join; using std::vector; //using std::swap; using std::cout; @@ -119,6 +120,7 @@ namespace test{ ,"Registry = NCC-1701-D" ,"Class = Galaxy" ,"Owner = United Federation of Planets" + ,"Operator= Starfleet" ,"built=2363" }) , strings ({"Picard", "Riker", "Data", "Troi", "Worf", "Crusher", "La Forge"}) @@ -139,8 +141,11 @@ namespace test{ cout << "enterprise = " << string(enterprise)<" << join (enterprise.keys(), "<->")<" << join (enterprise.vals(), "<->")<" << join (enterprise.scope()," | ")<