chromium/v8/test/unittests/parser/scanner-streams-unittest.cc

// 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 "src/base/strings.h"
#include "src/heap/factory-inl.h"
#include "src/objects/objects-inl.h"
#include "src/parsing/scanner-character-streams.h"
#include "src/parsing/scanner.h"
#include "test/unittests/heap/heap-utils.h"
#include "test/unittests/test-utils.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {

using ScannerStreamsTest = v8::TestWithIsolate;
// Implement ExternalSourceStream based on const char**.
// This will take each string as one chunk. The last chunk must be empty.
class ChunkSource : public v8::ScriptCompiler::ExternalSourceStream {};

// Checks that Lock() / Unlock() pairs are balanced. Not thread-safe.
class LockChecker {};

class TestExternalResource : public v8::String::ExternalStringResource,
                             public LockChecker {};

class TestExternalOneByteResource
    : public v8::String::ExternalOneByteStringResource,
      public LockChecker {};

// A test string with all lengths of utf-8 encodings.
const char unicode_utf8[] =;              // 3x ascii again.
const uint16_t unicode_ucs2[] =;

i::Handle<i::String> NewExternalTwoByteStringFromResource(
    i::Isolate* isolate, TestExternalResource* resource) {}

}  // anonymous namespace

TEST_F(ScannerStreamsTest, Utf8StreamAsciiOnly) {}

TEST_F(ScannerStreamsTest, Utf8StreamMaxNonSurrogateCharCode) {}

TEST_F(ScannerStreamsTest, Utf8StreamBOM) {}

TEST_F(ScannerStreamsTest, Utf8SplitBOM) {}

TEST_F(ScannerStreamsTest, Utf8SplitMultiBOM) {}

TEST_F(ScannerStreamsTest, Utf8AdvanceUntil) {}

TEST_F(ScannerStreamsTest, AdvanceMatchAdvanceUntil) {}

TEST_F(ScannerStreamsTest, Utf8AdvanceUntilOverChunkBoundaries) {}

TEST_F(ScannerStreamsTest, Utf8ChunkBoundaries) {}

TEST_F(ScannerStreamsTest, Utf8SingleByteChunks) {}

#define CHECK_EQU

void TestCharacterStream(const char* reference, i::Utf16CharacterStream* stream,
                         unsigned length, unsigned start, unsigned end) {}

void TestCloneCharacterStream(const char* reference,
                              i::Utf16CharacterStream* stream,
                              unsigned length) {}

#undef CHECK_EQU

void TestCharacterStreams(const char* one_byte_source, unsigned length,
                          unsigned start = 0, unsigned end = 0) {}

TEST_F(ScannerStreamsTest, CharacterStreams) {}

// Regression test for crbug.com/651333. Read invalid utf-8.
TEST_F(ScannerStreamsTest, Regress651333) {}

void TestChunkStreamAgainstReference(
    const char* cases[],
    const std::vector<std::vector<uint16_t>>& unicode_expected) {}

TEST_F(ScannerStreamsTest, Regress6377) {}

TEST_F(ScannerStreamsTest, Regress6836) {}

TEST_F(ScannerStreamsTest, TestOverlongAndInvalidSequences) {}

TEST_F(ScannerStreamsTest, RelocatingCharacterStream) {}

TEST_F(ScannerStreamsTest, RelocatingUnbufferedCharacterStream) {}

TEST_F(ScannerStreamsTest, CloneCharacterStreams) {}