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

pythagorean-triplet: Add generator and regenerate tests #807

Merged
merged 1 commit into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions exercises/practice/pythagorean-triplet/.meta/generator.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(ns pythagorean-triplet-test
(:require [clojure.test :refer [deftest testing is]]
pythagorean-triplet))

{{#test_cases.tripletsWithSum}}
(deftest find-pythagorean-triplets_test_{{idx}}
(testing {{description}}
(is (= [{{#expected~}}
{{.}}
{{/expected}}]
(pythagorean-triplet/find-pythagorean-triplets {{input.n}})))))
{{/test_cases.tripletsWithSum}}
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@

(deftest find-pythagorean-triplets_test_1
(testing "triplets whose sum is 12"
(is (= [[3 4 5]] (pythagorean-triplet/find-pythagorean-triplets 12)))))
(is (= [[3 4 5]]
(pythagorean-triplet/find-pythagorean-triplets 12)))))

(deftest find-pythagorean-triplets_test_2
(testing "triplets whose sum is 108"
(is (= [[27 36 45]] (pythagorean-triplet/find-pythagorean-triplets 108)))))
(is (= [[27 36 45]]
(pythagorean-triplet/find-pythagorean-triplets 108)))))

(deftest find-pythagorean-triplets_test_3
(testing "triplets whose sum is 1000"
(is (= [[200 375 425]] (pythagorean-triplet/find-pythagorean-triplets 1000)))))
(is (= [[200 375 425]]
(pythagorean-triplet/find-pythagorean-triplets 1000)))))

(deftest find-pythagorean-triplets_test_4
(testing "no matching triplets for 1001"
(is (= [] (pythagorean-triplet/find-pythagorean-triplets 1001)))))
(is (= []
(pythagorean-triplet/find-pythagorean-triplets 1001)))))

(deftest find-pythagorean-triplets_test_5
(testing "returns all matching triplets"
Expand Down