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
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
|
#include "tests/Test.h"
|
2018-03-01 20:56:37 +00:00
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
|
#include "include/core/SkString.h"
|
|
|
|
|
#include "src/core/SkStringUtils.h"
|
2018-09-19 15:31:27 +00:00
|
|
|
|
|
2013-10-11 18:50:45 +00:00
|
|
|
|
#include <stdio.h>
|
2017-10-30 15:57:15 +00:00
|
|
|
|
#include <thread>
|
2011-07-08 17:49:22 +00:00
|
|
|
|
|
2013-12-12 21:11:12 +00:00
|
|
|
|
DEF_TEST(String, reporter) {
|
2009-02-27 22:06:06 +00:00
|
|
|
|
SkString a;
|
|
|
|
|
SkString b((size_t)0);
|
|
|
|
|
SkString c("");
|
2015-08-27 14:41:13 +00:00
|
|
|
|
SkString d(nullptr, 0);
|
2009-02-27 22:06:06 +00:00
|
|
|
|
|
|
|
|
|
REPORTER_ASSERT(reporter, a.isEmpty());
|
|
|
|
|
REPORTER_ASSERT(reporter, a == b && a == c && a == d);
|
|
|
|
|
|
|
|
|
|
a.set("hello");
|
|
|
|
|
b.set("hellox", 5);
|
|
|
|
|
c.set(a);
|
|
|
|
|
d.resize(5);
|
|
|
|
|
memcpy(d.writable_str(), "helloz", 5);
|
|
|
|
|
|
|
|
|
|
REPORTER_ASSERT(reporter, !a.isEmpty());
|
|
|
|
|
REPORTER_ASSERT(reporter, a.size() == 5);
|
|
|
|
|
REPORTER_ASSERT(reporter, a == b && a == c && a == d);
|
|
|
|
|
REPORTER_ASSERT(reporter, a.equals("hello", 5));
|
|
|
|
|
REPORTER_ASSERT(reporter, a.equals("hello"));
|
|
|
|
|
REPORTER_ASSERT(reporter, !a.equals("help"));
|
|
|
|
|
|
2012-04-27 17:11:31 +00:00
|
|
|
|
REPORTER_ASSERT(reporter, a.startsWith("hell"));
|
2012-10-29 16:42:11 +00:00
|
|
|
|
REPORTER_ASSERT(reporter, a.startsWith('h'));
|
2012-04-27 17:11:31 +00:00
|
|
|
|
REPORTER_ASSERT(reporter, !a.startsWith( "ell"));
|
2012-10-29 16:42:11 +00:00
|
|
|
|
REPORTER_ASSERT(reporter, !a.startsWith( 'e'));
|
2012-04-27 17:11:31 +00:00
|
|
|
|
REPORTER_ASSERT(reporter, a.startsWith(""));
|
|
|
|
|
REPORTER_ASSERT(reporter, a.endsWith("llo"));
|
2012-10-29 16:42:11 +00:00
|
|
|
|
REPORTER_ASSERT(reporter, a.endsWith('o'));
|
2012-04-27 17:11:31 +00:00
|
|
|
|
REPORTER_ASSERT(reporter, !a.endsWith("ll" ));
|
2012-10-29 16:42:11 +00:00
|
|
|
|
REPORTER_ASSERT(reporter, !a.endsWith('l'));
|
2012-04-27 17:11:31 +00:00
|
|
|
|
REPORTER_ASSERT(reporter, a.endsWith(""));
|
|
|
|
|
REPORTER_ASSERT(reporter, a.contains("he"));
|
|
|
|
|
REPORTER_ASSERT(reporter, a.contains("ll"));
|
|
|
|
|
REPORTER_ASSERT(reporter, a.contains("lo"));
|
|
|
|
|
REPORTER_ASSERT(reporter, a.contains("hello"));
|
|
|
|
|
REPORTER_ASSERT(reporter, !a.contains("hellohello"));
|
|
|
|
|
REPORTER_ASSERT(reporter, a.contains(""));
|
2012-10-29 16:42:11 +00:00
|
|
|
|
REPORTER_ASSERT(reporter, a.contains('e'));
|
|
|
|
|
REPORTER_ASSERT(reporter, !a.contains('z'));
|
2012-08-23 18:14:13 +00:00
|
|
|
|
|
2009-02-27 22:06:06 +00:00
|
|
|
|
SkString e(a);
|
|
|
|
|
SkString f("hello");
|
|
|
|
|
SkString g("helloz", 5);
|
|
|
|
|
|
|
|
|
|
REPORTER_ASSERT(reporter, a == e && a == f && a == g);
|
|
|
|
|
|
|
|
|
|
b.set("world");
|
|
|
|
|
c = b;
|
|
|
|
|
REPORTER_ASSERT(reporter, a != b && a != c && b == c);
|
|
|
|
|
|
|
|
|
|
a.append(" world");
|
|
|
|
|
e.append("worldz", 5);
|
|
|
|
|
e.insert(5, " ");
|
|
|
|
|
f.set("world");
|
|
|
|
|
f.prepend("hello ");
|
|
|
|
|
REPORTER_ASSERT(reporter, a.equals("hello world") && a == e && a == f);
|
|
|
|
|
|
|
|
|
|
a.reset();
|
|
|
|
|
b.resize(0);
|
|
|
|
|
REPORTER_ASSERT(reporter, a.isEmpty() && b.isEmpty() && a == b);
|
|
|
|
|
|
|
|
|
|
a.set("a");
|
|
|
|
|
a.set("ab");
|
|
|
|
|
a.set("abc");
|
|
|
|
|
a.set("abcd");
|
2010-10-12 23:08:13 +00:00
|
|
|
|
|
|
|
|
|
a.set("");
|
2013-06-19 18:27:20 +00:00
|
|
|
|
a.appendS32(0x7FFFFFFFL);
|
|
|
|
|
REPORTER_ASSERT(reporter, a.equals("2147483647"));
|
|
|
|
|
a.set("");
|
|
|
|
|
a.appendS32(0x80000001L);
|
|
|
|
|
REPORTER_ASSERT(reporter, a.equals("-2147483647"));
|
|
|
|
|
a.set("");
|
|
|
|
|
a.appendS32(0x80000000L);
|
|
|
|
|
REPORTER_ASSERT(reporter, a.equals("-2147483648"));
|
2010-10-12 23:08:13 +00:00
|
|
|
|
|
|
|
|
|
a.set("");
|
2013-06-19 18:27:20 +00:00
|
|
|
|
a.appendU32(0x7FFFFFFFUL);
|
|
|
|
|
REPORTER_ASSERT(reporter, a.equals("2147483647"));
|
|
|
|
|
a.set("");
|
|
|
|
|
a.appendU32(0x80000001UL);
|
|
|
|
|
REPORTER_ASSERT(reporter, a.equals("2147483649"));
|
|
|
|
|
a.set("");
|
|
|
|
|
a.appendU32(0xFFFFFFFFUL);
|
|
|
|
|
REPORTER_ASSERT(reporter, a.equals("4294967295"));
|
2010-10-12 23:08:13 +00:00
|
|
|
|
|
|
|
|
|
a.set("");
|
2013-06-19 18:27:20 +00:00
|
|
|
|
a.appendS64(0x7FFFFFFFFFFFFFFFLL, 0);
|
|
|
|
|
REPORTER_ASSERT(reporter, a.equals("9223372036854775807"));
|
|
|
|
|
a.set("");
|
|
|
|
|
a.appendS64(0x8000000000000001LL, 0);
|
|
|
|
|
REPORTER_ASSERT(reporter, a.equals("-9223372036854775807"));
|
|
|
|
|
a.set("");
|
|
|
|
|
a.appendS64(0x8000000000000000LL, 0);
|
|
|
|
|
REPORTER_ASSERT(reporter, a.equals("-9223372036854775808"));
|
|
|
|
|
a.set("");
|
|
|
|
|
a.appendS64(0x0000000001000000LL, 15);
|
|
|
|
|
REPORTER_ASSERT(reporter, a.equals("000000016777216"));
|
|
|
|
|
a.set("");
|
|
|
|
|
a.appendS64(0xFFFFFFFFFF000000LL, 15);
|
|
|
|
|
REPORTER_ASSERT(reporter, a.equals("-000000016777216"));
|
2010-10-12 23:08:13 +00:00
|
|
|
|
|
|
|
|
|
a.set("");
|
2013-06-19 18:27:20 +00:00
|
|
|
|
a.appendU64(0x7FFFFFFFFFFFFFFFULL, 0);
|
|
|
|
|
REPORTER_ASSERT(reporter, a.equals("9223372036854775807"));
|
|
|
|
|
a.set("");
|
|
|
|
|
a.appendU64(0x8000000000000001ULL, 0);
|
|
|
|
|
REPORTER_ASSERT(reporter, a.equals("9223372036854775809"));
|
|
|
|
|
a.set("");
|
|
|
|
|
a.appendU64(0xFFFFFFFFFFFFFFFFULL, 0);
|
|
|
|
|
REPORTER_ASSERT(reporter, a.equals("18446744073709551615"));
|
|
|
|
|
a.set("");
|
|
|
|
|
a.appendU64(0x0000000001000000ULL, 15);
|
|
|
|
|
REPORTER_ASSERT(reporter, a.equals("000000016777216"));
|
2011-02-28 21:29:58 +00:00
|
|
|
|
|
2016-04-25 16:25:35 +00:00
|
|
|
|
a.printf("%i", 0);
|
|
|
|
|
REPORTER_ASSERT(reporter, a.equals("0"));
|
|
|
|
|
a.printf("%g", 3.14);
|
|
|
|
|
REPORTER_ASSERT(reporter, a.equals("3.14"));
|
|
|
|
|
a.printf("hello %s", "skia");
|
|
|
|
|
REPORTER_ASSERT(reporter, a.equals("hello skia"));
|
|
|
|
|
|
2011-02-28 21:29:58 +00:00
|
|
|
|
static const struct {
|
|
|
|
|
SkScalar fValue;
|
|
|
|
|
const char* fString;
|
|
|
|
|
} gRec[] = {
|
|
|
|
|
{ 0, "0" },
|
|
|
|
|
{ SK_Scalar1, "1" },
|
|
|
|
|
{ -SK_Scalar1, "-1" },
|
|
|
|
|
{ SK_Scalar1/2, "0.5" },
|
2015-09-22 18:43:53 +00:00
|
|
|
|
#if defined(SK_BUILD_FOR_WIN) && (_MSC_VER < 1900)
|
2011-07-08 17:49:22 +00:00
|
|
|
|
{ 3.4028234e38f, "3.4028235e+038" },
|
|
|
|
|
{ -3.4028234e38f, "-3.4028235e+038" },
|
|
|
|
|
#else
|
2011-03-01 15:44:08 +00:00
|
|
|
|
{ 3.4028234e38f, "3.4028235e+38" },
|
|
|
|
|
{ -3.4028234e38f, "-3.4028235e+38" },
|
2011-07-08 17:49:22 +00:00
|
|
|
|
#endif
|
2011-02-28 21:29:58 +00:00
|
|
|
|
};
|
|
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) {
|
|
|
|
|
a.reset();
|
|
|
|
|
a.appendScalar(gRec[i].fValue);
|
2020-07-28 13:23:54 +00:00
|
|
|
|
REPORTER_ASSERT(reporter, a.size() <= kSkStrAppendScalar_MaxSize);
|
2015-08-07 00:56:13 +00:00
|
|
|
|
if (!a.equals(gRec[i].fString)) {
|
|
|
|
|
ERRORF(reporter, "received <%s> expected <%s>\n", a.c_str(), gRec[i].fString);
|
|
|
|
|
}
|
2011-02-28 21:29:58 +00:00
|
|
|
|
}
|
2011-06-30 14:39:52 +00:00
|
|
|
|
|
|
|
|
|
REPORTER_ASSERT(reporter, SkStringPrintf("%i", 0).equals("0"));
|
2020-06-18 19:49:38 +00:00
|
|
|
|
}
|
2011-07-08 17:49:22 +00:00
|
|
|
|
|
2020-06-18 19:49:38 +00:00
|
|
|
|
static void assert_2000_spaces(skiatest::Reporter* reporter, const SkString& str) {
|
|
|
|
|
REPORTER_ASSERT(reporter, str.size() == 2000);
|
|
|
|
|
for (size_t i = 0; i < str.size(); ++i) {
|
|
|
|
|
REPORTER_ASSERT(reporter, str[i] == ' ');
|
2016-04-25 16:25:35 +00:00
|
|
|
|
}
|
2020-06-18 19:49:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DEF_TEST(String_overflow, reporter) {
|
|
|
|
|
// 2000 is larger than the static buffer size inside SkString.cpp
|
|
|
|
|
SkString a = SkStringPrintf("%2000s", " ");
|
|
|
|
|
assert_2000_spaces(reporter, a);
|
|
|
|
|
|
|
|
|
|
a = "X";
|
2016-04-25 16:25:35 +00:00
|
|
|
|
a.printf("%2000s", " ");
|
2020-06-18 19:49:38 +00:00
|
|
|
|
assert_2000_spaces(reporter, a);
|
|
|
|
|
|
|
|
|
|
a = "X";
|
|
|
|
|
a.appendf("%1999s", " ");
|
|
|
|
|
REPORTER_ASSERT(reporter, a[0] == 'X');
|
|
|
|
|
a[0] = ' ';
|
|
|
|
|
assert_2000_spaces(reporter, a);
|
|
|
|
|
|
|
|
|
|
a = "X";
|
|
|
|
|
a.prependf("%1999s", " ");
|
|
|
|
|
REPORTER_ASSERT(reporter, a[1999] == 'X');
|
|
|
|
|
a[1999] = ' ';
|
|
|
|
|
assert_2000_spaces(reporter, a);
|
2009-02-27 22:06:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-02 13:50:38 +00:00
|
|
|
|
DEF_TEST(String_SkStrSplit, r) {
|
|
|
|
|
SkTArray<SkString> results;
|
|
|
|
|
|
|
|
|
|
SkStrSplit("a-_b_c-dee--f-_-_-g-", "-_", &results);
|
|
|
|
|
REPORTER_ASSERT(r, results.count() == 6);
|
|
|
|
|
REPORTER_ASSERT(r, results[0].equals("a"));
|
|
|
|
|
REPORTER_ASSERT(r, results[1].equals("b"));
|
|
|
|
|
REPORTER_ASSERT(r, results[2].equals("c"));
|
|
|
|
|
REPORTER_ASSERT(r, results[3].equals("dee"));
|
|
|
|
|
REPORTER_ASSERT(r, results[4].equals("f"));
|
|
|
|
|
REPORTER_ASSERT(r, results[5].equals("g"));
|
2015-09-22 18:43:53 +00:00
|
|
|
|
|
|
|
|
|
results.reset();
|
|
|
|
|
SkStrSplit("\n", "\n", &results);
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
|
REPORTER_ASSERT(r, results.count() == 0);
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Review URL: https://codereview.chromium.org/1490113005
2015-12-22 07:48:13 +00:00
|
|
|
|
|
|
|
|
|
results.reset();
|
Revert of Add config options to run different GPU APIs to dm and nanobench (patchset #21 id:400001 of https://codereview.chromium.org/1490113005/ )
Reason for revert:
The Test-Win8-MSVC-ShuttleB-GPU-HD4600-x86_64-Debug builder fails after this CL.
Links to specific builds:
http://build.chromium.org/p/client.skia/builders/Test-Win8-MSVC-ShuttleB-GPU-HD4600-x86_64-Debug/builds/1689
http://build.chromium.org/p/client.skia/builders/Test-Win8-MSVC-ShuttleB-GPU-HD4600-x86_64-Debug/builds/1690
http://build.chromium.org/p/client.skia/builders/Test-Win8-MSVC-ShuttleB-GPU-HD4600-x86_64-Debug/builds/1691
Original issue's description:
> Add config options to run different GPU APIs to dm and nanobench
>
> Add extended config specification form that can be used to run different
> gpu backend with different APIs.
>
> The configs can be specified with the form:
> gpu(api=string,dit=bool,nvpr=bool,samples=int)
>
> This replaces and removes the --gpuAPI flag.
>
> All existing configs should still work.
>
> Adds following documentation:
>
> out/Debug/dm --help config
>
> Flags:
> --config: type: string default: 565 8888 gpu nonrendering
> Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
> nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
> xps or use extended form 'backend(option=value,...)'.
>
> Extended form: 'backend(option=value,...)'
>
> Possible backends and options:
>
> gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
> api type: string default: native.
> Select graphics API to use with gpu backend.
> Options:
> native Use platform default OpenGL or OpenGL ES backend.
> gl Use OpenGL.
> gles Use OpenGL ES.
> debug Use debug OpenGL.
> null Use null OpenGL.
> dit type: bool default: false.
> Use device independent text.
> nvpr type: bool default: false.
> Use NV_path_rendering OpenGL and OpenGL ES extension.
> samples type: int default: 0.
> Use multisampling with N samples.
>
> Predefined configs:
>
> gpu = gpu()
> msaa4 = gpu(samples=4)
> msaa16 = gpu(samples=16)
> nvprmsaa4 = gpu(nvpr=true,samples=4)
> nvprmsaa16 = gpu(nvpr=true,samples=16)
> gpudft = gpu(dit=true)
> gpudebug = gpu(api=debug)
> gpunull = gpu(api=null)
> debug = gpu(api=debug)
> nullgpu = gpu(api=null)
>
> BUG=skia:2992
>
> Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
>
> Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
>
> Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
TBR=mtklein@google.com,bsalomon@google.com,joshualitt@google.com,scroggo@google.com,kkinnunen@nvidia.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:2992
Review URL: https://codereview.chromium.org/1548683002
2015-12-22 18:22:26 +00:00
|
|
|
|
SkStrSplit("", "\n", &results);
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Review URL: https://codereview.chromium.org/1490113005
2015-12-22 07:48:13 +00:00
|
|
|
|
REPORTER_ASSERT(r, results.count() == 0);
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
|
|
|
|
|
|
results.reset();
|
|
|
|
|
SkStrSplit("a", "\n", &results);
|
|
|
|
|
REPORTER_ASSERT(r, results.count() == 1);
|
|
|
|
|
REPORTER_ASSERT(r, results[0].equals("a"));
|
|
|
|
|
}
|
|
|
|
|
DEF_TEST(String_SkStrSplit_All, r) {
|
|
|
|
|
SkTArray<SkString> results;
|
|
|
|
|
SkStrSplit("a-_b_c-dee--f-_-_-g-", "-_", kStrict_SkStrSplitMode, &results);
|
|
|
|
|
REPORTER_ASSERT(r, results.count() == 13);
|
|
|
|
|
REPORTER_ASSERT(r, results[0].equals("a"));
|
|
|
|
|
REPORTER_ASSERT(r, results[1].equals(""));
|
|
|
|
|
REPORTER_ASSERT(r, results[2].equals("b"));
|
|
|
|
|
REPORTER_ASSERT(r, results[3].equals("c"));
|
|
|
|
|
REPORTER_ASSERT(r, results[4].equals("dee"));
|
|
|
|
|
REPORTER_ASSERT(r, results[5].equals(""));
|
|
|
|
|
REPORTER_ASSERT(r, results[6].equals("f"));
|
|
|
|
|
REPORTER_ASSERT(r, results[7].equals(""));
|
|
|
|
|
REPORTER_ASSERT(r, results[8].equals(""));
|
|
|
|
|
REPORTER_ASSERT(r, results[9].equals(""));
|
|
|
|
|
REPORTER_ASSERT(r, results[10].equals(""));
|
|
|
|
|
REPORTER_ASSERT(r, results[11].equals("g"));
|
|
|
|
|
REPORTER_ASSERT(r, results[12].equals(""));
|
|
|
|
|
|
|
|
|
|
results.reset();
|
|
|
|
|
SkStrSplit("\n", "\n", kStrict_SkStrSplitMode, &results);
|
|
|
|
|
REPORTER_ASSERT(r, results.count() == 2);
|
|
|
|
|
REPORTER_ASSERT(r, results[0].equals(""));
|
|
|
|
|
REPORTER_ASSERT(r, results[1].equals(""));
|
|
|
|
|
|
|
|
|
|
results.reset();
|
|
|
|
|
SkStrSplit("", "\n", kStrict_SkStrSplitMode, &results);
|
|
|
|
|
REPORTER_ASSERT(r, results.count() == 0);
|
|
|
|
|
|
|
|
|
|
results.reset();
|
|
|
|
|
SkStrSplit("a", "\n", kStrict_SkStrSplitMode, &results);
|
|
|
|
|
REPORTER_ASSERT(r, results.count() == 1);
|
|
|
|
|
REPORTER_ASSERT(r, results[0].equals("a"));
|
|
|
|
|
|
|
|
|
|
results.reset();
|
|
|
|
|
SkStrSplit(",,", ",", kStrict_SkStrSplitMode, &results);
|
|
|
|
|
REPORTER_ASSERT(r, results.count() == 3);
|
|
|
|
|
REPORTER_ASSERT(r, results[0].equals(""));
|
|
|
|
|
REPORTER_ASSERT(r, results[1].equals(""));
|
|
|
|
|
REPORTER_ASSERT(r, results[2].equals(""));
|
|
|
|
|
|
|
|
|
|
results.reset();
|
|
|
|
|
SkStrSplit(",a,b,", ",", kStrict_SkStrSplitMode, &results);
|
|
|
|
|
REPORTER_ASSERT(r, results.count() == 4);
|
|
|
|
|
REPORTER_ASSERT(r, results[0].equals(""));
|
|
|
|
|
REPORTER_ASSERT(r, results[1].equals("a"));
|
|
|
|
|
REPORTER_ASSERT(r, results[2].equals("b"));
|
|
|
|
|
REPORTER_ASSERT(r, results[3].equals(""));
|
2013-12-02 13:50:38 +00:00
|
|
|
|
}
|
2017-10-03 15:08:14 +00:00
|
|
|
|
|
|
|
|
|
// https://bugs.chromium.org/p/skia/issues/detail?id=7107
|
|
|
|
|
DEF_TEST(String_Threaded, r) {
|
2017-10-30 15:57:15 +00:00
|
|
|
|
SkString str("foo");
|
|
|
|
|
|
|
|
|
|
std::thread threads[5];
|
|
|
|
|
for (auto& thread : threads) {
|
|
|
|
|
thread = std::thread([&] {
|
2020-08-07 21:35:54 +00:00
|
|
|
|
SkString copy = str; // NOLINT(performance-unnecessary-copy-initialization)
|
2017-10-30 15:57:15 +00:00
|
|
|
|
(void)copy.equals("test");
|
|
|
|
|
});
|
2017-10-03 15:08:14 +00:00
|
|
|
|
}
|
2017-10-30 15:57:15 +00:00
|
|
|
|
for (auto& thread : threads) {
|
2017-10-03 15:08:14 +00:00
|
|
|
|
thread.join();
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-02-14 18:58:06 +00:00
|
|
|
|
|
|
|
|
|
// Ensure that the string allocate doesn't internally overflow any calculations, and accidentally
|
|
|
|
|
// let us create a string with a requested length longer than we can manage.
|
|
|
|
|
DEF_TEST(String_huge, r) {
|
|
|
|
|
// start testing slightly below max 32
|
Reland "Remove SK_MaxSizeT, SK_M{in|ax}U{16|32}, #defines."
This reverts commit ab17347df32807cabd9f2a518d22c3bd420e482f.
Reason for revert: Chromium should now be ok.
Original change's description:
> Revert "Remove SK_MaxSizeT, SK_M{in|ax}U{16|32}, #defines."
>
> This reverts commit e1bc7de7c07686b28b00b850e44e0722189f3592.
>
> Reason for revert: chrome used it
>
> Original change's description:
> > Remove SK_MaxSizeT, SK_M{in|ax}U{16|32}, #defines.
> >
> > sed 's/SK_MaxSizeT/SIZE_MAX/g'
> > sed 's/SK_MaxU32/UINT32_MAX/g'
> > sed 's/SK_MaxU16/UINT16_MAX/g'
> >
> > SK_MinU32 and SK_MinU16 were unused
> >
> > Change-Id: I6b6c824df47b05bde7e73b13a58e851a5f63fe0e
> > Reviewed-on: https://skia-review.googlesource.com/134607
> > Commit-Queue: Hal Canary <halcanary@google.com>
> > Reviewed-by: Ben Wagner <bungeman@google.com>
>
> TBR=halcanary@google.com,bungeman@google.com,reed@google.com
>
> Change-Id: I1e2c440dcf9f59bf87c1fea113248cd5136f7519
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/134921
> Reviewed-by: Hal Canary <halcanary@google.com>
> Commit-Queue: Hal Canary <halcanary@google.com>
CQ_INCLUDE_TRYBOTS=luci.chromium.try:linux-ozone-rel
TBR=halcanary@google.com,bungeman@google.com,reed@google.com
Change-Id: I7709f9715bea0463b85b5b0a89712ac1020fcddb
Reviewed-on: https://skia-review.googlesource.com/135180
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2018-06-15 15:37:57 +00:00
|
|
|
|
size_t size = UINT32_MAX - 16;
|
2018-02-14 18:58:06 +00:00
|
|
|
|
// See where we crash, and manually check that its at the right point.
|
|
|
|
|
//
|
|
|
|
|
// To test, change the false to true
|
|
|
|
|
while (false) {
|
|
|
|
|
// On a 64bit build, this should crash when size == 1 << 32, since we can't store
|
|
|
|
|
// that length in the string's header (which has a u32 slot for the length).
|
|
|
|
|
//
|
|
|
|
|
// On a 32bit build, this should crash the first time around, since we can't allocate
|
|
|
|
|
// anywhere near this amount.
|
|
|
|
|
//
|
|
|
|
|
SkString str(size);
|
|
|
|
|
size += 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-01 17:32:18 +00:00
|
|
|
|
DEF_TEST(String_fromUTF16, r) {
|
|
|
|
|
// test data produced with `iconv`.
|
|
|
|
|
const uint16_t test1[] = {
|
|
|
|
|
0xD835, 0xDCD0, 0xD835, 0xDCD1, 0xD835, 0xDCD2, 0xD835, 0xDCD3, 0xD835, 0xDCD4, 0x0020,
|
|
|
|
|
0xD835, 0xDCD5, 0xD835, 0xDCD6, 0xD835, 0xDCD7, 0xD835, 0xDCD8, 0xD835, 0xDCD9
|
|
|
|
|
};
|
2018-03-01 20:56:37 +00:00
|
|
|
|
REPORTER_ASSERT(r, SkStringFromUTF16(test1, SK_ARRAY_COUNT(test1)).equals("𝓐𝓑𝓒𝓓𝓔 𝓕𝓖𝓗𝓘𝓙"));
|
2018-03-01 17:32:18 +00:00
|
|
|
|
|
|
|
|
|
const uint16_t test2[] = {
|
|
|
|
|
0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0020, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A,
|
|
|
|
|
};
|
2018-03-01 20:56:37 +00:00
|
|
|
|
REPORTER_ASSERT(r, SkStringFromUTF16(test2, SK_ARRAY_COUNT(test2)).equals("ABCDE FGHIJ"));
|
2018-03-01 17:32:18 +00:00
|
|
|
|
|
|
|
|
|
const uint16_t test3[] = {
|
|
|
|
|
0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x0020, 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA,
|
|
|
|
|
};
|
2018-03-01 20:56:37 +00:00
|
|
|
|
REPORTER_ASSERT(r, SkStringFromUTF16(test3, SK_ARRAY_COUNT(test3)).equals("αβγδε ζηθικ"));
|
2018-03-01 17:32:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-06-18 19:49:38 +00:00
|
|
|
|
static void test_va_list_print(skiatest::Reporter* r, const char format[], ...) {
|
|
|
|
|
va_list args;
|
|
|
|
|
va_start(args, format);
|
|
|
|
|
|
|
|
|
|
SkString str("123");
|
|
|
|
|
str.printVAList(format, args);
|
|
|
|
|
REPORTER_ASSERT(r, str.equals("hello world"));
|
|
|
|
|
|
|
|
|
|
va_end(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void test_va_list_append(skiatest::Reporter* r, const char format[], ...) {
|
|
|
|
|
va_list args;
|
|
|
|
|
va_start(args, format);
|
|
|
|
|
|
|
|
|
|
SkString str("123");
|
|
|
|
|
str.appendVAList(format, args);
|
|
|
|
|
REPORTER_ASSERT(r, str.equals("123hello world"));
|
|
|
|
|
|
|
|
|
|
va_end(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void test_va_list_prepend(skiatest::Reporter* r, const char format[], ...) {
|
|
|
|
|
va_list args;
|
|
|
|
|
va_start(args, format);
|
|
|
|
|
|
|
|
|
|
SkString str("123");
|
|
|
|
|
str.prependVAList(format, args);
|
|
|
|
|
REPORTER_ASSERT(r, str.equals("hello world123"));
|
|
|
|
|
|
|
|
|
|
va_end(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DEF_TEST(String_VAList, r) {
|
|
|
|
|
test_va_list_print(r, "%s %c%c%c%c%c", "hello", 'w', 'o', 'r', 'l', 'd');
|
|
|
|
|
test_va_list_append(r, "%s %c%c%c%c%c", "hello", 'w', 'o', 'r', 'l', 'd');
|
|
|
|
|
test_va_list_prepend(r, "%s %c%c%c%c%c", "hello", 'w', 'o', 'r', 'l', 'd');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void test_va_list_overflow_print(skiatest::Reporter* r, const char format[], ...) {
|
|
|
|
|
va_list args;
|
|
|
|
|
va_start(args, format);
|
|
|
|
|
|
|
|
|
|
SkString str("X");
|
|
|
|
|
str.printVAList(format, args);
|
|
|
|
|
assert_2000_spaces(r, str);
|
|
|
|
|
|
|
|
|
|
va_end(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void test_va_list_overflow_append(skiatest::Reporter* r, const char format[], ...) {
|
|
|
|
|
va_list args;
|
|
|
|
|
va_start(args, format);
|
|
|
|
|
|
|
|
|
|
SkString str("X");
|
|
|
|
|
str.appendVAList(format, args);
|
|
|
|
|
REPORTER_ASSERT(r, str[0] == 'X');
|
|
|
|
|
str[0] = ' ';
|
|
|
|
|
assert_2000_spaces(r, str);
|
|
|
|
|
|
|
|
|
|
va_end(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void test_va_list_overflow_prepend(skiatest::Reporter* r, const char format[], ...) {
|
|
|
|
|
va_list args;
|
|
|
|
|
va_start(args, format);
|
|
|
|
|
|
|
|
|
|
SkString str("X");
|
|
|
|
|
str.prependVAList(format, args);
|
|
|
|
|
REPORTER_ASSERT(r, str[1999] == 'X');
|
|
|
|
|
str[1999] = ' ';
|
|
|
|
|
assert_2000_spaces(r, str);
|
|
|
|
|
|
|
|
|
|
va_end(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DEF_TEST(String_VAList_overflow, r) {
|
|
|
|
|
test_va_list_overflow_print(r, "%2000s", " ");
|
|
|
|
|
test_va_list_overflow_append(r, "%1999s", " ");
|
|
|
|
|
test_va_list_overflow_prepend(r, "%1999s", " ");
|
|
|
|
|
}
|
2020-06-22 21:54:05 +00:00
|
|
|
|
|
|
|
|
|
DEF_TEST(String_resize_to_nothing, r) {
|
|
|
|
|
SkString s("hello world!");
|
|
|
|
|
REPORTER_ASSERT(r, s.equals("hello world!"));
|
|
|
|
|
s.resize(0);
|
|
|
|
|
REPORTER_ASSERT(r, s.equals(""));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DEF_TEST(String_resize_shrink, r) {
|
|
|
|
|
SkString s("hello world!");
|
|
|
|
|
REPORTER_ASSERT(r, s.equals("hello world!"));
|
|
|
|
|
s.resize(5);
|
|
|
|
|
REPORTER_ASSERT(r, s.equals("hello"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DEF_TEST(String_resize_grow, r) {
|
|
|
|
|
SkString s("hello world!");
|
|
|
|
|
REPORTER_ASSERT(r, s.equals("hello world!"));
|
|
|
|
|
s.resize(25);
|
|
|
|
|
REPORTER_ASSERT(r, 0 == strcmp(s.c_str(), "hello world!")); // no promises about data past \0
|
|
|
|
|
REPORTER_ASSERT(r, s.size() == 25);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DEF_TEST(String_resize_after_assignment, r) {
|
|
|
|
|
SkString s("hello world!");
|
|
|
|
|
SkString t;
|
|
|
|
|
t = s;
|
|
|
|
|
REPORTER_ASSERT(r, s.equals("hello world!"));
|
|
|
|
|
s.resize(25);
|
|
|
|
|
REPORTER_ASSERT(r, 0 == strcmp(s.c_str(), "hello world!"));
|
|
|
|
|
REPORTER_ASSERT(r, s.size() == 25);
|
|
|
|
|
s.resize(5);
|
|
|
|
|
REPORTER_ASSERT(r, s.equals("hello"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void resize_helper_function(skiatest::Reporter* r, SkString s) {
|
|
|
|
|
REPORTER_ASSERT(r, s.equals("hello world!"));
|
|
|
|
|
s.resize(5);
|
|
|
|
|
REPORTER_ASSERT(r, s.equals("hello"));
|
|
|
|
|
s.resize(25);
|
|
|
|
|
REPORTER_ASSERT(r, 0 == strcmp(s.c_str(), "hello"));
|
|
|
|
|
REPORTER_ASSERT(r, s.size() == 25);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DEF_TEST(String_resize_after_copy_construction, r) {
|
|
|
|
|
SkString s("hello world!");
|
|
|
|
|
resize_helper_function(r, s);
|
|
|
|
|
}
|