SQLite

Check-in [498922cc35]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add test cases for examples recently added to documentation file fts3.html.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 498922cc356316a3ec59320529b685728e407746
User & Date: dan 2009-11-30 08:55:04.000
Context
2009-11-30
19:48
Test coverage improvements in the FTS3 porter stemmer. (check-in: 6d112bfd53 user: drh tags: trunk)
08:55
Add test cases for examples recently added to documentation file fts3.html. (check-in: 498922cc35 user: dan tags: trunk)
2009-11-28
21:33
Updates to snippet() and offsets() functions of FTS3 so that they work sanely following an OOM fault. (check-in: b939a37a8c user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/e_fts3.test.
100
101
102
103
104
105
106






107





















































108
# different syntax.
ddl_test   1.7.1 {CREATE VIRTUAL TABLE data USING fts3;}
read_test  1.7.2 {PRAGMA table_info(data)} {0 content {} 0 {} 0}
ddl_test   1.7.3 {DROP TABLE data}

##########################################################################







}





















































finish_test







>
>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# different syntax.
ddl_test   1.7.1 {CREATE VIRTUAL TABLE data USING fts3;}
read_test  1.7.2 {PRAGMA table_info(data)} {0 content {} 0 {} 0}
ddl_test   1.7.3 {DROP TABLE data}

##########################################################################

##########################################################################
# Test the example in section 5 (custom tokenizers).
#
ddl_test   2.1.1 { CREATE VIRTUAL TABLE simple USING fts3(tokenize=simple) } 
write_test 2.1.2 simple_content { 
  INSERT INTO simple VALUES('Right now they''re very frustrated')
}
read_test  2.1.3 {SELECT docid FROM simple WHERE simple MATCH 'Frustrated'} {1} 
read_test  2.1.4 {SELECT docid FROM simple WHERE simple MATCH 'Frustration'} {}

ddl_test   2.2.1 { CREATE VIRTUAL TABLE porter USING fts3(tokenize=porter) } 
write_test 2.2.2 porter_content { 
  INSERT INTO porter VALUES('Right now they''re very frustrated')
}
read_test  2.2.3 {SELECT docid FROM porter WHERE porter MATCH 'Frustrated'} {1} 
read_test  2.2.4 {SELECT docid FROM porter WHERE porter MATCH 'Frustration'} {1}

##########################################################################
# Test the examples in section 4 (auxillary functions).
#
ddl_test   3.1.1 { CREATE VIRTUAL TABLE mail USING fts3(subject, body) }

write_test 3.1.2 mail_content { 
  INSERT INTO mail VALUES(
    'hello world', 'This message is a hello world message.');
}
write_test 3.1.3 mail_content { 
  INSERT INTO mail VALUES(
    'urgent: serious', 'This mail is seen as a more serious mail');
}

read_test 3.1.4 { 
  SELECT offsets(mail) FROM mail WHERE mail MATCH 'world';
} {{0 0 6 5 1 0 24 5}}
read_test 3.1.5 { 
  SELECT offsets(mail) FROM mail WHERE mail MATCH 'message'
} {{1 0 5 7 1 0 30 7}}
read_test 3.1.6 { 
  SELECT offsets(mail) FROM mail WHERE mail MATCH '"serious mail"'
} {{1 0 28 7 1 1 36 4}}

ddl_test 3.2.1 { CREATE VIRTUAL TABLE text USING fts3() }

write_test 3.2.2 text_content {
  INSERT INTO text VALUES('
    During 30 Nov-1 Dec, 2-3oC drops. Cool in the upper portion, minimum temperature 14-16oC and cool elsewhere, minimum temperature 17-20oC. Cold to very cold on mountaintops, minimum temperature 6-12oC. Northeasterly winds 15-30 km/hr. After that, temperature increases. Northeasterly winds 15-30 km/hr.
  ');
}

read_test 3.2.3 {
  SELECT snippet(text) FROM text WHERE text MATCH 'cold'
} {{<b>...</b> elsewhere, minimum temperature 17-20oC. <b>Cold</b> to very <b>cold</b> on mountaintops, minimum <b>...</b>}}

read_test 3.2.4 {
  SELECT snippet(text, '[', ']', '...') FROM text WHERE text MATCH '"min* tem*"'
} {{... 2-3oC drops. Cool in the upper portion, [minimum] [temperature] 14-16oC and cool elsewhere, [minimum] ...}}

#break
}

finish_test
Changes to test/fts3_common.tcl.
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
  set str [join $answers " OR "]

  foreach {nRepeat zName} $modes {
    for {set iFail 1} 1 {incr iFail} {
      if {$::DO_MALLOC_TEST} {sqlite3_memdebug_fail $iFail -repeat $nRepeat}

      set res [catchsql $sql]
      if {[lsearch $answers $res]>=0} {
        set res $str
      }
      do_test $name.$zName.$iFail [list set {} $res] $str
      set nFail [sqlite3_memdebug_fail -1 -benigncnt nBenign]
      if {$nFail==0} break
    }
  }







|







330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
  set str [join $answers " OR "]

  foreach {nRepeat zName} $modes {
    for {set iFail 1} 1 {incr iFail} {
      if {$::DO_MALLOC_TEST} {sqlite3_memdebug_fail $iFail -repeat $nRepeat}

      set res [catchsql $sql]
      if {[lsearch -exact $answers $res]>=0} {
        set res $str
      }
      do_test $name.$zName.$iFail [list set {} $res] $str
      set nFail [sqlite3_memdebug_fail -1 -benigncnt nBenign]
      if {$nFail==0} break
    }
  }