skia2/tests/CrbugOssfuzz21688.cpp
John Stiles fdbd50a8dc Simplify SkSL::String by removing unused parts.
- reset, findLastOf: these were entirely unused
- find: already existed in C++11's std::string, can just be inherited
- defaulted constructors: in C++11, these can be inherited directly from
  std::string via 'using'

Change-Id: I1772ef04e49ab905aaada2ec38c1abeb9a8e26bf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/311039
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-08-17 14:21:09 +00:00

32 lines
1.1 KiB
C++

/*
* Copyright 2020 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "tests/Test.h"
#include <memory>
#include "src/gpu/GrShaderCaps.h"
#include "src/sksl/SkSLCompiler.h"
#include "src/sksl/SkSLString.h"
#include "src/sksl/ir/SkSLProgram.h"
DEF_TEST(crbug_ossfuzz_21688_interfaceblock, reporter) {
// Tests that arrays of zero-sized interface blocks are disallowed.
SkSL::Compiler compiler;
SkSL::String output;
SkSL::Program::Settings settings;
sk_sp<GrShaderCaps> caps = SkSL::ShaderCapsFactory::Default();
settings.fCaps = caps.get();
const char* const kProgramText = "testBlock {} x[2];";
std::unique_ptr<SkSL::Program> program = compiler.convertProgram(SkSL::Program::kFragment_Kind,
kProgramText, settings);
REPORTER_ASSERT(reporter, program == nullptr);
REPORTER_ASSERT(reporter, compiler.errorText().find(
"interface block 'testBlock' must "
"contain at least one member") != SkSL::String::npos);
}