Skip to content

🚨 Add tests for contest type (#1074)#1075

Merged
KATO-Hiro merged 1 commit into
stagingfrom
#1074
Aug 7, 2024
Merged

🚨 Add tests for contest type (#1074)#1075
KATO-Hiro merged 1 commit into
stagingfrom
#1074

Conversation

@KATO-Hiro
Copy link
Copy Markdown
Collaborator

@KATO-Hiro KATO-Hiro commented Aug 7, 2024

close #1074

Summary by CodeRabbit

  • Tests
    • Introduced a comprehensive suite of unit tests for contest classification, ensuring accurate categorization of various contest IDs.
    • Enhanced test coverage for different contest formats to improve reliability and maintainability of the classification logic.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 7, 2024

Walkthrough

This update introduces a comprehensive suite of unit tests for the classifyContest function, enhancing the robustness of contest classification within the $lib/utils/contest module. Utilizing the Vitest framework, the tests cover a wide range of contest ID formats and ensure accurate categorization according to predefined rules, thus improving the reliability and maintainability of the codebase.

Changes

Files Change Summary
src/test/lib/utils/contest.test.ts Added a new test suite for the classifyContest function, covering various contest ID scenarios, ensuring proper classification against the ContestType enumeration.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ClassifyContest
    participant ContestType

    User->>ClassifyContest: Input contest ID
    ClassifyContest->>ContestType: Match ID
    ContestType-->>ClassifyContest: Return Contest Type
    ClassifyContest-->>User: Output Contest Type
Loading

Poem

In fields of code where contests play,
A bunny hops with tests today.
Each ID sorted, neat and clear,
A joyful dance, no need to fear!
With Vitest by our side so bright,
We classify with pure delight! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9145cc3 and 17dc229.

Files selected for processing (1)
  • src/test/lib/utils/contest.test.ts (1 hunks)
Additional comments not posted (15)
src/test/lib/utils/contest.test.ts (15)

1-4: LGTM! Import statements are correct.

The import statements correctly bring in the necessary modules and functions for testing.


6-12: LGTM! Type definitions are clear and correct.

The type definitions for TestCaseForContestType and TestCasesForContestType are well-defined and appropriate for structuring the test cases.


13-15: LGTM! The describe block is well-structured.

The describe block sets up the context for testing the classifyContest function effectively.


16-18: LGTM! Test case for ABS contest ID is correct.

The test case for the ABS contest ID checks if the classifyContest function correctly classifies 'abs' as ContestType.ABS.


20-36: LGTM! Test cases for ABC contest IDs are comprehensive.

The test cases for ABC contest IDs cover a wide range of possible IDs and ensure accurate classification by the classifyContest function.


38-40: LGTM! Test case for APG4b contest ID is correct.

The test case for the APG4b contest ID checks if the classifyContest function correctly classifies 'APG4b' as ContestType.APG4B.


42-44: LGTM! Test case for typical90 contest ID is correct.

The test case for the typical90 contest ID checks if the classifyContest function correctly classifies 'typical90' as ContestType.TYPICAL90.


46-48: LGTM! Test case for dp (EDPC) contest ID is correct.

The test case for the dp (EDPC) contest ID checks if the classifyContest function correctly classifies 'dp' as ContestType.EDPC.


50-52: LGTM! Test case for tdpc contest ID is correct.

The test case for the tdpc contest ID checks if the classifyContest function correctly classifies 'tdpc' as ContestType.TDPC.


54-69: LGTM! Test cases for PAST contest IDs are comprehensive.

The test cases for PAST contest IDs cover a wide range of possible IDs and ensure accurate classification by the classifyContest function.


71-73: LGTM! Test case for practice2 (ACL practice) contest ID is correct.

The test case for the practice2 (ACL practice) contest ID checks if the classifyContest function correctly classifies 'practice2' as ContestType.ACL_PRACTICE.


75-93: LGTM! Test cases for JOI contest IDs are comprehensive.

The test cases for JOI contest IDs cover a wide range of possible IDs and ensure accurate classification by the classifyContest function.


95-97: LGTM! Test case for tessoku-book contest ID is correct.

The test case for the tessoku-book contest ID checks if the classifyContest function correctly classifies 'tessoku-book' as ContestType.TESSOKU_BOOK.


99-101: LGTM! Test case for math-and-algorithm contest ID is correct.

The test case for the math-and-algorithm contest ID checks if the classifyContest function correctly classifies 'math-and-algorithm' as ContestType.MATH_AND_ALGORITHM.


103-109: LGTM! Helper function runTests is well-defined.

The helper function runTests simplifies running multiple test cases and is well-defined.

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

Successfully merging this pull request may close these issues.

単体テスト: コンテスト種類の識別に関するテストを追加しましょう

1 participant