Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 1 | // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #include <stdlib.h> |
| 29 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 30 | #include "src/v8.h" |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 31 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 32 | #include "src/base/platform/platform.h" |
| 33 | #include "src/double.h" |
| 34 | #include "src/fixed-dtoa.h" |
| 35 | #include "test/cctest/cctest.h" |
| 36 | #include "test/cctest/gay-fixed.h" |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 37 | |
| 38 | using namespace v8::internal; |
| 39 | |
| 40 | static const int kBufferSize = 500; |
| 41 | |
| 42 | TEST(FastFixedVariousDoubles) { |
| 43 | char buffer_container[kBufferSize]; |
| 44 | Vector<char> buffer(buffer_container, kBufferSize); |
| 45 | int length; |
| 46 | int point; |
| 47 | |
| 48 | CHECK(FastFixedDtoa(1.0, 1, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 49 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 50 | CHECK_EQ(1, point); |
| 51 | |
| 52 | CHECK(FastFixedDtoa(1.0, 15, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 53 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 54 | CHECK_EQ(1, point); |
| 55 | |
| 56 | CHECK(FastFixedDtoa(1.0, 0, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 57 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 58 | CHECK_EQ(1, point); |
| 59 | |
| 60 | CHECK(FastFixedDtoa(0xFFFFFFFF, 5, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 61 | CHECK_EQ(0, strcmp("4294967295", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 62 | CHECK_EQ(10, point); |
| 63 | |
| 64 | CHECK(FastFixedDtoa(4294967296.0, 5, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 65 | CHECK_EQ(0, strcmp("4294967296", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 66 | CHECK_EQ(10, point); |
| 67 | |
| 68 | CHECK(FastFixedDtoa(1e21, 5, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 69 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 70 | // CHECK_EQ(22, point); |
| 71 | CHECK_EQ(22, point); |
| 72 | |
| 73 | CHECK(FastFixedDtoa(999999999999999868928.00, 2, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 74 | CHECK_EQ(0, strcmp("999999999999999868928", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 75 | CHECK_EQ(21, point); |
| 76 | |
| 77 | CHECK(FastFixedDtoa(6.9999999999999989514240000e+21, 5, buffer, |
| 78 | &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 79 | CHECK_EQ(0, strcmp("6999999999999998951424", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 80 | CHECK_EQ(22, point); |
| 81 | |
| 82 | CHECK(FastFixedDtoa(1.5, 5, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 83 | CHECK_EQ(0, strcmp("15", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 84 | CHECK_EQ(1, point); |
| 85 | |
| 86 | CHECK(FastFixedDtoa(1.55, 5, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 87 | CHECK_EQ(0, strcmp("155", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 88 | CHECK_EQ(1, point); |
| 89 | |
| 90 | CHECK(FastFixedDtoa(1.55, 1, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 91 | CHECK_EQ(0, strcmp("16", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 92 | CHECK_EQ(1, point); |
| 93 | |
| 94 | CHECK(FastFixedDtoa(1.00000001, 15, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 95 | CHECK_EQ(0, strcmp("100000001", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 96 | CHECK_EQ(1, point); |
| 97 | |
| 98 | CHECK(FastFixedDtoa(0.1, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 99 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 100 | CHECK_EQ(0, point); |
| 101 | |
| 102 | CHECK(FastFixedDtoa(0.01, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 103 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 104 | CHECK_EQ(-1, point); |
| 105 | |
| 106 | CHECK(FastFixedDtoa(0.001, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 107 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 108 | CHECK_EQ(-2, point); |
| 109 | |
| 110 | CHECK(FastFixedDtoa(0.0001, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 111 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 112 | CHECK_EQ(-3, point); |
| 113 | |
| 114 | CHECK(FastFixedDtoa(0.00001, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 115 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 116 | CHECK_EQ(-4, point); |
| 117 | |
| 118 | CHECK(FastFixedDtoa(0.000001, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 119 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 120 | CHECK_EQ(-5, point); |
| 121 | |
| 122 | CHECK(FastFixedDtoa(0.0000001, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 123 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 124 | CHECK_EQ(-6, point); |
| 125 | |
| 126 | CHECK(FastFixedDtoa(0.00000001, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 127 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 128 | CHECK_EQ(-7, point); |
| 129 | |
| 130 | CHECK(FastFixedDtoa(0.000000001, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 131 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 132 | CHECK_EQ(-8, point); |
| 133 | |
| 134 | CHECK(FastFixedDtoa(0.0000000001, 15, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 135 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 136 | CHECK_EQ(-9, point); |
| 137 | |
| 138 | CHECK(FastFixedDtoa(0.00000000001, 15, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 139 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 140 | CHECK_EQ(-10, point); |
| 141 | |
| 142 | CHECK(FastFixedDtoa(0.000000000001, 15, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 143 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 144 | CHECK_EQ(-11, point); |
| 145 | |
| 146 | CHECK(FastFixedDtoa(0.0000000000001, 15, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 147 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 148 | CHECK_EQ(-12, point); |
| 149 | |
| 150 | CHECK(FastFixedDtoa(0.00000000000001, 15, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 151 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 152 | CHECK_EQ(-13, point); |
| 153 | |
| 154 | CHECK(FastFixedDtoa(0.000000000000001, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 155 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 156 | CHECK_EQ(-14, point); |
| 157 | |
| 158 | CHECK(FastFixedDtoa(0.0000000000000001, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 159 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 160 | CHECK_EQ(-15, point); |
| 161 | |
| 162 | CHECK(FastFixedDtoa(0.00000000000000001, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 163 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 164 | CHECK_EQ(-16, point); |
| 165 | |
| 166 | CHECK(FastFixedDtoa(0.000000000000000001, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 167 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 168 | CHECK_EQ(-17, point); |
| 169 | |
| 170 | CHECK(FastFixedDtoa(0.0000000000000000001, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 171 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 172 | CHECK_EQ(-18, point); |
| 173 | |
| 174 | CHECK(FastFixedDtoa(0.00000000000000000001, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 175 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 176 | CHECK_EQ(-19, point); |
| 177 | |
| 178 | CHECK(FastFixedDtoa(0.10000000004, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 179 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 180 | CHECK_EQ(0, point); |
| 181 | |
| 182 | CHECK(FastFixedDtoa(0.01000000004, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 183 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 184 | CHECK_EQ(-1, point); |
| 185 | |
| 186 | CHECK(FastFixedDtoa(0.00100000004, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 187 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 188 | CHECK_EQ(-2, point); |
| 189 | |
| 190 | CHECK(FastFixedDtoa(0.00010000004, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 191 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 192 | CHECK_EQ(-3, point); |
| 193 | |
| 194 | CHECK(FastFixedDtoa(0.00001000004, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 195 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 196 | CHECK_EQ(-4, point); |
| 197 | |
| 198 | CHECK(FastFixedDtoa(0.00000100004, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 199 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 200 | CHECK_EQ(-5, point); |
| 201 | |
| 202 | CHECK(FastFixedDtoa(0.00000010004, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 203 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 204 | CHECK_EQ(-6, point); |
| 205 | |
| 206 | CHECK(FastFixedDtoa(0.00000001004, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 207 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 208 | CHECK_EQ(-7, point); |
| 209 | |
| 210 | CHECK(FastFixedDtoa(0.00000000104, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 211 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 212 | CHECK_EQ(-8, point); |
| 213 | |
| 214 | CHECK(FastFixedDtoa(0.0000000001000004, 15, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 215 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 216 | CHECK_EQ(-9, point); |
| 217 | |
| 218 | CHECK(FastFixedDtoa(0.0000000000100004, 15, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 219 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 220 | CHECK_EQ(-10, point); |
| 221 | |
| 222 | CHECK(FastFixedDtoa(0.0000000000010004, 15, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 223 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 224 | CHECK_EQ(-11, point); |
| 225 | |
| 226 | CHECK(FastFixedDtoa(0.0000000000001004, 15, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 227 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 228 | CHECK_EQ(-12, point); |
| 229 | |
| 230 | CHECK(FastFixedDtoa(0.0000000000000104, 15, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 231 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 232 | CHECK_EQ(-13, point); |
| 233 | |
| 234 | CHECK(FastFixedDtoa(0.000000000000001000004, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 235 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 236 | CHECK_EQ(-14, point); |
| 237 | |
| 238 | CHECK(FastFixedDtoa(0.000000000000000100004, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 239 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 240 | CHECK_EQ(-15, point); |
| 241 | |
| 242 | CHECK(FastFixedDtoa(0.000000000000000010004, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 243 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 244 | CHECK_EQ(-16, point); |
| 245 | |
| 246 | CHECK(FastFixedDtoa(0.000000000000000001004, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 247 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 248 | CHECK_EQ(-17, point); |
| 249 | |
| 250 | CHECK(FastFixedDtoa(0.000000000000000000104, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 251 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 252 | CHECK_EQ(-18, point); |
| 253 | |
| 254 | CHECK(FastFixedDtoa(0.000000000000000000014, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 255 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 256 | CHECK_EQ(-19, point); |
| 257 | |
| 258 | CHECK(FastFixedDtoa(0.10000000006, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 259 | CHECK_EQ(0, strcmp("1000000001", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 260 | CHECK_EQ(0, point); |
| 261 | |
| 262 | CHECK(FastFixedDtoa(0.01000000006, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 263 | CHECK_EQ(0, strcmp("100000001", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 264 | CHECK_EQ(-1, point); |
| 265 | |
| 266 | CHECK(FastFixedDtoa(0.00100000006, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 267 | CHECK_EQ(0, strcmp("10000001", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 268 | CHECK_EQ(-2, point); |
| 269 | |
| 270 | CHECK(FastFixedDtoa(0.00010000006, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 271 | CHECK_EQ(0, strcmp("1000001", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 272 | CHECK_EQ(-3, point); |
| 273 | |
| 274 | CHECK(FastFixedDtoa(0.00001000006, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 275 | CHECK_EQ(0, strcmp("100001", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 276 | CHECK_EQ(-4, point); |
| 277 | |
| 278 | CHECK(FastFixedDtoa(0.00000100006, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 279 | CHECK_EQ(0, strcmp("10001", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 280 | CHECK_EQ(-5, point); |
| 281 | |
| 282 | CHECK(FastFixedDtoa(0.00000010006, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 283 | CHECK_EQ(0, strcmp("1001", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 284 | CHECK_EQ(-6, point); |
| 285 | |
| 286 | CHECK(FastFixedDtoa(0.00000001006, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 287 | CHECK_EQ(0, strcmp("101", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 288 | CHECK_EQ(-7, point); |
| 289 | |
| 290 | CHECK(FastFixedDtoa(0.00000000106, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 291 | CHECK_EQ(0, strcmp("11", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 292 | CHECK_EQ(-8, point); |
| 293 | |
| 294 | CHECK(FastFixedDtoa(0.0000000001000006, 15, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 295 | CHECK_EQ(0, strcmp("100001", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 296 | CHECK_EQ(-9, point); |
| 297 | |
| 298 | CHECK(FastFixedDtoa(0.0000000000100006, 15, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 299 | CHECK_EQ(0, strcmp("10001", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 300 | CHECK_EQ(-10, point); |
| 301 | |
| 302 | CHECK(FastFixedDtoa(0.0000000000010006, 15, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 303 | CHECK_EQ(0, strcmp("1001", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 304 | CHECK_EQ(-11, point); |
| 305 | |
| 306 | CHECK(FastFixedDtoa(0.0000000000001006, 15, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 307 | CHECK_EQ(0, strcmp("101", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 308 | CHECK_EQ(-12, point); |
| 309 | |
| 310 | CHECK(FastFixedDtoa(0.0000000000000106, 15, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 311 | CHECK_EQ(0, strcmp("11", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 312 | CHECK_EQ(-13, point); |
| 313 | |
| 314 | CHECK(FastFixedDtoa(0.000000000000001000006, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 315 | CHECK_EQ(0, strcmp("100001", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 316 | CHECK_EQ(-14, point); |
| 317 | |
| 318 | CHECK(FastFixedDtoa(0.000000000000000100006, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 319 | CHECK_EQ(0, strcmp("10001", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 320 | CHECK_EQ(-15, point); |
| 321 | |
| 322 | CHECK(FastFixedDtoa(0.000000000000000010006, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 323 | CHECK_EQ(0, strcmp("1001", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 324 | CHECK_EQ(-16, point); |
| 325 | |
| 326 | CHECK(FastFixedDtoa(0.000000000000000001006, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 327 | CHECK_EQ(0, strcmp("101", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 328 | CHECK_EQ(-17, point); |
| 329 | |
| 330 | CHECK(FastFixedDtoa(0.000000000000000000106, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 331 | CHECK_EQ(0, strcmp("11", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 332 | CHECK_EQ(-18, point); |
| 333 | |
| 334 | CHECK(FastFixedDtoa(0.000000000000000000016, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 335 | CHECK_EQ(0, strcmp("2", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 336 | CHECK_EQ(-19, point); |
| 337 | |
| 338 | CHECK(FastFixedDtoa(0.6, 0, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 339 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 340 | CHECK_EQ(1, point); |
| 341 | |
| 342 | CHECK(FastFixedDtoa(0.96, 1, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 343 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 344 | CHECK_EQ(1, point); |
| 345 | |
| 346 | CHECK(FastFixedDtoa(0.996, 2, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 347 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 348 | CHECK_EQ(1, point); |
| 349 | |
| 350 | CHECK(FastFixedDtoa(0.9996, 3, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 351 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 352 | CHECK_EQ(1, point); |
| 353 | |
| 354 | CHECK(FastFixedDtoa(0.99996, 4, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 355 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 356 | CHECK_EQ(1, point); |
| 357 | |
| 358 | CHECK(FastFixedDtoa(0.999996, 5, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 359 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 360 | CHECK_EQ(1, point); |
| 361 | |
| 362 | CHECK(FastFixedDtoa(0.9999996, 6, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 363 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 364 | CHECK_EQ(1, point); |
| 365 | |
| 366 | CHECK(FastFixedDtoa(0.99999996, 7, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 367 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 368 | CHECK_EQ(1, point); |
| 369 | |
| 370 | CHECK(FastFixedDtoa(0.999999996, 8, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 371 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 372 | CHECK_EQ(1, point); |
| 373 | |
| 374 | CHECK(FastFixedDtoa(0.9999999996, 9, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 375 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 376 | CHECK_EQ(1, point); |
| 377 | |
| 378 | CHECK(FastFixedDtoa(0.99999999996, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 379 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 380 | CHECK_EQ(1, point); |
| 381 | |
| 382 | CHECK(FastFixedDtoa(0.999999999996, 11, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 383 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 384 | CHECK_EQ(1, point); |
| 385 | |
| 386 | CHECK(FastFixedDtoa(0.9999999999996, 12, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 387 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 388 | CHECK_EQ(1, point); |
| 389 | |
| 390 | CHECK(FastFixedDtoa(0.99999999999996, 13, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 391 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 392 | CHECK_EQ(1, point); |
| 393 | |
| 394 | CHECK(FastFixedDtoa(0.999999999999996, 14, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 395 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 396 | CHECK_EQ(1, point); |
| 397 | |
| 398 | CHECK(FastFixedDtoa(0.9999999999999996, 15, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 399 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 400 | CHECK_EQ(1, point); |
| 401 | |
| 402 | CHECK(FastFixedDtoa(0.00999999999999996, 16, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 403 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 404 | CHECK_EQ(-1, point); |
| 405 | |
| 406 | CHECK(FastFixedDtoa(0.000999999999999996, 17, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 407 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 408 | CHECK_EQ(-2, point); |
| 409 | |
| 410 | CHECK(FastFixedDtoa(0.0000999999999999996, 18, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 411 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 412 | CHECK_EQ(-3, point); |
| 413 | |
| 414 | CHECK(FastFixedDtoa(0.00000999999999999996, 19, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 415 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 416 | CHECK_EQ(-4, point); |
| 417 | |
| 418 | CHECK(FastFixedDtoa(0.000000999999999999996, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 419 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 420 | CHECK_EQ(-5, point); |
| 421 | |
| 422 | CHECK(FastFixedDtoa(323423.234234, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 423 | CHECK_EQ(0, strcmp("323423234234", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 424 | CHECK_EQ(6, point); |
| 425 | |
| 426 | CHECK(FastFixedDtoa(12345678.901234, 4, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 427 | CHECK_EQ(0, strcmp("123456789012", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 428 | CHECK_EQ(8, point); |
| 429 | |
| 430 | CHECK(FastFixedDtoa(98765.432109, 5, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 431 | CHECK_EQ(0, strcmp("9876543211", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 432 | CHECK_EQ(5, point); |
| 433 | |
| 434 | CHECK(FastFixedDtoa(42, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 435 | CHECK_EQ(0, strcmp("42", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 436 | CHECK_EQ(2, point); |
| 437 | |
| 438 | CHECK(FastFixedDtoa(0.5, 0, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 439 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 440 | CHECK_EQ(1, point); |
| 441 | |
| 442 | CHECK(FastFixedDtoa(1e-23, 10, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 443 | CHECK_EQ(0, strcmp("", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 444 | CHECK_EQ(-10, point); |
| 445 | |
| 446 | CHECK(FastFixedDtoa(1e-123, 2, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 447 | CHECK_EQ(0, strcmp("", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 448 | CHECK_EQ(-2, point); |
| 449 | |
| 450 | CHECK(FastFixedDtoa(1e-123, 0, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 451 | CHECK_EQ(0, strcmp("", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 452 | CHECK_EQ(0, point); |
| 453 | |
| 454 | CHECK(FastFixedDtoa(1e-23, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 455 | CHECK_EQ(0, strcmp("", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 456 | CHECK_EQ(-20, point); |
| 457 | |
| 458 | CHECK(FastFixedDtoa(1e-21, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 459 | CHECK_EQ(0, strcmp("", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 460 | CHECK_EQ(-20, point); |
| 461 | |
| 462 | CHECK(FastFixedDtoa(1e-22, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 463 | CHECK_EQ(0, strcmp("", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 464 | CHECK_EQ(-20, point); |
| 465 | |
| 466 | CHECK(FastFixedDtoa(6e-21, 20, buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 467 | CHECK_EQ(0, strcmp("1", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 468 | CHECK_EQ(-19, point); |
| 469 | |
| 470 | CHECK(FastFixedDtoa(9.1193616301674545152000000e+19, 0, |
| 471 | buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 472 | CHECK_EQ(0, strcmp("91193616301674545152", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 473 | CHECK_EQ(20, point); |
| 474 | |
| 475 | CHECK(FastFixedDtoa(4.8184662102767651659096515e-04, 19, |
| 476 | buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 477 | CHECK_EQ(0, strcmp("4818466210276765", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 478 | CHECK_EQ(-3, point); |
| 479 | |
| 480 | CHECK(FastFixedDtoa(1.9023164229540652612705182e-23, 8, |
| 481 | buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 482 | CHECK_EQ(0, strcmp("", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 483 | CHECK_EQ(-8, point); |
| 484 | |
| 485 | CHECK(FastFixedDtoa(1000000000000000128.0, 0, |
| 486 | buffer, &length, &point)); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 487 | CHECK_EQ(0, strcmp("1000000000000000128", buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 488 | CHECK_EQ(19, point); |
| 489 | } |
| 490 | |
| 491 | |
| 492 | TEST(FastFixedDtoaGayFixed) { |
| 493 | char buffer_container[kBufferSize]; |
| 494 | Vector<char> buffer(buffer_container, kBufferSize); |
| 495 | bool status; |
| 496 | int length; |
| 497 | int point; |
| 498 | |
| 499 | Vector<const PrecomputedFixed> precomputed = |
| 500 | PrecomputedFixedRepresentations(); |
| 501 | for (int i = 0; i < precomputed.length(); ++i) { |
| 502 | const PrecomputedFixed current_test = precomputed[i]; |
| 503 | double v = current_test.v; |
| 504 | int number_digits = current_test.number_digits; |
| 505 | status = FastFixedDtoa(v, number_digits, |
| 506 | buffer, &length, &point); |
| 507 | CHECK(status); |
| 508 | CHECK_EQ(current_test.decimal_point, point); |
| 509 | CHECK_GE(number_digits, length - point); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 510 | CHECK_EQ(0, strcmp(current_test.representation, buffer.start())); |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 511 | } |
| 512 | } |