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

Unit tests for PROFINET diagnosis decoding and parsing. More...

#include <gtest/gtest.h>
#include "profinet/diagnosis.h"
#include "profinet/wire.h"
+ Include dependency graph for test_diagnosis.cpp:

Go to the source code of this file.

Classes

class  DiagnosisTest
 

Functions

 TEST_F (DiagnosisTest, ChannelPropertiesFromUint16DecodesAllBitFields)
 
 TEST_F (DiagnosisTest, ChannelPropertiesFromUint16HandlesZeroValue)
 
 TEST_F (DiagnosisTest, DecodeChannelErrorTypeResolvesKnownAndRangeBasedFallbacks)
 
 TEST_F (DiagnosisTest, DecodeExtChannelErrorTypeUsesContextSpecificTables)
 
 TEST_F (DiagnosisTest, ParseDiagnosisBlockParsesSingleChannelDiagnosisEntry)
 
 TEST_F (DiagnosisTest, ParseDiagnosisBlockParsesExtChannelDiagnosisEntry)
 
 TEST_F (DiagnosisTest, ParseDiagnosisBlockLocationHeaderUpdatesLocation)
 
 TEST_F (DiagnosisTest, ParseDiagnosisBlockReturnsEmptyForTooShortData)
 
 TEST_F (DiagnosisTest, ParseDiagnosisSimpleStopsOnZeroFilledSentinelEntry)
 
 TEST_F (DiagnosisTest, DiagnosisDataMaintenanceFlagsReflectEntryFlags)
 
 TEST_F (DiagnosisTest, DiagnosisDataGetByChannelFiltersEntries)
 

Detailed Description

Unit tests for PROFINET diagnosis decoding and parsing.

Verifies the diagnosis data structures, error-type decoding, and parsing behavior provided by diagnosis.h.

The tests cover:

  • Decoding ChannelProperties bit fields and zero/default values.
  • Channel and extended channel error-type name resolution.
  • Parsing standard ChannelDiagnosis entries.
  • Parsing ExtChannelDiagnosis entries and extended error information.
  • Handling API, slot, and subslot location headers.
  • Handling truncated or insufficient diagnosis data.
  • Parsing simple diagnosis blocks and stopping at zero-filled sentinels.
  • Detection of maintenance-required and maintenance-demanded conditions.
  • Filtering parsed diagnosis entries by channel number.

Definition in file test_diagnosis.cpp.

Function Documentation

◆ TEST_F() [1/11]

TEST_F ( DiagnosisTest  ,
ChannelPropertiesFromUint16DecodesAllBitFields   
)
Test:
ChannelProperties::from_uint16 decodes all bit fields

Definition at line 32 of file test_diagnosis.cpp.

References profinet::diagnosis::ChannelProperties::FromUint16().

+ Here is the call graph for this function:

◆ TEST_F() [2/11]

TEST_F ( DiagnosisTest  ,
ChannelPropertiesFromUint16HandlesZeroValue   
)
Test:
ChannelProperties::from_uint16 handles zero value

Definition at line 56 of file test_diagnosis.cpp.

References profinet::diagnosis::ChannelProperties::FromUint16().

+ Here is the call graph for this function:

◆ TEST_F() [3/11]

TEST_F ( DiagnosisTest  ,
DecodeChannelErrorTypeResolvesKnownAndRangeBasedFallbacks   
)
Test:
decode_channel_error_type resolves known and range-based fallbacks

Definition at line 66 of file test_diagnosis.cpp.

References profinet::diagnosis::DecodeChannelErrorType().

+ Here is the call graph for this function:

◆ TEST_F() [4/11]

TEST_F ( DiagnosisTest  ,
DecodeExtChannelErrorTypeUsesContextSpecificTables   
)
Test:
decode_ext_channel_error_type uses context-specific tables

Definition at line 94 of file test_diagnosis.cpp.

References profinet::diagnosis::DecodeExtChannelErrorType().

+ Here is the call graph for this function:

◆ TEST_F() [5/11]

TEST_F ( DiagnosisTest  ,
DiagnosisDataGetByChannelFiltersEntries   
)
Test:
DiagnosisData::get_by_channel filters entries

Definition at line 319 of file test_diagnosis.cpp.

References profinet::diagnosis::ParseDiagnosisBlock(), profinet::wire::PutU16(), and profinet::wire::PutU8().

+ Here is the call graph for this function:

◆ TEST_F() [6/11]

TEST_F ( DiagnosisTest  ,
DiagnosisDataMaintenanceFlagsReflectEntryFlags   
)
Test:
DiagnosisData::has_maintenance_required / demanded reflect entry flags

Definition at line 294 of file test_diagnosis.cpp.

References profinet::diagnosis::ParseDiagnosisBlock(), profinet::wire::PutU16(), and profinet::wire::PutU8().

+ Here is the call graph for this function:

◆ TEST_F() [7/11]

TEST_F ( DiagnosisTest  ,
ParseDiagnosisBlockLocationHeaderUpdatesLocation   
)
Test:
parse_diagnosis_block with API/Slot/Subslot location header updates location

Definition at line 224 of file test_diagnosis.cpp.

References profinet::diagnosis::ParseDiagnosisBlock(), profinet::wire::PutU16(), profinet::wire::PutU32(), and profinet::wire::PutU8().

+ Here is the call graph for this function:

◆ TEST_F() [8/11]

TEST_F ( DiagnosisTest  ,
ParseDiagnosisBlockParsesExtChannelDiagnosisEntry   
)
Test:
parse_diagnosis_block parses ExtChannelDiagnosis entry

Definition at line 192 of file test_diagnosis.cpp.

References profinet::diagnosis::ParseDiagnosisBlock(), profinet::wire::PutU16(), and profinet::wire::PutU8().

+ Here is the call graph for this function:

◆ TEST_F() [9/11]

TEST_F ( DiagnosisTest  ,
ParseDiagnosisBlockParsesSingleChannelDiagnosisEntry   
)
Test:
parse_diagnosis_block parses a single ChannelDiagnosis entry with block header

Definition at line 160 of file test_diagnosis.cpp.

References profinet::diagnosis::ParseDiagnosisBlock(), profinet::wire::PutU16(), and profinet::wire::PutU8().

+ Here is the call graph for this function:

◆ TEST_F() [10/11]

TEST_F ( DiagnosisTest  ,
ParseDiagnosisBlockReturnsEmptyForTooShortData   
)
Test:
parse_diagnosis_block returns empty result for too-short data

Definition at line 253 of file test_diagnosis.cpp.

References profinet::diagnosis::ParseDiagnosisBlock().

+ Here is the call graph for this function:

◆ TEST_F() [11/11]

TEST_F ( DiagnosisTest  ,
ParseDiagnosisSimpleStopsOnZeroFilledSentinelEntry   
)
Test:
parse_diagnosis_simple stops on zero-filled sentinel entry

Definition at line 264 of file test_diagnosis.cpp.

References profinet::diagnosis::ParseDiagnosisSimple(), profinet::wire::PutU16(), and profinet::wire::PutU8().

+ Here is the call graph for this function: