skia2/tests/FitsInTest.cpp
tfarina@chromium.org e4fafb146e Use DEFINE_TESTCLASS_SHORT macro in tests.
The three version of DEFINE_TESTCLASS macro is deprecated and thus just
use the simple, short one.

BUG=None
TEST=out/Debug/tests
R=mtklein@google.com, bsalomon@google.com, robertphillips@google.com

Review URL: https://codereview.chromium.org/100113004

git-svn-id: http://skia.googlecode.com/svn/trunk@12653 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-12-12 21:11:12 +00:00

71 lines
2.6 KiB
C++

/*
* 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 "TestClassDef.h"
#include "SkTypes.h"
#include "SkTFitsIn.h"
#include <limits>
#define TEST(S, s, D, expected) REPORTER_ASSERT(reporter, (SkTFitsIn<D>((S)(s)) == (expected)))
DEF_TEST(FitsIn, reporter) {
TEST(int32_t, 1, int8_t, true);
TEST(int32_t, -1, int8_t, true);
TEST(int32_t, (int32_t)(std::numeric_limits<int8_t>::max)(), int8_t, true);
TEST(int32_t, ((int32_t)(std::numeric_limits<int8_t>::max)())+1, int8_t, false);
TEST(int32_t, (int32_t)(std::numeric_limits<int8_t>::min)(), int8_t, true);
TEST(int32_t, (int32_t)((std::numeric_limits<int8_t>::min)())-1, int8_t, false);
TEST(int32_t, 1, uint8_t, true);
TEST(int32_t, -1, uint8_t, false);
TEST(int32_t, (int32_t)(std::numeric_limits<uint8_t>::max)(), uint8_t, true);
TEST(int32_t, ((int32_t)(std::numeric_limits<uint8_t>::max)())+1, uint8_t, false);
TEST(int32_t, 0, uint8_t, true);
TEST(int32_t, -1, uint8_t, false);
TEST(int32_t, -127, uint8_t, false);
TEST(int32_t, -128, uint8_t, false);
TEST(int32_t, 1000, int8_t, false);
TEST(int32_t, 1000, uint8_t, false);
TEST(int32_t, 1, int32_t, true);
TEST(int32_t, -1, int32_t, true);
TEST(int32_t, 1, uint32_t, true);
TEST(int32_t, -1, uint32_t, false);
TEST(int32_t, 1, int64_t, true);
TEST(int32_t, -1, int64_t, true);
TEST(int32_t, 1, uint64_t, true);
TEST(int32_t, -1, uint64_t, false);
TEST(uint32_t, 1, int8_t, true);
TEST(uint32_t, 1, uint8_t, true);
TEST(uint32_t, 1, int32_t, true);
TEST(uint32_t, 1, uint32_t, true);
TEST(uint32_t, 1, int64_t, true);
TEST(uint32_t, 1, uint64_t, true);
TEST(uint32_t, (std::numeric_limits<uint32_t>::max)(), int8_t, false);
TEST(uint32_t, (std::numeric_limits<uint32_t>::max)(), uint8_t, false);
TEST(uint32_t, (std::numeric_limits<uint32_t>::max)(), int32_t, false);
TEST(uint32_t, (std::numeric_limits<uint32_t>::max)(), uint32_t, true);
TEST(uint32_t, (std::numeric_limits<uint32_t>::max)(), int64_t, true);
TEST(uint32_t, (std::numeric_limits<uint32_t>::max)(), uint64_t, true);
TEST(uint64_t, 1, int8_t, true);
TEST(uint64_t, 1, uint8_t, true);
TEST(uint64_t, 1, int32_t, true);
TEST(uint64_t, 1, uint32_t, true);
TEST(uint64_t, 1, int64_t, true);
TEST(uint64_t, 1, uint64_t, true);
// Uncommenting the following should cause compile failures.
//TEST(float, 1, uint64_t, true);
}