diff graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/source/BytesSourceSectionTest.java @ 17095:174f78c24747

Truffle: simplify byte section tests.
author Chris Seaton <chris.seaton@oracle.com>
date Wed, 10 Sep 2014 21:38:26 +0100
parents 0bcefb0f8488
children
line wrap: on
line diff
--- 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());