From 91e57c69f8502c7d295f91e8462fd419f91995b9 Mon Sep 17 00:00:00 2001 From: Jesse Kroon Date: Thu, 1 Feb 2024 08:59:19 +0100 Subject: [PATCH] move item struct to be in the exercise instead of generated test file --- exercises/practice/knapsack/.meta/gen.go | 12 +++++------- exercises/practice/knapsack/cases_test.go | 12 +++++------- exercises/practice/knapsack/knapsack.go | 4 ++++ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/exercises/practice/knapsack/.meta/gen.go b/exercises/practice/knapsack/.meta/gen.go index 7ca7855db..2fe8081b9 100644 --- a/exercises/practice/knapsack/.meta/gen.go +++ b/exercises/practice/knapsack/.meta/gen.go @@ -39,21 +39,19 @@ var tmpl = `package knapsack {{.Header}} -type item struct { - Weight int - Value int -} - type maximumValueCaseInput struct { MaximumWeight int Items []item } -var maximumValueTests = []struct { +type maximumValueTest struct { description string input maximumValueCaseInput expected int -}{ {{range .J.maximumValue}} +} + +var maximumValueTests = []maximumValueTest { + {{range .J.maximumValue}} { description: {{printf "%q" .Description}}, input: maximumValueCaseInput { diff --git a/exercises/practice/knapsack/cases_test.go b/exercises/practice/knapsack/cases_test.go index ca5d2fdf8..a4b559be5 100644 --- a/exercises/practice/knapsack/cases_test.go +++ b/exercises/practice/knapsack/cases_test.go @@ -5,21 +5,19 @@ package knapsack // Source: exercism/problem-specifications // Commit: 6c1d8e2 Knapsack: Fix empty list of items (#2350) -type item struct { - Weight int - Value int -} - type maximumValueCaseInput struct { MaximumWeight int Items []item } -var maximumValueTests = []struct { +type maximumValueTest struct { description string input maximumValueCaseInput expected int -}{ +} + +var maximumValueTests = []maximumValueTest{ + { description: "no items", input: maximumValueCaseInput{ diff --git a/exercises/practice/knapsack/knapsack.go b/exercises/practice/knapsack/knapsack.go index 3ea38d27e..657cd2313 100644 --- a/exercises/practice/knapsack/knapsack.go +++ b/exercises/practice/knapsack/knapsack.go @@ -1,5 +1,9 @@ package knapsack +type item struct { + Weight, Value int +} + func Knapsack(maximumWeight int, items []item) int { return 0 }