func TestEntryOrdering(t *testing.T) {
	wg := &sync.WaitGroup{}
	wg.Add(2)
	cron := New()
	cron.Add(Every(40*time.Second), arbitraryJob{wg, "job-1"})
	cron.Add(Every(1*time.Second), arbitraryJob{wg, "job-2"})
	cron.Add(Every(1*xtime.Week), arbitraryJob{wg, "job-3"})
	cron.Add(Every(12*time.Second), arbitraryJob{wg, "job-4"})
	cron.Add(Every(8*time.Second), arbitraryJob{wg, "job-5"})
	cron.Start()
	select {
	case <-time.After(2 * OneSecond):
		t.FailNow()
	case <-wait(wg):
	}
	cron.Stop()
	want := []string{"job-2", "job-5", "job-4", "job-1", "job-3"}
	var got []string
	for _, e := range cron.Entries() {
		got = append(got, e.Job.(arbitraryJob).id)
	}
	for i := range got {
		if want[i] != got[i] {
			t.Errorf("incorrect sequencing: (want) %q != %q (got)", want, got)
			break
		}
	}
}
Test that entries are in correct sequence after n run.
package gron
import (
	"fmt"
	"reflect"
	"sort"
	"strings"
	"sync"
	"testing"
	"time"
	"github.com/roylee0704/gron/xtime"
)
const OneSecond = 1*time.Second + 10*time.Millisecond
func TestNoEntries(t *testing.T) {
	cron := New()
	cron.Start()
	select {
	case <-time.After(OneSecond):
		t.FailNow()
	case <-stop(cron):
	}
}
func TestNoPhantomJobs(t *testing.T) {
	entry := 0
	after = func(d time.Duration) <-chan time.Time {
		entry++
		return time.After(d)
	}
	defer func() {
		after = time.After
	}()  
	cron := New()
	cron.Start()
	defer cron.Stop()
	time.Sleep(1 * time.Millisecond)  
	if entry > 1 {
		t.Errorf("phantom job had run %d time(s).", entry)
	}
}
func TestAddBeforeRun(t *testing.T) {
	done := make(chan struct{})
	cron := New()
	cron.AddFunc(Every(1*time.Second), func() { done <- struct{}{} })
	cron.Start()
	defer cron.Stop()
	select {
	case <-time.After(OneSecond):
		t.FailNow()
	case <-done:
	}
}
func TestAddWhileRun(t *testing.T) {
	done := make(chan struct{})
	cron := New()
	cron.Start()
	defer cron.Stop()
	cron.AddFunc(Every(1*time.Second), func() { done <- struct{}{} })
	select {
	case <-time.After(OneSecond):
		t.FailNow()
	case <-done:
	}
}
func TestStopWithoutStart(t *testing.T) {
	cron := New()
	cron.Stop()
}
func TestJobsDontRunAfterStop(t *testing.T) {
	wg := &sync.WaitGroup{}
	wg.Add(1)
	cron := New()
	cron.Start()
	cron.Stop()
	cron.AddFunc(Every(1*time.Second), func() { wg.Done() })
	select {
	case <-time.After(OneSecond):
	case <-wait(wg):
		t.FailNow()
	}
}
func TestMultipleEntries(t *testing.T) {
	wg := &sync.WaitGroup{}
	wg.Add(3)
	cron := New()
	cron.AddFunc(Every(5*time.Minute), func() {})
	cron.AddFunc(Every(1*time.Second), func() { wg.Done() })
	cron.AddFunc(Every(1*time.Second), func() { wg.Done() })
	cron.AddFunc(Every(1*time.Second), func() { wg.Done() })
	cron.AddFunc(Every(4*xtime.Week), func() {})
	cron.Start()
	defer cron.Stop()
	select {
	case <-time.After(OneSecond):
		t.FailNow()
	case <-wait(wg):
	}
}
func TestRunJobTwice(t *testing.T) {
	wg := &sync.WaitGroup{}
	wg.Add(2)
	cron := New()
	cron.Start()
	defer cron.Stop()
	cron.AddFunc(Every(1*xtime.Day), func() { wg.Done() })
	cron.AddFunc(Every(1*xtime.Week), func() { wg.Done() })
	cron.AddFunc(Every(1*time.Second), func() { wg.Done() })
	select {
	case <-time.After(2 * OneSecond):
		t.FailNow()
	case <-wait(wg):
	}
}
type arbitraryJob struct {
	wg *sync.WaitGroup  
	id string           
}
func (j arbitraryJob) Run() {
	if j.wg != nil {
		j.wg.Done()
	}
}
func TestJobImplementer(t *testing.T) {
	wg := &sync.WaitGroup{}
	wg.Add(2)
	cron := New()
	cron.Add(Every(1*xtime.Day), arbitraryJob{wg, "job-1"})  
	cron.Add(Every(1*time.Second), arbitraryJob{wg, "job-2"})
	cron.Add(Every(1*xtime.Week), arbitraryJob{wg, "job-3"})  
	cron.Start()
	defer cron.Stop()
	select {
	case <-time.After(2 * OneSecond):
		t.FailNow()
	case <-wait(wg):
	}
}