1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Create the test_destructor16() test SQL function to enhance test coverage.

Prior to check-in (4883), the test_destructor() function was sufficient,
but we now need separate functions since the implementation is restricted
to using the published API. (CVS 4884)

FossilOrigin-Name: bb7218657f3b06d810ad710fe64e5c9984aa518c
This commit is contained in:
drh
2008-03-19 16:35:24 +00:00
parent 984bfaa4c7
commit da84ca8de9
4 changed files with 46 additions and 15 deletions

View File

@@ -12,7 +12,7 @@
** Code for testing all sorts of SQLite interfaces. This code
** implements new SQL functions used by the test scripts.
**
** $Id: test_func.c,v 1.1 2008/03/19 16:08:54 drh Exp $
** $Id: test_func.c,v 1.2 2008/03/19 16:35:24 drh Exp $
*/
#include "sqlite3.h"
#include "tcl.h"
@@ -114,6 +114,28 @@ static void test_destructor(
memcpy(zVal, sqlite3_value_text(argv[0]), len);
sqlite3_result_text(pCtx, zVal, -1, destructor);
}
static void test_destructor16(
sqlite3_context *pCtx,
int nArg,
sqlite3_value **argv
){
char *zVal;
int len;
test_destructor_count_var++;
assert( nArg==1 );
if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
len = sqlite3_value_bytes16(argv[0]);
zVal = testContextMalloc(pCtx, len+3);
if( !zVal ){
return;
}
zVal[len+1] = 0;
zVal[len+2] = 0;
zVal++;
memcpy(zVal, sqlite3_value_text16(argv[0]), len);
sqlite3_result_text16(pCtx, zVal, -1, destructor);
}
static void test_destructor_count(
sqlite3_context *pCtx,
int nArg,
@@ -187,6 +209,7 @@ static int registerTestFunctions(sqlite3 *db){
} aFuncs[] = {
{ "randstr", 2, SQLITE_UTF8, randStr },
{ "test_destructor", 1, SQLITE_UTF8, test_destructor},
{ "test_destructor16", 1, SQLITE_UTF8, test_destructor16},
{ "test_destructor_count", 0, SQLITE_UTF8, test_destructor_count},
{ "test_auxdata", -1, SQLITE_UTF8, test_auxdata},
{ "test_error", 1, SQLITE_UTF8, test_error},