Diff
Not logged in

Differences From Artifact [aa60c34591041ca2]:

To Artifact [e911a30d1f923777]:


16 auto writer = appender!string(); 16 auto writer = appender!string(); 17 formattedWrite(writer, fmt, params); 17 formattedWrite(writer, fmt, params); 18 return writer.data; 18 return writer.data; 19 } 19 } 20 20 21 unittest 21 unittest 22 { 22 { 23 assert( sprintf!"%s == %d"("1+2", 3) == "1+2 == 3" ); | 23 assert( sprintf!"%s == %d"("1+2", 3) == "1+2 == 3" ); 24 assert( sprintf!"%s == %04d"("1+2", 3) == "1+2 == 0003" ); 24 assert( sprintf!"%s == %04d"("1+2", 3) == "1+2 == 0003" ); 25 } 25 } 26 26 27 /// Unittest helper that asserts an expression must throw something 27 /// Unittest helper that asserts an expression must throw something 28 28 29 void assert_throw(ExceptionType, T, string fn=__FILE__, int ln=__LINE__)(lazy T 29 void assert_throw(ExceptionType, T, string fn=__FILE__, int ln=__LINE__)(lazy T 30 { 30 { ................................................................................................................................................................................ 85 alias assertOp!(`<`) assert_lt; 85 alias assertOp!(`<`) assert_lt; 86 alias assertOp!(`<=`) assert_le; 86 alias assertOp!(`<=`) assert_le; 87 alias assertOp!(`>`) assert_gt; 87 alias assertOp!(`>`) assert_gt; 88 alias assertOp!(`>=`) assert_ge; 88 alias assertOp!(`>=`) assert_ge; 89 89 90 unittest 90 unittest 91 { 91 { 92 assert_nothrow( assert_eq("foo", "foo") ); | 92 assert_nothrow( assert_eq(1, 1) ); 93 assert_nothrow( assert_ne("foo", "bar") ); | 93 assert_nothrow( assert_ne(1, 0) ); 94 assert_nothrow( assert_lt("bar", "foo") ); | 94 assert_nothrow( assert_lt(0, 1) ); 95 assert_nothrow( assert_le("bar", "foo") ); | 95 assert_nothrow( assert_le(0, 1) ); 96 assert_nothrow( assert_le("bar", "bar") ); | 96 assert_nothrow( assert_le(0, 0) ); 97 assert_nothrow( assert_gt("foo", "bar") ); | 97 assert_nothrow( assert_gt(1, 0) ); 98 assert_nothrow( assert_ge("foo", "bar") ); | 98 assert_nothrow( assert_ge(1, 0) ); 99 assert_nothrow( assert_ge("bar", "bar") ); | 99 assert_nothrow( assert_ge(0, 0) ); 100 100 101 assert_throw!AssertError( assert_eq("foo", "bar") ); | 101 assert_throw!AssertError( assert_eq(1, 0) ); 102 assert_throw!AssertError( assert_ne("foo", "foo") ); | 102 assert_throw!AssertError( assert_ne(1, 1) ); 103 assert_throw!AssertError( assert_lt("foo", "foo") ); | 103 assert_throw!AssertError( assert_lt(1, 1) ); 104 assert_throw!AssertError( assert_lt("foo", "bar") ); | 104 assert_throw!AssertError( assert_lt(1, 0) ); 105 assert_throw!AssertError( assert_le("foo", "bar") ); | 105 assert_throw!AssertError( assert_le(1, 0) ); 106 assert_throw!AssertError( assert_gt("bar", "bar") ); | 106 assert_throw!AssertError( assert_gt(0, 0) ); 107 assert_throw!AssertError( assert_gt("bar", "foo") ); | 107 assert_throw!AssertError( assert_gt(0, 1) ); 108 assert_throw!AssertError( assert_ge("bar", "foo") ); | 108 assert_throw!AssertError( assert_ge(0, 1) ); 109 109 110 class Temp { bool opEquals(int x){return x/x==x;} } 110 class Temp { bool opEquals(int x){return x/x==x;} } 111 assert_throw!AssertError( assert_eq(new Temp, 0) ); 111 assert_throw!AssertError( assert_eq(new Temp, 0) ); 112 assert_nothrow ( assert_eq(new Temp, 1) ); 112 assert_nothrow ( assert_eq(new Temp, 1) ); 113 assert_throw!AssertError( assert_eq(new Temp, 2) ); 113 assert_throw!AssertError( assert_eq(new Temp, 2) ); 114 } 114 } 115 115