Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added test for the GCD algorithm #3061

Closed
anhpham197 opened this issue May 23, 2022 · 2 comments
Closed

Added test for the GCD algorithm #3061

anhpham197 opened this issue May 23, 2022 · 2 comments
Assignees
Labels

Comments

@anhpham197
Copy link
Contributor

I saw that there was no testing for GCD algorithm, so I decided to write some test for the function gcd (int num1, int num2) based on MC/DC standard.

dir: src/test/java/com.thealgorithms/maths/GCDTest

`package com.thealgorithms.maths;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class GCDTest {

@Test
void test1() {
    Assertions.assertThrows(ArithmeticException.class, () -> GCD.gcd(-1,0));
}

@Test
void test2() {
    Assertions.assertThrows(ArithmeticException.class, () -> GCD.gcd(10, -2));
}

@Test
void test3() {
    Assertions.assertThrows(ArithmeticException.class, () -> GCD.gcd(-5, -3));
}

@Test
void test4() {
    Assertions.assertEquals(GCD.gcd(0, 2), 2);
}

@Test
void test5() {
    Assertions.assertEquals(GCD.gcd(10, 0), 10);
}

@Test
void test6() {
    Assertions.assertEquals(GCD.gcd(1, 0), 1);
}

@Test
void test7() {
    Assertions.assertEquals(GCD.gcd(9, 6), 3);
}

}`

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Jun 25, 2022
@github-actions
Copy link

github-actions bot commented Jul 2, 2022

Please reopen this issue once you add more information and updates here. If this is not the case and you need some help, feel free to seek help from our Gitter or ping one of the reviewers. Thank you for your contributions!

@github-actions github-actions bot closed this as completed Jul 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant