I'm very confused by the fact that your class allows you to modify the keys stored inside an std::set
by const_cast
ing the pointer into said std::set
.
I don't use STL so my knowledge is shallow at best, but this SO thread seems to agree that you must always erase and re-insert the key if you want to modify it.
My guess is that this code
sb["banana"] = 25;
// ...
sb["banana"] = 15;
sb[15] = "melon";
// ...
SSVUT_EXPECT(!sb.has("banana"));
only works because at this point of your test the set
s contain just one item, so the red/black trees inside of them have no opportunity to get corrupted.