test_utils_clearInput.cpp 1004 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) 2019 - 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_utils_clearInput.c
  10. * @brief unittest for shellmatta utils_clearInput
  11. * @author Stefan Strobel <stefan.strobel@shimatta.net>
  12. */
  13. #include "test/framework/catch.hpp"
  14. #include "src/shellmatta_utils.c"
  15. #include <string.h>
  16. static shellmatta_retCode_t writeFct(const char* data, uint32_t length)
  17. {
  18. (void)data;
  19. (void)length;
  20. return SHELLMATTA_OK;
  21. }
  22. TEST_CASE( "shellmatta_clearInput normal call" ) {
  23. shellmatta_instance_t inst;
  24. char buffer[20];
  25. inst.buffer = buffer;
  26. inst.bufferSize = 20;
  27. inst.cursor = 10;
  28. inst.inputCount = 10;
  29. inst.write = writeFct;
  30. utils_clearInput(&inst);
  31. CHECK( inst.cursor == 0);
  32. REQUIRE( inst.inputCount == 0);
  33. }