Add ConstString to several other places where context isn't changed much during runtime.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-02-28 19:23:24 +01:00
parent 469fcfe280
commit 5a05a2f4d3
17 changed files with 73 additions and 85 deletions

View File

@@ -9,11 +9,11 @@ using namespace CreatureLib::Battling;
class TestScript : public Script {
private:
std::string _name;
ConstString _name;
public:
explicit TestScript(std::string name) : _name(std::move(name)){};
const std::string& GetName() const override { return _name; }
const ConstString& GetName() const override { return _name; }
void TestMethod(int& runCount) { runCount++; }
};

View File

@@ -9,11 +9,11 @@ using namespace CreatureLib::Battling;
class TestScript : public Script {
private:
std::string _name;
ConstString _name;
public:
explicit TestScript(std::string name) : _name(std::move(name)){};
const std::string& GetName() const override { return _name; }
const ConstString& GetName() const override { return _name; }
};
TEST_CASE("Empty script set count == 0", "[Battling, Scripting]") {
@@ -64,7 +64,7 @@ TEST_CASE("Add script to script set, then remove it", "[Battling, Scripting]") {
auto s = new TestScript("foobar");
set.Add(s);
REQUIRE(set.Count() == 1);
set.Remove("foobar");
set.Remove("foobar"_cnc);
REQUIRE(set.Count() == 0);
auto it = set.GetIterator();
REQUIRE(it->empty());
@@ -77,7 +77,7 @@ TEST_CASE("Add two scripts to script set, then remove them", "[Battling, Scripti
set.Add(s);
set.Add(s2);
REQUIRE(set.Count() == 2);
set.Remove("foobar");
set.Remove("foobar"_cnc);
REQUIRE(set.Count() == 1);
auto it = set.GetIterator();
REQUIRE(it->at(0)->GetName() == "foobar2");

View File

@@ -10,11 +10,11 @@ using namespace CreatureLib::Battling;
class TestScript : public Script {
private:
std::string _name;
ConstString _name;
public:
explicit TestScript(std::string name) : _name(std::move(name)){};
const std::string& GetName() const override { return _name; }
const ConstString& GetName() const override { return _name; }
void TestMethod(int& runCount) { runCount++; }
};

View File

@@ -24,9 +24,9 @@ SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
auto l = new SpeciesLibrary();
l->Insert("testSpecies1"_cnc,
new CreatureSpecies(0, "testSpecies1"_cnc,
new SpeciesVariant("default", 1, 1, 10, {0, 1},
StatisticSet<uint16_t>(10, 10, 10, 10, 10, 10), {"testTalent"},
{"testSecretTalent"}, new LearnableAttacks(100)),
new SpeciesVariant("default"_cnc, 1, 1, 10, {0, 1},
StatisticSet<uint16_t>(10, 10, 10, 10, 10, 10), {"testTalent"_cnc},
{"testSecretTalent"_cnc}, new LearnableAttacks(100)),
0.5f, "testGrowthRate"_cnc, 5));
return l;
}