chromium/third_party/zxcvbn-cpp/BUILD.gn

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

import("//testing/libfuzzer/fuzzer_test.gni")
import("//testing/test.gni")

config("zxcvbn_internal_config") {
  cflags = [ "-Wno-shadow" ]
}

config("zxcvbn_public_config") {
  include_dirs = [ "//third_party/zxcvbn-cpp/native-src" ]
}

source_set("zxcvbn-cpp") {
  sources = [
    "native-src/zxcvbn/adjacency_graphs.cpp",
    "native-src/zxcvbn/adjacency_graphs.hpp",
    "native-src/zxcvbn/common.hpp",
    "native-src/zxcvbn/frequency_lists.cpp",
    "native-src/zxcvbn/frequency_lists.hpp",
    "native-src/zxcvbn/matching.cpp",
    "native-src/zxcvbn/matching.hpp",
    "native-src/zxcvbn/optional.hpp",
    "native-src/zxcvbn/scoring.cpp",
    "native-src/zxcvbn/scoring.hpp",
    "native-src/zxcvbn/time_estimates.cpp",
    "native-src/zxcvbn/time_estimates.hpp",
    "native-src/zxcvbn/util.cpp",
    "native-src/zxcvbn/util.hpp",
  ]

  public_deps = [ "//base" ]
  deps = [ "//third_party/icu" ]

  public_configs = [ ":zxcvbn_public_config" ]
  configs += [ ":zxcvbn_internal_config" ]
}

test("zxcvbn_unittests") {
  sources = [
    "test/matching_unittest.cc",
    "test/scoring_unittest.cc",
  ]

  deps = [
    ":zxcvbn-cpp",
    "//testing/gmock",
    "//testing/gtest",
    "//testing/gtest:gtest_main",
  ]

  configs += [ ":zxcvbn_internal_config" ]
}

fuzzer_test("zxcvbn_matching_fuzzer") {
  sources = [ "test/matching_fuzzer.cc" ]
  deps = [
    ":zxcvbn-cpp",
    "//base",
  ]
  libfuzzer_options = [ "max_len=128" ]
}

fuzzer_test("zxcvbn_scoring_fuzzer") {
  sources = [ "test/scoring_fuzzer.cc" ]
  deps = [
    ":zxcvbn-cpp",
    "//base",
  ]
  libfuzzer_options = [ "max_len=128" ]
}