package icecast

import (
	"testing"
	"time"
)

func TestNextBackoff(t *testing.T) {
	cfg := ReconnectConfig{
		Enabled:          true,
		InitialBackoffMs: 1000,
		MaxBackoffMs:     5000,
	}
	if got := cfg.nextBackoff(1); got != 1*time.Second {
		t.Fatalf("attempt1 got %s", got)
	}
	if got := cfg.nextBackoff(2); got != 2*time.Second {
		t.Fatalf("attempt2 got %s", got)
	}
	if got := cfg.nextBackoff(3); got != 4*time.Second {
		t.Fatalf("attempt3 got %s", got)
	}
	if got := cfg.nextBackoff(4); got != 5*time.Second {
		t.Fatalf("attempt4 got %s", got)
	}
}
