< prev index next >
test/jdk/java/util/Formatter/Constructors.java
Print this page
@@ -399,16 +399,27 @@
fail("new Formatter((OutputStream) null, \"ISO-8859-1\", Locale.UK)",
x);
}
try (PrintStream ps = new PrintStream("foo")) {
- new Formatter(ps, null, Locale.UK);
- fail("new Formatter(new PrintStream(\"foo\"), null, Locale.UK)");
+ new Formatter(ps, (String)null, Locale.UK);
+ fail("new Formatter(new PrintStream(\"foo\"), (String)null, Locale.UK)");
} catch (NullPointerException x) {
pass();
} catch (Exception x) {
- fail("new Formatter(new PrintStream(\"foo\"), null, Locale.UK)",
+ fail("new Formatter(new PrintStream(\"foo\"), (String)null, Locale.UK)",
+ x);
+ }
+
+ // Formatter(OutputStream os, Charset charset, Locale l)
+ try (PrintStream ps = new PrintStream("foo")) {
+ new Formatter(ps, (Charset)null, Locale.UK);
+ fail("new Formatter(new PrintStream(\"foo\"), (Charset)null, Locale.UK)");
+ } catch (NullPointerException x) {
+ pass();
+ } catch (Exception x) {
+ fail("new Formatter(new PrintStream(\"foo\"), (Charset)null, Locale.UK)",
x);
}
try (PrintStream ps = new PrintStream("foo")) {
new Formatter(ps, "bar", Locale.UK);
@@ -436,16 +447,26 @@
fail("new PrintStream(\"foo\")", x);
}
// PrintStream(String fileName, String csn)
try {
- new PrintStream("foo", null);
- fail("new PrintStream(\"foo\", null)");
+ new PrintStream("foo", (String)null);
+ fail("new PrintStream(\"foo\", (String)null)");
+ } catch (NullPointerException x) {
+ pass();
+ } catch (Exception x) {
+ fail("new PrintStream(\"foo\", (String)null)", x);
+ }
+
+ // PrintStream(String fileName, Charset charset)
+ try {
+ new PrintStream("foo", (Charset)null);
+ fail("new PrintStream(\"foo\", (Charset)null)");
} catch (NullPointerException x) {
pass();
} catch (Exception x) {
- fail("new PrintStream(\"foo\", null)", x);
+ fail("new PrintStream(\"foo\", (Charset)null)", x);
}
// PrintStream(File file)
try (PrintStream ps = new PrintStream(new File("foo"))) {
pass();
@@ -453,16 +474,26 @@
fail("new PrintStream(new File(\"foo\"))", x);
}
// PrintStream(File file, String csn)
try {
- new PrintStream(new File("foo"), null);
- fail("new PrintStream(new File(\"foo\"), null)");
+ new PrintStream(new File("foo"), (String)null);
+ fail("new PrintStream(new File(\"foo\"), (String)null)");
} catch (NullPointerException x) {
pass();
} catch (Exception x) {
- fail("new PrintStream(new File(\"foo\"), null)", x);
+ fail("new PrintStream(new File(\"foo\"), (String)null)", x);
+ }
+
+ // PrintStream(File file, Charset charset)
+ try {
+ new PrintStream(new File("foo"), (Charset)null);
+ fail("new PrintStream(new File(\"foo\"), (Charset)null)");
+ } catch (NullPointerException x) {
+ pass();
+ } catch (Exception x) {
+ fail("new PrintStream(new File(\"foo\"), (Charset)null)", x);
}
// PrintWriter(String fileName)
try (PrintWriter pw = new PrintWriter("foo")) {
pass();
@@ -470,16 +501,26 @@
fail("new PrintWriter(\"foo\")", x);
}
// PrintWriter(String fileName, String csn)
try {
- new PrintWriter("foo", null);
- fail("new PrintWriter(\"foo\"), null");
+ new PrintWriter("foo", (String)null);
+ fail("new PrintWriter(\"foo\"), (String)null");
} catch (NullPointerException x) {
pass();
} catch (Exception x) {
- fail("new PrintWriter(\"foo\"), null", x);
+ fail("new PrintWriter(\"foo\"), (String)null", x);
+ }
+
+ // PrintWriter(String fileName, Charset charset)
+ try {
+ new PrintWriter("foo", (Charset)null);
+ fail("new PrintWriter(\"foo\"), (Charset)null");
+ } catch (NullPointerException x) {
+ pass();
+ } catch (Exception x) {
+ fail("new PrintWriter(\"foo\"), (Charset)null", x);
}
// PrintWriter(File file)
try (PrintWriter pw = new PrintWriter(new File("foo"))) {
pass();
@@ -487,16 +528,26 @@
fail("new PrintWriter(new File(\"foo\"))", x);
}
// PrintWriter(File file, String csn)
try {
- new PrintWriter(new File("foo"), null);
- fail("new PrintWriter(new File(\"foo\")), null");
+ new PrintWriter(new File("foo"), (String)null);
+ fail("new PrintWriter(new File(\"foo\")), (String)null");
+ } catch (NullPointerException x) {
+ pass();
+ } catch (Exception x) {
+ fail("new PrintWriter(new File(\"foo\")), (String)null", x);
+ }
+
+ // PrintWriter(File file, Charset charset)
+ try {
+ new PrintWriter(new File("foo"), (Charset)null);
+ fail("new PrintWriter(new File(\"foo\")), (Charset)null");
} catch (NullPointerException x) {
pass();
} catch (Exception x) {
- fail("new PrintWriter(new File(\"foo\")), null", x);
+ fail("new PrintWriter(new File(\"foo\")), (Charset)null", x);
}
if (fail != 0)
throw new RuntimeException((fail + pass) + " tests: "
+ fail + " failure(s), first", first);
< prev index next >