mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
Add comprehensive tests for DrawingMessageParser and SarMessageParser
- Implement critical string formatting tests for DrawingMessageParser, ensuring correct message creation, parsing, and validation. - Validate JSON structure, coordinate formatting, and color index preservation in drawing messages. - Introduce tests for various drawing types, including LineDrawing and RectangleDrawing, with emphasis on output consistency and error handling. - Add tests for SarMessageParser, covering message creation, parsing, and format validation, including backward compatibility with old formats. - Ensure proper handling of special characters, empty notes, and extreme coordinate values in SAR messages. - Validate that messages conform to the CLAUDE.md specification and maintain compactness and efficiency.
This commit is contained in:
@@ -46,7 +46,7 @@ class DrawingMessageParser {
|
||||
/// Sender will be determined from packet metadata on receiving end
|
||||
static String createDrawingMessage(MapDrawing drawing) {
|
||||
final json = drawing.toNetworkJson();
|
||||
final jsonStr = jsonEncode(json);
|
||||
final jsonStr = jsonEncode(json).toString();
|
||||
return '$prefix$jsonStr';
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ class SarMessageParser {
|
||||
}) {
|
||||
// New format: S:emoji:colorIndex:lat,lon:notes
|
||||
final colorIdx = colorIndex ?? 0; // Default to red if not specified
|
||||
final text = 'S:${type.emoji}:$colorIdx:${location.latitude},${location.longitude}';
|
||||
final text = 'S:${type.emoji}:$colorIdx:${location.latitude.toString()},${location.longitude.toString()}';
|
||||
if (notes != null && notes.isNotEmpty) {
|
||||
// Use colon-separated format for inline message
|
||||
return '$text:$notes';
|
||||
|
||||
Reference in New Issue
Block a user