Skip to content

Add (void) cast to all EXPECT_THROW calls in test_railwaynetwork.cpp#154

Merged
sengels-tum merged 3 commits into2026-refactor-problem-instancefrom
copilot/update-expect-throw-calls
Apr 22, 2026
Merged

Add (void) cast to all EXPECT_THROW calls in test_railwaynetwork.cpp#154
sengels-tum merged 3 commits into2026-refactor-problem-instancefrom
copilot/update-expect-throw-calls

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 22, 2026

Description

All EXPECT_THROW calls in test/test_railwaynetwork.cpp lacked the (void) cast on the expression argument, which suppresses unused-value/nodiscard warnings. 49 occurrences were updated; calls that already had (void) were left unchanged.

Before:

EXPECT_THROW(network.get_vertex(10), cda_rail::exceptions::VertexNotExistentException);

After:

EXPECT_THROW((void)network.get_vertex(10), cda_rail::exceptions::VertexNotExistentException);

Multi-line forms where the expression appears on the next line were handled correctly:

// Before
EXPECT_THROW(
    network.all_paths_of_length_starting_in_vertex(v_3, 0, v_5, {}, false),
    cda_rail::exceptions::InvalidInputException);

// After
EXPECT_THROW(
    (void)network.all_paths_of_length_starting_in_vertex(v_3, 0, v_5, {}, false),
    cda_rail::exceptions::InvalidInputException);

Checklist:

  • The pull request only contains commits that are related to it.
  • I have added appropriate tests and documentation.
  • I have made sure that all CI jobs on GitHub pass.
  • The pull request introduces no new warnings and follows the project's style guidelines.
Original prompt

n all(!) tests in test_railwaynetwork.cpp do the following:

Whenever there is an EXPECT_THROW(...); replace with EXPECT_THROW((void)...); However, note that some checks already include the "(void)" in which case these calls should not(!) be updated. Make sure to update every(!) occurance in test_railwaynetwork.cpp.

You may only edit test_railwaynetwork.cpp as described. You may not open any other file or change anything else.

The user has attached the following files from their workspace:

  • test/test_railwaynetwork.cpp

Copilot AI changed the title [WIP] Update EXPECT_THROW calls in test_railwaynetwork.cpp Add (void) cast to all EXPECT_THROW calls in test_railwaynetwork.cpp Apr 22, 2026
Copilot AI requested a review from sengels-tum April 22, 2026 20:25
Copy link
Copy Markdown
Collaborator

@sengels-tum sengels-tum left a comment

Choose a reason for hiding this comment

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

lgtm (if it compiles)

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.8%. Comparing base (0a0a5fa) to head (a4ff83d).
⚠️ Report is 4 commits behind head on 2026-refactor-problem-instance.

Additional details and impacted files
@@                      Coverage Diff                       @@
##           2026-refactor-problem-instance    #154   +/-   ##
==============================================================
  Coverage                            93.8%   93.8%           
==============================================================
  Files                                  11      11           
  Lines                                1468    1468           
  Branches                              290     290           
==============================================================
  Hits                                 1378    1378           
  Misses                                 90      90           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sengels-tum
Copy link
Copy Markdown
Collaborator

pre-commit.ci autofix

@sengels-tum sengels-tum marked this pull request as ready for review April 22, 2026 20:36
@sengels-tum sengels-tum merged commit 6671c37 into 2026-refactor-problem-instance Apr 22, 2026
5 of 7 checks passed
@sengels-tum sengels-tum deleted the copilot/update-expect-throw-calls branch April 22, 2026 20:37
@github-actions
Copy link
Copy Markdown
Contributor

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-tidy (v18.1.8) reports: 5 concern(s)
  • test/test_railwaynetwork.cpp:7:1: warning: [misc-include-cleaner]

    included header gmock-spec-builders.h is not used directly

        7 | #include "gmock/gmock-spec-builders.h"
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        8 | #include "gtest/gtest.h"
  • test/test_railwaynetwork.cpp:129:3: warning: [misc-const-correctness]

    variable 'v2_expected' of type 'cda_rail::Vertex' can be declared 'const'

      129 |   cda_rail::Vertex v2_expected{"v2", cda_rail::VertexType::VSS, 42};
          |   ^
          |                    const 
  • test/test_railwaynetwork.cpp:161:3: warning: [misc-const-correctness]

    variable 'e12_expected' of type 'cda_rail::Edge' can be declared 'const'

      161 |   cda_rail::Edge e12_expected{v1, v2, 150, 20, true, 28, 37};
          |   ^
          |                  const 
  • test/test_railwaynetwork.cpp:166:3: warning: [misc-const-correctness]

    variable 'v2_str' of type 'std::string' (aka 'basic_string') can be declared 'const'

      166 |   std::string    v2_str{"v2"};
          |   ^
          |                  const 
  • test/test_railwaynetwork.cpp:3489:2: warning: [readability-avoid-unconditional-preprocessor-if]

    preprocessor condition is always 'false', consider removing both the condition and its contents

     3489 | #if 0 // TODO: The following tests are disabled because they use classes which
          |  ^

Have any feedback or feature suggestions? Share it here.

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.

2 participants