| From 35b3b4180e8719be8dce0d68ec476a4315bb4538 Mon Sep 17 00:00:00 2001 |
| From: Michael Dolan <michdolan@gmail.com> |
| Date: Mon, 29 Apr 2019 15:51:32 -0700 |
| Subject: [PATCH] Fix typo in FormatRegistry::getFormatNameByIndex (RB-1.1) |
| (#736) |
| |
| * Fix typo in FormatRegistry::getFormatNameByIndex (#732) |
| |
| * Fix copy paste error |
| |
| * FormatByIndex API UnitTest |
| |
| * Fix invisible character |
| |
| * Improve unittest |
| |
| * Out of bounds index fix |
| |
| * Rename test method |
| |
| Conflicts: |
| src/OpenColorIO/transforms/FileTransform.cpp |
| |
| * Remove dependency on master Platform |
| --- |
| src/core/FileTransform.cpp | 35 ++++++++++++++++++++++++++++++++++- |
| 1 file changed, 34 insertions(+), 1 deletion(-) |
| |
| diff --git a/src/core/FileTransform.cpp b/src/core/FileTransform.cpp |
| index d3e144071..946265b9d 100644 |
| --- a/src/core/FileTransform.cpp |
| +++ b/src/core/FileTransform.cpp |
| @@ -334,7 +334,7 @@ OCIO_NAMESPACE_ENTER |
| } |
| else if(capability == FORMAT_CAPABILITY_WRITE) |
| { |
| - if(index<0 || index>=static_cast<int>(m_readFormatNames.size())) |
| + if(index<0 || index>=static_cast<int>(m_writeFormatNames.size())) |
| { |
| return ""; |
| } |
| @@ -671,3 +671,36 @@ OCIO_NAMESPACE_ENTER |
| } |
| } |
| OCIO_NAMESPACE_EXIT |
| + |
| +/////////////////////////////////////////////////////////////////////////////// |
| + |
| +#ifdef OCIO_UNIT_TEST |
| + |
| +namespace OCIO = OCIO_NAMESPACE; |
| +#include "UnitTest.h" |
| + |
| +void ValidateFormatByIndex(OCIO::FormatRegistry ®, int cap) |
| +{ |
| + int numFormat = reg.getNumFormats(cap); |
| + |
| + // Check out of bounds access |
| + OIIO_CHECK_EQUAL(0, strcmp(reg.getFormatNameByIndex(cap, -1), "")); |
| + OIIO_CHECK_EQUAL(0, strcmp(reg.getFormatExtensionByIndex(cap, -1), "")); |
| + OIIO_CHECK_EQUAL(0, strcmp(reg.getFormatNameByIndex(cap, numFormat), "")); |
| + OIIO_CHECK_EQUAL(0, strcmp(reg.getFormatExtensionByIndex(cap, numFormat), "")); |
| + |
| + // Check valid access |
| + for (int i = 0; i < numFormat; ++i) { |
| + OIIO_CHECK_NE(0, strcmp(reg.getFormatNameByIndex(cap, i), "")); |
| + OIIO_CHECK_NE(0, strcmp(reg.getFormatExtensionByIndex(cap, i), "")); |
| + } |
| +} |
| + |
| +OIIO_ADD_TEST(FileTransform, FormatByIndex) |
| +{ |
| + OCIO::FormatRegistry & formatRegistry = OCIO::FormatRegistry::GetInstance(); |
| + ValidateFormatByIndex(formatRegistry, OCIO::FORMAT_CAPABILITY_WRITE); |
| + ValidateFormatByIndex(formatRegistry, OCIO::FORMAT_CAPABILITY_READ); |
| +} |
| + |
| +#endif // OCIO_UNIT_TEST |