summaryrefslogtreecommitdiff
path: root/indra/test
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2017-11-27 10:19:43 -0800
committerRider Linden <rider@lindenlab.com>2017-11-27 10:19:43 -0800
commit66ba27cb91b4f81625b8ab535f41bcf38a2aae99 (patch)
treea542d46607c4360a1648fd53c8dbe03f4690a9a7 /indra/test
parent0bf6386c61c0c28b298c2cccd82c786f754024af (diff)
Added boost::hash<> spec for LLSD
Diffstat (limited to 'indra/test')
-rw-r--r--indra/test/llsdutil_tut.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/indra/test/llsdutil_tut.cpp b/indra/test/llsdutil_tut.cpp
index 140f4b832b..6fce53f335 100644
--- a/indra/test/llsdutil_tut.cpp
+++ b/indra/test/llsdutil_tut.cpp
@@ -386,4 +386,49 @@ namespace tut
lmap["Seattle"] = 72;
ensure("llsd_equals(superset left map)", ! llsd_equals(lmap, rmap));
}
+
+ template<> template<>
+ void llsdutil_object::test<10>()
+ {
+ set_test_name("llsd_hashing");
+
+ {
+ LLSD data_s1 = LLSD::String("The quick brown aardvark jumped over the lazy lemming.");
+ LLSD data_s2 = LLSD::String("The quick brown aardvark jumped over the lazy lemming.");
+
+ ensure("hash: Identical string hashes match.", boost::hash<LLSD>{}(data_s1) == boost::hash<LLSD>{}(data_s2));
+ }
+ {
+ LLSD data_r1 = LLSD::Real(3.0f);
+ LLSD data_i1 = LLSD::Integer(3);
+ ensure("hash: equivalent values but different types do not match.", boost::hash<LLSD>{}(data_r1) != boost::hash<LLSD>{}(data_i1));
+ }
+ {
+ LLSD data_a1 = LLSDArray("A")("B")("C");
+ LLSD data_a2 = LLSDArray("A")("B")("C");
+
+ ensure("hash: identical arrays produce identical results", boost::hash<LLSD>{}(data_a1) == boost::hash<LLSD>{}(data_a2));
+
+ data_a2.append(LLSDArray(1)(2));
+
+ ensure("hash: changing the array changes the hash.", boost::hash<LLSD>{}(data_a1) != boost::hash<LLSD>{}(data_a2));
+
+ data_a1.append(LLSDArray(1)(2));
+ ensure("hash: identical arrays produce identical results with nested arrays", boost::hash<LLSD>{}(data_a1) == boost::hash<LLSD>{}(data_a2));
+ }
+ {
+ LLSD data_m1 = LLSDMap("key1", LLSD::Real(3.0))("key2", "value2")("key3", LLSDArray(1)(2)(3));
+ LLSD data_m2 = LLSDMap("key1", LLSD::Real(3.0))("key2", "value2")("key3", LLSDArray(1)(2)(3));
+
+ ensure("hash: identical maps produce identical results", boost::hash<LLSD>{}(data_m1) == boost::hash<LLSD>{}(data_m2));
+
+ LLSD data_m3 = LLSDMap("key1", LLSD::Real(5.0))("key2", "value2")("key3", LLSDArray(1)(2)(3));
+ ensure("hash: Different values in the map produce different hashes.", boost::hash<LLSD>{}(data_m1) != boost::hash<LLSD>{}(data_m3));
+
+ LLSD data_m4 = LLSDMap("keyA", LLSD::Real(3.0))("key2", "value2")("key3", LLSDArray(1)(2)(3));
+ ensure("hash: Different keys in the map produce different hashes.", boost::hash<LLSD>{}(data_m1) != boost::hash<LLSD>{}(data_m4));
+
+ }
+ }
+
}