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

Additional unit tests for PROFINET utility helpers. More...

#include <gtest/gtest.h>
#include <array>
#include <chrono>
#include <cstdint>
#include <string>
#include <vector>
#include "profinet/exceptions.h"
#include "profinet/protocol.h"
#include "profinet/udpSocket.h"
#include "profinet/util.h"
+ Include dependency graph for test_utilMore.cpp:

Go to the source code of this file.

Functions

 TEST_F (UtilMoreTests, HexFormattersHandleBoundaries)
 
 TEST_F (UtilMoreTests, ToVecConvertsStringBytes)
 
 TEST_F (UtilMoreTests, ToHexHandlesRawPointerAndEmptyInput)
 
 TEST_F (UtilMoreTests, DecodeBytesPreservesEmbeddedNul)
 
 TEST_F (UtilMoreTests, String2MacAcceptsCanonicalHexDigits)
 
 TEST_F (UtilMoreTests, String2MacRejectsMalformedVariants)
 
 TEST_F (UtilMoreTests, IpConversionHandlesBoundaryAddresses)
 
 TEST_F (UtilMoreTests, String2IpRejectsInvalidLength)
 
 TEST_F (UtilMoreTests, Ip2StringRejectsExtraComponents)
 
 TEST_F (UtilMoreTests, SkipVlanTagsHandlesTruncatedTag)
 
 TEST_F (UtilMoreTests, SkipVlanTagsLeavesOrdinaryEtherTypeUntouched)
 
 TEST_F (UtilMoreTests, SkipVlanTagsHandlesTripleTaggedFrame)
 
 TEST_F (UtilMoreTests, MaxTimeoutRemainingIsPositiveBeforeExpiry)
 
 TEST_F (UtilMoreTests, MaxTimeoutRemainingIsZeroAfterExpiry)
 
 TEST_F (UtilMoreTests, MaxTimeoutHandlesPastDeadline)
 
 TEST_F (UtilMoreTests, GetExecutableDirectoryReturnsExistingDirectory)
 
 TEST_F (UtilMoreTests, GetMacRejectsUnknownInterface)
 
 TEST_F (UtilMoreTests, GetMacReadsLoopbackInterface)
 
 TEST_F (UtilMoreTests, SkipVlanTagsRecognizesSupportedTpids)
 
 TEST_F (UtilMoreTests, SkipVlanTagsStopsAfterSupportedTag)
 
 TEST_F (UtilMoreTests, SkipVlanTagsHandlesShortFrame)
 
 TEST_F (UtilMoreTests, SkipVlanTagsHandlesIncompleteVlanHeader)
 
 TEST_F (UtilMoreTests, String2MacHandlesBoundaryValues)
 
 TEST_F (UtilMoreTests, String2MacRejectsWrongDelimiterPosition)
 
 TEST_F (UtilMoreTests, String2MacRejectsWhitespace)
 
 TEST_F (UtilMoreTests, Mac2StringRejectsInvalidLength)
 
 TEST_F (UtilMoreTests, String2IpHandlesExactAndExtendedInput)
 
 TEST_F (UtilMoreTests, DecodeBytesPreservesNonPaddedData)
 
 TEST_F (UtilMoreTests, DecodeBytesHandlesAllNuls)
 

Detailed Description

Additional unit tests for PROFINET utility helpers.

Covers hexadecimal formatting, byte/vector conversion, VLAN scanning, IPv4 edge cases, decode behavior, timeout remaining-time semantics, and safe move operations for local socket wrappers.

Definition in file test_utilMore.cpp.

Function Documentation

◆ TEST_F() [1/29]

TEST_F ( UtilMoreTests  ,
DecodeBytesHandlesAllNuls   
)
Test:
Verify DecodeBytes reduces an all-zero buffer to an empty string.

Definition at line 289 of file test_utilMore.cpp.

References profinet::DecodeBytes().

+ Here is the call graph for this function:

◆ TEST_F() [2/29]

TEST_F ( UtilMoreTests  ,
DecodeBytesPreservesEmbeddedNul   
)
Test:
Verify DecodeBytes decodes an embedded NUL but removes trailing NUL padding.

Definition at line 66 of file test_utilMore.cpp.

References profinet::DecodeBytes().

+ Here is the call graph for this function:

◆ TEST_F() [3/29]

TEST_F ( UtilMoreTests  ,
DecodeBytesPreservesNonPaddedData   
)
Test:
Verify DecodeBytes preserves data when no trailing NUL exists.

Definition at line 281 of file test_utilMore.cpp.

References profinet::DecodeBytes().

+ Here is the call graph for this function:

◆ TEST_F() [4/29]

TEST_F ( UtilMoreTests  ,
GetExecutableDirectoryReturnsExistingDirectory   
)
Test:
Verify GetExecutableDirectory returns an existing absolute directory.

Definition at line 175 of file test_utilMore.cpp.

References profinet::GetExecutableDirectory().

+ Here is the call graph for this function:

◆ TEST_F() [5/29]

TEST_F ( UtilMoreTests  ,
GetMacReadsLoopbackInterface   
)
Test:
Verify GetMac returns six bytes for the loopback interface.

Definition at line 191 of file test_utilMore.cpp.

References profinet::GetInterfaceMac(), and profinet::macAddressLength.

+ Here is the call graph for this function:

◆ TEST_F() [6/29]

TEST_F ( UtilMoreTests  ,
GetMacRejectsUnknownInterface   
)
Test:
Verify GetMac rejects an interface that does not exist.

Definition at line 185 of file test_utilMore.cpp.

References profinet::GetInterfaceMac().

+ Here is the call graph for this function:

◆ TEST_F() [7/29]

TEST_F ( UtilMoreTests  ,
HexFormattersHandleBoundaries   
)
Test:
Verify hexadecimal formatters preserve leading zeroes and case.

Definition at line 33 of file test_utilMore.cpp.

References profinet::Hex2(), and profinet::Hex4().

+ Here is the call graph for this function:

◆ TEST_F() [8/29]

TEST_F ( UtilMoreTests  ,
Ip2StringRejectsExtraComponents   
)
Test:
Verify Ip2String rejects extra IPv4 components.

Definition at line 105 of file test_utilMore.cpp.

References profinet::Ip2String().

+ Here is the call graph for this function:

◆ TEST_F() [9/29]

TEST_F ( UtilMoreTests  ,
IpConversionHandlesBoundaryAddresses   
)
Test:
Verify IPv4 conversion accepts zero and broadcast addresses.

Definition at line 91 of file test_utilMore.cpp.

References profinet::Ip2String(), and profinet::String2Ip().

+ Here is the call graph for this function:

◆ TEST_F() [10/29]

TEST_F ( UtilMoreTests  ,
Mac2StringRejectsInvalidLength   
)
Test:
Verify Mac2String rejects buffers that are not exactly six bytes.

Definition at line 266 of file test_utilMore.cpp.

References profinet::Mac2String().

+ Here is the call graph for this function:

◆ TEST_F() [11/29]

TEST_F ( UtilMoreTests  ,
MaxTimeoutHandlesPastDeadline   
)
Test:
Verify MaxTimeout reports a near-zero timeout as elapsed when started in the past.

Definition at line 167 of file test_utilMore.cpp.

References profinet::MaxTimeout::TimedOut().

+ Here is the call graph for this function:

◆ TEST_F() [12/29]

TEST_F ( UtilMoreTests  ,
MaxTimeoutRemainingIsPositiveBeforeExpiry   
)
Test:
Verify MaxTimeout::Remaining is positive before expiration.

Definition at line 149 of file test_utilMore.cpp.

References profinet::MaxTimeout::Remaining(), and profinet::MaxTimeout::TimedOut().

+ Here is the call graph for this function:

◆ TEST_F() [13/29]

TEST_F ( UtilMoreTests  ,
MaxTimeoutRemainingIsZeroAfterExpiry   
)
Test:
Verify MaxTimeout::Remaining returns zero after expiration.

Definition at line 158 of file test_utilMore.cpp.

References profinet::MaxTimeout::Remaining(), and profinet::MaxTimeout::TimedOut().

+ Here is the call graph for this function:

◆ TEST_F() [14/29]

TEST_F ( UtilMoreTests  ,
SkipVlanTagsHandlesIncompleteVlanHeader   
)
Test:
Verify SkipVlanTags handles a frame ending exactly at the minimum VLAN header.

Definition at line 233 of file test_utilMore.cpp.

References frame, and profinet::SkipVlanTags().

+ Here is the call graph for this function:

◆ TEST_F() [15/29]

TEST_F ( UtilMoreTests  ,
SkipVlanTagsHandlesShortFrame   
)
Test:
Verify SkipVlanTags returns the Ethernet EtherType offset for an empty frame.

Definition at line 227 of file test_utilMore.cpp.

References profinet::SkipVlanTags().

+ Here is the call graph for this function:

◆ TEST_F() [16/29]

TEST_F ( UtilMoreTests  ,
SkipVlanTagsHandlesTripleTaggedFrame   
)
Test:
Verify SkipVlanTags can walk several stacked VLAN tags.

Definition at line 131 of file test_utilMore.cpp.

References frame, and profinet::SkipVlanTags().

+ Here is the call graph for this function:

◆ TEST_F() [17/29]

TEST_F ( UtilMoreTests  ,
SkipVlanTagsHandlesTruncatedTag   
)
Test:
Verify SkipVlanTags stops safely on truncated VLAN tags.

Definition at line 111 of file test_utilMore.cpp.

References frame, and profinet::SkipVlanTags().

+ Here is the call graph for this function:

◆ TEST_F() [18/29]

TEST_F ( UtilMoreTests  ,
SkipVlanTagsLeavesOrdinaryEtherTypeUntouched   
)
Test:
Verify SkipVlanTags does not skip unrelated EtherTypes.

Definition at line 121 of file test_utilMore.cpp.

References frame, and profinet::SkipVlanTags().

+ Here is the call graph for this function:

◆ TEST_F() [19/29]

TEST_F ( UtilMoreTests  ,
SkipVlanTagsRecognizesSupportedTpids   
)
Test:
Verify SkipVlanTags recognizes each supported VLAN TPID.

Definition at line 198 of file test_utilMore.cpp.

References frame, and profinet::SkipVlanTags().

+ Here is the call graph for this function:

◆ TEST_F() [20/29]

TEST_F ( UtilMoreTests  ,
SkipVlanTagsStopsAfterSupportedTag   
)
Test:
Verify SkipVlanTags stops after a complete VLAN tag followed by a normal EtherType.

Definition at line 216 of file test_utilMore.cpp.

References frame, and profinet::SkipVlanTags().

+ Here is the call graph for this function:

◆ TEST_F() [21/29]

TEST_F ( UtilMoreTests  ,
String2IpHandlesExactAndExtendedInput   
)
Test:
Verify String2Ip accepts exactly four bytes and ignores additional bytes.

Definition at line 273 of file test_utilMore.cpp.

References profinet::String2Ip().

+ Here is the call graph for this function:

◆ TEST_F() [22/29]

TEST_F ( UtilMoreTests  ,
String2IpRejectsInvalidLength   
)
Test:
Verify String2Ip rejects lengths other than four bytes.

Definition at line 98 of file test_utilMore.cpp.

References profinet::String2Ip().

+ Here is the call graph for this function:

◆ TEST_F() [23/29]

TEST_F ( UtilMoreTests  ,
String2MacAcceptsCanonicalHexDigits   
)
Test:
Verify MAC parsing accepts uppercase and mixed separators consistently.

Definition at line 75 of file test_utilMore.cpp.

References profinet::String2Mac().

+ Here is the call graph for this function:

◆ TEST_F() [24/29]

TEST_F ( UtilMoreTests  ,
String2MacHandlesBoundaryValues   
)
Test:
Verify String2Mac accepts all-zero and all-FF MAC addresses.

Definition at line 243 of file test_utilMore.cpp.

References profinet::String2Mac().

+ Here is the call graph for this function:

◆ TEST_F() [25/29]

TEST_F ( UtilMoreTests  ,
String2MacRejectsMalformedVariants   
)
Test:
Verify MAC parsing rejects malformed component counts and lengths.

Definition at line 82 of file test_utilMore.cpp.

References profinet::String2Mac().

+ Here is the call graph for this function:

◆ TEST_F() [26/29]

TEST_F ( UtilMoreTests  ,
String2MacRejectsWhitespace   
)
Test:
Verify String2Mac rejects whitespace and other non-hex characters.

Definition at line 261 of file test_utilMore.cpp.

References profinet::String2Mac().

+ Here is the call graph for this function:

◆ TEST_F() [27/29]

TEST_F ( UtilMoreTests  ,
String2MacRejectsWrongDelimiterPosition   
)
Test:
Verify String2Mac rejects a valid-length address containing a misplaced delimiter.

Definition at line 255 of file test_utilMore.cpp.

References profinet::String2Mac().

+ Here is the call graph for this function:

◆ TEST_F() [28/29]

TEST_F ( UtilMoreTests  ,
ToHexHandlesRawPointerAndEmptyInput   
)
Test:
Verify ToHex handles a raw pointer as well as an empty buffer.

Definition at line 56 of file test_utilMore.cpp.

References profinet::ToHex().

+ Here is the call graph for this function:

◆ TEST_F() [29/29]

TEST_F ( UtilMoreTests  ,
ToVecConvertsStringBytes   
)
Test:
Verify ToVec converts every input character to one byte.

Definition at line 45 of file test_utilMore.cpp.

References profinet::ToVec().

+ Here is the call graph for this function: