OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "test/unittests/test-utils.h" | 5 #include "test/unittests/test-utils.h" |
6 | 6 |
7 #include "src/objects-inl.h" | 7 #include "src/objects-inl.h" |
8 #include "src/wasm/decoder.h" | 8 #include "src/wasm/decoder.h" |
9 #include "src/wasm/leb-helper.h" | 9 #include "src/wasm/leb-helper.h" |
10 | 10 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 #define DECLARE_ENCODE_DECODE_CHECKER(ctype, name) \ | 91 #define DECLARE_ENCODE_DECODE_CHECKER(ctype, name) \ |
92 static void CheckEncodeDecode_##name(ctype val) { \ | 92 static void CheckEncodeDecode_##name(ctype val) { \ |
93 static const int kSize = 16; \ | 93 static const int kSize = 16; \ |
94 static byte buffer[kSize]; \ | 94 static byte buffer[kSize]; \ |
95 byte *ptr = buffer; \ | 95 byte *ptr = buffer; \ |
96 LEBHelper::write_##name(&ptr, val); \ | 96 LEBHelper::write_##name(&ptr, val); \ |
97 EXPECT_EQ(LEBHelper::sizeof_##name(val), \ | 97 EXPECT_EQ(LEBHelper::sizeof_##name(val), \ |
98 static_cast<size_t>(ptr - buffer)); \ | 98 static_cast<size_t>(ptr - buffer)); \ |
99 Decoder decoder(buffer, buffer + kSize); \ | 99 Decoder decoder(buffer, buffer + kSize); \ |
100 int length = 0; \ | 100 unsigned length = 0; \ |
101 ctype result = decoder.checked_read_##name(buffer, 0, &length); \ | 101 ctype result = decoder.checked_read_##name(buffer, 0, &length); \ |
102 EXPECT_EQ(val, result); \ | 102 EXPECT_EQ(val, result); \ |
103 EXPECT_EQ(LEBHelper::sizeof_##name(val), static_cast<size_t>(length)); \ | 103 EXPECT_EQ(LEBHelper::sizeof_##name(val), static_cast<size_t>(length)); \ |
104 } | 104 } |
105 | 105 |
106 DECLARE_ENCODE_DECODE_CHECKER(int32_t, i32v) | 106 DECLARE_ENCODE_DECODE_CHECKER(int32_t, i32v) |
107 DECLARE_ENCODE_DECODE_CHECKER(uint32_t, u32v) | 107 DECLARE_ENCODE_DECODE_CHECKER(uint32_t, u32v) |
108 DECLARE_ENCODE_DECODE_CHECKER(int64_t, i64v) | 108 DECLARE_ENCODE_DECODE_CHECKER(int64_t, i64v) |
109 DECLARE_ENCODE_DECODE_CHECKER(uint64_t, u64v) | 109 DECLARE_ENCODE_DECODE_CHECKER(uint64_t, u64v) |
110 | 110 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 CheckEncodeDecode_i64v(bit_cast<int64_t>(val)); | 182 CheckEncodeDecode_i64v(bit_cast<int64_t>(val)); |
183 } | 183 } |
184 | 184 |
185 for (uint64_t val = 0xFFFFFFFFFFFFFF3B; val != 0; val = val << 1) { | 185 for (uint64_t val = 0xFFFFFFFFFFFFFF3B; val != 0; val = val << 1) { |
186 CheckEncodeDecode_i64v(bit_cast<int64_t>(val)); | 186 CheckEncodeDecode_i64v(bit_cast<int64_t>(val)); |
187 } | 187 } |
188 } | 188 } |
189 } // namespace wasm | 189 } // namespace wasm |
190 } // namespace internal | 190 } // namespace internal |
191 } // namespace v8 | 191 } // namespace v8 |
OLD | NEW |