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 "src/sksl/SkSLBuiltinTypes.h"
9 #include "src/sksl/ir/SkSLType.h"
10 #include "tests/Test.h"
11
12 #include <cstdint>
13 #include <limits>
14 #include <memory>
15
DEF_TEST(SkSLTypeLimits,r)16 DEF_TEST(SkSLTypeLimits, r) {
17 SkSL::BuiltinTypes types;
18
19 using int_limits = std::numeric_limits<int32_t>;
20 REPORTER_ASSERT(r, types.fInt->minimumValue() == int_limits::lowest());
21 REPORTER_ASSERT(r, types.fInt->maximumValue() == int_limits::max());
22
23 using short_limits = std::numeric_limits<int16_t>;
24 REPORTER_ASSERT(r, types.fShort->minimumValue() == short_limits::lowest());
25 REPORTER_ASSERT(r, types.fShort->maximumValue() == short_limits::max());
26
27 using uint_limits = std::numeric_limits<uint32_t>;
28 REPORTER_ASSERT(r, types.fUInt->minimumValue() == uint_limits::lowest());
29 REPORTER_ASSERT(r, types.fUInt->maximumValue() == uint_limits::max());
30
31 using ushort_limits = std::numeric_limits<uint16_t>;
32 REPORTER_ASSERT(r, types.fUShort->minimumValue() == ushort_limits::lowest());
33 REPORTER_ASSERT(r, types.fUShort->maximumValue() == ushort_limits::max());
34
35 using float_limits = std::numeric_limits<float>;
36 REPORTER_ASSERT(r, types.fFloat->minimumValue() == float_limits::lowest());
37 REPORTER_ASSERT(r, types.fFloat->maximumValue() == float_limits::max());
38 }
39