2011-07-28 14:26:00 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2011 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2013-12-12 21:11:12 +00:00
|
|
|
|
2009-05-08 16:45:52 +00:00
|
|
|
#include "SkSize.h"
|
2014-06-25 17:39:00 +00:00
|
|
|
|
2014-01-24 20:56:26 +00:00
|
|
|
#include "Test.h"
|
2009-05-08 16:45:52 +00:00
|
|
|
|
2014-06-25 17:39:00 +00:00
|
|
|
DEF_TEST(ISize, reporter) {
|
2009-05-08 16:45:52 +00:00
|
|
|
SkISize a, b;
|
2012-08-23 18:14:13 +00:00
|
|
|
|
2009-05-08 16:45:52 +00:00
|
|
|
a.set(0, 0);
|
|
|
|
REPORTER_ASSERT(reporter, a.isEmpty());
|
|
|
|
a.set(5, -5);
|
|
|
|
REPORTER_ASSERT(reporter, a.isEmpty());
|
2017-04-11 16:12:02 +00:00
|
|
|
a = SkISize{5, 0};
|
2009-05-08 16:45:52 +00:00
|
|
|
REPORTER_ASSERT(reporter, a.isEmpty());
|
|
|
|
b.set(5, 0);
|
|
|
|
REPORTER_ASSERT(reporter, a == b);
|
2012-08-23 18:14:13 +00:00
|
|
|
|
2009-05-08 16:45:52 +00:00
|
|
|
a.set(3, 5);
|
|
|
|
REPORTER_ASSERT(reporter, !a.isEmpty());
|
|
|
|
b = a;
|
|
|
|
REPORTER_ASSERT(reporter, !b.isEmpty());
|
|
|
|
REPORTER_ASSERT(reporter, a == b);
|
|
|
|
REPORTER_ASSERT(reporter, !(a != b));
|
|
|
|
REPORTER_ASSERT(reporter,
|
|
|
|
a.fWidth == b.fWidth && a.fHeight == b.fHeight);
|
|
|
|
}
|
|
|
|
|
2013-12-12 21:11:12 +00:00
|
|
|
DEF_TEST(Size, reporter) {
|
2009-05-08 16:45:52 +00:00
|
|
|
SkSize a, b;
|
|
|
|
int ix = 5;
|
|
|
|
int iy = 3;
|
|
|
|
SkScalar x = SkIntToScalar(ix);
|
|
|
|
SkScalar y = SkIntToScalar(iy);
|
2012-08-23 18:14:13 +00:00
|
|
|
|
2009-05-08 16:45:52 +00:00
|
|
|
a.set(0, 0);
|
|
|
|
REPORTER_ASSERT(reporter, a.isEmpty());
|
|
|
|
a.set(x, -x);
|
|
|
|
REPORTER_ASSERT(reporter, a.isEmpty());
|
2017-04-11 16:12:02 +00:00
|
|
|
a = SkSize{x, 0};
|
2009-05-08 16:45:52 +00:00
|
|
|
REPORTER_ASSERT(reporter, a.isEmpty());
|
|
|
|
b.set(x, 0);
|
|
|
|
REPORTER_ASSERT(reporter, a == b);
|
2012-08-23 18:14:13 +00:00
|
|
|
|
2009-05-08 16:45:52 +00:00
|
|
|
a.set(y, x);
|
|
|
|
REPORTER_ASSERT(reporter, !a.isEmpty());
|
|
|
|
b = a;
|
|
|
|
REPORTER_ASSERT(reporter, !b.isEmpty());
|
|
|
|
REPORTER_ASSERT(reporter, a == b);
|
|
|
|
REPORTER_ASSERT(reporter, !(a != b));
|
|
|
|
REPORTER_ASSERT(reporter,
|
|
|
|
a.fWidth == b.fWidth && a.fHeight == b.fHeight);
|
2012-08-23 18:14:13 +00:00
|
|
|
|
2009-05-08 16:45:52 +00:00
|
|
|
SkISize ia;
|
|
|
|
ia.set(ix, iy);
|
|
|
|
a.set(x, y);
|
2010-06-15 00:57:50 +00:00
|
|
|
REPORTER_ASSERT(reporter, a.toRound() == ia);
|
2013-12-12 21:11:12 +00:00
|
|
|
}
|