Skip to content

Commit

Permalink
pythagorean-triplet: Add generator and regenerate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tasxatzial committed Feb 1, 2025
1 parent 3943afe commit 822f3a0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
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

0 comments on commit 822f3a0

Please sign in to comment.