Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Suggestion][Feedback Wanted] using cmake + google test for writing tests#1464

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
yuuurchyk wants to merge1 commit intocp-algorithms:main
base:main
Choose a base branch
Loading
fromyuuurchyk:feature/update-tests-building-approach

Conversation

yuuurchyk
Copy link
Contributor

@yuuurchykyuuurchyk commentedMay 24, 2025
edited
Loading

Hey! This is a draft suggestion PR to move to more industry-oriented approach for testing.

Suggested Changes:

  1. use cmake as a meta-build system. This should make it easier to develop new tests. Benefits:
  • no manual compilation of tests required
  • supports any compiler on any OS (as opposed totest.sh)
  1. use googletest as testing library
  • provides information about failed tests/execution time out of the box (as opposed to manual reporting)
  • we can now compile all the tests into a single executable to launch allcp-algorithms tests at once.

Side note: I was suspecting that there will be ODR violation error when including the same snippet in multiple source files, but it seems that we're good, since ODR is applicable only to a single translation unit.

Current Changes

  • reworkextract_snippets.py script (add logging and command line arguments support)
  • rework the file structure in thetest/ folder, suggested layout:

image

  • update 2sat and aho_korasick tests to use gtest (see./test/src folder)

Changes To Be Implemented If This Approach Is Approved

  1. add-fsanitize=undefined -fno-sanitize-recover compiler flags
  2. update all testtest_*.cpp files to use google test framework
  3. update test workflow
  4. add#pragma once to all generated snippets

Question to Maintainers

What are your thoughts on this? I'm down to rework all the test files, but would like to hear your feedback/suggestions first :)

* refactor extract_snippets.py to take arguments from command line* add logging to extract_snippets.py script* add suggested CMakeLists.txt* add google test library, add example refactoring for 2sat and aho korasick tests
@yuuurchykyuuurchyk changed the title[Suggestion] using cmake + google test for writing tests[Suggestion][Feedback Wanted] using cmake + google test for writing testsMay 24, 2025
@adamant-pwn
Copy link
Member

adamant-pwn commentedMay 24, 2025
edited
Loading

Hi, thank you very much for the pull request!

I agree that it would be great to rework the testing system. I would say that, ideally, we would like to usecompetitive verifier for this somehow, so that we refer to well-prepared problems on external judges, rather than our own ad hoc test cases. We already use it forhttps://lib.cp-algorithms.com, but that one is a whole library, rather than self-contained snippets.

I think we might actually try to run competitive verifier on test files thatrefer to snippets in a similar manner to what's going on athttps://lib.cp-algorithms.com, so essentially we'd change testing files naming scheme toname.test.cpp, and then add

#definePROBLEM"..."

at the top to specify online judge that can be used for testing. Do you think it would be realistic to somehow integrate your approach with competitive verifier? Then, we would also be able to useoj-verify run ... to test things locally as well.

@yuuurchyk
Copy link
ContributorAuthor

yuuurchyk commentedMay 24, 2025
edited
Loading

@adamant-pwn thanks for the quick feedback. I will take a look at competitive-verifier, haven't heard about it.

Will take a look at it in a week at least :(

We'll be in touch then

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@yuuurchyk@adamant-pwn

[8]ページ先頭

©2009-2025 Movatter.jp