package main

import (
	"reflect"
	"testing"
)

func TestSum(t *testing.T) {

	t.Run("SumTest", func(t *testing.T) {
		num := []int{1, 2, 3, 4, 5}
		got := Sum(num)
		want := 15
		if got != want {
			t.Errorf("get '%d'but go '%d' given '%v", got, want, num)
		}
	})
	t.Run("collection of any size", func(t *testing.T) {
		numbers := []int{1, 2, 3}

		got := Sum(numbers)
		want := 6

		if got != want {
			t.Errorf("got %d want %d given, %v", got, want, numbers)
		}
	})

}

func TestSumAllTails(t *testing.T) {

	checkSums := func(t *testing.T, got, want []int) {
		if !reflect.DeepEqual(got, want) {
			t.Errorf("got %v want %v", got, want)
		}
	}

	t.Run("make the sums of tails of", func(t *testing.T) {
		got := SumAllTails([]int{1, 2}, []int{0, 9})
		want := []int{2, 9}
		checkSums(t, got, want)
	})

	t.Run("safely sum empty slices", func(t *testing.T) {
		got := SumAllTails([]int{}, []int{3, 4, 5})
		want := []int{0, 9}
		checkSums(t, got, want)
	})

	t.Run("test3", func(t *testing.T) {
		got := SumAllTails([]int{}, []int{3, 4, 5}, []int{1, 3, 4, 5})
		want := []int{0, 9, 12}
		checkSums(t, got, want)
	})

}
