[LLD][COFF] Emit tail merge pdata for delay load thunks on ARM64EC (#116810)
[llvm-project.git] / mlir / unittests / Analysis / Presburger / FractionTest.cpp
blobc9fad953dacd56d183e2fdcb34748e64a258edcb
1 #include "mlir/Analysis/Presburger/Fraction.h"
2 #include "./Utils.h"
3 #include <gmock/gmock.h>
4 #include <gtest/gtest.h>
6 using namespace mlir;
7 using namespace presburger;
9 TEST(FractionTest, getAsInteger) {
10 Fraction f(3, 1);
11 EXPECT_EQ(f.getAsInteger(), DynamicAPInt(3));
14 TEST(FractionTest, nearIntegers) {
15 Fraction f(52, 14);
17 EXPECT_EQ(floor(f), 3);
18 EXPECT_EQ(ceil(f), 4);
21 TEST(FractionTest, reduce) {
22 Fraction f(20, 35), g(-56, 63);
23 EXPECT_EQ(f, Fraction(4, 7));
24 EXPECT_EQ(g, Fraction(-8, 9));
27 TEST(FractionTest, arithmetic) {
28 Fraction f(3, 4), g(-2, 3);
30 EXPECT_EQ(f / g, Fraction(-9, 8));
31 EXPECT_EQ(f * g, Fraction(-1, 2));
32 EXPECT_EQ(f + g, Fraction(1, 12));
33 EXPECT_EQ(f - g, Fraction(17, 12));
35 f /= g;
36 EXPECT_EQ(f, Fraction(-9, 8));
37 f *= g;
38 EXPECT_EQ(f, Fraction(3, 4));
39 f += g;
40 EXPECT_EQ(f, Fraction(Fraction(1, 12)));
41 f -= g;
42 EXPECT_EQ(f, Fraction(3, 4));
45 TEST(FractionTest, relational) {
46 Fraction f(2, 5), g(3, 7);
47 EXPECT_TRUE(f < g);
48 EXPECT_FALSE(g < f);
50 EXPECT_EQ(f, Fraction(4, 10));