Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alignment with https://github.com/BHoM/BHoM_Engine/pull/3430 #22

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DiffingTests/HashTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ public void PropertyNumericTolerance_DifferentObjects_IncreasingTolerance()
Node node1 = new Node();
node1.Position = new Point() { X = 0, Y = 0, Z = 0 };
Node node2 = new Node();
node2.Position = new Point() { X = 0.0003, Y = 0.0003, Z = 0.9 }; // X and Y have very small variation, Z has large variation.
node2.Position = new Point() { X = 0.0003, Y = 0.0003, Z = 0.4 }; // X and Y have very small variation, Z has large variation.

// With the default tolerance, the objects must be seen as different.
Assert.IsTrue(node1.Hash(cc) != node2.Hash(cc));
Expand Down Expand Up @@ -745,7 +745,7 @@ public void PropertyNumericTolerance_DifferentObjects_SeenAsEqual()
Node node1 = new Node();
node1.Position = new Point() { X = 0, Y = 0, Z = 0 };
Node node2 = new Node();
node2.Position = new Point() { X = 0.0003, Y = 0.0003, Z = 0.9 }; // X and Y have very small variation, Z has large variation.
node2.Position = new Point() { X = 0.0003, Y = 0.0003, Z = 0.4 }; // X and Y have very small variation, Z has large variation.

// With the default tolerance, the objects must be seen as different.
Assert.IsTrue(node1.Hash(cc) != node2.Hash(cc));
Expand Down
26 changes: 13 additions & 13 deletions DiffingTests/Query/RoundWithTolerance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,36 @@ public partial class Query
[Test]
[TestCase(1.2345, 1.1, 1.1)]
[TestCase(1.2345, 1, 1)]
[TestCase(0.9999, 1, 0)]
[TestCase(12, 20, 0)]
[TestCase(0.9999, 1, 1)]
[TestCase(12, 20, 20)]
[TestCase(12, 200, 0)]
[TestCase(121, 2, 120)]
[TestCase(121, 2, 122)]
[TestCase(0.014, 0.01, 0.01)]
[TestCase(0.014, 0.02, 0)]
[TestCase(0.016, 0.02, 0)]
[TestCase(0.014, 0.02, 0.02)]
[TestCase(0.016, 0.02, 0.02)]
[TestCase(0.02, 0.02, 0.02)]
[TestCase(0.03, 0.02, 0.02)]
[TestCase(0.03, 0.02, 0.04)]
[TestCase(-0.02, 0.02, -0.02)]
[TestCase(-0.016, 0.02, 0)]
[TestCase(-121, 2, -120)]
[TestCase(-0.016, 0.02, -0.02)]
[TestCase(-121, 2, -122)]
[TestCase(-122, 2, -122)]
public void RoundWithTolerance(double number, double tolerance, double expected)
{
var result = BH.Engine.Base.Query.RoundWithTolerance(number, tolerance);
var result = BH.Engine.Base.Query.Round(number, tolerance);
Assert.IsTrue(result == expected, $"Returned value was {result} instead of {expected}.");
}

[Test]
[TestCase(10, 10, 10)]
[TestCase(10, 20, 0)]
[TestCase(30, 20, 20)]
[TestCase(10, 20, 20)]
[TestCase(30, 20, 40)]
[TestCase(40, 20, 40)]
[TestCase(-30, 20, -20)]
[TestCase(-30, 20, -40)]
[TestCase(-40, 20, -40)]
public void RoundWithTolerance_Integers(int number, double tolerance, int expected)
{
// This method tests the integer-specific version.
var result = BH.Engine.Base.Query.RoundWithTolerance(number, tolerance);
var result = BH.Engine.Base.Query.Round(number, tolerance);
Assert.IsTrue(result == expected, $"Returned value was {result} instead of {expected}.");
}
}
Expand Down