public void CapacityLength() { // null-allocated { String nullString= null; AString ms= new AString(); UT_EQ( ms.Capacity(), 0 ); ms= new AString( 0 ); UT_EQ( ms.Capacity(), 0 ); ms= new AString( nullString ); UT_EQ( ms.Capacity(), 0 ); ms._( "" ); UT_TRUE( ms.Capacity() > 0 ); } { AString ms= new AString( 5 ); ms._( 'a' ); UT_TRUE ( ms.Capacity() == 5 ); ms._( 'b' ); UT_TRUE ( ms.Capacity() == 5 ); ms._( 'c' ); UT_TRUE ( ms.Capacity() == 5 ); ms._( 'd' ); UT_TRUE ( ms.Capacity() == 5 ); ms._( 'e' ); UT_TRUE ( ms.Capacity() == 5 ); ms._( 'x' ); UT_TRUE ( ms.Capacity() >= 6 ); UT_EQ( "abcdex", ms ); ms.EnsureRemainingCapacity( 2000 ); UT_TRUE ( ms.Capacity() >= 2000 ); } { AString ms= new AString(); int asize; ms._( "0123456789" ); UT_EQ ( ms.Length(), 10 ); UT_TRUE ( ms.Capacity() >= 10 ); asize= ms.Capacity(); Report.GetDefault().PushHaltFlags( false, false ); Console.WriteLine( "A warning should follow" ); ms.SetLength(20); UT_EQ ( ms.Length(), 10 ); UT_EQ ( ms.Capacity(), asize ); UT_EQ( ms, "0123456789" ); ms.SetLength(5); UT_EQ ( ms.Length(), 5 ); UT_EQ ( ms.Capacity(), asize ); UT_EQ( ms, "01234" ); ms.SetBuffer(3); UT_EQ ( ms.Length(), 3 ); UT_EQ ( ms.Capacity(), 3 ); UT_EQ( ms, "012" ); ms._("ABC"); UT_EQ ( ms.Length(), 6 ); UT_TRUE( ms.Capacity() >= 6); UT_EQ( ms, "012ABC" ); Report.GetDefault().PopHaltFlags(); } }