[PATCH weston v2 2/2] config-parser-test: test support for more color formats

Eric Engestrom eric at engestrom.ch
Wed Oct 26 22:53:56 UTC 2016


Add tests for all the supported colour formats

Cc: Bryce Harrington <bryce at osg.samsung.com>
Cc: Quentin Glidic <sardemff7+wayland at sardemff7.net>
Signed-off-by: Eric Engestrom <eric at engestrom.ch>
---
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


More information about the wayland-devel mailing list