1 module tests.pass.property; 2 3 import unit_threaded; 4 5 @("int[] property") 6 unittest { 7 // probably as unlikely to happen as quantum tunneling to the moon 8 check!((int[] a) => a != [0, 1, 2, 3, 4]); 9 } 10 11 @("int[] sorting twice yields the same result") unittest { 12 import std.algorithm: sort; 13 check!((int[] a) { 14 sort(a); 15 auto b = a.dup; 16 sort(b); 17 return a == b; 18 }); 19 } 20 21 22 struct MyStruct { 23 int i; 24 } 25 26 @("Property testing with user defined type") 27 unittest { 28 checkCustom!( 29 () { 30 return MyStruct(5); 31 }, 32 (MyStruct s) { 33 return s.i == 5; 34 }); 35 } 36 37 @("Property testing with strings") 38 unittest { 39 check!((string s) { 40 import std.utf : validate, UTFException; 41 try { 42 validate(s); 43 } catch (UTFException e) { 44 return false; 45 } 46 return true; 47 }); 48 } 49 50 @("Property testing with wstrings") 51 unittest { 52 check!((wstring s) { 53 import std.utf : validate, UTFException; 54 try { 55 validate(s); 56 } catch (UTFException e) { 57 return false; 58 } 59 return true; 60 }); 61 } 62 63 @("Property testing with dstrings") 64 unittest { 65 check!((dstring s) { 66 import std.utf : validate, UTFException; 67 try { 68 validate(s); 69 } catch (UTFException e) { 70 return false; 71 } 72 return true; 73 }); 74 }