From 28083a7bb0e76217e36bc997ced4c0521934c843 Mon Sep 17 00:00:00 2001 From: Ned Palacios Date: Sat, 3 Feb 2024 20:29:15 +0800 Subject: [PATCH] fix: update translation_test.go texts --- translation_test.go | 125 ++++++++++++++++++++++---------------------- 1 file changed, 62 insertions(+), 63 deletions(-) diff --git a/translation_test.go b/translation_test.go index d94f467..671afda 100644 --- a/translation_test.go +++ b/translation_test.go @@ -20,87 +20,87 @@ func TestExplainGenerator(t *testing.T) { t.Run("Add", func(t *testing.T) { t.Run("Simple", func(t *testing.T) { gen := &lib.ExplainGenerator{} - gen.Add("This is a simple error message.") + gen.Add("This is a simple error explanation.") - if gen.Builder.String() != "This is a simple error message." { - t.Errorf("Expected 'This is a simple error message.', got %s", gen.Builder.String()) + if gen.Builder.String() != "This is a simple error explanation." { + t.Errorf("Expected 'This is a simple error explanation.', got %s", gen.Builder.String()) } }) t.Run("Simple with string data", func(t *testing.T) { gen := &lib.ExplainGenerator{} - gen.Add("This is a simple error message with data: %s", "Hello") + gen.Add("This is a simple error explanation with data: %s", "Hello") - if gen.Builder.String() != "This is a simple error message with data: Hello" { - t.Errorf("Expected 'This is a simple error message with data: Hello', got %s", gen.Builder.String()) + if gen.Builder.String() != "This is a simple error explanation with data: Hello" { + t.Errorf("Expected 'This is a simple error explanation with data: Hello', got %s", gen.Builder.String()) } }) t.Run("Simple with int data", func(t *testing.T) { gen := &lib.ExplainGenerator{} - gen.Add("This is a simple error message with data: %d", 10) + gen.Add("This is a simple error explanation with data: %d", 10) - if gen.Builder.String() != "This is a simple error message with data: 10" { - t.Errorf("Expected 'This is a simple error message with data: 10', got %s", gen.Builder.String()) + if gen.Builder.String() != "This is a simple error explanation with data: 10" { + t.Errorf("Expected 'This is a simple error explanation with data: 10', got %s", gen.Builder.String()) } }) t.Run("Simple with mixed data", func(t *testing.T) { gen := &lib.ExplainGenerator{} - gen.Add("This is a simple error message with data: %s and %d", "Hello", 10) + gen.Add("This is a simple error explanation with data: %s and %d", "Hello", 10) - if gen.Builder.String() != "This is a simple error message with data: Hello and 10" { - t.Errorf("Expected 'This is a simple error message with data: Hello and 10', got %s", gen.Builder.String()) + if gen.Builder.String() != "This is a simple error explanation with data: Hello and 10" { + t.Errorf("Expected 'This is a simple error explanation with data: Hello and 10', got %s", gen.Builder.String()) } }) t.Run("Append", func(t *testing.T) { gen := &lib.ExplainGenerator{} - gen.Add("This is a simple error message.") + gen.Add("This is a simple error explanation.") gen.Add("This is another error message.") - if gen.Builder.String() != "This is a simple error message.This is another error message." { - t.Errorf("Expected 'This is a simple error message.This is another error message.', got %s", gen.Builder.String()) + if gen.Builder.String() != "This is a simple error explanation.This is another error message." { + t.Errorf("Expected 'This is a simple error explanation.This is another error message.', got %s", gen.Builder.String()) } }) t.Run("Append with newline", func(t *testing.T) { gen := &lib.ExplainGenerator{ErrorName: "TestError"} - gen.Add("This is a simple error message.\n") + gen.Add("This is a simple error explanation.\n") gen.Add("This is another error message.") - if gen.Builder.String() != "This is a simple error message.\nThis is another error message." { - t.Errorf("Expected 'This is a simple error message.\nThis is another error message.', got %s", gen.Builder.String()) + if gen.Builder.String() != "This is a simple error explanation.\nThis is another error message." { + t.Errorf("Expected 'This is a simple error explanation.\nThis is another error message.', got %s", gen.Builder.String()) } }) t.Run("Append with string data", func(t *testing.T) { gen := &lib.ExplainGenerator{} - gen.Add("This is a simple error message with data: %s", "Hello") + gen.Add("This is a simple error explanation with data: %s", "Hello") gen.Add("This is another error message with data: %s", "World") - if gen.Builder.String() != "This is a simple error message with data: HelloThis is another error message with data: World" { - t.Errorf("Expected 'This is a simple error message with data: HelloThis is another error message with data: World', got %s", gen.Builder.String()) + if gen.Builder.String() != "This is a simple error explanation with data: HelloThis is another error message with data: World" { + t.Errorf("Expected 'This is a simple error explanation with data: HelloThis is another error message with data: World', got %s", gen.Builder.String()) } }) t.Run("Append with int data", func(t *testing.T) { gen := &lib.ExplainGenerator{} - gen.Add("This is a simple error message with data: %d", 10) + gen.Add("This is a simple error explanation with data: %d", 10) gen.Add("This is another error message with data: %d", 20) - if gen.Builder.String() != "This is a simple error message with data: 10This is another error message with data: 20" { - t.Errorf("Expected 'This is a simple error message with data: 10This is another error message with data: 20', got %s", gen.Builder.String()) + if gen.Builder.String() != "This is a simple error explanation with data: 10This is another error message with data: 20" { + t.Errorf("Expected 'This is a simple error explanation with data: 10This is another error message with data: 20', got %s", gen.Builder.String()) } }) t.Run("Append with mixed data", func(t *testing.T) { gen := &lib.ExplainGenerator{} - gen.Add("This is a simple error message with data: %s", "Hello") + gen.Add("This is a simple error explanation with data: %s", "Hello") gen.Add("This is another error message with data: %d", 20) - if gen.Builder.String() != "This is a simple error message with data: HelloThis is another error message with data: 20" { - t.Errorf("Expected 'This is a simple error message with data: HelloThis is another error message with data: 20', got %s", gen.Builder.String()) + if gen.Builder.String() != "This is a simple error explanation with data: HelloThis is another error message with data: 20" { + t.Errorf("Expected 'This is a simple error explanation with data: HelloThis is another error message with data: 20', got %s", gen.Builder.String()) } }) @@ -174,9 +174,9 @@ func TestBugFixGenerator(t *testing.T) { Document: doc, } - gen.Add("This is a simple error message.", func(s *lib.BugFixSuggestion) { - if s.Title != "This is a simple error message." { - t.Errorf("Expected 'This is a simple error message.', got %s", s.Title) + gen.Add("A descriptive suggestion sentence or phrase", func(s *lib.BugFixSuggestion) { + if s.Title != "A descriptive suggestion sentence or phrase" { + t.Errorf("Expected 'A descriptive suggestion sentence or phrase', got %s", s.Title) } if s.Doc == nil { @@ -205,7 +205,7 @@ func TestBugFixGenerator(t *testing.T) { Document: doc, } - err := gen.Add("This is a simple error message.", nil) + err := gen.Add("A descriptive suggestion sentence or phrase", nil) if err == nil { t.Errorf("Expected error, got nil") } @@ -220,7 +220,7 @@ func TestBugFixGenerator(t *testing.T) { Document: doc, } - gen.Add("This is a simple error message.", func(s *lib.BugFixSuggestion) {}) + gen.Add("A descriptive suggestion sentence or phrase", func(s *lib.BugFixSuggestion) {}) gen.Add("This is another error message.", func(s *lib.BugFixSuggestion) {}) if len(gen.Suggestions) != 2 { @@ -235,10 +235,10 @@ func TestBugFixGenerator(t *testing.T) { Document: doc, } - gen.Add("This is a simple error message.", func(s *lib.BugFixSuggestion) { - s.AddStep("This is a simple step.", func(step *lib.BugFixStep) { - if step.Content != "This is a simple step." { - t.Errorf("Expected 'This is a simple step.', got %s", step.Content) + gen.Add("A descriptive suggestion sentence or phrase", func(s *lib.BugFixSuggestion) { + s.AddStep("This is a step.", func(step *lib.BugFixStep) { + if step.Content != "This is a step." { + t.Errorf("Expected 'This is a step.', got %s", step.Content) } if step.Doc == nil { @@ -253,10 +253,10 @@ func TestBugFixGenerator(t *testing.T) { Document: doc, } - gen.Add("This is a simple error message.", func(s *lib.BugFixSuggestion) { - s.AddStep("This is a simple step", func(step *lib.BugFixStep) { - if step.Content != "This is a simple step." { - t.Errorf("Expected 'This is a simple step.', got %s", step.Content) + gen.Add("A descriptive suggestion sentence or phrase", func(s *lib.BugFixSuggestion) { + s.AddStep("This is a step", func(step *lib.BugFixStep) { + if step.Content != "This is a step." { + t.Errorf("Expected 'This is a step.', got %s", step.Content) } }) }) @@ -267,7 +267,7 @@ func TestBugFixGenerator(t *testing.T) { Document: doc, } - gen.Add("This is a simple error message.", func(s *lib.BugFixSuggestion) { + gen.Add("A descriptive suggestion sentence or phrase", func(s *lib.BugFixSuggestion) { s.AddStep("Oh wow!", func(step *lib.BugFixStep) { if step.Content != "Oh wow!" { t.Errorf("Expected 'Oh wow!', got %s", step.Content) @@ -281,10 +281,10 @@ func TestBugFixGenerator(t *testing.T) { Document: doc, } - gen.Add("This is a simple error message.", func(s *lib.BugFixSuggestion) { - s.AddStep("This is a simple step with data: %s", "Hello", func(step *lib.BugFixStep) { - if step.Content != "This is a simple step with data: Hello." { - t.Errorf("Expected 'This is a simple step with data: Hello.', got %s", step.Content) + gen.Add("A descriptive suggestion sentence or phrase", func(s *lib.BugFixSuggestion) { + s.AddStep("This is a step with data: %s", "Hello", func(step *lib.BugFixStep) { + if step.Content != "This is a step with data: Hello." { + t.Errorf("Expected 'This is a step with data: Hello.', got %s", step.Content) } }) }) @@ -295,10 +295,10 @@ func TestBugFixGenerator(t *testing.T) { Document: doc, } - gen.Add("This is a simple error message.", func(s *lib.BugFixSuggestion) { - s.AddStep("This is a simple step with data: %d", 10, func(step *lib.BugFixStep) { - if step.Content != "This is a simple step with data: 10." { - t.Errorf("Expected 'This is a simple step with data: 10.', got %s", step.Content) + gen.Add("A descriptive suggestion sentence or phrase", func(s *lib.BugFixSuggestion) { + s.AddStep("This is a step with data: %d", 10, func(step *lib.BugFixStep) { + if step.Content != "This is a step with data: 10." { + t.Errorf("Expected 'This is a step with data: 10.', got %s", step.Content) } }) }) @@ -309,10 +309,10 @@ func TestBugFixGenerator(t *testing.T) { Document: doc, } - gen.Add("This is a simple error message.", func(s *lib.BugFixSuggestion) { - s.AddStep("This is a simple step with data: %s and %d", "Hello", 10, func(step *lib.BugFixStep) { - if step.Content != "This is a simple step with data: Hello and 10." { - t.Errorf("Expected 'This is a simple step with data: Hello and 10.', got %s", step.Content) + gen.Add("A descriptive suggestion sentence or phrase", func(s *lib.BugFixSuggestion) { + s.AddStep("This is a step with data: %s and %d", "Hello", 10, func(step *lib.BugFixStep) { + if step.Content != "This is a step with data: Hello and 10." { + t.Errorf("Expected 'This is a step with data: Hello and 10.', got %s", step.Content) } }) }) @@ -323,7 +323,7 @@ func TestBugFixGenerator(t *testing.T) { Document: doc, } - gen.Add("This is a simple error message.", func(s *lib.BugFixSuggestion) { + gen.Add("A descriptive suggestion sentence or phrase", func(s *lib.BugFixSuggestion) { // recover defer func() { if r := recover(); r != nil { @@ -344,9 +344,9 @@ func TestBugFixGenerator(t *testing.T) { Document: doc, } - gen.Add("This is a simple error message.", func(s *lib.BugFixSuggestion) { + gen.Add("A descriptive suggestion sentence or phrase", func(s *lib.BugFixSuggestion) { // add a = 1 fix - step := s.AddStep("This is a simple step."). + step := s.AddStep("This is a step."). AddFix(lib.FixSuggestion{ NewText: "\na = 1", StartPosition: lib.Position{ @@ -367,7 +367,6 @@ func TestBugFixGenerator(t *testing.T) { t.Errorf("Expected 1 fix, got %d", len(s.Steps[0].Fixes)) } }) - }) t.Run("Suggestion/AddFix/Update", func(t *testing.T) { @@ -375,8 +374,8 @@ func TestBugFixGenerator(t *testing.T) { Document: doc, } - gen.Add("This is a simple error message.", func(s *lib.BugFixSuggestion) { - step := s.AddStep("This is a simple step."). + gen.Add("A descriptive suggestion sentence or phrase", func(s *lib.BugFixSuggestion) { + step := s.AddStep("This is a step."). AddFix(lib.FixSuggestion{ NewText: "Welcome to the world", StartPosition: lib.Position{ @@ -417,9 +416,9 @@ func TestBugFixGenerator(t *testing.T) { Document: doc, } - gen.Add("This is a simple error message.", func(s *lib.BugFixSuggestion) { + gen.Add("A descriptive suggestion sentence or phrase", func(s *lib.BugFixSuggestion) { // removes the content inside the print function - step := s.AddStep("This is a simple step."). + step := s.AddStep("This is a step."). AddFix(lib.FixSuggestion{ NewText: "", StartPosition: lib.Position{ @@ -443,9 +442,9 @@ func TestBugFixGenerator(t *testing.T) { Document: doc, } - gen.Add("This is a simple error message.", func(s *lib.BugFixSuggestion) { + gen.Add("A descriptive suggestion sentence or phrase", func(s *lib.BugFixSuggestion) { // removes the content inside the print function - step := s.AddStep("This is a simple step."). + step := s.AddStep("This is a step."). AddFix(lib.FixSuggestion{ NewText: "", StartPosition: lib.Position{