shithub: rgbds

Download patch

ref: cbf6fadcdbf7402845adbeb840de1cb8fcb41be4
parent: a77b0b396a9e3c5dc96bf88ab79d43e98b8f3e10
author: ISSOtm <[email protected]>
date: Mon Apr 25 05:39:30 EDT 2022

Add RGBGFX tests

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -77,12 +77,23 @@
   message(STATUS "Cannot determine RGBDS version (Git not installed), falling back")
 endif(GIT)
 
+find_package(PkgConfig)
+if(MSVC OR NOT PKG_CONFIG_FOUND)
+  # fallback to find_package
+  find_package(PNG REQUIRED)
+else()
+  pkg_check_modules(LIBPNG REQUIRED libpng)
+endif()
+
 include_directories("${PROJECT_SOURCE_DIR}/include")
 
 set(CMAKE_C_STANDARD 11)
 set(CMAKE_C_STANDARD_REQUIRED True)
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED True)
 
 add_subdirectory(src)
+add_subdirectory(test)
 
 # By default, build in Release mode; Debug mode must be explicitly requested
 # (You may want to augment it with the options above)
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -14,14 +14,6 @@
     "_version.c"
     )
 
-find_package(PkgConfig)
-if(MSVC OR NOT PKG_CONFIG_FOUND)
-  # fallback to find_package
-  find_package(PNG REQUIRED)
-else()
-  pkg_check_modules(LIBPNG REQUIRED libpng)
-endif()
-
 find_package(BISON REQUIRED)
 set(BISON_FLAGS "-Wall")
 # Set sompe optimization flags on versions that support them
@@ -103,8 +95,6 @@
                  )
   install(TARGETS rgb${PROG} RUNTIME DESTINATION bin)
 endforeach()
-
-set_target_properties(rgbgfx PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED True)
 
 if(LIBPNG_FOUND) # pkg-config
   target_include_directories(rgbgfx PRIVATE ${LIBPNG_INCLUDE_DIRS})
--- /dev/null
+++ b/test/CMakeLists.txt
@@ -1,0 +1,21 @@
+
+add_executable(randtilegen gfx/randtilegen.c)
+if(NOT MSVC)
+  target_compile_options(randtilegen PRIVATE -Wno-vla)
+endif()
+
+add_executable(rgbgfx_test gfx/rgbgfx_test.cpp)
+
+install(TARGETS randtilegen rgbgfx_test DESTINATION ${rgbds_SOURCE_DIR}/test/gfx)
+
+foreach(TARGET randtilegen rgbgfx_test)
+  if(LIBPNG_FOUND) # pkg-config
+    target_include_directories(${TARGET} PRIVATE ${LIBPNG_INCLUDE_DIRS})
+    target_link_directories(${TARGET} PRIVATE ${LIBPNG_LIBRARY_DIRS})
+    target_link_libraries(${TARGET} PRIVATE ${LIBPNG_LIBRARIES})
+  else()
+    target_compile_definitions(${TARGET} PRIVATE ${PNG_DEFINITIONS})
+    target_include_directories(${TARGET} PRIVATE ${PNG_INCLUDE_DIRS})
+    target_link_libraries(${TARGET} PRIVATE ${PNG_LIBRARIES})
+  endif()
+endforeach()
binary files /dev/null b/test/gfx/seed0.bin differ
binary files /dev/null b/test/gfx/seed1.bin differ
binary files /dev/null b/test/gfx/seed10.bin differ
binary files /dev/null b/test/gfx/seed11.bin differ
binary files /dev/null b/test/gfx/seed12.bin differ
--- /dev/null
+++ b/test/gfx/seed13.bin
@@ -1,0 +1,1 @@
+?x��)&<�av��(˷z��ߕx_;�yc&o��$��w���x�TST+��ǑX��g��t�����|c�UJ=��u<lP��>І����[g$Ca��I޿�ÃsI5;��D2��jD[ �S+���c���8[j�?��D��������D,���r��Iٽ�N�
;�jzA���#a�\vD�p�="�(X��fE���~(���$�(K�;Sc�A܍^[���$�6��^u
\ No newline at end of file
binary files /dev/null b/test/gfx/seed14.bin differ
binary files /dev/null b/test/gfx/seed15.bin differ
binary files /dev/null b/test/gfx/seed16.bin differ
binary files /dev/null b/test/gfx/seed17.bin differ
binary files /dev/null b/test/gfx/seed18.bin differ
binary files /dev/null b/test/gfx/seed19.bin differ
binary files /dev/null b/test/gfx/seed2.bin differ
binary files /dev/null b/test/gfx/seed20.bin differ
binary files /dev/null b/test/gfx/seed21.bin differ
binary files /dev/null b/test/gfx/seed22.bin differ
binary files /dev/null b/test/gfx/seed23.bin differ
binary files /dev/null b/test/gfx/seed24.bin differ
binary files /dev/null b/test/gfx/seed25.bin differ
binary files /dev/null b/test/gfx/seed26.bin differ
--- /dev/null
+++ b/test/gfx/seed27.bin
@@ -1,0 +1,3 @@
+��
+�.[)�(�l%�!�����\Ƕ�W|'R2���x���8���tUfZ�]�~��Ů�oZ.�v���Xc,�nό��Pl8�#�Z<~�?�y%�S�*�,@e&���Xc�ɟ���'����$zOgn�ü��7Mb�Y��y��q#c�S�D�b���#�/��JnOK��AƁ0b��/)Wm�R&��AwW%-��>����=�0�a�B������y�1?�]	�v�b���?A#f��d�i�hf�&�[ \ϫ���+<�oj��?� ��d��'��&f���G:pz�e�ܶ�w;ABy�[���L�w�ݮFr��-����r��o&�s̼`f��dp�F�n2-�26E���ĕ��qx�Ez���@�S�N�5;F�a�]#�it�R�� !ֵ��+6*��3�K����F�I�/[	)�]�ag���]J�����C�5?����<�8e.����.GM
+��dK$��R
�{+!�����7j-F
\ No newline at end of file
binary files /dev/null b/test/gfx/seed28.bin differ
binary files /dev/null b/test/gfx/seed29.bin differ
binary files /dev/null b/test/gfx/seed3.bin differ
binary files /dev/null b/test/gfx/seed4.bin differ
binary files /dev/null b/test/gfx/seed5.bin differ
binary files /dev/null b/test/gfx/seed6.bin differ
binary files /dev/null b/test/gfx/seed7.bin differ
binary files /dev/null b/test/gfx/seed8.bin differ
binary files /dev/null b/test/gfx/seed9.bin differ
--- /dev/null
+++ b/test/gfx/test.sh
@@ -1,0 +1,11 @@
+#!/usr/bin/env bash
+
+[[ -e ./rgbgfx_test ]] || make -C ../.. test/gfx/rgbgfx_test
+[[ -e ./randtilegen ]] || make -C ../.. test/gfx/randtilegen
+
+rc=0
+for f in *.bin; do
+	./rgbgfx_test "$f" || rc=1
+done
+
+exit $rc
--- a/test/run-tests.sh
+++ b/test/run-tests.sh
@@ -14,7 +14,7 @@
 
 # Tests included with the repository
 
-for dir in asm link fix; do
+for dir in asm link fix gfx; do
 	pushd $dir
 	./test.sh
 	popd