SQLite4
Check-in [fd1c1a7d4f]
Not logged in

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

Overview
Comment:Add tests for the pbReal output of sqlite4_num_from_text
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: fd1c1a7d4fdde4a91e6902db3a625135131eb4ef
User & Date: peterreid 2013-10-24 23:54:50
Context
2013-10-24
23:59
Fixed flagging infinity as a real (instead of an integer) in sqlite4_num_from_text check-in: 73b8f01f49 user: peterreid tags: trunk
23:54
Add tests for the pbReal output of sqlite4_num_from_text check-in: fd1c1a7d4f user: peterreid tags: trunk
19:59
Updates to code to read log files. check-in: aabb6dacf6 user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/num.test.

235
236
237
238
239
240
241








242
243
244
245
246
  7     -2147483648                                  -2147483648 
  8     {sign:0 approx:1 e:4 m:2}                    ~20000
  9     .00034                                       ~0
  10    -.99                                         ~0
} {
  do_test num-11.1.$tn { sqlite4_num_to_int32 $in } [list {*}$out]
}









#-------------------------------------------------------------------------
finish_test









>
>
>
>
>
>
>
>





235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
  7     -2147483648                                  -2147483648 
  8     {sign:0 approx:1 e:4 m:2}                    ~20000
  9     .00034                                       ~0
  10    -.99                                         ~0
} {
  do_test num-11.1.$tn { sqlite4_num_to_int32 $in } [list {*}$out]
}

foreach {tn in real} {
  0     4              false
  1     -84.63         true
} {
  do_test num-12.1-$tn { sqlite4_num_text_is_real $in } $real
}


#-------------------------------------------------------------------------
finish_test


Changes to test/test_num.c.

103
104
105
106
107
108
109

























110
111
112
113
114
115
116
...
292
293
294
295
296
297
298

299
300
301
302
303
304
305
    len = -1;
  }

  A = sqlite4_num_from_text(argv[1], len, 0, 0);
  append_num_result(interp, A);
  return TCL_OK;
}


























static int test_num_to_text(
  void *NotUsed,
  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
  int argc,              /* Number of arguments */
  char **argv            /* Text of each argument */
){
................................................................................
int Sqlitetest_num_init(Tcl_Interp *interp){
  static struct {
     char *zName;
     Tcl_CmdProc *xProc;
  } aCmd[] = {
     { "sqlite4_num_compare",           (Tcl_CmdProc*)test_num_compare      }, 
     { "sqlite4_num_from_text",         (Tcl_CmdProc*)test_num_from_text    }, 

     { "sqlite4_num_to_text",           (Tcl_CmdProc*)test_num_to_text      },
     { "sqlite4_num_add",               (Tcl_CmdProc*)test_num_add          },
     { "sqlite4_num_sub",               (Tcl_CmdProc*)test_num_sub          },
     { "sqlite4_num_mul",               (Tcl_CmdProc*)test_num_mul          },
     { "sqlite4_num_div",               (Tcl_CmdProc*)test_num_div          },
     { "sqlite4_num_isinf",             (Tcl_CmdProc*)test_num_isinf        },
     { "sqlite4_num_isnan",             (Tcl_CmdProc*)test_num_isnan        },







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







 







>







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
...
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
    len = -1;
  }

  A = sqlite4_num_from_text(argv[1], len, 0, 0);
  append_num_result(interp, A);
  return TCL_OK;
}

static int test_num_text_is_real(
  void *NotUsed,
  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
  int argc,              /* Number of arguments */
  char **argv            /* Text of each argument */
){
  int pbReal;
  int len;
  if( argc!=2 && argc!=3 ){
    Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
      " STRING\" or \"", argv[0], " STRING INTEGER\"", 0);
    return TCL_ERROR;
  }

  if( argc==3 ){
    if ( Tcl_GetInt(interp, argv[2], &len) ) return TCL_ERROR; 
  }else{
    len = -1;
  }

  sqlite4_num_from_text(argv[1], len, 0, &pbReal);
  Tcl_AppendResult( interp, pbReal ? "true" : "false", 0 );
  return TCL_OK;
}

static int test_num_to_text(
  void *NotUsed,
  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
  int argc,              /* Number of arguments */
  char **argv            /* Text of each argument */
){
................................................................................
int Sqlitetest_num_init(Tcl_Interp *interp){
  static struct {
     char *zName;
     Tcl_CmdProc *xProc;
  } aCmd[] = {
     { "sqlite4_num_compare",           (Tcl_CmdProc*)test_num_compare      }, 
     { "sqlite4_num_from_text",         (Tcl_CmdProc*)test_num_from_text    }, 
     { "sqlite4_num_text_is_real",      (Tcl_CmdProc*)test_num_text_is_real }, 
     { "sqlite4_num_to_text",           (Tcl_CmdProc*)test_num_to_text      },
     { "sqlite4_num_add",               (Tcl_CmdProc*)test_num_add          },
     { "sqlite4_num_sub",               (Tcl_CmdProc*)test_num_sub          },
     { "sqlite4_num_mul",               (Tcl_CmdProc*)test_num_mul          },
     { "sqlite4_num_div",               (Tcl_CmdProc*)test_num_div          },
     { "sqlite4_num_isinf",             (Tcl_CmdProc*)test_num_isinf        },
     { "sqlite4_num_isnan",             (Tcl_CmdProc*)test_num_isnan        },