ZigRazor / CXXGraph

Header-Only C++ Library for Graph Representation and Algorithms
https://zigrazor.github.io/CXXGraph/
Mozilla Public License 2.0
463 stars 113 forks source link

Randomly Shuffling Access Ordering of Graphs #439

Open edogawashinichi opened 5 months ago

edogawashinichi commented 5 months ago

Is your feature request related to a problem? Please describe. issue433 issue408 Bug-free code is rare in medium and large projects. Therefore, test coverage is extremely important. Due to differences in operating systems, compilers, etc., the access order of graphs in test cases may also differ, which may cause test cases to behave differently.

Describe the solution you'd like By randomly shuffling the access order of the graph, we can easily obtain a large number of equivalent test cases, allowing us to find hidden bugs as much as possible. So I propose to add a test class between the test case and the graph class to allow random access.

Describe alternatives you've considered Open a test branch,and add this feature to it.

Additional context Add any other context or screenshots about the feature request here.

edogawashinichi commented 5 months ago

I have implemented the alternative locally. You do have the opportunity to find more bugs each time you run the test cases.

image
edogawashinichi commented 5 months ago

and more bugs I've found

image
nolankramer commented 5 months ago

This is a great idea - as long as we can always reproduce test cases by using the same seed. Fuzzing is a great way to ensure robust coverage and functionality.

edogawashinichi commented 5 months ago

This is a great idea - as long as we can always reproduce test cases by using the same seed. Fuzzing is a great way to ensure robust coverage and functionality.

Yep, technically using the same seed is a precise and efficient way. Currently the method I use is to save the vertex traversal ordering of the buggy test case.

ZigRazor commented 5 months ago

Good Idea!

badumbatish commented 5 months ago

@edogawashinichi this must be what you're referring to in #433

I hope it's not too much to ask but would you please create a draft PR? would love to learn how to implement this

edogawashinichi commented 5 months ago

@edogawashinichi this must be what you're referring to in #433

I hope it's not too much to ask but would you please create a draft PR? would love to learn how to implement this

Sure, I just implement a very rough test branch that help trace bugs caused by ordering.

image