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

Unified 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: Actually add all of the files. 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 side-by-side diff with in-line comments
Download patch
Index: tests/FitsInTest.cpp
===================================================================
--- tests/FitsInTest.cpp (revision 0)
+++ tests/FitsInTest.cpp (working copy)
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "Test.h"
+#include "SkTFitsIn.h"
+#include <limits.h>
+namespace {
+
+#define TEST(S, s, D, expected) REPORTER_ASSERT(reporter, (SkTFitsIn<D>((S)(s)) == (expected)));
+
+static void FitsInTest(skiatest::Reporter* reporter) {
+ TEST(int, 1, signed char, true);
+ TEST(int, -1, signed char, true);
+ TEST(int, (int)SCHAR_MAX, signed char, true);
+ TEST(int, (int)SCHAR_MAX+1, signed char, false);
+ TEST(int, (int)SCHAR_MIN, signed char, true);
+ TEST(int, (int)SCHAR_MIN-1, signed char, false);
+
+ TEST(int, 1, unsigned char, true);
+ TEST(int, -1, unsigned char, false);
+ TEST(int, (int)UCHAR_MAX, unsigned char, true);
+ TEST(int, (int)UCHAR_MAX+1, unsigned char, false);
+ TEST(int, 0, unsigned char, true);
+ TEST(int, -1, unsigned char, false);
+ TEST(int, -127, unsigned char, false);
+ TEST(int, -128, unsigned char, false);
+
+ TEST(int, 1000, signed char, false);
+ TEST(int, 1000, unsigned char, false);
+
+ TEST(int, 1, int, true);
+ TEST(int, -1, int, true);
+ TEST(int, 1, unsigned int, true);
+ TEST(int, -1, unsigned int, false);
+
+ TEST(int, 1, long, true);
+ TEST(int, -1, long, true);
+ TEST(int, 1, unsigned long, true);
+ TEST(int, -1, unsigned long, false);
+
+ TEST(unsigned int, 1, signed char, true);
+ TEST(unsigned int, 1, unsigned char, true);
+ TEST(unsigned int, 1, int, true);
+ TEST(unsigned int, 1, unsigned int, true);
+ TEST(unsigned int, 1, long, true);
+ TEST(unsigned int, 1, unsigned long, true);
+
+ TEST(unsigned int, UINT_MAX, signed char, false);
+ TEST(unsigned int, UINT_MAX, unsigned char, false);
+ TEST(unsigned int, UINT_MAX, int, false);
+ TEST(unsigned int, UINT_MAX, unsigned int, true);
+ TEST(unsigned int, UINT_MAX, long, true);
+ TEST(unsigned int, UINT_MAX, unsigned long, true)
+
+ TEST(unsigned long, 1, signed char, true);
+ TEST(unsigned long, 1, unsigned char, true);
+ TEST(unsigned long, 1, int, true);
+ TEST(unsigned long, 1, unsigned int, true);
+ TEST(unsigned long, 1, long, true);
+ TEST(unsigned long, 1, unsigned long, true);
+}
+
+}
+
+#include "TestClassDef.h"
+DEFINE_TESTCLASS("FitsIn", FitsInTestClass, FitsInTest)
+
« src/utils/win/SkDWriteFontFileStream.cpp ('K') | « src/utils/win/SkDWriteFontFileStream.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698