gem5  v22.1.0.0
units.test.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 Daniel R. Carvalho
3  * All rights reserved
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #include <gtest/gtest-spi.h>
30 #include <gtest/gtest.h>
31 
32 #include "base/stats/units.hh"
33 
34 using namespace gem5;
35 
36 TEST(StatsUnitsTest, Cycle)
37 {
40 }
41 
42 TEST(StatsUnitsTest, Tick)
43 {
46 }
47 
48 TEST(StatsUnitsTest, Second)
49 {
52 }
53 
54 TEST(StatsUnitsTest, Bit)
55 {
57  ASSERT_EQ(unit->getUnitString(), statistics::units::Bit::toString());
58 }
59 
60 TEST(StatsUnitsTest, Byte)
61 {
64 }
65 
66 TEST(StatsUnitsTest, Watt)
67 {
70 }
71 
72 TEST(StatsUnitsTest, Joule)
73 {
76 }
77 
78 TEST(StatsUnitsTest, Volt)
79 {
82 }
83 
84 TEST(StatsUnitsTest, DegreeCelsius)
85 {
88  ASSERT_EQ(unit->getUnitString(),
90 }
91 
92 TEST(StatsUnitsTest, Count)
93 {
96 }
97 
98 TEST(StatsUnitsTest, Rate1)
99 {
101  statistics::units::Count> *unit =
103  statistics::units::Count>::get();
104  ASSERT_EQ(unit->getUnitString(), "(Count/Count)");
105  ASSERT_EQ(unit->getUnitString(),
107  statistics::units::Count>::toString()));
108 }
109 
110 TEST(StatsUnitsTest, Rate2)
111 {
116  ASSERT_EQ(unit->getUnitString(), "(Tick/Second)");
117  ASSERT_EQ(unit->getUnitString(),
119  statistics::units::Second>::toString()));
120 }
121 
122 TEST(StatsUnitsTest, RateOfRates)
123 {
125  statistics::units::Second> BitPerSecond;
127  statistics::units::Cycle> CountPerCycle;
130  ASSERT_EQ(unit->getUnitString(), "((Bit/Second)/(Count/Cycle))");
131  ASSERT_EQ(unit->getUnitString(),
133 }
134 
135 TEST(StatsUnitsTest, Ratio)
136 {
139 }
140 
141 TEST(StatsUnitsTest, Unspecified)
142 {
145  ASSERT_EQ(unit->getUnitString(),
147 }
static Bit * get()
Definition: units.hh:187
static std::string toString()
Definition: units.hh:192
std::string getUnitString() const override
Definition: units.hh:193
static Byte * get()
Definition: units.hh:204
std::string getUnitString() const override
Definition: units.hh:210
static std::string toString()
Definition: units.hh:209
std::string getUnitString() const override
Definition: units.hh:301
static std::string toString()
Definition: units.hh:300
static Count * get()
Definition: units.hh:295
static std::string toString()
Definition: units.hh:141
static Cycle * get()
Definition: units.hh:136
std::string getUnitString() const override
Definition: units.hh:142
static DegreeCelsius * get()
Definition: units.hh:273
std::string getUnitString() const override
Definition: units.hh:280
static std::string toString()
Definition: units.hh:278
std::string getUnitString() const override
Definition: units.hh:245
static Joule * get()
Definition: units.hh:239
static std::string toString()
Definition: units.hh:244
static Rate< T1, T2 > * get()
Definition: units.hh:360
std::string getUnitString() const override
Definition: units.hh:371
static Ratio * get()
Definition: units.hh:312
static std::string toString()
Definition: units.hh:317
std::string getUnitString() const override
Definition: units.hh:318
std::string getUnitString() const override
Definition: units.hh:176
static std::string toString()
Definition: units.hh:175
static Second * get()
Definition: units.hh:170
static std::string toString()
Definition: units.hh:158
static Tick * get()
Definition: units.hh:153
std::string getUnitString() const override
Definition: units.hh:159
static std::string toString()
Definition: units.hh:334
std::string getUnitString() const override
Definition: units.hh:336
static Unspecified * get()
Definition: units.hh:329
static Volt * get()
Definition: units.hh:256
std::string getUnitString() const override
Definition: units.hh:262
static std::string toString()
Definition: units.hh:261
static std::string toString()
Definition: units.hh:226
std::string getUnitString() const override
Definition: units.hh:227
static Watt * get()
Definition: units.hh:221
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint64_t Tick
Tick count type.
Definition: types.hh:58
TEST(StatsUnitsTest, Cycle)
Definition: units.test.cc:36

Generated on Wed Dec 21 2022 10:22:29 for gem5 by doxygen 1.9.1