1 #include "shared.rsh" 2 3 // Testing vector types 4 float2 f2 = { 1.0f, 2.0f }; 5 float3 f3 = { 1.0f, 2.0f, 3.0f }; 6 float4 f4 = { 1.0f, 2.0f, 3.0f, 4.0f }; 7 8 double2 d2 = { 1.0, 2.0 }; 9 double3 d3 = { 1.0, 2.0, 3.0 }; 10 double4 d4 = { 1.0, 2.0, 3.0, 4.0 }; 11 12 char2 i8_2 = { 1, 2 }; 13 char3 i8_3 = { 1, 2, 3 }; 14 char4 i8_4 = { 1, 2, 3, 4 }; 15 16 uchar2 u8_2 = { 1, 2 }; 17 uchar3 u8_3 = { 1, 2, 3 }; 18 uchar4 u8_4 = { 1, 2, 3, 4 }; 19 20 short2 i16_2 = { 1, 2 }; 21 short3 i16_3 = { 1, 2, 3 }; 22 short4 i16_4 = { 1, 2, 3, 4 }; 23 24 ushort2 u16_2 = { 1, 2 }; 25 ushort3 u16_3 = { 1, 2, 3 }; 26 ushort4 u16_4 = { 1, 2, 3, 4 }; 27 28 int2 i32_2 = { 1, 2 }; 29 int3 i32_3 = { 1, 2, 3 }; 30 int4 i32_4 = { 1, 2, 3, 4 }; 31 32 uint2 u32_2 = { 1, 2 }; 33 uint3 u32_3 = { 1, 2, 3 }; 34 uint4 u32_4 = { 1, 2, 3, 4 }; 35 36 long2 i64_2 = { 1, 2 }; 37 long3 i64_3 = { 1, 2, 3 }; 38 long4 i64_4 = { 1, 2, 3, 4 }; 39 40 ulong2 u64_2 = { 1, 2 }; 41 ulong3 u64_3 = { 1, 2, 3 }; 42 ulong4 u64_4 = { 1, 2, 3, 4 }; 43 44 static bool test_vector_types() { 45 bool failed = false; 46 47 rsDebug("Testing F32", 0); 48 _RS_ASSERT(f2.x == 2.99f); 49 _RS_ASSERT(f2.y == 3.99f); 50 51 _RS_ASSERT(f3.x == 2.99f); 52 _RS_ASSERT(f3.y == 3.99f); 53 _RS_ASSERT(f3.z == 4.99f); 54 55 _RS_ASSERT(f4.x == 2.99f); 56 _RS_ASSERT(f4.y == 3.99f); 57 _RS_ASSERT(f4.z == 4.99f); 58 _RS_ASSERT(f4.w == 5.99f); 59 60 rsDebug("Testing F64", 0); 61 _RS_ASSERT(d2.x == 2.99); 62 _RS_ASSERT(d2.y == 3.99); 63 64 _RS_ASSERT(d3.x == 2.99); 65 _RS_ASSERT(d3.y == 3.99); 66 _RS_ASSERT(d3.z == 4.99); 67 68 _RS_ASSERT(d4.x == 2.99); 69 _RS_ASSERT(d4.y == 3.99); 70 _RS_ASSERT(d4.z == 4.99); 71 _RS_ASSERT(d4.w == 5.99); 72 73 rsDebug("Testing I8", 0); 74 _RS_ASSERT(i8_2.x == 2); 75 _RS_ASSERT(i8_2.y == 3); 76 77 _RS_ASSERT(i8_3.x == 2); 78 _RS_ASSERT(i8_3.y == 3); 79 _RS_ASSERT(i8_3.z == 4); 80 81 _RS_ASSERT(i8_4.x == 2); 82 _RS_ASSERT(i8_4.y == 3); 83 _RS_ASSERT(i8_4.z == 4); 84 _RS_ASSERT(i8_4.w == 5); 85 86 rsDebug("Testing U8", 0); 87 _RS_ASSERT(u8_2.x == 2); 88 _RS_ASSERT(u8_2.y == 3); 89 90 _RS_ASSERT(u8_3.x == 2); 91 _RS_ASSERT(u8_3.y == 3); 92 _RS_ASSERT(u8_3.z == 4); 93 94 _RS_ASSERT(u8_4.x == 2); 95 _RS_ASSERT(u8_4.y == 3); 96 _RS_ASSERT(u8_4.z == 4); 97 _RS_ASSERT(u8_4.w == 5); 98 99 rsDebug("Testing I16", 0); 100 _RS_ASSERT(i16_2.x == 2); 101 _RS_ASSERT(i16_2.y == 3); 102 103 _RS_ASSERT(i16_3.x == 2); 104 _RS_ASSERT(i16_3.y == 3); 105 _RS_ASSERT(i16_3.z == 4); 106 107 _RS_ASSERT(i16_4.x == 2); 108 _RS_ASSERT(i16_4.y == 3); 109 _RS_ASSERT(i16_4.z == 4); 110 _RS_ASSERT(i16_4.w == 5); 111 112 rsDebug("Testing U16", 0); 113 _RS_ASSERT(u16_2.x == 2); 114 _RS_ASSERT(u16_2.y == 3); 115 116 _RS_ASSERT(u16_3.x == 2); 117 _RS_ASSERT(u16_3.y == 3); 118 _RS_ASSERT(u16_3.z == 4); 119 120 _RS_ASSERT(u16_4.x == 2); 121 _RS_ASSERT(u16_4.y == 3); 122 _RS_ASSERT(u16_4.z == 4); 123 _RS_ASSERT(u16_4.w == 5); 124 125 rsDebug("Testing I32", 0); 126 _RS_ASSERT(i32_2.x == 2); 127 _RS_ASSERT(i32_2.y == 3); 128 129 _RS_ASSERT(i32_3.x == 2); 130 _RS_ASSERT(i32_3.y == 3); 131 _RS_ASSERT(i32_3.z == 4); 132 133 _RS_ASSERT(i32_4.x == 2); 134 _RS_ASSERT(i32_4.y == 3); 135 _RS_ASSERT(i32_4.z == 4); 136 _RS_ASSERT(i32_4.w == 5); 137 138 rsDebug("Testing U32", 0); 139 _RS_ASSERT(u32_2.x == 2); 140 _RS_ASSERT(u32_2.y == 3); 141 142 _RS_ASSERT(u32_3.x == 2); 143 _RS_ASSERT(u32_3.y == 3); 144 _RS_ASSERT(u32_3.z == 4); 145 146 _RS_ASSERT(u32_4.x == 2); 147 _RS_ASSERT(u32_4.y == 3); 148 _RS_ASSERT(u32_4.z == 4); 149 _RS_ASSERT(u32_4.w == 5); 150 151 rsDebug("Testing I64", 0); 152 _RS_ASSERT(i64_2.x == 2); 153 _RS_ASSERT(i64_2.y == 3); 154 155 _RS_ASSERT(i64_3.x == 2); 156 _RS_ASSERT(i64_3.y == 3); 157 _RS_ASSERT(i64_3.z == 4); 158 159 _RS_ASSERT(i64_4.x == 2); 160 _RS_ASSERT(i64_4.y == 3); 161 _RS_ASSERT(i64_4.z == 4); 162 _RS_ASSERT(i64_4.w == 5); 163 164 rsDebug("Testing U64", 0); 165 _RS_ASSERT(u64_2.x == 2); 166 _RS_ASSERT(u64_2.y == 3); 167 168 _RS_ASSERT(u64_3.x == 2); 169 _RS_ASSERT(u64_3.y == 3); 170 _RS_ASSERT(u64_3.z == 4); 171 172 _RS_ASSERT(u64_4.x == 2); 173 _RS_ASSERT(u64_4.y == 3); 174 _RS_ASSERT(u64_4.z == 4); 175 _RS_ASSERT(u64_4.w == 5); 176 177 if (failed) { 178 rsDebug("test_vector FAILED", 0); 179 } 180 else { 181 rsDebug("test_vector PASSED", 0); 182 } 183 184 return failed; 185 } 186 187 void vector_test() { 188 bool failed = false; 189 failed |= test_vector_types(); 190 191 if (failed) { 192 rsSendToClientBlocking(RS_MSG_TEST_FAILED); 193 } 194 else { 195 rsSendToClientBlocking(RS_MSG_TEST_PASSED); 196 } 197 } 198 199