SQLite4
Check-in [91bfc9e7d7]
Not logged in

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

Overview
Comment:Add sqlite4_num_add/sub/mul/div to testfixture and some tests that use them.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | num_work
Files: files | file ages | folders
SHA1: 91bfc9e7d7018a98ee03f26162969a744f51c7cf
User & Date: peterreid 2013-02-10 22:03:48
Context
2013-02-11
04:09
Num comparison says that +0 = -0. Before, 1-1 > (-1)-(-1). check-in: 13d342510f user: peterreid tags: num_work
2013-02-10
22:03
Add sqlite4_num_add/sub/mul/div to testfixture and some tests that use them. check-in: 91bfc9e7d7 user: peterreid tags: num_work
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
Changes
Hide Diffs Unified Diffs Show Whitespace Changes Patch

Changes to test/num.test.

32
33
34
35
36
37
38



39






















40

do_test num-2.1.1 {
  sqlite4_num_to_text [sqlite4_num_from_text 37]
} {37}
do_test num-2.1.2 {
  sqlite4_num_to_text [sqlite4_num_from_text 37 2]
} {37}


























finish_test







>
>
>

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

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

do_test num-2.1.1 {
  sqlite4_num_to_text [sqlite4_num_from_text 37]
} {37}
do_test num-2.1.2 {
  sqlite4_num_to_text [sqlite4_num_from_text 37 2]
} {37}
do_test num-2.1.4 {
  sqlite4_num_compare [sqlite4_num_from_text 2.9e2X 5] 290
} {equal}

do_test num-3.1.1 {
  sqlite4_num_to_text [sqlite4_num_add 5 7]
} {12}

do_test num-4.1.1 {
  sqlite4_num_to_text [sqlite4_num_sub 9 3]
} {6}
do_test num-4.1.2 {
  sqlite4_num_to_text [sqlite4_num_sub 5 12]
} {-7}

do_test num-5.1.1 {
  sqlite4_num_to_text [sqlite4_num_mul 9 8]
} {72}

do_test num-6.1.1 {
  sqlite4_num_to_text [sqlite4_num_div 6 5]
} {1.2}




finish_test

Changes to test/test_main.c.

4454
4455
4456
4457
4458
4459
4460























































4461
4462
4463
4464
4465
4466
4467
....
4511
4512
4513
4514
4515
4516
4517





4518
4519
4520
4521
4522
4523
4524
      " NUM\"", 0);
    return TCL_ERROR;
  }
  sqlite4_num_to_text( test_parse_num( argv[1] ), text );
  Tcl_AppendResult( interp, text, 0 );
  return TCL_OK;
}
























































/*
** Register commands with the TCL interpreter.
*/
int Sqlitetest1_Init(Tcl_Interp *interp){
  extern int sqlite4_search_count;
  extern int sqlite4_found_count;
................................................................................
     { "sqlite4_get_autocommit",        (Tcl_CmdProc*)get_autocommit        },
     { "sqlite4_stack_used",            (Tcl_CmdProc*)test_stack_used       },
     { "printf",                        (Tcl_CmdProc*)test_printf           },
     { "sqlite4IoTrace",                (Tcl_CmdProc*)test_io_trace         },
     { "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      }, 





  };
  static struct {
     char *zName;
     Tcl_ObjCmdProc *xProc;
     void *clientData;
  } aObjCmd[] = {
     { "sqlite4_connection_pointer",    get_sqlite_pointer, 0 },







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







 







>
>
>
>
>







4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
....
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
      " NUM\"", 0);
    return TCL_ERROR;
  }
  sqlite4_num_to_text( test_parse_num( argv[1] ), text );
  Tcl_AppendResult( interp, text, 0 );
  return TCL_OK;
}

static int test_num_binary_op(
  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
  int argc,              /* Number of arguments */
  char **argv,            /* Text of each argument */
  sqlite4_num (*op) (sqlite4_num, sqlite4_num)
){
  sqlite4_num A, B, R;
  if( argc!=3 ){
    Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
      " NUM NUM\"", 0);
    return TCL_ERROR;
  }
  A = test_parse_num(argv[1]);
  B = test_parse_num(argv[2]);
  R = op(A, B);
  append_num_result(interp, R);
  return TCL_OK;
}

static int test_num_add(
  void *NotUsed,
  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
  int argc,              /* Number of arguments */
  char **argv            /* Text of each argument */
){
  return test_num_binary_op( interp, argc, argv, sqlite4_num_add );
}

static int test_num_sub(
  void *NotUsed,
  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
  int argc,              /* Number of arguments */
  char **argv            /* Text of each argument */
){
  return test_num_binary_op( interp, argc, argv, sqlite4_num_sub );
}

static int test_num_mul(
  void *NotUsed,
  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
  int argc,              /* Number of arguments */
  char **argv            /* Text of each argument */
){
  return test_num_binary_op( interp, argc, argv, sqlite4_num_mul );
}

static int test_num_div(
  void *NotUsed,
  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
  int argc,              /* Number of arguments */
  char **argv            /* Text of each argument */
){
  return test_num_binary_op( interp, argc, argv, sqlite4_num_div );
}

/*
** Register commands with the TCL interpreter.
*/
int Sqlitetest1_Init(Tcl_Interp *interp){
  extern int sqlite4_search_count;
  extern int sqlite4_found_count;
................................................................................
     { "sqlite4_get_autocommit",        (Tcl_CmdProc*)get_autocommit        },
     { "sqlite4_stack_used",            (Tcl_CmdProc*)test_stack_used       },
     { "printf",                        (Tcl_CmdProc*)test_printf           },
     { "sqlite4IoTrace",                (Tcl_CmdProc*)test_io_trace         },
     { "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          },
   
  };
  static struct {
     char *zName;
     Tcl_ObjCmdProc *xProc;
     void *clientData;
  } aObjCmd[] = {
     { "sqlite4_connection_pointer",    get_sqlite_pointer, 0 },