Skip to content

Commit

Permalink
test: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shihyuho committed Jan 20, 2024
1 parent 47f10ce commit 4340533
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
package main

import (
"github.com/softleader/memory-calculator/calc"
"strings"
"testing"
"github.com/softleader/memory-calculator/calc"
"strings"
"testing"
)

func TestMemoryCalculation_WithLoadedClassCount(t *testing.T) {
calculator := calc.NewCalculator()
*calculator.LoadedClassCount = 1000
calculator := calc.NewCalculator()
*calculator.LoadedClassCount = 1000

jto, err := calculator.Execute()
if err != nil {
t.Fatalf("Execute returned an error: %v", err)
}
options := jto.String()
for _, o := range calc.ContributeOptions {
options = strings.ReplaceAll(options, o, "")
}
options = strings.ReplaceAll(options, calc.OptionsSeparator, "")
jto, err := calculator.Execute()
if err != nil {
t.Fatalf("Execute returned an error: %v", err)
}
options := jto.String()
for _, o := range calc.ContributeOptions {
options = strings.ReplaceAll(options, o, "")
}
options = strings.ReplaceAll(options, calc.OptionsSeparator, "")

if options == "" {
t.Errorf("Execute returned an empty string")
}
if options == "" {
t.Errorf("Execute returned an empty string")
}
}

func TestMemoryCalculation_WithoutLoadedClassCount(t *testing.T) {
calculator := calc.NewCalculator()
*calculator.AppPath = "."
*calculator.JVMClassCount = 1000
*calculator.JVMClassAdj = "150%"
calculator := calc.NewCalculator()
*calculator.AppPath = "."
*calculator.JVMClassCount = 1000
*calculator.JVMClassAdj = "10%"

jto, err := calculator.Execute()
if err != nil {
t.Fatalf("Execute returned an error: %v", err)
}
options := jto.String()
for _, o := range calc.ContributeOptions {
options = strings.ReplaceAll(options, o, "")
}
options = strings.ReplaceAll(options, calc.OptionsSeparator, "")
jto, err := calculator.Execute()
if err != nil {
t.Fatalf("Execute returned an error: %v", err)
}
options := jto.String()
for _, o := range calc.ContributeOptions {
options = strings.ReplaceAll(options, o, "")
}
options = strings.ReplaceAll(options, calc.OptionsSeparator, "")

if options == "" {
t.Errorf("Execute returned an empty string")
}
if options == "" {
t.Errorf("Execute returned an empty string")
}
}

0 comments on commit 4340533

Please sign in to comment.