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

Test.cpp header issue #1

Open
kapooramanpreet opened this issue Feb 16, 2024 · 5 comments
Open

Test.cpp header issue #1

kapooramanpreet opened this issue Feb 16, 2024 · 5 comments
Assignees

Comments

@kapooramanpreet
Copy link
Member

The test.cpp has a header which doesn't point to the amalgamated file. This should be fixed.

@LunaVoid
Copy link

I'm gonna submit a pull request. Just fixed it and thought it would be nice to learn github a bit more.

@LunaVoid
Copy link

So changing the header fixes the default tests, but in my test code:

main.cpp:


using namespace std;

int testFunc(int num){
    return num;
}


int main(){
	cout << "Hello AVL!\n";
	return 0;
}

test.cpp:

#include "catch/catch_amalgamated.hpp"
#include <iostream>
#include "../src/main.cpp"

using namespace std;



TEST_CASE("Example Test Name - Change me!"){
    REQUIRE(testFunc(5)==5);
}

Then I get a ton of errors such as these below:

In file included from test/test.cpp:1: on   main !2 ?2  g++ test/test.cpp                                                                               1 ✘ 
test/catch/catch_amalgamated.hpp:545:33: warning: default member initializer for non-static data member is a C++11 extension [-Wc++11-extensions]
        IConfig const* m_config = nullptr;
                                ^
test/catch/catch_amalgamated.hpp:546:41: warning: default member initializer for non-static data member is a C++11 extension [-Wc++11-extensions]
        IResultCapture* m_resultCapture = nullptr;
                                        ^
test/catch/catch_amalgamated.hpp:545:35: error: use of undeclared identifier 'nullptr'
        IConfig const* m_config = nullptr;
                                  ^
test/catch/catch_amalgamated.hpp:546:43: error: use of undeclared identifier 'nullptr'
        IResultCapture* m_resultCapture = nullptr;
                                          ^
test/catch/catch_amalgamated.hpp:609:6: error: expected expression
    [[noreturn]] void throw_test_failure_exception();
``` etc

I'm not sure if this is an issue with the file or if I am just doing something wrong. I created this test case based on the one from previous quizzes but I will look at the docs to check if I did something wrong



@Brian-Magnuson
Copy link
Contributor

@LunaVoid , can you list what commands you used to compile? I recently updated the README with the commands for method 3.

@Herschenglime
Copy link
Collaborator

@kapooramanpreet test.cpp by default points to the catch header pulled in through CMake's git integration. Instructions for changing this to use the local amalgamated headers are included in method 3.

Changing the CMake project to use the local catch amalgamated would require significant change to the project structure and template; the catch_amalgamated files are provided more as a convenience for students who wish to forego the editor integration and just test from the command line with Method 3.

I have a rough proof of concept for using a local catch with CMake, but it would require more R&D to have it reach feature parity with the current template setup. Is this something you'd want to see developed further?

@Herschenglime
Copy link
Collaborator

Also @LunaVoid, if you change the header like that you can't use the existing CMakeLists.txt's setup for editor integration. Please see Method 3 in the readme if you'd like to use commandline-only testing instead with the local catch files, but for the main template I won't be able to merge your PR without other changes to the project structure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants