### Question:
RegionMask implements Grid { public static RegionMask create(String name, String data) throws ParseException { final boolean[][] samples = new boolean[height][width]; final StringTokenizer stringTokenizer = new StringTokenizer(data, "\n"); int lineNo = 0; int y = 0; while (stringTokenizer.hasMoreTokens()) { lineNo++; String line = stringTokenizer.nextToken().trim(); if (!line.isEmpty() && !line.startsWith("#")) { if (line.length() != width) { throw new ParseException(String.format("Region %s: Illegal mask format in line %d: Line must contain exactly %d characters, but found %d.", name, lineNo, width, line.length()), 0); } for (int x = 0; x < width; x++) { char c = line.charAt(x); if (c != '0' && c != '1') { throw new ParseException(String.format("Region %s: Illegal mask format in line %d: Only use characters '0' and '1'.", name, lineNo), x); } if (c == '1') { samples[y][x] = true; } } y++; } } if (y != height) { throw new ParseException(String.format("Region %s: Illegal mask format in line %d: Exactly %d lines are required, but found %d.", name, lineNo, height, y), 0); } return new RegionMask(name, samples); } private  RegionMask(String name, boolean[][] samples); static void setSpatialResolution(SpatialResolution spatialResolution); static RegionMask create(String name, String data); static RegionMask create(String name, double west, double north, double east, double south); String getName(); Coverage getCoverage(); int getWidth(); int getHeight(); @Override GridDef getGridDef(); @Override boolean getSampleBoolean(int gridX, int gridY); @Override int getSampleInt(int gridX, int gridY); @Override double getSampleDouble(int gridX, int gridY); static RegionMask combine(RegionMaskList regionMaskList);  }### Answer:
@Test public void testCreate_invalidLineWidth() { final char[] data = createData(56, 36); try { RegionMask.create("test", new String(data)); fail("ParseException expected"); } catch (ParseException expected) { } }
@Test public void testCreate_invalidHeight() { final char[] data = createData(73, 11); try { RegionMask.create("test", new String(data)); fail("ParseException expected"); } catch (ParseException expected) { } }
@Test public void testCreate_invalidData() { final char[] data = createData(73, 36); set(data, 11, 19, 'I'); try { RegionMask.create("test", new String(data)); fail("ParseException expected"); } catch (ParseException expected) { } }
@Test public void testCreate_southBelowNorth() { try { RegionMask.create("X", 0, 10, 10, 20); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { } }