MCPcopy Index your code
hub / github.com/oshi/oshi / testReadFile

Method testReadFile

oshi-core/src/test/java/oshi/util/FileUtilTest.java:77–97  ·  view source on GitHub ↗

Test read file.

()

Source from the content-addressed store, hash-verified

75 * Test read file.
76 */
77 @Test
78 void testReadFile() {
79 // Try file not found
80 assertThat("no file", FileUtil.readFile(NO_FILE), is(empty()));
81 // Try this file
82 List<String> thisFile = FileUtil.readFile(THISCLASS);
83 // Comment ONE line
84 int lineOne = 0;
85 // Comment TWO line
86 int lineTwo = 0;
87 for (int i = 0; i < thisFile.size(); i++) {
88 String line = thisFile.get(i);
89 if (lineOne == 0 && line.contains("Comment ONE line")) {
90 lineOne = i;
91 } else if (lineTwo == 0 && line.contains("Comment TWO line")) {
92 lineTwo = i;
93 break;
94 }
95 }
96 assertThat("Comment line difference", lineTwo - lineOne, is(2));
97 }
98
99 /**
100 * Test get*FromFile

Callers

nothing calls this directly

Calls 3

readFileMethod · 0.95
assertThatMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected