update: add widthratio and templatetag
This commit is contained in:
parent
35bc0df2cd
commit
e9c042a654
2 changed files with 146 additions and 0 deletions
|
|
@ -854,3 +854,65 @@ test "parse resetcycle com nome" {
|
|||
try testing.expect(rc.cycle_name != null);
|
||||
try testing.expectEqualStrings("rowclass", rc.cycle_name.?);
|
||||
}
|
||||
|
||||
test "parse widthratio simples" {
|
||||
const allocator = testing.allocator;
|
||||
const template = "Progresso: {% widthratio progresso 0 100 %}%";
|
||||
const nodes = try parser.parse(allocator, template);
|
||||
defer {
|
||||
for (nodes) |node| node.deinit(allocator);
|
||||
allocator.free(nodes);
|
||||
}
|
||||
|
||||
try testing.expectEqual(@as(usize, 3), nodes.len);
|
||||
try testing.expect(nodes[1].type == .widthratio);
|
||||
const wr = nodes[1].widthratio.?;
|
||||
try testing.expectEqualStrings("progresso", wr.value);
|
||||
try testing.expectEqualStrings("0", wr.max_value);
|
||||
try testing.expectEqualStrings("100", wr.divisor.?);
|
||||
}
|
||||
|
||||
test "parse widthratio sem divisor" {
|
||||
const allocator = testing.allocator;
|
||||
const template = "{% widthratio valor 100 %}";
|
||||
const nodes = try parser.parse(allocator, template);
|
||||
defer {
|
||||
for (nodes) |node| node.deinit(allocator);
|
||||
allocator.free(nodes);
|
||||
}
|
||||
|
||||
try testing.expectEqual(@as(usize, 1), nodes.len);
|
||||
try testing.expect(nodes[0].type == .widthratio);
|
||||
const wr = nodes[0].widthratio.?;
|
||||
try testing.expectEqualStrings("valor", wr.value);
|
||||
try testing.expectEqualStrings("100", wr.max_value);
|
||||
try testing.expect(wr.divisor == null);
|
||||
}
|
||||
|
||||
test "parse templatetag openblock" {
|
||||
const allocator = testing.allocator;
|
||||
const template = "{% templatetag openblock %}";
|
||||
const nodes = try parser.parse(allocator, template);
|
||||
defer {
|
||||
for (nodes) |node| node.deinit(allocator);
|
||||
allocator.free(nodes);
|
||||
}
|
||||
|
||||
try testing.expectEqual(@as(usize, 1), nodes.len);
|
||||
try testing.expect(nodes[0].type == .templatetag);
|
||||
try testing.expect(nodes[0].templatetag.?.kind == .openblock);
|
||||
}
|
||||
|
||||
test "parse templatetag closevariable" {
|
||||
const allocator = testing.allocator;
|
||||
const template = "{% templatetag closevariable %}";
|
||||
const nodes = try parser.parse(allocator, template);
|
||||
defer {
|
||||
for (nodes) |node| node.deinit(allocator);
|
||||
allocator.free(nodes);
|
||||
}
|
||||
|
||||
try testing.expectEqual(@as(usize, 1), nodes.len);
|
||||
try testing.expect(nodes[0].type == .templatetag);
|
||||
try testing.expect(nodes[0].templatetag.?.kind == .closevariable);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue