skia2/tests/AbseilTest.cpp
Mike Klein 56a6120b0f retry³ absl
This merges the two CLs we've been considering,

    1) the first attempt,
       https://skia-review.googlesource.com/c/skia/+/286070;
    2) the roll to latest Abseil LTS branch,
       https://skia-review.googlesource.com/c/skia/+/323076.

(See also the second attempt,
https://skia-review.googlesource.com/c/skia/+/322976.)

We'll need this working in Google3 or punt like we have for Android.

Bug: skia:10165
Cq-Include-Trybots: luci.skia.skia.primary:Canary-G3
Change-Id: Ifb42c1bb2c5e70848208d17b841cdb67bd36e182
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/323158
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-10-07 01:36:15 +00:00

38 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"
#ifndef SK_BUILD_FOR_ANDROID_FRAMEWORK
#include <absl/container/btree_map.h>
#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);
absl::btree_map<int, int> m;
m[42] = 47;
m[41] = 46;
int expected_key = 41,
expected_val = 46;
for (auto [k,v] : m) {
REPORTER_ASSERT(reporter, k == expected_key++);
REPORTER_ASSERT(reporter, v == expected_val++);
}
}
#endif // SK_BUILD_FOR_ANDROID_FRAMEWORK