Commit b763a8e0 authored by Jelte Jansen's avatar Jelte Jansen

rename createFromString() to fromJSON()


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac172@2113 e5f2f494-b856-4b98-b285-d166d9295462
parent ab6751e3
...@@ -236,7 +236,7 @@ updateConfig(AuthSrv* server, const char* const dbfile, ...@@ -236,7 +236,7 @@ updateConfig(AuthSrv* server, const char* const dbfile,
const bool expect_success) const bool expect_success)
{ {
const ElementPtr config_answer = const ElementPtr config_answer =
server->updateConfig(Element::createFromString(dbfile)); server->updateConfig(Element::fromJSON(dbfile));
EXPECT_EQ(Element::map, config_answer->getType()); EXPECT_EQ(Element::map, config_answer->getType());
EXPECT_TRUE(config_answer->contains("result")); EXPECT_TRUE(config_answer->contains("result"));
......
...@@ -261,7 +261,7 @@ Element::createMap() { ...@@ -261,7 +261,7 @@ Element::createMap() {
// //
// helper functions for createFromString factory // helper functions for fromJSON factory
// //
namespace { namespace {
bool bool
...@@ -477,7 +477,7 @@ from_stringstream_list(std::istream &in, const std::string& file, int& line, int ...@@ -477,7 +477,7 @@ from_stringstream_list(std::istream &in, const std::string& file, int& line, int
skip_chars(in, " \t\n", line, pos); skip_chars(in, " \t\n", line, pos);
while (c != EOF && c != ']') { while (c != EOF && c != ']') {
if (in.peek() != ']') { if (in.peek() != ']') {
cur_list_element = Element::createFromString(in, file, line, pos); cur_list_element = Element::fromJSON(in, file, line, pos);
list->add(cur_list_element); list->add(cur_list_element);
skip_to(in, file, line, pos, ",]", " \t\n"); skip_to(in, file, line, pos, ",]", " \t\n");
} }
...@@ -511,7 +511,7 @@ from_stringstream_map(std::istream &in, const std::string& file, int& line, ...@@ -511,7 +511,7 @@ from_stringstream_map(std::istream &in, const std::string& file, int& line,
in.get(); in.get();
pos++; pos++;
ElementPtr value = Element::createFromString(in, file, line, pos); ElementPtr value = Element::fromJSON(in, file, line, pos);
map->set(key, value); map->set(key, value);
skip_to(in, file, line, pos, ",}", " \t\n"); skip_to(in, file, line, pos, ",}", " \t\n");
...@@ -524,20 +524,20 @@ from_stringstream_map(std::istream &in, const std::string& file, int& line, ...@@ -524,20 +524,20 @@ from_stringstream_map(std::istream &in, const std::string& file, int& line,
} }
ElementPtr ElementPtr
Element::createFromString(std::istream& in) throw(ParseError) { Element::fromJSON(std::istream& in) throw(ParseError) {
int line = 1, pos = 1; int line = 1, pos = 1;
return createFromString(in, "<istream>", line, pos); return fromJSON(in, "<istream>", line, pos);
} }
ElementPtr ElementPtr
Element::createFromString(std::istream& in, const std::string& file_name) throw(ParseError) Element::fromJSON(std::istream& in, const std::string& file_name) throw(ParseError)
{ {
int line = 1, pos = 1; int line = 1, pos = 1;
return createFromString(in, file_name, line, pos); return fromJSON(in, file_name, line, pos);
} }
ElementPtr ElementPtr
Element::createFromString(std::istream &in, const std::string& file, int& line, int& pos) throw(ParseError) Element::fromJSON(std::istream &in, const std::string& file, int& line, int& pos) throw(ParseError)
{ {
char c = 0; char c = 0;
ElementPtr element; ElementPtr element;
...@@ -602,10 +602,10 @@ Element::createFromString(std::istream &in, const std::string& file, int& line, ...@@ -602,10 +602,10 @@ Element::createFromString(std::istream &in, const std::string& file, int& line,
} }
ElementPtr ElementPtr
Element::createFromString(const std::string &in) { Element::fromJSON(const std::string &in) {
std::stringstream ss; std::stringstream ss;
ss << in; ss << in;
return createFromString(ss, "<string>"); return fromJSON(ss, "<string>");
} }
// to JSON format // to JSON format
...@@ -712,7 +712,7 @@ Element::fromWire(const std::string& s) { ...@@ -712,7 +712,7 @@ Element::fromWire(const std::string& s) {
std::stringstream ss; std::stringstream ss;
ss << s; ss << s;
int line = 0, pos = 0; int line = 0, pos = 0;
return createFromString(ss, "<wire>", line, pos); return fromJSON(ss, "<wire>", line, pos);
} }
ElementPtr ElementPtr
...@@ -728,7 +728,7 @@ Element::fromWire(std::stringstream& in, int length) { ...@@ -728,7 +728,7 @@ Element::fromWire(std::stringstream& in, int length) {
//} //}
//length -= 4; //length -= 4;
int line = 0, pos = 0; int line = 0, pos = 0;
return createFromString(in, "<wire>", line, pos); return fromJSON(in, "<wire>", line, pos);
} }
void void
......
...@@ -75,7 +75,7 @@ private: ...@@ -75,7 +75,7 @@ private:
/// ///
/// Elements should in calling functions usually be referenced through /// Elements should in calling functions usually be referenced through
/// an \c ElementPtr, which can be created using the factory functions /// an \c ElementPtr, which can be created using the factory functions
/// \c Element::create() and \c Element::createFromString() /// \c Element::create() and \c Element::fromJSON()
/// ///
/// Notes to developers: Element is a base class, implemented by a /// Notes to developers: Element is a base class, implemented by a
/// specific subclass for each type (IntElement, BoolElement, etc). /// specific subclass for each type (IntElement, BoolElement, etc).
...@@ -164,6 +164,7 @@ public: ...@@ -164,6 +164,7 @@ public:
virtual bool getValue(std::vector<ElementPtr>& t); virtual bool getValue(std::vector<ElementPtr>& t);
virtual bool getValue(std::map<std::string, ElementPtr>& t); virtual bool getValue(std::map<std::string, ElementPtr>& t);
//@} //@}
/// ///
/// \name Exception-safe setters. /// \name Exception-safe setters.
/// ///
...@@ -193,21 +194,26 @@ public: ...@@ -193,21 +194,26 @@ public:
/// of bounds, this function throws an std::out_of_range exception. /// of bounds, this function throws an std::out_of_range exception.
/// \param i The position of the ElementPtr to return /// \param i The position of the ElementPtr to return
virtual ElementPtr get(const int i); virtual ElementPtr get(const int i);
/// Sets the ElementPtr at the given index. If the index is out /// Sets the ElementPtr at the given index. If the index is out
/// of bounds, this function throws an std::out_of_range exception. /// of bounds, this function throws an std::out_of_range exception.
/// \param i The position of the ElementPtr to set /// \param i The position of the ElementPtr to set
/// \param element The ElementPtr to set at the position /// \param element The ElementPtr to set at the position
virtual void set(const size_t i, ElementPtr element); virtual void set(const size_t i, ElementPtr element);
/// Adds an ElementPtr to the list /// Adds an ElementPtr to the list
/// \param element The ElementPtr to add /// \param element The ElementPtr to add
virtual void add(ElementPtr element); virtual void add(ElementPtr element);
/// Removes the element at the given position. If the index is out /// Removes the element at the given position. If the index is out
/// of nothing happens. /// of nothing happens.
/// \param i The index of the element to remove. /// \param i The index of the element to remove.
virtual void remove(const int i); virtual void remove(const int i);
/// Returns the number of elements in the list. /// Returns the number of elements in the list.
virtual size_t size(); virtual size_t size();
//@} //@}
/// \name MapElement functions /// \name MapElement functions
/// ///
...@@ -218,16 +224,20 @@ public: ...@@ -218,16 +224,20 @@ public:
/// \param name The key of the Element to return /// \param name The key of the Element to return
/// \return The ElementPtr at the given key /// \return The ElementPtr at the given key
virtual ElementPtr get(const std::string& name); virtual ElementPtr get(const std::string& name);
/// Sets the ElementPtr at the given key /// Sets the ElementPtr at the given key
/// \param name The key of the Element to set /// \param name The key of the Element to set
virtual void set(const std::string& name, ElementPtr element); virtual void set(const std::string& name, ElementPtr element);
/// Remove the ElementPtr at the given key /// Remove the ElementPtr at the given key
/// \param name The key of the Element to remove /// \param name The key of the Element to remove
virtual void remove(const std::string& name); virtual void remove(const std::string& name);
/// Checks if there is data at the given key /// Checks if there is data at the given key
/// \param name The key of the Element to remove /// \param name The key of the Element to remove
/// \return true if there is data at the key, false if not. /// \return true if there is data at the key, false if not.
virtual bool contains(const std::string& name); virtual bool contains(const std::string& name);
/// Recursively finds any data at the given identifier. The /// Recursively finds any data at the given identifier. The
/// identifier is a /-separated list of names of nested maps, with /// identifier is a /-separated list of names of nested maps, with
/// the last name being the leaf that is returned. /// the last name being the leaf that is returned.
...@@ -242,6 +252,7 @@ public: ...@@ -242,6 +252,7 @@ public:
/// null ElementPtr if it is not found, which can be checked with /// null ElementPtr if it is not found, which can be checked with
/// Element::is_null(ElementPtr e). /// Element::is_null(ElementPtr e).
virtual ElementPtr find(const std::string& identifier); virtual ElementPtr find(const std::string& identifier);
/// See \c Element::find() /// See \c Element::find()
/// \param identifier The identifier of the element to find /// \param identifier The identifier of the element to find
/// \param t Reference to store the resulting ElementPtr, if found. /// \param t Reference to store the resulting ElementPtr, if found.
...@@ -249,6 +260,7 @@ public: ...@@ -249,6 +260,7 @@ public:
virtual bool find(const std::string& identifier, ElementPtr& t); virtual bool find(const std::string& identifier, ElementPtr& t);
//@} //@}
/// \name Factory functions /// \name Factory functions
// TODO: should we move all factory functions to a different class // TODO: should we move all factory functions to a different class
...@@ -276,10 +288,12 @@ public: ...@@ -276,10 +288,12 @@ public:
/// \brief Creates an empty ListElement type ElementPtr. /// \brief Creates an empty ListElement type ElementPtr.
static ElementPtr createList(); static ElementPtr createList();
/// \brief Creates an empty MapElement type ElementPtr. /// \brief Creates an empty MapElement type ElementPtr.
static ElementPtr createMap(); static ElementPtr createMap();
//@} //@}
/// \name Compound factory functions /// \name Compound factory functions
/// \brief These functions will parse the given string (JSON) /// \brief These functions will parse the given string (JSON)
...@@ -287,18 +301,21 @@ public: ...@@ -287,18 +301,21 @@ public:
/// error, an exception of the type isc::data::ParseError is thrown. /// error, an exception of the type isc::data::ParseError is thrown.
//@{ //@{
/// Creates an Element from the given string /// Creates an Element from the given JSON string
/// \param in The string to parse the element from /// \param in The string to parse the element from
/// \return An ElementPtr that contains the element(s) specified /// \return An ElementPtr that contains the element(s) specified
/// in the given string. /// in the given string.
static ElementPtr createFromString(const std::string& in); static ElementPtr fromJSON(const std::string& in);
/// Creates an Element from the given input stream /// Creates an Element from the given input stream containing JSON
/// formatted data.
///
/// \param in The string to parse the element from /// \param in The string to parse the element from
/// \return An ElementPtr that contains the element(s) specified /// \return An ElementPtr that contains the element(s) specified
/// in the given input stream. /// in the given input stream.
static ElementPtr createFromString(std::istream& in) throw(ParseError); static ElementPtr fromJSON(std::istream& in) throw(ParseError);
static ElementPtr createFromString(std::istream& in, const std::string& file_name) throw(ParseError); static ElementPtr fromJSON(std::istream& in, const std::string& file_name) throw(ParseError);
/// Creates an Element from the given input stream, where we keep /// Creates an Element from the given input stream, where we keep
/// track of the location in the stream for error reporting. /// track of the location in the stream for error reporting.
/// ///
...@@ -310,7 +327,7 @@ public: ...@@ -310,7 +327,7 @@ public:
/// \return An ElementPtr that contains the element(s) specified /// \return An ElementPtr that contains the element(s) specified
/// in the given input stream. /// in the given input stream.
// make this one private? // make this one private?
static ElementPtr createFromString(std::istream& in, const std::string& file, int& line, int &pos) throw(ParseError); static ElementPtr fromJSON(std::istream& in, const std::string& file, int& line, int &pos) throw(ParseError);
//@} //@}
/// \name Wire format factory functions /// \name Wire format factory functions
...@@ -323,7 +340,7 @@ public: ...@@ -323,7 +340,7 @@ public:
/// Creates an Element from the wire format in the given /// Creates an Element from the wire format in the given
/// stringstream of the given length. /// stringstream of the given length.
/// Since the wire format is JSON, thise is the same as /// Since the wire format is JSON, thise is the same as
/// createFromString, and could be removed. /// fromJSON, and could be removed.
/// ///
/// \param in The input stringstream. /// \param in The input stringstream.
/// \param length The length of the wireformat data in the stream /// \param length The length of the wireformat data in the stream
...@@ -332,7 +349,7 @@ public: ...@@ -332,7 +349,7 @@ public:
/// Creates an Element from the wire format in the given string /// Creates an Element from the wire format in the given string
/// Since the wire format is JSON, thise is the same as /// Since the wire format is JSON, thise is the same as
/// createFromString, and could be removed. /// fromJSON, and could be removed.
/// ///
/// \param s The input string /// \param s The input string
/// \return ElementPtr with the data that is parsed. /// \return ElementPtr with the data that is parsed.
......
...@@ -65,14 +65,14 @@ TEST(Element, from_and_to_str) { ...@@ -65,14 +65,14 @@ TEST(Element, from_and_to_str) {
BOOST_FOREACH(std::string s, sv) { BOOST_FOREACH(std::string s, sv) {
// also test << operator, which uses Element::str() // also test << operator, which uses Element::str()
std::ostringstream stream; std::ostringstream stream;
el = Element::createFromString(s); el = Element::fromJSON(s);
stream << el; stream << el;
EXPECT_EQ(stream.str(), s); EXPECT_EQ(stream.str(), s);
} }
// some parse errors // some parse errors
try { try {
Element::createFromString("{1}"); Element::fromJSON("{1}");
} catch (isc::data::ParseError pe) { } catch (isc::data::ParseError pe) {
std::string s = std::string(pe.what()); std::string s = std::string(pe.what());
EXPECT_EQ(s, "String expected in <string>:1:3"); EXPECT_EQ(s, "String expected in <string>:1:3");
...@@ -80,7 +80,7 @@ TEST(Element, from_and_to_str) { ...@@ -80,7 +80,7 @@ TEST(Element, from_and_to_str) {
sv.clear(); sv.clear();
sv.push_back("{1}"); sv.push_back("{1}");
//ElementPtr ep = Element::createFromString("\"aaa\nbbb\"err"); //ElementPtr ep = Element::fromJSON("\"aaa\nbbb\"err");
//std::cout << ep << std::endl; //std::cout << ep << std::endl;
sv.push_back("\n\nTru"); sv.push_back("\n\nTru");
sv.push_back("{ \n \"aaa\nbbb\"err:"); sv.push_back("{ \n \"aaa\nbbb\"err:");
...@@ -89,19 +89,19 @@ TEST(Element, from_and_to_str) { ...@@ -89,19 +89,19 @@ TEST(Element, from_and_to_str) {
sv.push_back(""); sv.push_back("");
BOOST_FOREACH(std::string s, sv) { BOOST_FOREACH(std::string s, sv) {
EXPECT_THROW(el = Element::createFromString(s), isc::data::ParseError); EXPECT_THROW(el = Element::fromJSON(s), isc::data::ParseError);
} }
// some json specific format tests, here the str() output is // some json specific format tests, here the str() output is
// different from the string input // different from the string input
EXPECT_EQ("100", Element::createFromString("1e2")->str()); EXPECT_EQ("100", Element::fromJSON("1e2")->str());
EXPECT_EQ("0.01", Element::createFromString("1e-2")->str()); EXPECT_EQ("0.01", Element::fromJSON("1e-2")->str());
EXPECT_EQ("1.2", Element::createFromString("1.2")->str()); EXPECT_EQ("1.2", Element::fromJSON("1.2")->str());
EXPECT_EQ("1", Element::createFromString("1.0")->str()); EXPECT_EQ("1", Element::fromJSON("1.0")->str());
EXPECT_EQ("120", Element::createFromString("1.2e2")->str()); EXPECT_EQ("120", Element::fromJSON("1.2e2")->str());
EXPECT_EQ("100", Element::createFromString("1.0e2")->str()); EXPECT_EQ("100", Element::fromJSON("1.0e2")->str());
EXPECT_EQ("0.01", Element::createFromString("1.0e-2")->str()); EXPECT_EQ("0.01", Element::fromJSON("1.0e-2")->str());
EXPECT_EQ("0.012", Element::createFromString("1.2e-2")->str()); EXPECT_EQ("0.012", Element::fromJSON("1.2e-2")->str());
} }
TEST(Element, create_and_value_throws) { TEST(Element, create_and_value_throws) {
...@@ -155,12 +155,12 @@ TEST(Element, create_and_value_throws) { ...@@ -155,12 +155,12 @@ TEST(Element, create_and_value_throws) {
TEST(Element, ListElement) { TEST(Element, ListElement) {
// this function checks the specific functions for ListElements // this function checks the specific functions for ListElements
ElementPtr el = Element::createFromString("[ 1, \"bar\", 3 ]"); ElementPtr el = Element::fromJSON("[ 1, \"bar\", 3 ]");
EXPECT_EQ(el->get(0)->intValue(), 1); EXPECT_EQ(el->get(0)->intValue(), 1);
EXPECT_EQ(el->get(1)->stringValue(), "bar"); EXPECT_EQ(el->get(1)->stringValue(), "bar");
EXPECT_EQ(el->get(2)->intValue(), 3); EXPECT_EQ(el->get(2)->intValue(), 3);
el->set(0, Element::createFromString("\"foo\"")); el->set(0, Element::fromJSON("\"foo\""));
EXPECT_EQ(el->get(0)->stringValue(), "foo"); EXPECT_EQ(el->get(0)->stringValue(), "foo");
el->add(Element::create(47806)); el->add(Element::create(47806));
...@@ -188,7 +188,7 @@ const string long_maptag("0123456789abcdef1123456789abcdef2123456789abcdef" ...@@ -188,7 +188,7 @@ const string long_maptag("0123456789abcdef1123456789abcdef2123456789abcdef"
TEST(Element, MapElement) { TEST(Element, MapElement) {
// this function checks the specific functions for ListElements // this function checks the specific functions for ListElements
ElementPtr el = Element::createFromString("{ \"name\": \"foo\", \"value1\": \"bar\", \"value2\": { \"number\": 42 } }"); ElementPtr el = Element::fromJSON("{ \"name\": \"foo\", \"value1\": \"bar\", \"value2\": { \"number\": 42 } }");
ElementPtr el2; ElementPtr el2;
EXPECT_EQ(el->get("name")->stringValue(), "foo"); EXPECT_EQ(el->get("name")->stringValue(), "foo");
...@@ -220,7 +220,7 @@ TEST(Element, MapElement) { ...@@ -220,7 +220,7 @@ TEST(Element, MapElement) {
"f123456789abcde"); "f123456789abcde");
EXPECT_EQ(255, long_maptag.length()); // check prerequisite EXPECT_EQ(255, long_maptag.length()); // check prerequisite
el = Element::createFromString("{ \"" + long_maptag + "\": \"bar\"}"); el = Element::fromJSON("{ \"" + long_maptag + "\": \"bar\"}");
EXPECT_EQ("bar", el->find(long_maptag)->stringValue()); EXPECT_EQ("bar", el->find(long_maptag)->stringValue());
el = Element::createMap(); el = Element::createMap();
...@@ -229,7 +229,7 @@ TEST(Element, MapElement) { ...@@ -229,7 +229,7 @@ TEST(Element, MapElement) {
// A one-byte longer tag should trigger an exception. // A one-byte longer tag should trigger an exception.
long_maptag.push_back('f'); long_maptag.push_back('f');
EXPECT_THROW(Element::createFromString("{ \"" + long_maptag + EXPECT_THROW(Element::fromJSON("{ \"" + long_maptag +
"\": \"bar\"}"), "\": \"bar\"}"),
ParseError); ParseError);
...@@ -246,14 +246,14 @@ TEST(Element, to_and_from_wire) { ...@@ -246,14 +246,14 @@ TEST(Element, to_and_from_wire) {
EXPECT_EQ("false", Element::create(false)->toWire()); EXPECT_EQ("false", Element::create(false)->toWire());
EXPECT_EQ("null", Element::create()->toWire()); EXPECT_EQ("null", Element::create()->toWire());
EXPECT_EQ("\"a string\"", Element::create("a string")->toWire()); EXPECT_EQ("\"a string\"", Element::create("a string")->toWire());
EXPECT_EQ("[ \"a\", \"list\" ]", Element::createFromString("[ \"a\", \"list\" ]")->toWire()); EXPECT_EQ("[ \"a\", \"list\" ]", Element::fromJSON("[ \"a\", \"list\" ]")->toWire());
EXPECT_EQ("{ \"a\": \"map\" }", Element::createFromString("{ \"a\": \"map\" }")->toWire()); EXPECT_EQ("{ \"a\": \"map\" }", Element::fromJSON("{ \"a\": \"map\" }")->toWire());
EXPECT_EQ("1", Element::fromWire("1")->str()); EXPECT_EQ("1", Element::fromWire("1")->str());
} }
ElementPtr efs(const std::string& str) { ElementPtr efs(const std::string& str) {
return Element::createFromString(str); return Element::fromJSON(str);
} }
TEST(Element, equals) { TEST(Element, equals) {
...@@ -314,45 +314,45 @@ TEST(Element, removeIdentical) { ...@@ -314,45 +314,45 @@ TEST(Element, removeIdentical) {
removeIdentical(a, b); removeIdentical(a, b);
EXPECT_TRUE(a == c); EXPECT_TRUE(a == c);
a = Element::createFromString("{ \"a\": 1 }"); a = Element::fromJSON("{ \"a\": 1 }");
b = Element::createFromString("{ \"a\": 1 }"); b = Element::fromJSON("{ \"a\": 1 }");
c = Element::createMap(); c = Element::createMap();
removeIdentical(a, b); removeIdentical(a, b);
EXPECT_TRUE(a == c); EXPECT_TRUE(a == c);
a = Element::createFromString("{ \"a\": 1, \"b\": [ 1, 2 ] }"); a = Element::fromJSON("{ \"a\": 1, \"b\": [ 1, 2 ] }");
b = Element::createMap(); b = Element::createMap();
c = Element::createFromString("{ \"a\": 1, \"b\": [ 1, 2 ] }"); c = Element::fromJSON("{ \"a\": 1, \"b\": [ 1, 2 ] }");
removeIdentical(a, b); removeIdentical(a, b);
EXPECT_TRUE(a == c); EXPECT_TRUE(a == c);
a = Element::createFromString("{ \"a\": 1, \"b\": [ 1, 2 ] }"); a = Element::fromJSON("{ \"a\": 1, \"b\": [ 1, 2 ] }");
b = Element::createFromString("{ \"a\": 1, \"b\": [ 1, 2 ] }"); b = Element::fromJSON("{ \"a\": 1, \"b\": [ 1, 2 ] }");
c = Element::createMap(); c = Element::createMap();
removeIdentical(a, b); removeIdentical(a, b);
EXPECT_TRUE(a == c); EXPECT_TRUE(a == c);
a = Element::createFromString("{ \"a\": 1, \"b\": [ 1, 2 ] }"); a = Element::fromJSON("{ \"a\": 1, \"b\": [ 1, 2 ] }");
b = Element::createFromString("{ \"a\": 1, \"b\": [ 1, 3 ] }"); b = Element::fromJSON("{ \"a\": 1, \"b\": [ 1, 3 ] }");
c = Element::createFromString("{ \"b\": [ 1, 2 ] }"); c = Element::fromJSON("{ \"b\": [ 1, 2 ] }");
removeIdentical(a, b); removeIdentical(a, b);
EXPECT_TRUE(a == c); EXPECT_TRUE(a == c);
a = Element::createFromString("{ \"a\": { \"b\": \"c\" } }"); a = Element::fromJSON("{ \"a\": { \"b\": \"c\" } }");
b = Element::createMap(); b = Element::createMap();
c = Element::createFromString("{ \"a\": { \"b\": \"c\" } }"); c = Element::fromJSON("{ \"a\": { \"b\": \"c\" } }");
removeIdentical(a, b); removeIdentical(a, b);
EXPECT_TRUE(a == c); EXPECT_TRUE(a == c);
a = Element::createFromString("{ \"a\": { \"b\": \"c\" } }"); a = Element::fromJSON("{ \"a\": { \"b\": \"c\" } }");
b = Element::createFromString("{ \"a\": { \"b\": \"c\" } }"); b = Element::fromJSON("{ \"a\": { \"b\": \"c\" } }");
c = Element::createMap(); c = Element::createMap();
removeIdentical(a, b); removeIdentical(a, b);
EXPECT_TRUE(a == c); EXPECT_TRUE(a == c);
a = Element::createFromString("{ \"a\": { \"b\": \"c\" } }"); a = Element::fromJSON("{ \"a\": { \"b\": \"c\" } }");
b = Element::createFromString("{ \"a\": { \"b\": \"d\" } }"); b = Element::fromJSON("{ \"a\": { \"b\": \"d\" } }");
c = Element::createFromString("{ \"a\": { \"b\": \"c\" } }"); c = Element::fromJSON("{ \"a\": { \"b\": \"c\" } }");
removeIdentical(a, b); removeIdentical(a, b);
EXPECT_TRUE(a == c); EXPECT_TRUE(a == c);
} }
...@@ -365,25 +365,25 @@ TEST(Element, merge) ...@@ -365,25 +365,25 @@ TEST(Element, merge)
merge(a, b); merge(a, b);
EXPECT_TRUE(a == c); EXPECT_TRUE(a == c);
a = Element::createFromString("1"); a = Element::fromJSON("1");
b = Element::createMap(); b = Element::createMap();
EXPECT_THROW(merge(a, b), TypeError); EXPECT_THROW(merge(a, b), TypeError);
a = Element::createMap(); a = Element::createMap();
b = Element::createFromString("{ \"a\": 1 }"); b = Element::fromJSON("{ \"a\": 1 }");
c = Element::createFromString("{ \"a\": 1 }"); c = Element::fromJSON("{ \"a\": 1 }");
merge(a, b); merge(a, b);
EXPECT_TRUE(a == c); EXPECT_TRUE(a == c);
a = Element::createFromString("{ \"a\": 1 }"); a = Element::fromJSON("{ \"a\": 1 }");
b = Element::createFromString("{ \"a\": 2 }");