Merge upstream dev companion CLI updates
This commit is contained in:
commit
2143d3e04b
46 files changed
+1976
-163
No files matched your search
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// CommonRadioPrefs applies live settings through the target's global radio
|
||||
// driver. Native serializer tests do not build a hardware variant, so provide
|
||||
// the narrow interface that helper needs.
|
||||
class NativeRadioDriverMock {
|
||||
public:
|
||||
bool setRxBoostedGainMode(bool) { return true; }
|
||||
bool setTxPower(int8_t) { return true; }
|
||||
};
|
||||
|
||||
inline NativeRadioDriverMock radio_driver;
|
||||
@@ -14,6 +14,16 @@ static bool enqueue(TestFrame queue[], size_t& count, size_t capacity,
|
||||
return mesh::enqueueCompanionFrame(queue, count, capacity, &code, 1);
|
||||
}
|
||||
|
||||
TEST(CompanionFrameQueue, HighBitSeparatesResponsesFromPushes) {
|
||||
const uint8_t highest_command_or_response = 0x7F;
|
||||
const uint8_t first_push = 0x80;
|
||||
const uint8_t unknown_high_code = 0x98;
|
||||
|
||||
EXPECT_FALSE(mesh::isCompanionPushFrame(&highest_command_or_response, 1));
|
||||
EXPECT_TRUE(mesh::isCompanionPushFrame(&first_push, 1));
|
||||
EXPECT_TRUE(mesh::isCompanionPushFrame(&unknown_high_code, 1));
|
||||
}
|
||||
|
||||
TEST(CompanionFrameQueue, PushTrafficLeavesOneResponseSlot) {
|
||||
TestFrame queue[4] = {};
|
||||
size_t count = 0;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "helpers/ConfigSerializer.h"
|
||||
#include "helpers/DynamicConfigSerializer.h"
|
||||
|
||||
class NativeFileSystem {
|
||||
public:
|
||||
@@ -314,6 +315,90 @@ TEST(NodePrefs, ExplicitWrappedBridgeFormatReplacesRawInMemoryValue) {
|
||||
EXPECT_EQ(mesh::bridge::ESPNOW_FORMAT_WRAPPED, loaded.bridge_format);
|
||||
}
|
||||
|
||||
TEST(DynamicConfigSerializer, GetSet_Basic) {
|
||||
DynamicConfigSerializer data;
|
||||
|
||||
bool s1 = data.setByKey("age", "11");
|
||||
bool s2 = data.setByKey("name", "Scott");
|
||||
EXPECT_TRUE(s1 && s2);
|
||||
|
||||
char tmp[32];
|
||||
bool g1 = data.getByKey("age", tmp, 31);
|
||||
EXPECT_TRUE(g1);
|
||||
EXPECT_STREQ("11", tmp);
|
||||
|
||||
bool g2 = data.getByKey("name", tmp, 31);
|
||||
EXPECT_TRUE(g2);
|
||||
EXPECT_STREQ("Scott", tmp);
|
||||
}
|
||||
|
||||
TEST(DynamicConfigSerializer, Set_Replaces) {
|
||||
DynamicConfigSerializer data;
|
||||
|
||||
bool s1 = data.setByKey("age", "11");
|
||||
bool s2 = data.setByKey("name", "Scott");
|
||||
EXPECT_TRUE(s1 && s2);
|
||||
|
||||
bool s3 = data.setByKey("age", "333");
|
||||
EXPECT_TRUE(s3);
|
||||
|
||||
char tmp[32];
|
||||
bool g1 = data.getByKey("age", tmp, 31);
|
||||
EXPECT_TRUE(g1);
|
||||
EXPECT_STREQ("333", tmp);
|
||||
|
||||
bool g2 = data.getByKey("name", tmp, 31);
|
||||
EXPECT_TRUE(g2);
|
||||
EXPECT_STREQ("Scott", tmp);
|
||||
}
|
||||
|
||||
TEST(DynamicConfigSerializer, GetUnknown_Fail) {
|
||||
DynamicConfigSerializer data;
|
||||
|
||||
bool s1 = data.setByKey("age", "11");
|
||||
EXPECT_TRUE(s1);
|
||||
|
||||
char tmp[32];
|
||||
bool g2 = data.getByKey("name", tmp, 31);
|
||||
EXPECT_FALSE(g2);
|
||||
}
|
||||
|
||||
TEST(DynamicConfigSerializer, SaveCustom_Basic) {
|
||||
MockPrintStream s;
|
||||
DynamicConfigSerializer data;
|
||||
|
||||
bool s1 = data.setByKey("age", "11");
|
||||
bool s2 = data.setByKey("name", "Scott");
|
||||
EXPECT_TRUE(s1 && s2);
|
||||
|
||||
bool success = data.saveSerial(s);
|
||||
EXPECT_TRUE(success);
|
||||
|
||||
auto l = s.getLength();
|
||||
char tmp[128];
|
||||
memcpy(tmp, s.getBytes(), l);
|
||||
tmp[l] = 0;
|
||||
|
||||
const char* expect = "{age:\"11\",name:\"Scott\"}";
|
||||
EXPECT_STREQ(expect, tmp);
|
||||
}
|
||||
|
||||
TEST(DynamicConfigSerializer, LoadCustom_Basic) {
|
||||
MockInputStream s("{age:\"" TEST_INT_S "\",name:\"Scott\"}");
|
||||
DynamicConfigSerializer data;
|
||||
|
||||
bool success = data.loadSerial(s);
|
||||
EXPECT_TRUE(success);
|
||||
|
||||
char tmp[32];
|
||||
bool g1 = data.getByKey("age", tmp, 31);
|
||||
EXPECT_TRUE(g1);
|
||||
EXPECT_STREQ(TEST_INT_S, tmp);
|
||||
|
||||
bool g2 = data.getByKey("name", tmp, 31);
|
||||
EXPECT_TRUE(g2);
|
||||
EXPECT_STREQ("Scott", tmp);
|
||||
}
|
||||
|
||||
// ── main ───────────────────────────────────────────────────────
|
||||
|
||||
|
||||
Reference in new issue
Block a user