package main import "testing" func TestCalcCalories(t *testing.T) { t.Parallel() tests := []struct { name string text string want int wantErr bool }{ { "empty text", "", 0, false, }, { "1 text", "1", 1, false, }, { "2 5 text", "20 50", 10, false, }, { "чай text", "чай", 39, false, }, } for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() count, err := calcCalories(tt.text) if (err != nil) != tt.wantErr { t.Errorf("error calc calories: %v", err) return } if count != tt.want { t.Errorf("error count: %v", err) return } }) } }