diff --git a/tests/basics/typed-counter-test.cpp b/tests/basics/typed-counter-test.cpp index 72fd45f3e..b34231e5d 100644 --- a/tests/basics/typed-counter-test.cpp +++ b/tests/basics/typed-counter-test.cpp @@ -326,22 +326,42 @@ namespace test{ CHECK (0==myCounter.size()); CHECK (0 == myCounter.get()); - CHECK (1 == myCounter.size()); + CHECK (0 < myCounter.size()); + // probably greater than 1; + // other parts of the application allocate type-IDs as well - CHECK (0 == myCounter.get()); - CHECK (2 == myCounter.size()); + // now allocate a counter for a type not seen yet + struct X { }; + struct U { }; - CHECK (-1 == myCounter.dec()); - CHECK (-2 == myCounter.dec()); - CHECK (+1 == myCounter.inc()); + CHECK (0 == myCounter.get()); + size_t sX = myCounter.size(); - CHECK (-2 == myCounter.get()); - CHECK (+1 == myCounter.get()); + CHECK (0 == myCounter.get()); + CHECK (sX + 1 == myCounter.size()); + CHECK (0 == myCounter.get()); + CHECK (sX + 1 == myCounter.size()); + CHECK (-1 == myCounter.dec()); + CHECK (-2 == myCounter.dec()); + CHECK (+1 == myCounter.inc()); - CHECK (1 == TypedContext::ID::get()); - CHECK (2 == TypedContext::ID::get()); - CHECK (2 == myCounter.size()); + CHECK (-2 == myCounter.get()); + CHECK (+1 == myCounter.get()); + + // each new type has gotten a new "slot" (i.e. a distinct type-ID) + IxID typeID_short = TypedContext::ID::get(); + IxID typeID_X = TypedContext::ID::get(); + IxID typeID_U = TypedContext::ID::get(); + + CHECK (0 < typeID_short); + CHECK (0 < typeID_X); + CHECK (0 < typeID_U); + CHECK (typeID_short < typeID_X); + CHECK (typeID_X < typeID_U); + // type-IDs are allocated in the order of first usage + + CHECK (sX + 1 == myCounter.size()); }