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

Unified Diff: gpu/command_buffer/common/gles2_cmd_utils_unittest.cc

Issue 10855274: Fix Uniform Name Parsing (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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 | « gpu/command_buffer/common/gles2_cmd_utils.cc ('k') | gpu/command_buffer/service/program_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/common/gles2_cmd_utils_unittest.cc
diff --git a/gpu/command_buffer/common/gles2_cmd_utils_unittest.cc b/gpu/command_buffer/common/gles2_cmd_utils_unittest.cc
index 97b5dba08e7c2fd161dfa0f0fd4a4604b3533e65..0bf11f07ce42c59909e13afe305e2cd211a9f644 100644
--- a/gpu/command_buffer/common/gles2_cmd_utils_unittest.cc
+++ b/gpu/command_buffer/common/gles2_cmd_utils_unittest.cc
@@ -181,6 +181,48 @@ TEST_F(GLES2UtilTest, RenderbufferBytesPerPixel) {
EXPECT_EQ(0u, GLES2Util::RenderbufferBytesPerPixel(-1));
}
+namespace {
+
+void CheckParseUniformName(
+ const char* name,
+ bool expected_success,
+ size_t expected_array_pos,
+ int expected_index,
+ bool expected_getting_array) {
+ int index = 1234;
+ size_t array_pos = 1244;
+ bool getting_array = false;
+ bool success = GLES2Util::ParseUniformName(
+ name, &array_pos, &index, &getting_array);
+ EXPECT_EQ(expected_success, success);
+ if (success) {
+ EXPECT_EQ(expected_array_pos, array_pos);
+ EXPECT_EQ(expected_index, index);
+ EXPECT_EQ(expected_getting_array, getting_array);
+ }
+}
+
+} // anonymous namespace
+
+TEST_F(GLES2UtilTest, ParseUniformName) {
+ CheckParseUniformName("u_name", true, std::string::npos, 0, false);
+ CheckParseUniformName("u_name[]", false, std::string::npos, 0, false);
+ CheckParseUniformName("u_name]", false, std::string::npos, 0, false);
+ CheckParseUniformName("u_name[0a]", false, std::string::npos, 0, false);
+ CheckParseUniformName("u_name[a0]", false, std::string::npos, 0, false);
+ CheckParseUniformName("u_name[0a0]", false, std::string::npos, 0, false);
+ CheckParseUniformName("u_name[0]", true, 6u, 0, true);
+ CheckParseUniformName("u_name[2]", true, 6u, 2, true);
+ CheckParseUniformName("u_name[02]", true, 6u, 2, true);
+ CheckParseUniformName("u_name[20]", true, 6u, 20, true);
+ CheckParseUniformName("u_name[020]", true, 6u, 20, true);
+ CheckParseUniformName("u_name[0][0]", true, 9u, 0, true);
+ CheckParseUniformName("u_name[3][2]", true, 9u, 2, true);
+ CheckParseUniformName("u_name[03][02]", true, 10u, 2, true);
+ CheckParseUniformName("u_name[30][20]", true, 10u, 20, true);
+ CheckParseUniformName("u_name[030][020]", true, 11u, 20, true);
+}
+
} // namespace gles2
} // namespace gpu
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils.cc ('k') | gpu/command_buffer/service/program_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698