skia2/tests/AbseilTest.cpp
John Stiles 78debd6f6d Reland "Add Abseil to third_party."
This is a reland of 816226e822

Original change's description:
> Add Abseil to third_party.
>
> At present, this is a proof-of-concept which only supports a small
> subset of absl modules:
> - Base
> - Hash
> - Numeric
> - String
>
> This is only used by one unit test, which builds a string and then
> hashes it.
>
> Bug: skia:10165
> Bug: b/154848688
>
> Change-Id: I016250bf700b522c7a6bc78cf1844abff2260c35
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284805
> Reviewed-by: Derek Sollenberger <djsollen@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>

Bug: skia:10165, b/154848688
Change-Id: I618bb4411445fe5b45a91741934ca888a09adf05
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/285537
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-04-27 06:07:43 +00:00

26 lines
789 B
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"
#ifndef SK_BUILD_FOR_ANDROID_FRAMEWORK
#include "absl/hash/hash.h"
#include "absl/strings/substitute.h"
DEF_TEST(AbseilTest, reporter) {
// Tests that Abseil can be compiled, linked and run. Can be removed once Abseil is in use
// elsewhere.
const void* nullVoid = nullptr;
const std::string kStringToHash = absl::Substitute("$0 $1 $2 $3", "absl", 0, false, nullVoid);
REPORTER_ASSERT(reporter, kStringToHash == "absl 0 false NULL");
const size_t hashValue = absl::Hash<std::string>{}(kStringToHash);
REPORTER_ASSERT(reporter, hashValue != 0);
}
#endif // SK_BUILD_FOR_ANDROID_FRAMEWORK