c++ - Unittest++: test for multiple possible values -


I am currently implementing a simple tray tracer in C ++. I have a class called Orthogonal Basis, which is a Or generates three orthogonal unit vectors from two specified vectors, for example:

  void OrthonormalBasis :: init_from_u (Cunt Vector and U) {Vector N (1, 0,0); Vector m (0,1,0); U_ = united (U); V_ = cross (U_, n); If (v_.length () & lt; ONB_EPSILON) v_ = cross (u_, m); W_ = cross (u_, v_); }  

I am testing all my methods with the Unistet ++ framework. The problem is, there is more than one possible solution for a valid Orthonematic base. For example, this test:

exam (orthornarmlabassis_should_in_tam_u) {vector u (1,0,0); Orthonal Basis Onb; Onb.init_from_u (u); CHECK_EQUAL (vector (1, 0, 0), onb.au ()); CHECK_EQUAL (vector (0, 0, 1), onb.v ()); CHECK_EQUAL (vector (0, 1, 0), onb.w ()); }

Sometimes it succeeds, sometimes it fails, because in vectors v and w there can be a negative 1, and still a legitimate human Represents. Is there a way to specify many expected values? Or do you know another way to do this?

It is important that I get the actual and expected value printed in the standout so that this solution will not work to debug the methods:

  Exam (Orthoneormalbasis_should_int_frame_u) { Vector u (1,0,0); Orthonal Basis Onb; Onb.init_from_u (u); CHECK_EQUAL (vector (1, 0, 0), onb.au ()); Czech (vector (0, 0, 1) == onb.v () vector (0, 0, -1) == onb.v ()); Czech (vector (0, 1, 0) == onb.w () = vector (0, -1, 0) == onb.w ()); }     

Definitely if you are testing all Is your base Orthonal, so this is what you need to test?

  // Check Orthogonity CHECK_EQUAL (0, dot (onb.u (), onb.v); CHECK_EQUAL (0, dot (onb.u (), onb.w); CHECK_EQUAL (0, dot (onb.v), onb.w); // Czech Normal CHECK_EQUAL (1, dot (onb.u (), onb.u)); CHECK_EQUAL (1, dot (onb.v (), onb.v); CHECK_EQUAL (1, dot (onb.w (), onb.w);  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -