ESP32-basiertes Kraftort-Suchger�t mit GPS, LED-Ring und PlatformIO-Firmware.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

52 lignes
1.4KB

  1. #include <unity.h>
  2. #include <vector>
  3. #include "geo.h"
  4. using kraftort::geo::Place;
  5. void test_haversine_basics() {
  6. const double d0 = kraftort::geo::haversineMeters(47.0, 8.0, 47.0, 8.0);
  7. TEST_ASSERT_FLOAT_WITHIN(0.01f, 0.0f, static_cast<float>(d0));
  8. const double d1 = kraftort::geo::haversineMeters(47.3769, 8.5417, 47.4979, 8.7241);
  9. TEST_ASSERT_TRUE(d1 > 18000.0);
  10. TEST_ASSERT_TRUE(d1 < 21000.0);
  11. }
  12. void test_bearing_and_led_index() {
  13. const double bearing = kraftort::geo::initialBearingDeg(47.0, 8.0, 48.0, 8.0);
  14. TEST_ASSERT_FLOAT_WITHIN(1.0f, 0.0f, static_cast<float>(bearing));
  15. const int idx = kraftort::geo::bearingToLedIndex(90.0, 0.0, 54);
  16. TEST_ASSERT_TRUE(idx >= 13 && idx <= 14);
  17. }
  18. void test_nearest_place() {
  19. std::vector<Place> places = {
  20. {"A", 47.0, 8.0, 100.0f},
  21. {"B", 47.5, 8.5, 100.0f},
  22. };
  23. double distance = 0.0;
  24. const std::size_t idx = kraftort::geo::findNearestPlaceIndex(places, 47.02, 8.02, &distance);
  25. TEST_ASSERT_EQUAL_UINT32(0u, static_cast<uint32_t>(idx));
  26. TEST_ASSERT_TRUE(distance < 5000.0);
  27. }
  28. int runUnityTests(void) {
  29. UNITY_BEGIN();
  30. RUN_TEST(test_haversine_basics);
  31. RUN_TEST(test_bearing_and_led_index);
  32. RUN_TEST(test_nearest_place);
  33. return UNITY_END();
  34. }
  35. #ifdef ARDUINO
  36. #include <Arduino.h>
  37. void setup() { delay(1000); runUnityTests(); }
  38. void loop() {}
  39. #else
  40. int main() { return runUnityTests(); }
  41. #endif