Debian Codegraph @

src/keywords/multiple_of.rs

raw symbols SCIP
1 use craterust-analyzer cargo jsonschema 0.37.4 crate/::{
2 compilerrust-analyzer cargo jsonschema 0.37.4 compiler/,
3 errorrust-analyzer cargo jsonschema 0.37.4 error/::ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#,
4 extrust-analyzer cargo jsonschema 0.37.4 ext/::numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/,
5 keywordsrust-analyzer cargo jsonschema 0.37.4 keywords/::CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#,
6 pathsrust-analyzer cargo jsonschema 0.37.4 paths/::{LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#},
7 typesrust-analyzer cargo jsonschema 0.37.4 types/::JsonTyperust-analyzer cargo jsonschema 0.37.4 types/JsonType#,
8 validatorrust-analyzer cargo jsonschema 0.37.4 validator/::{Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate#, ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#},
9 };
10 use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::{Maprust-analyzer cargo serde_json 1.0.145 map/Map#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#};
11
12 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct MultipleOfFloatValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfFloatValidator# {
13 multiple_ofrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfFloatValidator#multiple_of.: f64,
14 #[cfg(feature = "arbitrary-precision")]
15 original_valuerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfFloatValidator#original_value.: serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Numberrust-analyzer cargo serde_json 1.0.145 number/Number#,
16 locationrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfFloatValidator#location.: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#,
17 }
18
19 impl MultipleOfFloatValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfFloatValidator# {
20 #[inline]
21 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/impl#[MultipleOfFloatValidator]compile().<'a>(
22 multiple_of: f64,
23 #[cfg(feature = "arbitrary-precision")] original_value: &serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Numberrust-analyzer cargo serde_json 1.0.145 number/Number#,
24 location: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#,
25 ) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> {
26 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(MultipleOfFloatValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfFloatValidator# {
27 multiple_ofrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfFloatValidator#multiple_of.,
28 #[cfg(feature = "arbitrary-precision")]
29 original_valuerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfFloatValidator#original_value.: original_value.clonerust-analyzer cargo serde_json 1.0.145 number/impl#[Number][Clone]clone().(),
30 locationrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfFloatValidator#location.,
31 }))
32 }
33 }
34
35 impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for MultipleOfFloatValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfFloatValidator# {
36 fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/impl#[MultipleOfFloatValidator][Validate]is_valid().(&self, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, _ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#) -> bool {
37 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Numberrust-analyzer cargo serde_json 1.0.145 value/Value#Number#(item) = instance {
38 numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::is_multiple_of_floatrust-analyzer cargo jsonschema 0.37.4 ext/numeric/is_multiple_of_float().(item, self.multiple_ofrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfFloatValidator#multiple_of.)
39 } else {
40 true
41 }
42 }
43
44 fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/impl#[MultipleOfFloatValidator][Validate]validate().<'i>(
45 &self,
46 instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
47 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
48 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
49 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> {
50 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.is_validrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/impl#[MultipleOfFloatValidator][Validate]is_valid().(instance, ctx) {
51 #[cfg(feature = "arbitrary-precision")]
52 {
53 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::multiple_ofrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]multiple_of().(
54 self.locationrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfFloatValidator#location..clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(),
55 location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
56 instance,
57 Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Numberrust-analyzer cargo serde_json 1.0.145 value/Value#Number#(self.original_valuerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfFloatValidator#original_value..clonerust-analyzer cargo serde_json 1.0.145 number/impl#[Number][Clone]clone().()),
58 ));
59 }
60 #[cfg(not(feature = "arbitrary-precision"))]
61 {
62 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::multiple_of(
63 self.location.clone(),
64 location.into(),
65 instance,
66 self.multiple_of,
67 ));
68 }
69 }
70 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
71 }
72 }
73
74 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct MultipleOfIntegerValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfIntegerValidator# {
75 multiple_ofrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfIntegerValidator#multiple_of.: f64,
76 #[cfg(feature = "arbitrary-precision")]
77 original_valuerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfIntegerValidator#original_value.: serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Numberrust-analyzer cargo serde_json 1.0.145 number/Number#,
78 locationrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfIntegerValidator#location.: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#,
79 }
80
81 impl MultipleOfIntegerValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfIntegerValidator# {
82 #[inline]
83 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/impl#[MultipleOfIntegerValidator]compile().<'a>(
84 multiple_of: f64,
85 #[cfg(feature = "arbitrary-precision")] original_value: &serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Numberrust-analyzer cargo serde_json 1.0.145 number/Number#,
86 location: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#,
87 ) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> {
88 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(MultipleOfIntegerValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfIntegerValidator# {
89 multiple_ofrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfIntegerValidator#multiple_of.,
90 #[cfg(feature = "arbitrary-precision")]
91 original_valuerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfIntegerValidator#original_value.: original_value.clonerust-analyzer cargo serde_json 1.0.145 number/impl#[Number][Clone]clone().(),
92 locationrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfIntegerValidator#location.,
93 }))
94 }
95 }
96
97 impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for MultipleOfIntegerValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfIntegerValidator# {
98 fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/impl#[MultipleOfIntegerValidator][Validate]is_valid().(&self, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, _ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#) -> bool {
99 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Numberrust-analyzer cargo serde_json 1.0.145 value/Value#Number#(item) = instance {
100 numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::is_multiple_of_integerrust-analyzer cargo jsonschema 0.37.4 ext/numeric/is_multiple_of_integer().(item, self.multiple_ofrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfIntegerValidator#multiple_of.)
101 } else {
102 true
103 }
104 }
105
106 fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/impl#[MultipleOfIntegerValidator][Validate]validate().<'i>(
107 &self,
108 instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
109 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
110 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
111 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> {
112 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.is_validrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/impl#[MultipleOfIntegerValidator][Validate]is_valid().(instance, ctx) {
113 #[cfg(feature = "arbitrary-precision")]
114 {
115 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::multiple_ofrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]multiple_of().(
116 self.locationrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfIntegerValidator#location..clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(),
117 location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
118 instance,
119 Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Numberrust-analyzer cargo serde_json 1.0.145 value/Value#Number#(self.original_valuerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfIntegerValidator#original_value..clonerust-analyzer cargo serde_json 1.0.145 number/impl#[Number][Clone]clone().()),
120 ));
121 }
122 #[cfg(not(feature = "arbitrary-precision"))]
123 {
124 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::multiple_of(
125 self.location.clone(),
126 location.into(),
127 instance,
128 self.multiple_of,
129 ));
130 }
131 }
132 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
133 }
134 }
135
136 #[cfg(feature = "arbitrary-precision")]
137 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct MultipleOfBigIntValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigIntValidator# {
138 multiple_ofrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigIntValidator#multiple_of.: num_bigintrust-analyzer cargo num-bigint 0.4.6 crate/::BigIntrust-analyzer cargo num-bigint 0.4.6 bigint/BigInt#,
139 original_valuerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigIntValidator#original_value.: serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Numberrust-analyzer cargo serde_json 1.0.145 number/Number#,
140 locationrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigIntValidator#location.: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#,
141 }
142
143 #[cfg(feature = "arbitrary-precision")]
144 impl MultipleOfBigIntValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigIntValidator# {
145 #[inline]
146 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/impl#[MultipleOfBigIntValidator]compile().<'a>(
147 multiple_of: num_bigintrust-analyzer cargo num-bigint 0.4.6 crate/::BigIntrust-analyzer cargo num-bigint 0.4.6 bigint/BigInt#,
148 original_value: &serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Numberrust-analyzer cargo serde_json 1.0.145 number/Number#,
149 location: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#,
150 ) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> {
151 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(MultipleOfBigIntValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigIntValidator# {
152 multiple_ofrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigIntValidator#multiple_of.,
153 original_valuerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigIntValidator#original_value.: original_value.clonerust-analyzer cargo serde_json 1.0.145 number/impl#[Number][Clone]clone().(),
154 locationrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigIntValidator#location.,
155 }))
156 }
157 }
158
159 #[cfg(feature = "arbitrary-precision")]
160 impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for MultipleOfBigIntValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigIntValidator# {
161 fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/impl#[MultipleOfBigIntValidator][Validate]is_valid().(&self, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, _ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#) -> bool {
162 use num_bigintrust-analyzer cargo num-bigint 0.4.6 crate/::BigIntrust-analyzer cargo num-bigint 0.4.6 bigint/BigInt#;
163 use num_traitsrust-analyzer cargo num-traits 0.2.19 crate/::Onerust-analyzer cargo num-traits 0.2.19 identities/One#;
164 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Numberrust-analyzer cargo serde_json 1.0.145 value/Value#Number#(item) = instance {
165 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(instance_bigint) = numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::bignumrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/::try_parse_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/try_parse_bigint().(item) {
166 numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::bignumrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/::is_multiple_of_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/is_multiple_of_bigint().(&instance_bigint, &self.multiple_ofrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigIntValidator#multiple_of.)
167 } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v) = item.as_u64rust-analyzer cargo serde_json 1.0.145 number/impl#[Number]as_u64().() {
168 let v_bigint = BigIntrust-analyzer cargo num-bigint 0.4.6 bigint/BigInt#::fromrust-analyzer cargo num-bigint 0.4.6 bigint/convert/impl#[BigInt][`From<u64>`]from().(v);
169 numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::bignumrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/::is_multiple_of_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/is_multiple_of_bigint().(&v_bigint, &self.multiple_ofrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigIntValidator#multiple_of.)
170 } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v) = item.as_i64rust-analyzer cargo serde_json 1.0.145 number/impl#[Number]as_i64().() {
171 let v_bigint = BigIntrust-analyzer cargo num-bigint 0.4.6 bigint/BigInt#::fromrust-analyzer cargo num-bigint 0.4.6 bigint/convert/impl#[BigInt][`From<i64>`]from().(v);
172 numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::bignumrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/::is_multiple_of_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/is_multiple_of_bigint().(&v_bigint, &self.multiple_ofrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigIntValidator#multiple_of.)
173 } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v) = item.as_f64rust-analyzer cargo serde_json 1.0.145 number/impl#[Number]as_f64().() {
174 if v.fractrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]fract().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialEq<Self>`]ne().0.0 {
175 return false;
176 }
177 // JSON numbers that originate as f64 are only exactly representable if their
178 // absolute value is below 2^53. Within that "safe integer" window we can round-trip
179 // to i64 without losing bits, so convert and reuse the bigint path.
180 #[allow(clippy::cast_precision_loss, clippy::cast_possible_truncation)]
181 if v.is_finiterust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]is_finite().() && v.absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]abs().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().(1u64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<i32>`]shl().53) as f64 {
182 let v_bigint = BigIntrust-analyzer cargo num-bigint 0.4.6 bigint/BigInt#::fromrust-analyzer cargo num-bigint 0.4.6 bigint/convert/impl#[BigInt][`From<i64>`]from().(v as i64);
183 numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::bignumrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/::is_multiple_of_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/is_multiple_of_bigint().(&v_bigint, &self.multiple_ofrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigIntValidator#multiple_of.)
184 } else {
185 // 2^53 and above can no longer be recovered exactly from the binary64 mantissa,
186 // so we bail out instead of pretending we know whether the bigint divisor divides
187 // such an approximation.
188 false
189 }
190 } else {
191 // as_f64() returning None means the literal overflowed binary64 (e.g. 1e10000) or was
192 // written in plain decimal form with more precision than f64 can carry. We attempt to
193 // parse it as an exact BigFraction and only accept it when the denominator is 1 so we
194 // can safely convert it to BigInt before running the modulo check below.
195 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(instance_bigfrac) = numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::bignumrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/::try_parse_bigfractionrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/try_parse_bigfraction().(item) {
196 if instance_bigfrac.denomrust-analyzer cargo fraction 0.15.3 fraction/generic_fraction/impl#[`GenericFraction<T>`]denom().().is_none_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none_or().(Onerust-analyzer cargo num-traits 0.2.19 identities/One#::is_onerust-analyzer cargo num-bigint 0.4.6 biguint/impl#[BigUint][One]is_one().) {
197 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(numer) = instance_bigfrac.numerrust-analyzer cargo fraction 0.15.3 fraction/generic_fraction/impl#[`GenericFraction<T>`]numer().() {
198 let instance_bigint = BigIntrust-analyzer cargo num-bigint 0.4.6 bigint/BigInt#::fromrust-analyzer cargo num-bigint 0.4.6 bigint/convert/impl#[BigInt][`From<BigUint>`]from().(numer.clonerust-analyzer cargo num-bigint 0.4.6 biguint/impl#[BigUint][Clone]clone().());
199 return numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::bignumrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/::is_multiple_of_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/is_multiple_of_bigint().(
200 &instance_bigint,
201 &self.multiple_ofrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigIntValidator#multiple_of.,
202 );
203 }
204 }
205 }
206 // If we made it here we encountered scientific notation that can’t be normalized, or
207 // a decimal with a fractional part. Either way it cannot be an integer multiple.
208 false
209 }
210 } else {
211 true
212 }
213 }
214
215 fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/impl#[MultipleOfBigIntValidator][Validate]validate().<'i>(
216 &self,
217 instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
218 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
219 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
220 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> {
221 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.is_validrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/impl#[MultipleOfBigIntValidator][Validate]is_valid().(instance, ctx) {
222 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::multiple_ofrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]multiple_of().(
223 self.locationrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigIntValidator#location..clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(),
224 location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
225 instance,
226 Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Numberrust-analyzer cargo serde_json 1.0.145 value/Value#Number#(self.original_valuerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigIntValidator#original_value..clonerust-analyzer cargo serde_json 1.0.145 number/impl#[Number][Clone]clone().()),
227 ));
228 }
229 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
230 }
231 }
232
233 #[cfg(feature = "arbitrary-precision")]
234 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct MultipleOfBigFracValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigFracValidator# {
235 multiple_ofrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigFracValidator#multiple_of.: fractionrust-analyzer cargo fraction 0.15.3 crate/::BigFractionrust-analyzer cargo fraction 0.15.3 prelude/BigFraction#,
236 original_valuerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigFracValidator#original_value.: serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Numberrust-analyzer cargo serde_json 1.0.145 number/Number#,
237 locationrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigFracValidator#location.: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#,
238 }
239
240 #[cfg(feature = "arbitrary-precision")]
241 impl MultipleOfBigFracValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigFracValidator# {
242 #[inline]
243 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/impl#[MultipleOfBigFracValidator]compile().<'a>(
244 multiple_of: fractionrust-analyzer cargo fraction 0.15.3 crate/::BigFractionrust-analyzer cargo fraction 0.15.3 prelude/BigFraction#,
245 original_value: &serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Numberrust-analyzer cargo serde_json 1.0.145 number/Number#,
246 location: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#,
247 ) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> {
248 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(MultipleOfBigFracValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigFracValidator# {
249 multiple_ofrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigFracValidator#multiple_of.,
250 original_valuerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigFracValidator#original_value.: original_value.clonerust-analyzer cargo serde_json 1.0.145 number/impl#[Number][Clone]clone().(),
251 locationrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigFracValidator#location.,
252 }))
253 }
254 }
255
256 #[cfg(feature = "arbitrary-precision")]
257 impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for MultipleOfBigFracValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigFracValidator# {
258 fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/impl#[MultipleOfBigFracValidator][Validate]is_valid().(&self, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, _ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#) -> bool {
259 use num_traitsrust-analyzer cargo num-traits 0.2.19 crate/::ToPrimitiverust-analyzer cargo num-traits 0.2.19 cast/ToPrimitive#;
260 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Numberrust-analyzer cargo serde_json 1.0.145 value/Value#Number#(item) = instance {
261 // Try to parse instance as BigFraction for exact precision
262 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(instance_bigfrac) = numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::bignumrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/::try_parse_bigfractionrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/try_parse_bigfraction().(item) {
263 numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::bignumrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/::is_multiple_of_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/is_multiple_of_bigfrac().(&instance_bigfrac, &self.multiple_ofrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigFracValidator#multiple_of.)
264 } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(instance_bigint) = numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::bignumrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/::try_parse_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/try_parse_bigint().(item) {
265 let value_frac = fractionrust-analyzer cargo fraction 0.15.3 crate/::BigFractionrust-analyzer cargo fraction 0.15.3 prelude/BigFraction#::fromrust-analyzer cargo fraction 0.15.3 fraction/generic_fraction/impl#[`GenericFraction<T>`][`From<BigInt>`]from().(instance_bigint);
266 numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::bignumrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/::is_multiple_of_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/is_multiple_of_bigfrac().(&value_frac, &self.multiple_ofrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigFracValidator#multiple_of.)
267 } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v) = item.as_u64rust-analyzer cargo serde_json 1.0.145 number/impl#[Number]as_u64().() {
268 let v_frac = fractionrust-analyzer cargo fraction 0.15.3 crate/::BigFractionrust-analyzer cargo fraction 0.15.3 prelude/BigFraction#::fromrust-analyzer cargo fraction 0.15.3 fraction/generic_fraction/impl#[`GenericFraction<T>`][`From<u64>`]from().(v);
269 numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::bignumrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/::is_multiple_of_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/is_multiple_of_bigfrac().(&v_frac, &self.multiple_ofrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigFracValidator#multiple_of.)
270 } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v) = item.as_i64rust-analyzer cargo serde_json 1.0.145 number/impl#[Number]as_i64().() {
271 let v_frac = fractionrust-analyzer cargo fraction 0.15.3 crate/::BigFractionrust-analyzer cargo fraction 0.15.3 prelude/BigFraction#::fromrust-analyzer cargo fraction 0.15.3 fraction/generic_fraction/impl#[`GenericFraction<T>`][`From<i64>`]from().(v);
272 numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::bignumrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/::is_multiple_of_bigfracrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/is_multiple_of_bigfrac().(&v_frac, &self.multiple_ofrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigFracValidator#multiple_of.)
273 } else {
274 // Fall back to the regular float-based validation since precision is already lost
275 let multiple_f64 = self.multiple_ofrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigFracValidator#multiple_of..to_f64rust-analyzer cargo fraction 0.15.3 fraction/generic_fraction/impl#[`GenericFraction<T>`][ToPrimitive]to_f64().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(f64::INFINITYrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]INFINITY.);
276 numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::is_multiple_of_floatrust-analyzer cargo jsonschema 0.37.4 ext/numeric/is_multiple_of_float().(item, multiple_f64)
277 }
278 } else {
279 true
280 }
281 }
282
283 fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/impl#[MultipleOfBigFracValidator][Validate]validate().<'i>(
284 &self,
285 instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
286 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
287 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
288 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> {
289 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.is_validrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/impl#[MultipleOfBigFracValidator][Validate]is_valid().(instance, ctx) {
290 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::multiple_ofrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]multiple_of().(
291 self.locationrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigFracValidator#location..clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(),
292 location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
293 instance,
294 Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Numberrust-analyzer cargo serde_json 1.0.145 value/Value#Number#(self.original_valuerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigFracValidator#original_value..clonerust-analyzer cargo serde_json 1.0.145 number/impl#[Number][Clone]clone().()),
295 ));
296 }
297 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
298 }
299 }
300
301 #[inline]
302 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/compile().<'a>(
303 ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#,
304 _: &'a Maprust-analyzer cargo serde_json 1.0.145 map/Map#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>,
305 schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
306 ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a>> {
307 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Numberrust-analyzer cargo serde_json 1.0.145 value/Value#Number#(multiple_of) = schema {
308 let location = ctx.locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]location().().joinrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]join().("multipleOf");
309
310 #[cfg(feature = "arbitrary-precision")]
311 {
312 // Try BigInt first for large integers
313 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(bigint_multiple) = numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::bignumrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/::try_parse_bigintrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/try_parse_bigint().(multiple_of) {
314 return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(MultipleOfBigIntValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigIntValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/impl#[MultipleOfBigIntValidator]compile().(
315 bigint_multiple,
316 multiple_of,
317 location,
318 ));
319 }
320 // Then try BigFraction for exact decimal precision
321 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(bigfrac_multiple) = numericrust-analyzer cargo jsonschema 0.37.4 ext/numeric/::bignumrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/::try_parse_bigfractionrust-analyzer cargo jsonschema 0.37.4 ext/numeric/bignum/try_parse_bigfraction().(multiple_of) {
322 return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(MultipleOfBigFracValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfBigFracValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/impl#[MultipleOfBigFracValidator]compile().(
323 bigfrac_multiple,
324 multiple_of,
325 location,
326 ));
327 }
328 }
329
330 // If not BigInt or BigFraction, try to represent as f64
331 // Note: Extreme scientific notation (e.g., 1e309, 1e400) cannot fit in f64
332 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(f64_value) = multiple_of.as_f64rust-analyzer cargo serde_json 1.0.145 number/impl#[Number]as_f64().() {
333 #[cfg(feature = "arbitrary-precision")]
334 {
335 if f64_value.fractrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]fract().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialEq<Self>`]eq().0. {
336 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(MultipleOfIntegerValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfIntegerValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/impl#[MultipleOfIntegerValidator]compile().(
337 f64_value,
338 multiple_of,
339 location,
340 ))
341 } else {
342 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(MultipleOfFloatValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfFloatValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/impl#[MultipleOfFloatValidator]compile().(
343 f64_value,
344 multiple_of,
345 location,
346 ))
347 }
348 }
349 #[cfg(not(feature = "arbitrary-precision"))]
350 {
351 if f64_value.fract() == 0. {
352 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(MultipleOfIntegerValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfIntegerValidator#::compile(f64_value, location))
353 } else {
354 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(MultipleOfFloatValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/MultipleOfFloatValidator#::compile(f64_value, location))
355 }
356 }
357 } else {
358 // Extreme numbers beyond f64 range (e.g., 1e309) - not supported
359 // Skip this keyword - all instances will be considered valid
360 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
361 }
362 } else {
363 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::single_type_errorrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]single_type_error().(
364 Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#::newrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]new().(),
365 ctx.locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]location().().clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(),
366 schema,
367 JsonTyperust-analyzer cargo jsonschema 0.37.4 types/JsonType#::Numberrust-analyzer cargo jsonschema 0.37.4 types/JsonType#Number#,
368 )))
369 }
370 }
371
372 #[cfg(test)]
373 mod testsrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/ {
374 use craterust-analyzer cargo jsonschema 0.37.4 crate/::tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/;
375 use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::{jsonrust-analyzer cargo serde_json 1.0.145 macros/json!, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#};
376 use test_caserust-analyzer cargo test-case 3.3.1 crate/::test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:;
377
378 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 2}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(4))]
379 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 1.0}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(4.0))]
380 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 1.5}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(3.0))]
381 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 1.5}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(4.5))]
382 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 0.1}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(12.2))]
383 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 0.0001}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(3.1254))]
384 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 0.0001}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(47.498))]
385 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 0.1}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(1.1))]
386 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 0.1}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(1.2))]
387 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 0.1}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(1.3))]
388 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 0.02}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(1.02))]
389 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 1e-16}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(1e-15))]
390 fn multiple_of_is_validrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/multiple_of_is_valid().(schema: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#) {
391 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_valid().(schema, instance);
392 }
393
394 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 1.0}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(4.5))]
395 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 0.1}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(4.55))]
396 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 0.2}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(4.5))]
397 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 0.02}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(1.01))]
398 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 1.3}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(1.3e-16))]
399 fn multiple_of_is_not_validrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/multiple_of_is_not_valid().(schema: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#) {
400 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_not_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_not_valid().(schema, instance);
401 }
402
403 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 2}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(3), "/multipleOf")]
404 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 1.5}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(5), "/multipleOf")]
405 fn locationrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/location().(schema: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, expected: &str) {
406 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::assert_schema_locationrust-analyzer cargo jsonschema 0.37.4 tests_util/assert_schema_location().(schema, instance, expected);
407 }
408
409 #[cfg(feature = "arbitrary-precision")]
410 mod arbitrary_precisionrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/ {
411 use craterust-analyzer cargo jsonschema 0.37.4 crate/::tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/;
412 use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Valuerust-analyzer cargo serde_json 1.0.145 value/Value#;
413 use test_caserust-analyzer cargo test-case 3.3.1 crate/::test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:;
414
415 fn parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(s: &str) -> Valuerust-analyzer cargo serde_json 1.0.145 value/Value# {
416 serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::from_strrust-analyzer cargo serde_json 1.0.145 de/from_str().(s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
417 }
418
419 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.1}"#, "0.3", true; "bigfrac 0.3 is multiple of 0.1")]
420 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.1}"#, "0.35", false; "bigfrac 0.35 not multiple of 0.1")]
421 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.01}"#, "0.03", true; "bigfrac 0.03 is multiple of 0.01")]
422 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.1}"#, "10", true; "bigfrac validator with u64 instance")]
423 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.5}"#, "-2", true; "bigfrac validator with i64 instance")]
424 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.3}"#, "0.0", true; "bigfrac zero is multiple")]
425 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.1}"#, "10.05", false; "bigfrac 10.05 not multiple of 0.1")]
426 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.5}"#, "-1.3", false; "bigfrac -1.3 not multiple of 0.5")]
427 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 0.1}"#, "0.3", true; "bigfrac minimum 0.3 >= 0.1")]
428 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 0.1}"#, "0.05", false; "bigfrac minimum 0.05 < 0.1")]
429 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 0.5}"#, "0.3", true; "bigfrac maximum 0.3 <= 0.5")]
430 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 0.5}"#, "0.7", false; "bigfrac maximum 0.7 > 0.5")]
431 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 2}"#, "1e1000", true; "huge scientific integer is even")]
432 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 3}"#, "1e1000", false; "10^1000 not multiple of 3")]
433 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.5}"#, "1e1000", true; "huge scientific integer multiple of 0.5")]
434 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 18446744073709551616}"#, "36893488147419103232", true; "large bigint multiple")]
435 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 18446744073709551616}"#, "18446744073709551617", false; "large bigint non-multiple")]
436 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 18446744073709551616}"#, "100", false; "small int not multiple of large")]
437 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 18446744073709551616}"#, "-100", false; "negative small int not multiple")]
438 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 18446744073709551616}"#, "0", true; "zero is multiple of large bigint")]
439 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 18446744073709551616}"#, "1.5", false; "decimal not multiple of bigint")]
440 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 18446744073709551616}"#, "1e20", false; "scientific notation not multiple")]
441 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 18446744073709551616}"#, "9223372036854775808", false; "2^63 not multiple of 2^64")]
442 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 18446744073709551616}"#, "1e308", true; "huge float multiple of 2^64")]
443 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 1e19}"#, "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", true; "1e19 scientific notation divisor with huge instance that is exact multiple")]
444 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 2e19}"#, "200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", true; "2e19 scientific notation divisor with huge instance that is exact multiple")]
445 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 1000000000000000000}"#, "1e18", true; "1e18 is 10^18")]
446 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 1000000000000000000}"#, "2e18", true; "2e18 is 2*10^18")]
447 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 1000000000000000000}"#, "1.5e18", false; "1.5e18 not integer multiple")]
448 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 3}"#, "1e20", false; "1e20 not multiple of 3")]
449 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 18446744073709551616}"#, "1e100", true; "bigint min with huge number")]
450 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 18446744073709551616}"#, "1e100", false; "bigint max with huge number")]
451 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 1e309}"#, "1e309", true; "extreme schema value beyond f64 - schema compilation should handle")]
452 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 1e400}"#, "2e400", true; "extreme schema values - both unsupported")]
453 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 1e309}"#, "1e310", true; "extreme minimum - instance validation")]
454 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 1e309}"#, "1e308", true; "extreme maximum - instance validation")]
455 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMinimum": 18446744073709551616}"#, "1e100", true; "bigint exclusive min")]
456 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMaximum": 18446744073709551616}"#, "1e10", true; "bigint exclusive max")]
457 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 18446744073709551616}"#, "100", false; "small number below bigint min")]
458 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 18446744073709551616}"#, "99999999999999999999", false; "large number above bigint max")]
459 fn arbitrary_precision_validationrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/arbitrary_precision_validation().(schema_json: &str, instance_json: &str, expected: bool) {
460 let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(schema_json);
461 let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(instance_json);
462 if expected {
463 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_valid().(&schema, &instance);
464 } else {
465 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_not_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_not_valid().(&schema, &instance);
466 }
467 }
468
469 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 18446744073709551616}"#, "4.0", false; "safe_float_not_multiple")]
470 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 18446744073709551616}"#, "0.0", true; "safe_float_zero_multiple")]
471 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(
472 r#"{"multipleOf": 18446744073709551616}"#,
473 "18014398509481984.0",
474 false;
475 "float_beyond_safe_range_rejected"
476 )]
477 fn bigint_validator_float_instancesrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/bigint_validator_float_instances().(
478 schema_json: &str,
479 instance_json: &str,
480 expected: bool,
481 ) {
482 let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(schema_json);
483 let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(instance_json);
484 if expected {
485 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_valid().(&schema, &instance);
486 } else {
487 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_not_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_not_valid().(&schema, &instance);
488 }
489 }
490
491 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
492 fn bigint_validator_accepts_bigfraction_integer_instancesrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/bigint_validator_accepts_bigfraction_integer_instances().() {
493 let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(r#"{"multipleOf": 18446744073709551616}"#);
494 let mut huge = "18446744073709551616".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().();
495 huge.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&"0".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(400));
496 huge.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(".0");
497 let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(&huge);
498 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_valid().(&schema, &instance);
499 }
500
501 // Test cases for dynamically generated huge numbers
502 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("2", 100, 2, true; "2 followed by 100 zeros is multiple of 2")]
503 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("2", 200, 3, false; "2 followed by 200 zeros not multiple of 3")]
504 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("1", 100, 3, false; "1 followed by 100 zeros not multiple of 3")]
505 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("3", 400, 7, false; "3 followed by 400 zeros not multiple of 7")]
506 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("2", 100, 2, true; "huge bigint is multiple")]
507 fn generated_huge_numbersrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/generated_huge_numbers().(prefix: &str, zeros: usize, divisor: u64, expected: bool) {
508 let schema_json = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(r#"{{"multipleOf": {divisor}}}"#);
509 let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(&schema_json);
510 let huge = prefix.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). &"0".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(zeros);
511 let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(&huge);
512 if expected {
513 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_valid().(&schema, &instance);
514 } else {
515 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_not_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_not_valid().(&schema, &instance);
516 }
517 }
518
519 // Test non-number instances with MultipleOfFloatValidator
520 // Use serde_json::json! macro to avoid arbitrary-precision parsing
521 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 2.5}), &serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!("string"); "float string")]
522 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 2.5}), &serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(true); "float bool")]
523 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 2.5}), &serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!([]); "float array")]
524 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 2.5}), &serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({}); "float object")]
525 fn non_number_with_float_validatorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/non_number_with_float_validator().(schema: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#) {
526 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_valid().(schema, instance);
527 }
528
529 // Test non-number instances with BigInt/BigFrac validators (via JSON parsing)
530 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 18446744073709551616}"#, r#""string""#; "bigint string")]
531 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.1}"#, r"true"; "bigfrac bool")]
532 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 18446744073709551616}"#, r"[]"; "bigint min array")]
533 fn non_number_with_bignum_validatorsrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/non_number_with_bignum_validators().(schema_json: &str, instance_json: &str) {
534 let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(schema_json);
535 let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(instance_json);
536 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_valid().(&schema, &instance);
537 }
538
539 // Test validate() error paths
540 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 2.5}"#, "5.1"; "float validator error")]
541 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 3}"#, "7"; "integer validator error")]
542 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.3}"#, "0.7"; "bigfrac validator error")]
543 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 18446744073709551616}"#, "123"; "bigint validator error")]
544 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 18446744073709551616}"#, "100"; "bigint minimum error")]
545 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 18446744073709551616}"#, "99999999999999999999"; "bigint maximum error")]
546 fn validator_error_pathsrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/validator_error_paths().(schema_json: &str, instance_json: &str) {
547 let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(schema_json);
548 let validator = craterust-analyzer cargo jsonschema 0.37.4 crate/::validator_forrust-analyzer cargo jsonschema 0.37.4 validator_for().(&schema).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
549 let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(instance_json);
550 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(validator.validaterust-analyzer cargo jsonschema 0.37.4 validator/impl#[Validator]validate().(&instance).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().());
551 }
552
553 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
554 fn invalid_multiple_of_schemarust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/invalid_multiple_of_schema().() {
555 let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(r#"{"multipleOf": "not a number"}"#);
556 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(craterust-analyzer cargo jsonschema 0.37.4 crate/::validator_forrust-analyzer cargo jsonschema 0.37.4 validator_for().(&schema).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().());
557 }
558
559 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
560 fn huge_bigfraction_beyond_f64rust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/huge_bigfraction_beyond_f64().() {
561 // Test BigFraction parsing for numbers way beyond f64::MAX
562 let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(r#"{"multipleOf": 7}"#);
563 // Number not divisible by 7 (sum of digits = 3, not divisible by 7)
564 let huge = "3".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&"0".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(400);
565 let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(&huge);
566 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_not_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_not_valid().(&schema, &instance);
567 }
568
569 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
570 fn large_u64_divisor_beyond_i64_maxrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/large_u64_divisor_beyond_i64_max().() {
571 // Test for the bug where u64 divisors beyond i64::MAX were incorrectly handled
572 // 10^19 = 10000000000000000000 is beyond i64::MAX but within u64::MAX
573 // This should now use BigIntValidator to preserve exact value
574 let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(r#"{"multipleOf": 10000000000000000000}"#);
575
576 // 10^320 is a valid multiple of 10^19 (it's 10^19 * 10^301)
577 let huge_multiple = "1".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&"0".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(320);
578 let instance_valid = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(&huge_multiple);
579 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_valid().(&schema, &instance_valid);
580
581 // 10^320 + 1 is NOT a multiple of 10^19
582 let mut huge_non_multiple = "1".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&"0".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(320);
583 huge_non_multiple = huge_non_multiple[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#huge_non_multiple.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index()..to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().+rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add()."1";
584 let instance_invalid = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(&huge_non_multiple);
585 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_not_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_not_valid().(&schema, &instance_invalid);
586 }
587
588 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
589 fn u64_max_divisorrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/u64_max_divisor().() {
590 // Test with exactly u64::MAX as divisor
591 let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(r#"{"multipleOf": 18446744073709551615}"#);
592
593 // u64::MAX * 2 (expressed as a large number)
594 let double = "36893488147419103230";
595 let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(double);
596 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_valid().(&schema, &instance);
597 }
598
599 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
600 fn huge_decimal_beyond_f64_but_parseablerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/huge_decimal_beyond_f64_but_parseable().() {
601 // This number is so large it overflows f64 to infinity (as_f64() returns None)
602 // but can still be parsed as BigFraction - hits MultipleOfBigIntValidator else branch
603 let divisor = "18446744073709551616"; // 2^64
604 let schema_json = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(r#"{{"multipleOf": {divisor}}}"#);
605 let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(&schema_json);
606
607 // Valid: 2^64 * 10^400 - parseable as BigFraction
608 let huge = divisor.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&"0".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(400) rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().+rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().".0";
609 let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(&huge);
610 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_valid().(&schema, &instance);
611
612 // Invalid: all 1s - parseable as BigFraction but not a multiple
613 let huge_non_multiple = "1".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(400) rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().+rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().".0";
614 let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(&huge_non_multiple);
615 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_not_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_not_valid().(&schema, &instance);
616 }
617
618 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
619 fn huge_scientific_notation_else_branch_unparsablerust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/huge_scientific_notation_else_branch_unparsable().() {
620 // This hits the else branch but CANNOT be parsed as BigFraction (scientific notation)
621 // as_f64() returns None (infinity), try_parse_bigfraction returns None (has exponent)
622 let divisor = "18446744073709551616"; // 2^64
623 let schema_json = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(r#"{{"multipleOf": {divisor}}}"#);
624 let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(&schema_json);
625
626 // Scientific notation that overflows to infinity - cannot be parsed as BigFraction
627 let infinity_positive = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().("1e1000001");
628 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_not_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_not_valid().(&schema, &infinity_positive);
629
630 let infinity_negative = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().("-1e1000001");
631 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_not_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_not_valid().(&schema, &infinity_negative);
632
633 // Huge scientific notation decimal (not just integer exponent)
634 let huge_scientific = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().("1.5e1000002");
635 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_not_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_not_valid().(&schema, &huge_scientific);
636 }
637
638 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 18446744073709551616}"#, "1.0", false; "bigint divisor small float")]
639 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 18446744073709551616}"#, "2.0", false; "bigint divisor 2.0")]
640 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 18446744073709551616}"#, "1000.0", false; "bigint divisor 1000.0")]
641 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 18446744073709551616}"#, "18446744073709551616", true; "bigint schema u64 instance")]
642 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 18446744073709551616}"#, "-18446744073709551616", true; "bigint schema neg i64")]
643 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 18446744073709551616}"#, "18446744073709551616", true; "bigint min u64 exact")]
644 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 18446744073709551616}"#, "0", true; "bigint max small i64")]
645 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMinimum": 9223372036854775807}"#, "9223372036854775808", true; "i64_max exclusive u64")]
646 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 0.1}"#, "18446744073709551616", true; "bigfrac schema large int")]
647 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.5}"#, "36893488147419103232", true; "bigfrac schema huge int")]
648 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 18446744073709551616}"#, "9223372036854775808", false; "bigint half value")]
649 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 18446744073709551616}"#, "9223372036854775807", false; "bigint min i64_max")]
650 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 9223372036854775807}"#, "18446744073709551616", false; "i64_max max u64")]
651 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMaximum": 18446744073709551616}"#, "18446744073709551616", false; "bigint exmax boundary")]
652 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.3}"#, "18446744073709551616", false; "bigfrac 0.3 large int")]
653 fn mixed_type_comparisonsrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/mixed_type_comparisons().(schema_json: &str, instance_json: &str, expected: bool) {
654 let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(schema_json);
655 let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(instance_json);
656 if expected {
657 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_valid().(&schema, &instance);
658 } else {
659 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_not_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_not_valid().(&schema, &instance);
660 }
661 }
662
663 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.1}"#, "0.1", true; "0.1 multiple 0.1")]
664 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.1}"#, "0.2", true; "0.2 multiple 0.1")]
665 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.1}"#, "0.7", true; "0.7 multiple 0.1")]
666 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.1}"#, "0.11", false; "0.11 not multiple 0.1")]
667 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.01}"#, "0.99", true; "0.99 multiple 0.01")]
668 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.01}"#, "0.999", false; "0.999 not multiple 0.01")]
669 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.001}"#, "1.234", true; "1.234 multiple 0.001")]
670 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.001}"#, "1.2345", false; "1.2345 not multiple 0.001")]
671 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 0.1}"#, "0.1", true; "min 0.1 equal")]
672 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 0.3}"#, "0.3", true; "max 0.3 equal")]
673 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 0.1}"#, "0.09999999999999999", false; "below 0.1")]
674 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 0.1}"#, "0.10000000000000001", false; "above 0.1")]
675 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"const": 0.3}"#, "0.3", true; "const 0.3")]
676 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"const": 0.1}"#, "0.10000000000000002", false; "const close not equal")]
677 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 1.0}"#, "1", true; "decimal min int equal")]
678 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 1.5}"#, "1", false; "decimal min int below")]
679 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 1.5}"#, "2", true; "decimal min int above")]
680 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 2.5}"#, "2", true; "decimal max int below")]
681 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 2.5}"#, "3", false; "decimal max int above")]
682 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.5}"#, "1", true; "0.5 multiple int 1")]
683 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.5}"#, "2", true; "0.5 multiple int 2")]
684 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.5}"#, "3", true; "0.5 multiple int 3")]
685 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.3}"#, "1", false; "0.3 not multiple int 1")]
686 fn decimal_precision_testsrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/decimal_precision_tests().(schema_json: &str, instance_json: &str, expected: bool) {
687 let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(schema_json);
688 let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(instance_json);
689 if expected {
690 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_valid().(&schema, &instance);
691 } else {
692 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_not_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_not_valid().(&schema, &instance);
693 }
694 }
695
696 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 18446744073709551616}"#, "-36893488147419103232", true; "pos bigint neg instance")]
697 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": -18446744073709551616}"#, "-18446744073709551615", true; "neg bigint minimum")]
698 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": -18446744073709551616}"#, "-18446744073709551617", true; "neg bigint maximum")]
699 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": -99999999999999999999}"#, "-99999999999999999998", true; "huge neg minimum")]
700 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": -99999999999999999999}"#, "-100000000000000000000", true; "huge neg maximum")]
701 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 18446744073709551616}"#, "0", true; "zero multiple large")]
702 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": -18446744073709551616}"#, "0", true; "zero above neg min")]
703 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 18446744073709551616}"#, "0", true; "zero below large max")]
704 fn negative_large_numbersrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/negative_large_numbers().(schema_json: &str, instance_json: &str, expected: bool) {
705 let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(schema_json);
706 let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(instance_json);
707 if expected {
708 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_valid().(&schema, &instance);
709 } else {
710 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_not_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_not_valid().(&schema, &instance);
711 }
712 }
713
714 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 9223372036854775807}"#, "9223372036854775807", true; "i64_max min equal")]
715 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 9223372036854775807}"#, "9223372036854775808", true; "i64_max min plus")]
716 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 18446744073709551615}"#, "18446744073709551615", true; "u64_max equal")]
717 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 18446744073709551615}"#, "18446744073709551616", false; "u64_max plus")]
718 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": -9223372036854775808}"#, "-9223372036854775808", true; "i64_min equal")]
719 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": -9223372036854775808}"#, "-9223372036854775809", true; "i64_min minus")]
720 fn boundary_conditionsrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/boundary_conditions().(schema_json: &str, instance_json: &str, expected: bool) {
721 let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(schema_json);
722 let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(instance_json);
723 if expected {
724 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_valid().(&schema, &instance);
725 } else {
726 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_not_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_not_valid().(&schema, &instance);
727 }
728 }
729
730 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 99999999999999999999}"#, "99999999999999999999", true; "min equal")]
731 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 99999999999999999999}"#, "100000000000000000000", true; "min greater")]
732 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 99999999999999999999}"#, "99999999999999999998", false; "min less")]
733 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 99999999999999999999}"#, "99999999999999999999", true; "max equal")]
734 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 99999999999999999999}"#, "100000000000000000000", false; "max greater")]
735 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 99999999999999999999}"#, "99999999999999999998", true; "max less")]
736 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMinimum": 99999999999999999999}"#, "99999999999999999999", false; "exmin equal")]
737 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMinimum": 99999999999999999999}"#, "100000000000000000000", true; "exmin greater")]
738 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMinimum": 99999999999999999999}"#, "99999999999999999998", false; "exmin less")]
739 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMaximum": 99999999999999999999}"#, "99999999999999999999", false; "exmax equal")]
740 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMaximum": 99999999999999999999}"#, "100000000000000000000", false; "exmax greater")]
741 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"exclusiveMaximum": 99999999999999999999}"#, "99999999999999999998", true; "exmax less")]
742 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 0.5}"#, "0.5", true; "frac min equal")]
743 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 0.5}"#, "0.6", true; "frac min greater")]
744 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 0.5}"#, "0.4", false; "frac min less")]
745 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 0.5}"#, "0.5", true; "frac max equal")]
746 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 0.5}"#, "0.6", false; "frac max greater")]
747 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 0.5}"#, "0.4", true; "frac max less")]
748 fn comparison_operatorsrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/comparison_operators().(schema_json: &str, instance_json: &str, expected: bool) {
749 let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(schema_json);
750 let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(instance_json);
751 if expected {
752 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_valid().(&schema, &instance);
753 } else {
754 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_not_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_not_valid().(&schema, &instance);
755 }
756 }
757
758 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"const": 18446744073709551616}"#, "18446744073709551616", true; "bigint match")]
759 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"const": 18446744073709551616}"#, "18446744073709551617", false; "bigint mismatch")]
760 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"const": 0.1}"#, "0.1", true; "decimal match")]
761 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"const": 0.1}"#, "0.10", true; "decimal trailing zero")]
762 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"const": 0.1}"#, "0.2", false; "decimal mismatch")]
763 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"const": -99999999999999999999}"#, "-99999999999999999999", true; "neg bigint")]
764 fn const_large_numbersrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/const_large_numbers().(schema_json: &str, instance_json: &str, expected: bool) {
765 let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(schema_json);
766 let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(instance_json);
767 if expected {
768 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_valid().(&schema, &instance);
769 } else {
770 tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::is_not_validrust-analyzer cargo jsonschema 0.37.4 tests_util/is_not_valid().(&schema, &instance);
771 }
772 }
773
774 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": "not a number"}"#; "string")]
775 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": null}"#; "null")]
776 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": []}"#; "array")]
777 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": {}}"#; "object")]
778 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": true}"#; "boolean")]
779 fn malformed_schema_errorsrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/malformed_schema_errors().(schema_json: &str) {
780 let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(schema_json);
781 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(craterust-analyzer cargo jsonschema 0.37.4 crate/::validator_forrust-analyzer cargo jsonschema 0.37.4 validator_for().(&schema).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().());
782 }
783
784 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 18446744073709551616}"#, "18446744073709551617"; "multiple_of bigint")]
785 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 99999999999999999999}"#, "99999999999999999998"; "minimum bigint")]
786 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.1}"#, "0.15"; "multiple_of decimal")]
787 fn error_messages_preserve_precisionrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/error_messages_preserve_precision().(schema_json: &str, instance_json: &str) {
788 let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(schema_json);
789 let instance = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(instance_json);
790 let validator = craterust-analyzer cargo jsonschema 0.37.4 crate/::validator_forrust-analyzer cargo jsonschema 0.37.4 validator_for().(&schema).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
791 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(validator.validaterust-analyzer cargo jsonschema 0.37.4 validator/impl#[Validator]validate().(&instance).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().());
792 }
793
794 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 0.0000000000000001}"#; "tiny decimal")]
795 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 999999999999999999999999999999}"#; "huge integer")]
796 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": -999999999999999999999999999999}"#; "huge negative")]
797 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": 999999999999999999999999999999}"#; "huge positive")]
798 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"multipleOf": 1e-100}"#; "tiny scientific")]
799 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"minimum": 1e308}"#; "near f64_max")]
800 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(r#"{"maximum": -1e308}"#; "near f64_min")]
801 fn schema_compilation_edge_casesrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/schema_compilation_edge_cases().(schema_json: &str) {
802 let schema = parse_jsonrust-analyzer cargo jsonschema 0.37.4 keywords/multiple_of/tests/arbitrary_precision/parse_json().(schema_json);
803 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(craterust-analyzer cargo jsonschema 0.37.4 crate/::validator_forrust-analyzer cargo jsonschema 0.37.4 validator_for().(&schema).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
804 }
805 }
806 }