Add tests for all the supported colour formats
Cc: Bryce Harrington <[email protected]>
Cc: Quentin Glidic <[email protected]>
Signed-off-by: Eric Engestrom <[email protected]>
---
v2: reduce the number of formats supported
read #-prefixed values the same way CSS would
---
tests/config-parser-test.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 96 insertions(+)
diff --git a/tests/config-parser-test.c b/tests/config-parser-test.c
index 1cdffff..e35e2b8 100644
--- a/tests/config-parser-test.c
+++ b/tests/config-parser-test.c
@@ -127,6 +127,12 @@ static struct zuc_fixture config_test_t1 = {
"oct=01234567\n"
"dec=12345670\n"
"short=1234567\n"
+ "hex6=0x123456\n"
+ "hex8=0x12345678\n"
+ "css3=#123\n"
+ "css4=#1234\n"
+ "css6=#123456\n"
+ "css8=#12345678\n"
"\n"
"[stuff]\n"
"flag= true \n"
@@ -609,6 +615,96 @@ ZUC_TEST_F(config_test_t1, test028, data)
ZUC_ASSERT_EQ(ERANGE, errno);
}
+ZUC_TEST_F(config_test_t1, test029, data)
+{
+ int r;
+ uint32_t n;
+ struct weston_config_section *section;
+ struct weston_config *config = data;
+
+ section = weston_config_get_section(config, "colors", NULL, NULL);
+ r = weston_config_section_get_color(section, "hex6", &n, 0xff336699);
+
+ ZUC_ASSERT_EQ(0, r);
+ ZUC_ASSERT_EQ(0xff123456, n);
+ ZUC_ASSERT_EQ(0, errno);
+}
+
+ZUC_TEST_F(config_test_t1, test030, data)
+{
+ int r;
+ uint32_t n;
+ struct weston_config_section *section;
+ struct weston_config *config = data;
+
+ section = weston_config_get_section(config, "colors", NULL, NULL);
+ r = weston_config_section_get_color(section, "hex8", &n, 0xff336699);
+
+ ZUC_ASSERT_EQ(0, r);
+ ZUC_ASSERT_EQ(0x12345678, n);
+ ZUC_ASSERT_EQ(0, errno);
+}
+
+ZUC_TEST_F(config_test_t1, test031, data)
+{
+ int r;
+ uint32_t n;
+ struct weston_config_section *section;
+ struct weston_config *config = data;
+
+ section = weston_config_get_section(config, "colors", NULL, NULL);
+ r = weston_config_section_get_color(section, "css3", &n, 0xff336699);
+
+ ZUC_ASSERT_EQ(0, r);
+ ZUC_ASSERT_EQ(0xff112233, n);
+ ZUC_ASSERT_EQ(0, errno);
+}
+
+ZUC_TEST_F(config_test_t1, test032, data)
+{
+ int r;
+ uint32_t n;
+ struct weston_config_section *section;
+ struct weston_config *config = data;
+
+ section = weston_config_get_section(config, "colors", NULL, NULL);
+ r = weston_config_section_get_color(section, "css4", &n, 0xff336699);
+
+ ZUC_ASSERT_EQ(0, r);
+ ZUC_ASSERT_EQ(0x44112233, n);
+ ZUC_ASSERT_EQ(0, errno);
+}
+
+ZUC_TEST_F(config_test_t1, test033, data)
+{
+ int r;
+ uint32_t n;
+ struct weston_config_section *section;
+ struct weston_config *config = data;
+
+ section = weston_config_get_section(config, "colors", NULL, NULL);
+ r = weston_config_section_get_color(section, "css6", &n, 0xff336699);
+
+ ZUC_ASSERT_EQ(0, r);
+ ZUC_ASSERT_EQ(0xff123456, n);
+ ZUC_ASSERT_EQ(0, errno);
+}
+
+ZUC_TEST_F(config_test_t1, test034, data)
+{
+ int r;
+ uint32_t n;
+ struct weston_config_section *section;
+ struct weston_config *config = data;
+
+ section = weston_config_get_section(config, "colors", NULL, NULL);
+ r = weston_config_section_get_color(section, "css8", &n, 0xff336699);
+
+ ZUC_ASSERT_EQ(0, r);
+ ZUC_ASSERT_EQ(0x78123456, n);
+ ZUC_ASSERT_EQ(0, errno);
+}
+
ZUC_TEST_F(config_test_t2, doesnt_parse, data)
{
struct weston_config *config = data;
--
Cheers,
Eric
_______________________________________________
wayland-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/wayland-devel