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

Side by Side Diff: tests/GrGLSLPrettyPrintTest.cpp

Issue 924973002: Revert of Multi-string shaders (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #if SK_SUPPORT_GPU 8 #if SK_SUPPORT_GPU
9 #include "Test.h" 9 #include "Test.h"
10 #include "gl/GrGLSLPrettyPrint.h" 10 #include "gl/GrGLSLPrettyPrint.h"
11 11
12 #define ASSERT(x) REPORTER_ASSERT(r, x) 12 #define ASSERT(x) REPORTER_ASSERT(r, x)
13 13
14 const SkString input1("#this is not a realshader\nvec4 some stuff;outside of a f unction;" 14 const SkString input1("#this is not a realshader\nvec4 some stuff;outside of a f unction;"
15 "int i(int b, int c) { { some stuff;} fake block; //comment s\n return i;}" 15 "int i(int b, int c) { { some stuff;} fake block; //comment s\n return i;}"
16 "void main()"); 16 "void main()"
17 const SkString input2("{nowin a function;{indenting;{abit more;dreadedfor((;;)(; )((;;);)){" 17 "{nowin a function;{indenting;{abit more;dreadedfor((;;)(;) ((;;);)){doingstuff"
18 "doingstuff"
19 ";for(;;;){and more stufff;mixed garbage\n\n\t\t\t\t\n/*usi ng this" 18 ";for(;;;){and more stufff;mixed garbage\n\n\t\t\t\t\n/*usi ng this"
20 " comment\n is"); 19 " comment\n is"
21 const SkString input3(" dangerous\ndo so at your own\n risk*/;\n\n\t\t\t\n" 20 " dangerous\ndo so at your own\n risk*/;\n\n\t\t\t\n"
22 "//a comment"); 21 "//a comment\n}}a; little ; love; for ; leading; spaces ;} "
23 const SkString input4("breaking in comment");
24 const SkString input5("continuing the comment");
25 const SkString input6("\n}}a; little ; love; for ; leading; spaces;} "
26 "an struct = { int a; int b; };" 22 "an struct = { int a; int b; };"
27 "int[5] arr = int[5](1,2,3,4,5);} some code at the bottom; for(;;) {} }"); 23 "int[5] arr = int[5](1,2,3,4,5);} some code at the bottom; for(;;) {} }");
28 24
29 const SkString output1( 25 const SkString output1(
30 " 1\t#this is not a realshader\n" 26 " 1\t#this is not a realshader\n"
31 " 2\tvec4 some stuff;\n" 27 " 2\tvec4 some stuff;\n"
32 " 3\toutside of a function;\n" 28 " 3\toutside of a function;\n"
33 " 4\tint i(int b, int c) \n" 29 " 4\tint i(int b, int c) \n"
34 " 5\t{\n" 30 " 5\t{\n"
35 " 6\t\t{\n" 31 " 6\t\t{\n"
(...skipping 13 matching lines...) Expand all
49 " 20\t\t\t\tdreadedfor((;;)(;)((;;);))\n" 45 " 20\t\t\t\tdreadedfor((;;)(;)((;;);))\n"
50 " 21\t\t\t\t{\n" 46 " 21\t\t\t\t{\n"
51 " 22\t\t\t\t\tdoingstuff;\n" 47 " 22\t\t\t\t\tdoingstuff;\n"
52 " 23\t\t\t\t\tfor(;;;)\n" 48 " 23\t\t\t\t\tfor(;;;)\n"
53 " 24\t\t\t\t\t{\n" 49 " 24\t\t\t\t\t{\n"
54 " 25\t\t\t\t\t\tand more stufff;\n" 50 " 25\t\t\t\t\t\tand more stufff;\n"
55 " 26\t\t\t\t\t\tmixed garbage/*using this comment\n" 51 " 26\t\t\t\t\t\tmixed garbage/*using this comment\n"
56 " 27\t\t\t\t\t\t is dangerous\n" 52 " 27\t\t\t\t\t\t is dangerous\n"
57 " 28\t\t\t\t\t\tdo so at your own\n" 53 " 28\t\t\t\t\t\tdo so at your own\n"
58 " 29\t\t\t\t\t\t risk*/;\n" 54 " 29\t\t\t\t\t\t risk*/;\n"
59 " 30\t\t\t\t\t\t//a commentbreaking in commentcontinuing the comment\n" 55 " 30\t\t\t\t\t\t//a comment\n"
60 " 31\t\t\t\t\t}\n" 56 " 31\t\t\t\t\t}\n"
61 " 32\t\t\t\t}\n" 57 " 32\t\t\t\t}\n"
62 " 33\t\t\t\ta;\n" 58 " 33\t\t\t\ta;\n"
63 " 34\t\t\t\tlittle ;\n" 59 " 34\t\t\t\tlittle ;\n"
64 " 35\t\t\t\tlove;\n" 60 " 35\t\t\t\tlove;\n"
65 " 36\t\t\t\tfor ;\n" 61 " 36\t\t\t\tfor ;\n"
66 " 37\t\t\t\tleading;\n" 62 " 37\t\t\t\tleading;\n"
67 " 38\t\t\t\tspaces;\n" 63 " 38\t\t\t\tspaces;\n"
68 " 39\t\t\t}\n" 64 " 39\t\t\t}\n"
69 " 40\t\t\tan struct = \n" 65 " 40\t\t\tan struct = \n"
70 " 41\t\t\t{\n" 66 " 41\t\t\t{\n"
71 " 42\t\t\t\tint a;\n" 67 " 42\t\t\t\tint a;\n"
72 " 43\t\t\t\tint b;\n" 68 " 43\t\t\t\tint b;\n"
73 " 44\t\t\t}\n" 69 " 44\t\t\t}\n"
74 " 45\t\t\t;\n" 70 " 45\t\t\t;\n"
75 " 46\t\t\tint[5] arr = int[5](1,2,3,4,5);\n" 71 " 46\t\t\tint[5] arr = int[5](1,2,3,4,5);\n"
76 " 47\t\t}\n" 72 " 47\t\t}\n"
77 " 48\t\tsome code at the bottom;\n" 73 " 48\t\tsome code at the bottom;\n"
78 " 49\t\tfor(;;) \n" 74 " 49\t\tfor(;;) \n"
79 " 50\t\t{\n" 75 " 50\t\t{\n"
80 " 51\t\t}\n" 76 " 51\t\t}\n"
81 " 52\t}\n" 77 " 52\t}\n"
82 " 53\t"); 78 " 53\t");
83 79
84 const SkString neg1("{;;{{{{;;;{{{{{{{{{{{"); 80 const SkString input2("{;;{{{{;;;{{{{{{{{{{{###\n##\n#####(((((((((((((unbalance d verything;;;"
85 const SkString neg2("###\n##\n#####(((((((((((((unbalanced verything;;;"); 81 "}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}"
86 const SkString neg3("}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}"
87 ";;;;;;/////"); 82 ";;;;;;/////");
88 83
89 DEF_TEST(GrGLSLPrettyPrint, r) { 84 DEF_TEST(GrGLSLPrettyPrint, r) {
90 SkTArray<const char*> testStr; 85 SkString test = GrGLSLPrettyPrint::PrettyPrintGLSL(input1, true);
91 SkTArray<int> lengths;
92 testStr.push_back(input1.c_str());
93 lengths.push_back(input1.size());
94 testStr.push_back(input2.c_str());
95 lengths.push_back(input2.size());
96 testStr.push_back(input3.c_str());
97 lengths.push_back(input3.size());
98 testStr.push_back(input4.c_str());
99 lengths.push_back(input4.size());
100 testStr.push_back(input5.c_str());
101 lengths.push_back(input5.size());
102 testStr.push_back(input6.c_str());
103 lengths.push_back(input6.size());
104
105 SkString test = GrGLSLPrettyPrint::PrettyPrintGLSL(testStr.begin(), lengths. begin(),
106 testStr.count(), true);
107 ASSERT(output1 == test); 86 ASSERT(output1 == test);
108 87
109 testStr.reset();
110 lengths.reset();
111 testStr.push_back(neg1.c_str());
112 lengths.push_back(neg1.size());
113 testStr.push_back(neg2.c_str());
114 lengths.push_back(neg2.size());
115 testStr.push_back(neg3.c_str());
116 lengths.push_back(neg3.size());
117
118 // Just test we don't crash with garbage input 88 // Just test we don't crash with garbage input
119 ASSERT(GrGLSLPrettyPrint::PrettyPrintGLSL(testStr.begin(), lengths.begin(), 1, 89 ASSERT(GrGLSLPrettyPrint::PrettyPrintGLSL(input2, true).c_str() != NULL);
120 true).c_str() != NULL);
121 } 90 }
122 91
123 #endif 92 #endif
OLDNEW
« 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