test_crc16Fast.cpp 929 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_crc16Fast.h
  10. * @brief unittest implementation for crc16 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_YMODEM_CRC_NO_LOOKUP
  17. #include "test_crc_data.h"
  18. #include "src/shellmatta_crc.c"
  19. TEST_CASE( "shellmatta_crc crc16Fast" ) {
  20. uint32_t crc = crc16Fast((char*)"123456789", 9, crc16Table);
  21. REQUIRE(crc == 0x31C3u);
  22. }
  23. TEST_CASE( "shellmatta_crc crc16Fast - more data" ) {
  24. uint32_t crc = crc16Fast((char*)data, sizeof(data), crc16Table);
  25. REQUIRE(crc == data_crc_16);
  26. }