printf() public static method

public static printf ( string Format ) : void
Format string
return void
Exemplo n.º 1
0
        public void Strings()
        {
            Console.WriteLine("Test string format %s");
            Console.WriteLine("--------------------------------------------------------------------------------");

            Assert.IsTrue(RunTest("[%s]", "[This is a test]", "This is a test"));
            Assert.IsTrue(RunTest("[%s]", "[A test with %]", "A test with %"));
            Assert.IsTrue(RunTest("[%s]", "[A test with %s inside]", "A test with %s inside"));
            Assert.IsTrue(RunTest("[%% %s %%]", "[% % Another test % %]", "% Another test %"));
            Assert.IsTrue(RunTest("[%20s]", "[       a long string]", "a long string"));
            Assert.IsTrue(RunTest("[%-20s]", "[a long string       ]", "a long string"));
            Assert.IsTrue(RunTest("[%020s]", "[0000000a long string]", "a long string"));
            Assert.IsTrue(RunTest("[%-020s]", "[a long string       ]", "a long string"));

            Assert.IsTrue(RunTest("[%.10s]", "[This is a ]", "This is a shortened string"));
            Assert.IsTrue(RunTest("[%20.10s]", "[          This is a ]", "This is a shortened string"));
            Assert.IsTrue(RunTest("[%-20.10s]", "[This is a           ]", "This is a shortened string"));
            Assert.IsTrue(RunTest("[%020.10s]", "[0000000000This is a ]", "This is a shortened string"));
            Assert.IsTrue(RunTest("[%-020.10s]", "[This is a           ]", "This is a shortened string"));

            Tools.printf("Account balance: %'+20.2f\n", 12345678);

            Console.WriteLine("\n\n");
        }