Files
game-code-4/tests/unit/cases/test_number_format.gd
T

20 lines
936 B
GDScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
extends RefCounted
# 用例:NumberFormat(core/numbers/number_format.gd)
func run(a, _data) -> void:
a.eq(NumberFormat.short(999.0), "999", "short 999")
a.eq(NumberFormat.short(1000.0), "1.00K", "short 1K")
a.eq(NumberFormat.short(1234.0), "1.23K", "short 1234")
a.eq(NumberFormat.short(1.5e9), "1.50B", "short 1.5B")
a.eq(NumberFormat.short(1.5e12), "1.50T", "short 1.5T")
a.eq(NumberFormat.short_int(1500.0), "2K", "short_int 1500 → 2K")
a.eq(NumberFormat.short_int(1400.0), "1K", "short_int 1400 → 1K")
a.eq(NumberFormat.duration(42.0), "42s", "duration 42s")
a.eq(NumberFormat.duration(90.0), "1m 30s", "duration 90s")
a.eq(NumberFormat.duration(3600.0), "1h", "duration 1h")
a.eq(NumberFormat.duration(5100.0), "1h 25m", "duration 1h25m")
a.eq(NumberFormat.minutes(25.0), "25m", "minutes 25")
a.eq(NumberFormat.minutes(180.0), "3h", "minutes 180")
a.eq(NumberFormat.minutes(125.0), "2h 5m", "minutes 125")