Rectify TypedCounter_test fixture -- Type-IDs are not stable
Hehe... with GenNode, we started to use these global Type-IDs to generate unique Names for unnamed Children in a diff::Record. This means, when running in the test-suite, the TypeID for 'short' and 'long' are likely to be allready allocated, so our Test can not not observe the allocateion, nor is it sensible to assume fixed numbers for these Type-IDs. Instead, we create two local types right within the test function, to force generation of new unique type-IDs, which we can observe
This commit is contained in:
parent
d7f87c9b72
commit
7d448be97a
1 changed files with 31 additions and 11 deletions
|
|
@ -326,22 +326,42 @@ namespace test{
|
|||
CHECK (0==myCounter.size());
|
||||
|
||||
CHECK (0 == myCounter.get<short>());
|
||||
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<long>());
|
||||
CHECK (2 == myCounter.size());
|
||||
// now allocate a counter for a type not seen yet
|
||||
struct X { };
|
||||
struct U { };
|
||||
|
||||
CHECK (-1 == myCounter.dec<short>());
|
||||
CHECK (-2 == myCounter.dec<short>());
|
||||
CHECK (+1 == myCounter.inc<long>());
|
||||
CHECK (0 == myCounter.get<X>());
|
||||
size_t sX = myCounter.size();
|
||||
|
||||
CHECK (-2 == myCounter.get<short>());
|
||||
CHECK (+1 == myCounter.get<long>());
|
||||
CHECK (0 == myCounter.get<U>());
|
||||
CHECK (sX + 1 == myCounter.size());
|
||||
CHECK (0 == myCounter.get<X>());
|
||||
CHECK (sX + 1 == myCounter.size());
|
||||
|
||||
CHECK (-1 == myCounter.dec<X>());
|
||||
CHECK (-2 == myCounter.dec<X>());
|
||||
CHECK (+1 == myCounter.inc<U>());
|
||||
|
||||
CHECK (1 == TypedContext<TypedCounter>::ID<short>::get());
|
||||
CHECK (2 == TypedContext<TypedCounter>::ID<long>::get());
|
||||
CHECK (2 == myCounter.size());
|
||||
CHECK (-2 == myCounter.get<X>());
|
||||
CHECK (+1 == myCounter.get<U>());
|
||||
|
||||
// each new type has gotten a new "slot" (i.e. a distinct type-ID)
|
||||
IxID typeID_short = TypedContext<TypedCounter>::ID<short>::get();
|
||||
IxID typeID_X = TypedContext<TypedCounter>::ID<X>::get();
|
||||
IxID typeID_U = TypedContext<TypedCounter>::ID<U>::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());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue