Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8326718: Test java/util/Formatter/Padding.java should timeout on large inputs before fix in JDK-8299677 #18033

Closed
wants to merge 3 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions test/jdk/java/util/Formatter/Padding.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@

/*
* @test
* @bug 4906370
* @bug 4906370 8299677 8326718
* @summary Tests to excercise padding on int and double values,
* with various flag combinations.
* @run junit Padding
@@ -40,6 +40,9 @@

public class Padding {

private static final String tenMillionZeros = "0".repeat(10000000);
private static final String tenMillionBlanks = " ".repeat(10000000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nit to help readability

Suggested change
private static final String tenMillionZeros = "0".repeat(10000000);
private static final String tenMillionBlanks = " ".repeat(10000000);
private static final String tenMillionZeros = "0".repeat(10_000_000);
private static final String tenMillionBlanks = " ".repeat(10_000_000);


static Arguments[] padding() {
return new Arguments[] {
/* blank padding, right adjusted, optional plus sign */
@@ -49,27 +52,31 @@ static Arguments[] padding() {
arguments(" 12", "%4d", 12),
arguments(" 12", "%5d", 12),
arguments(" 12", "%10d", 12),
arguments(tenMillionBlanks + "12", "%10000002d", 12),

arguments("-12", "%1d", -12),
arguments("-12", "%2d", -12),
arguments("-12", "%3d", -12),
arguments(" -12", "%4d", -12),
arguments(" -12", "%5d", -12),
arguments(" -12", "%10d", -12),
arguments(tenMillionBlanks + "-12", "%10000003d", -12),

arguments("1.2", "%1.1f", 1.2),
arguments("1.2", "%2.1f", 1.2),
arguments("1.2", "%3.1f", 1.2),
arguments(" 1.2", "%4.1f", 1.2),
arguments(" 1.2", "%5.1f", 1.2),
arguments(" 1.2", "%10.1f", 1.2),
arguments(tenMillionBlanks + "1.2", "%10000003.1f", 1.2),

arguments("-1.2", "%1.1f", -1.2),
arguments("-1.2", "%2.1f", -1.2),
arguments("-1.2", "%3.1f", -1.2),
arguments("-1.2", "%4.1f", -1.2),
arguments(" -1.2", "%5.1f", -1.2),
arguments(" -1.2", "%10.1f", -1.2),
arguments(tenMillionBlanks + "-1.2", "%10000004.1f", -1.2),

/* blank padding, right adjusted, mandatory plus sign */
arguments("+12", "%+1d", 12),
@@ -78,27 +85,31 @@ static Arguments[] padding() {
arguments(" +12", "%+4d", 12),
arguments(" +12", "%+5d", 12),
arguments(" +12", "%+10d", 12),
arguments(tenMillionBlanks + "+12", "%+10000003d", 12),

arguments("-12", "%+1d", -12),
arguments("-12", "%+2d", -12),
arguments("-12", "%+3d", -12),
arguments(" -12", "%+4d", -12),
arguments(" -12", "%+5d", -12),
arguments(" -12", "%+10d", -12),
arguments(tenMillionBlanks + "-12", "%+10000003d", -12),

arguments("+1.2", "%+1.1f", 1.2),
arguments("+1.2", "%+2.1f", 1.2),
arguments("+1.2", "%+3.1f", 1.2),
arguments("+1.2", "%+4.1f", 1.2),
arguments(" +1.2", "%+5.1f", 1.2),
arguments(" +1.2", "%+10.1f", 1.2),
arguments(tenMillionBlanks + "+1.2", "%+10000004.1f", 1.2),

arguments("-1.2", "%+1.1f", -1.2),
arguments("-1.2", "%+2.1f", -1.2),
arguments("-1.2", "%+3.1f", -1.2),
arguments("-1.2", "%+4.1f", -1.2),
arguments(" -1.2", "%+5.1f", -1.2),
arguments(" -1.2", "%+10.1f", -1.2),
arguments(tenMillionBlanks + "-1.2", "%+10000004.1f", -1.2),

/* blank padding, right adjusted, mandatory blank sign */
arguments(" 12", "% 1d", 12),
@@ -107,27 +118,31 @@ static Arguments[] padding() {
arguments(" 12", "% 4d", 12),
arguments(" 12", "% 5d", 12),
arguments(" 12", "% 10d", 12),
arguments(tenMillionBlanks + "12", "% 10000002d", 12),

arguments("-12", "% 1d", -12),
arguments("-12", "% 2d", -12),
arguments("-12", "% 3d", -12),
arguments(" -12", "% 4d", -12),
arguments(" -12", "% 5d", -12),
arguments(" -12", "% 10d", -12),
arguments(tenMillionBlanks + "-12", "% 10000003d", -12),

arguments(" 1.2", "% 1.1f", 1.2),
arguments(" 1.2", "% 2.1f", 1.2),
arguments(" 1.2", "% 3.1f", 1.2),
arguments(" 1.2", "% 4.1f", 1.2),
arguments(" 1.2", "% 5.1f", 1.2),
arguments(" 1.2", "% 10.1f", 1.2),
arguments(tenMillionBlanks + "1.2", "% 10000003.1f", 1.2),

arguments("-1.2", "% 1.1f", -1.2),
arguments("-1.2", "% 2.1f", -1.2),
arguments("-1.2", "% 3.1f", -1.2),
arguments("-1.2", "% 4.1f", -1.2),
arguments(" -1.2", "% 5.1f", -1.2),
arguments(" -1.2", "% 10.1f", -1.2),
arguments(tenMillionBlanks + "-1.2", "% 10000004.1f", -1.2),

/* blank padding, left adjusted, optional sign */
arguments("12", "%-1d", 12),
@@ -136,27 +151,31 @@ static Arguments[] padding() {
arguments("12 ", "%-4d", 12),
arguments("12 ", "%-5d", 12),
arguments("12 ", "%-10d", 12),
arguments("12" + tenMillionBlanks, "%-10000002d", 12),

arguments("-12", "%-1d", -12),
arguments("-12", "%-2d", -12),
arguments("-12", "%-3d", -12),
arguments("-12 ", "%-4d", -12),
arguments("-12 ", "%-5d", -12),
arguments("-12 ", "%-10d", -12),
arguments("-12" + tenMillionBlanks, "%-10000003d", -12),

arguments("1.2", "%-1.1f", 1.2),
arguments("1.2", "%-2.1f", 1.2),
arguments("1.2", "%-3.1f", 1.2),
arguments("1.2 ", "%-4.1f", 1.2),
arguments("1.2 ", "%-5.1f", 1.2),
arguments("1.2 ", "%-10.1f", 1.2),
arguments("1.2" + tenMillionBlanks, "%-10000003.1f", 1.2),

arguments("-1.2", "%-1.1f", -1.2),
arguments("-1.2", "%-2.1f", -1.2),
arguments("-1.2", "%-3.1f", -1.2),
arguments("-1.2", "%-4.1f", -1.2),
arguments("-1.2 ", "%-5.1f", -1.2),
arguments("-1.2 ", "%-10.1f", -1.2),
arguments("-1.2" + tenMillionBlanks, "%-10000004.1f", -1.2),

/* blank padding, left adjusted, mandatory plus sign */
arguments("+12", "%-+1d", 12),
@@ -165,27 +184,31 @@ static Arguments[] padding() {
arguments("+12 ", "%-+4d", 12),
arguments("+12 ", "%-+5d", 12),
arguments("+12 ", "%-+10d", 12),
arguments("+12" + tenMillionBlanks, "%-+10000003d", 12),

arguments("-12", "%-+1d", -12),
arguments("-12", "%-+2d", -12),
arguments("-12", "%-+3d", -12),
arguments("-12 ", "%-+4d", -12),
arguments("-12 ", "%-+5d", -12),
arguments("-12 ", "%-+10d", -12),
arguments("-12" + tenMillionBlanks, "%-+10000003d", -12),

arguments("+1.2", "%-+1.1f", 1.2),
arguments("+1.2", "%-+2.1f", 1.2),
arguments("+1.2", "%-+3.1f", 1.2),
arguments("+1.2", "%-+4.1f", 1.2),
arguments("+1.2 ", "%-+5.1f", 1.2),
arguments("+1.2 ", "%-+10.1f", 1.2),
arguments("+1.2" + tenMillionBlanks, "%-+10000004.1f", 1.2),

arguments("-1.2", "%-+1.1f", -1.2),
arguments("-1.2", "%-+2.1f", -1.2),
arguments("-1.2", "%-+3.1f", -1.2),
arguments("-1.2", "%-+4.1f", -1.2),
arguments("-1.2 ", "%-+5.1f", -1.2),
arguments("-1.2 ", "%-+10.1f", -1.2),
arguments("-1.2" + tenMillionBlanks, "%-+10000004.1f", -1.2),

/* blank padding, left adjusted, mandatory blank sign */
arguments(" 12", "%- 1d", 12),
@@ -194,27 +217,31 @@ static Arguments[] padding() {
arguments(" 12 ", "%- 4d", 12),
arguments(" 12 ", "%- 5d", 12),
arguments(" 12 ", "%- 10d", 12),
arguments(" 12" + tenMillionBlanks, "%- 10000003d", 12),

arguments("-12", "%- 1d", -12),
arguments("-12", "%- 2d", -12),
arguments("-12", "%- 3d", -12),
arguments("-12 ", "%- 4d", -12),
arguments("-12 ", "%- 5d", -12),
arguments("-12 ", "%- 10d", -12),
arguments("-12" + tenMillionBlanks, "%- 10000003d", -12),

arguments(" 1.2", "%- 1.1f", 1.2),
arguments(" 1.2", "%- 2.1f", 1.2),
arguments(" 1.2", "%- 3.1f", 1.2),
arguments(" 1.2", "%- 4.1f", 1.2),
arguments(" 1.2 ", "%- 5.1f", 1.2),
arguments(" 1.2 ", "%- 10.1f", 1.2),
arguments(" 1.2" + tenMillionBlanks, "%- 10000004.1f", 1.2),

arguments("-1.2", "%- 1.1f", -1.2),
arguments("-1.2", "%- 2.1f", -1.2),
arguments("-1.2", "%- 3.1f", -1.2),
arguments("-1.2", "%- 4.1f", -1.2),
arguments("-1.2 ", "%- 5.1f", -1.2),
arguments("-1.2 ", "%- 10.1f", -1.2),
arguments("-1.2" + tenMillionBlanks, "%- 10000004.1f", -1.2),

/* zero padding, right adjusted, optional sign */
arguments("12", "%01d", 12),
@@ -223,27 +250,31 @@ static Arguments[] padding() {
arguments("0012", "%04d", 12),
arguments("00012", "%05d", 12),
arguments("0000000012", "%010d", 12),
arguments(tenMillionZeros + "12", "%010000002d", 12),

arguments("-12", "%01d", -12),
arguments("-12", "%02d", -12),
arguments("-12", "%03d", -12),
arguments("-012", "%04d", -12),
arguments("-0012", "%05d", -12),
arguments("-000000012", "%010d", -12),
arguments("-" + tenMillionZeros + "12", "%010000003d", -12),

arguments("1.2", "%01.1f", 1.2),
arguments("1.2", "%02.1f", 1.2),
arguments("1.2", "%03.1f", 1.2),
arguments("01.2", "%04.1f", 1.2),
arguments("001.2", "%05.1f", 1.2),
arguments("00000001.2", "%010.1f", 1.2),
arguments(tenMillionZeros + "1.2", "%010000003.1f", 1.2),

arguments("-1.2", "%01.1f", -1.2),
arguments("-1.2", "%02.1f", -1.2),
arguments("-1.2", "%03.1f", -1.2),
arguments("-1.2", "%04.1f", -1.2),
arguments("-01.2", "%05.1f", -1.2),
arguments("-0000001.2", "%010.1f", -1.2),
arguments("-" + tenMillionZeros + "1.2", "%010000004.1f", -1.2),

/* zero padding, right adjusted, mandatory plus sign */
arguments("+12", "%+01d", 12),
@@ -252,27 +283,31 @@ static Arguments[] padding() {
arguments("+012", "%+04d", 12),
arguments("+0012", "%+05d", 12),
arguments("+000000012", "%+010d", 12),
arguments("+" + tenMillionZeros + "12", "%+010000003d", 12),

arguments("-12", "%+01d", -12),
arguments("-12", "%+02d", -12),
arguments("-12", "%+03d", -12),
arguments("-012", "%+04d", -12),
arguments("-0012", "%+05d", -12),
arguments("-000000012", "%+010d", -12),
arguments("-" + tenMillionZeros + "12", "%+010000003d", -12),

arguments("+1.2", "%+01.1f", 1.2),
arguments("+1.2", "%+02.1f", 1.2),
arguments("+1.2", "%+03.1f", 1.2),
arguments("+1.2", "%+04.1f", 1.2),
arguments("+01.2", "%+05.1f", 1.2),
arguments("+0000001.2", "%+010.1f", 1.2),
arguments("+" + tenMillionZeros + "1.2", "%+010000004.1f", 1.2),

arguments("-1.2", "%+01.1f", -1.2),
arguments("-1.2", "%+02.1f", -1.2),
arguments("-1.2", "%+03.1f", -1.2),
arguments("-1.2", "%+04.1f", -1.2),
arguments("-01.2", "%+05.1f", -1.2),
arguments("-0000001.2", "%+010.1f", -1.2),
arguments("-" + tenMillionZeros + "1.2", "%+010000004.1f", -1.2),

/* zero padding, right adjusted, mandatory blank sign */
arguments(" 12", "% 01d", 12),
@@ -281,27 +316,31 @@ static Arguments[] padding() {
arguments(" 012", "% 04d", 12),
arguments(" 0012", "% 05d", 12),
arguments(" 000000012", "% 010d", 12),
arguments(" " + tenMillionZeros + "12", "% 010000003d", 12),

arguments("-12", "% 01d", -12),
arguments("-12", "% 02d", -12),
arguments("-12", "% 03d", -12),
arguments("-012", "% 04d", -12),
arguments("-0012", "% 05d", -12),
arguments("-000000012", "% 010d", -12),
arguments("-" + tenMillionZeros + "12", "% 010000003d", -12),

arguments(" 1.2", "% 01.1f", 1.2),
arguments(" 1.2", "% 02.1f", 1.2),
arguments(" 1.2", "% 03.1f", 1.2),
arguments(" 1.2", "% 04.1f", 1.2),
arguments(" 01.2", "% 05.1f", 1.2),
arguments(" 0000001.2", "% 010.1f", 1.2),
arguments(" " + tenMillionZeros + "1.2", "% 010000004.1f", 1.2),

arguments("-1.2", "% 01.1f", -1.2),
arguments("-1.2", "% 02.1f", -1.2),
arguments("-1.2", "% 03.1f", -1.2),
arguments("-1.2", "% 04.1f", -1.2),
arguments("-01.2", "% 05.1f", -1.2),
arguments("-0000001.2", "% 010.1f", -1.2),
arguments("-" + tenMillionZeros + "1.2", "% 010000004.1f", -1.2),

};
}