コード例 #1
0
        public void Int32AndUInt32ConvertToStringTest()
        {
            Int32  val0 = 0;
            Int32  val1 = 1;
            Int32  val2 = -1;
            UInt32 val3 = 0;
            UInt32 val4 = 1;

            val0.CastToString().ShouldBe("0");
            val1.CastToString().ShouldBe("1");
            val2.CastToString().ShouldBe("-1");
            val3.CastToString().ShouldBe("0");
            val4.CastToString().ShouldBe("1");

            val0.CastToString("---").ShouldBe("0");
            val1.CastToString("---").ShouldBe("1");
            val2.CastToString("---").ShouldBe("-1");
            val3.CastToString("---").ShouldBe("0");
            val4.CastToString("---").ShouldBe("1");

            val0.CastToString(NumericConvOptions.ZeroAsEmpty).ShouldBe("0");
            val1.CastToString(NumericConvOptions.ZeroAsEmpty).ShouldBe("1");
            val2.CastToString(NumericConvOptions.ZeroAsEmpty).ShouldBe("-1");
            val3.CastToString(NumericConvOptions.ZeroAsEmpty).ShouldBe("0");
            val4.CastToString(NumericConvOptions.ZeroAsEmpty).ShouldBe("1");

            val0.CastToString(NumericConvOptions.ZeroAsEmpty, "---").ShouldBe("---");
            val1.CastToString(NumericConvOptions.ZeroAsEmpty, "---").ShouldBe("1");
            val2.CastToString(NumericConvOptions.ZeroAsEmpty, "---").ShouldBe("-1");
            val3.CastToString(NumericConvOptions.ZeroAsEmpty, "---").ShouldBe("---");
            val4.CastToString(NumericConvOptions.ZeroAsEmpty, "---").ShouldBe("1");
        }