Flutter Engine
The Flutter Engine
Macros | Enumerations | Functions
FitsInTest.cpp File Reference
#include "include/core/SkTypes.h"
#include "include/private/base/SkTFitsIn.h"
#include "tests/Test.h"
#include <cstdint>
#include <limits>

Go to the source code of this file.

Macros

#define TEST(S, s, D, expected)   REPORTER_ASSERT(reporter, (SkTFitsIn<D>((S)(s)) == (expected)))
 

Enumerations

enum  TestEnum_t : uint8_t { kFoo , kBar , kBaz }
 

Functions

 DEF_TEST (FitsIn, reporter)
 

Macro Definition Documentation

◆ TEST

#define TEST (   S,
  s,
  D,
  expected 
)    REPORTER_ASSERT(reporter, (SkTFitsIn<D>((S)(s)) == (expected)))

Definition at line 15 of file FitsInTest.cpp.

Enumeration Type Documentation

◆ TestEnum_t

enum TestEnum_t : uint8_t
Enumerator
kFoo 
kBar 
kBaz 

Definition at line 17 of file FitsInTest.cpp.

17 : uint8_t {
18 kFoo,
19 kBar,
20 kBaz,
21};
@ kFoo
Definition: FitsInTest.cpp:18
@ kBaz
Definition: FitsInTest.cpp:20
@ kBar
Definition: FitsInTest.cpp:19

Function Documentation

◆ DEF_TEST()

DEF_TEST ( FitsIn  ,
reporter   
)

Definition at line 23 of file FitsInTest.cpp.

23 {
24 TEST(uint16_t, 257, int8_t, false);
25
26 TEST(int32_t, 1, int8_t, true);
27 TEST(int32_t, -1, int8_t, true);
28 TEST(int32_t, (int32_t)(std::numeric_limits<int8_t>::max)(), int8_t, true);
29 TEST(int32_t, ((int32_t)(std::numeric_limits<int8_t>::max)())+1, int8_t, false);
30 TEST(int32_t, (int32_t)(std::numeric_limits<int8_t>::min)(), int8_t, true);
31 TEST(int32_t, (int32_t)((std::numeric_limits<int8_t>::min)())-1, int8_t, false);
32
33 TEST(int32_t, 1, uint8_t, true);
34 TEST(int32_t, -1, uint8_t, false);
35 TEST(int32_t, (int32_t)(std::numeric_limits<uint8_t>::max)(), uint8_t, true);
36 TEST(int32_t, ((int32_t)(std::numeric_limits<uint8_t>::max)())+1, uint8_t, false);
37 TEST(int32_t, 0, uint8_t, true);
38 TEST(int32_t, -1, uint8_t, false);
39 TEST(int32_t, -127, uint8_t, false);
40 TEST(int32_t, -128, uint8_t, false);
41
42 TEST(uint8_t, 2, TestEnum_t, true);
43 TEST(TestEnum_t, kBar, uint8_t, true);
44
45 TEST(int32_t, 1000, int8_t, false);
46 TEST(int32_t, 1000, uint8_t, false);
47
48 TEST(int32_t, 1, int32_t, true);
49 TEST(int32_t, -1, int32_t, true);
50 TEST(int32_t, 1, uint32_t, true);
51 TEST(int32_t, -1, uint32_t, false);
52
53 TEST(int32_t, 1, int64_t, true);
54 TEST(int32_t, -1, int64_t, true);
55 TEST(int32_t, 1, uint64_t, true);
56 TEST(int32_t, -1, uint64_t, false);
57
58 TEST(uint32_t, 1, int8_t, true);
59 TEST(uint32_t, 1, uint8_t, true);
60 TEST(uint32_t, 1, int32_t, true);
61 TEST(uint32_t, 1, uint32_t, true);
62 TEST(uint32_t, 1, int64_t, true);
63 TEST(uint32_t, 1, uint64_t, true);
64
65 TEST(uint32_t, (std::numeric_limits<uint32_t>::max)(), int8_t, false);
66 TEST(uint32_t, (std::numeric_limits<uint32_t>::max)(), uint8_t, false);
67 TEST(uint32_t, (std::numeric_limits<uint32_t>::max)(), int32_t, false);
68 TEST(uint32_t, (std::numeric_limits<uint32_t>::max)(), uint32_t, true);
69 TEST(uint32_t, (std::numeric_limits<uint32_t>::max)(), int64_t, true);
70 TEST(uint32_t, (std::numeric_limits<uint32_t>::max)(), uint64_t, true);
71
72 TEST(uint64_t, 1, int8_t, true);
73 TEST(uint64_t, 1, uint8_t, true);
74 TEST(uint64_t, 1, int32_t, true);
75 TEST(uint64_t, 1, uint32_t, true);
76 TEST(uint64_t, 1, int64_t, true);
77 TEST(uint64_t, 1, uint64_t, true);
78
79 enum class E : int { n1 = -1, p1 = 1 };
80 TEST(E, E::p1, int, true);
81 TEST(E, E::n1, int, true);
82 TEST(int, -1, E, true);
83 TEST(int, 1, E, true);
84 TEST(E, E::p1, unsigned, true);
85 TEST(E, E::n1, unsigned, false);
86
87 // Uncommenting the following should cause compile failures.
88 //TEST(float, 1, uint64_t, true);
89}
TestEnum_t
Definition: FitsInTest.cpp:17
#define TEST(S, s, D, expected)
Definition: FitsInTest.cpp:15
static float max(float r, float g, float b)
Definition: hsl.cpp:49
static float min(float r, float g, float b)
Definition: hsl.cpp:48