mirror of
https://github.com/tw93/Mole.git
synced 2026-02-11 22:19:00 +00:00
refactor: use builtin max instead of maxInt (#430)
This commit is contained in:
@@ -142,7 +142,7 @@ func (m model) View() string {
|
||||
header := renderHeader(m.metrics, m.errMessage, m.animFrame, m.width, m.catHidden)
|
||||
cardWidth := 0
|
||||
if m.width > 80 {
|
||||
cardWidth = maxInt(24, m.width/2-4)
|
||||
cardWidth = max(24, m.width/2-4)
|
||||
}
|
||||
cards := buildCards(m.metrics, cardWidth)
|
||||
|
||||
|
||||
@@ -763,7 +763,7 @@ func renderTwoColumns(cards []cardData, width int) string {
|
||||
if i+1 < len(cards) {
|
||||
right = renderCard(cards[i+1], cw, 0)
|
||||
}
|
||||
targetHeight := maxInt(lipgloss.Height(left), lipgloss.Height(right))
|
||||
targetHeight := max(lipgloss.Height(left), lipgloss.Height(right))
|
||||
left = renderCard(cards[i], cw, targetHeight)
|
||||
if right != "" {
|
||||
right = renderCard(cards[i+1], cw, targetHeight)
|
||||
@@ -782,10 +782,3 @@ func renderTwoColumns(cards []cardData, width int) string {
|
||||
}
|
||||
return lipgloss.JoinVertical(lipgloss.Left, spacedRows...)
|
||||
}
|
||||
|
||||
func maxInt(a, b int) int {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
@@ -822,32 +822,6 @@ func TestGetScoreStyle(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMaxInt(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
a int
|
||||
b int
|
||||
want int
|
||||
}{
|
||||
{"a greater", 10, 5, 10},
|
||||
{"b greater", 3, 8, 8},
|
||||
{"equal", 7, 7, 7},
|
||||
{"negative a greater", -5, -10, -5},
|
||||
{"negative b greater", -10, -5, -5},
|
||||
{"zero vs positive", 0, 5, 5},
|
||||
{"zero vs negative", 0, -5, 0},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := maxInt(tt.a, tt.b)
|
||||
if got != tt.want {
|
||||
t.Errorf("maxInt(%d, %d) = %d, want %d", tt.a, tt.b, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSparkline(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
Reference in New Issue
Block a user