From ca6be31b69802b48c0bd1278627ce23c00f4ff78 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 12 Dec 2009 19:15:27 +0000 Subject: [PATCH] Tests to cover a few extra branches in fts3.c. FossilOrigin-Name: 06b72b007393dc34d75a8bb16ce0e4507d5f8faa --- ext/fts3/fts3.c | 8 ++++---- manifest | 14 +++++++------- manifest.uuid | 2 +- test/fts3cov.test | 23 ++++++++++++++++++++++- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 749922f180..a66c776dd8 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -817,7 +817,7 @@ static int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){ rc = SQLITE_CORRUPT; } pCsr->isEof = 1; - if( pContext && rc!=SQLITE_OK ){ + if( pContext ){ sqlite3_result_error_code(pContext, rc); } return rc; @@ -1520,13 +1520,13 @@ static int fts3TermSelect( int nSegment = 0; /* Size of apSegment array */ int nAlloc = 16; /* Allocated size of segment array */ int rc; /* Return code */ - sqlite3_stmt *pStmt; /* SQL statement to scan %_segdir table */ + sqlite3_stmt *pStmt = 0; /* SQL statement to scan %_segdir table */ int iAge = 0; /* Used to assign ages to segments */ apSegment = (Fts3SegReader **)sqlite3_malloc(sizeof(Fts3SegReader*)*nAlloc); if( !apSegment ) return SQLITE_NOMEM; rc = sqlite3Fts3SegReaderPending(p, zTerm, nTerm, isPrefix, &apSegment[0]); - if( rc!=SQLITE_OK ) return rc; + if( rc!=SQLITE_OK ) goto finished; if( apSegment[0] ){ nSegment = 1; } @@ -2050,7 +2050,7 @@ static void fts3SnippetFunc( case 3: zEnd = (const char*)sqlite3_value_text(apVal[2]); case 2: zStart = (const char*)sqlite3_value_text(apVal[1]); } - if( !zStart || !zEnd || !zEllipsis ){ + if( !zEllipsis || !zEnd || !zStart ){ sqlite3_result_error_nomem(pContext); }else if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){ sqlite3Fts3Snippet(pContext, pCsr, zStart, zEnd, zEllipsis); diff --git a/manifest b/manifest index 7355ac2e41..7aff063b1c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Further\sfts3\scoverage\stests. -D 2009-12-12T16:04:32 +C Tests\sto\scover\sa\sfew\sextra\sbranches\sin\sfts3.c. +D 2009-12-12T19:15:28 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -56,7 +56,7 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c e1828210a55b4b27df2b1f6fa78b1fb12058f56e +F ext/fts3/fts3.c ea601b21f6bcaab4035804993328a9f0231ec6cb F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 6fdd41b4f296e5bcc908444dc591397995d4ff5d F ext/fts3/fts3_expr.c fcf6812dbfd9cb9a2cabaf50e741411794f83e7e @@ -396,7 +396,7 @@ F test/fts3ao.test 0aa29dd4fc1c8d46b1f7cfe5926f7ac97551bea9 F test/fts3atoken.test 25c2070e1e8755d414bf9c8200427b277a9f99fa F test/fts3b.test e93bbb653e52afde110ad53bbd793f14fe7a8984 F test/fts3c.test fc723a9cf10b397fdfc2b32e73c53c8b1ec02958 -F test/fts3cov.test f2d27d29628941e4814473345603b20421b93c78 +F test/fts3cov.test 3a9d8618a3107166530c447e808f8992372e0415 F test/fts3d.test 95fb3c862cbc4297c93fceb9a635543744e9ef52 F test/fts3e.test 1f6c6ac9cc8b772ca256e6b22aaeed50c9350851 F test/fts3expr.test 05dab77387801e4900009917bb18f556037d82da @@ -779,7 +779,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 68cccd62b71f7b55bf7f2f56dc8507cbe80229ba -R 24dafc1291b25c037b068505da647d63 +P d2a8c0f683271f5fb8c9badfb13e4e46fd78db71 +R 2bf0117c3db56e5351a8a9dca36e7a01 U dan -Z f50ab64261ebba22ef3131cb9e897960 +Z cff0315b4b1d4f7a0aab7cdae117a3f0 diff --git a/manifest.uuid b/manifest.uuid index 521448761d..3d353b7ff6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d2a8c0f683271f5fb8c9badfb13e4e46fd78db71 \ No newline at end of file +06b72b007393dc34d75a8bb16ce0e4507d5f8faa \ No newline at end of file diff --git a/test/fts3cov.test b/test/fts3cov.test index dab208bd54..d3fe4fa8c5 100644 --- a/test/fts3cov.test +++ b/test/fts3cov.test @@ -348,5 +348,26 @@ do_test fts3cov-11.1 { execsql { SELECT * FROM xx WHERE xx MATCH 'two' } } {} -finish_test +do_malloc_test fts3cov-12 -sqlprep { + CREATE VIRTUAL TABLE t12 USING fts3; + INSERT INTO t12 VALUES('is one of the two togther'); + BEGIN; + INSERT INTO t12 VALUES('one which was appropriate at the time'); +} -sqlbody { + SELECT * FROM t12 WHERE t12 MATCH 'one' +} + +do_malloc_test fts3cov-13 -sqlprep { + PRAGMA encoding = 'UTF-16'; + CREATE VIRTUAL TABLE t13 USING fts3; + INSERT INTO t13 VALUES('two scalar functions'); + INSERT INTO t13 VALUES('scalar two functions'); + INSERT INTO t13 VALUES('functions scalar two'); +} -sqlbody { + SELECT snippet(t13, '%%', '%%', '#') FROM t13 WHERE t13 MATCH 'two'; + SELECT snippet(t13, '%%', '%%') FROM t13 WHERE t13 MATCH 'two'; + SELECT snippet(t13, '%%') FROM t13 WHERE t13 MATCH 'two'; +} + +finish_test -- 2.47.2