Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(900)

Side by Side Diff: tests/FitsInTest.cpp

Issue 18503009: Fix SkTFits in to work properly with signed/unsigned mixtures. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Address comments by adding comments and assertions. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/utils/win/SkDWriteFontFileStream.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 Google Inc.
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 "Test.h"
9
10 #include "SkTypes.h"
11 #include "SkTFitsIn.h"
12 #include <limits>
13
14 namespace {
15
16 #define TEST(S, s, D, expected) REPORTER_ASSERT(reporter, (SkTFitsIn<D>((S)(s)) == (expected)))
17
18 static void FitsInTest(skiatest::Reporter* reporter) {
19 TEST(int32_t, 1, int8_t, true);
20 TEST(int32_t, -1, int8_t, true);
21 TEST(int32_t, (int32_t)(std::numeric_limits<int8_t>::max)(), int8_t, tru e);
22 TEST(int32_t, ((int32_t)(std::numeric_limits<int8_t>::max)())+1, int8_t, fal se);
23 TEST(int32_t, (int32_t)(std::numeric_limits<int8_t>::min)(), int8_t, tru e);
24 TEST(int32_t, (int32_t)((std::numeric_limits<int8_t>::min)())-1, int8_t, fal se);
25
26 TEST(int32_t, 1, uint8_t, true);
27 TEST(int32_t, -1, uint8_t, false);
28 TEST(int32_t, (int32_t)(std::numeric_limits<uint8_t>::max)(), uint8_t, t rue);
29 TEST(int32_t, ((int32_t)(std::numeric_limits<uint8_t>::max)())+1, uint8_t, f alse);
30 TEST(int32_t, 0, uint8_t, true);
31 TEST(int32_t, -1, uint8_t, false);
32 TEST(int32_t, -127, uint8_t, false);
33 TEST(int32_t, -128, uint8_t, false);
34
35 TEST(int32_t, 1000, int8_t, false);
36 TEST(int32_t, 1000, uint8_t, false);
37
38 TEST(int32_t, 1, int32_t, true);
39 TEST(int32_t, -1, int32_t, true);
40 TEST(int32_t, 1, uint32_t, true);
41 TEST(int32_t, -1, uint32_t, false);
42
43 TEST(int32_t, 1, int64_t, true);
44 TEST(int32_t, -1, int64_t, true);
45 TEST(int32_t, 1, uint64_t, true);
46 TEST(int32_t, -1, uint64_t, false);
47
48 TEST(uint32_t, 1, int8_t, true);
49 TEST(uint32_t, 1, uint8_t, true);
50 TEST(uint32_t, 1, int32_t, true);
51 TEST(uint32_t, 1, uint32_t, true);
52 TEST(uint32_t, 1, int64_t, true);
53 TEST(uint32_t, 1, uint64_t, true);
54
55 TEST(uint32_t, (std::numeric_limits<uint32_t>::max)(), int8_t, false);
56 TEST(uint32_t, (std::numeric_limits<uint32_t>::max)(), uint8_t, false);
57 TEST(uint32_t, (std::numeric_limits<uint32_t>::max)(), int32_t, false);
58 TEST(uint32_t, (std::numeric_limits<uint32_t>::max)(), uint32_t, true);
59 TEST(uint32_t, (std::numeric_limits<uint32_t>::max)(), int64_t, true);
60 TEST(uint32_t, (std::numeric_limits<uint32_t>::max)(), uint64_t, true);
61
62 TEST(uint64_t, 1, int8_t, true);
63 TEST(uint64_t, 1, uint8_t, true);
64 TEST(uint64_t, 1, int32_t, true);
65 TEST(uint64_t, 1, uint32_t, true);
66 TEST(uint64_t, 1, int64_t, true);
67 TEST(uint64_t, 1, uint64_t, true);
68
69 // Uncommenting the following should cause compile failures.
70 //TEST(float, 1, uint64_t, true);
71 }
72
73 }
74
75 #include "TestClassDef.h"
76 DEFINE_TESTCLASS("FitsIn", FitsInTestClass, FitsInTest)
77
OLDNEW
« no previous file with comments | « src/utils/win/SkDWriteFontFileStream.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698