Twenty account components: SettingsList, OptionCycler, KeyBindings, ControllerMap, ProfileCard, CharacterCreator, LoginForm, PasswordGrid, SessionList, LanguagePicker, PalettePicker, VolumeMixer, DifficultySelect, AccessibilityOptions, AccountSwitcher, PlayerSelect, TwoFactor, About, PatchNotes and FeedbackForm. The components never check credentials, and no secret reaches the log: LoginForm reports Submitted and the caller counts Failures; each new failure clears the password, refocuses it, shakes the form and names no field. TwoFactor builds on input.PinInput and drains an epoch-aligned period bar. PalettePicker draws each tile in its own palette on a pixel.Pad grid. pixel.Settings.Reduce stills motion like the system preference, the micro font gains '?', display.Face draws avatar faces anywhere, and input.PinInput pastes on Cmd+V as native hosts send it.
25 lines
548 B
Go
25 lines
548 B
Go
package account
|
|
|
|
import (
|
|
"math"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestSecondsLeftRoundsUpWithoutOverflow(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
now time.Time
|
|
period time.Duration
|
|
want int64
|
|
}{
|
|
{time.Unix(0, 0), 30 * time.Second, 30},
|
|
{time.Unix(1, 0), 30 * time.Second, 29},
|
|
{time.Unix(29, 5e8), 30 * time.Second, 1},
|
|
{time.Unix(0, 0), math.MaxInt64, 9223372037},
|
|
} {
|
|
if got := secondsLeft(tc.now, tc.period); got != tc.want {
|
|
t.Errorf("%v into %v: %d s left, want %d", tc.now.Unix(), tc.period, got, tc.want)
|
|
}
|
|
}
|
|
}
|