Home | History | Annotate | Download | only in cts
      1 #include "shared.rsh"
      2 
      3 static bool test_clamp_vector() {
      4     bool failed = false;
      5 
      6     float2 src2 = { 2.0f, 2.0f};
      7     float2 min2 = { 0.5f, -3.0f};
      8     float2 max2 = { 1.0f, 9.0f};
      9 
     10     float2 res2 = clamp(src2, min2, max2);
     11     _RS_ASSERT(res2.x == 1.0f);
     12     _RS_ASSERT(res2.y == 2.0f);
     13 
     14 
     15     float3 src3 = { 2.0f, 2.0f, 1.0f};
     16     float3 min3 = { 0.5f, -3.0f, 3.0f};
     17     float3 max3 = { 1.0f, 9.0f, 4.0f};
     18 
     19     float3 res3 = clamp(src3, min3, max3);
     20     _RS_ASSERT(res3.x == 1.0f);
     21     _RS_ASSERT(res3.y == 2.0f);
     22     _RS_ASSERT(res3.z == 3.0f);
     23 
     24 
     25     float4 src4 = { 2.0f, 2.0f, 1.0f, 4.0f };
     26     float4 min4 = { 0.5f, -3.0f, 3.0f, 4.0f };
     27     float4 max4 = { 1.0f, 9.0f, 4.0f, 4.0f };
     28 
     29     float4 res4 = clamp(src4, min4, max4);
     30     _RS_ASSERT(res4.x == 1.0f);
     31     _RS_ASSERT(res4.y == 2.0f);
     32     _RS_ASSERT(res4.z == 3.0f);
     33     _RS_ASSERT(res4.w == 4.0f);
     34 
     35     if (failed) {
     36         rsDebug("test_clamp_vector FAILED", 0);
     37     }
     38     else {
     39         rsDebug("test_clamp_vector PASSED", 0);
     40     }
     41 
     42     return failed;
     43 }
     44 
     45 void clamp_test() {
     46     bool failed = false;
     47     failed |= test_clamp_vector();
     48 
     49     if (failed) {
     50         rsSendToClientBlocking(RS_MSG_TEST_FAILED);
     51     }
     52     else {
     53         rsSendToClientBlocking(RS_MSG_TEST_PASSED);
     54     }
     55 }
     56 
     57