- libopenpu : validation VIN, modèles JSON (getAvailableUpdate, devices), classification ecuType -> type/guide, sélection des mises à jour - couche Transport abstraite + implémentation libcurl (proxy env, redirections, streaming, timeout d'inactivité) - tolérance au EOF TLS sans close_notify de la passerelle Majestic, limitée aux corps délimités par la fermeture (ni Content-Length ni chunked) - openpu-cli : check / raw-devices / raw-updates - tests doctest (VIN, parsing, classification, client API avec faux transport), fixtures dont une capture réelle anonymisée (NAC wave 2) - qualité : presets CMake (debug, asan, tidy), .clang-tidy, tools/check.sh (tests, ASan/UBSan, valgrind, clang-tidy, cppcheck) - validé contre l'API réelle sur 3 véhicules (NAC w4, RCC, NAC w2) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WDASLCiN764v685boRVYar
27 lines
932 B
C++
27 lines
932 B
C++
#include "openpu/vin.hpp"
|
|
|
|
#include <doctest/doctest.h>
|
|
|
|
using openpu::isValidVin;
|
|
using openpu::normalizeVin;
|
|
|
|
TEST_CASE("VIN validation follows ^V[FR]3[A-Z0-9]{14}$")
|
|
{
|
|
CHECK(isValidVin("VF3ABCDEFGH123456"));
|
|
CHECK(isValidVin("VR3UPHNKSKT000001"));
|
|
CHECK_FALSE(isValidVin(""));
|
|
CHECK_FALSE(isValidVin("VF3ABCDEFGH12345")); // 16 chars
|
|
CHECK_FALSE(isValidVin("VF3ABCDEFGH1234567")); // 18 chars
|
|
CHECK_FALSE(isValidVin("VX3ABCDEFGH123456")); // bad 2nd char
|
|
CHECK_FALSE(isValidVin("VF1ABCDEFGH123456")); // Renault WMI
|
|
CHECK_FALSE(isValidVin("WF3ABCDEFGH123456"));
|
|
CHECK_FALSE(isValidVin("vf3abcdefgh123456")); // must be normalised first
|
|
CHECK_FALSE(isValidVin("VF3ABCDEFGH12345-"));
|
|
}
|
|
|
|
TEST_CASE("VIN normalisation upper-cases and strips blanks")
|
|
{
|
|
CHECK(normalizeVin(" vf3 abcd efgh 123456\n") == "VF3ABCDEFGH123456");
|
|
CHECK(isValidVin(normalizeVin("vr3uphnksk t000001")));
|
|
}
|