gem5  v21.1.0.2
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 }
gem5::statistics::units::Second::get
static Second * get()
Definition: units.hh:170
gem5::statistics::units::DegreeCelsius::toString
static std::string toString()
Definition: units.hh:278
gem5::statistics::units::Byte::toString
static std::string toString()
Definition: units.hh:209
gem5::statistics::units::Rate::getUnitString
std::string getUnitString() const override
Definition: units.hh:371
gem5::statistics::units::Joule::toString
static std::string toString()
Definition: units.hh:244
gem5::statistics::units::Unspecified::toString
static std::string toString()
Definition: units.hh:334
gem5::statistics::units::DegreeCelsius
Definition: units.hh:265
gem5::statistics::units::DegreeCelsius::getUnitString
std::string getUnitString() const override
Definition: units.hh:280
gem5::statistics::units::Unspecified::getUnitString
std::string getUnitString() const override
Definition: units.hh:336
gem5::statistics::units::Rate::get
static Rate< T1, T2 > * get()
Definition: units.hh:360
gem5::statistics::units::Cycle::get
static Cycle * get()
Definition: units.hh:136
gem5::statistics::units::Count
Definition: units.hh:287
gem5::statistics::units::Unspecified::get
static Unspecified * get()
Definition: units.hh:329
gem5::statistics::units::Second
Definition: units.hh:162
gem5::statistics::units::Volt::getUnitString
std::string getUnitString() const override
Definition: units.hh:262
gem5::statistics::units::Tick::toString
static std::string toString()
Definition: units.hh:158
gem5::statistics::units::Watt::toString
static std::string toString()
Definition: units.hh:226
gem5::statistics::units::Count::get
static Count * get()
Definition: units.hh:295
gem5::statistics::units::Ratio::get
static Ratio * get()
Definition: units.hh:312
gem5::statistics::units::Volt
Definition: units.hh:248
gem5::statistics::units::Ratio::toString
static std::string toString()
Definition: units.hh:317
gem5::statistics::units::Volt::toString
static std::string toString()
Definition: units.hh:261
gem5::statistics::units::Joule::get
static Joule * get()
Definition: units.hh:239
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::statistics::units::Joule
Definition: units.hh:231
gem5::statistics::units::Tick::getUnitString
std::string getUnitString() const override
Definition: units.hh:159
gem5::statistics::units::Unspecified
Definition: units.hh:321
gem5::statistics::units::Watt::getUnitString
std::string getUnitString() const override
Definition: units.hh:227
gem5::statistics::units::Second::toString
static std::string toString()
Definition: units.hh:175
gem5::statistics::units::Byte
Definition: units.hh:196
gem5::statistics::units::Cycle::getUnitString
std::string getUnitString() const override
Definition: units.hh:142
gem5::statistics::units::Count::getUnitString
std::string getUnitString() const override
Definition: units.hh:301
gem5::statistics::units::Bit
Definition: units.hh:179
gem5::statistics::units::Cycle
Definition: units.hh:128
gem5::statistics::units::Second::getUnitString
std::string getUnitString() const override
Definition: units.hh:176
gem5::statistics::units::Ratio
Definition: units.hh:304
gem5::statistics::units::Byte::getUnitString
std::string getUnitString() const override
Definition: units.hh:210
gem5::statistics::units::Bit::get
static Bit * get()
Definition: units.hh:187
gem5::statistics::units::Count::toString
static std::string toString()
Definition: units.hh:300
units.hh
TEST
TEST(StatsUnitsTest, Cycle)
Definition: units.test.cc:36
gem5::statistics::units::Volt::get
static Volt * get()
Definition: units.hh:256
gem5::statistics::units::Ratio::getUnitString
std::string getUnitString() const override
Definition: units.hh:318
gem5::statistics::units::Tick::get
static Tick * get()
Definition: units.hh:153
gem5::statistics::units::Rate
Definition: units.hh:343
gem5::statistics::units::DegreeCelsius::get
static DegreeCelsius * get()
Definition: units.hh:273
gem5::statistics::units::Watt::get
static Watt * get()
Definition: units.hh:221
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::statistics::units::Byte::get
static Byte * get()
Definition: units.hh:204
gem5::statistics::units::Bit::toString
static std::string toString()
Definition: units.hh:192
gem5::statistics::units::Joule::getUnitString
std::string getUnitString() const override
Definition: units.hh:245
gem5::statistics::units::Tick
Definition: units.hh:145
gem5::statistics::units::Watt
Definition: units.hh:213
gem5::statistics::units::Cycle::toString
static std::string toString()
Definition: units.hh:141
gem5::statistics::units::Bit::getUnitString
std::string getUnitString() const override
Definition: units.hh:193

Generated on Tue Sep 21 2021 12:25:00 for gem5 by doxygen 1.8.17