eive-obsw/unittest/testStampInFilename.cpp

22 lines
716 B
C++
Raw Normal View History

2022-12-12 16:18:00 +01:00
#include <catch2/catch_test_macros.hpp>
#include <cinttypes>
#include "fsfw/timemanager/Clock.h"
TEST_CASE("Stamp in Filename", "[Stamp In Filename]") {
Clock::TimeOfDay_t tod;
std::string baseName = "verif";
std::string pathStr = "verif_2022-05-25T16:55:23Z.bin";
2022-12-12 16:30:16 +01:00
unsigned int underscorePos = pathStr.find_last_of('_');
std::string stampStr = pathStr.substr(underscorePos + 1);
2022-12-12 16:18:00 +01:00
float seconds = 0.0;
char* prefix = nullptr;
int count =
2022-12-12 16:30:16 +01:00
sscanf(stampStr.c_str(),
"%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 "T%2" SCNu32 ":%2" SCNu32 ":%2" SCNu32 "Z",
&tod.year, &tod.month, &tod.day, &tod.hour, &tod.minute, &tod.second);
2022-12-12 16:18:00 +01:00
static_cast<void>(count);
2022-12-12 16:30:16 +01:00
CHECK(count == 6);
2022-12-12 16:18:00 +01:00
}