add tests for control protocol and angle representation parsing

This commit is contained in:
2025-02-03 23:03:07 +03:00
parent 61afd0f4a7
commit a2e2896f29
5 changed files with 133 additions and 18 deletions

View File

@@ -1,5 +1,6 @@
#pragma once
#include <charconv>
#include <ranges>
#include <regex>
@@ -111,14 +112,19 @@ static std::optional<double> parsAngleString(R&& r, bool hms = false)
if (ok) {
auto str = trimSpaces(std::forward<R>(r));
auto parts = std::views::split(str, ":");
auto parts = std::views::split(str, std::string_view(":"));
double val;
double p1 = numFromStr<double>(parts[0]);
double p1 = numFromStr<double>(*parts.begin()).value();
val = std::abs(p1);
val += numFromStr<double>(parts[1]) / 60.0;
val += numFromStr<double>(parts[2]) / 3600.0;
double dv = 60.0;
for (auto const& v : parts | std::views::drop(1)) {
val += numFromStr<double>(v).value() / dv;
dv *= 60.0;
}
// val += numFromStr<double>(parts[1]) / 60.0;
// val += numFromStr<double>(parts[2]) / 3600.0;
if (p1 < 0) {
val = -val;
}