Added small tests for deconstructors

This commit is contained in:
Gerard Gunnewijk 2019-05-01 17:18:06 +02:00
Родитель 3356538284
Коммит 62f1cee898
6 изменённых файлов: 126 добавлений и 6 удалений

Просмотреть файл

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -191,5 +191,20 @@ namespace SixLabors.Primitives.Tests
var p = new PointF(5.1F, -5.123F); var p = new PointF(5.1F, -5.123F);
Assert.Equal(string.Format(CultureInfo.CurrentCulture, "PointF [ X={0}, Y={1} ]", p.X, p.Y), p.ToString()); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "PointF [ X={0}, Y={1} ]", p.X, p.Y), p.ToString());
} }
[Theory]
[InlineData(float.MaxValue, float.MinValue)]
[InlineData(float.MinValue, float.MinValue)]
[InlineData(float.MaxValue, float.MaxValue)]
[InlineData(0, 0)]
public void DeconstructTest(float x, float y)
{
PointF p = new PointF(x, y);
(float deconstructedX, float deconstructedY) = p;
Assert.Equal(x, deconstructedX);
Assert.Equal(y, deconstructedY);
}
} }
} }

Просмотреть файл

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -239,5 +239,20 @@ namespace SixLabors.Primitives.Tests
var p = new Point(5, -5); var p = new Point(5, -5);
Assert.Equal(string.Format(CultureInfo.CurrentCulture, "Point [ X={0}, Y={1} ]", p.X, p.Y), p.ToString()); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "Point [ X={0}, Y={1} ]", p.X, p.Y), p.ToString());
} }
[Theory]
[InlineData(int.MaxValue, int.MinValue)]
[InlineData(int.MinValue, int.MinValue)]
[InlineData(int.MaxValue, int.MaxValue)]
[InlineData(0, 0)]
public void DeconstructTest(int x, int y)
{
Point p = new Point(x, y);
(int deconstructedX, int deconstructedY) = p;
Assert.Equal(x, deconstructedX);
Assert.Equal(y, deconstructedY);
}
} }
} }

Просмотреть файл

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -252,5 +252,35 @@ namespace SixLabors.Primitives.Tests
var r = new RectangleF(5, 5.1F, 1.3F, 1); var r = new RectangleF(5, 5.1F, 1.3F, 1);
Assert.Equal(string.Format(CultureInfo.CurrentCulture, "RectangleF [ X={0}, Y={1}, Width={2}, Height={3} ]", r.X, r.Y, r.Width, r.Height), r.ToString()); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "RectangleF [ X={0}, Y={1}, Width={2}, Height={3} ]", r.X, r.Y, r.Width, r.Height), r.ToString());
} }
[Theory]
[InlineData(float.MinValue, float.MaxValue, float.MaxValue, float.MaxValue)]
[InlineData(float.MinValue, float.MaxValue, float.MaxValue, float.MinValue)]
[InlineData(float.MinValue, float.MaxValue, float.MinValue, float.MaxValue)]
[InlineData(float.MinValue, float.MaxValue, float.MinValue, float.MinValue)]
[InlineData(float.MinValue, float.MinValue, float.MaxValue, float.MaxValue)]
[InlineData(float.MinValue, float.MinValue, float.MaxValue, float.MinValue)]
[InlineData(float.MinValue, float.MinValue, float.MinValue, float.MaxValue)]
[InlineData(float.MinValue, float.MinValue, float.MinValue, float.MinValue)]
[InlineData(float.MaxValue, float.MaxValue, float.MaxValue, float.MaxValue)]
[InlineData(float.MaxValue, float.MaxValue, float.MaxValue, float.MinValue)]
[InlineData(float.MaxValue, float.MaxValue, float.MinValue, float.MaxValue)]
[InlineData(float.MaxValue, float.MaxValue, float.MinValue, float.MinValue)]
[InlineData(float.MaxValue, float.MinValue, float.MaxValue, float.MaxValue)]
[InlineData(float.MaxValue, float.MinValue, float.MaxValue, float.MinValue)]
[InlineData(float.MaxValue, float.MinValue, float.MinValue, float.MaxValue)]
[InlineData(float.MaxValue, float.MinValue, float.MinValue, float.MinValue)]
[InlineData(0, 0, 0, 0)]
public void DeconstructTest(float x, float y, float width, float height)
{
RectangleF r = new RectangleF(x, y, width, height);
(float dx, float dy, float dw, float dh) = r;
Assert.Equal(x, dx);
Assert.Equal(y, dy);
Assert.Equal(width, dw);
Assert.Equal(height, dh);
}
} }
} }

Просмотреть файл

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -294,5 +294,35 @@ namespace SixLabors.Primitives.Tests
var r = new Rectangle(5, -5, 0, 1); var r = new Rectangle(5, -5, 0, 1);
Assert.Equal(string.Format(CultureInfo.CurrentCulture, "Rectangle [ X={0}, Y={1}, Width={2}, Height={3} ]", r.X, r.Y, r.Width, r.Height), r.ToString()); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "Rectangle [ X={0}, Y={1}, Width={2}, Height={3} ]", r.X, r.Y, r.Width, r.Height), r.ToString());
} }
[Theory]
[InlineData(int.MinValue, int.MaxValue, int.MaxValue, int.MaxValue)]
[InlineData(int.MinValue, int.MaxValue, int.MaxValue, int.MinValue)]
[InlineData(int.MinValue, int.MaxValue, int.MinValue, int.MaxValue)]
[InlineData(int.MinValue, int.MaxValue, int.MinValue, int.MinValue)]
[InlineData(int.MinValue, int.MinValue, int.MaxValue, int.MaxValue)]
[InlineData(int.MinValue, int.MinValue, int.MaxValue, int.MinValue)]
[InlineData(int.MinValue, int.MinValue, int.MinValue, int.MaxValue)]
[InlineData(int.MinValue, int.MinValue, int.MinValue, int.MinValue)]
[InlineData(int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue)]
[InlineData(int.MaxValue, int.MaxValue, int.MaxValue, int.MinValue)]
[InlineData(int.MaxValue, int.MaxValue, int.MinValue, int.MaxValue)]
[InlineData(int.MaxValue, int.MaxValue, int.MinValue, int.MinValue)]
[InlineData(int.MaxValue, int.MinValue, int.MaxValue, int.MaxValue)]
[InlineData(int.MaxValue, int.MinValue, int.MaxValue, int.MinValue)]
[InlineData(int.MaxValue, int.MinValue, int.MinValue, int.MaxValue)]
[InlineData(int.MaxValue, int.MinValue, int.MinValue, int.MinValue)]
[InlineData(0, 0, 0, 0)]
public void DeconstructTest(int x, int y, int width, int height)
{
Rectangle r = new Rectangle(x, y, width, height);
(int dx, int dy, int dw, int dh) = r;
Assert.Equal(x, dx);
Assert.Equal(y, dy);
Assert.Equal(width, dw);
Assert.Equal(height, dh);
}
} }
} }

Просмотреть файл

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -231,5 +231,20 @@ namespace SixLabors.Primitives.Tests
SizeF expected = new SizeF(width / divisor, height / divisor); SizeF expected = new SizeF(width / divisor, height / divisor);
Assert.Equal(expected, size / divisor); Assert.Equal(expected, size / divisor);
} }
[Theory]
[InlineData(float.MaxValue, float.MinValue)]
[InlineData(float.MinValue, float.MinValue)]
[InlineData(float.MaxValue, float.MaxValue)]
[InlineData(0, 0)]
public void DeconstructTest(float width, float height)
{
SizeF s = new SizeF(width, height);
(float deconstructedWidth, float deconstructedHeight) = s;
Assert.Equal(width, deconstructedWidth);
Assert.Equal(height, deconstructedHeight);
}
} }
} }

Просмотреть файл

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
@ -360,5 +360,20 @@ namespace SixLabors.Primitives.Tests
expected = new SizeF(width / divisor, height / divisor); expected = new SizeF(width / divisor, height / divisor);
Assert.Equal(expected, size / divisor); Assert.Equal(expected, size / divisor);
} }
[Theory]
[InlineData(int.MaxValue, int.MinValue)]
[InlineData(int.MinValue, int.MinValue)]
[InlineData(int.MaxValue, int.MaxValue)]
[InlineData(0, 0)]
public void DeconstructTest(int width, int height)
{
Size s = new Size(width, height);
(int deconstructedWidth, int deconstructedHeight) = s;
Assert.Equal(width, deconstructedWidth);
Assert.Equal(height, deconstructedHeight);
}
} }
} }