summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2018-06-21 15:49:53 +0100
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2018-06-21 15:49:53 +0100
commit9d7b353cbb5c12cd74559a8f3a7365312f95d4d0 (patch)
treeb35c3e3eb0c9c93cea2c01248a3943d5c1277fa7 /indra/llcommon
parent8abfd8da4fb222382437f4b547567fabc6f75cf8 (diff)
parentdc07de2f4a4c49d1877bf743b6f0d209392f6eb6 (diff)
merge
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llfile.cpp4
-rw-r--r--indra/llcommon/llfile.h2
-rw-r--r--indra/llcommon/tests/llsdserialize_test.cpp184
3 files changed, 184 insertions, 6 deletions
diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp
index 8aa41035b9..fc203f78e1 100644
--- a/indra/llcommon/llfile.cpp
+++ b/indra/llcommon/llfile.cpp
@@ -258,7 +258,7 @@ int LLFile::remove(const std::string& filename, int supress_error)
return warnif("remove", filename, rc, supress_error);
}
-int LLFile::rename(const std::string& filename, const std::string& newname)
+int LLFile::rename(const std::string& filename, const std::string& newname, int supress_error)
{
#if LL_WINDOWS
std::string utf8filename = filename;
@@ -269,7 +269,7 @@ int LLFile::rename(const std::string& filename, const std::string& newname)
#else
int rc = ::rename(filename.c_str(),newname.c_str());
#endif
- return warnif(STRINGIZE("rename to '" << newname << "' from"), filename, rc);
+ return warnif(STRINGIZE("rename to '" << newname << "' from"), filename, rc, supress_error);
}
bool LLFile::copy(const std::string from, const std::string to)
diff --git a/indra/llcommon/llfile.h b/indra/llcommon/llfile.h
index ba935b8714..398938b729 100644
--- a/indra/llcommon/llfile.h
+++ b/indra/llcommon/llfile.h
@@ -74,7 +74,7 @@ public:
static int rmdir(const std::string& filename);
static int remove(const std::string& filename, int supress_error = 0);
- static int rename(const std::string& filename,const std::string& newname);
+ static int rename(const std::string& filename,const std::string& newname, int supress_error = 0);
static bool copy(const std::string from, const std::string to);
static int stat(const std::string& filename,llstat* file_status);
diff --git a/indra/llcommon/tests/llsdserialize_test.cpp b/indra/llcommon/tests/llsdserialize_test.cpp
index 8836230640..745e3a168c 100644
--- a/indra/llcommon/tests/llsdserialize_test.cpp
+++ b/indra/llcommon/tests/llsdserialize_test.cpp
@@ -513,19 +513,20 @@ namespace tut
const std::string& msg,
const std::string& in,
const LLSD& expected_value,
- S32 expected_count)
+ S32 expected_count,
+ S32 depth_limit = -1)
{
std::stringstream input;
input.str(in);
LLSD parsed_result;
mParser->reset(); // reset() call is needed since test code re-uses mParser
- S32 parsed_count = mParser->parse(input, parsed_result, in.size());
+ S32 parsed_count = mParser->parse(input, parsed_result, in.size(), depth_limit);
ensure_equals(msg.c_str(), parsed_result, expected_value);
// This count check is really only useful for expected
// parse failures, since the ensures equal will already
- // require eqality.
+ // require equality.
std::string count_msg(msg);
count_msg += " (count)";
ensure_equals(count_msg, parsed_count, expected_count);
@@ -714,6 +715,43 @@ namespace tut
expected,
1);
}
+
+ template<> template<>
+ void TestLLSDXMLParsingObject::test<5>()
+ {
+ // test deeper nested levels
+ LLSD level_5 = LLSD::emptyMap(); level_5["level_5"] = 42.f;
+ LLSD level_4 = LLSD::emptyMap(); level_4["level_4"] = level_5;
+ LLSD level_3 = LLSD::emptyMap(); level_3["level_3"] = level_4;
+ LLSD level_2 = LLSD::emptyMap(); level_2["level_2"] = level_3;
+ LLSD level_1 = LLSD::emptyMap(); level_1["level_1"] = level_2;
+ LLSD level_0 = LLSD::emptyMap(); level_0["level_0"] = level_1;
+
+ LLSD v;
+ v["deep"] = level_0;
+
+ ensureParse(
+ "deep llsd xml map",
+ "<llsd><map>"
+ "<key>deep</key><map>"
+ "<key>level_0</key><map>"
+ "<key>level_1</key><map>"
+ "<key>level_2</key><map>"
+ "<key>level_3</key><map>"
+ "<key>level_4</key><map>"
+ "<key>level_5</key><real>42.0</real>"
+ "</map>"
+ "</map>"
+ "</map>"
+ "</map>"
+ "</map>"
+ "</map>"
+ "</map></llsd>",
+ v,
+ 8);
+ }
+
+
/*
TODO:
test XML parsing
@@ -975,6 +1013,146 @@ namespace tut
LLSDParser::PARSE_FAILURE);
}
+ template<> template<>
+ void TestLLSDNotationParsingObject::test<18>()
+ {
+ LLSD level_1 = LLSD::emptyMap(); level_1["level_2"] = 99;
+ LLSD level_0 = LLSD::emptyMap(); level_0["level_1"] = level_1;
+
+ LLSD deep = LLSD::emptyMap();
+ deep["level_0"] = level_0;
+
+ LLSD root = LLSD::emptyMap();
+ root["deep"] = deep;
+
+ ensureParse(
+ "nested notation 3 deep",
+ "{'deep' : {'level_0':{'level_1':{'level_2': i99} } } }",
+ root,
+ 5,
+ 5); // 4 '{' plus i99 also counts as llsd, so real depth is 5
+ }
+
+ template<> template<>
+ void TestLLSDNotationParsingObject::test<19>()
+ {
+ LLSD level_9 = LLSD::emptyMap(); level_9["level_9"] = (S32)99;
+ LLSD level_8 = LLSD::emptyMap(); level_8["level_8"] = level_9;
+ LLSD level_7 = LLSD::emptyMap(); level_7["level_7"] = level_8;
+ LLSD level_6 = LLSD::emptyMap(); level_6["level_6"] = level_7;
+ LLSD level_5 = LLSD::emptyMap(); level_5["level_5"] = level_6;
+ LLSD level_4 = LLSD::emptyMap(); level_4["level_4"] = level_5;
+ LLSD level_3 = LLSD::emptyMap(); level_3["level_3"] = level_4;
+ LLSD level_2 = LLSD::emptyMap(); level_2["level_2"] = level_3;
+ LLSD level_1 = LLSD::emptyMap(); level_1["level_1"] = level_2;
+ LLSD level_0 = LLSD::emptyMap(); level_0["level_0"] = level_1;
+
+ LLSD deep = LLSD::emptyMap();
+ deep["deep"] = level_0;
+
+ ensureParse(
+ "nested notation 10 deep",
+ "{'deep' : {'level_0':{'level_1':{'level_2':{'level_3':{'level_4':{'level_5':{'level_6':{'level_7':{'level_8':{'level_9':i99}"
+ "} } } } } } } } } }",
+ deep,
+ 12,
+ 15);
+ }
+
+ template<> template<>
+ void TestLLSDNotationParsingObject::test<20>()
+ {
+ LLSD end = LLSD::emptyMap(); end["end"] = (S32)99;
+
+ LLSD level_49 = LLSD::emptyMap(); level_49["level_49"] = end;
+ LLSD level_48 = LLSD::emptyMap(); level_48["level_48"] = level_49;
+ LLSD level_47 = LLSD::emptyMap(); level_47["level_47"] = level_48;
+ LLSD level_46 = LLSD::emptyMap(); level_46["level_46"] = level_47;
+ LLSD level_45 = LLSD::emptyMap(); level_45["level_45"] = level_46;
+ LLSD level_44 = LLSD::emptyMap(); level_44["level_44"] = level_45;
+ LLSD level_43 = LLSD::emptyMap(); level_43["level_43"] = level_44;
+ LLSD level_42 = LLSD::emptyMap(); level_42["level_42"] = level_43;
+ LLSD level_41 = LLSD::emptyMap(); level_41["level_41"] = level_42;
+ LLSD level_40 = LLSD::emptyMap(); level_40["level_40"] = level_41;
+
+ LLSD level_39 = LLSD::emptyMap(); level_39["level_39"] = level_40;
+ LLSD level_38 = LLSD::emptyMap(); level_38["level_38"] = level_39;
+ LLSD level_37 = LLSD::emptyMap(); level_37["level_37"] = level_38;
+ LLSD level_36 = LLSD::emptyMap(); level_36["level_36"] = level_37;
+ LLSD level_35 = LLSD::emptyMap(); level_35["level_35"] = level_36;
+ LLSD level_34 = LLSD::emptyMap(); level_34["level_34"] = level_35;
+ LLSD level_33 = LLSD::emptyMap(); level_33["level_33"] = level_34;
+ LLSD level_32 = LLSD::emptyMap(); level_32["level_32"] = level_33;
+ LLSD level_31 = LLSD::emptyMap(); level_31["level_31"] = level_32;
+ LLSD level_30 = LLSD::emptyMap(); level_30["level_30"] = level_31;
+
+ LLSD level_29 = LLSD::emptyMap(); level_29["level_29"] = level_30;
+ LLSD level_28 = LLSD::emptyMap(); level_28["level_28"] = level_29;
+ LLSD level_27 = LLSD::emptyMap(); level_27["level_27"] = level_28;
+ LLSD level_26 = LLSD::emptyMap(); level_26["level_26"] = level_27;
+ LLSD level_25 = LLSD::emptyMap(); level_25["level_25"] = level_26;
+ LLSD level_24 = LLSD::emptyMap(); level_24["level_24"] = level_25;
+ LLSD level_23 = LLSD::emptyMap(); level_23["level_23"] = level_24;
+ LLSD level_22 = LLSD::emptyMap(); level_22["level_22"] = level_23;
+ LLSD level_21 = LLSD::emptyMap(); level_21["level_21"] = level_22;
+ LLSD level_20 = LLSD::emptyMap(); level_20["level_20"] = level_21;
+
+ LLSD level_19 = LLSD::emptyMap(); level_19["level_19"] = level_20;
+ LLSD level_18 = LLSD::emptyMap(); level_18["level_18"] = level_19;
+ LLSD level_17 = LLSD::emptyMap(); level_17["level_17"] = level_18;
+ LLSD level_16 = LLSD::emptyMap(); level_16["level_16"] = level_17;
+ LLSD level_15 = LLSD::emptyMap(); level_15["level_15"] = level_16;
+ LLSD level_14 = LLSD::emptyMap(); level_14["level_14"] = level_15;
+ LLSD level_13 = LLSD::emptyMap(); level_13["level_13"] = level_14;
+ LLSD level_12 = LLSD::emptyMap(); level_12["level_12"] = level_13;
+ LLSD level_11 = LLSD::emptyMap(); level_11["level_11"] = level_12;
+ LLSD level_10 = LLSD::emptyMap(); level_10["level_10"] = level_11;
+
+ LLSD level_9 = LLSD::emptyMap(); level_9["level_9"] = level_10;
+ LLSD level_8 = LLSD::emptyMap(); level_8["level_8"] = level_9;
+ LLSD level_7 = LLSD::emptyMap(); level_7["level_7"] = level_8;
+ LLSD level_6 = LLSD::emptyMap(); level_6["level_6"] = level_7;
+ LLSD level_5 = LLSD::emptyMap(); level_5["level_5"] = level_6;
+ LLSD level_4 = LLSD::emptyMap(); level_4["level_4"] = level_5;
+ LLSD level_3 = LLSD::emptyMap(); level_3["level_3"] = level_4;
+ LLSD level_2 = LLSD::emptyMap(); level_2["level_2"] = level_3;
+ LLSD level_1 = LLSD::emptyMap(); level_1["level_1"] = level_2;
+ LLSD level_0 = LLSD::emptyMap(); level_0["level_0"] = level_1;
+
+ LLSD deep = LLSD::emptyMap();
+ deep["deep"] = level_0;
+
+ ensureParse(
+ "nested notation deep",
+ "{'deep':"
+ "{'level_0' :{'level_1' :{'level_2' :{'level_3' :{'level_4' :{'level_5' :{'level_6' :{'level_7' :{'level_8' :{'level_9' :"
+ "{'level_10':{'level_11':{'level_12':{'level_13':{'level_14':{'level_15':{'level_16':{'level_17':{'level_18':{'level_19':"
+ "{'level_20':{'level_21':{'level_22':{'level_23':{'level_24':{'level_25':{'level_26':{'level_27':{'level_28':{'level_29':"
+ "{'level_30':{'level_31':{'level_32':{'level_33':{'level_34':{'level_35':{'level_36':{'level_37':{'level_38':{'level_39':"
+ "{'level_40':{'level_41':{'level_42':{'level_43':{'level_44':{'level_45':{'level_46':{'level_47':{'level_48':{'level_49':"
+ "{'end':i99}"
+ "} } } } } } } } } }"
+ "} } } } } } } } } }"
+ "} } } } } } } } } }"
+ "} } } } } } } } } }"
+ "} } } } } } } } } }"
+ "}",
+ deep,
+ 53);
+ }
+
+ template<> template<>
+ void TestLLSDNotationParsingObject::test<21>()
+ {
+ ensureParse(
+ "nested notation 10 deep",
+ "{'deep' : {'level_0':{'level_1':{'level_2':{'level_3':{'level_4':{'level_5':{'level_6':{'level_7':{'level_8':{'level_9':i99}"
+ "} } } } } } } } } }",
+ LLSD(),
+ LLSDParser::PARSE_FAILURE,
+ 9);
+ }
+
/**
* @class TestLLSDBinaryParsing
* @brief Concrete instance of a parse tester.