Files
gio-patched/unit/unit_test.go
T
Egon Elbre 72669e19bc unit: add Metric.DpToSp and Metric.SpToDp
It's sometimes necessary to specify padding or spacing based on
the text size.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2022-06-15 11:30:12 +02:00

33 lines
466 B
Go

// SPDX-License-Identifier: Unlicense OR MIT
package unit_test
import (
"testing"
"gioui.org/unit"
)
func TestMetric_DpToSp(t *testing.T) {
m := unit.Metric{
PxPerDp: 2,
PxPerSp: 3,
}
{
exp := m.Dp(5)
got := m.Sp(m.DpToSp(5))
if got != exp {
t.Errorf("DpToSp conversion mismatch %v != %v", exp, got)
}
}
{
exp := m.Sp(5)
got := m.Dp(m.SpToDp(5))
if got != exp {
t.Errorf("SpToDp conversion mismatch %v != %v", exp, got)
}
}
}