Remove namespaces, and make file-local helpers static
Names that only a namespace told apart get prefixes: TOOL_PAN, FONT_BOLD, ICON_FOLDER, COLOR_WHITE, path_to_utf8 and so on. The OpenGL shader class is ShaderProgram, and its uniform ShaderUniform, beside the document's Shader and Uniform. Free functions a member of the same name would hide are called through :: for now. Two unused shader window helpers are gone.
This commit is contained in:
1 parent
7fb2c607c2
commit
666f65bf3a
174 files changed
+2396
-3154
No files matched your search
+21
-24
@@ -1,8 +1,5 @@
|
||||
#include "common.h"
|
||||
|
||||
using namespace anm2ed;
|
||||
using namespace anm2ed::test;
|
||||
|
||||
TEST_CASE("per-fixture invariants")
|
||||
{
|
||||
for (const auto& fixture : fixtures_get())
|
||||
@@ -16,11 +13,11 @@ TEST_CASE("saved text escapes what it holds, and reads back the same")
|
||||
{
|
||||
auto model = model_load(file_load(CORPUS_DIR / "11_unknown.anm2"));
|
||||
model.extras.children.emplace_back(
|
||||
0, model::XmlNode{.tag = "Note",
|
||||
0, XmlNode{.tag = "Note",
|
||||
.attributes = {{"Quote", "it's \"x\" & <y>"}},
|
||||
.text = "a & b > c 'd' \"e\"",
|
||||
.children = {{.tag = "Inner", .children = {{.tag = "Leaf", .attributes = {{"A", "1"}}}}}}});
|
||||
auto text = model::model_to_string(model);
|
||||
auto text = model_to_string(model);
|
||||
CHECK(text.find("Quote=\"it's "x" & <y>\"") != std::string::npos);
|
||||
CHECK(text.find(">a & b > c 'd' \"e\"<") != std::string::npos);
|
||||
auto reloaded = model_load(text).extras.children;
|
||||
@@ -35,10 +32,10 @@ TEST_CASE("saves leave out default colors, which read back the same")
|
||||
{
|
||||
INFO("fixture: ", fixture.string());
|
||||
auto model = model_load(file_load(fixture));
|
||||
auto text = model::model_to_string(model);
|
||||
auto text = model_to_string(model);
|
||||
CHECK(text.find("Tint=\"255\"") == std::string::npos);
|
||||
CHECK(text.find("Offset=\"0\"") == std::string::npos);
|
||||
CHECK(model::model_hash(model_load(text)) == model::model_hash(model));
|
||||
CHECK(model_hash(model_load(text)) == model_hash(model));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,14 +45,14 @@ TEST_CASE("JSON documents read back as the editor's copy")
|
||||
{
|
||||
INFO("fixture: ", fixture.string());
|
||||
auto model = model_load(file_load(fixture));
|
||||
auto text = model::model_to_json(model);
|
||||
auto text = model_to_json(model);
|
||||
auto reloaded = model_load(text);
|
||||
CHECK(model::model_to_json(reloaded) == text);
|
||||
CHECK(model_to_json(reloaded) == text);
|
||||
// Unknown XML, element order, dangling references and repeated animation names are not kept.
|
||||
auto isQuirky = fixture.filename() == "09_legacy_quirks.anm2" || fixture.filename() == "11_unknown.anm2";
|
||||
if (!isQuirky)
|
||||
CHECK(model::model_serialize(reloaded, SERIALIZE_ANM2ED_DEFAULT) ==
|
||||
model::model_serialize(model, SERIALIZE_ANM2ED_DEFAULT));
|
||||
CHECK(model_serialize(reloaded, SERIALIZE_ANM2ED_DEFAULT) ==
|
||||
model_serialize(model, SERIALIZE_ANM2ED_DEFAULT));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +60,7 @@ TEST_CASE("JSON animations get unique names")
|
||||
{
|
||||
auto model = model_load(file_load(CORPUS_DIR / "01_minimal.anm2"));
|
||||
model.animations.entries.push_back(model.animations.entries.front());
|
||||
auto reloaded = model_load(model::model_to_json(model));
|
||||
auto reloaded = model_load(model_to_json(model));
|
||||
REQUIRE(reloaded.animations_count_get() == 2);
|
||||
CHECK(reloaded.animation_get(1)->name == reloaded.animation_get(0)->name + " 2");
|
||||
}
|
||||
@@ -71,9 +68,9 @@ TEST_CASE("JSON animations get unique names")
|
||||
TEST_CASE("JSON groups don't renumber an animation sharing their name")
|
||||
{
|
||||
auto model = model_load(file_load(CORPUS_DIR / "01_minimal.anm2"));
|
||||
auto animation = std::get<std::shared_ptr<const model::Animation>>(model.animations.entries.front());
|
||||
model.animations.entries = {model::AnimationGroup{.name = animation->name, .animations = {animation}}};
|
||||
auto reloaded = model_load(model::model_to_json(model));
|
||||
auto animation = std::get<std::shared_ptr<const Animation>>(model.animations.entries.front());
|
||||
model.animations.entries = {AnimationGroup{.name = animation->name, .animations = {animation}}};
|
||||
auto reloaded = model_load(model_to_json(model));
|
||||
REQUIRE(reloaded.animations_count_get() == 1);
|
||||
CHECK(reloaded.animation_get(0)->name == animation->name);
|
||||
}
|
||||
@@ -81,7 +78,7 @@ TEST_CASE("JSON groups don't renumber an animation sharing their name")
|
||||
TEST_CASE("JSON markers are a pair, and a frame's child an object only when it has one")
|
||||
{
|
||||
auto model = model_load(file_load(CORPUS_DIR / "01_minimal.anm2"));
|
||||
auto text = model::model_to_json(model);
|
||||
auto text = model_to_json(model);
|
||||
CHECK(text.find("\"child\"") == std::string::npos);
|
||||
model.animation_edit(0)->startMarker = 2;
|
||||
model.animation_edit(0)->endMarker = 5;
|
||||
@@ -89,12 +86,12 @@ TEST_CASE("JSON markers are a pair, and a frame's child an object only when it h
|
||||
REQUIRE(frame);
|
||||
frame->childMode = ChildMode::HOLD;
|
||||
frame->childStart = 3;
|
||||
text = model::model_to_json(model);
|
||||
text = model_to_json(model);
|
||||
CHECK(text.find("\"markers\": [2, 5]") != std::string::npos);
|
||||
CHECK(text.find("\"child\": {\"mode\": \"hold\", \"start\": 3}") != std::string::npos);
|
||||
auto reloaded = model_load(text);
|
||||
CHECK(reloaded.animation_get(0)->endMarker == 5);
|
||||
CHECK(model::model_to_json(reloaded) == text);
|
||||
CHECK(model_to_json(reloaded) == text);
|
||||
}
|
||||
|
||||
TEST_CASE("JSON dates are ISO 8601")
|
||||
@@ -105,7 +102,7 @@ TEST_CASE("JSON dates are ISO 8601")
|
||||
{"12/31/2024 11:59:59 PM", "2024-12-31T23:59:59"}})
|
||||
{
|
||||
model.info.createdOn = date;
|
||||
auto text = model::model_to_json(model);
|
||||
auto text = model_to_json(model);
|
||||
CHECK(text.find(iso) != std::string::npos);
|
||||
CHECK(model_load(text).info.createdOn == date);
|
||||
}
|
||||
@@ -116,9 +113,9 @@ TEST_CASE("JSON that can't be read is reported by where it is, and the rest stil
|
||||
auto text = R"({ "colour": 1, "info": { "fps": "fast" },
|
||||
"layers": [ { "name": "a", "sheet": 4 } ],
|
||||
"animations": { "Idle": { "length": 3, "root": [ { "pos": [1], "ease": "bouncy", "delay": 3 } ] } } })";
|
||||
model::Model model{};
|
||||
Model model{};
|
||||
std::string issues{};
|
||||
REQUIRE(model::model_load_string(model, text, &issues));
|
||||
REQUIRE(model_load_string(model, text, &issues));
|
||||
CHECK(model.animation_get(0)->frameNum == 3);
|
||||
CHECK(model.animation_get(0)->root.frames[0].duration == 3);
|
||||
for (auto issue : {"colour: unknown key", "info.fps: expected a number", "layers[0].sheet: no item at index 4",
|
||||
@@ -126,16 +123,16 @@ TEST_CASE("JSON that can't be read is reported by where it is, and the rest stil
|
||||
"animations.Idle.root[0].ease: unknown value \"bouncy\""})
|
||||
CHECK_MESSAGE(issues.find(issue) != std::string::npos, issue);
|
||||
|
||||
CHECK_FALSE(model::model_load_string(model, "{ \"fps\": 30, ", &issues));
|
||||
CHECK_FALSE(model_load_string(model, "{ \"fps\": 30, ", &issues));
|
||||
}
|
||||
|
||||
TEST_CASE("JSON layers can name a library listed after them in the file")
|
||||
{
|
||||
auto text = R"({ "layers": [ { "name": "shadow", "library": 0, "animation": "Small" } ],
|
||||
"libraries": [ "shared/shadows.anm2" ] })";
|
||||
model::Model model{};
|
||||
Model model{};
|
||||
std::string issues{};
|
||||
REQUIRE(model::model_load_string(model, text, &issues));
|
||||
REQUIRE(model_load_string(model, text, &issues));
|
||||
CHECK(issues.empty());
|
||||
CHECK(model.content.layers[0].libraryId == 0);
|
||||
}
|
||||
Reference in new issue
Block a user