38#include <gtest/gtest.h>
56TEST(CyclesTest, PrefixIncrement)
59 EXPECT_EQ(1, ++cycles);
60 EXPECT_EQ(2, ++cycles);
65TEST(CyclesTest, PrefixDecrement)
68 EXPECT_EQ(9, --cycles);
69 EXPECT_EQ(8, --cycles);
73TEST(CyclesTest, InPlaceAddition)
78 EXPECT_EQ(17, cycles);
81TEST(CyclesTest, GreaterThanLessThan)
85 EXPECT_TRUE(two_cycles > one_cycle);
86 EXPECT_TRUE(one_cycle < two_cycles);
93 Cycles added = cycles_1 + cycles_2;
97TEST(CyclesTest, SubtractCycles)
101 Cycles subtracted = cycles_1 - cycles_2;
102 EXPECT_EQ(24, subtracted);
107 Cycles cycles(1ULL << 40);
108 Cycles cycles_shifted = cycles >> 5;
109 EXPECT_EQ((1ULL << 35), cycles_shifted);
114 Cycles cycles(1ULL << 40);
115 Cycles cycles_shifted = cycles << 20;
116 EXPECT_EQ((1ULL << 60), cycles_shifted);
122 std::ostringstream
ss;
123 ss <<
"The number of cycles is: " << cycles << std::endl;
124 EXPECT_EQ(
"The number of cycles is: 56\n",
ss.str());
131TEST(MicroPCTest, CheckMicroPCRomBit)
136TEST(MicroPCTest, RomMicroPCTest)
141TEST(MicroPCTest, NormalMicroPCTest)
146TEST(MicroPCTest, IsRomMicroPCTest)
151TEST(MicroPCTest, IsNotRomMicroPCTest)
176TEST(TypesTest, floatsToBitsDoubleInput)
178 double val = 0.84023;
182TEST(TypesTest, floatsToBitsFloatInput)
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Cycles is a wrapper class for representing cycle counts, i.e.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
static uint32_t floatToBits32(float val)
static uint64_t floatToBits(double val)
static MicroPC romMicroPC(MicroPC upc)
static uint64_t floatToBits64(double val)
static bool isRomMicroPC(MicroPC upc)
static const MicroPC MicroPCRomBit
static MicroPC normalMicroPC(MicroPC upc)
TEST(CyclesTest, NoCycles)