2019-02-25 05:30:05 +08:00
|
|
|
// Copyright 2019 Google Inc.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2018-05-08 00:44:32 +08:00
|
|
|
package align
|
|
|
|
|
2019-02-25 04:44:13 +08:00
|
|
|
import "testing"
|
2018-05-08 00:44:32 +08:00
|
|
|
|
2019-02-25 04:44:13 +08:00
|
|
|
func TestHorizontal(t *testing.T) {
|
2018-05-08 00:44:32 +08:00
|
|
|
tests := []struct {
|
2019-02-25 04:44:13 +08:00
|
|
|
desc string
|
|
|
|
align Horizontal
|
|
|
|
want string
|
2018-05-08 00:44:32 +08:00
|
|
|
}{
|
|
|
|
{
|
2019-02-25 04:44:13 +08:00
|
|
|
desc: "unknown",
|
|
|
|
align: Horizontal(-1),
|
|
|
|
want: "HorizontalUnknown",
|
2018-05-08 00:44:32 +08:00
|
|
|
},
|
|
|
|
{
|
2019-02-25 04:44:13 +08:00
|
|
|
desc: "left",
|
|
|
|
align: HorizontalLeft,
|
|
|
|
want: "HorizontalLeft",
|
2018-05-08 00:44:32 +08:00
|
|
|
},
|
|
|
|
{
|
2019-02-25 04:44:13 +08:00
|
|
|
desc: "center",
|
|
|
|
align: HorizontalCenter,
|
|
|
|
want: "HorizontalCenter",
|
2018-05-08 00:44:32 +08:00
|
|
|
},
|
|
|
|
{
|
2019-02-25 04:44:13 +08:00
|
|
|
desc: "right",
|
|
|
|
align: HorizontalRight,
|
|
|
|
want: "HorizontalRight",
|
2018-05-08 00:44:32 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, tc := range tests {
|
|
|
|
t.Run(tc.desc, func(t *testing.T) {
|
2019-02-25 04:44:13 +08:00
|
|
|
if got := tc.align.String(); got != tc.want {
|
|
|
|
t.Errorf("String => %q, want %q", got, tc.want)
|
2018-05-08 00:44:32 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2018-05-08 03:32:14 +08:00
|
|
|
|
2019-02-25 04:44:13 +08:00
|
|
|
func TestVertical(t *testing.T) {
|
2018-05-08 03:32:14 +08:00
|
|
|
tests := []struct {
|
2019-02-25 04:44:13 +08:00
|
|
|
desc string
|
|
|
|
align Vertical
|
|
|
|
want string
|
2018-05-08 03:32:14 +08:00
|
|
|
}{
|
|
|
|
{
|
2019-02-25 04:44:13 +08:00
|
|
|
desc: "unknown",
|
|
|
|
align: Vertical(-1),
|
|
|
|
want: "VerticalUnknown",
|
2018-05-08 03:32:14 +08:00
|
|
|
},
|
|
|
|
{
|
2019-02-25 04:44:13 +08:00
|
|
|
desc: "top",
|
|
|
|
align: VerticalTop,
|
|
|
|
want: "VerticalTop",
|
2018-05-08 03:32:14 +08:00
|
|
|
},
|
|
|
|
{
|
2019-02-25 04:44:13 +08:00
|
|
|
desc: "middle",
|
|
|
|
align: VerticalMiddle,
|
|
|
|
want: "VerticalMiddle",
|
2018-05-08 03:32:14 +08:00
|
|
|
},
|
|
|
|
{
|
2019-02-25 04:44:13 +08:00
|
|
|
desc: "bottom",
|
|
|
|
align: VerticalBottom,
|
|
|
|
want: "VerticalBottom",
|
2018-05-08 03:32:14 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, tc := range tests {
|
|
|
|
t.Run(tc.desc, func(t *testing.T) {
|
2019-02-25 04:44:13 +08:00
|
|
|
if got := tc.align.String(); got != tc.want {
|
|
|
|
t.Errorf("String => %q, want %q", got, tc.want)
|
2018-05-08 03:32:14 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|