Skip to content

Commit

Permalink
avoid shadowing warning
Browse files Browse the repository at this point in the history
Signed-off-by: Rosen Penev <rosenp@gmail.com>
  • Loading branch information
neheb committed Feb 14, 2023
1 parent 691c78b commit 0698efe
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions unitTests/test_image_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using namespace Exiv2::Internal;
using Exiv2::makeSlice;
using Exiv2::Slice;

static const unsigned char buf[10] = {'a', 'b', 'c', 1, 4, 0, 'e', 136, 0, 'a'};
static const unsigned char b[10] = {'a', 'b', 'c', 1, 4, 0, 'e', 136, 0, 'a'};

template <typename T>
void checkBinaryToString(const Exiv2::Slice<T> sl, const char* expectedOutput) {
Expand All @@ -23,25 +23,25 @@ void checkBinaryToString(const Exiv2::Slice<T> sl, const char* expectedOutput) {

TEST(binaryToString, zeroStart) {
// a, b, c are printable, 1 & 4 are not => '.', 0 at last position => skipped
checkBinaryToString(makeSlice(buf, 0, 6), "abc..");
checkBinaryToString(makeSlice(b, 0, 6), "abc..");

// same as previous, but now last element is not ignored since it is not 0
checkBinaryToString(makeSlice(buf, 0, 5), "abc..");
checkBinaryToString(makeSlice(b, 0, 5), "abc..");

// same as first, only now the 0 & 136 are converted to '.'
checkBinaryToString(makeSlice(buf, 0, 8), "abc...e.");
checkBinaryToString(makeSlice(b, 0, 8), "abc...e.");

// should result in the same as previously, as trailing zero is ignored
checkBinaryToString(makeSlice(buf, 0, 9), "abc...e.");
checkBinaryToString(makeSlice(b, 0, 9), "abc...e.");

// ensure that the function does not overread when last element != 0
checkBinaryToString(makeSlice(buf, 0, sizeof(buf)), "abc...e..a");
checkBinaryToString(makeSlice(b, 0, sizeof(b)), "abc...e..a");
}

TEST(binaryToString, nonZeroStart) {
// start @ index 1, read 6 characters (until e)
checkBinaryToString(makeSlice(buf, 1, 7), "bc...e");
checkBinaryToString(makeSlice(b, 1, 7), "bc...e");

// start @ index 3, read until end
checkBinaryToString(makeSlice(buf, 3, sizeof(buf)), "...e..a");
checkBinaryToString(makeSlice(b, 3, sizeof(b)), "...e..a");
}

0 comments on commit 0698efe

Please sign in to comment.