-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from FHIR/2023-07-gg-more-test-cases
- Loading branch information
Showing
8 changed files
with
138 additions
and
12 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
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,29 @@ | ||
package org.fhir.ucum; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.junit.Assert.assertThrows; | ||
|
||
import java.io.File; | ||
import java.io.InputStream; | ||
import java.io.FileInputStream; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class UcumTestsIssue21 { | ||
|
||
@Test | ||
public void testMileConversion() throws IOException, UcumException { | ||
|
||
String fileName = "ucum-essence.xml"; | ||
ClassLoader classLoader = getClass().getClassLoader(); | ||
File file = new File(classLoader.getResource(fileName).getFile()); | ||
InputStream inputStream = new FileInputStream(file); | ||
UcumEssenceService ucumService = new UcumEssenceService(inputStream); | ||
|
||
Decimal m = ucumService.convert(new Decimal("1",15), "[mi_i]","m"); | ||
Assert.assertEquals("1609", m.asDecimal()); // because UCUM value for cm is wrong precision | ||
} | ||
|
||
} |
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,34 @@ | ||
package org.fhir.ucum; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.junit.Assert.assertThrows; | ||
|
||
import java.io.File; | ||
import java.io.InputStream; | ||
import java.io.FileInputStream; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class UcumTestsIssue22 { | ||
|
||
@Test | ||
public void testDegreeConversion() throws IOException, UcumException { | ||
|
||
String fileName = "ucum-essence.xml"; | ||
ClassLoader classLoader = getClass().getClassLoader(); | ||
File file = new File(classLoader.getResource(fileName).getFile()); | ||
InputStream inputStream = new FileInputStream(file); | ||
UcumEssenceService ucumService = new UcumEssenceService(inputStream); | ||
|
||
assertThrows(UcumException.class, () -> { | ||
ucumService.convert(new Decimal("100", 15), "Cel", "K"); | ||
}); | ||
|
||
assertThrows(UcumException.class, () -> { | ||
ucumService.convert(new Decimal("100", 15), "[degF]", "Cel"); | ||
}); | ||
} | ||
|
||
} |