@@ -17,11 +17,13 @@ impl fmt::Display for Error {
17
17
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
18
18
match self {
19
19
Error :: TypeError => write ! ( f, "TypeError: Wrong type" ) ,
20
- Error :: UnknownVariable => write ! ( f, "UnknownVariable: Unknown varialbe passed" ) ,
20
+ Error :: UnknownVariable => write ! ( f, "UnknownVariable: Unknown variable passed" ) ,
21
21
}
22
22
}
23
23
}
24
24
25
+ impl std:: error:: Error for Error { }
26
+
25
27
#[ derive( Debug , Serialize , Deserialize , Clone , PartialEq , Eq ) ]
26
28
#[ serde( untagged) ]
27
29
pub enum Rule {
@@ -322,17 +324,11 @@ mod test {
322
324
use crate :: targeting:: AdSlot ;
323
325
324
326
#[ test]
325
- fn deserialzes_intersects_rule ( ) {
327
+ fn deserialize_intersects_with_get_rule ( ) {
326
328
let json = r#"{"intersects": [{ "get": "adSlot.categories" }, ["News", "Bitcoin"]]}"# ;
327
329
328
330
let parsed_rule = serde_json:: from_str :: < Rule > ( json) . expect ( "Should deserialize" ) ;
329
331
330
- let mut expected_map = Map :: new ( ) ;
331
- expected_map. insert (
332
- "get" . to_string ( ) ,
333
- SerdeValue :: String ( "adSlot.categories" . to_string ( ) ) ,
334
- ) ;
335
-
336
332
let expected = Rule :: Function ( Function :: new_intersects (
337
333
Rule :: Function ( Function :: new_get ( "adSlot.categories" ) ) ,
338
334
Rule :: Value ( Value :: Array ( vec ! [
@@ -383,7 +379,7 @@ mod test {
383
379
384
380
assert_eq ! (
385
381
Value :: Bool ( true ) ,
386
- result. expect( "Sould return Non-NULL result!" )
382
+ result. expect( "Should return Non-NULL result!" )
387
383
) ;
388
384
389
385
let mut input = Input :: default ( ) ;
@@ -397,7 +393,7 @@ mod test {
397
393
398
394
assert_eq ! (
399
395
Value :: Bool ( false ) ,
400
- result. expect( "Sould return Non-NULL result!" )
396
+ result. expect( "Should return Non-NULL result!" )
401
397
) ;
402
398
}
403
399
@@ -456,12 +452,12 @@ mod test {
456
452
457
453
let cases = vec ! [
458
454
( Value :: new_string( "1000" ) , Value :: BigNum ( 1000 . into( ) ) ) ,
459
- ( Value :: new_number( 5000 ) , Value :: BigNum ( 5000 . into( ) ) ) ,
460
- ( Value :: BigNum ( 2 . into( ) ) , Value :: BigNum ( 2 . into( ) ) ) ,
455
+ ( Value :: new_number( 2_000 ) , Value :: BigNum ( 2_000 . into( ) ) ) ,
456
+ ( Value :: BigNum ( 3 . into( ) ) , Value :: BigNum ( 3 . into( ) ) ) ,
461
457
// rounded floats should work!
462
458
(
463
- Value :: Number ( Number :: from_f64( 2 .0) . expect( "should create float number" ) ) ,
464
- Value :: BigNum ( 2 . into( ) ) ,
459
+ Value :: Number ( Number :: from_f64( 40 .0) . expect( "should create float number" ) ) ,
460
+ Value :: BigNum ( 40 . into( ) ) ,
465
461
) ,
466
462
] ;
467
463
@@ -483,7 +479,7 @@ mod test {
483
479
484
480
let error_cases = vec ! [
485
481
Value :: new_string( "text" ) ,
486
- // BigNums can only be possitive
482
+ // BigNums can only be positive
487
483
Value :: new_number( -100 ) ,
488
484
Value :: Bool ( true ) ,
489
485
Value :: Array ( vec![ Value :: Bool ( false ) ] ) ,
0 commit comments