summaryrefslogtreecommitdiff
path: root/deps/v8/test/unittests/unicode-unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/unittests/unicode-unittest.cc')
-rw-r--r--deps/v8/test/unittests/unicode-unittest.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/deps/v8/test/unittests/unicode-unittest.cc b/deps/v8/test/unittests/unicode-unittest.cc
new file mode 100644
index 0000000000..67edfb7331
--- /dev/null
+++ b/deps/v8/test/unittests/unicode-unittest.cc
@@ -0,0 +1,39 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <memory>
+#include <string>
+
+#include "src/unicode-decoder.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace v8 {
+namespace internal {
+
+namespace {
+
+using Utf8Decoder = unibrow::Utf8Decoder<512>;
+
+void Decode(Utf8Decoder* decoder, const std::string& str) {
+ // Put the string in its own buffer on the heap to make sure that
+ // AddressSanitizer's heap-buffer-overflow logic can see what's going on.
+ std::unique_ptr<char[]> buffer(new char[str.length()]);
+ memcpy(buffer.get(), str.data(), str.length());
+ decoder->Reset(buffer.get(), str.length());
+}
+
+} // namespace
+
+TEST(UnicodeTest, ReadOffEndOfUtf8String) {
+ Utf8Decoder decoder;
+
+ // Not enough continuation bytes before string ends.
+ Decode(&decoder, "\xE0");
+ Decode(&decoder, "\xED");
+ Decode(&decoder, "\xF0");
+ Decode(&decoder, "\xF4");
+}
+
+} // namespace internal
+} // namespace v8