feat(ui-calculator): input validation, load caps, ceil display, modernization layout
- custom load capped at cargo capacity (error when exceeded); full load shows the cargo capacity; zero cargo pins load to empty and disables the toggle - per-input red border + tooltip for every invalid value (blocks, techs, load, MAT, modernization target); no value may be negative; locking a speed is disabled when drive is zero - display every computed number (results + goal-seek back-solved input) rounded up to 3 decimals via a shared pkg/calc Ceil3 bridged to wasm; engine keeps its own round-to-nearest util.Fixed* - modernization total upgrade cost spans two columns (single line) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package calc_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
source "galaxy/calc"
|
||||
bridge "galaxy/core/calc"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCeil3Parity(t *testing.T) {
|
||||
t.Parallel()
|
||||
cases := []float64{0, 5, 5.0003, 4.2761, 139.29503, 0.0001, 1.9999999998}
|
||||
for _, c := range cases {
|
||||
assert.Equal(t, source.Ceil3(c), bridge.Ceil3(c))
|
||||
}
|
||||
}
|
||||
|
||||
func TestCeil3Values(t *testing.T) {
|
||||
t.Parallel()
|
||||
assert.Equal(t, 5.0, source.Ceil3(5.0))
|
||||
assert.Equal(t, 5.001, source.Ceil3(5.0003))
|
||||
assert.Equal(t, 4.277, source.Ceil3(4.2761))
|
||||
// Float noise just above an exact step stays put.
|
||||
assert.Equal(t, 5.0, source.Ceil3(5.0000000002))
|
||||
}
|
||||
Reference in New Issue
Block a user