Print nodes.
parent
eac5b58017
commit
3d604c3238
|
@ -11,6 +11,14 @@ fn say(tosay: []const u8) void {
|
|||
std.debug.print("{}", .{tosay});
|
||||
}
|
||||
|
||||
fn print_node(node: Node) void {
|
||||
std.debug.print("Node type {} (id: {})\n", .{node.type_name, node.id});
|
||||
var it = node.properties.iterator();
|
||||
while(it.next()) |kv| {
|
||||
std.debug.print("\t{} => {}\n", .{kv.key, node.properties.get(kv.key)});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const PropertyHashMap = AutoHashMap([] const u8, PropertyValue);
|
||||
const NodeList = ArrayList(Node);
|
||||
|
@ -100,7 +108,6 @@ test "simple test about structures" {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
test "init a Root structure" {
|
||||
const allocator = std.heap.page_allocator;
|
||||
|
||||
|
@ -116,16 +123,18 @@ test "init a Root structure" {
|
|||
try root.children.append(try Node.create(allocator, "otherObject", null));
|
||||
try root.children.append(try Node.create(allocator, "Text", "my-id-for-text-object"));
|
||||
|
||||
|
||||
say("root.definitions:\n");
|
||||
var it = root.definitions.iterator();
|
||||
while(it.next()) |kv| {
|
||||
std.debug.print("{} => {}:\n", .{kv.key, root.definitions.get(kv.key)});
|
||||
std.debug.print("{} => ", .{kv.key});
|
||||
const node = root.definitions.get(kv.key);
|
||||
if(node) |n| { print_node(n); }
|
||||
}
|
||||
|
||||
say("root.children:\n");
|
||||
for(root.children.items) |k, v| {
|
||||
std.debug.print("{} => {}:\n", .{k, v});
|
||||
for(root.children.items) |v, k| {
|
||||
std.debug.print("{} => ", .{k});
|
||||
print_node(v);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue