2018-04-25 06:17:20 +00:00
|
|
|
package timeid
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2018-09-06 14:41:03 +00:00
|
|
|
"time"
|
2018-04-25 06:17:20 +00:00
|
|
|
)
|
|
|
|
|
2018-09-06 14:41:03 +00:00
|
|
|
func TestGuessing(t *testing.T) {
|
2018-04-25 06:17:20 +00:00
|
|
|
|
2018-09-06 14:41:03 +00:00
|
|
|
var windowSize float64 = .5
|
2018-04-25 06:17:20 +00:00
|
|
|
|
2018-09-06 14:41:03 +00:00
|
|
|
id, parity := Generate(windowSize)
|
2018-04-25 06:17:20 +00:00
|
|
|
|
2018-09-06 14:41:03 +00:00
|
|
|
time.Sleep(time.Duration(windowSize) * time.Second)
|
2018-04-25 06:17:20 +00:00
|
|
|
|
2018-09-06 14:41:03 +00:00
|
|
|
var guessedId = Guess(windowSize, parity)
|
2018-04-25 06:17:20 +00:00
|
|
|
|
|
|
|
if id != guessedId {
|
2018-09-06 14:41:03 +00:00
|
|
|
t.Errorf("Wrong guessed id, expected '%d' ; got '%d'", id, guessedId)
|
2018-04-25 06:17:20 +00:00
|
|
|
}
|
|
|
|
|
2018-09-06 14:41:03 +00:00
|
|
|
}
|