oh-my-posh/src/segment_memory_test.go

30 lines
673 B
Go
Raw Normal View History

2021-09-03 11:54:19 -07:00
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestMemory(t *testing.T) {
cases := []struct {
Case string
ExpectedString string
Memory memory
Precision int
}{
{Case: "50", ExpectedString: "50", Memory: memory{FreeMemory: 50, TotalMemory: 100}},
{Case: "50.0", ExpectedString: "50.0", Memory: memory{FreeMemory: 50, TotalMemory: 100}, Precision: 1},
}
for _, tc := range cases {
tc.Memory.env = new(MockedEnvironment)
tc.Memory.props = &properties{
values: map[Property]interface{}{
Precision: tc.Precision,
},
}
assert.Equal(t, tc.ExpectedString, tc.Memory.string(), tc.Case)
}
}