29#include <gtest/gtest-spi.h>
30#include <gtest/gtest.h>
43 bool check()
const override {
return true; }
46 bool zero()
const override {
return false; }
51TEST(StatsInfoTest, NameNewStyle)
54 info.
setName(
"InfoNameNewStyle",
false);
55 ASSERT_EQ(info.
name,
"InfoNameNewStyle");
59TEST(StatsInfoTest, NameFirstCharacter)
63 ASSERT_EQ(info.
name,
"X");
67 ASSERT_EQ(info2.
name,
"a");
71 ASSERT_EQ(info3.
name,
"_");
75 ASSERT_EQ(info4.
name,
"X.Y");
78 info5.
setName(
"a.b._.d.e",
false);
79 ASSERT_EQ(info5.
name,
"a.b._.d.e");
83TEST(StatsInfoTest, NameOtherCharacters)
87 ASSERT_EQ(info.
name,
"abCde");
91 ASSERT_EQ(info2.
name,
"ab_de");
95 ASSERT_EQ(info3.
name,
"ab9de");
98 info4.
setName(
"a_bCD12_ef",
false);
99 ASSERT_EQ(info4.
name,
"a_bCD12_ef");
102 info5.
setName(
"a_._bC.D12_ef",
false);
103 ASSERT_EQ(info5.
name,
"a_._bC.D12_ef");
110TEST(StatsInfoTest, NameOldStyle)
113 info.
setName(
"InfoNameOldStyle",
true);
114 ASSERT_EQ(info.
name,
"InfoNameOldStyle");
118 ASSERT_EQ(info.
id, it->second->id);
126TEST(StatsInfoTest, DISABLED_NameOldStyleTwice)
129 std::string old_name =
"InfoNameOldStyleTwice";
131 info.
setName(
"InfoNameOldStyleTwice2",
true);
132 ASSERT_EQ(info.
name,
"InfoNameOldStyleTwice2");
143TEST(StatsInfoTest, NameNewStyleDuplicate)
146 std::string
name =
"InfoNameNewStyleDuplicate";
160TEST(StatsInfoTest, NameMixStyleDuplicate)
163 std::string
name =
"InfoNameMixStyleDuplicate";
201TEST(StatsInfoTest, BaseCheckInit)
209TEST(StatsInfoTest, BaseCheckDisplay)
212 info.
setName(
"BaseCheckDisplay");
232TEST(StatsInfoDeathTest, NameEmpty)
235 ASSERT_ANY_THROW(info.
setName(
"",
false));
239TEST(StatsInfoDeathTest, NameSubEmpty)
242 ASSERT_ANY_THROW(info.
setName(
".a",
false));
246TEST(StatsInfoDeathTest, NameSubEmpty2)
249 ASSERT_ANY_THROW(info.
setName(
"A.",
false));
253TEST(StatsInfoDeathTest, NameSubEmpty3)
256 ASSERT_ANY_THROW(info.
setName(
"a.b..c",
false));
260TEST(StatsInfoDeathTest, NameFirstCharacterNumber)
263 ASSERT_ANY_THROW(info.
setName(
"1",
false));
267TEST(StatsInfoDeathTest, NameFirstCharacterNumberSub)
270 ASSERT_ANY_THROW(info.
setName(
"A.1",
false));
274TEST(StatsInfoDeathTest, NameFirstCharacterSpecial)
277 ASSERT_ANY_THROW(info.
setName(
"!",
false));
284TEST(StatsInfoDeathTest, NameFirstCharacterSpecialSub)
287 ASSERT_ANY_THROW(info.
setName(
"A.!",
false));
291TEST(StatsInfoDeathTest, NameOtherCharacterSpecial)
294 ASSERT_ANY_THROW(info.
setName(
"ab!de",
false));
298TEST(StatsInfoDeathTest, NameOldStyleDuplicate)
301 std::string
name =
"InfoNameOldStyleDuplicate";
310TEST(StatsInfoDeathTest, BaseCheckNoInit)
317TEST(StatsInfoDeathTest, BaseCheckDisplayNoName)
void visit(statistics::Output &visitor) override
Visitor entry for outputing statistics data.
bool zero() const override
bool check() const override
Check that this stat has been set up properly and is ready for use.
void reset() override
Reset the stat to the default state.
void prepare() override
Prepare the stat for dumping.
void setName(const std::string &name, bool old_style=true)
Set the name of this statistic.
Flags flags
The formatting flags.
std::string name
The name of the stat.
static std::string separatorString
The separator string used for vectors, dist, etc.
static bool less(Info *stat1, Info *stat2)
Checks if the first stat's name is alphabetically less than the second.
void setSeparator(std::string _sep)
void set(Type mask)
Set all flag's bits matching the given mask.
TEST(StatsInfoTest, NameNewStyle)
Test that a name is properly assigned under the new style.
const FlagsType init
This Stat is Initialized.
const FlagsType display
Print this stat.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
const std::string & name()