Skip to content

Commit

Permalink
fix file content unit tests, add entries to index.ts (#521)
Browse files Browse the repository at this point in the history
  • Loading branch information
hcyang authored Feb 4, 2020
1 parent 94c660f commit c21b8d5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
10 changes: 10 additions & 0 deletions packages/dispatcher/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,19 @@ import { mainCrossValidatorWithColumnarContent } from "./model/evaluation/cross_
import { mainCrossValidatorWithLuContent } from "./model/evaluation/cross_validation/AppCrossValidator";
import { mainCrossValidator } from "./model/evaluation/cross_validation/AppCrossValidator";

import { mainPredictor } from "./model/evaluation/predict/AppPredictor";

import { mainDataProfileReporter } from "./model/evaluation/report/AppDataProfileReporter";
import { mainModelMetaDataProfileReporter } from "./model/evaluation/report/AppModelMetaDataProfileReporter";
import { mainThresholdReporter } from "./model/evaluation/report/AppThresholdReporter";

export default {
AppAutoActiveLearner,
mainCrossValidator,
mainCrossValidatorWithLuContent,
mainCrossValidatorWithColumnarContent,
mainPredictor,
mainDataProfileReporter,
mainModelMetaDataProfileReporter,
mainThresholdReporter,
};
7 changes: 7 additions & 0 deletions packages/dispatcher/src/utility/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,13 @@ export class Utility {
return null;
}

public static stringToLineArray(
stringContent: string): string[] {
const lineArray: string[] = stringContent.split("\n");
const lineTrimedArray: string[] = lineArray.map((x) => x.trim());
return lineTrimedArray;
}

public static loadFile(
filename: string,
encoding: string = "utf8"): string {
Expand Down
20 changes: 16 additions & 4 deletions packages/dispatcher/test/utility/utility.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1625,8 +1625,14 @@ describe("Test Suite - utility/Utility", () => {
Utility.loadFile(filename);
Utility.debuggingLog(
`fileContent.length=${fileContent.length}`);
assert.ok(fileContent.length === 25892,
`fileContent.length=${fileContent.length}`);
const lineArray: string[] =
Utility.stringToLineArray(fileContent);
const fileContentReCombined: string =
lineArray.reduce((accumulant, entry) => accumulant += (entry + "\n"), "");
assert.ok(lineArray.length === 603,
`lineArray.length=${lineArray.length}`);
assert.ok(fileContentReCombined.length === 25291, // ---- NOTE ---- Windows file length: 25892,
`fileContentReCombined.length=${fileContentReCombined.length}`);
});
it("Test.1201 dumpFile()", function() {
Utility.toPrintDebuggingLogToConsole = UnitTestHelper.getDefaultUnitTestDebuggingLogFlag();
Expand All @@ -1638,8 +1644,14 @@ describe("Test Suite - utility/Utility", () => {
Utility.loadFile(filename);
Utility.debuggingLog(
`fileContent.length=${fileContent.length}`);
assert.ok(fileContent.length === 25892,
`fileContent.length=${fileContent.length}`);
const lineArray: string[] =
Utility.stringToLineArray(fileContent);
const fileContentReCombined: string =
lineArray.reduce((accumulant, entry) => accumulant += (entry + "\n"), "");
assert.ok(lineArray.length === 603,
`lineArray.length=${lineArray.length}`);
assert.ok(fileContentReCombined.length === 25291, // ---- NOTE ---- Windows file length: 25892,
`fileContentReCombined.length=${fileContentReCombined.length}`);
const filenameOuput: string = "resources/data/Columnar/Email_UtilityUnitTest_1201.tsv";
Utility.dumpFile(filenameOuput, fileContent);
});
Expand Down

0 comments on commit c21b8d5

Please sign in to comment.