ketura

stat_tests.v.1

Aug 25th, 2017
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.31 KB | None | 0 0
  1. <#@ template debug="true" hostspecific="false" language="C#" #>
  2. <#@ assembly name="System.Core" #>
  3. <#@ import namespace="System.Linq" #>
  4. <#@ import namespace="System.Text" #>
  5. <#@ import namespace="System.Collections.Generic" #>
  6. <#@ output extension=".cs" #>
  7.  
  8. <#
  9.  
  10. Dictionary<string, TypeInfo> types = new Dictionary<string, TypeInfo>()
  11. {
  12.  
  13. { "Decimal", new TypeInfo() { Type = typeof(decimal), TypeName = "Decimal", Name = "Decimal", Signed = true, Decimal = true, MateName = null, BitCount = 128, ConvertTo = new Dictionary<string, string>(), ConvertFrom = new Dictionary<string, string>() } },
  14. { "Double", new TypeInfo() { Type = typeof(double), TypeName = "Double", Name = "Double", Signed = true, Decimal = true, MateName = null, BitCount = 64, ConvertTo = new Dictionary<string, string>(), ConvertFrom = new Dictionary<string, string>() } },
  15. { "Float", new TypeInfo() { Type = typeof(Single), TypeName = "Single", Name = "Float", Signed = true, Decimal = true, MateName = null, BitCount = 32, ConvertTo = new Dictionary<string, string>(), ConvertFrom = new Dictionary<string, string>() } },
  16. { "Byte", new TypeInfo() { Type = typeof(byte), TypeName = "Byte", Name = "Byte", Signed = false, Decimal = false, MateName = "SByte", BitCount = 8, ConvertTo = new Dictionary<string, string>(), ConvertFrom = new Dictionary<string, string>() } },
  17. { "SByte", new TypeInfo() { Type = typeof(sbyte), TypeName = "SByte", Name = "SByte", Signed = true, Decimal = false, MateName = "Byte", BitCount = 8, ConvertTo = new Dictionary<string, string>(), ConvertFrom = new Dictionary<string, string>() } },
  18. { "Short", new TypeInfo() { Type = typeof(Int16), TypeName = "Int16", Name = "Short", Signed = true, Decimal = false, MateName = "UShort", BitCount = 16, ConvertTo = new Dictionary<string, string>(), ConvertFrom = new Dictionary<string, string>() } },
  19. { "UShort", new TypeInfo() { Type = typeof(UInt16), TypeName = "UInt16", Name = "UShort", Signed = false, Decimal = false, MateName = "Short", BitCount = 16, ConvertTo = new Dictionary<string, string>(), ConvertFrom = new Dictionary<string, string>() } },
  20. { "Int", new TypeInfo() { Type = typeof(Int32), TypeName = "Int32", Name = "Int", Signed = true, Decimal = false, MateName = "UInt", BitCount = 32, ConvertTo = new Dictionary<string, string>(), ConvertFrom = new Dictionary<string, string>() } },
  21. { "UInt", new TypeInfo() { Type = typeof(UInt32), TypeName = "UInt32", Name = "UInt", Signed = false, Decimal = false, MateName = "Int", BitCount = 32, ConvertTo = new Dictionary<string, string>(), ConvertFrom = new Dictionary<string, string>() } },
  22. { "Long", new TypeInfo() { Type = typeof(Int64), TypeName = "Int64", Name = "Long", Signed = true, Decimal = false, MateName = "ULong", BitCount = 64, ConvertTo = new Dictionary<string, string>(), ConvertFrom = new Dictionary<string, string>() } },
  23. { "ULong", new TypeInfo() { Type = typeof(UInt64), TypeName = "UInt64", Name = "ULong", Signed = false, Decimal = false, MateName = "Long", BitCount = 64, ConvertTo = new Dictionary<string, string>(), ConvertFrom = new Dictionary<string, string>() } }
  24.  
  25. };
  26.  
  27.  
  28. #>
  29.  
  30. using System;
  31. //using XGEFCore;
  32. using test;
  33. //using Microsoft.VisualStudio.TestTools.UnitTesting;
  34. using Stats;
  35.  
  36. //****************************
  37. //****************************
  38. //
  39. // THE BELOW CODE IS AUTOGENERATED.  Please do not bother editing it, instead please see the template that it was generated from.
  40. //
  41. //****************************
  42. //****************************
  43.  
  44.  
  45. namespace StatTests
  46. {
  47.  
  48.     public class Assert
  49.     {
  50.         public static void IsTrue(params object[] values) { }
  51.     }
  52.  
  53. <#  foreach(var pair in types) {
  54.             string T = pair.Value.Type.Name;
  55.             string Class = pair.Key + "Stat"; #>
  56.  
  57.     //[TestClass()]
  58.     public class <#= Class #>Tests
  59.     {
  60.         #region Operator Overload Tests
  61. <#  foreach(var typePair in types) {
  62.             string otherT = typePair.Value.Type.Name;
  63.             string otherClass = typePair.Value.Name + "Stat";#>
  64.  
  65.         //[TestMethod()]
  66.         public void <#= Class #>_Add<#= otherT #>()
  67.         {
  68.             <#= Class #> stat = 0;
  69.             <#= otherT #> rhs = 50;
  70.             stat += rhs;
  71.             Assert.IsTrue(stat.Value == 50);
  72.         }
  73.         //[TestMethod()]
  74.         public void <#= Class #>_Add<#= otherClass #>()
  75.         {
  76.             <#= Class #> stat = 0;
  77.             <#= otherClass #> rhs = 50;
  78.             stat += rhs;
  79.             Assert.IsTrue(stat.Value == 50);
  80.         }
  81.  
  82.         //[TestMethod()]
  83.         public void <#= Class #>_Subtract<#= otherT #>()
  84.         {
  85.             <#= Class #> stat = 100;
  86.             <#= otherT #> rhs = 50;
  87.             stat -= rhs;
  88.             Assert.IsTrue(stat.Value == 50);
  89.         }
  90.         //[TestMethod()]
  91.         public void <#= Class #>_Subtract<#= otherClass #>()
  92.         {
  93.             <#= Class #> stat = 100;
  94.             <#= otherClass #> rhs = 50;
  95.             stat += rhs;
  96.             Assert.IsTrue(stat.Value == 50);
  97.         }
  98.  
  99.         //[TestMethod()]
  100.         public void <#= Class #>_Multiply<#= otherT #>()
  101.         {
  102.             <#= Class #> stat = 10;
  103.             <#= otherT #> rhs = 5;
  104.             stat *= rhs;
  105.             Assert.IsTrue(stat.Value == 50);
  106.         }
  107.         //[TestMethod()]
  108.         public void <#= Class #>_Multiply<#= otherClass #>()
  109.         {
  110.             <#= Class #> stat = 10;
  111.             <#= otherClass #> rhs = 5;
  112.             stat *= rhs;
  113.             Assert.IsTrue(stat.Value == 50);
  114.         }
  115.  
  116.         //[TestMethod()]
  117.         public void <#= Class #>_Divide<#= otherT #>()
  118.         {
  119.             <#= Class #> stat = 50;
  120.             <#= otherT #> rhs = 10;
  121.             stat /= rhs;
  122.             Assert.IsTrue(stat.Value == 5);
  123.         }
  124.         //[TestMethod()]
  125.         public void <#= Class #>_Divide<#= otherClass #>()
  126.         {
  127.             <#= Class #> stat = 50;
  128.             <#= otherClass #> rhs = 10;
  129.             stat /= rhs;
  130.             Assert.IsTrue(stat.Value == 5);
  131.         }
  132.  
  133.         //[TestMethod()]
  134.         public void <#= Class #>_Modulo<#= otherT #>()
  135.         {
  136.             <#= Class #> stat = 50;
  137.             <#= otherT #> rhs = 10;
  138.             stat %= rhs;
  139.             Assert.IsTrue(stat.Value == 0);
  140.         }
  141.         //[TestMethod()]
  142.         public void <#= Class #>_Modulo<#= otherClass #>()
  143.         {
  144.             <#= Class #> stat = 50;
  145.             <#= otherClass #> rhs = 10;
  146.             stat %= rhs;
  147.             Assert.IsTrue(stat.Value == 0);
  148.         }
  149.  
  150.         //[TestMethod()]
  151.         public void <#= Class #>_Pow<#= otherT #>()
  152.         {
  153.             <#= Class #> stat = 10;
  154.             <#= otherT #> rhs = 2;
  155.             stat ^= rhs;
  156.             Assert.IsTrue(stat.Value == 100);
  157.         }
  158.         //[TestMethod()]
  159.         public void <#= Class #>_Pow<#= otherClass #>()
  160.         {
  161.             <#= Class #> stat = 10;
  162.             <#= otherClass #> rhs = 2;
  163.             stat ^= rhs;
  164.             Assert.IsTrue(stat.Value == 100);
  165.         }
  166.  
  167.         //[TestMethod()]
  168.         public void <#= Class #>_GreaterThan<#= otherT #>()
  169.         {
  170.             <#= Class #> stat = 10;
  171.             <#= otherT #> rhs = 2;
  172.             Assert.IsTrue(stat > rhs);
  173.         }
  174.         //[TestMethod()]
  175.         public void <#= Class #>_GreaterThan<#= otherClass #>()
  176.         {
  177.             <#= Class #> stat = 10;
  178.             <#= otherClass #> rhs = 2;
  179.             Assert.IsTrue(stat > rhs);
  180.         }
  181.  
  182.         //[TestMethod()]
  183.         public void <#= Class #>_LessThan<#= otherT #>()
  184.         {
  185.             <#= Class #> stat = 10;
  186.             <#= otherT #> rhs = 100;
  187.             Assert.IsTrue(stat < rhs);
  188.         }
  189.         //[TestMethod()]
  190.         public void <#= Class #>_LessThan<#= otherClass #>()
  191.         {
  192.             <#= Class #> stat = 10;
  193.             <#= otherClass #> rhs = 100;
  194.             Assert.IsTrue(stat < rhs);
  195.         }
  196. <# } #>
  197.     }
  198.     #endregion
  199.  
  200.    
  201.  
  202.    
  203. <# } #>
  204. }
  205.  
  206. <#+
  207. public struct TypeInfo
  208. {
  209.     public Type Type { get; set; }
  210.     public string Name { get; set; }
  211.     public string TypeName { get; set; }
  212.     public bool Signed { get; set; }
  213.     public bool Decimal { get; set; }
  214.     public string MateName { get; set; }
  215.     public int BitCount { get; set; }
  216.     public Dictionary<string, string> ConvertTo { get; set; }
  217.     public Dictionary<string, string> ConvertFrom{ get; set; }
  218. }
  219. #>
Advertisement
Add Comment
Please, Sign In to add comment