Fixes and updates

This commit is contained in:
Ken Van Hoeylandt 2026-08-08 19:17:18 +02:00
parent 994aa31f6e
commit 87f4985037
4 changed files with 5 additions and 162 deletions

View File

@ -25,4 +25,9 @@ else()
target_include_directories(QRCode target_include_directories(QRCode
PUBLIC src PUBLIC src
) )
# qrcode.h polyfills bool/true/false for pre-C23 compilers - on a host compiler that
# defaults to C23 (where bool is a keyword), that polyfill itself fails to compile. Pin to
# C11 for the simulator build only; ESP-IDF's own toolchain default is unaffected.
set_target_properties(QRCode PROPERTIES C_STANDARD 11 C_STANDARD_REQUIRED ON)
endif() endif()

View File

@ -1,83 +0,0 @@
#include "TestFile.h"
#include "../../Tactility/Private/Tactility/app/AppManifestParsing.h"
#include "../../Tactility/Private/Tactility/app/AppManifestParsingInternal.h"
#include "doctest.h"
using namespace tt;
using namespace tt::app;
TEST_CASE("parseManifest() should parse a V1 (sectioned) manifest.properties file") {
TestFile file("test-manifest-v1.properties");
file.writeData(
"[manifest]\n"
"version=0.1\n"
"[target]\n"
"sdk=0.0.0\n"
"platforms=esp32,esp32s3,esp32c6,esp32p4\n"
"[app]\n"
"id=one.tactility.sdktest\n"
"versionName=0.1.0\n"
"versionCode=1\n"
"name=SDK Test\n"
);
AppManifest manifest;
CHECK_EQ(parseManifest(file.getPath(), manifest), true);
CHECK_EQ(manifest.targetSdk, "0.0.0");
CHECK_EQ(manifest.targetPlatforms, "esp32,esp32s3,esp32c6,esp32p4");
CHECK_EQ(manifest.appId, "one.tactility.sdktest");
CHECK_EQ(manifest.appName, "SDK Test");
CHECK_EQ(manifest.appVersionName, "0.1.0");
CHECK_EQ(manifest.appVersionCode, 1);
}
TEST_CASE("parseManifest() should parse a V2 (flat) manifest.properties file") {
TestFile file("test-manifest-v2.properties");
file.writeData(
"manifest.version=0.1\n"
"target.sdk=0.0.0\n"
"target.platforms=esp32,esp32s3,esp32c6,esp32p4\n"
"app.id=one.tactility.sdktest\n"
"app.version.name=0.1.0\n"
"app.version.code=1\n"
"app.name=SDK Test\n"
);
AppManifest manifest;
CHECK_EQ(parseManifest(file.getPath(), manifest), true);
CHECK_EQ(manifest.targetSdk, "0.0.0");
CHECK_EQ(manifest.targetPlatforms, "esp32,esp32s3,esp32c6,esp32p4");
CHECK_EQ(manifest.appId, "one.tactility.sdktest");
CHECK_EQ(manifest.appName, "SDK Test");
CHECK_EQ(manifest.appVersionName, "0.1.0");
CHECK_EQ(manifest.appVersionCode, 1);
}
TEST_CASE("parseManifestV1() should fail when a required key is missing") {
std::map<std::string, std::string> properties = {
{"[manifest]version", "0.1"},
{"[app]id", "one.tactility.sdktest"},
{"[app]name", "SDK Test"},
{"[app]versionName", "0.1.0"},
{"[app]versionCode", "1"},
// Missing [target]sdk
{"[target]platforms", "esp32"},
};
AppManifest manifest;
CHECK_EQ(parseManifestV1(properties, manifest), false);
}
TEST_CASE("parseManifestV2() should fail when the app id is invalid") {
std::map<std::string, std::string> properties = {
{"manifest.version", "0.1"},
{"app.id", "abc"}, // too short (isValidId requires >= 5 chars)
{"app.name", "SDK Test"},
{"app.version.name", "0.1.0"},
{"app.version.code", "1"},
{"target.sdk", "0.0.0"},
{"target.platforms", "esp32"},
};
AppManifest manifest;
CHECK_EQ(parseManifestV2(properties, manifest), false);
}

View File

@ -1,49 +0,0 @@
#include "doctest.h"
#include <Tactility/Bundle.h>
using namespace tt;
TEST_CASE("boolean can be stored and retrieved") {
Bundle bundle;
bundle.putBool("key", true);
CHECK(bundle.hasBool("key"));
CHECK(bundle.getBool("key"));
bool opt_result = false;
CHECK(bundle.optBool("key", opt_result));
CHECK_EQ(opt_result, true);
}
TEST_CASE("int32 can be stored and retrieved") {
Bundle bundle;
bundle.putInt32("key", true);
CHECK(bundle.hasInt32("key"));
CHECK(bundle.getInt32("key"));
int32_t opt_result = false;
CHECK(bundle.optInt32("key", opt_result));
CHECK_EQ(opt_result, true);
}
TEST_CASE("string can be stored and retrieved") {
Bundle bundle;
bundle.putString("key", "test");
CHECK(bundle.hasString("key"));
CHECK_EQ(bundle.getString("key"), "test");
std::string opt_result;
CHECK(bundle.optString("key", opt_result));
CHECK_EQ(opt_result, "test");
}
TEST_CASE("bundle copy makes an actual copy") {
auto* original_ptr = new Bundle();
Bundle& original = *original_ptr;
original.putBool("bool", true);
original.putInt32("int32", 123);
original.putString("string", "text");
Bundle copy = original;
delete original_ptr;
CHECK_EQ(copy.getBool("bool"), true);
CHECK_EQ(copy.getInt32("int32"), 123);
CHECK_EQ(copy.getString("string"), "text");
}

View File

@ -1,30 +0,0 @@
#include "TestFile.h"
#include "../../Tactility/Include/Tactility/file/PropertiesFile.h"
#include "doctest.h"
using namespace tt;
TEST_CASE("loadPropertiesFile() should return false when the file does not exist") {
std::map<std::string, std::string> properties;
CHECK_EQ(file::loadPropertiesFile("does_not_exist.properties", properties), false);
}
TEST_CASE("PropertiesFile should parse a valid file properly") {
TestFile file("test.properties");
file.writeData(
"# Comment\n" // Regular comment
" \t# Comment\n" // Prefixed comment
"key1=value1\n" // Regular property
" \tkey 2\t = \tvalue 2\t " // Property with empty space
);
std::map<std::string, std::string> properties;
// Load data
CHECK_EQ(file::loadPropertiesFile(file.getPath(), properties), true);
CHECK_EQ(properties.size(), 2);
CHECK_EQ(properties["key1"], "value1");
CHECK_EQ(properties["key 2"], "value 2");
}