Skip to content

Commit

Permalink
Test program also assert equailty
Browse files Browse the repository at this point in the history
  • Loading branch information
samchon committed Dec 10, 2024
1 parent 287f6b8 commit 08cb922
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 18 deletions.
2 changes: 1 addition & 1 deletion test/src/internal/_test_functional_validateFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const _test_functional_validateFunction =
throw new Error(
`Bug on typia.functional.validateFunction(): failed to detect error on the ${name} type.`,
);
typia.assert(valid);
typia.assertEquals(valid);
valid.errors.sort((x, y) => (x.path < y.path ? -1 : 1));

if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const _test_functional_validateFunctionAsync =
throw new Error(
`Bug on await typia.functional.validateFunction(): failed to detect error on the ${name} type.`,
);
typia.assert(valid);
typia.assertEquals(valid);
valid.errors.sort((x, y) => (x.path < y.path ? -1 : 1));

if (
Expand Down
2 changes: 1 addition & 1 deletion test/src/internal/_test_functional_validateParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const _test_functional_validateParameters =
throw new Error(
`Bug on typia.functional.validateFunction(): failed to detect error on the ${name} type.`,
);
typia.assert(valid);
typia.assertEquals(valid);
valid.errors.sort((x, y) => (x.path < y.path ? -1 : 1));

if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const _test_functional_validateParametersAsync =
throw new Error(
`Bug on await typia.functional.validateFunction(): failed to detect error on the ${name} type.`,
);
typia.assert(valid);
typia.assertEquals(valid);
valid.errors.sort((x, y) => (x.path < y.path ? -1 : 1));

if (
Expand Down
2 changes: 1 addition & 1 deletion test/src/internal/_test_functional_validateReturn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const _test_functional_validateReturn =
throw new Error(
`Bug on typia.functional.validateFunction(): failed to detect error on the ${name} type.`,
);
typia.assert(valid);
typia.assertEquals(valid);
valid.errors.sort((x, y) => (x.path < y.path ? -1 : 1));

if (
Expand Down
3 changes: 2 additions & 1 deletion test/src/internal/_test_http_validateFormData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const _test_http_validateFormData =
throw new Error(
`Bug on typia.http.validateFormData(): failed to understand ${name} type.`,
);
typia.assertEquals<typia.IValidation.ISuccess<unknown>>(result);

const equal: boolean =
result !== null && resolved_equal_to(name)(data, result.data);
Expand All @@ -38,7 +39,7 @@ export const _test_http_validateFormData =
`Bug on typia.http.validateFormData(): failed to detect error on the ${name} type.`,
);

typia.assert(valid);
typia.assertEquals(valid);
expected.sort();
valid.errors.sort((x, y) => (x.path < y.path ? -1 : 1));

Expand Down
3 changes: 2 additions & 1 deletion test/src/internal/_test_http_validateHeaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const _test_http_validateHeaders =
throw new Error(
`Bug on typia.http.validateHeaders(): failed to understand ${name} type.`,
);
typia.assertEquals<typia.IValidation.ISuccess<unknown>>(result);

const equal: boolean =
result !== null && resolved_equal_to(name)(data, result.data);
Expand All @@ -43,7 +44,7 @@ export const _test_http_validateHeaders =
`Bug on typia.http.validateHeaders(): failed to detect error on the ${name} type.`,
);

typia.assert(valid);
typia.assertEquals(valid);
expected.sort();
valid.errors.sort((x, y) => (x.path < y.path ? -1 : 1));

Expand Down
3 changes: 2 additions & 1 deletion test/src/internal/_test_http_validateQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const _test_http_validateQuery =
throw new Error(
`Bug on typia.http.validateQuery(): failed to understand ${name} type.`,
);
typia.assertEquals<typia.IValidation.ISuccess<unknown>>(result);

const equal: boolean =
result !== null && resolved_equal_to(name)(data, result.data);
Expand All @@ -38,7 +39,7 @@ export const _test_http_validateQuery =
`Bug on typia.http.validateQuery(): failed to detect error on the ${name} type.`,
);

typia.assert(valid);
typia.assertEquals(valid);
expected.sort();
valid.errors.sort((x, y) => (x.path < y.path ? -1 : 1));

Expand Down
1 change: 1 addition & 0 deletions test/src/internal/_test_json_validateParse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const _test_json_validateParse =
`Bug on typia.json.validateParse(): failed to understand the ${name} type.`,
);
}
typia.assertEquals<IValidation.ISuccess<unknown>>(valid);

const wrong: ISpoiled[] = [];
for (const spoil of factory.SPOILERS ?? []) {
Expand Down
3 changes: 2 additions & 1 deletion test/src/internal/_test_json_validateStringify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const _test_json_validateStringify =
`Bug on typia.json.validateStringify(): failed to understand the ${name} type.`,
);

typia.assertEquals(valid);
if (predicate(input, valid.data) === false) {
throw new Error(
`Bug on typia.json.validateStringify(): failed to understand the ${name} type.`,
Expand All @@ -32,7 +33,7 @@ export const _test_json_validateStringify =
`Bug on typia.json.validateStringify(): failed to detect error on the ${name} type.`,
);

typia.assert(valid);
typia.assertEquals(valid);
expected.sort();
valid.errors.sort((x, y) => (x.path < y.path ? -1 : 1));

Expand Down
3 changes: 2 additions & 1 deletion test/src/internal/_test_misc_validateClone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const _test_misc_validateClone =
`Bug on typia.misc.validateClone(): failed to understand the ${name} type.`,
);

typia.assertEquals<typia.IValidation.ISuccess<unknown>>(valid);
if (resolved_equal_to(name)(input, valid.data) === false) {
throw new Error(
`Bug on typia.misc.validateClone(): failed to understand the ${name} type.`,
Expand All @@ -32,7 +33,7 @@ export const _test_misc_validateClone =
`Bug on typia.misc.validateClone(): failed to detect error on the ${name} type.`,
);

typia.assert(valid);
typia.assertEquals(valid);
expected.sort();
valid.errors.sort((x, y) => (x.path < y.path ? -1 : 1));

Expand Down
4 changes: 2 additions & 2 deletions test/src/internal/_test_misc_validatePrune.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IValidation, assert } from "typia";
import { IValidation, assertEquals } from "typia";

import { TestStructure } from "../helpers/TestStructure";

Expand Down Expand Up @@ -45,7 +45,7 @@ export const _test_misc_validatePrune =
`Bug on typia.misc.validatePrune(): failed to detect error on the ${name} type.`,
);

assert(valid);
assertEquals(valid);
expected.sort();
valid.errors.sort((x, y) => (x.path < y.path ? -1 : 1));

Expand Down
4 changes: 3 additions & 1 deletion test/src/internal/_test_notation_validateGeneral.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IValidation } from "typia";
import typia, { IValidation } from "typia";

import { TestStructure } from "../helpers/TestStructure";
import { _test_notation_general } from "./_test_notation_general";
Expand All @@ -19,6 +19,7 @@ export const _test_notation_validateGeneral =
throw new Error(
`Bug on typia.notations.validateX(): failed to understand the ${name} type.`,
);
typia.assertEquals<IValidation.ISuccess<unknown>>(res);
return res.data;
},
})();
Expand All @@ -34,6 +35,7 @@ export const _test_notation_validateGeneral =
`Bug on typia.notations.validateX(): failed to detect error on the ${name} type.`,
);

typia.assertEquals(valid);
expected.sort();
valid.errors.sort((x, y) => (x.path < y.path ? -1 : 1));

Expand Down
3 changes: 2 additions & 1 deletion test/src/internal/_test_protobuf_validateDecode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import typia from "typia";
import typia, { IValidation } from "typia";

import { _test_protobuf_decode } from "./_test_protobuf_decode";

Expand All @@ -14,6 +14,7 @@ export const _test_protobuf_validateDecode =
decode: (input) => {
const result = functor.decode(input);
if (!result.success) throw new Error();
typia.assertEquals<IValidation.ISuccess<unknown>>(result);
return result.data;
},
encode: functor.encode,
Expand Down
3 changes: 2 additions & 1 deletion test/src/internal/_test_protobuf_validateEncode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const _test_protobuf_validateEncode =
encode: (input: T) => {
const result: typia.IValidation<Uint8Array> = functor.encode(input);
if (!result.success) throw new Error();
typia.assertEquals(result);
return result.data;
},
})();
Expand All @@ -33,7 +34,7 @@ export const _test_protobuf_validateEncode =
`Bug on typia.json.validateEncode(): failed to detect error on the ${name} type.`,
);

typia.assert(valid);
typia.assertEquals(valid);
expected.sort();
valid.errors.sort((x, y) => (x.path < y.path ? -1 : 1));

Expand Down
4 changes: 2 additions & 2 deletions test/src/internal/_test_validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const _test_validate =
throw new Error(
"Bug on typia.validate(): failed to archive the input value.",
);
typia.assert(valid);
typia.assertEquals(valid);

const wrong: ISpoiled[] = [];
for (const spoil of factory.SPOILERS ?? []) {
Expand All @@ -30,7 +30,7 @@ export const _test_validate =
`Bug on typia.validate(): failed to detect error on the ${name} type.`,
);

typia.assert(valid);
typia.assertEquals(valid);
expected.sort();
valid.errors.sort((x, y) => (x.path < y.path ? -1 : 1));

Expand Down
2 changes: 1 addition & 1 deletion test/src/internal/_test_validateEquals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const _test_validateEquals =
throw new Error(
"Bug on typia.validateEquals(): failed to archive the input value.",
);
typia.assert(valid);
typia.assertEquals(valid);
if (factory.ADDABLE === false) return;

// EXPECTED
Expand Down

0 comments on commit 08cb922

Please sign in to comment.