diff options
author | Melanie Thielker | 2014-06-21 00:39:55 +0200 |
---|---|---|
committer | Melanie Thielker | 2014-06-21 00:39:55 +0200 |
commit | 159fcbf150b7da0e229b29aa7b94793484543d12 (patch) | |
tree | b8c0ff3b4c758a3fba8315b556c923ef4c02a185 /OpenSim/Framework/Tests/UtilTest.cs | |
parent | Merge commit '68c8633ba18f0a11cfc0ed04d1d0c7c59e6cec76' (diff) | |
parent | Merge branch 'master' into careminster (diff) | |
download | opensim-SC_OLD-159fcbf150b7da0e229b29aa7b94793484543d12.zip opensim-SC_OLD-159fcbf150b7da0e229b29aa7b94793484543d12.tar.gz opensim-SC_OLD-159fcbf150b7da0e229b29aa7b94793484543d12.tar.bz2 opensim-SC_OLD-159fcbf150b7da0e229b29aa7b94793484543d12.tar.xz |
Merge branch 'master' of ssh://3dhosting.de/var/git/careminster
Conflicts:
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
Diffstat (limited to 'OpenSim/Framework/Tests/UtilTest.cs')
-rw-r--r-- | OpenSim/Framework/Tests/UtilTest.cs | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/OpenSim/Framework/Tests/UtilTest.cs b/OpenSim/Framework/Tests/UtilTest.cs index 11ca068..3b7f252 100644 --- a/OpenSim/Framework/Tests/UtilTest.cs +++ b/OpenSim/Framework/Tests/UtilTest.cs | |||
@@ -282,5 +282,87 @@ namespace OpenSim.Framework.Tests | |||
282 | String.Format("Incorrect InventoryType mapped from Content-Type {0}", invcontenttypes[i])); | 282 | String.Format("Incorrect InventoryType mapped from Content-Type {0}", invcontenttypes[i])); |
283 | } | 283 | } |
284 | } | 284 | } |
285 | |||
286 | [Test] | ||
287 | public void FakeParcelIDTests() | ||
288 | { | ||
289 | byte[] hexBytes8 = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 }; | ||
290 | byte[] hexBytes16 = { | ||
291 | 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87, | ||
292 | 0x77, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f }; | ||
293 | UInt64 var64Bit = (UInt64)0xfedcba9876543210; | ||
294 | |||
295 | //Region handle is for location 255000,256000. | ||
296 | ulong regionHandle1 = 1095216660736000; | ||
297 | uint x1 = 100; | ||
298 | uint y1 = 200; | ||
299 | uint z1 = 22; | ||
300 | ulong regionHandle2; | ||
301 | uint x2, y2, z2; | ||
302 | UUID fakeParcelID1, fakeParcelID2, uuid; | ||
303 | |||
304 | ulong bigInt64 = Util.BytesToUInt64Big(hexBytes8); | ||
305 | Assert.AreEqual(var64Bit, bigInt64, | ||
306 | "BytesToUint64Bit conversion of 8 bytes to UInt64 failed."); | ||
307 | |||
308 | //Test building and decoding using some typical input values | ||
309 | fakeParcelID1 = Util.BuildFakeParcelID(regionHandle1, x1, y1); | ||
310 | Util.ParseFakeParcelID(fakeParcelID1, out regionHandle2, out x2, out y2); | ||
311 | Assert.AreEqual(regionHandle1, regionHandle2, | ||
312 | "region handle decoded from FakeParcelID wth X/Y failed."); | ||
313 | Assert.AreEqual(x1, x2, | ||
314 | "X coordinate decoded from FakeParcelID wth X/Y failed."); | ||
315 | Assert.AreEqual(y1, y2, | ||
316 | "Y coordinate decoded from FakeParcelID wth X/Y failed."); | ||
317 | |||
318 | fakeParcelID1 = Util.BuildFakeParcelID(regionHandle1, x1, y1, z1); | ||
319 | Util.ParseFakeParcelID(fakeParcelID1, out regionHandle2, out x2, out y2, out z2); | ||
320 | Assert.AreEqual(regionHandle1, regionHandle2, | ||
321 | "region handle decoded from FakeParcelID with X/Y/Z failed."); | ||
322 | Assert.AreEqual(x1, x2, | ||
323 | "X coordinate decoded from FakeParcelID with X/Y/Z failed."); | ||
324 | Assert.AreEqual(y1, y2, | ||
325 | "Y coordinate decoded from FakeParcelID with X/Y/Z failed."); | ||
326 | Assert.AreEqual(z1, z2, | ||
327 | "Z coordinate decoded from FakeParcelID with X/Y/Z failed."); | ||
328 | |||
329 | //Do some more extreme tests to check the encoding and decoding | ||
330 | x1 = 0x55aa; | ||
331 | y1 = 0x9966; | ||
332 | z1 = 0x5a96; | ||
333 | |||
334 | fakeParcelID1 = Util.BuildFakeParcelID(var64Bit, x1, y1); | ||
335 | Util.ParseFakeParcelID(fakeParcelID1, out regionHandle2, out x2, out y2); | ||
336 | Assert.AreEqual(var64Bit, regionHandle2, | ||
337 | "region handle decoded from FakeParcelID with X/Y/Z failed."); | ||
338 | Assert.AreEqual(x1, x2, | ||
339 | "X coordinate decoded from FakeParcelID with X/Y/Z failed."); | ||
340 | Assert.AreEqual(y1, y2, | ||
341 | "Y coordinate decoded from FakeParcelID with X/Y/Z failed."); | ||
342 | |||
343 | fakeParcelID1 = Util.BuildFakeParcelID(var64Bit, x1, y1, z1); | ||
344 | Util.ParseFakeParcelID(fakeParcelID1, out regionHandle2, out x2, out y2, out z2); | ||
345 | Assert.AreEqual(var64Bit, regionHandle2, | ||
346 | "region handle decoded from FakeParcelID with X/Y/Z failed."); | ||
347 | Assert.AreEqual(x1, x2, | ||
348 | "X coordinate decoded from FakeParcelID with X/Y/Z failed."); | ||
349 | Assert.AreEqual(y1, y2, | ||
350 | "Y coordinate decoded from FakeParcelID with X/Y/Z failed."); | ||
351 | Assert.AreEqual(z1, z2, | ||
352 | "Z coordinate decoded from FakeParcelID with X/Y/Z failed."); | ||
353 | |||
354 | |||
355 | x1 = 64; | ||
356 | y1 = 192; | ||
357 | fakeParcelID1 = Util.BuildFakeParcelID(regionHandle1, x1, y1); | ||
358 | Util.FakeParcelIDToGlobalPosition(fakeParcelID1, out x2, out y2); | ||
359 | Assert.AreEqual(255000+x1, x2, | ||
360 | "Global X coordinate decoded from regionHandle failed."); | ||
361 | Assert.AreEqual(256000+y1, y2, | ||
362 | "Global Y coordinate decoded from regionHandle failed."); | ||
363 | |||
364 | uuid = new UUID("00dd0700-00d1-0700-3800-000032000000"); | ||
365 | Util.FakeParcelIDToGlobalPosition(uuid, out x2, out y2); | ||
366 | } | ||
285 | } | 367 | } |
286 | } | 368 | } |