Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How are the validations covered by tests ? #950

Closed
bogeeee opened this issue Feb 5, 2024 · 3 comments
Closed

Question: How are the validations covered by tests ? #950

bogeeee opened this issue Feb 5, 2024 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@bogeeee
Copy link

bogeeee commented Feb 5, 2024

Question

Hi Samchon !

You sayed :

Furthermore, I've enhanced typia through 1,000,000 LOC test codes. Considering characteristics of typia using pure TypeScript type, typia must support every TypeScript type cases.

Can you explain, where in source code you cover the validations ?
I.e. by a simple example:

type MyType = number | boolean
assertEquals<MyType>("anEvilString")

So, where under test/src is the code, that covers a union type. I.e. i found this one: test/src/structures/AtomicUnion.ts ? How does it exactly go till there.
Also: Is the code under test/src/features all generated ? So, as i see, 1million LOC rather means mostly the generated code, right ?

The next question. As there's already much work put into the tests or structures: Might it be technically possible to take these to test the validation code in the typescript-rtti library ? What could be the hurdes ?

Thx for an answer and keep on that good project !

@samchon
Copy link
Owner

samchon commented Feb 8, 2024

Yes, all of the test files under the test/features director are automatically generated. All of automatically generated test functions are performing their detailed tests by calling functions of test/src/internal folder.

For ference, the test code generation program starts from the test/build/template.ts file.

Also, I think it may possible to validate the typescript-rtti by same way with me, and it would be meaningful taking test structures of typia and test the typescript-rtti with them. Also, you can utilize typia.random<T>() function to generate random test data, and you can damage the structured data by calling Structure.SPOILERS[i](value) fuction.

https://github.com/samchon/typia/blob/master/test/src/structures/ObjectHierarchical.ts#L112-L178

@samchon samchon self-assigned this Feb 8, 2024
@samchon samchon added the question Further information is requested label Feb 8, 2024
@bogeeee
Copy link
Author

bogeeee commented Feb 25, 2024

Hey samchon,
I had first success on running your test structures against typescript-rtti :) :) :) nice
Still i need to somehow filter out the structures that make only sense for typia but i don't understand all the TestStructure flags. So could you please jsdoc these flags here ?
Thanks !

@samchon
Copy link
Owner

samchon commented Feb 26, 2024

As typia is supporting not only validators, but also supporting many other features like protobuf.

By the way, in the protobuf case, its expression power is much lower than TypeScript. Therefore, it is not possible to make protobuf test functions for every structures case. The TestStructure type represents the spec that whether each structure can be used in each feature or not.

For example, NativeSimple structure can't be used in both JSON and Protobuf functions.

@samchon samchon closed this as completed Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants