SQLite4
Check-in [2cff3b428a]
Not logged in

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

Overview
Comment:Add a failing test and supporting functions. When the buffer is ended by a passed-in byte count instead of a trailing 0, sqlite4_num_from_text returns NaN
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | num_work
Files: files | file ages | folders
SHA1: 2cff3b428a29acb7031eb76dfe3b965e1cb68ad4
User & Date: peterreid 2013-02-10 04:26:15
Context
2013-02-10
19:21
Fix defect in which sqlite4_num_from_text returns NaN if it uses exactly as many bytes as the caller allows. check-in: 24ee36b76f user: peterreid tags: num_work
04:26
Add a failing test and supporting functions. When the buffer is ended by a passed-in byte count instead of a trailing 0, sqlite4_num_from_text returns NaN check-in: 2cff3b428a user: peterreid tags: num_work
04:06
Add a few sqlite4_num tests. check-in: 6cc07d19e4 user: peterreid tags: num_work
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/num.test.

    25     25   do_test num-equal-1.1.3 {
    26     26     sqlite4_num_compare -00034 -3.4e1
    27     27   } {equal}
    28     28   # Is +0 > -0?
    29     29   #do_test num-equal-1.1.4 {
    30     30   #  sqlite4_num_compare +0 -0
    31     31   #} {equal}
           32  +
           33  +do_test num-2.1.1 {
           34  +  sqlite4_num_to_text [sqlite4_num_from_text 37]
           35  +} {37}
           36  +do_test num-2.1.2 {
           37  +  sqlite4_num_to_text [sqlite4_num_from_text 37 2]
           38  +} {37}
    32     39   
    33     40   finish_test

Changes to test/test_main.c.

  4437   4437       len = -1;
  4438   4438     }
  4439   4439   
  4440   4440     A = sqlite4_num_from_text( argv[1], len, 0 );
  4441   4441     append_num_result(interp, A);
  4442   4442     return TCL_OK;
  4443   4443   }
         4444  +
         4445  +static int test_num_to_text(
         4446  +  void *NotUsed,
         4447  +  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
         4448  +  int argc,              /* Number of arguments */
         4449  +  char **argv            /* Text of each argument */
         4450  +){
         4451  +  char text[30];
         4452  +  if( argc!=2 ){
         4453  +    Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
         4454  +      " NUM\"", 0);
         4455  +    return TCL_ERROR;
         4456  +  }
         4457  +  sqlite4_num_to_text( test_parse_num( argv[1] ), text );
         4458  +  Tcl_AppendResult( interp, text, 0 );
         4459  +  return TCL_OK;
         4460  +}
  4444   4461   
  4445   4462   /*
  4446   4463   ** Register commands with the TCL interpreter.
  4447   4464   */
  4448   4465   int Sqlitetest1_Init(Tcl_Interp *interp){
  4449   4466     extern int sqlite4_search_count;
  4450   4467     extern int sqlite4_found_count;
................................................................................
  4493   4510        { "sqlite_delete_collation",       (Tcl_CmdProc*)delete_collation      },
  4494   4511        { "sqlite4_get_autocommit",        (Tcl_CmdProc*)get_autocommit        },
  4495   4512        { "sqlite4_stack_used",            (Tcl_CmdProc*)test_stack_used       },
  4496   4513        { "printf",                        (Tcl_CmdProc*)test_printf           },
  4497   4514        { "sqlite4IoTrace",                (Tcl_CmdProc*)test_io_trace         },
  4498   4515        { "sqlite4_num_compare",           (Tcl_CmdProc*)test_num_compare      }, 
  4499   4516        { "sqlite4_num_from_text",         (Tcl_CmdProc*)test_num_from_text    }, 
         4517  +     { "sqlite4_num_to_text",           (Tcl_CmdProc*)test_num_to_text      }, 
  4500   4518     };
  4501   4519     static struct {
  4502   4520        char *zName;
  4503   4521        Tcl_ObjCmdProc *xProc;
  4504   4522        void *clientData;
  4505   4523     } aObjCmd[] = {
  4506   4524        { "sqlite4_connection_pointer",    get_sqlite_pointer, 0 },