Skip to content

Commit

Permalink
Skip a test that will fail with ubsan in case that sanitizer is enabled.
Browse files Browse the repository at this point in the history
UBSAN is good in knowing beforehand that tests some out-of-range
mitigation, that the value in question is indeed out of range and will
complain.
  • Loading branch information
hzeller committed Dec 2, 2024
1 parent 660d166 commit fe1da2b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions verible/verilog/formatting/verilog-token_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ namespace {

using FTT = FormatTokenType;

// UBSAN check will notice, that 9999 is out of range; skip test in that case
#ifndef UNDEFINED_BEHAVIOR_SANITIZER
// Test that GetFormatTokenType() correctly converts a TokenInfo enum to FTT
TEST(VerilogTokenTest, GetFormatTokenTypeTestUnknown) {
const int FAKE_TOKEN = 9999;
verible::TokenInfo token_info(FAKE_TOKEN, "FakeToken");
verible::PreFormatToken format_token(&token_info);
EXPECT_EQ(FTT::unknown, GetFormatTokenType(verilog_tokentype(FAKE_TOKEN)));
}
#endif

struct GetFormatTokenTypeTestCase {
verilog_tokentype token_info_type;
Expand Down

0 comments on commit fe1da2b

Please sign in to comment.