102030405060708090100110120130140150164371701843719020441212220230244372522602702843729437300310320330340350360370380390400410420430440450460470480490500510520530 module fluentasserts.core.operations.equal; import fluentasserts.core.results; import fluentasserts.core.evaluation; import fluentasserts.core.lifecycle; version(unittest) { import fluentasserts.core.expect; } static immutable equalDescription = "Asserts that the target is strictly == equal to the given val."; /// IResult[] equal(ref Evaluation evaluation) @safe nothrow { evaluation.message.addText("."); bool result = evaluation.currentValue.strValue == evaluation.expectedValue.strValue; if(!result && evaluation.currentValue.proxyValue !is null && evaluation.expectedValue.proxyValue !is null) { result = evaluation.currentValue.proxyValue.isEqualTo(evaluation.expectedValue.proxyValue); } if(evaluation.isNegated) { result = !result; } if(result) { return []; } IResult[] results = []; if(evaluation.currentValue.typeName != "bool") { evaluation.message.addText(" "); evaluation.message.addValue(evaluation.currentValue.strValue); if(evaluation.isNegated) { evaluation.message.addText(" is equal to "); } else { evaluation.message.addText(" is not equal to "); } evaluation.message.addValue(evaluation.expectedValue.strValue); evaluation.message.addText("."); try results ~= new DiffResult(evaluation.expectedValue.strValue, evaluation.currentValue.strValue); catch(Exception) {} } try results ~= new ExpectedActualResult((evaluation.isNegated ? "not " : "") ~ evaluation.expectedValue.strValue, evaluation.currentValue.strValue); catch(Exception) {} return results; }
module fluentasserts.core.operations.equal; import fluentasserts.core.results; import fluentasserts.core.evaluation; import fluentasserts.core.lifecycle; version(unittest) { import fluentasserts.core.expect; } static immutable equalDescription = "Asserts that the target is strictly == equal to the given val."; /// IResult[] equal(ref Evaluation evaluation) @safe nothrow { evaluation.message.addText("."); bool result = evaluation.currentValue.strValue == evaluation.expectedValue.strValue; if(!result && evaluation.currentValue.proxyValue !is null && evaluation.expectedValue.proxyValue !is null) { result = evaluation.currentValue.proxyValue.isEqualTo(evaluation.expectedValue.proxyValue); } if(evaluation.isNegated) { result = !result; } if(result) { return []; } IResult[] results = []; if(evaluation.currentValue.typeName != "bool") { evaluation.message.addText(" "); evaluation.message.addValue(evaluation.currentValue.strValue); if(evaluation.isNegated) { evaluation.message.addText(" is equal to "); } else { evaluation.message.addText(" is not equal to "); } evaluation.message.addValue(evaluation.expectedValue.strValue); evaluation.message.addText("."); try results ~= new DiffResult(evaluation.expectedValue.strValue, evaluation.currentValue.strValue); catch(Exception) {} } try results ~= new ExpectedActualResult((evaluation.isNegated ? "not " : "") ~ evaluation.expectedValue.strValue, evaluation.currentValue.strValue); catch(Exception) {} return results; }