From 822f3a0e74403f58cf0d1d0a8c4552fdcac02a5b Mon Sep 17 00:00:00 2001 From: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> Date: Sat, 1 Feb 2025 19:57:56 +0200 Subject: [PATCH] pythagorean-triplet: Add generator and regenerate tests --- .../practice/pythagorean-triplet/.meta/generator.tpl | 12 ++++++++++++ .../test/pythagorean_triplet_test.clj | 12 ++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 exercises/practice/pythagorean-triplet/.meta/generator.tpl diff --git a/exercises/practice/pythagorean-triplet/.meta/generator.tpl b/exercises/practice/pythagorean-triplet/.meta/generator.tpl new file mode 100644 index 000000000..57885e23a --- /dev/null +++ b/exercises/practice/pythagorean-triplet/.meta/generator.tpl @@ -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}} diff --git a/exercises/practice/pythagorean-triplet/test/pythagorean_triplet_test.clj b/exercises/practice/pythagorean-triplet/test/pythagorean_triplet_test.clj index 096a1fe67..3359f4a16 100644 --- a/exercises/practice/pythagorean-triplet/test/pythagorean_triplet_test.clj +++ b/exercises/practice/pythagorean-triplet/test/pythagorean_triplet_test.clj @@ -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"