diff options
| author | Mike Buland <mike@xagasoft.com> | 2014-09-17 09:58:13 -0600 |
|---|---|---|
| committer | Mike Buland <mike@xagasoft.com> | 2014-09-17 09:58:13 -0600 |
| commit | d830593dda9525f12695c8ba2b4f62aa56658687 (patch) | |
| tree | 0fee9ba5b755dc7b5290bc40b35ec248b044756f /src/unitnumber.cpp | |
| parent | 3ada65d36621787f8dd103e9ae19083ef3c1df5b (diff) | |
| download | clic-d830593dda9525f12695c8ba2b4f62aa56658687.tar.gz clic-d830593dda9525f12695c8ba2b4f62aa56658687.tar.bz2 clic-d830593dda9525f12695c8ba2b4f62aa56658687.tar.xz clic-d830593dda9525f12695c8ba2b4f62aa56658687.zip | |
Added a unit test that breaks divide.
Diffstat (limited to 'src/unitnumber.cpp')
| -rw-r--r-- | src/unitnumber.cpp | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/src/unitnumber.cpp b/src/unitnumber.cpp index 92cf1b7..6e1a7c8 100644 --- a/src/unitnumber.cpp +++ b/src/unitnumber.cpp | |||
| @@ -121,6 +121,43 @@ void UnitNumber::number1() | |||
| 121 | "18446744073709551615", | 121 | "18446744073709551615", |
| 122 | "2034904753109530147"); | 122 | "2034904753109530147"); |
| 123 | } | 123 | } |
| 124 | #undef mathTest | ||
| 125 | |||
| 126 | #define mathTest( anum, op, bnum, scale, answ ) \ | ||
| 127 | unitTest( (Number(anum, scale) op Number(bnum, scale)).toString() == answ ) | ||
| 128 | /* | ||
| 129 | void UnitNumber::number2() | ||
| 130 | { | ||
| 131 | mathTest( "1", /, "17", 10, "0.0588235294" ); | ||
| 132 | mathTest( "1", /, "177", 10, "0.0056497175" ); | ||
| 133 | } | ||
| 134 | */ | ||
| 135 | |||
| 136 | /* | ||
| 137 | // clic | ||
| 138 | 1/17 | ||
| 139 | 0.0588235294 | ||
| 140 | 1/177 | ||
| 141 | 0.0005649717 | ||
| 142 | |||
| 143 | |||
| 144 | // bc | ||
| 145 | 1/17 | ||
| 146 | .0588235294 | ||
| 147 | 1/177 | ||
| 148 | .0056497175 | ||
| 149 | |||
| 150 | |||
| 151 | 1/17 | ||
| 152 | bc: .0588235294 | ||
| 153 | clic: 0.0588235294 | ||
| 154 | |||
| 155 | 1/177 | ||
| 156 | bc: .0056497175 | ||
| 157 | clic: 0.0005649717 | ||
| 158 | */ | ||
| 159 | //} | ||
| 160 | #undef mathTest | ||
| 124 | 161 | ||
| 125 | #define compcheck( anum, op, bnum ) \ | 162 | #define compcheck( anum, op, bnum ) \ |
| 126 | a = #anum; b = #bnum; \ | 163 | a = #anum; b = #bnum; \ |
| @@ -255,8 +292,6 @@ void UnitNumber::radix1() | |||
| 255 | 292 | ||
| 256 | void UnitNumber::fraction1() | 293 | void UnitNumber::fraction1() |
| 257 | { | 294 | { |
| 258 | Number a( 8 ), b( 8 ); | ||
| 259 | |||
| 260 | mathTestS( 8, "123.456", +, "0.987", "124.443" ); | 295 | mathTestS( 8, "123.456", +, "0.987", "124.443" ); |
| 261 | mathTestS( 8, "123.456", -, "0.987", "122.469" ); | 296 | mathTestS( 8, "123.456", -, "0.987", "122.469" ); |
| 262 | mathTestS( 8, "123.456", *, "0.987", "121.851072" ); | 297 | mathTestS( 8, "123.456", *, "0.987", "121.851072" ); |
| @@ -264,5 +299,8 @@ void UnitNumber::fraction1() | |||
| 264 | 299 | ||
| 265 | mathTestS( 8, "12", /, "4", "3" ); | 300 | mathTestS( 8, "12", /, "4", "3" ); |
| 266 | mathTestS( 100, "9", /, "1.9", "4.7368421052631578947368421052631578947368421052631578947368421052631578947368421052631578947368421052" ); | 301 | mathTestS( 100, "9", /, "1.9", "4.7368421052631578947368421052631578947368421052631578947368421052631578947368421052631578947368421052" ); |
| 302 | |||
| 303 | mathTestS( 10, "1", /, "17", "0.0588235294" ); | ||
| 304 | mathTestS( 10, "1", /, "177", "0.0056497175" ); | ||
| 267 | } | 305 | } |
| 268 | 306 | ||
