Skip to content

Commit

Permalink
Rename all of the test cases to not use the '.java' extension
Browse files Browse the repository at this point in the history
This prevents the formatter from clobbering test data.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=94804227
  • Loading branch information
cushon committed Jun 4, 2015
1 parent e47e022 commit 3fd5e83
Show file tree
Hide file tree
Showing 109 changed files with 8 additions and 7 deletions.
Expand Up @@ -14,6 +14,8 @@


package com.google.googlejavaformat.java; package com.google.googlejavaformat.java;


import static com.google.common.io.Files.getFileExtension;
import static com.google.common.io.Files.getNameWithoutExtension;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -61,21 +63,20 @@ public void testFormatter() throws Exception {
Path resourceNamePath = Paths.get(resourceName); Path resourceNamePath = Paths.get(resourceName);
if (resourceNamePath.startsWith(testDataPath)) { if (resourceNamePath.startsWith(testDataPath)) {
Path subPath = testDataPath.relativize(resourceNamePath); Path subPath = testDataPath.relativize(resourceNamePath);
assertEquals("bad testdata file names", 2, subPath.getNameCount()); assertEquals("bad testdata file names", 1, subPath.getNameCount());
String dirName = subPath.getName(0).toString(); String baseName = getNameWithoutExtension(subPath.getFileName().toString());
String fileName = subPath.getName(1).toString(); String extension = getFileExtension(subPath.getFileName().toString());
assertThat(fileName).endsWith(".java");
final String stringFromStream; final String stringFromStream;
try (InputStream stream = classLoader.getResourceAsStream(resourceName)) { try (InputStream stream = classLoader.getResourceAsStream(resourceName)) {
stringFromStream = stringFromStream =
CharStreams.toString(new InputStreamReader(stream, StandardCharsets.UTF_8)); CharStreams.toString(new InputStreamReader(stream, StandardCharsets.UTF_8));
} }
switch (dirName) { switch (extension) {
case "input": case "input":
inputs.put(fileName, stringFromStream); inputs.put(baseName, stringFromStream);
break; break;
case "output": case "output":
outputs.put(fileName, stringFromStream); outputs.put(baseName, stringFromStream);
break; break;
default: default:
} }
Expand Down

0 comments on commit 3fd5e83

Please sign in to comment.