test_crc32Fast.cpp 936 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (c) 2021 - 2024 Stefan Strobel <stefan.strobel@shimatta.net>
  3. *
  4. * This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
  7. */
  8. /**
  9. * @file test_crc32Fast.h
  10. * @brief unittest implementation for crc32 fast function
  11. * @author Stefan Strobel <stefan.strobel@shimatta.net>
  12. */
  13. #include "test/framework/catch.hpp"
  14. #include <string.h>
  15. #define SHELLMATTA_TRANSPORT
  16. #undef SHELLMATTA_TRANSPORT_CRC_NO_LOOKUP
  17. #include "test_crc_data.h"
  18. #include "src/shellmatta_crc.c"
  19. TEST_CASE( "shellmatta_crc crc32Fast" ) {
  20. uint32_t crc = crc32Fast((char*)"123456789", 9, crc32Table);
  21. REQUIRE(crc == 0xCBF43926u);
  22. }
  23. TEST_CASE( "shellmatta_crc crc32Fast - more data" ) {
  24. uint32_t crc = crc32Fast((char*)data, sizeof(data), crc32Table);
  25. REQUIRE(crc == data_crc_32);
  26. }