-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
54fd34c
commit 944197b
Showing
7 changed files
with
75 additions
and
63 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import davidkhala.common.CountryTool; | ||
import org.junit.Test; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class CountryTest { | ||
@Test | ||
public void getNames() { | ||
ArrayList<String> names = CountryTool.getNames(); | ||
assert names.contains("Hong Kong SAR China"); | ||
assert names.size() == 252; | ||
} | ||
@Test | ||
public void validateHKID() { | ||
String id = "D788888(1)"; | ||
assert CountryTool.isHKIDValid(id); | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -1,32 +1,33 @@ | ||
import davidkhala.common.FileTool; | ||
import org.junit.Test; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URI; | ||
import org.junit.Test; | ||
|
||
public class FileTest { | ||
@Test | ||
public void create_delete() throws IOException { | ||
String fileName = "dummy.txt"; | ||
File file = new File(fileName); | ||
String extension = FileTool.getExtensionName(fileName); | ||
assert extension.equals("txt"); | ||
FileTool.write(file, "txt"); | ||
file.deleteOnExit(); | ||
} | ||
@Test | ||
public void create_delete() throws IOException { | ||
String fileName = "dummy.txt"; | ||
File file = new File(fileName); | ||
String extension = FileTool.getExtensionName(fileName); | ||
assert extension.equals("txt"); | ||
FileTool.write(file, "txt"); | ||
file.deleteOnExit(); | ||
} | ||
|
||
@Test | ||
public void createDir() throws IOException { | ||
File file = new File("temp"); | ||
assert file.mkdirs(); | ||
file.deleteOnExit(); | ||
} | ||
@Test | ||
public void createDir() { | ||
File file = new File("temp"); | ||
assert file.mkdirs(); | ||
file.deleteOnExit(); | ||
} | ||
|
||
@Test | ||
public void fromURITest() throws IOException { | ||
String uriStr = "file:/C:/Users/david/Downloads/"; | ||
URI uri = URI.create(uriStr); | ||
File file = new File(uri); | ||
assert file.toURI().toString().equals(uriStr); | ||
} | ||
@Test | ||
public void fromURITest() { | ||
String uriStr = "file:/C:/Users/"; | ||
URI uri = URI.create(uriStr); | ||
File file = new File(uri); | ||
assert file.toURI().toString().equals(uriStr); | ||
} | ||
} |
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,24 @@ | ||
import davidkhala.common.AbstractPropertiesLoader; | ||
import davidkhala.common.Stream; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Properties; | ||
|
||
public class PropertiesLoaderTest { | ||
@Test | ||
public void loadProperties() throws IOException { | ||
|
||
AbstractPropertiesLoader loader = new AbstractPropertiesLoader(){ | ||
|
||
@Override | ||
protected InputStream propertiesProvider() throws IOException { | ||
return Stream.from("a=b"); | ||
} | ||
}; | ||
Properties properties = loader.getProperties(); | ||
System.out.println(properties); | ||
assert properties.get("a").equals("b"); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.