()
| 396 | |
| 397 | #[test] |
| 398 | fn adding_arms_works() { |
| 399 | let mut m = Match::new("x"); |
| 400 | m.arm("Orange", vec!["a", "b"], "some body"); |
| 401 | m.arm("Yellow", vec!["a", "b"], "some body"); |
| 402 | m.arm("Green", vec!["a", "b"], "different body"); |
| 403 | m.arm("Blue", vec!["x", "y"], "some body"); |
| 404 | assert_eq!(m.arms.len(), 3); |
| 405 | |
| 406 | let mut fmt = Formatter::new(Language::Rust); |
| 407 | fmt.add_match(m); |
| 408 | |
| 409 | let expected_lines = from_raw_string( |
| 410 | r#" |
| 411 | match x { |
| 412 | Green { a, b } => { |
| 413 | different body |
| 414 | } |
| 415 | Orange { a, b } | |
| 416 | Yellow { a, b } => { |
| 417 | some body |
| 418 | } |
| 419 | Blue { x, y } => { |
| 420 | some body |
| 421 | } |
| 422 | } |
| 423 | "#, |
| 424 | ); |
| 425 | assert_eq!(fmt.lines, expected_lines); |
| 426 | } |
| 427 | |
| 428 | #[test] |
| 429 | fn match_with_catchall_order() { |
nothing calls this directly
no test coverage detected