Skip to content

Commit 045612f

Browse files
Add tolerance to 32 bit tests
1 parent cfd1232 commit 045612f

File tree

3 files changed

+49
-24
lines changed

3 files changed

+49
-24
lines changed

.gitattributes

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
# Set default behavior to:
33
# treat as text and
44
# normalize to Unix-style line endings
5+
###############################################################################
56
* text eol=lf
7+
###############################################################################
68
# Set explicit file behavior to:
9+
# treat as text and
10+
# normalize to Unix-style line endings
11+
###############################################################################
712
*.asm text eol=lf
813
*.c text eol=lf
914
*.clj text eol=lf
@@ -48,19 +53,35 @@
4853
*.txt text eol=lf
4954
*.vb text eol=lf
5055
*.yml text eol=lf
56+
###############################################################################
57+
# Set explicit file behavior to:
5158
# treat as text
5259
# normalize to Unix-style line endings and
5360
# diff as csharp
61+
###############################################################################
5462
*.cs text eol=lf diff=csharp
63+
###############################################################################
64+
# Set explicit file behavior to:
65+
# treat as text
66+
# normalize to Unix-style line endings and
5567
# use a union merge when resoling conflicts
68+
###############################################################################
5669
*.csproj text eol=lf merge=union
5770
*.dbproj text eol=lf merge=union
5871
*.fsproj text eol=lf merge=union
5972
*.ncrunchproject text eol=lf merge=union
6073
*.vbproj text eol=lf merge=union
74+
###############################################################################
75+
# Set explicit file behavior to:
76+
# treat as text
6177
# normalize to Windows-style line endings and
78+
# use a union merge when resoling conflicts
79+
###############################################################################
6280
*.sln text eol=crlf merge=union
81+
###############################################################################
82+
# Set explicit file behavior to:
6383
# treat as binary
84+
###############################################################################
6485
*.basis binary
6586
*.bmp binary
6687
*.dds binary
@@ -89,7 +110,10 @@
89110
*.woff2 binary
90111
*.xls binary
91112
*.xlsx binary
113+
###############################################################################
114+
# Set explicit file behavior to:
92115
# diff as plain text
116+
###############################################################################
93117
*.doc diff=astextplain
94118
*.docx diff=astextplain
95119
*.dot diff=astextplain
@@ -98,12 +122,3 @@
98122
*.rtf diff=astextplain
99123
*.svg diff=astextplain
100124
*.jpg,*.jpeg,*.bmp,*.gif,*.png,*.tif,*.tiff,*.tga,*.webp filter=lfs diff=lfs merge=lfs -text
101-
*.jpg filter=lfs diff=lfs merge=lfs -text
102-
*.jpeg filter=lfs diff=lfs merge=lfs -text
103-
*.bmp filter=lfs diff=lfs merge=lfs -text
104-
*.gif filter=lfs diff=lfs merge=lfs -text
105-
*.png filter=lfs diff=lfs merge=lfs -text
106-
*.tif filter=lfs diff=lfs merge=lfs -text
107-
*.tiff filter=lfs diff=lfs merge=lfs -text
108-
*.tga filter=lfs diff=lfs merge=lfs -text
109-
*.webp filter=lfs diff=lfs merge=lfs -text

tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Apache License, Version 2.0.
33

4+
using System.Globalization;
45
using SixLabors.ImageSharp.PixelFormats;
56
using SixLabors.ImageSharp.Processing;
67
using SixLabors.ImageSharp.Processing.Processors.Binarization;
@@ -64,7 +65,7 @@ public void ImageShouldApplyBinarySaturationThresholdFilter<TPixel>(TestImagePro
6465
{
6566
image.Mutate(x => x.BinaryThreshold(value, BinaryThresholdColorComponent.Saturation));
6667
image.DebugSave(provider, value);
67-
image.CompareToReferenceOutput(ImageComparer.Exact, provider, value.ToString("0.00", System.Globalization.NumberFormatInfo.InvariantInfo));
68+
image.CompareToReferenceOutput(ImageComparer.Exact, provider, value.ToString("0.00", NumberFormatInfo.InvariantInfo));
6869
}
6970
}
7071

@@ -80,7 +81,7 @@ public void ImageShouldApplyBinarySaturationThresholdInBox<TPixel>(TestImageProv
8081

8182
image.Mutate(x => x.BinaryThreshold(value, BinaryThresholdColorComponent.Saturation, bounds));
8283
image.DebugSave(provider, value);
83-
image.CompareToReferenceOutput(ImageComparer.Exact, provider, value.ToString("0.00", System.Globalization.NumberFormatInfo.InvariantInfo));
84+
image.CompareToReferenceOutput(ImageComparer.Exact, provider, value.ToString("0.00", NumberFormatInfo.InvariantInfo));
8485
}
8586
}
8687

@@ -93,7 +94,16 @@ public void ImageShouldApplyBinaryMaxChromaThresholdFilter<TPixel>(TestImageProv
9394
{
9495
image.Mutate(x => x.BinaryThreshold(value, BinaryThresholdColorComponent.MaxChroma));
9596
image.DebugSave(provider, value);
96-
image.CompareToReferenceOutput(ImageComparer.Exact, provider, value.ToString("0.00", System.Globalization.NumberFormatInfo.InvariantInfo));
97+
98+
if (!TestEnvironment.Is64BitProcess && TestEnvironment.IsFramework)
99+
{
100+
var comparer = ImageComparer.TolerantPercentage(0.0004F);
101+
image.CompareToReferenceOutput(comparer, provider, value.ToString("0.00", NumberFormatInfo.InvariantInfo));
102+
}
103+
else
104+
{
105+
image.CompareToReferenceOutput(ImageComparer.Exact, provider, value.ToString("0.00", NumberFormatInfo.InvariantInfo));
106+
}
97107
}
98108
}
99109

@@ -109,7 +119,16 @@ public void ImageShouldApplyBinaryMaxChromaThresholdInBox<TPixel>(TestImageProvi
109119

110120
image.Mutate(x => x.BinaryThreshold(value, BinaryThresholdColorComponent.MaxChroma, bounds));
111121
image.DebugSave(provider, value);
112-
image.CompareToReferenceOutput(ImageComparer.Exact, provider, value.ToString("0.00", System.Globalization.NumberFormatInfo.InvariantInfo));
122+
123+
if (!TestEnvironment.Is64BitProcess && TestEnvironment.IsFramework)
124+
{
125+
var comparer = ImageComparer.TolerantPercentage(0.0004F);
126+
image.CompareToReferenceOutput(comparer, provider, value.ToString("0.00", NumberFormatInfo.InvariantInfo));
127+
}
128+
else
129+
{
130+
image.CompareToReferenceOutput(ImageComparer.Exact, provider, value.ToString("0.00", NumberFormatInfo.InvariantInfo));
131+
}
113132
}
114133
}
115134
}

tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using System.Linq;
88
using System.Reflection;
99
using System.Runtime.InteropServices;
10-
using SixLabors.ImageSharp.Memory;
1110

1211
namespace SixLabors.ImageSharp.Tests
1312
{
@@ -25,19 +24,11 @@ public static partial class TestEnvironment
2524

2625
private static readonly Lazy<string> SolutionDirectoryFullPathLazy = new Lazy<string>(GetSolutionDirectoryFullPathImpl);
2726

28-
private static readonly Lazy<bool> RunsOnCiLazy = new Lazy<bool>(
29-
() =>
30-
{
31-
bool isCi;
32-
return bool.TryParse(Environment.GetEnvironmentVariable("CI"), out isCi) && isCi;
33-
});
27+
private static readonly Lazy<bool> RunsOnCiLazy = new Lazy<bool>(() => bool.TryParse(Environment.GetEnvironmentVariable("CI"), out bool isCi) && isCi);
3428

3529
private static readonly Lazy<string> NetCoreVersionLazy = new Lazy<string>(GetNetCoreVersion);
3630

37-
static TestEnvironment()
38-
{
39-
PrepareRemoteExecutor();
40-
}
31+
static TestEnvironment() => PrepareRemoteExecutor();
4132

4233
/// <summary>
4334
/// Gets the .NET Core version, if running on .NET Core, otherwise returns an empty string.

0 commit comments

Comments
 (0)