Skip to content

Add tests for gcd function#9

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/add-tests-for-gcd-function
Draft

Add tests for gcd function#9
Copilot wants to merge 4 commits intomainfrom
copilot/add-tests-for-gcd-function

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 2, 2026

Adds test coverage for the gcd (Greatest Common Divisor) function in src/lib.ts.

Changes

  • src/lib_test.ts: 10 test cases covering:
    • Standard GCD calculations
    • Edge cases: zero values, negative inputs, decimal rounding
    • Special cases: coprime numbers, primes, powers of 2

Test Coverage

Tests validate the Euclidean algorithm implementation handles:

  • Absolute value conversion for negatives
  • Math.round() behavior for decimals
  • Identity cases (same numbers, one = 1)
// Example: validates rounding behavior
Deno.test("gcd - decimal numbers (should be rounded)", () => {
  assertEquals(gcd(12.7, 8.3), 1);  // rounds to gcd(13, 8) = 1
  assertEquals(gcd(12.4, 8.4), 4);  // rounds to gcd(12, 8) = 4
});

Run with: deno test src/lib_test.ts

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.deno.land
    • Triggering command: /usr/bin/curl curl -s REDACTED (dns block)
  • jsr.io
    • Triggering command: /tmp/deno deno test src/lib_test.ts (dns block)
    • Triggering command: /tmp/deno deno test --unsafely-ignore-certificate-errors src/lib_test.ts (dns block)
    • Triggering command: /tmp/deno deno cache --reload --unsafely-ignore-certificate-errors src/lib_test.ts (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Add tests for gcd function</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits March 2, 2026 18:07
Co-authored-by: marlonmarcello <1956448+marlonmarcello@users.noreply.github.com>
Co-authored-by: marlonmarcello <1956448+marlonmarcello@users.noreply.github.com>
Co-authored-by: marlonmarcello <1956448+marlonmarcello@users.noreply.github.com>
Copilot AI changed the title [WIP] Add tests for gcd function Add tests for gcd function Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add tests for gcd function

2 participants