diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-11-24 19:54:39 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-11-25 07:57:14 -0500 |
commit | 05be686a512299fc03e987399819ff13b7935b81 (patch) | |
tree | 47665a01030710cc00d2726c1fd184232bd137dd | |
parent | cddd173f713335318802a98f008d44b66ac4db46 (diff) | |
download | pango-05be686a512299fc03e987399819ff13b7935b81.tar.gz |
Add a newline to serialization results
Otherwise editing the output in an editor
is likely to make the data not match anymore,
since most editors will add a final newline.
Update all tests
29 files changed, 101 insertions, 216 deletions
diff --git a/pango/serializer.c b/pango/serializer.c index 5d2911df..6e394a1c 100644 --- a/pango/serializer.c +++ b/pango/serializer.c @@ -1478,6 +1478,7 @@ pango_layout_serialize (PangoLayout *layout, { JsonGenerator *generator; JsonNode *node; + GString *str; char *data; gsize size; @@ -1490,7 +1491,10 @@ pango_layout_serialize (PangoLayout *layout, json_generator_set_indent (generator, 2); json_generator_set_root (generator, node); - data = json_generator_to_data (generator, &size); + str = g_string_new (""); + g_string_append_c (json_generator_to_gstring (generator, str), '\n'); + size = str->len; + data = g_string_free (str, FALSE); json_node_free (node); g_object_unref (generator); diff --git a/tests/layouts/bratwurst.layout b/tests/layouts/bratwurst.layout index ddfe44c2..c31446ac 100644 --- a/tests/layouts/bratwurst.layout +++ b/tests/layouts/bratwurst.layout @@ -222,4 +222,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/bratwurst2.layout b/tests/layouts/bratwurst2.layout index 0fb44a24..ffd37cdd 100644 --- a/tests/layouts/bratwurst2.layout +++ b/tests/layouts/bratwurst2.layout @@ -185,4 +185,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/bratwurst3.layout b/tests/layouts/bratwurst3.layout index 7d58668b..e79ba81c 100644 --- a/tests/layouts/bratwurst3.layout +++ b/tests/layouts/bratwurst3.layout @@ -315,4 +315,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/bratwurst4.layout b/tests/layouts/bratwurst4.layout index 66c76828..f25f1e9e 100644 --- a/tests/layouts/bratwurst4.layout +++ b/tests/layouts/bratwurst4.layout @@ -242,4 +242,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/effigy.layout b/tests/layouts/effigy.layout index a2275d45..cc8c4282 100644 --- a/tests/layouts/effigy.layout +++ b/tests/layouts/effigy.layout @@ -185,4 +185,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/kebab.layout b/tests/layouts/kebab.layout index a62117ae..357fd40d 100644 --- a/tests/layouts/kebab.layout +++ b/tests/layouts/kebab.layout @@ -251,4 +251,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/valid-1.layout b/tests/layouts/valid-1.layout index 8fc1429a..8ee8cf46 100644 --- a/tests/layouts/valid-1.layout +++ b/tests/layouts/valid-1.layout @@ -688,4 +688,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/valid-10.layout b/tests/layouts/valid-10.layout index ef6298d5..765aba83 100644 --- a/tests/layouts/valid-10.layout +++ b/tests/layouts/valid-10.layout @@ -414,4 +414,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/valid-11.layout b/tests/layouts/valid-11.layout index d743acea..9a5e5f40 100644 --- a/tests/layouts/valid-11.layout +++ b/tests/layouts/valid-11.layout @@ -479,4 +479,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/valid-12.layout b/tests/layouts/valid-12.layout index b7ee6ddf..59451e08 100644 --- a/tests/layouts/valid-12.layout +++ b/tests/layouts/valid-12.layout @@ -785,4 +785,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/valid-13.layout b/tests/layouts/valid-13.layout index dadd40f0..b3aaeb1c 100644 --- a/tests/layouts/valid-13.layout +++ b/tests/layouts/valid-13.layout @@ -795,4 +795,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/valid-14.layout b/tests/layouts/valid-14.layout index 09894b52..61e7182e 100644 --- a/tests/layouts/valid-14.layout +++ b/tests/layouts/valid-14.layout @@ -525,4 +525,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/valid-15.layout b/tests/layouts/valid-15.layout index 8bcec049..b6613068 100644 --- a/tests/layouts/valid-15.layout +++ b/tests/layouts/valid-15.layout @@ -1030,4 +1030,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/valid-16.layout b/tests/layouts/valid-16.layout index 8c80be6d..fc2776e2 100644 --- a/tests/layouts/valid-16.layout +++ b/tests/layouts/valid-16.layout @@ -1038,4 +1038,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/valid-17.layout b/tests/layouts/valid-17.layout index f14c769c..71182844 100644 --- a/tests/layouts/valid-17.layout +++ b/tests/layouts/valid-17.layout @@ -332,4 +332,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/valid-18.layout b/tests/layouts/valid-18.layout index 9424a079..2337a562 100644 --- a/tests/layouts/valid-18.layout +++ b/tests/layouts/valid-18.layout @@ -27,8 +27,8 @@ "output" : { "is-wrapped" : true, "is-ellipsized" : false, - "unknown-glyphs" : 9, - "width" : 295936, + "unknown-glyphs" : 5, + "width" : 302080, "height" : 56320, "log-attrs" : [ { @@ -396,8 +396,8 @@ "log-cluster" : 3 }, { - "glyph" : 268444707, - "width" : 8192, + "glyph" : 1195, + "width" : 11264, "is-cluster-start" : true, "log-cluster" : 4 }, @@ -426,8 +426,8 @@ "log-cluster" : 8 }, { - "glyph" : 268444707, - "width" : 8192, + "glyph" : 1195, + "width" : 11264, "is-cluster-start" : true, "log-cluster" : 9 }, @@ -574,8 +574,8 @@ "log-cluster" : 2 }, { - "glyph" : 268444707, - "width" : 8192, + "glyph" : 1195, + "width" : 11264, "is-cluster-start" : true, "log-cluster" : 3 }, @@ -670,8 +670,8 @@ "log-cluster" : 20 }, { - "glyph" : 268444707, - "width" : 8192, + "glyph" : 1195, + "width" : 11264, "is-cluster-start" : true, "log-cluster" : 21 }, @@ -760,4 +760,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/valid-19.layout b/tests/layouts/valid-19.layout index aeec29a7..c9e6d979 100644 --- a/tests/layouts/valid-19.layout +++ b/tests/layouts/valid-19.layout @@ -15,47 +15,21 @@ 0.0 ] }, - "text" : " a⃠ 😊︎ 😊️ 🇩🇪 ✊ ✋🏾 0 # 🏴 ©\n", + "text" : "😊︎ 😊️ 🇩🇪 ✊ ✋🏾 0 # 🏴 ©\n", "font" : "Cantarell 11", "output" : { "is-wrapped" : false, "is-ellipsized" : false, - "unknown-glyphs" : 7, - "width" : 252928, - "height" : 38912, + "unknown-glyphs" : 0, + "width" : 649216, + "height" : 150528, "log-attrs" : [ { "char-break" : true, - "white" : true, "cursor-position" : true, "sentence-boundary" : true, - "backspace-deletes-character" : true, - "expandable-space" : true, - "word-boundary" : true - }, - { - "line-break" : true, - "char-break" : true, - "cursor-position" : true, - "word-start" : true, "sentence-start" : true, - "word-boundary" : true - }, - { - "break-inserts-hyphen" : true - }, - { - "char-break" : true, - "white" : true, - "cursor-position" : true, - "word-end" : true, - "expandable-space" : true, - "word-boundary" : true - }, - { - "line-break" : true, - "char-break" : true, - "cursor-position" : true, + "backspace-deletes-character" : true, "word-boundary" : true }, { }, @@ -195,72 +169,18 @@ "lines" : [ { "start-index" : 0, - "length" : 74, + "length" : 68, "paragraph-start" : true, "direction" : "ltr", "runs" : [ { "offset" : 0, - "length" : 6, - "text" : " a⃠ ", - "bidi-level" : 0, - "gravity" : "south", - "language" : "en-us", - "script" : "latin", - "font" : { - "description" : "Cantarell 11", - "checksum" : "5bcb6ee14ee9d210b2e91d643de1fe456e9d1aea770983fdb05951545efebbe2", - "variations" : { - "wght" : 0 - }, - "matrix" : [ - 1.0, - -0.0, - -0.0, - 1.0, - 0.0, - 0.0 - ] - }, - "flags" : 0, - "y-offset" : 0, - "start-x-offset" : 0, - "end-x-offset" : 0, - "glyphs" : [ - { - "glyph" : 1109, - "width" : 3072, - "is-cluster-start" : true, - "log-cluster" : 0 - }, - { - "glyph" : 244, - "width" : 8192, - "is-cluster-start" : true, - "log-cluster" : 1 - }, - { - "glyph" : 268443872, - "width" : 17408, - "is-cluster-start" : true, - "log-cluster" : 2 - }, - { - "glyph" : 1109, - "width" : 3072, - "is-cluster-start" : true, - "log-cluster" : 5 - } - ] - }, - { - "offset" : 6, "length" : 8, "text" : "😊︎ ", "bidi-level" : 0, "gravity" : "south", "language" : "en-us", - "script" : "latin", + "script" : "common", "font" : { "description" : "DejaVu Sans 11", "checksum" : "69ccd07023a72ceb27a5e5c22f728627353b60a198170f5e58dd7014221abf01", @@ -299,13 +219,13 @@ ] }, { - "offset" : 14, + "offset" : 8, "length" : 7, "text" : "😊️", "bidi-level" : 0, "gravity" : "south", "language" : "en-us", - "script" : "latin", + "script" : "common", "font" : { "description" : "DejaVu Sans 11", "checksum" : "69ccd07023a72ceb27a5e5c22f728627353b60a198170f5e58dd7014221abf01", @@ -338,13 +258,13 @@ ] }, { - "offset" : 21, + "offset" : 15, "length" : 1, "text" : " ", "bidi-level" : 0, "gravity" : "south", "language" : "en-us", - "script" : "latin", + "script" : "common", "font" : { "description" : "Cantarell 11", "checksum" : "5bcb6ee14ee9d210b2e91d643de1fe456e9d1aea770983fdb05951545efebbe2", @@ -374,16 +294,16 @@ ] }, { - "offset" : 22, + "offset" : 16, "length" : 8, "text" : "🇩🇪", "bidi-level" : 0, "gravity" : "south", "language" : "en-us", - "script" : "latin", + "script" : "common", "font" : { - "description" : "DejaVu Sans 11", - "checksum" : "69ccd07023a72ceb27a5e5c22f728627353b60a198170f5e58dd7014221abf01", + "description" : "Noto Color Emoji 11", + "checksum" : "cc2ce7351378d5dfa4fce6fd8619e5dcf73693d0089e9223c54e3926cdb8a531", "matrix" : [ 1.0, -0.0, @@ -399,27 +319,22 @@ "end-x-offset" : 0, "glyphs" : [ { - "glyph" : 268562921, - "width" : 23552, + "glyph" : 20, + "width" : 139264, "is-cluster-start" : true, + "is-color" : true, "log-cluster" : 0 - }, - { - "glyph" : 268562922, - "width" : 23552, - "is-cluster-start" : true, - "log-cluster" : 4 } ] }, { - "offset" : 30, + "offset" : 24, "length" : 1, "text" : " ", "bidi-level" : 0, "gravity" : "south", "language" : "en-us", - "script" : "latin", + "script" : "common", "font" : { "description" : "Cantarell 11", "checksum" : "5bcb6ee14ee9d210b2e91d643de1fe456e9d1aea770983fdb05951545efebbe2", @@ -449,16 +364,16 @@ ] }, { - "offset" : 31, + "offset" : 25, "length" : 3, "text" : "✊", "bidi-level" : 0, "gravity" : "south", "language" : "en-us", - "script" : "latin", + "script" : "common", "font" : { - "description" : "DejaVu Sans 11", - "checksum" : "69ccd07023a72ceb27a5e5c22f728627353b60a198170f5e58dd7014221abf01", + "description" : "Noto Color Emoji 11", + "checksum" : "cc2ce7351378d5dfa4fce6fd8619e5dcf73693d0089e9223c54e3926cdb8a531", "matrix" : [ 1.0, -0.0, @@ -474,21 +389,22 @@ "end-x-offset" : 0, "glyphs" : [ { - "glyph" : 268445450, - "width" : 17408, + "glyph" : 5, + "width" : 139264, "is-cluster-start" : true, + "is-color" : true, "log-cluster" : 0 } ] }, { - "offset" : 34, + "offset" : 28, "length" : 1, "text" : " ", "bidi-level" : 0, "gravity" : "south", "language" : "en-us", - "script" : "latin", + "script" : "common", "font" : { "description" : "Cantarell 11", "checksum" : "5bcb6ee14ee9d210b2e91d643de1fe456e9d1aea770983fdb05951545efebbe2", @@ -518,16 +434,16 @@ ] }, { - "offset" : 35, + "offset" : 29, "length" : 7, "text" : "✋🏾", "bidi-level" : 0, "gravity" : "south", "language" : "en-us", - "script" : "latin", + "script" : "common", "font" : { - "description" : "DejaVu Sans 11", - "checksum" : "69ccd07023a72ceb27a5e5c22f728627353b60a198170f5e58dd7014221abf01", + "description" : "Noto Color Emoji 11", + "checksum" : "cc2ce7351378d5dfa4fce6fd8619e5dcf73693d0089e9223c54e3926cdb8a531", "matrix" : [ 1.0, -0.0, @@ -543,27 +459,22 @@ "end-x-offset" : 0, "glyphs" : [ { - "glyph" : 268445451, - "width" : 17408, + "glyph" : 19, + "width" : 139264, "is-cluster-start" : true, + "is-color" : true, "log-cluster" : 0 - }, - { - "glyph" : 268563454, - "width" : 23552, - "is-cluster-start" : true, - "log-cluster" : 3 } ] }, { - "offset" : 42, + "offset" : 36, "length" : 5, "text" : " 0 # ", "bidi-level" : 0, "gravity" : "south", "language" : "en-us", - "script" : "latin", + "script" : "common", "font" : { "description" : "Cantarell 11", "checksum" : "5bcb6ee14ee9d210b2e91d643de1fe456e9d1aea770983fdb05951545efebbe2", @@ -617,16 +528,16 @@ ] }, { - "offset" : 47, + "offset" : 41, "length" : 24, "text" : "🏴", "bidi-level" : 0, "gravity" : "south", "language" : "en-us", - "script" : "latin", + "script" : "common", "font" : { - "description" : "DejaVu Sans 11", - "checksum" : "69ccd07023a72ceb27a5e5c22f728627353b60a198170f5e58dd7014221abf01", + "description" : "Noto Color Emoji 11", + "checksum" : "cc2ce7351378d5dfa4fce6fd8619e5dcf73693d0089e9223c54e3926cdb8a531", "matrix" : [ 1.0, -0.0, @@ -642,51 +553,22 @@ "end-x-offset" : 0, "glyphs" : [ { - "glyph" : 268563444, - "width" : 23552, + "glyph" : 22, + "width" : 139264, "is-cluster-start" : true, + "is-color" : true, "log-cluster" : 0 - }, - { - "glyph" : 268435455, - "width" : 0, - "is-cluster-start" : true, - "log-cluster" : 4 - }, - { - "glyph" : 268435455, - "width" : 0, - "is-cluster-start" : true, - "log-cluster" : 8 - }, - { - "glyph" : 268435455, - "width" : 0, - "is-cluster-start" : true, - "log-cluster" : 12 - }, - { - "glyph" : 268435455, - "width" : 0, - "is-cluster-start" : true, - "log-cluster" : 16 - }, - { - "glyph" : 268435455, - "width" : 0, - "is-cluster-start" : true, - "log-cluster" : 20 } ] }, { - "offset" : 71, + "offset" : 65, "length" : 3, "text" : " ©", "bidi-level" : 0, "gravity" : "south", "language" : "en-us", - "script" : "latin", + "script" : "common", "font" : { "description" : "Cantarell 11", "checksum" : "5bcb6ee14ee9d210b2e91d643de1fe456e9d1aea770983fdb05951545efebbe2", @@ -724,7 +606,7 @@ ] }, { - "start-index" : 75, + "start-index" : 69, "length" : 0, "paragraph-start" : true, "direction" : "ltr", @@ -732,4 +614,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/valid-2.layout b/tests/layouts/valid-2.layout index a7e490eb..7e8fb961 100644 --- a/tests/layouts/valid-2.layout +++ b/tests/layouts/valid-2.layout @@ -614,4 +614,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/valid-20.layout b/tests/layouts/valid-20.layout index e82eec6d..1be94175 100644 --- a/tests/layouts/valid-20.layout +++ b/tests/layouts/valid-20.layout @@ -235,4 +235,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/valid-22.layout b/tests/layouts/valid-22.layout index 5596cb19..615200cb 100644 --- a/tests/layouts/valid-22.layout +++ b/tests/layouts/valid-22.layout @@ -718,4 +718,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/valid-3.layout b/tests/layouts/valid-3.layout index b0310eaa..c11c2b35 100644 --- a/tests/layouts/valid-3.layout +++ b/tests/layouts/valid-3.layout @@ -218,4 +218,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/valid-4.layout b/tests/layouts/valid-4.layout index 5cdf02f4..e4358637 100644 --- a/tests/layouts/valid-4.layout +++ b/tests/layouts/valid-4.layout @@ -1957,4 +1957,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/valid-5.layout b/tests/layouts/valid-5.layout index 66801d85..a861ab30 100644 --- a/tests/layouts/valid-5.layout +++ b/tests/layouts/valid-5.layout @@ -1785,4 +1785,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/valid-6.layout b/tests/layouts/valid-6.layout index 7f103a8f..d74ff4eb 100644 --- a/tests/layouts/valid-6.layout +++ b/tests/layouts/valid-6.layout @@ -406,4 +406,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/valid-7.layout b/tests/layouts/valid-7.layout index 5a1fed32..705713ec 100644 --- a/tests/layouts/valid-7.layout +++ b/tests/layouts/valid-7.layout @@ -641,4 +641,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/valid-8.layout b/tests/layouts/valid-8.layout index d8fbee1b..ef463535 100644 --- a/tests/layouts/valid-8.layout +++ b/tests/layouts/valid-8.layout @@ -413,4 +413,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/layouts/valid-9.layout b/tests/layouts/valid-9.layout index 29e2fad9..20cf4e84 100644 --- a/tests/layouts/valid-9.layout +++ b/tests/layouts/valid-9.layout @@ -522,4 +522,4 @@ } ] } -}
\ No newline at end of file +} diff --git a/tests/testserialize.c b/tests/testserialize.c index e18df890..bd962a56 100644 --- a/tests/testserialize.c +++ b/tests/testserialize.c @@ -19,6 +19,7 @@ */ #include "config.h" + #include <glib.h> #include <pango/pangocairo.h> #include <gio/gio.h> @@ -129,7 +130,7 @@ test_serialize_layout_minimal (void) const char *test = "{\n" " \"text\" : \"Almost nothing\"\n" - "}"; + "}\n"; PangoContext *context; GBytes *bytes; @@ -200,7 +201,7 @@ test_serialize_layout_valid (void) " \"alignment\" : \"center\",\n" " \"width\" : 350000,\n" " \"line-spacing\" : 1.5\n" - "}"; + "}\n"; PangoContext *context; GBytes *bytes; @@ -208,7 +209,6 @@ test_serialize_layout_valid (void) PangoTabArray *tabs; GError *error = NULL; GBytes *out_bytes; - const char *str; char *s; context = pango_font_map_create_context (pango_cairo_font_map_get_default ()); @@ -231,14 +231,13 @@ test_serialize_layout_valid (void) g_assert_cmpfloat_with_epsilon (pango_layout_get_line_spacing (layout), 1.5, 0.0001); out_bytes = pango_layout_serialize (layout, PANGO_LAYOUT_SERIALIZE_DEFAULT); - str = g_bytes_get_data (out_bytes, NULL); - g_assert_cmpstr (str, ==, test); + g_assert_cmpstr (g_bytes_get_data (out_bytes, NULL), ==, g_bytes_get_data (bytes, NULL)); g_bytes_unref (out_bytes); + g_bytes_unref (bytes); g_object_unref (layout); - g_bytes_unref (bytes); g_object_unref (context); } @@ -253,7 +252,7 @@ test_serialize_layout_context (void) " \"round-glyph-positions\" : \"false\"\n" " },\n" " \"text\" : \"Some fun with layouts!\"\n" - "}"; + "}\n"; PangoContext *context; GBytes *bytes; @@ -292,7 +291,7 @@ test_serialize_layout_invalid (void) " \"type\" : \"caramba\"\n" " }\n" " ]\n" - "}", + "}\n", PANGO_LAYOUT_DESERIALIZE_INVALID_VALUE }, { @@ -302,7 +301,7 @@ test_serialize_layout_invalid (void) " \"type\" : \"weight\"\n" " }\n" " ]\n" - "}", + "}\n", PANGO_LAYOUT_DESERIALIZE_MISSING_VALUE }, { @@ -313,13 +312,13 @@ test_serialize_layout_invalid (void) " \"value\" : \"nonsense\"\n" " }\n" " ]\n" - "}", + "}\n", PANGO_LAYOUT_DESERIALIZE_INVALID_VALUE }, { "{\n" " \"alignment\" : \"nonsense\"\n" - "}", + "}\n", PANGO_LAYOUT_DESERIALIZE_INVALID_VALUE }, { @@ -327,7 +326,7 @@ test_serialize_layout_invalid (void) " \"attributes\" : {\n" " \"name\" : \"This is wrong\"\n" " }\n" - "}", + "}\n", PANGO_LAYOUT_DESERIALIZE_INVALID_SYNTAX } }; |