From 859ef52951b4aa2f69c61ad7561521471179b2e4 Mon Sep 17 00:00:00 2001 From: Justin Israel Date: Fri, 16 Sep 2022 16:44:15 +1200 Subject: [PATCH] cpp: fix framesToFrameRange() bad formatting with 2 frames (refs #24) (#25) cpp: fix framesToFrameRange() bad formatting with 2 frames (refs #24) --- CHANGES | 1 + cpp/fileseq.cpp | 6 +++--- cpp/test/TestFunctions.cc | 23 +++++++++++++++++++++++ testdata/2frame/foo.0001.ext | 0 testdata/2frame/foo.0002.ext | 0 5 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 testdata/2frame/foo.0001.ext create mode 100644 testdata/2frame/foo.0002.ext diff --git a/CHANGES b/CHANGES index f01309f..f994ff8 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,7 @@ Changes: 2.11.1 ---------------- * cpp - Fix FrameSet::inverted() memory leak +* cpp - Fix framesToFrameRange() bad formatting with 2 frames 2.11.0 ---------------- diff --git a/cpp/fileseq.cpp b/cpp/fileseq.cpp index 505a14b..90cc6ac 100644 --- a/cpp/fileseq.cpp +++ b/cpp/fileseq.cpp @@ -31,8 +31,8 @@ std::string framesToFrameRange(const Frames &frames, return internal::zfill(frames[0], zfill); } - Frames::const_iterator framesIt = frames.begin(); - Frames::const_iterator framesEnd = frames.end(); + auto framesIt = frames.begin(); + auto framesEnd = frames.end(); Frames sortedFrames; @@ -66,8 +66,8 @@ std::string framesToFrameRange(const Frames &frames, buf << ","; } buf << internal::zfill(framesIt[i], zfill); + hasWritten = true; } - hasWritten = true; break; } diff --git a/cpp/test/TestFunctions.cc b/cpp/test/TestFunctions.cc index 83eb3e8..d9cbccc 100644 --- a/cpp/test/TestFunctions.cc +++ b/cpp/test/TestFunctions.cc @@ -33,6 +33,21 @@ class TestFramesToFrameRange : public testing::Test { Case t = {FRAME_ARR_TO_VEC(arr), false, 4, "-010"}; m_cases.push_back(t); } + { + fileseq::Frame arr[] = {1, 2}; + Case t = {FRAME_ARR_TO_VEC(arr), true, 0, "1,2"}; + m_cases.push_back(t); + } + { + fileseq::Frame arr[] = {1, 3}; + Case t = {FRAME_ARR_TO_VEC(arr), true, 0, "1,3"}; + m_cases.push_back(t); + } + { + fileseq::Frame arr[] = {2, 4}; + Case t = {FRAME_ARR_TO_VEC(arr), true, 0, "2,4"}; + m_cases.push_back(t); + } { fileseq::Frame arr[] = {1, 2, 3, 4, 5}; Case t = {FRAME_ARR_TO_VEC(arr), true, 0, "1-5"}; @@ -405,6 +420,14 @@ class TestFindSequenceOnDisk : public testing::Test { Case t = {PadStyleHash4, "testdata/seqA.$F4.exr", "testdata/seqA.1,3-6,8-10#.exr"}; m_cases.push_back(t); } + { + Case t = {PadStyleHash4, "testdata/2frame/foo.0001.ext", "testdata/2frame/foo.1,2#.ext"}; + m_cases.push_back(t); + } + { + Case t = {PadStyleHash4, "testdata/2frame/foo.#.ext", "testdata/2frame/foo.1,2#.ext"}; + m_cases.push_back(t); + } } std::vector m_cases; diff --git a/testdata/2frame/foo.0001.ext b/testdata/2frame/foo.0001.ext new file mode 100644 index 0000000..e69de29 diff --git a/testdata/2frame/foo.0002.ext b/testdata/2frame/foo.0002.ext new file mode 100644 index 0000000..e69de29