antlr / antlr/antlr4-cpp

Unit Test expecting 57, 123; code review

Open
#10 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
80
Forks
33
PR merge metrics
No merged PRs in 30d

Description

Hello,

Inspiring on C ++ test for my unit tests in C, I noticed an error in the expecting result. Maybe the `+1` has no effect?

In `https://github.com/antlr/antlr4-cpp/blob/master/antlr4cpp/antlr/test/test_interval_set.cpp`

```
void test_mixed_ranges_and_elements()
{
interval_set s;
s.insert(1);
s.insert(std::make_pair(L'a',L'z'+1));
s.insert(std::make_pair(L'0',L'9'+1));
std::wstring expecting = L"{1, 48..57, 97..122}";
}
```

by comparison with Java implementation

```
IntervalSet interval_set = new IntervalSet();
interval_set.add(1);
interval_set.add('a', 'z'+1);
interval_set.add('0', '9'+1);
String str = interval_set.toString();
String expecting = "{1, 48..58, 97..123}";
```

PS:
C ++ operator overloading is friendly

```
interval_set s;
s << 1;// s+1 is ambigus
s << interval('a', 'z'+1);
s &= interval('0', '9'+1);
s |= interval('0', '9'+1);

std::cout << s << std::endl;
```

Contributor guide

Open the contributing guide

Research direction

Start with antlr4cpp/antlr/test/test_interval_set.cpp and the test_mixed_ranges_and_elements() method. Compare its expected interval string with the shown Java implementation and run the relevant C++ unit test. Done means the test expectation or interval behavior is confirmed and aligned with the intended inclusive-range semantics.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.