public void Gcd_ShouldReturnCorrectGcd(int expectedGcd, params int[] arguments) { // Arrange // Act var gcd = IntegerGcdCalculator.Gcd(arguments); // Assert gcd.Should().Be(expectedGcd); }
public void Gcd_ShouldReturnCorrectGcd(int a, int b, int expectedGcd) { // Arrange // Act var gcd = IntegerGcdCalculator.Gcd(a, b); // Assert gcd.Should().Be(expectedGcd); }
public void Gcd_IfAnyArgumentIsNegative_ShouldThrowArgumentException(int a, int b) { // Arrange // Act Action action = () => _ = IntegerGcdCalculator.Gcd(a, b); // Assert action.Should().Throw <ArgumentException>(); }
// TODO[mk] add random data generation + output logging public void Gcd_ShouldBeCommutative(int a, int b) { // Arrange // Act var gcdDirect = IntegerGcdCalculator.Gcd(a, b); var gcdInverse = IntegerGcdCalculator.Gcd(b, a); // Assert gcdDirect.Should().Be(gcdInverse); }
// TODO[mk] add random data generation + output logging public void Gcd_ShouldReturnValueWhichDivideToCoprimeQuotients(int a, int b) { // Arrange // Act var gcd = IntegerGcdCalculator.Gcd(a, b); // Assert var quotientA = a / gcd; var quotientB = b / gcd; var quotientsGcd = IntegerGcdCalculator.Gcd(quotientA, quotientB); quotientsGcd.Should().Be(1); }
// TODO[mk] add random data generation + output logging public void Gcd_ShouldReturnValueWhichDivideWithoutRemainder(int a, int b) { // Arrange // Act var gcd = IntegerGcdCalculator.Gcd(a, b); // Assert var remainderA = a % gcd; var remainderB = b % gcd; remainderA.Should().Be(0); remainderB.Should().Be(0); }
/// <summary> /// Calculates Greatest Common Divisor (GCD) /// of arbitrary number of non-negative integer numbers. /// </summary> /// <exception cref="ArgumentException"></exception> public static int Gcd(params int[] arguments) => IntegerGcdCalculator.Gcd(arguments);
/// <summary> /// Calculates Greatest Common Divisor (GCD) /// of two non-negative integer numbers. /// </summary> /// <exception cref="ArgumentException"></exception> public static int Gcd(int a, int b) => IntegerGcdCalculator.Gcd(a, b);