FbxDouble4Test.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // ***********************************************************************
  2. // Copyright (c) 2017 Unity Technologies. All rights reserved.
  3. //
  4. // Licensed under the ##LICENSENAME##.
  5. // See LICENSE.md file in the project root for full license information.
  6. // ***********************************************************************
  7. using NUnit.Framework;
  8. using Autodesk.Fbx;
  9. namespace Autodesk.Fbx.UnitTests
  10. {
  11. /// <summary>
  12. /// Run some tests that any vector type should be able to pass.
  13. /// If you add tests here, you probably want to add them to the other
  14. /// FbxDouble* test classes.
  15. /// </summary>
  16. public class FbxDouble4Test
  17. {
  18. #if ENABLE_COVERAGE_TEST
  19. [Test]
  20. public void TestCoverage() { CoverageTester.TestCoverage(typeof(FbxDouble4), this.GetType()); }
  21. #endif
  22. [Test]
  23. public void TestEquality()
  24. {
  25. EqualityTester<FbxDouble4>.TestEquality(
  26. new FbxDouble4(0, 1, 2, 3),
  27. new FbxDouble4(3, 2, 1, 0),
  28. new FbxDouble4(0, 1, 2, 3));
  29. }
  30. /// <summary>
  31. /// Test the basics. Subclasses should override and add some calls
  32. /// e.g. to excercise all the constructors.
  33. /// </summary>
  34. [Test]
  35. public void TestBasics()
  36. {
  37. FbxDouble4 v;
  38. // make sure the no-arg constructor doesn't crash
  39. new FbxDouble4();
  40. // Test other constructors
  41. v = new FbxDouble4(1, 2, 3, 4);
  42. var u = new FbxDouble4(v);
  43. Assert.AreEqual(v, u);
  44. u[0] = 5;
  45. Assert.AreEqual(5, u[0]);
  46. Assert.AreEqual(1, v[0]); // check that setting u doesn't set v
  47. var w = new FbxDouble4(3);
  48. Assert.AreEqual(3, w[0]);
  49. Assert.AreEqual(3, w[1]);
  50. Assert.AreEqual(3, w[2]);
  51. Assert.AreEqual(3, w[3]);
  52. // Test operator[]
  53. v = new FbxDouble4();
  54. v[0] = 1;
  55. Assert.AreEqual(1, v[0]);
  56. v[1] = 2;
  57. Assert.AreEqual(2, v[1]);
  58. v[2] = 3;
  59. Assert.AreEqual(3, v[2]);
  60. v[3] = 4;
  61. Assert.AreEqual(4, v[3]);
  62. Assert.That(() => v[-1], Throws.Exception.TypeOf<System.ArgumentOutOfRangeException>());
  63. Assert.That(() => v[ 4], Throws.Exception.TypeOf<System.ArgumentOutOfRangeException>());
  64. Assert.That(() => v[-1] = 5, Throws.Exception.TypeOf<System.ArgumentOutOfRangeException>());
  65. Assert.That(() => v[ 4] = 5, Throws.Exception.TypeOf<System.ArgumentOutOfRangeException>());
  66. // Test 4-argument constructor and members X/Y/Z/W
  67. v = new FbxDouble4(1, 2, 3, 4);
  68. Assert.AreEqual(1, v.X);
  69. Assert.AreEqual(2, v.Y);
  70. Assert.AreEqual(3, v.Z);
  71. Assert.AreEqual(4, v.W);
  72. v.X = 3;
  73. v.Y = 4;
  74. v.Z = 5;
  75. v.W = 6;
  76. Assert.AreEqual(3, v.X);
  77. Assert.AreEqual(4, v.Y);
  78. Assert.AreEqual(5, v.Z);
  79. Assert.AreEqual(6, v.W);
  80. v = new FbxDouble4(5);
  81. Assert.AreEqual(5, v.X);
  82. Assert.AreEqual(5, v.Y);
  83. Assert.AreEqual(5, v.Z);
  84. Assert.AreEqual(5, v.W);
  85. }
  86. }
  87. }