Initialize with = instead of braces, and drop const from local autos
Scalars get = 0, = false or = nullptr. Standard containers and strings rely on their constructors.
Other types get = {} or = value, and lists keep = {...}.
glm types are left alone until they're replaced.
This commit is contained in:
1 parent
666f65bf3a
commit
40f6b554b5
138 files changed
+1500
-1500
No files matched your search
+6
-6
@@ -10,7 +10,7 @@
|
||||
|
||||
TEST_CASE("Image png round trip and uid tracking")
|
||||
{
|
||||
const std::vector<uint8_t> pixels{255, 0, 0, 255, 0, 255, 0, 128, 0, 0, 255, 0, 10, 20, 30, 40};
|
||||
const std::vector<uint8_t> pixels = {255, 0, 0, 255, 0, 255, 0, 128, 0, 0, 255, 0, 10, 20, 30, 40};
|
||||
Image image(pixels.data(), {2, 2});
|
||||
REQUIRE(image.is_valid());
|
||||
|
||||
@@ -45,8 +45,8 @@ TEST_CASE("AudioData holds file bytes")
|
||||
|
||||
TEST_CASE("AssetStore keys assets by content")
|
||||
{
|
||||
AssetStore store{};
|
||||
const std::vector<uint8_t> pixels{1, 2, 3, 4};
|
||||
AssetStore store = {};
|
||||
const std::vector<uint8_t> pixels = {1, 2, 3, 4};
|
||||
auto key = store.image_add(Image(pixels.data(), {1, 1}));
|
||||
CHECK(key != 0);
|
||||
CHECK(store.image_add(Image(pixels.data(), {1, 1})) == key);
|
||||
@@ -91,7 +91,7 @@ TEST_CASE("SVG spritesheets compose into SVGs that draw the same")
|
||||
CHECK(swapped.pixel_read({1.0f, 1.0f}) == glm::vec4());
|
||||
|
||||
// A PNG part is embedded as an image, pixel for pixel; composing the result again still works.
|
||||
const std::vector<uint8_t> pixels{255, 0, 0, 255, 0, 255, 0, 255, 0, 0, 255, 255, 255, 255, 255, 255};
|
||||
const std::vector<uint8_t> pixels = {255, 0, 0, 255, 0, 255, 0, 255, 0, 0, 255, 255, 255, 255, 255, 255};
|
||||
Image raster(pixels.data(), {2, 2});
|
||||
auto mixed = Image::compose({{&swapped, {}, swapped.size, {}}, {&raster, {}, raster.size, {32, 0}}}, {34, 16}, true);
|
||||
REQUIRE(mixed.is_vector());
|
||||
@@ -123,8 +123,8 @@ TEST_CASE("Embedded resources load")
|
||||
for (auto& info : FRIENDS)
|
||||
{
|
||||
INFO("friend: ", info.name);
|
||||
Model model{};
|
||||
std::string errorString{};
|
||||
Model model = {};
|
||||
std::string errorString;
|
||||
CHECK(model_load_string(model, std::string_view((const char*)info.anm2->data, info.anm2->size), &errorString));
|
||||
CHECK(model.animations_count_get() > 0);
|
||||
CHECK(Image(info.png->data, info.png->size).is_valid());
|
||||
|
||||
+5
-5
@@ -43,8 +43,8 @@
|
||||
|
||||
inline std::vector<std::filesystem::path> fixtures_get()
|
||||
{
|
||||
std::vector<std::filesystem::path> fixtures{};
|
||||
for (const auto& entry : std::filesystem::directory_iterator(CORPUS_DIR))
|
||||
std::vector<std::filesystem::path> fixtures;
|
||||
for (auto& entry : std::filesystem::directory_iterator(CORPUS_DIR))
|
||||
if (entry.path().extension() == ".anm2") fixtures.push_back(entry.path());
|
||||
std::ranges::sort(fixtures);
|
||||
return fixtures;
|
||||
@@ -52,7 +52,7 @@
|
||||
|
||||
inline Model model_load(const std::string& text)
|
||||
{
|
||||
Model model{};
|
||||
Model model = {};
|
||||
REQUIRE(model_load_string(model, text));
|
||||
return model;
|
||||
}
|
||||
@@ -60,14 +60,14 @@
|
||||
// Every serialization and merge the editor can produce for a document; goldens lock each one down.
|
||||
inline std::vector<Variant> variants_get(const Model& model)
|
||||
{
|
||||
std::vector<Variant> variants{};
|
||||
std::vector<Variant> variants;
|
||||
for (auto [name, flags] : PRESETS)
|
||||
variants.emplace_back(name, model_serialize(model, flags));
|
||||
variants.emplace_back("save", model_to_string(model));
|
||||
for (auto [name, type] : MERGES)
|
||||
{
|
||||
auto merged = model;
|
||||
std::set<int> sources{0, 1, 2};
|
||||
std::set<int> sources = {0, 1, 2};
|
||||
animations_merge(merged, 0, sources, type, type == MERGE_PREPEND || type == MERGE_REPLACE,
|
||||
{});
|
||||
variants.emplace_back(name, model_serialize(merged, SERIALIZE_ANM2ED_DEFAULT));
|
||||
|
||||
@@ -8,20 +8,20 @@ TEST_CASE("local corpus matches baselines" * doctest::skip(!is_env_set("ANM2ED_C
|
||||
? std::filesystem::path(std::getenv("ANM2ED_CORPUS_BASELINE"))
|
||||
: std::filesystem::path(std::getenv("HOME")) / ".cache/anm2ed/corpus";
|
||||
std::istringstream list(file_load(std::getenv("ANM2ED_CORPUS")));
|
||||
std::string line{};
|
||||
std::string line;
|
||||
while (std::getline(list, line))
|
||||
{
|
||||
if (line.empty()) continue;
|
||||
INFO("file: ", line);
|
||||
auto key = std::format("{:016x}", std::hash<std::string>{}(line));
|
||||
Model anm2{};
|
||||
std::string error{};
|
||||
Model anm2 = {};
|
||||
std::string error;
|
||||
if (!model_load(anm2, line, &error))
|
||||
{
|
||||
golden_check(baseline / (key + ".error.txt"), error, true);
|
||||
continue;
|
||||
}
|
||||
for (const auto& [name, text] : variants_get(anm2))
|
||||
for (auto& [name, text] : variants_get(anm2))
|
||||
golden_check(baseline / std::format("{}.{}.xml", key, name), text, true);
|
||||
invariants_check(anm2);
|
||||
}
|
||||
|
||||
+11
-11
@@ -28,7 +28,7 @@ TEST_CASE("root transforms fold into layer draws")
|
||||
auto plain = animation_draws_get(anm2, animation, {});
|
||||
auto rooted = animation_draws_get(anm2, animation, {.isRootTransform = true});
|
||||
REQUIRE(plain.size() == rooted.size());
|
||||
bool isAnyMoved{};
|
||||
bool isAnyMoved = false;
|
||||
for (int i = 0; i < (int)plain.size(); ++i)
|
||||
isAnyMoved |= plain[i].type == DrawType::LAYER && plain[i].parent != rooted[i].parent;
|
||||
CHECK(isAnyMoved);
|
||||
@@ -39,8 +39,8 @@ TEST_CASE("a layer frame's depth moves it among the layers for that frame only")
|
||||
auto anm2 = model_load(file_load(TEST_DIR / "render" / "spin.anm2"));
|
||||
auto layer_ids_get = [&](float time)
|
||||
{
|
||||
std::vector<int> ids{};
|
||||
for (const auto& draw : animation_draws_get(anm2, *anm2.animation_get(0), {.time = time}))
|
||||
std::vector<int> ids;
|
||||
for (auto& draw : animation_draws_get(anm2, *anm2.animation_get(0), {.time = time}))
|
||||
if (draw.type == DrawType::LAYER) ids.push_back(draw.id);
|
||||
return ids;
|
||||
};
|
||||
@@ -60,8 +60,8 @@ TEST_CASE("a layer frame's blur reaches its child's draws and stays out of the g
|
||||
{
|
||||
auto anm2 = model_load(file_load(TEST_DIR / "render" / "nested.anm2"));
|
||||
anm2.frame_edit({0, LAYER, 1, 0})->blur = 6.0f;
|
||||
bool isAnyChild{};
|
||||
for (const auto& draw : animation_draws_get(anm2, *anm2.animation_get(0), {}))
|
||||
bool isAnyChild = false;
|
||||
for (auto& draw : animation_draws_get(anm2, *anm2.animation_get(0), {}))
|
||||
if (draw.type == DrawType::LAYER && draw.id == 1)
|
||||
{
|
||||
isAnyChild = true;
|
||||
@@ -79,11 +79,11 @@ TEST_CASE("an animation layer draws its child animation, from this file or a lib
|
||||
{
|
||||
auto anm2 = model_load(file_load(TEST_DIR / "render" / "nested.anm2"));
|
||||
auto spin = model_load(file_load(TEST_DIR / "render" / "spin.anm2"));
|
||||
DrawOptions options{.library_get = [&](const Model&, int id) { return id == 0 ? &spin : nullptr; }};
|
||||
DrawOptions options = {.library_get = [&](const Model&, int id) { return id == 0 ? &spin : nullptr; }};
|
||||
auto red_position_get = [&](int layerId)
|
||||
{
|
||||
std::optional<glm::vec2> position{};
|
||||
for (const auto& draw : animation_draws_get(anm2, *anm2.animation_get(0), options))
|
||||
for (auto& draw : animation_draws_get(anm2, *anm2.animation_get(0), options))
|
||||
if (draw.type == DrawType::LAYER && draw.id == layerId && draw.frame.crop == glm::vec2())
|
||||
position = glm::vec2(draw.parent * glm::vec4(draw.frame.position, 0.0f, 1.0f));
|
||||
return position;
|
||||
@@ -143,8 +143,8 @@ TEST_CASE("child animations fire their triggers as they reach them")
|
||||
auto library_get = [&](const Model&, int id) { return id == 0 ? &spin : nullptr; };
|
||||
auto sources_get = [&](int time)
|
||||
{
|
||||
std::vector<const Model*> sources{};
|
||||
for (const auto& fire : animation_triggers_get(anm2, *anm2.animation_get(0), time, library_get))
|
||||
std::vector<const Model*> sources;
|
||||
for (auto& fire : animation_triggers_get(anm2, *anm2.animation_get(0), time, library_get))
|
||||
sources.push_back(fire.source);
|
||||
return sources;
|
||||
};
|
||||
@@ -171,7 +171,7 @@ TEST_CASE("flattening animation layers bakes their children into plain layers th
|
||||
auto points_get = [&](const Model& model, const LibraryGet& get, float time)
|
||||
{
|
||||
std::vector<glm::vec2> points{};
|
||||
for (const auto& draw :
|
||||
for (auto& draw :
|
||||
animation_draws_get(model, *model.animation_get(0), {.time = time, .library_get = get}))
|
||||
if (draw.type == DrawType::LAYER)
|
||||
points.push_back(glm::round(glm::vec2(draw.parent * draw_quad_model_get(draw) * glm::vec4(1, 1, 0, 1))));
|
||||
@@ -223,7 +223,7 @@ TEST_CASE("the game's copy stands in for depth and alpha offsets")
|
||||
auto draws_get = [](const Model& model, float time)
|
||||
{
|
||||
std::vector<std::pair<glm::vec2, glm::vec2>> draws{};
|
||||
for (const auto& draw : animation_draws_get(model, *model.animation_get(0), {.time = time}))
|
||||
for (auto& draw : animation_draws_get(model, *model.animation_get(0), {.time = time}))
|
||||
if (draw.type == DrawType::LAYER && draw.frame.isVisible)
|
||||
draws.emplace_back(draw.frame.crop, draw.frame.position);
|
||||
return draws;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
TEST_CASE("per-fixture invariants")
|
||||
{
|
||||
for (const auto& fixture : fixtures_get())
|
||||
for (auto& fixture : fixtures_get())
|
||||
{
|
||||
INFO("fixture: ", fixture.filename().string());
|
||||
invariants_check(model_load(file_load(fixture)));
|
||||
@@ -28,7 +28,7 @@ TEST_CASE("saved text escapes what it holds, and reads back the same")
|
||||
|
||||
TEST_CASE("saves leave out default colors, which read back the same")
|
||||
{
|
||||
for (const auto& fixture : fixtures_get())
|
||||
for (auto& fixture : fixtures_get())
|
||||
{
|
||||
INFO("fixture: ", fixture.string());
|
||||
auto model = model_load(file_load(fixture));
|
||||
@@ -41,7 +41,7 @@ TEST_CASE("saves leave out default colors, which read back the same")
|
||||
|
||||
TEST_CASE("JSON documents read back as the editor's copy")
|
||||
{
|
||||
for (const auto& fixture : fixtures_get())
|
||||
for (auto& fixture : fixtures_get())
|
||||
{
|
||||
INFO("fixture: ", fixture.string());
|
||||
auto model = model_load(file_load(fixture));
|
||||
@@ -113,8 +113,8 @@ 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{};
|
||||
std::string issues{};
|
||||
Model model = {};
|
||||
std::string 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);
|
||||
@@ -130,8 +130,8 @@ 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{};
|
||||
std::string issues{};
|
||||
Model model = {};
|
||||
std::string issues;
|
||||
REQUIRE(model_load_string(model, text, &issues));
|
||||
CHECK(issues.empty());
|
||||
CHECK(model.content.layers[0].libraryId == 0);
|
||||
|
||||
+17
-17
@@ -21,7 +21,7 @@ static Track& layer_track_get(Model& model, int animationIndex, int layerId)
|
||||
|
||||
static int groups_named_count(const Animation& animation, std::string_view name)
|
||||
{
|
||||
int count{};
|
||||
int count = 0;
|
||||
for (const auto* entries : {&animation.layers, &animation.nulls})
|
||||
groups_each(*entries, [&](const TrackGroup& group) { count += group.name == name; });
|
||||
return count;
|
||||
@@ -85,7 +85,7 @@ TEST_CASE("frames_change")
|
||||
for (auto [name, type] : CHANGES)
|
||||
{
|
||||
auto model = fixture_load("02_items.anm2");
|
||||
FrameChange change{.cropX = 2.0f, .positionY = 4.0f, .scaleX = 50.0f, .rotation = 90.0f, .tintR = 0.5f};
|
||||
FrameChange change = {.cropX = 2.0f, .positionY = 4.0f, .scaleX = 50.0f, .rotation = 90.0f, .tintR = 0.5f};
|
||||
change.duration = 3;
|
||||
change.interpolation = Interpolation::EASE_IN;
|
||||
change.isFlipX = true;
|
||||
@@ -101,8 +101,8 @@ TEST_CASE("frame_bake and frame_mix")
|
||||
frame_bake(layer_track_get(model, 0, 0), 3, 1, false, true);
|
||||
operation_check("frame_bake", model);
|
||||
|
||||
Frame from{};
|
||||
Frame to{};
|
||||
Frame from = {};
|
||||
Frame to = {};
|
||||
to.position = {10.0f, -20.0f};
|
||||
to.skew = {30.0f, 0.0f};
|
||||
to.rotation = 90.0f;
|
||||
@@ -145,7 +145,7 @@ TEST_CASE("edit layer operations")
|
||||
std::size_t uidCount;
|
||||
};
|
||||
|
||||
const Reference head{0, LAYER, 0};
|
||||
const Reference head = {0, LAYER, 0};
|
||||
const Case CASES[] = {
|
||||
{"frame_insert", "02_items.anm2",
|
||||
[&](Model& anm2) { return frame_insert(anm2, {0, LAYER, 0, 0}, 0); }, 1},
|
||||
@@ -195,7 +195,7 @@ TEST_CASE("edit layer operations")
|
||||
{"animations_paste", "02_items.anm2",
|
||||
[&](Model& anm2)
|
||||
{
|
||||
std::set<int> groupIds{};
|
||||
std::set<int> groupIds;
|
||||
auto text = animation_to_string(*anm2.animation_get(1));
|
||||
return animations_paste(anm2, text, 0, -1, groupIds, nullptr);
|
||||
},
|
||||
@@ -217,7 +217,7 @@ TEST_CASE("edit layer operations")
|
||||
{"frames_change_apply", "02_items.anm2",
|
||||
[&](Model& anm2)
|
||||
{
|
||||
FrameChange change{.positionX = 3.0f, .rotation = 10.0f};
|
||||
FrameChange change = {.positionX = 3.0f, .rotation = 10.0f};
|
||||
return frames_change_apply(
|
||||
anm2, {.references = {{0, LAYER, 0, 1}, {0, NULL_, 0}}, .animations = {1}, .isRoot = true}, change,
|
||||
ChangeType::ADD);
|
||||
@@ -227,7 +227,7 @@ TEST_CASE("edit layer operations")
|
||||
[&](Model& anm2) { return animations_merge(anm2, 0, {1}, MERGE_APPEND, true, {0}); }, 1},
|
||||
};
|
||||
|
||||
for (const auto& entry : CASES)
|
||||
for (auto& entry : CASES)
|
||||
{
|
||||
INFO("operation: ", std::string(entry.name));
|
||||
auto anm2 = fixture_load(entry.fixture);
|
||||
@@ -303,7 +303,7 @@ TEST_CASE("markers stay in the editor's copy and bound playback")
|
||||
CHECK(reloaded.animation_get(0)->startMarker == 2);
|
||||
CHECK(reloaded.animation_get(0)->endMarker == 5);
|
||||
|
||||
Playback playback{};
|
||||
Playback playback = {};
|
||||
playback.isPlaying = true;
|
||||
playback.tick(10, 2, 6, true, 0.1f);
|
||||
CHECK(playback.time == doctest::Approx(3.0f));
|
||||
@@ -325,9 +325,9 @@ TEST_CASE("isaac_issues_get counts what the game's copy changes")
|
||||
TEST_CASE("frames_property_set copies one property to the frames that have it")
|
||||
{
|
||||
auto model = fixture_load("02_items.anm2");
|
||||
Frame source{.crop = {7, 8}, .position = {3, 4}};
|
||||
Reference layer{0, LAYER, 0, 0};
|
||||
Reference null{0, NULL_, 0, 0};
|
||||
Frame source = {.crop = {7, 8}, .position = {3, 4}};
|
||||
Reference layer = {0, LAYER, 0, 0};
|
||||
Reference null = {0, NULL_, 0, 0};
|
||||
REQUIRE(model.frame_get(layer));
|
||||
REQUIRE(model.frame_get(null));
|
||||
auto nullCrop = model.frame_get(null)->crop;
|
||||
@@ -367,8 +367,8 @@ TEST_CASE("frames_split splits every selected frame that spans the time")
|
||||
TEST_CASE("change all frame properties changes layer depth only")
|
||||
{
|
||||
auto model = fixture_load("02_items.anm2");
|
||||
Reference layer{0, LAYER, 0, 0};
|
||||
Reference null{0, NULL_, 0, 0};
|
||||
Reference layer = {0, LAYER, 0, 0};
|
||||
Reference null = {0, NULL_, 0, 0};
|
||||
frames_change_apply(model, {.references = {layer, null}}, {.depth = 2}, ChangeType::ADD);
|
||||
frames_change_apply(model, {.references = {layer, null}}, {.depth = 1}, ChangeType::SUBTRACT);
|
||||
CHECK(model.frame_get(layer)->depth == 1);
|
||||
@@ -378,8 +378,8 @@ TEST_CASE("change all frame properties changes layer depth only")
|
||||
TEST_CASE("change all frame properties blurs layers and changes only animation layers' children")
|
||||
{
|
||||
auto model = model_load(file_load(TEST_DIR / "render" / "nested.anm2"));
|
||||
Reference animationLayer{0, LAYER, 1, 0};
|
||||
Reference spritesheetLayer{1, LAYER, 2, 0};
|
||||
Reference animationLayer = {0, LAYER, 1, 0};
|
||||
Reference spritesheetLayer = {1, LAYER, 2, 0};
|
||||
REQUIRE(model.frame_get(spritesheetLayer));
|
||||
frames_change_apply(model, {.references = {animationLayer, spritesheetLayer}},
|
||||
{.blur = 8.0f, .childAnimation = "Spin", .childMode = ChildMode::ONCE, .childStart = 3},
|
||||
@@ -489,7 +489,7 @@ TEST_CASE("content_remove takes what refers to an item with it")
|
||||
{ content_remove(model, type, ids, spritesheetId, library_get, path_keep); };
|
||||
auto tracks_count = [](const Model& model, int layerId)
|
||||
{
|
||||
int count{};
|
||||
int count = 0;
|
||||
for (auto [index, animation] : model.animations_get())
|
||||
tracks_each(animation->layers, [&](const Track& track, auto*) { count += track.id == layerId; });
|
||||
return count;
|
||||
|
||||
@@ -36,7 +36,7 @@ static void golden_image_check(const std::string& name)
|
||||
Image golden(goldenPath);
|
||||
REQUIRE(golden.is_valid());
|
||||
REQUIRE(actual.size == golden.size);
|
||||
int mismatches{};
|
||||
int mismatches = 0;
|
||||
for (std::size_t i = 0; i < actual.pixels.size(); ++i)
|
||||
mismatches += std::abs((int)actual.pixels[i] - (int)golden.pixels[i]) > CHANNEL_TOLERANCE;
|
||||
CHECK((double)mismatches / (double)actual.pixels.size() <= MISMATCH_RATIO_MAX);
|
||||
@@ -44,11 +44,11 @@ static void golden_image_check(const std::string& name)
|
||||
|
||||
struct RenderFixture
|
||||
{
|
||||
HeadlessGL gl{};
|
||||
std::optional<Document> document{};
|
||||
std::optional<ShaderProgram> shader{};
|
||||
std::optional<Canvas> canvas{};
|
||||
const Animation* animation{};
|
||||
HeadlessGL gl = {};
|
||||
std::optional<Document> document;
|
||||
std::optional<ShaderProgram> shader;
|
||||
std::optional<Canvas> canvas;
|
||||
const Animation* animation = nullptr;
|
||||
glm::vec4 bounds{};
|
||||
|
||||
explicit RenderFixture(const char* file)
|
||||
@@ -255,7 +255,7 @@ TEST_CASE("a Rebirth save flattens animation layers for the game")
|
||||
// The game's copy draws what the editor does: skew, blur and a skewed root baked into a spritesheet beside the save.
|
||||
TEST_CASE("the game's copy bakes skew and blur into a spritesheet that draws the same")
|
||||
{
|
||||
HeadlessGL gl{};
|
||||
HeadlessGL gl = {};
|
||||
if (!gl.is_valid()) return;
|
||||
auto directory = std::filesystem::temp_directory_path() / "anm2ed_bake";
|
||||
std::filesystem::remove_all(directory);
|
||||
@@ -278,7 +278,7 @@ TEST_CASE("the game's copy bakes skew and blur into a spritesheet that draws the
|
||||
REQUIRE(document.is_valid());
|
||||
REQUIRE(document.save(directory / "saved.anm2"));
|
||||
CHECK(std::filesystem::exists(directory / "saved.baked.png"));
|
||||
std::string saved{};
|
||||
std::string saved;
|
||||
{
|
||||
std::ifstream file(directory / "saved.anm2");
|
||||
saved.assign(std::istreambuf_iterator<char>(file), {});
|
||||
@@ -310,7 +310,7 @@ TEST_CASE("the game's copy bakes skew and blur into a spritesheet that draws the
|
||||
1.0f, glm::vec4(0.0f), true);
|
||||
REQUIRE(actual.size() == expected.size());
|
||||
CHECK(std::ranges::any_of(expected, [](uint8_t channel) { return channel != 0; }));
|
||||
int mismatches{};
|
||||
int mismatches = 0;
|
||||
for (std::size_t i = 0; i < actual.size(); ++i)
|
||||
mismatches += std::abs((int)actual[i] - (int)expected[i]) > CHANNEL_TOLERANCE;
|
||||
CHECK((double)mismatches / (double)actual.size() <= MISMATCH_RATIO_MAX);
|
||||
|
||||
+2
-2
@@ -4,10 +4,10 @@ TEST_CASE("fixtures match goldens")
|
||||
{
|
||||
auto fixtures = fixtures_get();
|
||||
REQUIRE(!fixtures.empty());
|
||||
for (const auto& fixture : fixtures)
|
||||
for (auto& fixture : fixtures)
|
||||
{
|
||||
auto anm2 = model_load(file_load(fixture));
|
||||
for (const auto& [name, text] : variants_get(anm2))
|
||||
for (auto& [name, text] : variants_get(anm2))
|
||||
golden_check(GOLDEN_DIR / std::format("{}.{}.xml", fixture.stem().string(), name), text);
|
||||
}
|
||||
}
|
||||
+9
-9
@@ -16,17 +16,17 @@ void selection_edit(Model& anm2, Selection& selection, auto&& edit)
|
||||
|
||||
TEST_CASE("uids are unique and non-zero after load")
|
||||
{
|
||||
for (const auto& fixture : fixtures_get())
|
||||
for (auto& fixture : fixtures_get())
|
||||
{
|
||||
auto anm2 = model_load(file_load(fixture));
|
||||
std::set<std::uint64_t> uids{};
|
||||
bool isUnique{true};
|
||||
std::set<std::uint64_t> uids;
|
||||
bool isUnique = true;
|
||||
for (auto [index, animation] : anm2.animations_get())
|
||||
animation_tracks_each(*animation,
|
||||
[&](const Track& track)
|
||||
{
|
||||
isUnique &= uids.insert(track.uid).second;
|
||||
for (const auto& frame : track.frames)
|
||||
for (auto& frame : track.frames)
|
||||
isUnique &= uids.insert(frame.uid).second;
|
||||
});
|
||||
INFO("fixture: ", fixture.filename().string());
|
||||
@@ -37,7 +37,7 @@ TEST_CASE("uids are unique and non-zero after load")
|
||||
TEST_CASE("selected frames and focus follow inserts and moves")
|
||||
{
|
||||
auto anm2 = fixture_load_with_uids("02_items.anm2");
|
||||
Selection selection{};
|
||||
Selection selection = {};
|
||||
selection_references_set(selection, anm2, SelectionKind::FRAMES, {{0, LAYER, 0, 1}, {0, LAYER, 1, 0}});
|
||||
selection_focus_set(selection, anm2, {0, LAYER, 0, 1});
|
||||
|
||||
@@ -53,7 +53,7 @@ TEST_CASE("selected frames and focus follow inserts and moves")
|
||||
TEST_CASE("a removed focus falls back to its nearest survivor")
|
||||
{
|
||||
auto anm2 = fixture_load_with_uids("02_items.anm2");
|
||||
Selection selection{};
|
||||
Selection selection = {};
|
||||
selection_focus_set(selection, anm2, {0, LAYER, 0, 1});
|
||||
selection_references_set(selection, anm2, SelectionKind::FRAMES, {{0, LAYER, 0, 1}});
|
||||
|
||||
@@ -72,11 +72,11 @@ TEST_CASE("a removed focus falls back to its nearest survivor")
|
||||
TEST_CASE("track and group selection follow regrouping")
|
||||
{
|
||||
auto anm2 = fixture_load_with_uids("03a_groups_nested.anm2");
|
||||
const TrackGroup* group{};
|
||||
const TrackGroup* group = nullptr;
|
||||
groups_each(anm2.animation_get(0)->layers, [&](const TrackGroup& candidate) { group = &candidate; });
|
||||
REQUIRE(group);
|
||||
auto groupId = group->id;
|
||||
Selection selection{};
|
||||
Selection selection = {};
|
||||
selection_references_set(selection, anm2, SelectionKind::TRACKS, {{0, LAYER, 0, -1, LAYER, groupId}});
|
||||
selection_references_set(selection, anm2, SelectionKind::GROUPS, {{0, LAYER, groupId}});
|
||||
|
||||
@@ -91,7 +91,7 @@ TEST_CASE("track and group selection follow regrouping")
|
||||
TEST_CASE("content selection follows items, and regions follow the focused spritesheet")
|
||||
{
|
||||
auto anm2 = fixture_load_with_uids("05_regions.anm2");
|
||||
Selection selection{};
|
||||
Selection selection = {};
|
||||
auto& regions = item_get(anm2.content.spritesheets, 0)->regions;
|
||||
REQUIRE(regions.size() > 1);
|
||||
auto regionId = regions[1].id;
|
||||
|
||||
+4
-4
@@ -12,7 +12,7 @@ constexpr int UNDO_LIMIT = 1000;
|
||||
static std::vector<Reference> references_all_get(const Model& anm2, bool isFrames)
|
||||
{
|
||||
UidIndex index(anm2);
|
||||
std::vector<Reference> result{};
|
||||
std::vector<Reference> result;
|
||||
auto add = [&](std::uint64_t uid)
|
||||
{
|
||||
auto reference = index.reference_get(uid);
|
||||
@@ -24,7 +24,7 @@ static std::vector<Reference> references_all_get(const Model& anm2, bool isFrame
|
||||
[&](const Track& track)
|
||||
{
|
||||
add(track.uid);
|
||||
for (const auto& frame : track.frames)
|
||||
for (auto& frame : track.frames)
|
||||
add(frame.uid);
|
||||
});
|
||||
return result;
|
||||
@@ -81,7 +81,7 @@ TEST_CASE("undo and redo restore every state of a random edit walk")
|
||||
{"02_items.anm2", "03a_groups_nested.anm2", "04_group_root_transform.anm2", "07_special_interpolation.anm2"})
|
||||
{
|
||||
INFO("fixture: ", name);
|
||||
Snapshots snapshots{};
|
||||
Snapshots snapshots = {};
|
||||
snapshots.current.model = model_load(file_load(CORPUS_DIR / name));
|
||||
std::mt19937 random(WALK_SEED);
|
||||
|
||||
@@ -113,7 +113,7 @@ TEST_CASE("undo and redo restore every state of a random edit walk")
|
||||
|
||||
TEST_CASE("selection follows its frame through an edit and its undo")
|
||||
{
|
||||
Snapshots snapshots{};
|
||||
Snapshots snapshots = {};
|
||||
auto& current = snapshots.current;
|
||||
current.model = model_load(file_load(CORPUS_DIR / "02_items.anm2"));
|
||||
selection_focus_set(current.selection, current.model, {0, LAYER, 0, 1});
|
||||
|
||||
Reference in new issue
Block a user