raylib-assert.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. /**********************************************************************************************
  2. *
  3. * raylib-assert - Assertion library for raylib.
  4. * https://github.com/robloach/raylib-assert
  5. *
  6. * Version: v3.0.0
  7. *
  8. * Copyright 2023 Rob Loach (@RobLoach)
  9. *
  10. * DEPENDENCIES:
  11. * raylib 5.5+ https://www.raylib.com
  12. *
  13. * LICENSE: zlib/libpng
  14. *
  15. * raylib-assert is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
  16. * BSD-like license that allows static linking with closed source software:
  17. *
  18. * This software is provided "as-is", without any express or implied warranty. In no event
  19. * will the authors be held liable for any damages arising from the use of this software.
  20. *
  21. * Permission is granted to anyone to use this software for any purpose, including commercial
  22. * applications, and to alter it and redistribute it freely, subject to the following restrictions:
  23. *
  24. * 1. The origin of this software must not be misrepresented; you must not claim that you
  25. * wrote the original software. If you use this software in a product, an acknowledgment
  26. * in the product documentation would be appreciated but is not required.
  27. *
  28. * 2. Altered source versions must be plainly marked as such, and must not be misrepresented
  29. * as being the original software.
  30. *
  31. * 3. This notice may not be removed or altered from any source distribution.
  32. *
  33. **********************************************************************************************/
  34. #ifndef RAYLIB_ASSERT_H
  35. #define RAYLIB_ASSERT_H
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. // How to report failed assertions
  40. #ifndef RAYLIB_ASSERT_LOG
  41. /**
  42. * The Trace Log Level used to report to TraceLog() on failed assertions. Defaults to LOG_FATAL.
  43. *
  44. * @example
  45. * #define RAYLIB_ASSERT_LOG LOG_WARNING
  46. *
  47. * @see TraceLogLevel
  48. */
  49. #define RAYLIB_ASSERT_LOG LOG_FATAL
  50. #endif
  51. // Define NDEBUG or RAYLIB_ASSERT_NDEBUG to skip assertions
  52. #ifdef NDEBUG
  53. #ifndef RAYLIB_ASSERT_NDEBUG
  54. #define RAYLIB_ASSERT_NDEBUG
  55. #endif
  56. #endif
  57. #ifndef RAYLIB_ASSERT_TRACELOG
  58. /**
  59. * The TraceLog() function to use.
  60. *
  61. * @see TraceLog()
  62. */
  63. #define RAYLIB_ASSERT_TRACELOG TraceLog
  64. #endif
  65. #ifndef RAYLIB_ASSERT_TEXTFORMAT
  66. /**
  67. * The TextFormat() function to use when formating text.
  68. *
  69. * @see TextFormat()
  70. */
  71. #define RAYLIB_ASSERT_TEXTFORMAT TextFormat
  72. #endif
  73. // Variadic Arguments
  74. #define RAYLIB_ASSERT_CAT( A, B ) A ## B
  75. #define RAYLIB_ASSERT_SELECT( NAME, NUM ) RAYLIB_ASSERT_CAT( NAME ## _, NUM )
  76. #define RAYLIB_ASSERT_GET_COUNT( _1, _2, _3, _4, _5, _6, _7, RAYLIB_ASSERT_COUNT, ... ) RAYLIB_ASSERT_COUNT
  77. #define RAYLIB_ASSERT_VA_SIZE( ... ) RAYLIB_ASSERT_GET_COUNT( __VA_ARGS__, 7, 6, 5, 4, 3, 2, 1 )
  78. #define RAYLIB_ASSERT_VA_SELECT( NAME, ... ) RAYLIB_ASSERT_SELECT( NAME, RAYLIB_ASSERT_VA_SIZE(__VA_ARGS__) )(__VA_ARGS__)
  79. /**
  80. * Assert whether the given condition is true.
  81. *
  82. * @param condition The condition that is expected to be true.
  83. * @param message (Optional) The message to provide on failed assertions.
  84. * @param p1 (Optional) The first parameter in the message.
  85. * @param p2 (Optional) The second parameter in the message.
  86. * @param p3 (Optional) The third parameter in the message.
  87. * @param p4 (Optional) The fourth parameter in the message.
  88. * @param p5 (Optional) The fifth parameter in the message.
  89. */
  90. #define Assert(...) RAYLIB_ASSERT_VA_SELECT(Assert, __VA_ARGS__)
  91. /**
  92. * Assert whether the two given parameters are equal.
  93. *
  94. * @param actual The actual value.
  95. * @param expected The expected value.
  96. * @param message (Optional) The message to provide on failed assertions.
  97. * @param p1 (Optional) The first parameter in the message.
  98. * @param p2 (Optional) The second parameter in the message.
  99. * @param p3 (Optional) The third parameter in the message.
  100. * @param p4 (Optional) The fourth parameter in the message.
  101. */
  102. #define AssertEqual(...) RAYLIB_ASSERT_VA_SELECT(AssertEqual, __VA_ARGS__)
  103. /**
  104. * Assert whether the given condition is false.
  105. *
  106. * @param condition The condition that is expected to be false.
  107. * @param message (Optional) The message to provide on failed assertions.
  108. * @param p1 (Optional) The first parameter in the message.
  109. * @param p2 (Optional) The second parameter in the message.
  110. * @param p3 (Optional) The third parameter in the message.
  111. * @param p4 (Optional) The fourth parameter in the message.
  112. * @param p5 (Optional) The fifth parameter in the message.
  113. */
  114. #define AssertNot(...) RAYLIB_ASSERT_VA_SELECT(AssertNot, __VA_ARGS__)
  115. /**
  116. * Assert whether the two given parameters are not equal.
  117. *
  118. * @param actual The actual value.
  119. * @param notexpected The expected value that shouldn't equal the actual value.
  120. * @param message (Optional) The message to provide on failed assertions.
  121. * @param p1 (Optional) The first parameter in the message.
  122. * @param p2 (Optional) The second parameter in the message.
  123. * @param p3 (Optional) The third parameter in the message.
  124. * @param p4 (Optional) The fourth parameter in the message.
  125. */
  126. #define AssertNotEqual(...) RAYLIB_ASSERT_VA_SELECT(AssertNotEqual, __VA_ARGS__)
  127. /**
  128. * Sets a failed assertion, with the given message.
  129. *
  130. * @param message (Optional) The message to provide for the failed assertion.
  131. * @param p1 (Optional) The first parameter in the message.
  132. * @param p2 (Optional) The second parameter in the message.
  133. * @param p3 (Optional) The third parameter in the message.
  134. * @param p4 (Optional) The fourth parameter in the message.
  135. * @param p5 (Optional) The fifth parameter in the message.
  136. * @param p6 (Optional) The sixth parameter in the message.
  137. */
  138. #define AssertFail(...) RAYLIB_ASSERT_VA_SELECT(AssertFail, __VA_ARGS__)
  139. /**
  140. * Assert whether an image is loaded.
  141. *
  142. * @param image The image to check for valid data.
  143. * @param message (Optional) The message to provide on failed assertions.
  144. * @param p1 (Optional) The first parameter in the message.
  145. * @param p2 (Optional) The second parameter in the message.
  146. * @param p3 (Optional) The third parameter in the message.
  147. * @param p4 (Optional) The fourth parameter in the message.
  148. * @param p5 (Optional) The fifth parameter in the message.
  149. */
  150. #define AssertImage(...) RAYLIB_ASSERT_VA_SELECT(AssertImage, __VA_ARGS__)
  151. /**
  152. * Assert whether two images are the same.
  153. *
  154. * @param image1 The first image to check is equal to the second.
  155. * @param image2 The second image to check is equal to the first.
  156. * @param message (Optional) The message to provide on failed assertions.
  157. * @param p1 (Optional) The first parameter in the message.
  158. * @param p2 (Optional) The second parameter in the message.
  159. * @param p3 (Optional) The third parameter in the message.
  160. * @param p4 (Optional) The fourth parameter in the message.
  161. */
  162. #define AssertImageSame(...) RAYLIB_ASSERT_VA_SELECT(AssertImageSame, __VA_ARGS__)
  163. /**
  164. * Assert whether two colors are the same.
  165. *
  166. * @param color1 The first color to check.
  167. * @param color2 The second color to check.
  168. * @param message (Optional) The message to provide on failed assertions.
  169. * @param p1 (Optional) The first parameter in the message.
  170. * @param p2 (Optional) The second parameter in the message.
  171. * @param p3 (Optional) The third parameter in the message.
  172. * @param p4 (Optional) The fourth parameter in the message.
  173. */
  174. #define AssertColorSame(...) RAYLIB_ASSERT_VA_SELECT(AssertColorSame, __VA_ARGS__)
  175. /**
  176. * Assert whether two Vector2s are the same.
  177. *
  178. * @param vector1 The first Vector2 to check.
  179. * @param vector2 The second Vector2 to check.
  180. * @param message (Optional) The message to provide on failed assertions.
  181. * @param p1 (Optional) The first parameter in the message.
  182. * @param p2 (Optional) The second parameter in the message.
  183. * @param p3 (Optional) The third parameter in the message.
  184. * @param p4 (Optional) The fourth parameter in the message.
  185. */
  186. #define AssertVector2Same(...) RAYLIB_ASSERT_VA_SELECT(AssertVector2Same, __VA_ARGS__)
  187. /**
  188. * Assert whether two Vector3s are the same.
  189. *
  190. * @param vector1 The first Vector3 to check.
  191. * @param vector2 The second Vector3 to check.
  192. * @param message (Optional) The message to provide on failed assertions.
  193. * @param p1 (Optional) The first parameter in the message.
  194. * @param p2 (Optional) The second parameter in the message.
  195. * @param p3 (Optional) The third parameter in the message.
  196. * @param p4 (Optional) The fourth parameter in the message.
  197. */
  198. #define AssertVector3Same(...) RAYLIB_ASSERT_VA_SELECT(AssertVector3Same, __VA_ARGS__)
  199. // Assert()
  200. #ifdef RAYLIB_ASSERT_NDEBUG
  201. #define Assert_0()
  202. #define Assert_1(condition)
  203. #define Assert_2(condition, message)
  204. #define Assert_3(condition, message, p1)
  205. #define Assert_4(condition, message, p1, p2)
  206. #define Assert_5(condition, message, p1, p2, p3)
  207. #define Assert_6(condition, message, p1, p2, p3, p4)
  208. #define Assert_7(condition, message, p1, p2, p3, p4, p5)
  209. #else
  210. #define Assert_0() AssertFail_1("No condition provided for Assert()")
  211. #define Assert_1(condition) Assert_2(condition, #condition)
  212. #define Assert_2(condition, message) do { if (!((bool)(condition))) { RAYLIB_ASSERT_TRACELOG(RAYLIB_ASSERT_LOG, "ASSERT: %s (%s:%i)", message, __FILE__, __LINE__); } } while(0)
  213. #define Assert_3(condition, message, p1) Assert_2(condition, RAYLIB_ASSERT_TEXTFORMAT(message, p1))
  214. #define Assert_4(condition, message, p1, p2) Assert_2(condition, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2))
  215. #define Assert_5(condition, message, p1, p2, p3) Assert_2(condition, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3))
  216. #define Assert_6(condition, message, p1, p2, p3, p4) Assert_2(condition, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4))
  217. #define Assert_7(condition, message, p1, p2, p3, p4, p5) Assert_2(condition, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4, p5))
  218. #endif
  219. // AssertEqual()
  220. #define AssertEqual_0() AssertFail_1("No condition provided for AssertEqual()")
  221. #define AssertEqual_1(condition) Assert_2(condition, #condition)
  222. #define AssertEqual_2(actual, expected) Assert_4((actual) == (expected), "AssertEqual(%s, %s) - Provided arguments are not equal", #actual, #expected)
  223. #define AssertEqual_3(actual, expected, message) Assert_2((actual) == (expected), message)
  224. #define AssertEqual_4(actual, expected, message, p1) Assert_3((actual) == (expected), message, p1)
  225. #define AssertEqual_5(actual, expected, message, p1, p2) Assert_4((actual) == (expected), message, p1, p2)
  226. #define AssertEqual_6(actual, expected, message, p1, p2, p3) Assert_5((actual) == (expected), message, p1, p2, p3)
  227. #define AssertEqual_7(actual, expected, message, p1, p2, p3, p4) Assert_6((actual) == (expected), message, p1, p2, p3, p4)
  228. // AssertNotEqual()
  229. #define AssertNotEqual_0() AssertFail_1("No condition provided for AssertNotEqual()")
  230. #define AssertNotEqual_1(condition) AssertNot_2(condition, #condition)
  231. #define AssertNotEqual_2(actual, expected) Assert_4((actual) != (expected), "AssertNotEqual(%s, %s) - Provided arguments are equal", #actual, #expected)
  232. #define AssertNotEqual_3(actual, expected, message) Assert_2((actual) != (expected), message)
  233. #define AssertNotEqual_4(actual, expected, message, p1) Assert_3((actual) != (expected), message, p1)
  234. #define AssertNotEqual_5(actual, expected, message, p1, p2) Assert_4((actual) != (expected), message, p1, p2)
  235. #define AssertNotEqual_6(actual, expected, message, p1, p2, p3) Assert_5((actual) != (expected), message, p1, p2, p3)
  236. #define AssertNotEqual_7(actual, expected, message, p1, p2, p3, p4) Assert_6((actual) != (expected), message, p1, p2, p3, p4)
  237. // AssertNot()
  238. #define AssertNot_0() AssertFail_1("No condition provided for AssertNot()")
  239. #define AssertNot_1(condition) Assert_2(!(bool)(condition), #condition)
  240. #define AssertNot_2(condition, message) Assert_2(!(bool)(condition), message)
  241. #define AssertNot_3(condition, message, p1) Assert_3(!(bool)(condition), message, p1)
  242. #define AssertNot_4(condition, message, p1, p2) Assert_4(!(bool)(condition), message, p1, p2)
  243. #define AssertNot_5(condition, message, p1, p2, p3) Assert_5(!(bool)(condition), message, p1, p2, p3)
  244. #define AssertNot_6(condition, message, p1, p2, p3, p4) Assert_6(!(bool)(condition), message, p1, p2, p3, p4)
  245. #define AssertNot_7(condition, message, p1, p2, p3, p4, p5) Assert_7(!(bool)(condition), message, p1, p2, p3, p4, p5)
  246. // AssertFail()
  247. #ifdef RAYLIB_ASSERT_NDEBUG
  248. #define AssertFail_0()
  249. #define AssertFail_1(message)
  250. #define AssertFail_2(message, p1)
  251. #define AssertFail_3(message, p1, p2)
  252. #define AssertFail_4(message, p1, p2, p3)
  253. #define AssertFail_5(message, p1, p2, p3, p4)
  254. #define AssertFail_6(message, p1, p2, p3, p4, p5)
  255. #define AssertFail_7(message, p1, p2, p3, p4, p5, p6)
  256. #else
  257. #define AssertFail_0() RAYLIB_ASSERT_TRACELOG(RAYLIB_ASSERT_LOG, "ASSERT: AssertFail() (%s:%i)", __FILE__, __LINE__)
  258. #define AssertFail_1(message) RAYLIB_ASSERT_TRACELOG(RAYLIB_ASSERT_LOG, "ASSERT: %s (%s:%i)", message, __FILE__, __LINE__)
  259. #define AssertFail_2(message, p1) AssertFail_1(RAYLIB_ASSERT_TEXTFORMAT(message, p1))
  260. #define AssertFail_3(message, p1, p2) AssertFail_1(RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2))
  261. #define AssertFail_4(message, p1, p2, p3) AssertFail_1(RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3))
  262. #define AssertFail_5(message, p1, p2, p3, p4) AssertFail_1(RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4))
  263. #define AssertFail_6(message, p1, p2, p3, p4, p5) AssertFail_1(RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4, p5))
  264. #define AssertFail_7(message, p1, p2, p3, p4, p5, p6) AssertFail_1(RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4, p5, p6))
  265. #endif
  266. // AssertImage()
  267. #define AssertImage_0() AssertFail_1("No image provided for AssertImage()")
  268. #define AssertImage_1(image) Assert_3(IsImageValid(image), "AssertImage(%s) - Image not loaded", #image)
  269. #define AssertImage_2(image, message) Assert_2(IsImageValid(image), message)
  270. #define AssertImage_3(image, message, p1) Assert_3(IsImageValid(image), message, p1)
  271. #define AssertImage_4(image, message, p1, p2) Assert_4(IsImageValid(image), message, p1, p2)
  272. #define AssertImage_5(image, message, p1, p2, p3) Assert_5(IsImageValid(image), message, p1, p2, p3)
  273. #define AssertImage_6(image, message, p1, p2, p3, p4) Assert_6(IsImageValid(image), message, p1, p2, p3, p4)
  274. // AssertTexture()
  275. #define AssertTexture_0() AssertFail_1("No texture provided for AssertTexture()")
  276. #define AssertTexture_1(texture) Assert_3(IsTextureValid(texture), "AssertTexture(%s) - Texture not loaded", #texture)
  277. #define AssertTexture_2(texture, message) Assert_2(IsTextureValid(texture), message)
  278. #define AssertTexture_3(texture, message, p1) Assert_3(IsTextureValid(texture), message, p1)
  279. #define AssertTexture_4(texture, message, p1, p2) Assert_4(IsTextureValid(texture), message, p1, p2)
  280. #define AssertTexture_5(texture, message, p1, p2, p3) Assert_5(IsTextureValid(texture), message, p1, p2, p3)
  281. #define AssertTexture_6(texture, message, p1, p2, p3, p4) Assert_6(IsTextureValid(texture), message, p1, p2, p3, p4)
  282. // AssertImageSame()
  283. #ifdef RAYLIB_ASSERT_NDEBUG
  284. #define AssertImageSame_0()
  285. #define AssertImageSame_1(image)
  286. #define AssertImageSame_2(image1, image2)
  287. #define AssertImageSame_3(image1, image2, message)
  288. #define AssertImageSame_4(image1, image2, message, p1)
  289. #define AssertImageSame_5(image1, image2, message, p1, p2)
  290. #define AssertImageSame_6(image1, image2, message, p1, p2, p3)
  291. #define AssertImageSame_7(image1, image2, message, p1, p2, p3, p4)
  292. #else
  293. #define AssertImageSame_0() AssertFail_1("AssertImageSame(): No images provided to AssertImageSame(), expected 2")
  294. #define AssertImageSame_1(image) AssertFail_1("Only one image provided for AssertImageSame()")
  295. #define AssertImageSame_2(image1, image2) AssertImageSame_5(image1, image2, "AssertImageSame(%s, %s) - Images do not match", #image1, #image2)
  296. #define AssertImageSame_3(image1, image2, message) do { \
  297. if (image1.width != image2.width || image1.height != image2.height || image1.format != image2.format) { \
  298. AssertFail_1(message); \
  299. break; \
  300. } \
  301. Color* colors1 = LoadImageColors(image1); \
  302. Color* colors2 = LoadImageColors(image2); \
  303. bool failure = false; \
  304. for (int i = 0; i < image1.width * image1.height; i++) { \
  305. Color color1 = colors1[i]; \
  306. Color color2 = colors2[i]; \
  307. if (color1.r != color2.r || color1.g != color2.g || color1.b != color2.b || color1.a != color2.a) { \
  308. failure = true; \
  309. break; \
  310. } \
  311. } \
  312. UnloadImageColors(colors1); \
  313. UnloadImageColors(colors2); \
  314. if (failure) { \
  315. AssertFail_1(message); \
  316. } \
  317. } while(0)
  318. #define AssertImageSame_4(image1, image2, message, p1) AssertImageSame_3(image1, image2, RAYLIB_ASSERT_TEXTFORMAT(message, p1))
  319. #define AssertImageSame_5(image1, image2, message, p1, p2) AssertImageSame_3(image1, image2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2))
  320. #define AssertImageSame_6(image1, image2, message, p1, p2, p3) AssertImageSame_3(image1, image2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3))
  321. #define AssertImageSame_7(image1, image2, message, p1, p2, p3, p4) AssertImageSame_3(image1, image2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4))
  322. #endif
  323. // AssertColorSame()
  324. #ifdef RAYLIB_ASSERT_NDEBUG
  325. #define AssertColorSame_0()
  326. #define AssertColorSame_1(color)
  327. #define AssertColorSame_2(color1, color2)
  328. #define AssertColorSame_3(color1, color2, message)
  329. #define AssertColorSame_4(color1, color2, message, p1)
  330. #define AssertColorSame_5(color1, color2, message, p1, p2)
  331. #define AssertColorSame_6(color1, color2, message, p1, p2, p3)
  332. #define AssertColorSame_7(color1, color2, message, p1, p2, p3, p4)
  333. #else
  334. #define AssertColorSame_0() AssertFail_1("Colors not provided to AssertColorSame()")
  335. #define AssertColorSame_1(color) AssertFail_1("Expected two colors for AssertColorSame()")
  336. #define AssertColorSame_2(color1, color2) AssertColorSame_5(color1, color2, "AssertColorSame(%s, %s) - Colors do not match", #color1, #color2)
  337. #define AssertColorSame_3(color1, color2, message) do { \
  338. if (color1.r != color2.r || color1.g != color2.g || color1.b != color2.b || color1.a != color2.a) { \
  339. AssertFail_1(message); \
  340. }\
  341. } while (0)
  342. #define AssertColorSame_4(color1, color2, message, p1) AssertColorSame_3(color1, color2, RAYLIB_ASSERT_TEXTFORMAT(message, p1))
  343. #define AssertColorSame_5(color1, color2, message, p1, p2) AssertColorSame_3(color1, color2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2))
  344. #define AssertColorSame_6(color1, color2, message, p1, p2, p3) AssertColorSame_3(color1, color2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3))
  345. #define AssertColorSame_7(color1, color2, message, p1, p2, p3, p4) AssertColorSame_3(color1, color2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4))
  346. #endif
  347. // AssertVector2Same()
  348. #ifdef RAYLIB_ASSERT_NDEBUG
  349. #define AssertVector2Same_0()
  350. #define AssertVector2Same_1(vector)
  351. #define AssertVector2Same_2(vector1, vector2)
  352. #define AssertVector2Same_3(vector1, vector2, message)
  353. #define AssertVector2Same_4(vector1, vector2, message, p1)
  354. #define AssertVector2Same_5(vector1, vector2, message, p1, p2)
  355. #define AssertVector2Same_6(vector1, vector2, message, p1, p2, p3)
  356. #define AssertVector2Same_7(vector1, vector2, message, p1, p2, p3, p4)
  357. #else
  358. #define AssertVector2Same_0() AssertFail_1("Vectors not provided to AssertVector2Same()")
  359. #define AssertVector2Same_1(vector) AssertFail_1("Expected two vectors for AssertVector2Same()")
  360. #define AssertVector2Same_2(vector1, vector2) AssertVector2Same_5(vector1, vector2, "AssertVector2Same(%s, %s) - vectors do not match", #vector1, #vector2)
  361. #define AssertVector2Same_3(vector1, vector2, message) do { \
  362. if (vector1.x != vector2.x || vector1.y != vector2.y) { \
  363. AssertFail_1(message); \
  364. }\
  365. } while (0)
  366. #define AssertVector2Same_4(vector1, vector2, message, p1) AssertVector2Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1))
  367. #define AssertVector2Same_5(vector1, vector2, message, p1, p2) AssertVector2Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2))
  368. #define AssertVector2Same_6(vector1, vector2, message, p1, p2, p3) AssertVector2Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3))
  369. #define AssertVector2Same_7(vector1, vector2, message, p1, p2, p3, p4) AssertVector2Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4))
  370. #endif
  371. // AssertVector3Same()
  372. #ifdef RAYLIB_ASSERT_NDEBUG
  373. #define AssertVector3Same_0()
  374. #define AssertVector3Same_1(vector)
  375. #define AssertVector3Same_2(vector1, vector2)
  376. #define AssertVector3Same_3(vector1, vector2, message)
  377. #define AssertVector3Same_4(vector1, vector2, message, p1)
  378. #define AssertVector3Same_5(vector1, vector2, message, p1, p2)
  379. #define AssertVector3Same_6(vector1, vector2, message, p1, p2, p3)
  380. #define AssertVector3Same_7(vector1, vector2, message, p1, p2, p3, p4)
  381. #else
  382. #define AssertVector3Same_0() AssertFail_1("Vectors not provided to AssertVector2Same()")
  383. #define AssertVector3Same_1(vector) AssertFail_1("Expected two vectors for AssertVector2Same()")
  384. #define AssertVector3Same_2(vector1, vector2) AssertVector3Same_5(vector1, vector2, "AssertVector2Same(%s, %s) - vectors do not match", #vector1, #vector2)
  385. #define AssertVector3Same_3(vector1, vector2, message) do { \
  386. if (vector1.x != vector2.x || vector1.y != vector2.y || vector1.z != vector2.z) { \
  387. AssertFail_1(message); \
  388. }\
  389. } while (0)
  390. #define AssertVector3Same_4(vector1, vector2, message, p1) AssertVector3Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1))
  391. #define AssertVector3Same_5(vector1, vector2, message, p1, p2) AssertVector3Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2))
  392. #define AssertVector3Same_6(vector1, vector2, message, p1, p2, p3) AssertVector3Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3))
  393. #define AssertVector3Same_7(vector1, vector2, message, p1, p2, p3, p4) AssertVector3Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4))
  394. #endif
  395. #ifdef __cplusplus
  396. }
  397. #endif
  398. #endif // RAYLIB_ASSERT_H