MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_format_int_padding_with_grouping

Function test_format_int_padding_with_grouping

crates/common/src/format.rs:1547–1567  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1545
1546 #[test]
1547 fn test_format_int_padding_with_grouping() {
1548 // CPython behavior: f'{1234:010,}' results in "00,001,234"
1549 let spec1 = FormatSpec::parse("010,").unwrap();
1550 let result1 = spec1.format_int(&BigInt::from(1234)).unwrap();
1551 assert_eq!(result1, "00,001,234");
1552
1553 // CPython behavior: f'{-1234:010,}' results in "-0,001,234"
1554 let spec2 = FormatSpec::parse("010,").unwrap();
1555 let result2 = spec2.format_int(&BigInt::from(-1234)).unwrap();
1556 assert_eq!(result2, "-0,001,234");
1557
1558 // CPython behavior: f'{-1234:=10,}' results in "- 1,234"
1559 let spec3 = FormatSpec::parse("=10,").unwrap();
1560 let result3 = spec3.format_int(&BigInt::from(-1234)).unwrap();
1561 assert_eq!(result3, "- 1,234");
1562
1563 // CPython behavior: f'{1234:=10,}' results in " 1,234" (same as right-align for positive numbers)
1564 let spec4 = FormatSpec::parse("=10,").unwrap();
1565 let result4 = spec4.format_int(&BigInt::from(1234)).unwrap();
1566 assert_eq!(result4, " 1,234");
1567 }
1568
1569 #[test]
1570 fn test_format_int_non_aftersign_zero_padding() {

Callers

nothing calls this directly

Calls 3

format_intMethod · 0.80
parseFunction · 0.50
unwrapMethod · 0.45

Tested by

no test coverage detected