package main

import (
	"slices"
	"testing"
	"time"
)

func TestMergeClosedInputs(t *testing.T) {
	a, b := make(chan int, 2), make(chan int, 2)
	a <- 1
	a <- 3
	b <- 2
	b <- 4
	close(a)
	close(b)
	got := Merge(a, b)
	slices.Sort(got)
	if !slices.Equal(got, []int{1, 2, 3, 4}) {
		t.Fatalf("got %v", got)
	}
}
func TestNilTimeout(t *testing.T) {
	if _, ok := ReceiveWithin(nil, time.Millisecond); ok {
		t.Fatal("unexpected result")
	}
}
