# HG changeset patch # User Chris Seaton # Date 1410381506 -3600 # Node ID 174f78c2474706afc5a9168f2d21ef455a0d51cc # Parent 86888df288ec3fe1afdba4c16dedcd2980ce2443 Truffle: simplify byte section tests. diff -r 86888df288ec -r 174f78c24747 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/source/BytesSourceSectionTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/source/BytesSourceSectionTest.java Wed Sep 10 11:44:39 2014 +0200 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/source/BytesSourceSectionTest.java Wed Sep 10 21:38:26 2014 +0100 @@ -34,7 +34,7 @@ @Test public void testSectionsFromLineNumberASCII() { - final byte[] bytes = "foo\nbar\nbaz\n".getBytes(StandardCharsets.UTF_8); + final byte[] bytes = "foo\nbar\nbaz\n".getBytes(StandardCharsets.US_ASCII); final Source source = Source.fromBytes(bytes, "description", new BytesDecoder.UTF8BytesDecoder()); assertEquals("foo", source.createSection("identifier", 1).getCode()); assertEquals("bar", source.createSection("identifier", 2).getCode()); @@ -43,7 +43,7 @@ @Test public void testSectionsFromOffsetsASCII() { - final byte[] bytes = "foo\nbar\nbaz\n".getBytes(StandardCharsets.UTF_8); + final byte[] bytes = "foo\nbar\nbaz\n".getBytes(StandardCharsets.US_ASCII); final Source source = Source.fromBytes(bytes, "description", new BytesDecoder.UTF8BytesDecoder()); assertEquals("foo", source.createSection("identifier", 0, 3).getCode()); assertEquals("bar", source.createSection("identifier", 4, 3).getCode()); @@ -51,28 +51,8 @@ } @Test - public void testSectionsFromLineNumberUTF8() { - // ☃ is three bytes in UTF8 - final byte[] bytes = "foo\n☃\nbaz\n".getBytes(StandardCharsets.UTF_8); - final Source source = Source.fromBytes(bytes, "description", new BytesDecoder.UTF8BytesDecoder()); - assertEquals("foo", source.createSection("identifier", 1).getCode()); - assertEquals("☃", source.createSection("identifier", 2).getCode()); - assertEquals("baz", source.createSection("identifier", 3).getCode()); - } - - @Test - public void testSectionsFromOffsetsUTF8() { - // ☃ is three bytes in UTF8 - final byte[] bytes = "foo\n☃\nbaz\n".getBytes(StandardCharsets.UTF_8); - final Source source = Source.fromBytes(bytes, "description", new BytesDecoder.UTF8BytesDecoder()); - assertEquals("foo", source.createSection("identifier", 0, 3).getCode()); - assertEquals("☃", source.createSection("identifier", 4, 3).getCode()); - assertEquals("baz", source.createSection("identifier", 8, 3).getCode()); - } - - @Test public void testOffset() { - final byte[] bytes = "xxxfoo\nbar\nbaz\nxxx".getBytes(StandardCharsets.UTF_8); + final byte[] bytes = "xxxfoo\nbar\nbaz\nxxx".getBytes(StandardCharsets.US_ASCII); final Source source = Source.fromBytes(bytes, 3, bytes.length - 6, "description", new BytesDecoder.UTF8BytesDecoder()); assertEquals("foo", source.createSection("identifier", 0, 3).getCode()); assertEquals("bar", source.createSection("identifier", 4, 3).getCode());