-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
427 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...en-core-parent/cobigen-core-api/src/test/java/com/devonfw/cobigen/api/StringUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.devonfw.cobigen.api; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.Test; | ||
|
||
import com.devonfw.cobigen.api.util.StringUtil; | ||
|
||
/** | ||
* | ||
*/ | ||
public class StringUtilTest { | ||
|
||
/** Testdata root path */ | ||
private static final String testdataRoot = "src/test/resources/testdata/unittest/StringUtilTest"; | ||
|
||
/** | ||
* Tests whether consolidateLineEndings returns proper line endings for Windows, Linux and Osx | ||
* @throws Exception | ||
* test fails | ||
*/ | ||
@Test | ||
public void testConsolidateLineEndings() throws Exception { | ||
String origin = "\n"; | ||
String origin2 = "\r\n"; | ||
String lineDelimiterWindows = "\r\n"; | ||
String lineDelimiterLinux = "\n"; | ||
String lineDelimiterOsx = "\r"; | ||
String consolidatedWindows = StringUtil.consolidateLineEndings(origin, lineDelimiterWindows); | ||
String consolidatedLinux = StringUtil.consolidateLineEndings(origin2, lineDelimiterLinux); | ||
String consolidatedOsx = StringUtil.consolidateLineEndings(origin, lineDelimiterOsx); | ||
assertThat(consolidatedWindows).isEqualTo(lineDelimiterWindows); | ||
assertThat(consolidatedLinux).isEqualTo(lineDelimiterLinux); | ||
assertThat(consolidatedOsx).isEqualTo(lineDelimiterOsx); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...en-core-parent/cobigen-core-api/src/test/java/com/devonfw/cobigen/api/SystemUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.devonfw.cobigen.api; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
import org.junit.Test; | ||
|
||
import com.devonfw.cobigen.api.util.SystemUtil; | ||
|
||
/** Test suite for {@link SystemUtil}. */ | ||
public class SystemUtilTest { | ||
|
||
/** Testdata root path */ | ||
private static final String testdataRoot = "src/test/resources/testdata/unittest/SystemUtilTest"; | ||
|
||
/** | ||
* Tests whether determineLineDelimiter returns Linux line endings | ||
* @throws Exception | ||
* test fails | ||
*/ | ||
@Test | ||
public void testDetermineLineDelimiterLinux() throws Exception { | ||
Path path = Paths.get(testdataRoot, "TestLinuxLineEndings.txt"); | ||
String targetCharset = "UTF-8"; | ||
String lineEnding = SystemUtil.determineLineDelimiter(path, targetCharset); | ||
assertThat(lineEnding).isEqualTo("\n"); | ||
} | ||
|
||
/** | ||
* Tests whether determineLineDelimiter returns Windows line endings | ||
* @throws Exception | ||
* test fails | ||
*/ | ||
@Test | ||
public void testDetermineLineDelimiterWindows() throws Exception { | ||
Path path = Paths.get(testdataRoot, "TestWindowsLineEndings.txt"); | ||
String targetCharset = "UTF-8"; | ||
String lineEnding = SystemUtil.determineLineDelimiter(path, targetCharset); | ||
assertThat(lineEnding).isEqualTo("\r\n"); | ||
} | ||
|
||
/** | ||
* Tests whether determineLineDelimiter returns Osx line endings | ||
* @throws Exception | ||
* test fails | ||
*/ | ||
@Test | ||
public void testDetermineLineDelimiterOsx() throws Exception { | ||
Path path = Paths.get(testdataRoot, "TestOsxLineEndings.txt"); | ||
String targetCharset = "UTF-8"; | ||
String lineEnding = SystemUtil.determineLineDelimiter(path, targetCharset); | ||
assertThat(lineEnding).isEqualTo("\r"); | ||
} | ||
|
||
} |
2 changes: 2 additions & 0 deletions
2
...gen-core-api/src/test/resources/testdata/unittest/SystemUtilTest/TestLinuxLineEndings.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
a | ||
b |
1 change: 1 addition & 0 deletions
1
...bigen-core-api/src/test/resources/testdata/unittest/SystemUtilTest/TestOsxLineEndings.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ef | ||
|
2 changes: 2 additions & 0 deletions
2
...n-core-api/src/test/resources/testdata/unittest/SystemUtilTest/TestWindowsLineEndings.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
c | ||
d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.