| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Koji Ishii <kojiishi@gmail.com> | 2 * Copyright (C) 2012 Koji Ishii <kojiishi@gmail.com> |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "config.h" | 25 #include "config.h" |
| 26 | 26 |
| 27 #include "platform/SharedBuffer.h" | 27 #include "platform/SharedBuffer.h" |
| 28 #include "platform/fonts/opentype/OpenTypeTypes.h" | 28 #include "platform/fonts/opentype/OpenTypeTypes.h" |
| 29 #include "wtf/RefPtr.h" | 29 #include "wtf/RefPtr.h" |
| 30 #include <gtest/gtest.h> | 30 #include <gtest/gtest.h> |
| 31 | 31 |
| 32 using namespace blink; | 32 namespace blink { |
| 33 | |
| 34 namespace { | |
| 35 | 33 |
| 36 struct TestTable : OpenType::TableBase { | 34 struct TestTable : OpenType::TableBase { |
| 37 OpenType::Fixed version; | 35 OpenType::Fixed version; |
| 38 OpenType::Int16 ascender; | 36 OpenType::Int16 ascender; |
| 39 | 37 |
| 40 template <typename T> const T* validateOffset(const SharedBuffer& buffer, ui
nt16_t offset) const | 38 template <typename T> const T* validateOffset(const SharedBuffer& buffer, ui
nt16_t offset) const |
| 41 { | 39 { |
| 42 return TableBase::validateOffset<T>(buffer, offset); | 40 return TableBase::validateOffset<T>(buffer, offset); |
| 43 } | 41 } |
| 44 }; | 42 }; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 72 EXPECT_TRUE(table->validateOffset<uint8_t>(*buffer, offset)); | 70 EXPECT_TRUE(table->validateOffset<uint8_t>(*buffer, offset)); |
| 73 EXPECT_FALSE(table->validateOffset<uint8_t>(*buffer, sizeof(TestTable))); | 71 EXPECT_FALSE(table->validateOffset<uint8_t>(*buffer, sizeof(TestTable))); |
| 74 EXPECT_FALSE(table->validateOffset<uint8_t>(*buffer, sizeof(TestTable) + 1))
; | 72 EXPECT_FALSE(table->validateOffset<uint8_t>(*buffer, sizeof(TestTable) + 1))
; |
| 75 | 73 |
| 76 // For uint16_t, the last byte is invalid | 74 // For uint16_t, the last byte is invalid |
| 77 for (uint16_t offset = 0; offset < sizeof(TestTable) - 1; offset++) | 75 for (uint16_t offset = 0; offset < sizeof(TestTable) - 1; offset++) |
| 78 EXPECT_TRUE(table->validateOffset<uint16_t>(*buffer, offset)); | 76 EXPECT_TRUE(table->validateOffset<uint16_t>(*buffer, offset)); |
| 79 EXPECT_FALSE(table->validateOffset<uint16_t>(*buffer, sizeof(TestTable) - 1)
); | 77 EXPECT_FALSE(table->validateOffset<uint16_t>(*buffer, sizeof(TestTable) - 1)
); |
| 80 } | 78 } |
| 81 | 79 |
| 82 } // namespace | 80 } // namespace blink |
| OLD | NEW |