コード例 #1
0
ファイル: search_test.go プロジェクト: nitsnwits/go
// TestRegistration tests the registration of matchers is functioning.
func TestRegistration(t *testing.T) {
	matcher := search.FindMatcher("test")

	t.Log("The test Matcher should be returned.")
	if _, ok := matcher.(testMatcher); !ok {
		t.Fatalf("ERROR : Invalid Matcher : %T", matcher)
	}
}
コード例 #2
0
ファイル: search_test.go プロジェクト: nitsnwits/go
// TestSearch tests the search mechanism for using a Matcher
// with the channel response.
func TestSearch(t *testing.T) {
	matcher := search.FindMatcher("test")
	results := make(chan *search.Result, 1)
	var feed search.Feed
	var searchTerm string

	search.Match(matcher, &feed, searchTerm, results)
	result := <-results

	t.Log("The search should return the test results.")
	if result.Field != "Test Field" {
		t.Errorf("ERROR : Expecting[Test Field] Received[%s]", result.Field)
	}

	if result.Content != "Test Content" {
		t.Errorf("ERROR : Expecting[Test Content] Received[%s]", result.Content)
	}
}