Skip to content
This repository was archived by the owner on Dec 27, 2023. It is now read-only.

Commit 7cd87bc

Browse files
committed
Bugfix for #1
1 parent 8ef4af5 commit 7cd87bc

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

ColorSharp/src/LightSpectrums/RegularLightSpectrum.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929

3030
using System;
31+
using System.Linq;
3132
using System.Collections.Generic;
3233
using System.Collections.ObjectModel;
3334

@@ -200,15 +201,15 @@ public override bool Equals(Object obj)
200201
if (rls == this) {
201202
return true;
202203
}
203-
if (rls == null || GetHashCode () != rls.GetHashCode ()) {
204+
if (rls == null) {
204205
return false;
205-
}
206+
}
206207

207208
return (
208209
NmPerStep == rls.NmPerStep &&
209210
MinWaveLength == rls.MinWaveLength &&
210211
MaxWaveLength == rls.MaxWaveLength &&
211-
Amplitudes.Equals(rls.Amplitudes)
212+
Amplitudes.SequenceEqual(rls.Amplitudes)
212213
);
213214
}
214215

ColorSharpTests/tests/LightSpectrums/RegularLightSpectrumTest.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ public void TestEvaluateAt()
4848
Assert.AreEqual (20.0, ls.EvaluateAt (200.0), 0.00001);
4949
}
5050

51+
[Test]
52+
public void TestEquality()
53+
{
54+
var ls1 = new RegularLightSpectrum (100.0, 200.0, new [] { 20.0, 50.0, 20.0 });
55+
var ls2 = new RegularLightSpectrum (100.0, 200.0, new [] { 20.0, 50.0, 20.0 });
56+
57+
Assert.AreEqual (ls1, ls2);
58+
Assert.AreEqual (ls2, ls1);
59+
}
60+
5161
[Test]
5262
public void TestToCIEXYZ()
5363
{

0 commit comments

Comments
 (0)