Skip to content

Commit

Permalink
Merge remote-tracking branch 'la-vache/main' into slow-234
Browse files Browse the repository at this point in the history
  • Loading branch information
eggrobin committed May 31, 2024
2 parents 2c6b13c + 32c5ef9 commit 5a881a5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
4 changes: 3 additions & 1 deletion docs/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ We no longer post files to FTP folders, nor publish individual files without con
* org.unicode.text.UCD
* TestUnicodeInvariants.java
1. Run>Run As... Java Application\
Will create the following file of results:
Will create the following files of results:
```
{Generated}/UnicodeTestResults.txt
```
Expand Down Expand Up @@ -623,6 +623,8 @@ We no longer post files to FTP folders, nor publish individual files without con
and what are likely remedies
(changing properties, adding to an exceptions list, changing the test case).
Improve these comments as needed.
1. Additional tests for UTS #39 data are found in [unicodetools/src/main/resources/org/unicode/text/UCD/SecurityInvariantTest.txt](https://github.com/unicode-org/unicodetools/blob/main/unicodetools/src/main/resources/org/unicode/text/UCD/SecurityInvariantTest.txt).
1. These are reported in `{Generated}/UnicodeTestResults-security.txt` when running `TestTestUnicodeInvariants`.
### Options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static void main(String[] args) throws IOException {

System.out.println("HTML?\t" + doHtml);

testInvariants(file, doRange);
testInvariants(file, null, doRange);
}

static Transliterator toHTML;
Expand Down Expand Up @@ -124,34 +124,36 @@ enum Expected {
/**
* Fetch a reader for our input data.
*
* @param inputFile if null, read DEFAULT_FILE from classpath
* @param inputFile read from classpath
* @return BufferedReader
* @throws IOException
*/
private static BufferedReader getInputReader(String inputFile) throws IOException {
if (inputFile != null) {
return FileUtilities.openUTF8Reader(Settings.SRC_UCD_DIR, inputFile);
}

// null: read it from resource data
return FileUtilities.openFile(TestUnicodeInvariants.class, DEFAULT_FILE);
return FileUtilities.openFile(TestUnicodeInvariants.class, inputFile);
}

/**
* @param inputFile file to input, defaults to DEFAULT_FILE
* @param suffix Suffix for the test results report file, added after a hyphen if non-null.
* @param doRange normally true
* @return number of failures (0 is better)
* @throws IOException
*/
public static int testInvariants(String inputFile, boolean doRange) throws IOException {
public static int testInvariants(String inputFile, String suffix, boolean doRange)
throws IOException {
if (inputFile == null) {
inputFile = DEFAULT_FILE;
}
TestUnicodeInvariants.doRange = doRange;
parseErrorCount = 0;
testFailureCount = 0;
boolean showScript = false;
try (final PrintWriter out2 =
FileUtilities.openUTF8Writer(
Settings.Output.GEN_DIR,
"UnicodeTestResults." + (doHtml ? "html" : "txt"))) {
"UnicodeTestResults"
+ (suffix == null ? "" : "-" + suffix)
+ (doHtml ? ".html" : ".txt"))) {
final StringWriter writer = new StringWriter();
try (PrintWriter out3 = new PrintWriter(writer)) {
out = out3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ void testSRC_UCD_DIR() {

@Test
void testUnicodeInvariants() throws IOException {
int rc = TestUnicodeInvariants.testInvariants(null, true);
int rc = TestUnicodeInvariants.testInvariants(null, null, true);
assertEquals(0, rc, "TestUnicodeInvariants.testInvariants(default) failed");
}

@Test
void testSecurityInvariants() throws IOException {
int rc = TestUnicodeInvariants.testInvariants("SecurityInvariantTest.txt", true);
int rc =
TestUnicodeInvariants.testInvariants("SecurityInvariantTest.txt", "security", true);
assertEquals(0, rc, "TestUnicodeInvariants.testInvariants(security) failed");
}
}

0 comments on commit 5a881a5

Please sign in to comment.