Skip to content

πŸ“Œ Added Unit Tests for GraphMatrix.hpp Functions #75

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tulu-g559
Copy link

πŸ”Ή Summary

This PR adds unit tests for GraphMatrix.hpp in the test_suite/ folder, addressing the issue "Add Unit tests for GraphMatrix.hpp". The tests follow the structure defined in PR #59.

βœ… Changes Made

  • Created GraphMatrixTest.cpp in test_suite/.

  • Added tests for the following functions:

    • getEdge
    • findAllPaths
    • isConnected
    • removeVertex
    • getIsolated
  • Ensured consistency with the existing testing framework.

πŸ” Testing Done

  • Successfully compiled and executed tests using Google Test (gtest).

  • Verified expected outputs for all test cases.

πŸ“Œ Issue Reference

Closes #64

Copy link

@SharonIV0x86
Copy link
Owner

@tulu-g559

I appreciate you using the Google's testing framework, but Appledore has its own testing suite. Take a look at this PR.
#59 and implement tests accordingly.

@tulu-g559
Copy link
Author

@SharonIV0x86
Thanks for reviewing the mistake
Plz check now

@SharonIV0x86
Copy link
Owner

@SharonIV0x86 Thanks for reviewing the mistake Plz check now

It looks like your code is still using GTest.

Take a look at this short tutorial.

  1. This is how the test for a function is written in Appledore's test suite.
        void test_totalDegree()
        {
            size_t observed_value = ggraph.totalDegree(v8);
            if (observed_value == true_value_totalDegree_v8)
                printColoredText("βœ” test_totalDegree() PASSED!", ANSI_COLOR_GREEN);
            else
                printColoredText(std::format("✘ test_totalDegree() FAILED! \n\t Expected: {}, Got: {}", observed_value, true_value_totalDegree_v8), ANSI_COLOR_RED);
        }
  1. Now if you want to add a test for your function say, getEdge function and writing tests for this function is in the scope of your PR.
void test_getEdge()
        {
            int observed_edge = ggraph.getEdge(v1, v8);
            int true_edge_value = 31;
            if (observed_edge == true_edge_value)
                printColoredText("βœ” test_getEdge() PASSED!", ANSI_COLOR_GREEN);
            else
                printColoredText(std::format("✘ test_getEdge() FAILED! \n\t Expected: {}, Got: {}", true_edge_value, observed_edge), ANSI_COLOR_RED);
        }
  1. Once you have added this function in the C_TestGraphMatrix you will have to register this function in the init_tests function of the class.
void init_tests()
        {
            //other functions.
            test_getEdge(); //<- your new function to register here.
        }

I suggest you to write tests this way and remove the use of GTest.

@SharonIV0x86
Copy link
Owner

@tulu-g559 Status of your PR?

@tulu-g559
Copy link
Author

@SharonIV0x86
I am unavailable at this moment of time, plz unassign me from issue #59

@SharonIV0x86
Copy link
Owner

@SharonIV0x86 I am unavailable at this moment of time, plz unassign me from issue #59

No problem, you can work on new issues in future. πŸ‘πŸΌ

@SharonIV0x86 SharonIV0x86 added the wontfix This will not be worked on label Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Unit tests for GraphMatrix.hpp
2 participants