test(container): rectangle color filling
Some checks failed
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 1m4s
Some checks failed
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 1m4s
This commit is contained in:
@@ -154,6 +154,138 @@ pub const Rectangle = packed struct {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test "fill color overwrite parent fill" {
|
||||
const event = @import("event.zig");
|
||||
const testing = @import("testing.zig");
|
||||
|
||||
var container: Container(event.SystemEvent) = try .init(std.testing.allocator, .{
|
||||
.rectangle = .{ .fill = .green },
|
||||
}, .{});
|
||||
try container.append(try .init(std.testing.allocator, .{
|
||||
.rectangle = .{ .fill = .white },
|
||||
}, .{}));
|
||||
try container.append(try .init(std.testing.allocator, .{}, .{}));
|
||||
defer container.deinit();
|
||||
|
||||
try testing.expectContainerScreen(.{
|
||||
.rows = 20,
|
||||
.cols = 30,
|
||||
}, &container, @import("test/container/rectangle_with_parent_fill_without_padding.zon"));
|
||||
}
|
||||
|
||||
test "fill color padding to show parent fill" {
|
||||
const event = @import("event.zig");
|
||||
const testing = @import("testing.zig");
|
||||
|
||||
var container: Container(event.SystemEvent) = try .init(std.testing.allocator, .{
|
||||
.layout = .{
|
||||
.padding = .all(2),
|
||||
},
|
||||
.rectangle = .{ .fill = .green },
|
||||
}, .{});
|
||||
try container.append(try .init(std.testing.allocator, .{
|
||||
.rectangle = .{ .fill = .white },
|
||||
}, .{}));
|
||||
try container.append(try .init(std.testing.allocator, .{}, .{}));
|
||||
defer container.deinit();
|
||||
|
||||
try testing.expectContainerScreen(.{
|
||||
.rows = 20,
|
||||
.cols = 30,
|
||||
}, &container, @import("test/container/rectangle_with_parent_padding.zon"));
|
||||
}
|
||||
|
||||
test "fill color spacer with padding" {
|
||||
const event = @import("event.zig");
|
||||
const testing = @import("testing.zig");
|
||||
|
||||
var container: Container(event.SystemEvent) = try .init(std.testing.allocator, .{
|
||||
.rectangle = .{
|
||||
.fill = .black,
|
||||
},
|
||||
.layout = .{
|
||||
.padding = .vertical(2),
|
||||
.direction = .vertical,
|
||||
},
|
||||
}, .{});
|
||||
try container.append(try .init(std.testing.allocator, .{
|
||||
.rectangle = .{ .fill = .white },
|
||||
}, .{}));
|
||||
try container.append(try .init(std.testing.allocator, .{}, .{}));
|
||||
try container.append(try .init(std.testing.allocator, .{
|
||||
.rectangle = .{ .fill = .white },
|
||||
}, .{}));
|
||||
defer container.deinit();
|
||||
|
||||
try testing.expectContainerScreen(.{
|
||||
.rows = 20,
|
||||
.cols = 30,
|
||||
}, &container, @import("test/container/rectangle_with_padding.zon"));
|
||||
}
|
||||
|
||||
test "fill color with gap" {
|
||||
const event = @import("event.zig");
|
||||
const testing = @import("testing.zig");
|
||||
|
||||
var container: Container(event.SystemEvent) = try .init(std.testing.allocator, .{
|
||||
.rectangle = .{
|
||||
.fill = .black,
|
||||
},
|
||||
.layout = .{
|
||||
.padding = .vertical(1),
|
||||
.gap = 1,
|
||||
.direction = .vertical,
|
||||
},
|
||||
}, .{});
|
||||
try container.append(try .init(std.testing.allocator, .{
|
||||
.rectangle = .{ .fill = .white },
|
||||
}, .{}));
|
||||
try container.append(try .init(std.testing.allocator, .{
|
||||
.rectangle = .{ .fill = .blue },
|
||||
}, .{}));
|
||||
try container.append(try .init(std.testing.allocator, .{
|
||||
.rectangle = .{ .fill = .white },
|
||||
}, .{}));
|
||||
defer container.deinit();
|
||||
|
||||
try testing.expectContainerScreen(.{
|
||||
.rows = 20,
|
||||
.cols = 30,
|
||||
}, &container, @import("test/container/rectangle_with_gap.zon"));
|
||||
}
|
||||
|
||||
test "fill color with separator" {
|
||||
const event = @import("event.zig");
|
||||
const testing = @import("testing.zig");
|
||||
|
||||
var container: Container(event.SystemEvent) = try .init(std.testing.allocator, .{
|
||||
.rectangle = .{
|
||||
.fill = .black,
|
||||
},
|
||||
.layout = .{
|
||||
.padding = .vertical(1),
|
||||
.separator = .{
|
||||
.enabled = true,
|
||||
},
|
||||
},
|
||||
}, .{});
|
||||
try container.append(try .init(std.testing.allocator, .{
|
||||
.rectangle = .{ .fill = .white },
|
||||
}, .{}));
|
||||
try container.append(try .init(std.testing.allocator, .{
|
||||
.rectangle = .{ .fill = .blue },
|
||||
}, .{}));
|
||||
try container.append(try .init(std.testing.allocator, .{
|
||||
.rectangle = .{ .fill = .white },
|
||||
}, .{}));
|
||||
defer container.deinit();
|
||||
|
||||
try testing.expectContainerScreen(.{
|
||||
.rows = 20,
|
||||
.cols = 30,
|
||||
}, &container, @import("test/container/rectangle_with_seperator.zon"));
|
||||
}
|
||||
};
|
||||
|
||||
/// Layout configuration struct
|
||||
|
||||
1
src/test/container/rectangle_with_gap.zon
Normal file
1
src/test/container/rectangle_with_gap.zon
Normal file
File diff suppressed because one or more lines are too long
1
src/test/container/rectangle_with_padding.zon
Normal file
1
src/test/container/rectangle_with_padding.zon
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
src/test/container/rectangle_with_parent_padding.zon
Normal file
1
src/test/container/rectangle_with_parent_padding.zon
Normal file
File diff suppressed because one or more lines are too long
1
src/test/container/rectangle_with_seperator.zon
Normal file
1
src/test/container/rectangle_with_seperator.zon
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user