2021-05-27 19:53:13 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2021 Google LLC
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <limits>
|
|
|
|
|
2021-08-13 21:29:51 +00:00
|
|
|
#include "include/sksl/SkSLErrorReporter.h"
|
2021-05-27 19:53:13 +00:00
|
|
|
#include "src/gpu/GrCaps.h"
|
|
|
|
#include "src/sksl/SkSLContext.h"
|
2021-09-16 17:18:10 +00:00
|
|
|
#include "src/sksl/SkSLMangler.h"
|
2021-05-27 19:53:13 +00:00
|
|
|
#include "tests/Test.h"
|
|
|
|
|
|
|
|
DEF_TEST(SkSLTypeLimits, r) {
|
|
|
|
GrShaderCaps caps(GrContextOptions{});
|
|
|
|
SkSL::TestingOnly_AbortErrorReporter errors;
|
2021-09-16 17:18:10 +00:00
|
|
|
SkSL::Mangler mangler;
|
|
|
|
SkSL::Context context(errors, caps, mangler);
|
2021-05-27 19:53:13 +00:00
|
|
|
|
|
|
|
using int_limits = std::numeric_limits<int32_t>;
|
|
|
|
REPORTER_ASSERT(r, context.fTypes.fInt->minimumValue() == int_limits::min());
|
|
|
|
REPORTER_ASSERT(r, context.fTypes.fInt->maximumValue() == int_limits::max());
|
|
|
|
|
|
|
|
using short_limits = std::numeric_limits<int16_t>;
|
|
|
|
REPORTER_ASSERT(r, context.fTypes.fShort->minimumValue() == short_limits::min());
|
|
|
|
REPORTER_ASSERT(r, context.fTypes.fShort->maximumValue() == short_limits::max());
|
|
|
|
|
|
|
|
using uint_limits = std::numeric_limits<uint32_t>;
|
|
|
|
REPORTER_ASSERT(r, context.fTypes.fUInt->minimumValue() == uint_limits::min());
|
|
|
|
REPORTER_ASSERT(r, context.fTypes.fUInt->maximumValue() == uint_limits::max());
|
|
|
|
|
|
|
|
using ushort_limits = std::numeric_limits<uint16_t>;
|
|
|
|
REPORTER_ASSERT(r, context.fTypes.fUShort->minimumValue() == ushort_limits::min());
|
|
|
|
REPORTER_ASSERT(r, context.fTypes.fUShort->maximumValue() == ushort_limits::max());
|
|
|
|
}
|