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();
            }
        }
        public void _()
        {
            // append char[]
            {
                AString ms= new AString();  char[] csNull= null;  char[] csEmpty= "".ToCharArray();

                ms._( csNull );            UT_EQ  ( ms.Length(), 0     );  UT_TRUE( ms.IsNull()    );
                ms._( csEmpty);            UT_EQ  ( ms.Length(), 0     );  UT_TRUE( ms.IsNotNull() );
                ms.SetNull();              UT_EQ  ( ms.Length(), 0     );  UT_TRUE( ms.IsNull()    );

                ms._("1234567".ToCharArray());  UT_EQ  ( ms.Capacity(), 16  );  UT_EQ( "1234567",   ms );
                ms._("89"     .ToCharArray());  UT_TRUE( ms.Length()> 7     );  UT_EQ( "123456789", ms );

                char[] t= "0123456789".ToCharArray();
                ms.Clear()._   ( t, 5);                     UT_EQ( ms, "56789"      );
                ms.Clear()._   ( t, 5, 100);                UT_EQ( ms, "56789"      );
                ms.Clear()._   ( t, -5);                    UT_EQ( ms, "0123456789" );
                ms.Clear()._   ( t, -5, 3);                 UT_EQ( ms, ""           );
                ms.Clear()._   ( t, 50, 3);                 UT_EQ( ms, ""           );
                ms.Clear()._   ( t, 10, 3);                 UT_EQ( ms, ""           );
                ms.Clear()._   ( t, -5, 10);                UT_EQ( ms, "01234"      );
                ms.Clear()._   ( t, -5, 100);               UT_EQ( ms, "0123456789" );

                // _NC
                ms.SetNull();                  UT_EQ  ( ms.Length(), 0     );  UT_TRUE( ms.IsNull()    );
                ms._NC( csEmpty,0,0);          UT_EQ  ( ms.Length(), 0     );  UT_TRUE( ms.IsNull()   );
                ms.Clear()._NC( t, 5,3);       UT_EQ( ms, "567"      );
            }

            // append AString
            {
                AString ms= new AString();  AString asNull= null; AString asEmpty= new AString(""); AString t= new AString( "012" );
                ms._( asNull );            UT_EQ  ( ms.Length(), 0     );  UT_TRUE( ms.IsNull()   );
                ms._( asEmpty);            UT_EQ  ( ms.Length(), 0     );  UT_TRUE( ms.IsNotNull() );
                ms.SetNull();              UT_EQ  ( ms.Length(), 0     );  UT_TRUE( ms.IsNull()    );
                ms._( t );                 UT_EQ  ( ms.Capacity(), 16  );  UT_EQ( "012"   , ms );
                ms._( t );                 UT_TRUE( ms.Length()> 3     );  UT_EQ( "012012", ms );
                t.Clear()._( "0123456789" );
                ms.Clear()._   ( t, 5);                     UT_EQ( ms, "56789"      );
                ms.Clear()._   ( t, 5, 100);                UT_EQ( ms, "56789"      );
                ms.Clear()._   ( t, -5);                    UT_EQ( ms, "0123456789" );
                ms.Clear()._   ( t, -5, 3);                 UT_EQ( ms, ""           );
                ms.Clear()._   ( t, 50, 3);                 UT_EQ( ms, ""           );
                ms.Clear()._   ( t, 10, 3);                 UT_EQ( ms, ""           );
                ms.Clear()._   ( t, -5, 10);                UT_EQ( ms, "01234"      );
                ms.Clear()._   ( t, -5, 100);               UT_EQ( ms, "0123456789" );

                ms.Clear()._NC( t       );                  UT_EQ( ms, "0123456789" );
                ms.Clear()._NC( t, 1, 9 );                  UT_EQ( ms,  "123456789" );
                ms.Clear()._NC( t, 1, 2 );                  UT_EQ( ms,  "12"        );
                ms.Clear()._NC( t, 1, 8 );                  UT_EQ( ms,  "12345678"  );
                ms.Clear()._NC( t, 1, 9 );                  UT_EQ( ms,  "123456789" );
                ms.Clear()._NC( t, 5, 5 );                  UT_EQ( ms,      "56789" );

                // _NC
                ms.SetNull();                  UT_EQ  ( ms.Length(), 0     );  UT_TRUE( ms.IsNull()    );
                ms._NC( asEmpty);        UT_EQ  ( ms.Length(), 0     );  UT_TRUE( ms.IsNull()   );
                ms.Clear()._NC( t, 5, 3);                  UT_EQ( ms, "567"      );
            }

            // append Substring
            {
                AString ms= new AString();  Substring ssNull= null; Substring ssEmpty= new Substring( "" ); Substring t= new Substring( "01234" );
                ms._( ssNull );            UT_EQ  ( ms.Length(), 0     );  UT_TRUE( ms.IsNull()    );
                ms._( ssEmpty);            UT_EQ  ( ms.Length(), 0     );  UT_TRUE( ms.IsNotNull() );
                ms.SetNull();              UT_EQ  ( ms.Length(), 0     );  UT_TRUE( ms.IsNull()    );
                ms._( t );                 UT_EQ  ( ms.Capacity(), 16  );  UT_EQ( "01234"     , ms );
                ms._( t );                 UT_TRUE( ms.Length()> 5     );  UT_EQ( "0123401234", ms );

                t.Consume();      ms.Clear()._( t );           UT_EQ( ms,  "1234"      );
                t.Consume();      ms.Clear()._( t );           UT_EQ( ms,   "234"      );
                t.ConsumeFromEnd();  ms.Clear()._( t );           UT_EQ( ms,  "23"        );

                // _NC
                ms.SetNull();                   UT_EQ  ( ms.Length(), 0     );  UT_TRUE( ms.IsNull()   );
                ms._NC( ssEmpty );        UT_EQ  ( ms.Length(), 0     );  UT_TRUE( ms.IsNull()   );
                ms.Clear()._NC( t);                       UT_EQ( ms, "23"   );
            }

            // append String
            {
                AString ms= new AString();   String sEmpty= "";  String t= "012";
                ms._( sEmpty);             UT_EQ  ( ms.Length(), 0     );  UT_TRUE( ms.IsNotNull() );
                ms.SetNull();              UT_EQ  ( ms.Length(), 0     );  UT_TRUE( ms.IsNull()    );
                ms._( t );                 UT_EQ  ( ms.Capacity(), 16  );  UT_EQ( "012"   , ms );
                ms._( t );                 UT_TRUE( ms.Length()> 3     );  UT_EQ( "012012", ms );
                t= "0123456789";
                ms.Clear()._( t, 5);                     UT_EQ( ms, "56789"      );
                ms.Clear()._( t, 5, 100);                UT_EQ( ms, "56789"      );
                ms.Clear()._( t, -5);                    UT_EQ( ms, "0123456789" );
                ms.Clear()._( t, -5, 3);                 UT_EQ( ms, ""           );
                ms.Clear()._( t, 50, 3);                 UT_EQ( ms, ""           );
                ms.Clear()._( t, 10, 3);                 UT_EQ( ms, ""           );
                ms.Clear()._( t, -5, 10);                UT_EQ( ms, "01234"      );
                ms.Clear()._( t, -5, 100);               UT_EQ( ms, "0123456789" );

                // _NC
                ms.SetNull();                   UT_EQ  ( ms.Length(), 0     );  UT_TRUE( ms.IsNull()   );
                ms._NC(  sEmpty );        UT_EQ  ( ms.Length(), 0     );  UT_TRUE( ms.IsNull()   );
                ms.Clear()._NC( t);                      UT_EQ( ms, "0123456789"   );
                ms.Clear()._NC( t ,2,3);                 UT_EQ( ms, "234"          );
            }

            // append String Builders
            {
                AString ms= new AString();   StringBuilder t= new StringBuilder( "012");
                ms._( t );                 UT_EQ  ( ms.Capacity(), 16  );  UT_EQ( "012"   , ms );
                ms._( t );                 UT_TRUE( ms.Length()> 3     );  UT_EQ( "012012", ms );
                t.Clear().Append("0123456789");
                ms.Clear()._( t, 5);                     UT_EQ( ms, "56789"      );
                ms.Clear()._( t, 5, 100);                UT_EQ( ms, "56789"      );
                ms.Clear()._( t, -5);                    UT_EQ( ms, "0123456789" );
                ms.Clear()._( t, -5, 3);                 UT_EQ( ms, ""           );
                ms.Clear()._( t, 50, 3);                 UT_EQ( ms, ""           );
                ms.Clear()._( t, 10, 3);                 UT_EQ( ms, ""           );
                ms.Clear()._( t, -5, 10);                UT_EQ( ms, "01234"      );
                ms.Clear()._( t, -5, 100);               UT_EQ( ms, "0123456789" );
            }
        }
        public void Constructors()
        {
            AString ms;
            ms= new AString();                        UT_TRUE ( ms.Capacity() ==  0  && ms.Length() == 0 );
            ms= new AString(25);                      UT_TRUE ( ms.Capacity() == 25  && ms.Length() == 0 );
            ms= new AString("Test");                  UT_TRUE ( ms.Capacity() >=  4  && ms.Length() == 4 );

            AString tMSEmpty= new AString ( );

            ms= new AString( (AString) null );        UT_TRUE ( ms.Length() == 0 );    UT_TRUE ( ms.Capacity() == 0 );
            ms._( "was null" );                  UT_TRUE ( ms.Length() == 8 );
            ms= new AString( tMSEmpty );              UT_TRUE ( ms.Length() == 0 );    UT_TRUE ( ms.Capacity() > 0 );
            ms= new AString( tMSEmpty, 1,     0 );    UT_TRUE ( ms.Length() == 0 );    UT_TRUE ( ms.Capacity() > 0 );
            ms= new AString( tMSEmpty, -1000, 0 );    UT_TRUE ( ms.Length() == 0 );    UT_TRUE ( ms.Capacity() > 0 );
            ms= new AString( tMSEmpty, -1000, 1 );    UT_TRUE ( ms.Length() == 0 );    UT_TRUE ( ms.Capacity() > 0 );
            ms= new AString( tMSEmpty, -100,  1000);  UT_TRUE ( ms.Length() == 0 );    UT_TRUE ( ms.Capacity() > 0 );

            AString tMS=        new AString ( "0123456789" );
            ms= new AString( tMS );                   UT_TRUE ( ms.Capacity() >=  10 && ms.Length() == 10 );    UT_EQ( ms, "0123456789");
            ms= new AString( tMS, 5);                 UT_TRUE ( ms.Capacity() >=   5 && ms.Length() ==  5 );    UT_EQ( ms, "56789");
            ms= new AString( tMS, 5, 100);            UT_TRUE ( ms.Capacity() >=   5 && ms.Length() ==  5 );    UT_EQ( ms, "56789");
            ms= new AString( tMS, -5);                UT_TRUE ( ms.Capacity() >=  10 && ms.Length() == 10 );    UT_EQ( ms, "0123456789");
            ms= new AString( tMS, -5,  3);            UT_TRUE ( ms.Capacity() >    0 && ms.Length() ==  0 );    UT_EQ( ms, "");
            ms= new AString( tMS, 50,  3);            UT_TRUE ( ms.Capacity() >    0 && ms.Length() ==  0 );    UT_EQ( ms, "");
            ms= new AString( tMS, 10,  3);            UT_TRUE ( ms.Capacity() >    0 && ms.Length() ==  0 );    UT_EQ( ms, "");
            ms= new AString( tMS, -5, 10);            UT_TRUE ( ms.Capacity() >=   5 && ms.Length() ==  5 );    UT_EQ( ms, "01234");
            ms= new AString( tMS, -5, 100);           UT_TRUE ( ms.Capacity() >=  10 && ms.Length() == 10 );    UT_EQ( ms, "0123456789");

            Substring tSS=     new Substring ( "ABCDE0123456789FG".ToCharArray(), 5,10 );
            ms= new AString( tSS );                       UT_TRUE ( ms.Capacity() >=  10 && ms.Length()  == 10 );        UT_EQ( ms, "0123456789");

            String tS= "0123456789";
            ms= new AString( (String) null );         UT_TRUE ( ms.Length() == 0 ); UT_TRUE ( ms.Capacity() == 0 );
            ms._( "was null" );                  UT_TRUE ( ms.Length() == 8 );
            ms= new AString( "" );                    UT_TRUE ( ms.Length() == 0 ); UT_TRUE ( ms.Capacity() >  0 );
            ms= new AString( "", 1,     0 );          UT_TRUE ( ms.Length() == 0 ); UT_TRUE ( ms.Capacity() >  0 );
            ms= new AString( "", -1000, 0 );          UT_TRUE ( ms.Length() == 0 ); UT_TRUE ( ms.Capacity() >  0 );
            ms= new AString( "", -1000, 1 );          UT_TRUE ( ms.Length() == 0 ); UT_TRUE ( ms.Capacity() > 0 );
            ms= new AString( "", -100,  1000);        UT_TRUE ( ms.Length() == 0 ); UT_TRUE ( ms.Capacity() >  0 );
            ms= new AString( tS );                    UT_TRUE ( ms.Capacity() >=  10 && ms.Length() == 10 );    UT_EQ( ms, "0123456789");
            ms= new AString( tS, 5);                  UT_TRUE ( ms.Capacity() >=   5 && ms.Length() ==  5 );    UT_EQ( ms, "56789");
            ms= new AString( tS, 5, 100);             UT_TRUE ( ms.Capacity() >=   5 && ms.Length() ==  5 );    UT_EQ( ms, "56789");
            ms= new AString( tS, -5);                 UT_TRUE ( ms.Capacity() >=  10 && ms.Length() == 10 );    UT_EQ( ms, "0123456789");
            ms= new AString( tS, -5, 10);             UT_TRUE ( ms.Capacity() >=   5 && ms.Length() ==  5 );    UT_EQ( ms, "01234");
            ms= new AString( tS, -5, 100);            UT_TRUE ( ms.Capacity() >=  10 && ms.Length() == 10 );    UT_EQ( ms, "0123456789");


            StringBuilder tSBEmpty= new StringBuilder ( );
            ms= new AString( (StringBuilder) null ); UT_TRUE ( ms.Length() == 0 );    UT_TRUE ( ms.Capacity() == 0 );
            ms._( "was null" );                 UT_TRUE ( ms.Length() == 8 );
            ms= new AString( tSBEmpty );             UT_TRUE ( ms.Length() == 0 );    UT_TRUE ( ms.Capacity() > 0 );
            ms= new AString( tSBEmpty, 1,     0 );   UT_TRUE ( ms.Length() == 0 );    UT_TRUE ( ms.Capacity() > 0 );
            ms= new AString( tSBEmpty, -1000, 0 );   UT_TRUE ( ms.Length() == 0 );    UT_TRUE ( ms.Capacity() > 0 );
            ms= new AString( tSBEmpty, -1000, 1 );   UT_TRUE ( ms.Length() == 0 );    UT_TRUE ( ms.Capacity() > 0 );
            ms= new AString( tSBEmpty, -100,  1000); UT_TRUE ( ms.Length() == 0 );    UT_TRUE ( ms.Capacity() > 0 );

            StringBuilder tSB= new StringBuilder ( "0123456789" );
            ms= new AString( tSB );                  UT_TRUE  ( ms.Capacity() >=  10 && ms.Length() == 10 );
                                                     UT_EQ( ms, "0123456789");
            ms= new AString( tSB, 5);                UT_TRUE  ( ms.Capacity() >=  5  && ms.Length() == 5 );
                                                     UT_EQ( ms, "56789");
            ms= new AString( tSB, 5, 100);           UT_TRUE  ( ms.Capacity() >=  5  && ms.Length() == 5 );
                                                     UT_EQ( ms, "56789");
            ms= new AString( tSB, -5);               UT_TRUE  ( ms.Capacity() >=  10 && ms.Length() == 10 );
                                                     UT_EQ( ms, "0123456789");
            ms= new AString( tSB, -5, 10);           UT_TRUE  ( ms.Capacity() >=  5  && ms.Length() == 5 );
                                                     UT_EQ( ms, "01234");
            ms= new AString( tSB, -5, 100);          UT_TRUE  ( ms.Capacity() >=  10 && ms.Length() == 10 );
                                                     UT_EQ( ms, "0123456789");
        }
        public void IsNull()
        {
            AString ms
            = new AString();    UT_TRUE( ms.Capacity() == 0 ); UT_TRUE(  ms.IsNull() );  UT_TRUE( !ms.IsNotNull() );  UT_TRUE(  ms.IsEmpty() );  UT_TRUE( !ms.IsNotEmpty() );
            ms._("");           UT_TRUE( ms.Capacity() != 0 ); UT_TRUE( !ms.IsNull() );  UT_TRUE(  ms.IsNotNull() );  UT_TRUE(  ms.IsEmpty() );  UT_TRUE( !ms.IsNotEmpty() );
            ms._("x");          UT_TRUE( ms.Capacity() != 0 ); UT_TRUE( !ms.IsNull() );  UT_TRUE(  ms.IsNotNull() );  UT_TRUE( !ms.IsEmpty() );  UT_TRUE(  ms.IsNotEmpty() );

            ms.SetNull();       UT_TRUE( ms.Capacity() == 0 ); UT_TRUE(  ms.IsNull() );  UT_TRUE( !ms.IsNotNull() );  UT_TRUE(  ms.IsEmpty() );  UT_TRUE( !ms.IsNotEmpty() );
            ms._("");           UT_TRUE( ms.Capacity() != 0 ); UT_TRUE( !ms.IsNull() );  UT_TRUE(  ms.IsNotNull() );  UT_TRUE(  ms.IsEmpty() );  UT_TRUE( !ms.IsNotEmpty() );
            ms._("x");          UT_TRUE( ms.Capacity() != 0 ); UT_TRUE( !ms.IsNull() );  UT_TRUE(  ms.IsNotNull() );  UT_TRUE( !ms.IsEmpty() );  UT_TRUE(  ms.IsNotEmpty() );

            ms.SetNull();       UT_TRUE( ms.Capacity() == 0 ); UT_TRUE(  ms.IsNull() );  UT_TRUE( !ms.IsNotNull() );  UT_TRUE(  ms.IsEmpty() );  UT_TRUE( !ms.IsNotEmpty() );
            ms.SetBuffer(5);    UT_TRUE( ms.Capacity() != 0 ); UT_TRUE( !ms.IsNull() );  UT_TRUE(  ms.IsNotNull() );  UT_TRUE(  ms.IsEmpty() );  UT_TRUE( !ms.IsNotEmpty() );
            ms._("x");          UT_TRUE( ms.Capacity() != 0 ); UT_TRUE( !ms.IsNull() );  UT_TRUE(  ms.IsNotNull() );  UT_TRUE( !ms.IsEmpty() );  UT_TRUE(  ms.IsNotEmpty() );
        }