// gen 関数 呼び出し public static void test_gen_ni(afh.Application.Log log) { int c = 0; for (int i = 0, j = LOOP; i < LOOP; i++, j--) { if (compare_gen(i, j)) { c++; } } }
public static void test_inline_cmp(afh.Application.Log log) { int c = 0; for (int i = 0, j = LOOP; i < LOOP; i++, j--) { if (i.CompareTo(j) > 0) { c++; } } }
public static void test_inline(afh.Application.Log log) { int c = 0; for (int i = 0, j = LOOP; i < LOOP; i++, j--) { if (i > j) { c++; } } }
public static void CompressMZipEnc(afh.Application.Log log) { log.WriteLine("gzcomp.cs を圧縮中 ..."); //System.IO.Stream sread=System.IO.File.OpenRead(@"compress-test\gzcomp.cs"); //System.IO.Stream swrite=System.IO.File.OpenWrite(@"compress-test\gzcomp.cs.mwg"); //System.IO.Stream sread=System.IO.File.OpenRead(@"compress-test\test.txt"); //System.IO.Stream swrite=System.IO.File.OpenWrite(@"compress-test\test.txt.mwg"); System.IO.Stream sread = System.IO.File.OpenRead(@"compress-test\target.htm"); System.IO.Stream swrite = System.IO.File.OpenWrite(@"compress-test\target.mwg"); System.IO.Stream comp = CompressionUtil.MZipCompress(sread); afh.File.StreamUtil.PassAll(swrite, comp); swrite.Close(); comp.Close(); sread.Close(); }
public static void test_FontManager_Serialization(afh.Application.Log log) { afh.Rendering.FontManager manage = new afh.Rendering.FontManager("MS Mincho", 10); manage.Bold = true; log.WriteLine("Serialize 前:"); log.WriteLine(manage.ToString()); System.Runtime.Serialization.Formatters.Binary.BinaryFormatter f = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); System.IO.Stream mstr = new System.IO.MemoryStream(); f.Serialize(mstr, manage); mstr.Position = 0; afh.Rendering.FontManager manage2 = (afh.Rendering.FontManager)f.Deserialize(mstr); log.WriteLine("Deserialize 後:"); log.WriteLine(manage2.ToString()); }
public static void analyze_generic_PrimitiveTypes(afh.Application.Log log) { const Ref::BindingFlags BF = Ref::BindingFlags.Static | Ref::BindingFlags.NonPublic; Ref::MethodInfo gen_meth = typeof(UnitTest).GetMethod("analyze_genprim_IsLargerThan", BF); Ref::MethodInfo nrm_meth = typeof(UnitTest).GetMethod("analyze_genprim_IsLargerThanPrim", BF); log.WriteLine("generic<T> body"); log.DumpBytes(gen_meth.GetMethodBody().GetILAsByteArray()); // null らしい log.WriteLine("generic<int> body"); log.DumpBytes(gen_meth.MakeGenericMethod(typeof(int)).GetMethodBody().GetILAsByteArray()); log.WriteLine("normal body"); log.DumpBytes(nrm_meth.GetMethodBody().GetILAsByteArray()); // 実際に実験 log.WriteLine(analyze_genprim_IsLargerThan <int>(10, 8)); log.WriteLine(analyze_genprim_IsLargerThanPrim(10, 8)); }
public static void test_ColorNameParse(afh.Application.Log log) { System.Action <string> test = delegate(string text){ int i = 0; afh.Rendering.ColorName c = new afh.Rendering.ColorName(text, ref i); log.WriteLine("入力文字列 : [{0}]", text); log.WriteLine("読み取り文字列: [{0}]", text.Substring(0, i)); log.WriteLine("読み取り結果 : {0}", c); log.WriteLine(); }; test("#012345"); test("#abAbCD"); test("#FFdd88aa"); test("#dfaabbcc"); test("#747"); test("#9876"); test("#675 #456 #436"); test("#FfA"); test("ReD"); test("rgb (1 , 2 , 3 )"); test("hsv(12.6,29.7,200) Hello"); }
public static void test_string_buffer(afh.Application.Log log) { log.Lock(); log.WriteLine("---- test1 -----------"); log.WriteLine(" 同内容の文字列即値"); log.WriteLine("----------------------"); string text0 = "AIUEO"; string text1 = "AIUEO"; log.WriteVar("text0", text0); log.WriteVar("text1", text1); log.WriteLine("text1 を直接書き換え..."); string_ToLower(text1); log.WriteVar("text0", text0); log.WriteVar("text1", text1); // 結果: 両方変更されていた log.WriteLine(); log.WriteLine("---- test2 -----------"); log.WriteLine(" 即値書き換え後、書き換え前の即値を代入したつもり"); log.WriteLine("----------------------"); log.WriteLine("text0 に AIUEO を代入..."); text0 = "AIUEO"; log.WriteVar("text0", text0); log.WriteLine("text0 に \"AIUE\" を代入..."); log.WriteLine("text0+=\"O\"..."); text0 = "AIUE"; text0 += "O"; log.WriteVar("text0", text0); log.WriteLine(); log.WriteLine("---- test3 -----------"); log.WriteLine(" +\"\" で異なるバッファになるか"); log.WriteLine("----------------------"); text0 = "IROHA"; text1 = text0 + ""; log.WriteVar("text0", text0); log.WriteVar("text1=text0+\"\"", text1); log.WriteLine("text1 を直接書き換え..."); string_ToLower(text1); log.WriteVar("text0", text0); log.WriteVar("text1", text1); log.WriteLine(); log.WriteLine("---- test4 -----------"); log.WriteLine(" SubString(0) で異なるバッファになるか"); log.WriteLine("----------------------"); text0 = "AMETSUCHI"; text1 = text0.Substring(0); log.WriteVar("text0", text0); log.WriteVar("text1=text2.SubString(0)", text1); log.WriteLine("text1 を直接書き換え..."); string_ToLower(text1); log.WriteVar("text0", text0); log.WriteVar("text1", text1); // 同じインスタンス log.WriteLine(); log.WriteLine("---- test5 -----------"); log.WriteLine(" SubString(*,*) で異なるバッファになるか"); log.WriteLine("----------------------"); text0 = "TAWYINI"; text1 = text0.Substring(2, 3); log.WriteVar("text0", text0); log.WriteVar("text1=text2.SubString(2,3)", text1); log.WriteLine("text1 を直接書き換え..."); string_ToLower(text1); log.WriteVar("text0", text0); log.WriteVar("text1", text1); // 異なるインスタンス log.WriteLine(); log.Unlock(); }