-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from Yesser-Studios/improvements
Improve test coverage and used proper naming conventions
- Loading branch information
Showing
12 changed files
with
351 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
namespace yTools.ConsoleTryout | ||
using System.Globalization; | ||
|
||
namespace yTools.ConsoleApp | ||
{ | ||
internal class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
Console.WriteLine(Doubles.maxDouble.ToString()); | ||
Console.WriteLine(Doubles.MaxDouble.ToString(CultureInfo.InvariantCulture)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace yTools.Tests; | ||
|
||
[TestClass] | ||
public class BooleansTests | ||
{ | ||
[TestMethod] | ||
[DataRow(true)] | ||
[DataRow(false)] | ||
public void Invert(bool boolean) | ||
{ | ||
Assert.AreEqual(!boolean, Booleans.Invert(boolean)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
namespace yTools.Tests; | ||
|
||
[TestClass] | ||
public class DoublesTests | ||
{ | ||
[TestMethod] | ||
[DataRow(5, 0)] | ||
[DataRow(5.69, 47.9)] | ||
[DataRow(57979.46, 4798.689, 78.967)] | ||
public void Sum(params double[] nums) | ||
{ | ||
var expected = nums.Sum(); | ||
|
||
var summed = Doubles.Sum(nums); | ||
|
||
Assert.AreEqual(expected, summed); | ||
} | ||
|
||
[TestMethod] | ||
[DataRow(5, 0)] | ||
[DataRow(5.69, 47.9)] | ||
[DataRow(57979.46, 4798.689, 78.967)] | ||
public void Average(params double[] nums) | ||
{ | ||
var expected = nums.Average(); | ||
|
||
var average = Doubles.Average(nums); | ||
|
||
Assert.AreEqual(expected, average); | ||
} | ||
|
||
[TestMethod] | ||
[DataRow(5, 0)] | ||
[DataRow(5.69, 47.9)] | ||
[DataRow(57979.46, 4798.689, 78.967)] | ||
public void Max(params double[] nums) | ||
{ | ||
var expected = nums.Max(); | ||
|
||
var max = Doubles.Max(nums); | ||
|
||
Assert.AreEqual(expected, max); | ||
} | ||
|
||
[TestMethod] | ||
[DataRow(5, 0)] | ||
[DataRow(5.69, 47.9)] | ||
[DataRow(57979.46, 4798.689, 78.967)] | ||
public void Min(params double[] nums) | ||
{ | ||
var expected = nums.Min(); | ||
|
||
var min = Doubles.Min(nums); | ||
|
||
Assert.AreEqual(expected, min); | ||
} | ||
|
||
[TestMethod] | ||
[DataRow(5, 4)] | ||
[DataRow(5.69, 47.9)] | ||
public void Power(double a, double b) | ||
{ | ||
var expected = Math.Pow(a, b); | ||
|
||
var actual = Doubles.Power(a, b); | ||
|
||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[TestMethod] | ||
[DataRow(69)] | ||
[DataRow(4.5)] | ||
[DataRow(47.9)] | ||
public void SquareRoot(double num) | ||
{ | ||
var expected = Math.Sqrt(num); | ||
|
||
var actual = Doubles.SquareRoot(num); | ||
|
||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[TestMethod] | ||
[DataRow(69)] | ||
[DataRow(4.5)] | ||
[DataRow(47.9)] | ||
public void CubeRoot(double num) | ||
{ | ||
var expected = Math.Cbrt(num); | ||
|
||
var actual = Doubles.CubeRoot(num); | ||
|
||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[TestMethod] | ||
[DataRow(5, 4)] | ||
[DataRow(5.69, 47.9)] | ||
public void Add(double a, double b) | ||
{ | ||
var expected = a + b; | ||
|
||
var actual = Doubles.Add(a, b); | ||
|
||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[TestMethod] | ||
[DataRow(5, 4)] | ||
[DataRow(5.69, 47.9)] | ||
public void Subtract(double a, double b) | ||
{ | ||
var expected = a - b; | ||
|
||
var actual = Doubles.Substract(a, b); | ||
|
||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[TestMethod] | ||
[DataRow(5, 4)] | ||
[DataRow(5.69, 47.9)] | ||
public void Multiply(double a, double b) | ||
{ | ||
var expected = a * b; | ||
|
||
var actual = Doubles.Multiply(a, b); | ||
|
||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[TestMethod] | ||
[DataRow(5, 4)] | ||
[DataRow(5.69, 47.9)] | ||
public void Divide(double a, double b) | ||
{ | ||
var expected = a / b; | ||
|
||
var actual = Doubles.Divide(a, b); | ||
|
||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[TestMethod] | ||
[DataRow(5, 4)] | ||
[DataRow(5.69, 47.9)] | ||
public void Remainder(double a, double b) | ||
{ | ||
var expected = a % b; | ||
|
||
var actual = Doubles.Remainder(a, b); | ||
|
||
Assert.AreEqual(expected, actual); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using yTools.Vectors; | ||
|
||
namespace yTools.Tests; | ||
|
||
[TestClass] | ||
public class VectorsTests | ||
{ | ||
[TestMethod] | ||
public void Vector2ToString() | ||
{ | ||
Vector2 vector = new(49.5, 50); | ||
|
||
var expected = $"{vector.X},{vector.Y}"; | ||
var actual = vector.ToString(); | ||
|
||
Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[TestMethod] | ||
public void Vector3ToString() | ||
{ | ||
Vector3 vector = new(49, 50.1, 51); | ||
|
||
var expected = $"{vector.X},{vector.Y},{vector.Z}"; | ||
var actual = vector.ToString(); | ||
|
||
Assert.AreEqual(expected, actual); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.