diff options
| author | jacksonfu14 <jackson@fashionunited.com> | 2025-11-06 09:06:23 +0100 |
|---|---|---|
| committer | Jackson Moore <jacksonmoore@tuta.io> | 2025-11-06 09:06:23 +0100 |
| commit | 52d6f51b11ad7144ecef02ecd8710528076a67a4 (patch) | |
| tree | fd6e84925f5cac26adb3405be19b072f0a9176d8 /morphology/tests | |
| parent | 743bf0f56e566f9d7b7671805a81704c3b7b14c2 (diff) | |
feat: pretty print meta-affine values
Diffstat (limited to 'morphology/tests')
| -rw-r--r-- | morphology/tests/value.rs | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/morphology/tests/value.rs b/morphology/tests/value.rs index fcd4b76..10c21c5 100644 --- a/morphology/tests/value.rs +++ b/morphology/tests/value.rs @@ -302,3 +302,61 @@ fn test_path_immutability() { assert_eq!(value.outer, 3); assert_eq!(value.inner, 4); } + +// ======================================================================== +// PRETTY PRINT TESTS +// ======================================================================== + +#[test] +fn test_pretty_print_origin() { + assert_eq!(Value::new(0, 0).pretty_print(), "0"); +} + +#[test] +fn test_pretty_print_zero_outer() { + // When outer is 0, just print the inner value + assert_eq!(Value::new(0, 1).pretty_print(), "1"); + assert_eq!(Value::new(0, -1).pretty_print(), "-1"); + assert_eq!(Value::new(0, 5).pretty_print(), "5"); + assert_eq!(Value::new(0, -10).pretty_print(), "-10"); +} + +#[test] +fn test_pretty_print_positive_outer() { + // Positive outer: nest in parentheses + assert_eq!(Value::new(1, 0).pretty_print(), "(0)"); + assert_eq!(Value::new(2, 0).pretty_print(), "((0))"); + assert_eq!(Value::new(3, 0).pretty_print(), "(((0)))"); + assert_eq!(Value::new(1, 3).pretty_print(), "(3)"); + assert_eq!(Value::new(2, 1).pretty_print(), "((1))"); + assert_eq!(Value::new(3, -2).pretty_print(), "(((-2)))"); +} + +#[test] +fn test_pretty_print_negative_outer() { + // Negative outer: nest in square brackets + assert_eq!(Value::new(-1, 0).pretty_print(), "[0]"); + assert_eq!(Value::new(-2, 0).pretty_print(), "[[0]]"); + assert_eq!(Value::new(-3, 0).pretty_print(), "[[[0]]]"); + assert_eq!(Value::new(-1, 3).pretty_print(), "[3]"); + assert_eq!(Value::new(-2, 1).pretty_print(), "[[1]]"); + assert_eq!(Value::new(-3, 2).pretty_print(), "[[[2]]]"); + assert_eq!(Value::new(-4, -5).pretty_print(), "[[[[-5]]]]"); +} + +#[test] +fn test_pretty_print_various_cases() { + // Test a variety of combinations + assert_eq!(Value::new(5, 7).pretty_print(), "(((((7)))))"); + assert_eq!(Value::new(-5, 7).pretty_print(), "[[[[[7]]]]]"); + assert_eq!(Value::new(4, -8).pretty_print(), "((((-8))))"); + assert_eq!(Value::new(-4, -8).pretty_print(), "[[[[-8]]]]"); +} + +#[test] +fn test_pretty_print_large_values() { + // Test with larger nesting levels + assert_eq!(Value::new(10, 0).pretty_print(), "((((((((((0))))))))))"); + assert_eq!(Value::new(-10, 0).pretty_print(), "[[[[[[[[[[0]]]]]]]]]]"); + assert_eq!(Value::new(0, 100).pretty_print(), "100"); +} |