summaryrefslogtreecommitdiff
path: root/go/lasagna/lasagna_test.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <sokolyuk@gmail.com>2022-11-22 14:16:16 +0100
committerDimitri Sokolyuk <sokolyuk@gmail.com>2022-11-22 14:16:16 +0100
commit4a01c0d39db1d310d8a4f88b543135be4aa700b4 (patch)
treeaed4069e695047410126f1376d023175741adf5d /go/lasagna/lasagna_test.go
parent62966e2253ff5a045852e46b443c5c2a9e7f9f63 (diff)
finish lasagna
Diffstat (limited to 'go/lasagna/lasagna_test.go')
-rw-r--r--go/lasagna/lasagna_test.go94
1 files changed, 94 insertions, 0 deletions
diff --git a/go/lasagna/lasagna_test.go b/go/lasagna/lasagna_test.go
new file mode 100644
index 0000000..9ed503b
--- /dev/null
+++ b/go/lasagna/lasagna_test.go
@@ -0,0 +1,94 @@
+package lasagna
+
+import "testing"
+
+type lasagnaTests struct {
+ name string
+ layers, time, expected int
+}
+
+func TestOvenTime(t *testing.T) {
+ tests := []lasagnaTests{
+ {
+ name: "Calculates how many minutes the lasagna should be in the oven",
+ layers: 0,
+ time: 40,
+ expected: 40,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ if got := OvenTime; got != tt.expected {
+ t.Errorf("OvenTime(%d) = %d; want %d", tt.expected, got, tt.expected)
+ }
+ })
+ }
+}
+
+func TestRemainingOvenTime(t *testing.T) {
+ tests := []lasagnaTests{
+ {
+ name: "Remaining minutes in oven",
+ layers: 0,
+ time: 15,
+ expected: 25,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ if got := RemainingOvenTime(tt.time); got != tt.expected {
+ t.Errorf("RemainingOvenTime(%d) = %d; want %d", tt.time, got, tt.expected)
+ }
+ })
+ }
+
+}
+func TestPreparationTime(t *testing.T) {
+ tests := []lasagnaTests{
+ {
+ name: "Preparation time in minutes for one layer",
+ layers: 1,
+ time: 0,
+ expected: 2,
+ },
+ {
+ name: "Preparation time in minutes for multiple layers",
+ layers: 4,
+ time: 0,
+ expected: 8,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ if got := PreparationTime(tt.layers); got != tt.expected {
+ t.Errorf("PreparationTime(%d) = %d; want %d", tt.layers, got, tt.expected)
+ }
+ })
+
+ }
+}
+
+func TestElapsedTime(t *testing.T) {
+ tests := []lasagnaTests{
+ {
+ name: "Total time in minutes for one layer",
+ layers: 1,
+ time: 30,
+ expected: 32,
+ },
+ {
+ name: "Total time in minutes for multiple layers",
+ layers: 4,
+ time: 8,
+ expected: 16,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ if got := ElapsedTime(tt.layers, tt.time); got != tt.expected {
+ t.Errorf("ElapsedTime(%d, %d) = %d; want %d", tt.layers, tt.time, got, tt.expected)
+ }
+ })
+
+ }
+}