| // Copyright 2026 Google LLC | |
| // | |
| // Licensed under the Apache License, Version 2.0 (the "License"); | |
| // you may not use this file except in compliance with the License. | |
| // You may obtain a copy of the License at | |
| // | |
| // https://www.apache.org/licenses/LICENSE-2.0 | |
| // | |
| // Unless required by applicable law or agreed to in writing, software | |
| // distributed under the License is distributed on an "AS IS" BASIS, | |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| // See the License for the specific language governing permissions and | |
| // limitations under the License. | |
| // | |
| #include "formats/tiff/constants.h" | |
| #include "gtest/gtest.h" | |
| namespace credentio { | |
| namespace { | |
| TEST(ConstantsTest, SizeOfTiffType) { | |
| EXPECT_EQ(SizeOfTiffType(kTiffTypeByte), 1); | |
| EXPECT_EQ(SizeOfTiffType(kTiffTypeAscii), 1); | |
| EXPECT_EQ(SizeOfTiffType(kTiffTypeShort), 2); | |
| EXPECT_EQ(SizeOfTiffType(kTiffTypeLong), 4); | |
| EXPECT_EQ(SizeOfTiffType(kTiffTypeRational), 8); | |
| EXPECT_EQ(SizeOfTiffType(kTiffTypeSByte), 1); | |
| EXPECT_EQ(SizeOfTiffType(kTiffTypeUndefined), 1); | |
| EXPECT_EQ(SizeOfTiffType(kTiffTypeSShort), 2); | |
| EXPECT_EQ(SizeOfTiffType(kTiffTypeSLong), 4); | |
| EXPECT_EQ(SizeOfTiffType(kTiffTypeSRational), 8); | |
| EXPECT_EQ(SizeOfTiffType(kTiffTypeFloat), 4); | |
| EXPECT_EQ(SizeOfTiffType(kTiffTypeDouble), 8); | |
| EXPECT_EQ(SizeOfTiffType(0xFFFF), 1); // Default case | |
| } | |
| TEST(ConstantsTest, ByteSizeOfImageFileDirectory) { | |
| // count (2) + next offset (4) = 6 | |
| EXPECT_EQ(ByteSizeOfImageFileDirectory(0), 6); | |
| // 6 + 1 * 12 = 18 | |
| EXPECT_EQ(ByteSizeOfImageFileDirectory(1), 18); | |
| // 6 + 10 * 12 = 126 | |
| EXPECT_EQ(ByteSizeOfImageFileDirectory(10), 126); | |
| } | |
| } // namespace | |
| } // namespace credentio |