mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
72669e19bc
It's sometimes necessary to specify padding or spacing based on the text size. Signed-off-by: Egon Elbre <egonelbre@gmail.com>
33 lines
466 B
Go
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)
|
|
}
|
|
}
|
|
}
|