Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: test/unittests/wasm/leb-helper-unittest.cc

Issue 2052623003: [wasm] improve handling of malformed input (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove debugging statement Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/wasm/decoder.h" 7 #include "src/wasm/decoder.h"
8 #include "src/wasm/leb-helper.h" 8 #include "src/wasm/leb-helper.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 #define DECLARE_ENCODE_DECODE_CHECKER(ctype, name) \ 90 #define DECLARE_ENCODE_DECODE_CHECKER(ctype, name) \
91 static void CheckEncodeDecode_##name(ctype val) { \ 91 static void CheckEncodeDecode_##name(ctype val) { \
92 static const int kSize = 16; \ 92 static const int kSize = 16; \
93 static byte buffer[kSize]; \ 93 static byte buffer[kSize]; \
94 byte *ptr = buffer; \ 94 byte *ptr = buffer; \
95 LEBHelper::write_##name(&ptr, val); \ 95 LEBHelper::write_##name(&ptr, val); \
96 EXPECT_EQ(LEBHelper::sizeof_##name(val), \ 96 EXPECT_EQ(LEBHelper::sizeof_##name(val), \
97 static_cast<size_t>(ptr - buffer)); \ 97 static_cast<size_t>(ptr - buffer)); \
98 Decoder decoder(buffer, buffer + kSize); \ 98 Decoder decoder(buffer, buffer + kSize); \
99 int length = 0; \ 99 unsigned int length = 0; \
100 ctype result = decoder.checked_read_##name(buffer, 0, &length); \ 100 ctype result = decoder.checked_read_##name(buffer, 0, &length); \
101 EXPECT_EQ(val, result); \ 101 EXPECT_EQ(val, result); \
102 EXPECT_EQ(LEBHelper::sizeof_##name(val), static_cast<size_t>(length)); \ 102 EXPECT_EQ(LEBHelper::sizeof_##name(val), static_cast<size_t>(length)); \
103 } 103 }
104 104
105 DECLARE_ENCODE_DECODE_CHECKER(int32_t, i32v) 105 DECLARE_ENCODE_DECODE_CHECKER(int32_t, i32v)
106 DECLARE_ENCODE_DECODE_CHECKER(uint32_t, u32v) 106 DECLARE_ENCODE_DECODE_CHECKER(uint32_t, u32v)
107 DECLARE_ENCODE_DECODE_CHECKER(int64_t, i64v) 107 DECLARE_ENCODE_DECODE_CHECKER(int64_t, i64v)
108 DECLARE_ENCODE_DECODE_CHECKER(uint64_t, u64v) 108 DECLARE_ENCODE_DECODE_CHECKER(uint64_t, u64v)
109 109
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 CheckEncodeDecode_i64v(bit_cast<int64_t>(val)); 181 CheckEncodeDecode_i64v(bit_cast<int64_t>(val));
182 } 182 }
183 183
184 for (uint64_t val = 0xFFFFFFFFFFFFFF3B; val != 0; val = val << 1) { 184 for (uint64_t val = 0xFFFFFFFFFFFFFF3B; val != 0; val = val << 1) {
185 CheckEncodeDecode_i64v(bit_cast<int64_t>(val)); 185 CheckEncodeDecode_i64v(bit_cast<int64_t>(val));
186 } 186 }
187 } 187 }
188 } // namespace wasm 188 } // namespace wasm
189 } // namespace internal 189 } // namespace internal
190 } // namespace v8 190 } // namespace v8
OLDNEW
« src/wasm/ast-decoder.h ('K') | « test/unittests/wasm/decoder-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698