# HG changeset patch # User Kim Alvefur # Date 1615051372 -3600 # Node ID 83f5499d1f102237f1898c19050624a01135df53 # Parent c7948491c5e4c6bf1409504f0700c6536781980a util.rsm: Increase test coverage Test all fields in both directions in order to catch #1642 diff -r c7948491c5e4 -r 83f5499d1f10 spec/util_rsm_spec.lua --- a/spec/util_rsm_spec.lua Sat Mar 06 15:24:45 2021 +0100 +++ b/spec/util_rsm_spec.lua Sat Mar 06 18:22:52 2021 +0100 @@ -37,6 +37,28 @@ assert.same({ max = 10, before = "peter@pixyland.org" }, rsm.parse(test)); end); + it("all fields works", function() + local test = assert(xml.parse(strip([[ + + a + b + 10 + f + 5 + z + 100 + + ]]))); + assert.same({ + after = "a"; + before = "b"; + count = 10; + first = {index = 1; "f"}; + index = 5; + last = "z"; + max = 100; + }, rsm.parse(test)); + end); end); describe("generate", function () @@ -84,6 +106,27 @@ assert.equal("1", r1:get_child("first").attr.index); end); + + it("all fields works", function () + local res = rsm.generate({ + after = "a"; + before = "b"; + count = 10; + first = {index = 1; "f"}; + index = 5; + last = "z"; + max = 100; + }); + assert.equal("a", res:get_child_text("after")); + assert.equal("b", res:get_child_text("before")); + assert.equal("10", res:get_child_text("count")); + assert.equal("f", res:get_child_text("first")); + assert.equal("1", res:get_child("first").attr.index); + assert.equal("5", res:get_child_text("index")); + assert.equal("z", res:get_child_text("last")); + assert.equal("100", res:get_child_text("max")); + end); end); + end);