From 7f47321066c8c8bda50b4e01785a2a1bf6eb5815 Mon Sep 17 00:00:00 2001 From: Kalle Carlbark Date: Wed, 15 May 2024 22:33:07 +0200 Subject: [PATCH] tests: Test default values --- src/zpinner.zig | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/zpinner.zig b/src/zpinner.zig index 9d51cf1..b9086f2 100644 --- a/src/zpinner.zig +++ b/src/zpinner.zig @@ -118,3 +118,39 @@ const Zpinner = struct { } } }; + +test "empty options struct contains default delay value" { + const expectedValue = std.time.ns_per_s * 0.1; + + const defaultOptions = Options{}; + + try std.testing.expectEqual(@as(u64, defaultOptions.delay), @as(u64, expectedValue)); +} +test "empty options struct contains default snake charset" { + const expectedValue = chars.Snake; + + const opts = Options{}; + + try std.testing.expectEqual(opts.chars, expectedValue); +} +test "empty options struct contains default empty prefix" { + const expectedValue = ""; + + const opts = Options{}; + + try std.testing.expectEqual(opts.prefix, expectedValue); +} +test "empty options struct contains default empty suffix" { + const expectedValue = ""; + + const opts = Options{}; + + try std.testing.expectEqual(opts.suffix, expectedValue); +} +test "empty options struct contains default style default" { + const expectedValue = Style{ .foreground = Color.Default, .background = Color.Default }; + + const opts = Options{}; + + try std.testing.expectEqual(opts.style, expectedValue); +}