40 for (
auto i : {-1, 0, 1})
44 BEAST_EXPECT((i == 0) == (x == zero));
45 BEAST_EXPECT((i != 0) == (x != zero));
46 BEAST_EXPECT((i < 0) == (x < zero));
47 BEAST_EXPECT((i > 0) == (x > zero));
48 BEAST_EXPECT((i <= 0) == (x <= zero));
49 BEAST_EXPECT((i >= 0) == (x >= zero));
51 BEAST_EXPECT((0 == i) == (zero == x));
52 BEAST_EXPECT((0 != i) == (zero != x));
53 BEAST_EXPECT((0 < i) == (zero < x));
54 BEAST_EXPECT((0 > i) == (zero > x));
55 BEAST_EXPECT((0 <= i) == (zero <= x));
56 BEAST_EXPECT((0 >= i) == (zero >= x));
65 for (
auto i : {-1, 0, 1})
69 for (
auto j : {-1, 0, 1})
73 BEAST_EXPECT((i == j) == (x == y));
74 BEAST_EXPECT((i != j) == (x != y));
75 BEAST_EXPECT((i < j) == (x < y));
76 BEAST_EXPECT((i > j) == (x > y));
77 BEAST_EXPECT((i <= j) == (x <= y));
78 BEAST_EXPECT((i >= j) == (x >= y));
133 BEAST_EXPECT(test.drops() == 0);
135 test = make(beast::zero);
136 BEAST_EXPECT(test.drops() == 0);
139 BEAST_EXPECT(test.drops() == 0);
142 BEAST_EXPECT(test.drops() == 100);
145 BEAST_EXPECT(test.drops() == 100);
148 test = make(targetSame);
149 BEAST_EXPECT(test.drops() == 200);
150 BEAST_EXPECT(test == targetSame);
155 BEAST_EXPECT(test.drops() == 200);
157 BEAST_EXPECT(test.drops() == 300);
160 BEAST_EXPECT(test.drops() == 200);
162 BEAST_EXPECT(testOther);
163 BEAST_EXPECT(*testOther == 200);
166 BEAST_EXPECT(!testOther);
169 BEAST_EXPECT(!testOther);
171 test = targetSame * 2;
172 BEAST_EXPECT(test.drops() == 400);
173 test = 3 * targetSame;
174 BEAST_EXPECT(test.drops() == 600);
176 BEAST_EXPECT(test.drops() == 20);
179 BEAST_EXPECT(test.drops() == 220);
182 BEAST_EXPECT(test.drops() == 20);
185 BEAST_EXPECT(test.drops() == 100);
187 BEAST_EXPECT(test.drops() == 50);
189 BEAST_EXPECT(test.drops() == 11);
193 BEAST_EXPECT(test.drops() == -11);
194 BEAST_EXPECT(test.signum() == -1);
200 BEAST_EXPECT(test.signum() == 0);
202 BEAST_EXPECT(test.signum() == 1);
219 BEAST_EXPECT(big ==
mulRatio(big, maxUInt32, maxUInt32,
true));
221 BEAST_EXPECT(big ==
mulRatio(big, maxUInt32, maxUInt32,
false));
226 BEAST_EXPECT(
mulRatio(big, 3, 4,
false).value() == (big.
value() / 4) * 3);
227 BEAST_EXPECT(
mulRatio(big, 3, 4,
true).value() == (big.
value() / 4) * 3);
228 BEAST_EXPECT((big.
value() * 3) / 4 != (big.
value() / 4) * 3);
235 BEAST_EXPECT(big ==
mulRatio(big, maxUInt32, maxUInt32,
true));
237 BEAST_EXPECT(big ==
mulRatio(big, maxUInt32, maxUInt32,
false));
241 BEAST_EXPECT(
mulRatio(big, 3, 4,
false).value() == (big.
value() / 4) * 3);
242 BEAST_EXPECT(
mulRatio(big, 3, 4,
true).value() == (big.
value() / 4) * 3);
243 BEAST_EXPECT((big.
value() * 3) / 4 != (big.
value() / 4) * 3);
250 BEAST_EXPECT(tiny ==
mulRatio(tiny, 1, maxUInt32,
true));
252 BEAST_EXPECT(beast::zero ==
mulRatio(tiny, 1, maxUInt32,
false));
253 BEAST_EXPECT(beast::zero ==
mulRatio(tiny, maxUInt32 - 1, maxUInt32,
false));
258 BEAST_EXPECT(beast::zero ==
mulRatio(tinyNeg, 1, maxUInt32,
true));
259 BEAST_EXPECT(beast::zero ==
mulRatio(tinyNeg, maxUInt32 - 1, maxUInt32,
true));
261 BEAST_EXPECT(tinyNeg ==
mulRatio(tinyNeg, maxUInt32 - 1, maxUInt32,
false));
267 auto const rup =
mulRatio(one, maxUInt32 - 1, maxUInt32,
true);
268 auto const rdown =
mulRatio(one, maxUInt32 - 1, maxUInt32,
false);
269 BEAST_EXPECT(rup.drops() - rdown.drops() == 1);
274 auto const rup =
mulRatio(big, maxUInt32 - 1, maxUInt32,
true);
275 auto const rdown =
mulRatio(big, maxUInt32 - 1, maxUInt32,
false);
276 BEAST_EXPECT(rup.drops() - rdown.drops() == 1);
281 auto const rup =
mulRatio(negOne, maxUInt32 - 1, maxUInt32,
true);
282 auto const rdown =
mulRatio(negOne, maxUInt32 - 1, maxUInt32,
false);
283 BEAST_EXPECT(rup.drops() - rdown.drops() == 1);
301 XRPAmount const bigNegative(minXRP + 10);
302 BEAST_EXPECT(
mulRatio(bigNegative, 2, 1,
true) == minXRP);