// Copyright 2026 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <cstdlib>
#include <iostream>
#include <string_view>

#include "third_party/fuzztest/src/fuzztest/fuzztest.h"

// Very simple fuzzer to allow us to (manually) test that string comparison
// instrumentation is working. If so, this should almost immediately crash,
// otherwise it will run almost forever because there's no real chance of
// hitting upon 'fish' by accident.
void StringCompareWithSeeds(std::string_view the_string) {
  if (the_string == "fish") {
    std::cout << "Found fish\n";
    exit(1);
  }
}

// Seed with strings similar to target string to see impact on number of execs
// to find the crash.
FUZZ_TEST(TestFuzzer, StringCompareWithSeeds)
    .WithDomains(fuzztest::String().WithSeeds([]() -> std::vector<std::string> {
      // "fis" will not provide much direct signal to FuzzTest because it won't
      // make it past the string len check but "fisk" should help speed up
      // finding the string match by reporting a prefix match of "fis".
      return {"fis", "fisk"};
    }));
