[waffle] [PATCH 2/4] core: Add unittests for negative integral waffle_config attributes

Chad Versace chad.versace at linux.intel.com
Tue Sep 25 16:48:49 PDT 2012


This patch adds unittests for the previous commit. All tests pass.

Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
 src/waffle/core/wcore_config_attrs_unittest.c | 105 ++++++++++++++++++++++++++
 1 file changed, 105 insertions(+)

diff --git a/src/waffle/core/wcore_config_attrs_unittest.c b/src/waffle/core/wcore_config_attrs_unittest.c
index 3614c1c..f9cb866 100644
--- a/src/waffle/core/wcore_config_attrs_unittest.c
+++ b/src/waffle/core/wcore_config_attrs_unittest.c
@@ -188,6 +188,104 @@ TEST(wcore_config_attrs, core_profile_and_accum_buffer)
     EXPECT_TRUE(wcore_error_get_code() == WAFFLE_ERROR_BAD_ATTRIBUTE);
 }
 
+TEST(wcore_config_attrs, negative_red)
+{
+    const int32_t attrib_list[] = {
+        WAFFLE_CONTEXT_API,       WAFFLE_CONTEXT_OPENGL,
+        WAFFLE_RED_SIZE,          -2,
+        0,
+    };
+
+    ASSERT_TRUE(!wcore_config_attrs_parse(attrib_list, &actual_attrs));
+    EXPECT_TRUE(wcore_error_get_code() == WAFFLE_ERROR_BAD_ATTRIBUTE);
+    EXPECT_TRUE(strstr(wcore_error_get_info()->message, "WAFFLE_RED_SIZE"));
+    EXPECT_TRUE(strstr(wcore_error_get_info()->message, "-2"));
+}
+
+TEST(wcore_config_attrs, negative_green)
+{
+    const int32_t attrib_list[] = {
+        WAFFLE_CONTEXT_API,       WAFFLE_CONTEXT_OPENGL,
+        WAFFLE_GREEN_SIZE,        -2,
+        0,
+    };
+
+    ASSERT_TRUE(!wcore_config_attrs_parse(attrib_list, &actual_attrs));
+    EXPECT_TRUE(wcore_error_get_code() == WAFFLE_ERROR_BAD_ATTRIBUTE);
+    EXPECT_TRUE(strstr(wcore_error_get_info()->message, "WAFFLE_GREEN_SIZE"));
+    EXPECT_TRUE(strstr(wcore_error_get_info()->message, "-2"));
+}
+
+TEST(wcore_config_attrs, negative_blue)
+{
+    const int32_t attrib_list[] = {
+        WAFFLE_CONTEXT_API,       WAFFLE_CONTEXT_OPENGL,
+        WAFFLE_BLUE_SIZE,         -2,
+        0,
+    };
+
+    ASSERT_TRUE(!wcore_config_attrs_parse(attrib_list, &actual_attrs));
+    EXPECT_TRUE(wcore_error_get_code() == WAFFLE_ERROR_BAD_ATTRIBUTE);
+    EXPECT_TRUE(strstr(wcore_error_get_info()->message, "WAFFLE_BLUE_SIZE"));
+    EXPECT_TRUE(strstr(wcore_error_get_info()->message, "-2"));
+}
+
+TEST(wcore_config_attrs, negative_alpha)
+{
+    const int32_t attrib_list[] = {
+        WAFFLE_CONTEXT_API,       WAFFLE_CONTEXT_OPENGL,
+        WAFFLE_ALPHA_SIZE,        -2,
+        0,
+    };
+
+    ASSERT_TRUE(!wcore_config_attrs_parse(attrib_list, &actual_attrs));
+    EXPECT_TRUE(wcore_error_get_code() == WAFFLE_ERROR_BAD_ATTRIBUTE);
+    EXPECT_TRUE(strstr(wcore_error_get_info()->message, "WAFFLE_ALPHA_SIZE"));
+    EXPECT_TRUE(strstr(wcore_error_get_info()->message, "-2"));
+}
+
+TEST(wcore_config_attrs, negative_depth)
+{
+    const int32_t attrib_list[] = {
+        WAFFLE_CONTEXT_API,       WAFFLE_CONTEXT_OPENGL,
+        WAFFLE_DEPTH_SIZE,        -2,
+        0,
+    };
+
+    ASSERT_TRUE(!wcore_config_attrs_parse(attrib_list, &actual_attrs));
+    EXPECT_TRUE(wcore_error_get_code() == WAFFLE_ERROR_BAD_ATTRIBUTE);
+    EXPECT_TRUE(strstr(wcore_error_get_info()->message, "WAFFLE_DEPTH_SIZE"));
+    EXPECT_TRUE(strstr(wcore_error_get_info()->message, "-2"));
+}
+
+TEST(wcore_config_attrs, negative_stencil)
+{
+    const int32_t attrib_list[] = {
+        WAFFLE_CONTEXT_API,       WAFFLE_CONTEXT_OPENGL,
+        WAFFLE_STENCIL_SIZE,      -2,
+        0,
+    };
+
+    ASSERT_TRUE(!wcore_config_attrs_parse(attrib_list, &actual_attrs));
+    EXPECT_TRUE(wcore_error_get_code() == WAFFLE_ERROR_BAD_ATTRIBUTE);
+    EXPECT_TRUE(strstr(wcore_error_get_info()->message, "WAFFLE_STENCIL_SIZE"));
+    EXPECT_TRUE(strstr(wcore_error_get_info()->message, "-2"));
+}
+
+TEST(wcore_config_attrs, negative_samples)
+{
+    const int32_t attrib_list[] = {
+        WAFFLE_CONTEXT_API,       WAFFLE_CONTEXT_OPENGL,
+        WAFFLE_SAMPLES,           -2,
+        0,
+    };
+
+    ASSERT_TRUE(!wcore_config_attrs_parse(attrib_list, &actual_attrs));
+    EXPECT_TRUE(wcore_error_get_code() == WAFFLE_ERROR_BAD_ATTRIBUTE);
+    EXPECT_TRUE(strstr(wcore_error_get_info()->message, "WAFFLE_SAMPLES"));
+    EXPECT_TRUE(strstr(wcore_error_get_info()->message, "-2"));
+}
+
 void
 testsuite_wcore_config_attrs(void)
 {
@@ -199,4 +297,11 @@ testsuite_wcore_config_attrs(void)
     TEST_RUN(wcore_config_attrs, double_buffered_is_false);
     TEST_RUN(wcore_config_attrs, double_buffered_is_bad);
     TEST_RUN(wcore_config_attrs, core_profile_and_accum_buffer);
+    TEST_RUN(wcore_config_attrs, negative_red);
+    TEST_RUN(wcore_config_attrs, negative_green);
+    TEST_RUN(wcore_config_attrs, negative_blue);
+    TEST_RUN(wcore_config_attrs, negative_alpha);
+    TEST_RUN(wcore_config_attrs, negative_depth);
+    TEST_RUN(wcore_config_attrs, negative_stencil);
+    TEST_RUN(wcore_config_attrs, negative_samples);
 }
-- 
1.7.12.1



More information about the waffle mailing list