• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 "include/sksl/SkSLErrorReporter.h"
11 #include "src/gpu/GrCaps.h"
12 #include "src/sksl/SkSLContext.h"
13 #include "src/sksl/SkSLMangler.h"
14 #include "tests/Test.h"
15 
DEF_TEST(SkSLTypeLimits,r)16 DEF_TEST(SkSLTypeLimits, r) {
17     GrShaderCaps caps;
18     SkSL::TestingOnly_AbortErrorReporter errors;
19     SkSL::Mangler mangler;
20     SkSL::Context context(errors, caps, mangler);
21 
22     using int_limits = std::numeric_limits<int32_t>;
23     REPORTER_ASSERT(r, context.fTypes.fInt->minimumValue() == int_limits::min());
24     REPORTER_ASSERT(r, context.fTypes.fInt->maximumValue() == int_limits::max());
25 
26     using short_limits = std::numeric_limits<int16_t>;
27     REPORTER_ASSERT(r, context.fTypes.fShort->minimumValue() == short_limits::min());
28     REPORTER_ASSERT(r, context.fTypes.fShort->maximumValue() == short_limits::max());
29 
30     using uint_limits = std::numeric_limits<uint32_t>;
31     REPORTER_ASSERT(r, context.fTypes.fUInt->minimumValue() == uint_limits::min());
32     REPORTER_ASSERT(r, context.fTypes.fUInt->maximumValue() == uint_limits::max());
33 
34     using ushort_limits = std::numeric_limits<uint16_t>;
35     REPORTER_ASSERT(r, context.fTypes.fUShort->minimumValue() == ushort_limits::min());
36     REPORTER_ASSERT(r, context.fTypes.fUShort->maximumValue() == ushort_limits::max());
37 }
38