-my $query_string = 'foo';
-
-my $total_hits = $index->search(
- query => $query_string,
- offset => 0,
- num_wanted => 10,
-);
-
-diag "Total hits: $total_hits\n";
-while ( my $hit = $index->fetch_hit_hashref ) {
- ok( $hit, 'hit' );
- diag dump($hit);
+sub test_search {
+ my ( $query_string, $expected_hits ) = @_;
+
+ my $total_hits = $index->search(
+ query => $query_string,
+ offset => 0,
+ num_wanted => 10,
+ );
+
+ ok( $total_hits, "search '$query_string'" );
+
+ diag "Total hits: $total_hits\n" if $debug;
+
+ cmp_ok( $total_hits, '==', $expected_hits, 'total_hits' );
+
+ while ( my $hit = $index->fetch_hit_hashref ) {
+ ok( $hit, 'hit' );
+ ok( $hit->{foo} =~ m/èajðinica/, 'utf-8 conversion' );
+ diag dump($hit) if $debug;
+ }
+