Skip to content

Commit

Permalink
added helper tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Norym committed Jul 13, 2020
1 parent 044798c commit 1b75674
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 11 deletions.
48 changes: 42 additions & 6 deletions gtest/helper_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,63 @@
/* Copyright (c) 2020 Project WomoLIN */
/* Author Myron Franze <[email protected]> */

#include "../interface/helper.h"

#include <gtest/gtest.h>

namespace siguni::gtest
{

class CHelperExtractKeyValueTest : public ::testing::Test {};
class CHelperSignalStringsFindFirstCharacter : public ::testing::Test {};

TEST_F( CHelperExtractKeyValueTest, ValidKeyValuePair ) {
// TODO
TEST_F( CHelperSignalStringsFindFirstCharacter, PositionTests ) {

std::string testString = "^OneCaptureByteAtPostion0";
auto pos = helper::CSignalStrings::FindFirstCharacter( testString, '^');
ASSERT_EQ( 0, pos );

pos = helper::CSignalStrings::FindFirstCharacter( testString, '^', 0);
ASSERT_EQ( 0, pos );

testString = ">^OneCaptureByteAtPosition1";
pos = helper::CSignalStrings::FindFirstCharacter( testString, '^');
ASSERT_EQ( 1, pos );

pos = helper::CSignalStrings::FindFirstCharacter( testString, '^', 1);
ASSERT_EQ( 1, pos );

testString = "^Two^CaptureBytes";
pos = helper::CSignalStrings::FindFirstCharacter( testString, '^');
ASSERT_EQ( 0, pos );

// with offset 1, we expect the position of the second pos
pos = helper::CSignalStrings::FindFirstCharacter( testString, '^', 1);
ASSERT_EQ( 4, pos );

testString = "AtEndPosition^";
pos = helper::CSignalStrings::FindFirstCharacter( testString, '^' );
ASSERT_EQ( 13, pos );

testString = "NoCaptureByte";
pos = helper::CSignalStrings::FindFirstCharacter( testString, '^' );
ASSERT_EQ( -1, pos );
}

TEST_F( CHelperExtractKeyValueTest, TwoSeparators ) {
class CHelperSignalStringsFindLastCharacter : public ::testing::Test {};

TEST_F( CHelperSignalStringsFindLastCharacter, PositionTests ) {

// TODO
}

class CHelperGetValueItemsTest : public ::testing::Test {};
class CHelperSignalStringsExtractKeyValue : public ::testing::Test {};

TEST_F( CHelperSignalStringsExtractKeyValue, PositionTests ) {

TEST_F( CHelperGetValueItemsTest, ValidKeyValuePair ) {
// TODO
}




}
2 changes: 0 additions & 2 deletions gtest/protocol_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ TEST_F( CProtocolTest, MessageOverflow ) {
}




TEST_F( CProtocolTest, SendKeyValue ) {

key = "GetSimulationStatus";
Expand Down
2 changes: 0 additions & 2 deletions helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
namespace siguni::helper
{



int CSignalStrings::FindFirstCharacter( const std::string & attSignalMessage,
const char attCharacter,
const size_t attPos )
Expand Down
2 changes: 1 addition & 1 deletion protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace siguni
// remove this message from buffer
messageBuffer = messageBuffer.substr( pos+1 );

// if there are more than one startbytes then delete alle previous startbytes
// if there is more than one start byte, delete all previous start bytes
pos = helper::CSignalStrings::FindLastCharacter( protocolString, STARTBYTE );
if( pos >= 0)
{
Expand Down

0 comments on commit 1b75674

Please sign in to comment.