Fix errors in computing character set unions

This commit is contained in:
Max Brunsfeld 2014-02-06 09:12:03 -08:00
parent 8b1aeee0e3
commit e8337a3c70
5 changed files with 315 additions and 292 deletions

View file

@ -38,6 +38,11 @@ describe("character sets", []() {
CharacterSet set({ {'a', 'r'} }, true);
set.union_with(CharacterSet({ {'s', 'z'} }, true));
AssertThat(set, Equals(CharacterSet({ {'a', 'z'} }, true)));
set = CharacterSet({ 'c' });
auto c = set.complement();
set.union_with(c);
AssertThat(set, Equals(CharacterSet({ {0, -1} }, true)));
});
it("works when the result becomes a continuous range", []() {
@ -45,6 +50,12 @@ describe("character sets", []() {
set.union_with(CharacterSet({ {'d', 'f'} }, true));
AssertThat(set, Equals(CharacterSet({ {'a', 'z'} }, true)));
});
it("does nothing for the set of all characters", []() {
CharacterSet set({ {'\0', '\xff'} }, true);
set.union_with(CharacterSet({ 'a' }));
AssertThat(set, Equals(CharacterSet({ {'\0', '\xff'} }, true)));
});
});
});