PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
test_alarms.cpp File Reference

Unit tests for PROFINET alarm item and AlarmNotification parsing. More...

#include <gtest/gtest.h>
#include "profinet/alarms.h"
+ Include dependency graph for test_alarms.cpp:

Go to the source code of this file.

Functions

 TEST_F (AlarmItemTest, ParseChannelDiagnosis)
 
 TEST_F (AlarmItemTest, ParseExtChannelDiagnosis)
 
 TEST_F (AlarmItemTest, ParsePEAlarmItem)
 
 TEST_F (AlarmItemTest, ParseUnknownUSI)
 
 TEST_F (AlarmItemTest, RejectsTruncatedData)
 
 TEST_F (AlarmItemTest, ParseAlarmNotificationParsesHeaderAndItems)
 
 TEST_F (AlarmItemTest, ParseAlarmNotificationRejectsTooShortData)
 

Detailed Description

Unit tests for PROFINET alarm item and AlarmNotification parsing.

Verifies decoding of PROFINET alarm payloads and AlarmNotification PDUs provided by alarms.h.

The tests cover:

  • Parsing standard ChannelDiagnosis alarm items.
  • Parsing ExtendedChannelDiagnosis alarm items and extended fields.
  • Parsing PROFIenergy alarm items and operational modes.
  • Handling unknown USIs through the generic AlarmItem representation.
  • Rejecting truncated alarm item data.
  • Parsing AlarmNotification block headers and alarm body fields.
  • Decoding alarm type, sequence number, diagnosis flags, and device location information.
  • Parsing alarm items contained within an AlarmNotification payload.
  • Rejecting AlarmNotification PDUs that are shorter than the minimum structurally valid size.

The tests validate both the concrete alarm item type selected by USI and the decoded values exposed through the alarm data structures.

Definition in file test_alarms.cpp.

Function Documentation

◆ TEST_F() [1/7]

TEST_F ( AlarmItemTest  ,
ParseAlarmNotificationParsesHeaderAndItems   
)

◆ TEST_F() [2/7]

TEST_F ( AlarmItemTest  ,
ParseAlarmNotificationRejectsTooShortData   
)

Definition at line 175 of file test_alarms.cpp.

References profinet::ParseAlarmNotification().

+ Here is the call graph for this function:

◆ TEST_F() [3/7]

TEST_F ( AlarmItemTest  ,
ParseChannelDiagnosis   
)
Test:
parse_alarm_item: ChannelDiagnosis (USI 0x8000)

Definition at line 40 of file test_alarms.cpp.

References profinet::ParseAlarmItem(), and profinet::wire::PutU16().

+ Here is the call graph for this function:

◆ TEST_F() [4/7]

TEST_F ( AlarmItemTest  ,
ParseExtChannelDiagnosis   
)
Test:
parse_alarm_item: ExtChannelDiagnosis (USI 0x8002) includes ext fields

Definition at line 62 of file test_alarms.cpp.

References profinet::ParseAlarmItem(), profinet::wire::PutU16(), and profinet::wire::PutU32().

+ Here is the call graph for this function:

◆ TEST_F() [5/7]

TEST_F ( AlarmItemTest  ,
ParsePEAlarmItem   
)
Test:
parse_alarm_item: PE_AlarmItem (USI 0x8310)

Definition at line 87 of file test_alarms.cpp.

References profinet::ParseAlarmItem(), and profinet::wire::PutU16().

+ Here is the call graph for this function:

◆ TEST_F() [6/7]

TEST_F ( AlarmItemTest  ,
ParseUnknownUSI   
)
Test:
parse_alarm_item: unknown USI falls back to generic AlarmItem

Definition at line 108 of file test_alarms.cpp.

References profinet::ParseAlarmItem(), and profinet::wire::PutU16().

+ Here is the call graph for this function:

◆ TEST_F() [7/7]

TEST_F ( AlarmItemTest  ,
RejectsTruncatedData   
)
Test:
parse_alarm_item rejects truncated data

Definition at line 128 of file test_alarms.cpp.

References profinet::ParseAlarmItem().

+ Here is the call graph for this function: