Hi Steve,
This is a superb tool, and it's helping me write better code already. I have a question.
I'm writing a value class that doesn't use the handle graphics set/get functions, and I want to use the xUnit test framework to verify that the proper errors pop up if I set properties to incorrect values, like:
myObj.my3Vector = [1 1];
In the set.my3Vector method I've defined an error message:
function set.my3Vector(vec)
if numel(vec)~=3
error('myClass:3Vec','Needs 3 elements')
end
end
The assert* functions work perfectly in diagnosing problems when I set the values as properties in the class constructor, because the class constructor expression doesn't need an '=' sign. The problem is that in diagnosing the first expression, I can't use an anonymous function handle because of the '=' sign. I guess if I were writing a handle class, the call would be set(myObj,'my3Vector',[1 1]) and there would be no problem. But I don't think I want a handle class for this application (though I could be wrong, being relatively new to OOP).
Is there a workaround I'm missing? I tried putting try-catch blocks in my test file, but it just errored out in the try block (I suppose the point of the test framework is to not use complicated try-catch expressions).
Any advice would be appreciated. Don't know if it matters, but I'm using R2010b.
Thanks!