| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 The Android Open Source Project | 2 * Copyright 2010 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkBitSet.h" | 8 #include "SkBitSet.h" |
| 9 #include "SkData.h" | 9 #include "SkData.h" |
| 10 #include "SkPDFMakeToUnicodeCmap.h" | 10 #include "SkPDFMakeToUnicodeCmap.h" |
| 11 #include "SkStream.h" | 11 #include "SkStream.h" |
| 12 #include "Test.h" | 12 #include "Test.h" |
| 13 | 13 |
| 14 static const int kMaximumGlyphCount = SK_MaxU16 + 1; | 14 static const int kMaximumGlyphCount = SK_MaxU16 + 1; |
| 15 | 15 |
| 16 static bool stream_equals(const SkDynamicMemoryWStream& stream, size_t offset, | 16 static bool stream_equals(const SkDynamicMemoryWStream& stream, size_t offset, |
| 17 const char* buffer, size_t len) { | 17 const char* buffer, size_t len) { |
| 18 sk_sp<SkData> data(stream.copyToData()); | 18 sk_sp<SkData> data(stream.copyToData()); |
| 19 if (offset + len > data->size()) { | 19 if (offset + len > data->size()) { |
| 20 return false; | 20 return false; |
| 21 } | 21 } |
| 22 if (len != strlen(buffer)) { | 22 if (len != strlen(buffer)) { |
| 23 return false; | 23 return false; |
| 24 } | 24 } |
| 25 return memcmp(data->bytes() + offset, buffer, len) == 0; | 25 return memcmp(data->bytes() + offset, buffer, len) == 0; |
| 26 } | 26 } |
| 27 | 27 |
| 28 DEF_TEST(ToUnicode, reporter) { | 28 DEF_TEST(SkPDF_ToUnicode, reporter) { |
| 29 SkTDArray<SkUnichar> glyphToUnicode; | 29 SkTDArray<SkUnichar> glyphToUnicode; |
| 30 SkTDArray<uint16_t> glyphsInSubset; | 30 SkTDArray<uint16_t> glyphsInSubset; |
| 31 SkBitSet subset(kMaximumGlyphCount); | 31 SkBitSet subset(kMaximumGlyphCount); |
| 32 | 32 |
| 33 glyphToUnicode.push(0); // 0 | 33 glyphToUnicode.push(0); // 0 |
| 34 glyphToUnicode.push(0); // 1 | 34 glyphToUnicode.push(0); // 1 |
| 35 glyphToUnicode.push(0); // 2 | 35 glyphToUnicode.push(0); // 2 |
| 36 glyphsInSubset.push(3); | 36 glyphsInSubset.push(3); |
| 37 glyphToUnicode.push(0x20); // 3 | 37 glyphToUnicode.push(0x20); // 3 |
| 38 glyphsInSubset.push(4); | 38 glyphsInSubset.push(4); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 <004F> <006C>\n\ | 166 <004F> <006C>\n\ |
| 167 <0051> <006E>\n\ | 167 <0051> <006E>\n\ |
| 168 endbfchar\n\ | 168 endbfchar\n\ |
| 169 1 beginbfrange\n\ | 169 1 beginbfrange\n\ |
| 170 <0056> <0057> <0073>\n\ | 170 <0056> <0057> <0073>\n\ |
| 171 endbfrange\n"; | 171 endbfrange\n"; |
| 172 | 172 |
| 173 REPORTER_ASSERT(reporter, stream_equals(buffer2, 0, expectedResult2, | 173 REPORTER_ASSERT(reporter, stream_equals(buffer2, 0, expectedResult2, |
| 174 buffer2.getOffset())); | 174 buffer2.getOffset())); |
| 175 } | 175 } |
| OLD | NEW |