antlr4-cpp
antlr4-cpp copied to clipboard
Unit Test expecting 57, 123; code review
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;