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

Unified Diff: tests/GrGLSLPrettyPrintTest.cpp

Issue 929503002: Multi-string shaders (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: windows warning Created 5 years, 10 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
« no previous file with comments | « src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/GrGLSLPrettyPrintTest.cpp
diff --git a/tests/GrGLSLPrettyPrintTest.cpp b/tests/GrGLSLPrettyPrintTest.cpp
index 9977488d58f759a9f7b2c5f925d784fe81b8d278..827a27b4c519db2052d912a8cc9754bd34dda6df 100644
--- a/tests/GrGLSLPrettyPrintTest.cpp
+++ b/tests/GrGLSLPrettyPrintTest.cpp
@@ -13,12 +13,16 @@
const SkString input1("#this is not a realshader\nvec4 some stuff;outside of a function;"
"int i(int b, int c) { { some stuff;} fake block; //comments\n return i;}"
- "void main()"
- "{nowin a function;{indenting;{abit more;dreadedfor((;;)(;)((;;);)){doingstuff"
+ "void main()");
+const SkString input2("{nowin a function;{indenting;{abit more;dreadedfor((;;)(;)((;;);)){"
+ "doingstuff"
";for(;;;){and more stufff;mixed garbage\n\n\t\t\t\t\n/*using this"
- " comment\n is"
- " dangerous\ndo so at your own\n risk*/;\n\n\t\t\t\n"
- "//a comment\n}}a; little ; love; for ; leading; spaces;} "
+ " comment\n is");
+const SkString input3(" dangerous\ndo so at your own\n risk*/;\n\n\t\t\t\n"
+ "//a comment");
+const SkString input4("breaking in comment");
+const SkString input5("continuing the comment");
+const SkString input6("\n}}a; little ; love; for ; leading; spaces;} "
"an struct = { int a; int b; };"
"int[5] arr = int[5](1,2,3,4,5);} some code at the bottom; for(;;) {} }");
@@ -52,7 +56,7 @@ const SkString output1(
" 27\t\t\t\t\t\t is dangerous\n"
" 28\t\t\t\t\t\tdo so at your own\n"
" 29\t\t\t\t\t\t risk*/;\n"
- " 30\t\t\t\t\t\t//a comment\n"
+ " 30\t\t\t\t\t\t//a commentbreaking in commentcontinuing the comment\n"
" 31\t\t\t\t\t}\n"
" 32\t\t\t\t}\n"
" 33\t\t\t\ta;\n"
@@ -77,16 +81,43 @@ const SkString output1(
" 52\t}\n"
" 53\t");
-const SkString input2("{;;{{{{;;;{{{{{{{{{{{###\n##\n#####(((((((((((((unbalanced verything;;;"
- "}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}"
+const SkString neg1("{;;{{{{;;;{{{{{{{{{{{");
+const SkString neg2("###\n##\n#####(((((((((((((unbalanced verything;;;");
+const SkString neg3("}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}"
";;;;;;/////");
DEF_TEST(GrGLSLPrettyPrint, r) {
- SkString test = GrGLSLPrettyPrint::PrettyPrintGLSL(input1, true);
+ SkTArray<const char*> testStr;
+ SkTArray<int> lengths;
+ testStr.push_back(input1.c_str());
+ lengths.push_back((int)input1.size());
+ testStr.push_back(input2.c_str());
+ lengths.push_back((int)input2.size());
+ testStr.push_back(input3.c_str());
+ lengths.push_back((int)input3.size());
+ testStr.push_back(input4.c_str());
+ lengths.push_back((int)input4.size());
+ testStr.push_back(input5.c_str());
+ lengths.push_back((int)input5.size());
+ testStr.push_back(input6.c_str());
+ lengths.push_back((int)input6.size());
+
+ SkString test = GrGLSLPrettyPrint::PrettyPrintGLSL(testStr.begin(), lengths.begin(),
+ testStr.count(), true);
ASSERT(output1 == test);
+ testStr.reset();
+ lengths.reset();
+ testStr.push_back(neg1.c_str());
+ lengths.push_back((int)neg1.size());
+ testStr.push_back(neg2.c_str());
+ lengths.push_back((int)neg2.size());
+ testStr.push_back(neg3.c_str());
+ lengths.push_back((int)neg3.size());
+
// Just test we don't crash with garbage input
- ASSERT(GrGLSLPrettyPrint::PrettyPrintGLSL(input2, true).c_str() != NULL);
+ ASSERT(GrGLSLPrettyPrint::PrettyPrintGLSL(testStr.begin(), lengths.begin(), 1,
+ true).c_str() != NULL);
}
#endif
« no previous file with comments | « src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698