2015-09-18 13:52:45 +08:00
|
|
|
// +build darwin
|
|
|
|
|
|
|
|
package mem
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2016-02-20 03:53:29 +08:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2015-09-18 13:52:45 +08:00
|
|
|
)
|
|
|
|
|
2016-02-20 03:53:29 +08:00
|
|
|
func TestVirtualMemoryDarwin(t *testing.T) {
|
|
|
|
v, err := VirtualMemory()
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
|
|
|
assert.True(t, v.Total > 0)
|
|
|
|
|
2016-02-21 03:37:17 +08:00
|
|
|
assert.Equal(t, v.Total, v.Active+v.Inactive+v.Free+v.Wired)
|
|
|
|
|
2016-02-20 03:53:29 +08:00
|
|
|
assert.True(t, v.Available > 0)
|
|
|
|
assert.True(t, v.Available < v.Total)
|
|
|
|
assert.Equal(t, v.Available, v.Total-v.Wired-v.Active, "%v", v)
|
2016-02-21 03:37:17 +08:00
|
|
|
assert.Equal(t, v.Available, v.Free+v.Inactive, "%v", v)
|
2016-02-20 03:53:29 +08:00
|
|
|
|
|
|
|
assert.True(t, v.Used > 0)
|
|
|
|
assert.True(t, v.Used < v.Total)
|
|
|
|
|
|
|
|
assert.True(t, v.UsedPercent > 0)
|
|
|
|
assert.True(t, v.UsedPercent < 100)
|
|
|
|
|
|
|
|
assert.True(t, v.Free > 0)
|
|
|
|
assert.True(t, v.Free < v.Available)
|
|
|
|
|
|
|
|
assert.True(t, v.Active > 0)
|
|
|
|
assert.True(t, v.Active < v.Total)
|
|
|
|
|
|
|
|
assert.True(t, v.Inactive > 0)
|
|
|
|
assert.True(t, v.Inactive < v.Total)
|
|
|
|
|
|
|
|
assert.True(t, v.Wired > 0)
|
|
|
|
assert.True(t, v.Wired < v.Total)
|
|
|
|
}
|