Open dpostorivo opened 7 years ago
I think that's a really good idea. I agree that it would be something that is disabled by default. We have other things that fall into this category already, though. I think it makes a lot of sense.
Personally, I can imagine two useful versions:
TEST_ASSERT_EQUAL_TEXT_FILE - loads the files and then uses TEST_ASSERT_EQUAL_STRING_ARRAY or something? TEST_ASSERT_EQUAL_BINARY_FILE - loads the files and then uses TEST_ASSERT_EQUAL_MEMORY
:)
So I've tried to start making the binary file first which is in #283 . If someone could review it that would be nice.
While the last version got tangled up and discontinued, I'd like to revisit this feature. I still think it's a good one. At this point, I see it being in extras/files
and called something like unity_files.h
. It could then be included as needed.
Assertions it would add initially:
TEST_ASSERT_EQUAL_FILE_TEXT(exp_filename, act_filename)
TEST_ASSERT_EQUAL_FILE_BINARY(exp_filename, act_filename)
To resolve the problem described, you can follow the steps below:
Add unity_config.h to the Unity Include Directory:
Make sure the directory containing unity_config.h is added to Unity's include directories during compilation. This can be done by specifying -I
Define the UNITY_INCLUDE_CONFIG_H macro during compilation to enable the required doubles. This can be done using -DUNITY_INCLUDE_CONFIG_H in the build options. Update CMakeLists.txt:
In the CMakeLists.txt file in the testing directory, add the directory containing unity_config.h to the target unity include directories. This can be done using target_include_directories(unity PUBLIC
Verify that the directory hierarchy is correct and that unity_config.h is located in a location accessible to Unity during compilation. Test the Configuration:
After making the above changes, compile your project with CMake and check that Unity recognizes unity_config.h correctly and that doubles are enabled as expected. Additional Debugging:
If the problem persists, check that there are no typos or incorrect paths in the CMakeLists.txt settings and that there are no conflicts with other compilation settings or flags. Make sure you follow these steps carefully and check that the settings are correct at each step. If the problem persists, carefully review the error messages and try to identify the root cause of the problem to effectively resolve it.
Vou lhe fornecer um exemplo simples de como você pode configurar o arquivo CMakeLists.txt para incluir o diretório contendo unity_config.h durante a compilação do Unity. Vamos supor que o diretório que contém unity_config.h está localizado em project/testing.
cmake_minimum_required(VERSION 3.5)
project(MyProject)
add_subdirectory(testing)
Agora, no arquivo testing/CMakeLists.txt, você pode incluir o diretório contendo unity_config.h usando target_include_directories
target_include_directories(unity PUBLIC ${CMAKE_CURRENT_LIST_DIR})
Com essas configurações, o CMake irá garantir que o Unity tenha acesso ao arquivo unity_config.h durante a compilação. Certifique-se de adaptar os caminhos e nomes de arquivos de acordo com a estrutura do seu projeto.
cmake_minimum_required(VERSION 3.5)
project(MyProject)
add_subdirectory(testing)
Agora, no arquivo testing/CMakeLists.txt, adicione comentários explicativos e use uma variável para armazenar o caminho do diretório contendo unity_config.h.
set(UNITY_CONFIG_DIR ${CMAKE_CURRENT_LIST_DIR})
target_include_directories(unity PUBLIC ${UNITY_CONFIG_DIR})
Com essas melhorias, o código está mais organizado e os comentários fornecem uma explicação clara do que está sendo feito em cada parte do arquivo CMakeLists.txt.
I've been testing a lot of file IO recently and one thing that would be a nice to have would be a file compare inside of unity. For now I've been opening both files, putting them in a buffer, then comparing the resulting buffers and their size.
Obviously this would not be enabled by default especially in most embedded contexts, but having it will simplify tests for those who do work with file IO.
Thoughts on this? I can get started if others are interested.