skia2/tests/graphite/MaskTest.cpp
Greg Daniel 7b64e138b5 [graphite] Remove use of GraphiteTypesPriv and move to *Types in src.
We should only be using include/private for types that actually are
needed in include/ files. I moved everything that was just in src to
new src/*Types.h files. This actually left nothing in GraphiteTypesPriv
for now, so I deleted it. If we actually need private types that are
part of include/ we can add it back later.

Bug: skia:12466
Change-Id: I180fc2032afd47bc6c5e8b9ccd4954b5d2451fc7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/471758
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2021-11-15 20:57:23 +00:00

50 lines
1.4 KiB
C++

/*
* Copyright 2019 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "experimental/graphite/src/EnumBitMask.h"
#include "tests/Test.h"
enum class Flags {
kNone = 0,
kA = 1,
kB = 2,
kC = 4
};
SKGPU_MAKE_MASK_OPS(Flags);
using namespace skgpu;
DEF_GRAPHITE_TEST(skgpu_Mask, r) {
Mask<Flags> flags = Flags::kNone;
REPORTER_ASSERT(r, !flags);
flags |= Flags::kA;
REPORTER_ASSERT(r, flags);
REPORTER_ASSERT(r, !(flags & Flags::kB));
REPORTER_ASSERT(r, (flags & Flags::kA));
flags |= (Flags::kB | Flags::kC);
auto mask = Flags::kB | Flags::kC;
REPORTER_ASSERT(r, (flags & mask) == mask);
REPORTER_ASSERT(r, flags == (Flags::kA | Flags::kB | Flags::kC));
flags &= ~Flags::kC;
REPORTER_ASSERT(r, flags == (Flags::kA | Flags::kB));
REPORTER_ASSERT(r, (flags & mask) != mask);
REPORTER_ASSERT(r, (flags & mask) != Flags::kNone);
REPORTER_ASSERT(r, (flags & mask));
REPORTER_ASSERT(r, flags);
flags &= ~Flags::kB;
REPORTER_ASSERT(r, (flags & mask) == Flags::kNone);
REPORTER_ASSERT(r, !(flags & mask));
REPORTER_ASSERT(r, flags);
flags = (flags | flags) ^ (flags);
REPORTER_ASSERT(r, !flags);
flags ^= mask;
REPORTER_ASSERT(r, flags == mask);
REPORTER_ASSERT(r, !(Flags::kA & Flags::kB));
REPORTER_ASSERT(r, (Flags::kA ^ Flags::kB) == (Flags::kA | Flags::kB));
}