@@ -287,8 +287,10 @@ pub fn natural_logarithm_test() {
287
287
let assert Ok ( tol ) = float . power ( 10.0 , -6.0 )
288
288
// Check that the function agrees, at some arbitrary input
289
289
// points, with known function values
290
- maths . natural_logarithm ( 1.0 )
291
- |> should . equal ( Ok ( 0.0 ) )
290
+ let assert Ok ( result ) = maths . natural_logarithm ( 1.0 )
291
+ result
292
+ |> maths . is_close ( 0.0 , 0.0 , tol )
293
+ |> should . be_true ( )
292
294
293
295
let assert Ok ( result ) = maths . natural_logarithm ( 0.5 )
294
296
result
@@ -302,17 +304,24 @@ pub fn natural_logarithm_test() {
302
304
}
303
305
304
306
pub fn logarithm_test ( ) {
307
+ let assert Ok ( tol ) = float . power ( 10.0 , -6.0 )
308
+
305
309
// Check that the function agrees, at some arbitrary input
306
310
// points, with known function values
307
- maths . logarithm ( 10.0 , 10.0 )
308
- |> should . equal ( Ok ( 1.0 ) )
309
-
310
- maths . logarithm ( 10.0 , 100.0 )
311
- |> should . equal ( Ok ( 0.5 ) )
311
+ let assert Ok ( result ) = maths . logarithm ( 10.0 , 10.0 )
312
+ result
313
+ |> maths . is_close ( 1.0 , 0.0 , tol )
314
+ |> should . be_true ( )
312
315
313
- maths . logarithm ( 1.0 , 0.25 )
314
- |> should . equal ( Ok ( 0.0 ) )
316
+ let assert Ok ( result ) = maths . logarithm ( 10.0 , 100.0 )
317
+ result
318
+ |> maths . is_close ( 0.5 , 0.0 , tol )
319
+ |> should . be_true ( )
315
320
321
+ let assert Ok ( result ) = maths . logarithm ( 1.0 , 0.25 )
322
+ result
323
+ |> maths . is_close ( 0.0 , 0.0 , tol )
324
+ |> should . be_true ( )
316
325
// Check that we get an error when the function is evaluated
317
326
// outside its domain
318
327
maths . logarithm ( 1.0 , 1.0 )
@@ -324,11 +333,15 @@ pub fn logarithm_test() {
324
333
maths . logarithm ( -1.0 , 1.0 )
325
334
|> should . be_error ( )
326
335
327
- maths . logarithm ( 1.0 , 10.0 )
328
- |> should . equal ( Ok ( 0.0 ) )
336
+ let assert Ok ( result ) = maths . logarithm ( 1.0 , 10.0 )
337
+ result
338
+ |> maths . is_close ( 0.0 , 0.0 , tol )
339
+ |> should . be_true ( )
329
340
330
- maths . logarithm ( maths . e ( ) , maths . e ( ) )
331
- |> should . equal ( Ok ( 1.0 ) )
341
+ let assert Ok ( result ) = maths . logarithm ( maths . e ( ) , maths . e ( ) )
342
+ result
343
+ |> maths . is_close ( 1.0 , 0.0 , tol )
344
+ |> should . be_true ( )
332
345
333
346
maths . logarithm ( -1.0 , 2.0 )
334
347
|> should . be_error ( )
@@ -338,11 +351,15 @@ pub fn logarithm_2_test() {
338
351
let assert Ok ( tol ) = float . power ( 10.0 , -6.0 )
339
352
// Check that the function agrees, at some arbitrary input
340
353
// points, with known function values
341
- maths . logarithm_2 ( 1.0 )
342
- |> should . equal ( Ok ( 0.0 ) )
354
+ let assert Ok ( result ) = maths . logarithm_2 ( 1.0 )
355
+ result
356
+ |> maths . is_close ( 0.0 , 0.0 , tol )
357
+ |> should . be_true ( )
343
358
344
- maths . logarithm_2 ( 2.0 )
345
- |> should . equal ( Ok ( 1.0 ) )
359
+ let assert Ok ( result ) = maths . logarithm_2 ( 2.0 )
360
+ result
361
+ |> maths . is_close ( 1.0 , 0.0 , tol )
362
+ |> should . be_true ( )
346
363
347
364
let assert Ok ( result ) = maths . logarithm_2 ( 5.0 )
348
365
result
0 commit comments