From ac5cebb7e015231c14869248e07ea0a0eba49506 Mon Sep 17 00:00:00 2001 From: Matt Helsley Date: Tue, 13 Jun 2023 21:14:21 -0700 Subject: [PATCH] testing: Add manual instance test for Style PR #43 introduced a pub(crate) field in Style which broke the intended API (See: Issue #46). Introduce a new test which will fail in those cases since it won't be able to initialize pub(crate) fields. Inspired by: https://github.com/nushell/nu-ansi-term/issues/46#issue-1743515665 --- tests/style.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/style.rs diff --git a/tests/style.rs b/tests/style.rs new file mode 100644 index 0000000..e0c5202 --- /dev/null +++ b/tests/style.rs @@ -0,0 +1,28 @@ +use nu_ansi_term::Style; + +#[test] +fn manual_instance_style() { + let s = Style { ..Style::default() }; + assert_eq!(Style::default(), s); + + let s = Style { + is_underline: false, + ..Style::default() + }; + assert_eq!(Style::default(), s); + + let s = Style { + foreground: None, + background: None, + is_bold: false, + is_dimmed: false, + is_italic: false, + is_underline: false, + is_blink: false, + is_reverse: false, + is_hidden: false, + is_strikethrough: false, + with_reset: false, + }; + assert_eq!(Style::default(), s); +}