blob: c10361e196d1539218ba062ca8369e3d040499ca [file] [log] [blame]
John Stiles7d341a32021-05-27 15:53:13 -04001/*
2 * Copyright 2021 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include <limits>
9
10#include "src/gpu/GrCaps.h"
11#include "src/sksl/SkSLContext.h"
12#include "src/sksl/SkSLErrorReporter.h"
13#include "tests/Test.h"
14
15DEF_TEST(SkSLTypeLimits, r) {
16 GrShaderCaps caps(GrContextOptions{});
17 SkSL::TestingOnly_AbortErrorReporter errors;
18 SkSL::Context context(errors, caps);
19
20 using int_limits = std::numeric_limits<int32_t>;
21 REPORTER_ASSERT(r, context.fTypes.fInt->minimumValue() == int_limits::min());
22 REPORTER_ASSERT(r, context.fTypes.fInt->maximumValue() == int_limits::max());
23
24 using short_limits = std::numeric_limits<int16_t>;
25 REPORTER_ASSERT(r, context.fTypes.fShort->minimumValue() == short_limits::min());
26 REPORTER_ASSERT(r, context.fTypes.fShort->maximumValue() == short_limits::max());
27
28 using uint_limits = std::numeric_limits<uint32_t>;
29 REPORTER_ASSERT(r, context.fTypes.fUInt->minimumValue() == uint_limits::min());
30 REPORTER_ASSERT(r, context.fTypes.fUInt->maximumValue() == uint_limits::max());
31
32 using ushort_limits = std::numeric_limits<uint16_t>;
33 REPORTER_ASSERT(r, context.fTypes.fUShort->minimumValue() == ushort_limits::min());
34 REPORTER_ASSERT(r, context.fTypes.fUShort->maximumValue() == ushort_limits::max());
35}