Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Unified Diff: third_party/sqlite/src/test/atof1.test

Issue 949043002: Add //third_party/sqlite to dirs_to_snapshot, remove net_sql.patch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/sqlite/src/test/async5.test ('k') | third_party/sqlite/src/test/attach.test » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/test/atof1.test
diff --git a/third_party/sqlite/src/test/atof1.test b/third_party/sqlite/src/test/atof1.test
new file mode 100644
index 0000000000000000000000000000000000000000..5c04d022904702877003052202eb01a53757d263
--- /dev/null
+++ b/third_party/sqlite/src/test/atof1.test
@@ -0,0 +1,60 @@
+# 2012 June 18
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Tests of the sqlite3AtoF() function.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+if {![info exists __GNUC__] || [regexp arm $tcl_platform(machine)]} {
+ finish_test
+ return
+}
+
+expr srand(1)
+for {set i 1} {$i<20000} {incr i} {
+ set pow [expr {int((rand()-0.5)*100)}]
+ set x [expr {pow((rand()-0.5)*2*rand(),$pow)}]
+ set xf [format %.32e $x]
+
+ # Verify that text->real conversions get exactly same ieee754 floating-
+ # point value in SQLite as they do in TCL.
+ #
+ do_test atof1-1.$i.1 {
+ set y [db eval "SELECT $xf=\$x"]
+ if {!$y} {
+ puts -nonewline \173[db eval "SELECT real2hex($xf), real2hex(\$x)"]\175
+ db eval "SELECT $xf+0.0 AS a, \$x AS b" {
+ puts [format "\n%.60e\n%.60e\n%.60e" $x $a $b]
+ }
+ }
+ set y
+ } {1}
+
+ # Verify that round-trip real->text->real conversions using the quote()
+ # function preserve the bits of the numeric value exactly.
+ #
+ do_test atof1-1.$i.2 {
+ set y [db eval {SELECT $x=CAST(quote($x) AS real)}]
+ if {!$y} {
+ db eval {SELECT real2hex($x) a, real2hex(CAST(quote($x) AS real)) b} {}
+ puts "\nIN: $a $xf"
+ puts [format {QUOTE: %16s %s} {} [db eval {SELECT quote($x)}]]
+ db eval {SELECT CAST(quote($x) AS real) c} {}
+ puts "OUT: $b [format %.32e $c]"
+ }
+ set y
+ } {1}
+}
+
+
+finish_test
« no previous file with comments | « third_party/sqlite/src/test/async5.test ('k') | third_party/sqlite/src/test/attach.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698